// Define Form Object
var obj
obj = "document.form1."


//Common Validate Function to Check Blank Values
function validate(arrFields)
{
	var FieldsArr = arrFields.split(",");
	var arrLen = FieldsArr.length;
	returnStr = "";
	
	for (i=0;i<arrLen;i++)
	{
		indFields = FieldsArr[i].split(":");
		if(eval(obj+indFields[0]+".value")=="")
		{
			returnStr = FieldsArr[i];
			break;
		}
	}
	return returnStr;
}

function toggle_img(imgVal,titleval,strserverName)
{

imgVal = strserverName + "/images/units/"+imgVal;
//prompt(imgVal)
eval(obj+"txtImg1.value=titleval");
eval(obj+"img1.src=imgVal")
}

//function to check email
function chkEmail(strEmail)
{
	if(eval(obj+strEmail+".value").indexOf("@")< 1 || eval(obj+strEmail+".value").indexOf(".")< 1 || eval(obj+strEmail+".value").length < 5)
		return false;
	else
		return true;	
} 

//Function to Check Login Characters
function chkLogin(strLogin)
{
	blnflag = true;
	strLen = strLogin.length;
	for(i=0;i<strLen;i++)
	{
		theChar="";
		theChar=strLogin.substring(i,i+1)
		theChar=theChar.toLowerCase();
		if((theChar < "0" || theChar > "9") && (theChar < "a" || theChar > "z") && (theChar!="_"))
		{
			blnflag = false;
			break;
		}
	}
	return blnflag;
}
function validate_contact()
{
arrFlds = "txtname:Name,txtemail:Email,txtph:Phone";
	errMsg = validate(arrFlds);
	
	if (errMsg!="")
	{
		indFields = errMsg.split(":");
		alert(indFields[1] + " cannot be Blank!");
		eval(obj+indFields[0]+".focus()");
		return false;
	}
	else if(!chkEmail("txtemail"))
	{
		alert("Invalid Email Format ! Should be in somename@hostname.com");
		eval(obj+"txtemail.focus()");
		eval(obj+"txtemail.select()");
		return false;
	}

}
//Function to Check Equality 
function chkEquality(firstVal,secondVal)
{
	if (eval(obj+firstVal+".value")!=eval(obj+secondVal+".value"))
		return false;
	else
		return true;	
}

function keywordSearch()
{
	if (document.form1.txtKeywords.value=="")
	{
		alert("Please enter some value for Search !!")
		document.form1.txtKeywords.focus()
	}
	else if (document.form1.txtKeywords.value.length < 2)
	{
		alert("Please enter Minimum 2-Letter word for Search !!")
		document.form1.txtKeywords.focus()
		document.form1.txtKeywords.select()
	}
	else
		form1.submit();
}
