<!--
	function rollon() 
	{
	  if (window.event.srcElement.className == "Item") 
	  {
	     window.event.srcElement.className = "Highlight";
	  }
	}

	document.onmouseover = rollon;

	function rolloff() 
	{
	  if (window.event.srcElement.className == "Highlight") 
	  {
	     window.event.srcElement.className = "Item";
	  }
	}

	document.onmouseout = rolloff;

	function setFocus() 
	{ 
		window.document.frmpreliminfo.txtfirstname.focus(); 
	}   
	
	
	function appendEmpty(field,s)
	{
		field.value=stripInitialWhitespace(trailingSpaces(field.value));
		if(field.value == "")
		{
			return (s + "\n");
		}
		return "";
	}
	function stripInitialWhitespace (s)
	{   var i = 0;
			
	    while ((i < s.length) && charInString (s.charAt(i), " "))
	       i++;
			    
	    return s.substring (i, s.length);
	}

	function charInString (c, s)
	{   for (i = 0; i < s.length; i++)
	    {   if (s.charAt(i) == c) return true;
	    }
	    return false
	}

	function trailingSpaces(strng)
	{   
		var str;
		str=strng;
		var whitespace1 = " \t\n\r";
		var j = str.length;
		while ((j >0) && charInString(str.charAt(j-1),whitespace1))
		   j--;
				    
		var x=str.substring (0,j);
		return x ;
	}
	
	/* Call this function on change of country so that state and city are filled up*/

	function enablePassport()
	{

//		alert(document.frmpreliminfo.lstCountry.value);
		    document.getElementById("divPassport").style.display='none';
			document.getElementById("divPassportlabel").style.display='none';
			document.getElementById("divDOB").style.display='none';
			document.getElementById("divDOBlabel").style.display='none';
			document.getElementById("GMT").style.display='none';
			
		if (document.frmpreliminfo.lstCountry.value!='IN' && document.frmpreliminfo.lstCountry.value!='0')
		{
			document.getElementById("divDOB").style.display='none';
			document.getElementById("divDOBlabel").style.display='none';
			document.getElementById("divPassport").style.display='';
			document.getElementById("divPassportlabel").style.display=''; 
			document.getElementById("GMT").style.display='';
			//document.getElementById("IST").style.display='none';
		}
		else if(document.frmpreliminfo.lstCountry.value!='0')
		{
			document.getElementById("divPassport").style.display='none';
			document.getElementById("divPassportlabel").style.display='none';
			document.getElementById("divDOB").style.display='';
			document.getElementById("divDOBlabel").style.display='';
			document.getElementById("GMT").style.display='none';
			//document.getElementById("IST").style.display='';			
		}		

	}
	


	function isEmailAddr(email)
	{
	  var result = false
	  var theStr = new String(email)
	  var index = theStr.indexOf("@");
	  if (index > 0)
	  {
	  	var index1=theStr.indexOf("@",index+1)
	  	if (index1<0)
		{
			var pindex = theStr.indexOf(".",index);
			if ((pindex > index+1) && (theStr.length > pindex+1))
				result = true;
		}
	  }

	  return result;
	}
	
	function EmailValidator()
	{
	  if (document.frmpreliminfo.txtemail.value == "")
	  {
	    alert("Personal Email cannot be empty");
	    document.frmpreliminfo.txtemail.focus();
	    return
	  }

	  if (!isEmailAddr(document.frmpreliminfo.txtemail.value))
	  {
	    alert("Enter a complete email address in the form: yourname@yourdomain.com");
	    document.frmpreliminfo.txtemail.focus();
	    return
	  }
	   
	  if (document.frmpreliminfo.txtemail.value.length < 3)
	  {
	    alert("Enter at least 3 characters in the \"email\" field.");
	    document.frmpreliminfo.txtemail.focus();
	    return
	  }
	  return (true);
	}
	
	
	function CheckVal()
	{
		var Str = window.document.frmpreliminfo.txtemail.value;
		var flg
		for (var i=0; i< Str.length; i++)
		{
			if ((Str.charCodeAt(i)>63 && Str.charCodeAt(i)<=90) || (Str.charCodeAt(i)>=97 && Str.charCodeAt(i)<=122) || (Str.charCodeAt(i)>47 && Str.charCodeAt(i)<=57) || (Str.charCodeAt(i)==46) || (Str.charCodeAt(i)==95))
			{
				flg=true
			}
			else
			{
				flg=false
				break;
			}
		}
		return flg;
	}

