function validate_Email(strEmail)
{
	//var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
	var emailPat = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;

	var matchArray = strEmail.match(emailPat);
	if (matchArray == null)
	{
		alert ("Invalid Email Address! Example: someone@somewhere.com");
		//document.formall.email.focus();
		return false;
	}
	return true;
}
function validate_AgentEmail(strEmail)
{
	var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
	var matchArray = strEmail.match(emailPat);
	if (matchArray == null)
	{
		alert ("Invalid Email Address! Example: someone@somewhere.com");
		document.formall.Agentemail.focus();
		return false;
	}
	return true;
}
function validate_InsuredEmail(strEmail)
{
	var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
	var matchArray = strEmail.match(emailPat);
	if (matchArray == null)
	{
		alert ("Invalid Insured Email Address! Example: someone@somewhere.com");
		document.formall.Insuredemail.focus();
		return false;
	}
	return true;
}
function validate_Num(strNum)
{
	var numPat = /^-?\d+$/;
	var matchArray = strNum.match(numPat);
	if (matchArray == null)
		return false;

	return true;
}

function validate_CommaNum(strNum)
{
//if (strNum > 0) {
	var numPat = /^(\d?\d?\d(,\d\d\d)*|\d?\d?\d(,\d\d\d)*.\d\d?)$/;
	var matchArray = strNum.match(numPat);
	if (matchArray != null)
		return true;

	var numPat=/^(\d+|\d+.\d\d?)$/;
	var matchArray = strNum.match(numPat);
	if (matchArray != null)
		return true;
	return false;
	//}
return true;
}

function validate_NumMin(strNum, iMin)
{
	var numPat = /^-?\d+$/;
	var matchArray = strNum.match(numPat);
	if (matchArray == null)
		return false;
	
	if( iMin > parseInt(strNum))
		return false;

	return true;
}

function validate_PosFloat(strNum)
{
	var numPat=/^(\d+|\d+.\d\d?)$/;
	var matchArray = strNum.match(numPat);
	if (matchArray == null)
		return false;
	return true;
}

function validate_NumMax(strNum, iMax)
{
	var numPat = /^-?\d+$/;
	var matchArray = strNum.match(numPat);
	if (matchArray == null)
		return false;

	if(parseInt(strNum) > iMax)
		return false;

	return true;
}

function validate_NumMinMax(strNum, iMin, iMax)
{
	var numPat = /^-?\d+$/;
	var matchArray = strNum.match(numPat);
	if (matchArray == null)
		return false;
	
	if((parseInt(strNum) < iMin)  || (parseInt(strNum) > iMax))
		return false;

	return true;
}

function validate_StrLength(str, iMinLength)
{
	if (iMinLength > str.length)
		return false;

	return true;
}

function validate_InsuredCode(strCode)
{
	var strPat = /^[A-Za-z][A-Za-z][A-Za-z]\d\d\d\d\d$/;
	var matchArray = strCode.match(strPat);
	if (matchArray == null)
	{
		alert ("Invalid Insured Code. Example: ABC12345");
		return false;
	}

	return true;
}

function validate_JobCode(strCode)
{
	var strPat = /^\d\d\d\d\d\d+$/;
	var matchArray = strCode.match(strPat);
	if (matchArray == null)
	{
		alert ("Invalid Job Code. Example: 123456");
		return false;
	}

	return true;
}


function validate_CertHolderCode(strCode)
{
	var strPat = /^[A-Za-z][A-Za-z][A-Za-z]\d\d\d\d\d$/;
	var matchArray = strCode.match(strPat);
	if (matchArray == null)
	{
		alert ("Invalid Cert Holder Code. Example: ABC12345");
		return false;
	}

	return true;
}

function validate_AgentLicense(strLic)
{
	var strPat = /^[A-Za-z0-9]+$/;
	var matchArray = strLic.match(strPat);
	if (matchArray == null)
	{
		alert ("Invalid Agent License. Example: Sv443Gd9F");
		//document.formall.license.focus();
		return false;
	}

	return true;
}

function validate_AgentName(strName)
{
	var strPat = /^.+ .+$/;
	var matchArray = strName.match(strPat);
	if (matchArray == null)
	{
		alert ("Invalid Agent Contact Name. Example: John Smith");
		//document.formall.AgentcontactName.focus();
		return false;
	}
	return true;
}
function validate_InsuredName(strName)
{
	var strPat = /^.+ .+$/;
	var matchArray = strName.match(strPat);
	if (matchArray == null)
	{
		alert ("Invalid Insured Name. Example: John Smith");
		document.formall.InsuredcontactName.focus();
		return false;
	}
	return true;
}
function validate_Name(strName)
{
	var strPat = /^.+ .+$/;
	var matchArray = strName.match(strPat);
	if (matchArray == null)
	{
		alert ("Invalid Name. Example: John Smith");
		document.formall.contactName.focus();
		return false;
	}
	return true;
}

