
function validateForgotPasswordForm(form){
	var alertMsg = "Please enter data for the following missing fields:\n\n"
	//valifdate email address
	var emailID=document.forgotPassword.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 (alertMsg == "Please enter data for the following missing fields:\n\n"){
		return true;
	} 	
	else {
		alert(alertMsg);
		return false;
	}
}

function validateContactForm(form){
	var alertMsg = "Please enter data for the following missing fields:\n\n";
	
	if(form.drpSubject.value==""){
		alertMsg = alertMsg + "  Subject: \n";
	}
	
	if (form.drpSubject.value == "Other" && form.frmOtherField.value == "") {
		alertMsg = alertMsg + " Subject - Other: \n";
	}
	
	if(form.frmNameField.value==""){
		alertMsg = alertMsg + "  Name: \n";
	}
	
	//valifdate email address
	var emailID=document.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(form.frmComments.value==""){
		alertMsg = alertMsg + "  Comments: \n";
	}
	if (alertMsg == "Please enter data for the following missing fields:\n\n"){
		return true;
	} 	
	else {
		alert(alertMsg);
		return false;
	}
}


function validateRegistrationForm(form){
	var alertMsg = "Data is missing for one or both of the following required fields:\n\n";
	
	if(form.frmFirstName.value=="")
		alertMsg = alertMsg + "\t- First Name \n"

	if(form.frmLastName.value=="")
		alertMsg = alertMsg + "\t- Last Name \n";

	var emailID=document.profile.frmEmail;
	
	if ((emailID.value==null)||(emailID.value==""))
		alertMsg = alertMsg + "\t- Adviser E-mail Address \n";
	
	if ((form.frmEmail1.value==null)||(form.frmEmail1.value==""))
		alertMsg = alertMsg + "\t- Confirm E-mail Address \n";
	
	if(form.drpRoles.value=="") {
		alertMsg = alertMsg + "\t- Role \n"
	}
	
	if(form.frmJobNumber.value==""){
		alertMsg = alertMsg + "\t- Job Number \n"
	}
	
	if(form.frmSchoolZip.value==""){
		alertMsg = alertMsg + "\t- School Zip Code \n"
	}
	
	if (alertMsg != "Data is missing for one or both of the following required fields:\n\n"){
		alert(alertMsg);
		return false;
	}
	
	if (!isValidInput(form.frmFirstName.value)) {
		alert("Input can't contain \" and \'");
		form.frmFirstName.focus();
		return false;
	}
	
	if (!isValidInput(form.frmLastName.value)) {
		alert("Input can't contain \" and \'");
		form.frmLastName.focus();
		return false;
	}
	
	if (echeck(emailID.value) == false){
		emailID.focus();
		return false;
	}
	
	if (emailID.value != document.profile.frmEmail1.value) {
		alert("Please be sure that the Adviser E-mail field and the Confirm E-mail field are identical.");
		emailID.focus();
		return false;
	}
	
	if (!isNumeric(form.frmJobNumber.value) || form.frmJobNumber.value.length != 7) {
		alert("Sorry, you must enter a valid Lifetouch Job Number to register with the Lifetouch Publishing Web site and access YB track.");
		form.frmJobNumber.focus();
		return false;
	}

	if (!isValidInput(form.frmSchoolName.value)) {
		alert("Input can't contain \" and \'");
		form.frmSchoolName.focus();
		return false;
	}
	
		
	if (!isNumeric(form.frmSchoolZip.value) || form.frmSchoolZip.value.length < 5) {
		alert("Please be sure to entire a valid school zip.");
		form.frmSchoolZip.focus();
		return false;
	}
	
	if (!form.frmAge.checked) {
		alert("Sorry, You must be at least 13 years old to register with Lifetouch Publishing Web site and access YB Track.");
		form.frmAge.focus();
		return false;
	}
}

function isValidInput(sText) {
	var invalidChars = "\"\'";
	
	for (var i = 0; i < sText.length; i++)
		if (invalidChars.indexOf(sText.charAt(i)) >= 0) return false;
	
	return true;
}

function isNumeric(sText) {
	var validChars = "0123456789";
	
	for (var i = 0; i < sText.length; i++) 
		if (validChars.indexOf(sText.charAt(i)) == -1) return false;
	
	return true;
}

function validateProfileForm(form){
	var alertMsg = "Please enter data for the following missing fields:\n\n"
	
	if(form.frmFirstName.value==""){
		alertMsg = alertMsg + "  First Name: \n"
	}
	if(form.frmLastName.value==""){
		alertMsg = alertMsg + "  Last Name: \n"
	}
	//valifdate email address
	var emailID=document.profile.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(form.drpRoles.value==""){
		alertMsg = alertMsg + "  Role: \n"
	}
	if ((form.frmPassword1.value!="") || (form.frmPassword2.value!="")){
		//alert("here");
		if(form.frmPassword1.value!=form.frmPassword2.value){
			alertMsg = alertMsg + "  Passwords do not match.  Please re-enter them. \n"
			form.frmPassword1.value="";
			form.frmPassword2.value="";
			form.frmPassword1.focus();
		}
	}
	if (alertMsg == "Please enter data for the following missing fields:\n\n"){
		return true;
	} 	
	else {
		alert(alertMsg);
		return false;
	}
}

