
function validateContactForm(form){
	var alertMsg = "Please enter data for the following missing fields:\n\n"
	//alert("hello");
	if(contactUs.frmFirstName.value==""){
		alertMsg = alertMsg + "  First Name: \n"
	}
	if(contactUs.frmLastName.value==""){
		alertMsg = alertMsg + "  Last Name: \n"
	}	
	if(contactUs.frmPhone.value==""){
		alertMsg = alertMsg + "  Phone Number: \n"
	}
	if(contactUs.frmSchoolName.value==""){
		alertMsg = alertMsg + "  School Name: \n"
	}
	if(contactUs.frmSchoolCity.value==""){
		alertMsg = alertMsg + "  School City: \n"
	}
	if(contactUs.frmSchoolState.value==""){
		alertMsg = alertMsg + "  School State: \n"
	}
	if(contactUs.frmComments.value==""){
		alertMsg = alertMsg + "  Your Message: \n"
	}	
	
	//validate email address
	var emailID=contactUs.frmEmailAddress
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email Address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	//if(contactUs.frmEmailAddress.value==""){
	//	alertMsg = alertMsg + "  Email Address: \n"
	//}
	if (alertMsg == "Please enter data for the following missing fields:\n\n"){
		return true;
	} 	
	else {
		alert(alertMsg);
		return false;
	}
}

function validateRequestInfoForm(form){
	var alertMsg = "Please enter data for the following missing fields:\n\n"
	
	if(requestInfo.frmChurchName.value==""){
		alertMsg = alertMsg + "  First Name: \n"
	}
	if(requestInfo.frmContactName.value==""){
		alertMsg = alertMsg + "  Contact Name: \n"
	}
	//validate email address
	var emailID=requestInfo.frmEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email Address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	//if(requestInfo.frmEmail.value==""){
	//	alertMsg = alertMsg + "  Email Address: \n"
	//}
	if(requestInfo.frmAddress1.value==""){
		alertMsg = alertMsg + "  Address: \n"
	}
	if(requestInfo.frmCity.value==""){
		alertMsg = alertMsg + "  City: \n"
	}
	if(requestInfo.stateSelect.value==""){
		alertMsg = alertMsg + "  State: \n"
	}
	if(requestInfo.frmZip.value==""){
		alertMsg = alertMsg + "  Zip Code: \n"
	}
	if (alertMsg == "Please enter data for the following missing fields:\n\n"){
		return true;
	} 	
	else {
		alert(alertMsg);
		return false;
	}
}

function validateCityState(form){
	var alertMsg = "Please enter data for the following missing fields:\n\n"

	if(form.txtCity.value==""){
		alertMsg = alertMsg + "  School City: \n"
	}	
	if (alertMsg == "Please enter data for the following missing fields:\n\n"){
		return true;
	} 	
	else {
		alert(alertMsg);
		return false;
	}
}

function validatePortraitContactForm(form){
	var alertMsg = "Please enter data for the following missing fields:\n\n"
	//alert("hello");
	if(InfoRequest.frmFirstName.value==""){
		alertMsg = alertMsg + "  First Name: \n"
	}
	if(InfoRequest.frmLastName.value==""){
		alertMsg = alertMsg + "  Last Name: \n"
	}	
	if(InfoRequest.frmPhone.value==""){
		alertMsg = alertMsg + "  Phone Number: \n"
	}	
	if(InfoRequest.frmSchoolName.value==""){
		alertMsg = alertMsg + "  School Name: \n"
	}	
	
	if(InfoRequest.frmSchoolCity.value==""){
		alertMsg = alertMsg + "  School City: \n"
	}
	
	if(InfoRequest.frmSchoolState.value==""){
		alertMsg = alertMsg + "  School State: \n"
	}	
	
	if(InfoRequest.frmProgram.value==""){
		alertMsg = alertMsg + "  Portrait Program: \n"
	}
	
	if(InfoRequest.frmComments.value==""){
		alertMsg = alertMsg + "  Your Message: \n"
	}		
	
	//validate email address
	var emailID=InfoRequest.frmEmailAddress
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email Address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	
	if (alertMsg == "Please enter data for the following missing fields:\n\n"){
		return true;
	} 	
	else {
		alert(alertMsg);
		return false;
	}
}

function validateGeneralPortraitContactForm(form){
	var alertMsg = "Please enter data for the following missing fields:\n\n"
	//alert("hello");
	if(generalInfoRequest.frmFirstName.value==""){
		alertMsg = alertMsg + "  First Name: \n"
	}
	if(generalInfoRequest.frmLastName.value==""){
		alertMsg = alertMsg + "  Last Name: \n"
	}	
	if(generalInfoRequest.frmPhone.value==""){
		alertMsg = alertMsg + "  Phone Number: \n"
	}	
	if(generalInfoRequest.frmTitle.value==""){
		alertMsg = alertMsg + "  Title: \n"
	}
	if(generalInfoRequest.frmPhone.value==""){
		alertMsg = alertMsg + "  Phone Number: \n"
	}
	if(generalInfoRequest.frmSchoolName.value==""){
		alertMsg = alertMsg + "  School Name: \n"
	}	
	
	if(generalInfoRequest.frmSchoolCity.value==""){
		alertMsg = alertMsg + "  School City: \n"
	}
	
	if(generalInfoRequest.frmSchoolState.value==""){
		alertMsg = alertMsg + "  School State: \n"
	}	
	
	if(generalInfoRequest.frmComments.value==""){
		alertMsg = alertMsg + "  Your Message: \n"
	}		
	
	//validate email address
	var emailID=generalInfoRequest.frmEmailAddress
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email Address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	
	if (alertMsg == "Please enter data for the following missing fields:\n\n"){
		return true;
	} 	
	else {
		alert(alertMsg);
		return false;
	}
}


function resetForm(){
	document.contactUs.reset();
}

//validate email address.

function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
		alert("Invalid E-mail Address")
		return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		alert("Invalid E-mail Address")
		return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Invalid E-mail Address")
		return false
	}

		if (str.indexOf(at,(lat+1))!=-1){
		alert("Invalid E-mail Address")
		return false
		}

		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Invalid E-mail Address")
		return false
		}

		if (str.indexOf(dot,(lat+2))==-1){
		alert("Invalid E-mail Address")
		return false
		}
	
		if (str.indexOf(" ")!=-1){
		alert("Invalid E-mail Address")
		return false
		}

 		return true					
}