function validate_State(strState)
{
	var strPat = /^[A-Za-z][A-Za-z]$/;
	var matchArray = strState.match(strPat);
	if (matchArray == null)
	{
		alert ("Invalid State Code. Example: CA");
		return false;
	}
	return true;
}
function validate_AgentState(strState)
{
	var strPat = /^[A-Za-z][A-Za-z]$/;
	var matchArray = strState.match(strPat);
	if (matchArray == null)
	{
		alert ("Invalid State Code. Example: CA");
		document.formall.Agentstate.focus();
		return false;
	}
	return true;
}
function validate_InsuredState(strState)
{
	var strPat = /^[A-Za-z][A-Za-z]$/;
	var matchArray = strState.match(strPat);
	if (matchArray == null)
	{
		alert ("Invalid Insured State Code. Example: CA");
		document.formall.Insuredstate.focus();
		return false;
	}
	return true;
}
function validate_ZIP(strZIP)
{
	var strPat = /^\d\d\d\d\d$/;
	var matchArray = strZIP.match(strPat);
	if (matchArray == null)
	{
		alert ("Invalid ZIP Code. Example: 12345");
		return false;
	}
	return true;
}
function validate_AgentZIP(strZIP)
{
	var strPat = /^\d\d\d\d\d$/;
	var matchArray = strZIP.match(strPat);
	if (matchArray == null)
	{
		alert ("Invalid ZIP Code. Example: 12345");
		document.formall.Agentzip.focus();
		return false;
	}
	return true;
}
function validate_InsuredZIP(strZIP)
{
	var strPat = /^\d\d\d\d\d$/;
	var matchArray = strZIP.match(strPat);
	if (matchArray == null)
	{
		alert ("Invalid Insured ZIP Code. Example: 12345");
		document.formall.Insuredzip.focus();
		return false;
	}
	return true;
}
function validate_Phone(strPhone)
{
	var strPat = /^\d\d\d(-|)?\d\d\d(-|)?\d\d\d\d$/;
	var matchArray = strPhone.match(strPat);
	if (matchArray == null)
	{
		alert ("Invalid Phone Number. Example: 123-555-1212");
		return false;
	}
	return true;
}
function validate_AgentPhone(strPhone)
{
	var strPat = /^\d\d\d(-|)?\d\d\d(-|)?\d\d\d\d$/;
	var matchArray = strPhone.match(strPat);
	if (matchArray == null)
	{
		alert ("Invalid Phone Number. Example: 123-555-1212");
		return false;
	}
	return true;
}
function validate_InsuredPhone(strPhone)
{
	var strPat = /^\d\d\d(-|)?\d\d\d(-|)?\d\d\d\d$/;
	var matchArray = strPhone.match(strPat);
	if (matchArray == null)
	{
		alert ("Invalid Insured Phone Number. Example: 123-555-1212");
		document.formall.Insuredphone.focus();
		return false;
	}
	return true;
}
function validate_Username(strUsername)
{
	var strPat = /^[A-Za-z]+([A-Za-z]|\d|_)*$/;
	var matchArray = strUsername.match(strPat);
	if (matchArray == null || strUsername.length<4)
	{
		alert ("Invalid Username! Should start with an alphabet, only Alphanumeric and Underscore characters are valid, and should be at least 4 characters.");
		return false;
	}

	return true;
}

function validate_Password(strPass1, strPass2)
{
	if (strPass1 != strPass2)
	{
		alert ("Passwords do not match!");
		return false;
	}
	if (strPass1.length <5)
	{
		alert ("Password should be at least 5 characters long.");
		return false;
	}
 	return true;
}

function validate_TaxID(strTaxID)
{
	var strPat = /^\d\d-\d\d\d\d\d\d\d\d$/;
	var matchArray = strTaxID.match(strPat);
	if (matchArray == null)
		return false;

	return true;	
}

function validate_SSN(strSSN)
{
	var strPat = /^\d\d\d-\d\d-\d\d\d\d$/;
	var matchArray = strSSN.match(strPat);
	if (matchArray == null)
		return false;

	return true;	
}

function validate_DLNum(strDLNum)
{
	var strPat = /^[A-Za-z]\d\d\d\d\d\d\d$/;
	var matchArray = strDLNum.match(strPat);
	if (matchArray == null)
	{
		alert ("Invalid Driver License Number! Example: A1234567");
		return false;
	}
	
	return true;
}

function validate_Date(strDate)
{
	var strPat = /^\d?\d(-|\/)\d?\d(-|\/)\d\d\d\d$/;
	var matchArray = strDate.match(strPat);
	if (matchArray == null)
	{
		//alert ("Invalid Date. Use mm/dd/yy format.");
		return false;
	}
	
	return true;
}

function validate_Policy(strPol)
{
	var strPat = /^([A-Z]|[0-9]|-)+$/;
	
	var matchArray = strPol.match(strPat);
	if (matchArray == null)
	{
		//alert ("Invalid Policy. Example: GU01698X023502");
		return false;
	}
	
	return true;
}
