function checkFH(theForm) {
	if (theForm.FH_Name.value == "") {
		alert("Please enter the name of the funeral home.");
		theForm.FH_Name.focus();
		return false;
	}
	if (theForm.otherCountry.options[0].selected && (theForm.province.options[0].selected || theForm.province.options[14].selected)) { 
			alert("Please fill in your province (Canada or US)\n or country (other than Canada or US)."); 
			return false; 
		} 
	if (theForm.city != null && theForm.city.value == "") {
		alert("Please enter the city.");
		theForm.city.focus();
		return false;
	}
	if (theForm.Address != null && theForm.Address.value == "") {
		alert("Please enter your address.");
		return false;
	}
	/*if ((theForm.country[0].checked || theForm.country[1].checked) && theForm.postalCode.value != "") {
		if(theForm.country[0].checked) {
			regExpPattern = /[a-zA-Z][0-9][a-zA-Z]\-{0,1}\s*[0-9][a-zA-Z][0-9]/;
		}
		else if (theForm.country[1].checked) {
			regExpPattern = /\d{5}\-{0,1}\d;
		}
		if (!regExpPattern.exec(theForm.postalCode.value)) {
			alert("Please enter a valid Postal/Zip code");
			return false;
		}
	}*/
	if (theForm.postalCode.value != "") {
		
		if (!validatePostalCode(theForm,theForm.postalCode.value)){
			alert("Invalid postal code");
			return false;
		}
	}
	//check phone if canada/US
		if(theForm.province.options[theForm.province.options.selectedIndex].value != "") {
	if ((theForm.area != null && theForm.area.value == "") || (theForm.phonePart1 != null && theForm.phonePart1.value == "") || (theForm.phonePart2 != null &&theForm.phonePart2.value == "")) {
		alert("Please enter the phone number.");
		return false;
	}
	else if (theForm.area != null && theForm.area.value != "" && theForm.phonePart1.value != "" && theForm.phonePart2.value != "") {
		phoneNumber = theForm.area.value + theForm.phonePart1.value + theForm.phonePart2.value;
		if(phoneNumber.replace(" ","").length < 10 || isNaN(phoneNumber)) {
			alert("Please enter your a valid phone number.");
			return false;
		}
	}
	else if (theForm.phone != null && theForm.phone.value == "") {
		alert("Please enter the phone number.");
		return false;
	}
	
	else if (theForm.phone != null && theForm.phone.value != ""){
		if(isNaN(theForm.phone.value.replace(" ","").replace("-",""))){
			alert("Please enter a valid phone number.");
			return false;
		}
	
			if(theForm.phone.length < 10) {
				alert("Please enter a valid phone number including an area code.");
			}
		
	}
	}
	if (theForm.email.value != "") {
		regExpPattern = "(^\.+[@]\.+[.])(ca$|org$|net$|com$)";
		objRegExp = new RegExp(regExpPattern,"i");
		if (!objRegExp.test(theForm.email.value)) {
			alert("Please enter a valid email address");
			return false;
		}
	}
	if (theForm.username != null && theForm.username.value != "") {
		if (theForm.password.value == "" || theForm.password1.value == "") {
			alert("Please enter your password.");
			return false;
		}
		if (theForm.password.value != theForm.password1.value) {
			alert("The passwords you entered are not match.");
			return false;
		}
	}
	if (theForm.password && theForm.password.value != "" && theForm.username.value == "") {
		alert("Please enter your user name.");
		return false;
	}
	return true;
}

function checkFHwithDir(theForm) {
	if (checkFH(theForm)){
		if (theForm.dfn.value == "" || theForm.dln.value == "") {
			alert("Please enter the contact name.");
			return false;
		}
		return true;
	}
	else 
		return false;
}

	
function validatePostalCode(thisform,code) {
		i = thisform.province.options[thisform.province.options.selectedIndex].value;
	
		index = i.indexOf("|")+ 1;
		if (i.charAt(index) == 1){
			regExpPattern = /[a-zA-Z][0-9][a-zA-Z]\-{0,1}\s*[0-9][a-zA-Z][0-9]/;
		}
		else if (i.charAt(index) == 2){
			regExpPattern = /\d{5}\-{0,1}\d*/;
		}
	//objRegExp = new RegExp(regExpPattern);
		if (!regExpPattern.exec(code)) {
			return false;
		}
		return true;
}