/*Checks for Characters*/	
	function CheckAlphabets(field)
	{
		var Str = field.value;
		var flg
		for (var i=0; i< Str.length; i++)
		{
			if ((Str.charCodeAt(i)>64 && Str.charCodeAt(i)<=90) || (Str.charCodeAt(i)>=97 && Str.charCodeAt(i)<=122) || (Str.charCodeAt(i)==32))
			{
				flg=true
			}
			else
			{
				flg=false
				break;
			}
		}
		return flg;
	}

	function CheckCode(field)
	{
		var Str = field.value;
		var flg
		
		if (Str.length>0)
		{	
			
			for (var i=0; i< Str.length; i++)
			{
				if ((Str.charCodeAt(i)>47 && Str.charCodeAt(i)<58))
				{
					flg=true
				}
				else
				{
					flg=false
					break;
				}
			}
		}
			return flg;
	}
	
	function CheckPinCode(field)
	{
		var Str = field.value;
		var flg
		
		if (Str.length>0)
		{	
			
			for (var i=0; i< Str.length; i++)
			{
				if ((Str.charCodeAt(i)>47 && Str.charCodeAt(i)<58) || Str.charCodeAt(i)==32)
				{
					flg=true
				}
				else
				{
					flg=false
					break;
				}
			}
		}
			return flg;
	}
	
/* checks for alphanumeric for characters and numbers, and -*/	
	function IsAlphanumeric(field,flggap)
	{
		var Str = field.value;
		var flg
		for (var i=0; i< Str.length; i++)
		{
			if (flggap == 'N')
			{
				if ((Str.charCodeAt(i)>63 && Str.charCodeAt(i)<=90) || (Str.charCodeAt(i)>=97 && Str.charCodeAt(i)<=122) || (Str.charCodeAt(i)>47 && Str.charCodeAt(i)<58) || (Str.charCodeAt(i)==45))
				{
					flg=true
				}
				else
				{
					flg=false
					break;
				}
			}
			else
			{
				if ((Str.charCodeAt(i)>63 && Str.charCodeAt(i)<=90) || (Str.charCodeAt(i)>=97 && Str.charCodeAt(i)<=122) || (Str.charCodeAt(i)>47 && Str.charCodeAt(i)<58) || (Str.charCodeAt(i)==45)  || (Str.charCodeAt(i)==32))
				{
					flg=true
				}
				else
				{
					flg=false
					break;
				}
			}
			
		}
		return flg;
	}
	/* End of check for alphanumeric for characters and numbers*/	
	