function validateZoomOrder(form){
	var alertMsg = "Please enter data for the following missing fields:\n\n"
	
	if(form.frmJobNumber.value==""){
		alertMsg = alertMsg + "  Job Number: \n"
	}
	if(form.frmSchoolName.value==""){
		alertMsg = alertMsg + "  School Name: \n"
	}
	if(form.frmYourName.value==""){
		alertMsg = alertMsg + "  Your Name: \n"
	}
	if(form.drpPlacement.value=="None Selected"){
		alertMsg = alertMsg + "  Placement Option: \n"
	}
	
	//validate email address
	var emailID=document.orderZoom.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;
	}
}

//validate Refer a Friend form

function validateReferAFriendForm(form){
	var alertMsg = "Please enter data for the following missing fields:\n\n"
	
	if(form.frmJobNumber.value==""){
		alertMsg = alertMsg + " Your Information - Job Number: \n"
	}
	if(form.frmSchoolName.value==""){
		alertMsg = alertMsg + " Your Information - School Name: \n"
	}
	if(form.frmSchoolAddress.value==""){
		alertMsg = alertMsg + " Ship To - School Address: \n"
	}
	if(form.frmSchoolCity.value==""){
		alertMsg = alertMsg + " Ship To - School City: \n"
	}
	if(form.frmSchoolState.value==""){
		alertMsg = alertMsg + " Ship To - School State: \n"
	}
	if(form.frmSchoolZip.value==""){
		alertMsg = alertMsg + " Ship To - School Zip Code: \n"
	}
	if(form.frmYourName.value==""){
		alertMsg = alertMsg + " Ship To - Your Name : \n"
	}
	if(form.frmEmailAddress.value==""){
		alertMsg = alertMsg + " Ship To - E-mail Address: \n"
	}
	if(form.frmRefContactName.value==""){
		alertMsg = alertMsg + " Referral Information - Contact Name : \n"
	}
	if(form.frmRefSchoolName.value==""){
		alertMsg = alertMsg + " Referral Information - School Name: \n"
	}
	if(form.frmRefSchoolCity.value==""){
		alertMsg = alertMsg + " Referral Information - City: \n"
	}
	if(form.frmRefSchoolState.value==""){
		alertMsg = alertMsg + " Referral Information - State: \n"
	}
	if(form.frmRefSchoolZip.value==""){
		alertMsg = alertMsg + " Referral Information - Zip Code: \n"
	}
	
	//validate email address
	var emailID=document.frmReferAFriend.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
	}
	
	//validate referal email address
	var emailID=document.frmReferAFriend.frmRefSchoolEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter referral 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;
	}
}

//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					
}

function validateProfile06Form(form){
	var alertMsg = "Please enter data for the following missing fields:\n\n"

	if(form.frmUserName.value==""){
		alertMsg = alertMsg + "  User Name: \n"
	}
	if(form.frmFirstName.value==""){
		alertMsg = alertMsg + "  First Name: \n"
	}
	if(form.frmLastName.value==""){
		alertMsg = alertMsg + "  Last Name: \n"
	}
	//valifdate email address
	var emailID=document.profile.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 ((form.frmPassword1.value!="") || (form.frmPassword2.value!="")){
		//alert("here");
		if(form.frmPassword1.value!=form.frmPassword2.value){
			alertMsg = alertMsg + "  Passwords do not match.  Please re-enter them. \n"
			form.frmPassword1.value="";
			form.frmPassword2.value="";
			form.frmPassword1.focus();
		}
	}
	if (alertMsg == "Please enter data for the following missing fields:\n\n"){
		return true;
	} 	
	else {
		alert(alertMsg);
		return false;
	}
}

function validateNewProfile06Form(form){
	var alertMsg = ""

	if(form.frmUserName.value==""){
		alertMsg = alertMsg + "  User Name: \n"
	}
	if(form.frmFirstName.value==""){
		alertMsg = alertMsg + "  First Name: \n"
	}
	if(form.frmLastName.value==""){
		alertMsg = alertMsg + "  Last Name: \n"
	}
	if(form.frmEmail1.value==""){
		alertMsg = alertMsg + "  Email: \n"
	}
	if(form.frmPassword1.value==""){
		alertMsg = alertMsg + "  Password: \n"
	}

	//valifdate email address
	var emailID1=document.profile.frmEmail1
	var emailID2=document.profile.frmEmail2
	
	if (echeck(emailID1.value)==false){
		emailID1.value=""
		emailID1.focus()
		return false
	}

	if(emailID1.value!=emailID2.value){
			alertMsg = alertMsg + "  Email do not match.  Please re-enter them. \n"
			emailID1.focus();
	}

	if(form.frmPassword1.value!=form.frmPassword2.value){
			alertMsg = alertMsg + "  Passwords do not match.  Please re-enter them. \n"
			form.frmPassword1.focus();
	}

	if (alertMsg == ""){
		return true;
	} 	
	else {
		alert("Please enter data for the following missing fields:\n\n" + alertMsg);
		return false;
	}
}
