// JavaScript Document

function returnfalse(obj){
	obj.focus();
	return false;
}

function submitForm(RegiForm)
{
	//email id validation
	if(checkEmailField(RegiForm.txtEmail)==false)
	{
		//alert("Please enter email in valid format");
		RegiForm.txtEmail.focus();
		return false;		
	}
	
	//security question validation
	/*if(RegiForm.lstSecurityQuestion.selectedIndex==0)
	{
		alert("Please select security question");
		RegiForm.lstSecurityQuestion.focus();
		return false;
	}
	*/
	
	//security answer validation
	if(hasFieldOnlySpaces(RegiForm.txtSecurityAnswer)==false || isFieldEmpty(RegiForm.txtSecurityAnswer)==false)
	{
		alert("Please enter securiy answer");
		RegiForm.txtSecurityAnswer.focus();
		return false;
	}
	if(isFieldAlphanumericSpace(RegiForm.txtSecurityAnswer)==false) return returnfalse(RegiForm.txtSecurityAnswer);
	
	//firstname validation
	if(hasFieldOnlySpaces(RegiForm.txtFirstName)==false || isFieldEmpty(RegiForm.txtFirstName)==false)
	{
		alert("Please enter first name");
		RegiForm.txtFirstName.focus();
		return false;
	}
	if(isFieldAlpha(RegiForm.txtFirstName)==false) return returnfalse(RegiForm.txtFirstName);
	
	//lastname validation
	if(hasFieldOnlySpaces(RegiForm.txtLastName)==false || isFieldEmpty(RegiForm.txtLastName)==false)
	{
		alert("Please enter last name");
		RegiForm.txtLastName.focus();
		return false;
	}	
	if(isFieldAlpha(RegiForm.txtLastName)==false) return returnfalse(RegiForm.txtLastName);

	//company name validation
	if(hasFieldOnlySpaces(RegiForm.txtCompanyName)==false || isFieldEmpty(RegiForm.txtCompanyName)==false)
	{
		alert("Please enter company name");
		RegiForm.txtCompanyName.focus();
		return false;
	}	
	
	//address validation
	if(hasFieldOnlySpaces(RegiForm.txtAddress)==false || isFieldEmpty(RegiForm.txtAddress)==false)
	{
		alert("Please enter address");
		RegiForm.txtAddress.focus();
		return false;
	}	
	
	//city validation
	if(hasFieldOnlySpaces(RegiForm.txtCity)==false || isFieldEmpty(RegiForm.txtCity)==false)
	{
		alert("Please enter city");
		RegiForm.txtCity.focus();
		return false;
	}
	if(isFieldAlphaSpace(RegiForm.txtCity)==false) return returnfalse(RegiForm.txtCity);
	
	//state validation
	if(hasFieldOnlySpaces(RegiForm.txtState)==false || isFieldEmpty(RegiForm.txtState)==false)
	{
		alert("Please enter state");
		RegiForm.txtState.focus();
		return false;
	}
	if(isFieldAlphaSpace(RegiForm.txtState)==false) return returnfalse(RegiForm.txtState);
/*	if(RegiForm.txtState.selectedIndex==0)
	{
		alert("Please select state");
		RegiForm.txtState.focus();
		return false;
	}
*/
	//country validation
	if(hasFieldOnlySpaces(RegiForm.txtCountry)==false || isFieldEmpty(RegiForm.txtCountry)==false)
	{
		alert("Please enter country");
		RegiForm.txtCountry.focus();
		return false;
	}
	if(isFieldAlphaSpace(RegiForm.txtCountry)==false) return returnfalse(RegiForm.txtCountry);
	
	//zip validation
	if(hasFieldOnlySpaces(RegiForm.txtZip)==false || isFieldEmpty(RegiForm.txtZip)==false)
	{
		alert("Please enter zip");
		RegiForm.txtZip.focus();
		return false;
	}	
	if(isFieldAlphanumericSpace(RegiForm.txtZip)==false) return returnfalse(RegiForm.txtZip);

	return true;
}
