function IsValid()
{
	
	//do not validate if internal user
	if (document.frmMain.hidUserType.value != "H") {

		//validate firstname, lastname
  		if (IsNullShowAlertSetFocus (document.frmMain.txtFirstName, "Please enter your first name.", true)) return;
	  	if (IsNullShowAlertSetFocus (document.frmMain.txtLastName, "Please enter your last name.", true)) return;
		
		//validate email address
		strTemp = document.frmMain.txtEmail.value
		if (!GenIsValidEmail(strTemp, strTemp))
		{
			document.frmMain.txtEmail.focus();
			return;
		}			
			
		//validate home phone number if provided
		if (document.frmMain.txtHomePhone.value.length != 0) {
			if (!checkPhone(document.frmMain.txtHomePhone.value)) {
				alert("The home phone number entered is not valid.  Please enter a valid phone number in the format (614) 555-1234.");
				document.frmMain.txtHomePhone.focus();
				return;
			}
			else {
				document.frmMain.txtHomePhone.value = formatPhone(document.frmMain.txtHomePhone.value);					
			}			
		}
		else {
			alert("You must provide your home phone number.");	
			document.frmMain.txtHomePhone.focus();
			return;
		}

		//validate mobile number if provided
		if (document.frmMain.txtMobilePhone.value != "") {
			if (!checkPhone(document.frmMain.txtMobilePhone.value)) {
				alert("The mobile phone number entered is not valid.  Please enter a valid phone number in the format (614) 555-1234.");
				document.frmMain.txtMobilePhone.focus();
				return;
			}
			else if (document.frmMain.txtMobilePhone.value.length != 0) {
				document.frmMain.txtMobilePhone.value = formatPhone(document.frmMain.txtMobilePhone.value);
			}
		}
		//validate work phone number if provided
		if (document.frmMain.txtWorkPhone.value != "") {
			if (!checkPhone(document.frmMain.txtWorkPhone.value)) {
				alert("The work phone number entered is not valid.  Please enter a valid phone number in the format (614) 555-1234.");
				document.frmMain.txtWorkPhone.focus();
				return;
			}
			else if (document.frmMain.txtWorkPhone.value.length != 0) {
				document.frmMain.txtWorkPhone.value = formatPhone(document.frmMain.txtWorkPhone.value);
			}
		}

		//valdate address, city
		if (IsNullShowAlertSetFocus (document.frmMain.txtAddress1, "Please enter your home address.", true)) return;
		if (IsNullShowAlertSetFocus (document.frmMain.txtCity, "Please enter your city.", true)) return;
		
		//validate state
		if (document.frmMain.ddlState[document.frmMain.ddlState.selectedIndex].value == "")
		{
			alert("Please enter your state.");
			return;
		}		
		
		//validate zipcode
		if (IsNullShowAlertSetFocus (document.frmMain.txtZipCode, "Please enter your zipcode.", true)) return;
			
		//make sure preferred method of contact matches data provided
		if (document.frmMain.ddlPreferredContactMethod[document.frmMain.ddlPreferredContactMethod.selectedIndex].value == "HOME")
		{
			if (document.frmMain.txtHomePhone.value.length <= 0)
			{
			alert("You have indicated that your preferred method of contact is at home but you did not provide a home phone number.");	
			document.frmMain.txtHomePhone.focus();
			return;
			}				
		}				

		if (document.frmMain.ddlPreferredContactMethod[document.frmMain.ddlPreferredContactMethod.selectedIndex].value == "WORK")
		{
			if (document.frmMain.txtWorkPhone.value.length <= 0)
			{
			alert("You have indicated that your preferred method of contact is at work but you did not provide a work phone number.");	
			document.frmMain.txtWorkPhone.focus();			
			return;
			}			
		}	
				
		if (document.frmMain.ddlPreferredContactMethod[document.frmMain.ddlPreferredContactMethod.selectedIndex].value == "MOBL")
		{
			if (document.frmMain.txtMobilePhone.value.length <= 0)
			{
			alert("You have indicated that your preferred method of contact is on your mobile phone but you did not provide a mobile phone number.");	
			document.frmMain.txtMobilePhone.focus();			
			return;
			}				
		}
	}

	if (document.frmMain.ddlPreferredContactMethod.selectedIndex == 0) {
		alert("You must specify your preferred contact method.");
		document.frmMain.ddlPreferredContactMethod.focus();
		return;	
	}
					
	//Check form before submitting
	document.frmMain.hidDoIt.value = "S";
	document.frmMain.submit();			
}


function openwindow(Link)
{
window.open(Link)
}