/**********Validate Postal Code by the rules*************/
	function ValidatePinCode(field,ruleid)
	{
		
		var err;
		err=""
		
			
		/*****Maximum value length, without gaps******/
		if (ruleid == 1)
		{
			if (IsAlphanumeric(field,'N')==false)
			{
				err = appendError("Zip/Pincode to contain alphabets, numbers, - and should not have spaces")
				//ValidatePinCode = false
			}
		}
		
		/*****Maximum value length, numerical, without gaps****/
		if (ruleid == 2)
		{
			if (CheckCode(field)==false)
			{
				err = err + appendError("Zip/Pincode be numeric and should not have spaces")
				//ValidatePinCode = false
			}
		}
		
		/*****Length to be kept to exactly, without gaps***/
		if (ruleid == 3)
		{
			if (IsAlphanumeric(field,'N') == false)
			{
				err = err + appendError("Zip/Pincode to contain alphabets, numbers, - and should not have spaces")
				//ValidatePinCode = false
			}
			else
			{
				if ((field.value.length<field.maxLength) || (field.value.length>field.maxLength))
				{
					err = err + appendError("Length of Zip/Pincode should be "+field.maxLength+" only");
					//ValidatePinCode = false
				}
			}	///end of else
		}
		
		/******Length to be kept to exactly, numerical, without gaps****/
		if (ruleid == 4)
		{
			if (CheckCode(field)==false)
			{
				err = err + appendError("Zip/Pincode be numeric and should not have spaces")
				//ValidatePinCode = false
			}
			else
			{
				if ((field.value.length<field.maxLength) || (field.value.length>field.maxLength))
				{
					err = err + appendError("Length of Zip/Pincode should be "+field.maxLength+" only");
					//ValidatePinCode = false
				}
			}
		}
		
		/********Maximum value length****/
		
		if (ruleid == 5)
		{
			if (IsAlphanumeric(field,'Y')==false)
			{
				err = err + appendError("Zip/Pincode can either have alphabets,numeric,-, spaces")
				//ValidatePinCode = false
			}
		}
		
		/*****Maximum value length, numerical i.e, with gaps***/
		if (ruleid == 6)
		{
			if (CheckPinCode(field)==false)
			{
				err = err + appendError("Zip/Pincode be numeric and should not have spaces")
				//ValidatePinCode = false
			}
		}
		
		/*************Length to be kept to exactlyi.e, along with - and gaps****/
		
		if (ruleid == 7)
		{
			if (IsAlphanumeric(field,'Y') == false)
			{
				err = err + appendError("Zip/Pincode can either have alphabets,numeric,-, spaces")
				//ValidatePinCode = false
			}
			else
			{
				if ((field.value.length<field.maxLength) || (field.value.length>field.maxLength))
				{
					err = err + appendError("Length of Zip/Pincode should be "+field.maxLength+" only");
					//ValidatePinCode = false
				}
			}	///end of else
		}
		
		/********Length to be kept to exactly, numerical i.e with gaps****/
		if (ruleid == 8)
		{
			if (CheckPinCode(field)==false)
			{
				err = err + appendError("Zip/Pincode can contain numbers or spaces")
				//ValidatePinCode = false
			}
			else
			{
				if ((field.value.length<field.maxLength) || (field.value.length>field.maxLength))
				{
					err = err + appendError("Length of Zip/Pincode should be "+field.maxLength+" only");
					//ValidatePinCode = false
				}
			}
		}
		
		/******Check against country-specific edit format****/
		
		if (ruleid == 9)
		{
			if (IsAlphanumeric(field,'Y') == false)
			{
				err = err + appendError("Zip/Pincode can either have alphabets,numeric,-, spaces")
				//ValidatePinCode = false
			}
			else
			{
				field.maxLength = 7
			}	///end of else
		}
		
		if (err.length!=0)
		{
			window.alert(err)
			return false
		}
		else
		{
			return true
		}
		
	}	//End of function
	
	function submitform()
	{
		var err;
		var arr=new Array();
		var str=new String();
		var flg;

		err = "";
		
			err = appendEmpty(document.frmpreliminfo.txtfirstname,"First name cannot be empty");
			if (CheckAlphabets(document.frmpreliminfo.txtfirstname)==false)
				err=err+appendError("First Name should be in characters");
		
		
		document.frmpreliminfo.txtmiddlename.value=stripInitialWhitespace(trailingSpaces(document.frmpreliminfo.txtmiddlename.value))
		
		if(document.frmpreliminfo.txtmiddlename.value.length > 0)
		{
			if (CheckAlphabets(document.frmpreliminfo.txtmiddlename)==false)
				err=err+appendError("Middle Name should be in characters");
		}
		
		err = err + appendEmpty(document.frmpreliminfo.txtlastname,"Last name cannot be empty");
		if (CheckAlphabets(document.frmpreliminfo.txtlastname)==false)
			err=err+appendError("Last Name should be in characters");
		
		//Validate for Country before DOB. Suggested by Bhavani. For US dob should not be asked.
		err = err + appendLstEmpty(document.frmpreliminfo.lstCountry,"Select country");
		
		if (document.frmpreliminfo.lstCountry.value != 'IN')
		err = err + appendEmpty(document.frmpreliminfo.txtpassport,"Passport field cannot be empty");

		if (isValidDate(document.frmpreliminfo.lstday.value,document.frmpreliminfo.lstMonth.value,document.frmpreliminfo.lstyear.value)==false)
			err = err + appendError("Date of birth should be less than current date");
		
		if (err.length==0)
		{			
			if (CheckVal()==false)
			{
				alert("Email field should have characters or numbers or @ or _ or . \n Only one Email Id should be entered")
				return
			}
				if (EmailValidator()==true)
				{
					
					//if it exists it returns true
					//Updated on 19th Sep 2003
					//alert(document.frmpreliminfo.txtemail.value)
					if (CheckSatyamMail(document.frmpreliminfo.txtemail.value)==true)
					{
						alert("Satyam email id. not allowed");
						return false;
					}					
					flg=true;
				}
				else
				{
					flg=false;
				} 


		if (document.frmpreliminfo.txtCtryPhoneCode.value.length != 0)
		{
			if (CheckCode(document.frmpreliminfo.txtCtryPhoneCode)==false)
			{
				err = err + appendError("Country code should be numeric");
				alert(err);
				return false;
			}
		}

if (flg==true)
			{
				
				if ((CheckCode(document.frmpreliminfo.txtareacode)==false) || (CheckCode(document.frmpreliminfo.txttelcode1)==false))
					err = err + appendError("Home phone should be numeric");
					
				if (CheckCode(document.frmpreliminfo.txtmobile)==false) 
					err = err + appendError("Mobile phone should be numeric");
					
				
		err = appendEmpty(document.frmpreliminfo.lstCity,"City cannot be empty");
			if (CheckAlphabets(document.frmpreliminfo.lstCity)==false)
				err=err+appendError("City should be in characters");

							err = err + appendEmpty(document.frmpreliminfo.txtstreet,"House number cannot be empty");
				
if (err.length==0)
{					
	if (document.frmpreliminfo.txtpincode.value != "")
	{
		if (!ValidatePinCode(document.frmpreliminfo.txtpincode, document.frmpreliminfo.txtRuleId.value))
			return false;
	}
}

if (err.length==0)
{			
				err = err + appendEmpty(document.frmpreliminfo.txtresume,"Resume cannot be empty");
}
				
				if (err.length == 0)
				{
					document.frmpreliminfo.btnsubmit.disabled=true;
					document.frmpreliminfo.btnreset.disabled=true;					
					
					document.frmpreliminfo.hiddenCountry.value = document.frmpreliminfo.lstCountry.value;
					document.frmpreliminfo.hiddenState.value = document.frmpreliminfo.lstState.value;
					document.frmpreliminfo.hiddenCity.value = document.frmpreliminfo.lstCity.value;
					
					document.frmpreliminfo.txtCtryPhoneCode.disabled = false;

					document.frmpreliminfo.submit();

				}
				else
				{
					window.alert(err);
					return false;
				}
			}
		}
		else
		{
			window.alert(err);
			return;
		}
	}
  //-->
