/*
	purpose:
		used in the control panel
	page:
		/admin/login/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckAdminLoginForm(theform)
{
	
	if (!IsWordNumberSpecial(theform.logincompanyname.value))
	{
		alert("Please enter a valid company name.");
		theform.logincompanyname.focus();
		return false;
	}
	
	if (!IsUsername(theform.loginusername.value))
	{
		alert("Please enter a valid username.");
		theform.loginusername.focus();
		return false;
	}

	if ((theform.updatepassword.checked == 1) || (theform.submit_type.value == "add"))
	{
		if (!IsPassword(theform.loginpassword.value))
		{
			alert("Please enter a valid password.");
			theform.loginpassword.focus();
			return false;
		}
		
		if (!IsPassword(theform.loginpasswordconfirm.value))
		{
			alert("Please enter a valid password confirmation password.");
			theform.loginpasswordconfirm.focus();
			return false;
		}
	 	
		if (theform.loginpassword.value != theform.loginpasswordconfirm.value)
		{
		 	alert ("You Password and Confirm Password do not match");
			theform.loginpasswordconfirm.focus();
			return false;
		}
	}

	
	if (!IsWordSpace(theform.loginfirstname.value))
	{
		alert("Please enter a valid first name.");
		theform.loginfirstname.focus();
		return false;
	}
	
	if (!IsWordSpace(theform.loginlastname.value))
	{
		alert("Please enter a valid last name.");
		theform.loginlastname.focus();
		return false;
	}
	
	
	if (!IsWordNumberSpecial(theform.loginaddress.value))
	{
		alert("Please enter a valid address.");
		theform.loginaddress.focus();
		return false;
	}
	
	if (theform.loginaddress2.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.loginaddress2.value))
		{
			alert("Please enter a valid address 2 value.");
			theform.loginaddress2.focus();
			return false;
		}
	}
	
	if (!IsWordNumberSpecial(theform.logincity.value))
	{
		alert("Please enter a valid city value.");
		theform.logincity.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.loginpostal.value))
	{
		alert("Please enter a valid zip/postal code value.");
		theform.loginpostal.focus();
		return false;
	}
	
	if (!IsEmail(theform.loginemail.value))
	{
		alert("Please enter a valid email address.");
		theform.loginemail.focus();
		return false;
	}

	if (!IsPhone(theform.loginphone.value))
	{
		alert("Please enter a valid phone number. I.e. xxx-xxx-xxxx OR xxx-xxx-xxxx ext xxx");
		theform.loginphone.focus();
		return false;
	}

	if (!IsPhone(theform.loginfax.value))
	{
		alert("Please enter a valid fax number. I.e. xxx-xxx-xxxx");
		theform.loginfax.focus();
		return false;
	}
		
	if (!CheckDate(theform,'expiry','Expiration Date',1))
		return false;
		
	return true;
}




/*
	purpose:
		used in the control panel
	page:
		/admin/destination/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckDestinationForm(theform)
{
	var file_value="";
	
	if (theform.destinationdescription.value.length <4)
	{
		alert("Please enter a description.");
		theform.destinationdescription.focus();
		return false;
	}
	
	if (theform.destinationweather.value.length <4)
	{
		alert("Please enter the weather information.");
		theform.destinationweather.focus();
		return false;
	}
	
	if (theform.destinationfooddrink.value.length <4)
	{
		alert("Please enter the food & drink information.");
		theform.destinationfooddrink.focus();
		return false;
	}
	
	if (theform.destinationgettingmarried.value.length <4)
	{
		alert("Please enter the getting married information.");
		theform.destinationgettingmarried.focus();
		return false;
	}
	
	
	//if we are supposed to upload a file
	if (theform.uploadimage.value == 1)
	{
		file_value=theform.destinationlargeimage_file.value;
		
		if (!IsImageExtension(file_value.substring(file_value.lastIndexOf("."),file_value.length)))
		{
			alert("Please select a valid file for uploading (must be .gif or .jpg).");
			theform.destinationlargeimage_file.focus();
			return false;
		}
	}
	
	if ((theform.destinationlargeimage.value.length > 0) || (theform.destinationlargeimage_file.value.length > 0))
	{
		if (!IsWordNumberSpecial(theform.destinationlargeimagetitle.value))
		{
			alert("Please enter the image title.");
			theform.destinationlargeimagetitle.focus();
			return false;
		}
	}
	
	return true;
}




/*
	purpose:
		used in the control panel
	page:
		/admin/itinerary/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckItineraryForm(theform)
{
	var file_value="";
	
	if (!IsWordNumberSpecial(theform.itineraryname.value))
	{
		alert("Please enter a name.");
		theform.itineraryname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.itineraryduration.value))
	{
		alert("Please enter the duration.");
		theform.itineraryduration.focus();
		return false;
	}
	
	if (theform.itinerarybreakdown.value.length <4)
	{
		alert("Please enter the itinerary breakdown.");
		theform.itinerarybreakdown.focus();
		return false;
	}
	
	if (theform.itinerarynotes.value.length <4)
	{
		alert("Please enter the itinerary notes.");
		theform.itinerarynotes.focus();
		return false;
	}
	
	
	return true;
}

/*
	purpose:
		used in the quote request section
	page:
		/quote_request/
	Parameters:
		theform - object reference to the form being passed
*/

function CheckQuoteRequestForm(theform)
{
	var item_checked=false;
	
	if (!IsWordNumberSpecial(theform.quotefirstname.value))
	{
		alert("Please enter your first name.");
		theform.quotefirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.quotelastname.value))
	{
		alert("Please enter your last name.");
		theform.quotelastname.focus();
		return false;
	}

	if (!IsPhone(theform.quotephone.value))
	{
		alert("Please enter a valid phone number. i.e. xxx-yyy-zzzz or xxxyyyzzzz");
		theform.quotephone.focus();
		return false;
	}

	if (!IsEmail(theform.quoteemail.value))
	{
		alert("Please enter a valid email address.");
		theform.quoteemail.focus();
		return false;
	}

	if (!CheckDate(theform,'quotetravelstartdate','Travel Start Date'))
		return false;
		
	if (!CheckDate(theform,'quotetravelenddate','Travel End Date'))
		return false;	

	if (!IsDescription(theform.quotehoneymoonideas.value))
	{
		alert("Please enter your honeymoon ideas.");
		theform.quotehoneymoonideas.focus();
		return false;
	}
	
	if (theform.quotemusthave1.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.quotemusthave1.value))
		{
			alert("Please enter your three honeymoon 'must have' items.");
			theform.quotemusthave1.focus();
			return false;
		}
	}
	
	if (theform.quotemusthave2.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.quotemusthave2.value))
		{
			alert("Please enter your three honeymoon 'must have' items.");
			theform.quotemusthave2.focus();
			return false;
		}
	}
	
	if (theform.quotemusthave3.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.quotemusthave3.value))
		{
			alert("Please enter your three honeymoon 'must have' items.");
			theform.quotemusthave3.focus();
			return false;
		}
	}
	
	//make sure at least one check box is selected 
	for (var i=0;i<theform.quotepreferences.length;i++)
	{
		if (theform.quotepreferences[i].checked)
			item_checked=true;
	}

	if (item_checked == false)
	{
		alert("Please select your preferences.");
		theform.quotepreferences[0].focus();
		return false;
	}
	
	//reset
	item_checked=false;
	
	//make sure at least one check box is selected 
	for (var i=0;i<theform.quotehoneymoontype.length;i++)
	{
		if (theform.quotehoneymoontype[i].checked)
			item_checked=true;
	}

	if (item_checked == false)
	{
		alert("Please indicate the type of Honeymoon you are looking for.");
		theform.quotehoneymoontype[0].focus();
		return false;
	}
	
	return true;
}


/*
	purpose:
		used in the contact page
	page:
		/contactus/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckContactForm(theform)
{
	var item_checked=false;

	if (!IsWordNumberSpecial(theform.contactfirstname.value))
	{
		alert("Please enter your first name.");
		theform.contactfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contactlastname.value))
	{
		alert("Please enter your last name.");
		theform.contactlastname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contactaddress.value))
	{
		alert("Please enter your address.");
		theform.contactaddress.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contactcity.value))
	{
		alert("Please enter your city.");
		theform.contactcity.focus();
		return false;
	}
	
	if (theform.stateid[theform.stateid.selectedIndex].value == "")
	{
		alert("Please select a valid state/province.");
		theform.stateid.focus();
		return false;
	}
	
	if (theform.countryid[theform.countryid.selectedIndex].value == "")
	{
		alert("Please select a valid country.");
		theform.countryid.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contactpostal.value))
	{
		alert("Please enter your postal/zip code.");
		theform.contactpostal.focus();
		return false;
	}

	if (!IsPhone(theform.contactphone.value))
	{
		alert("Please enter a valid phone number.");
		theform.contactphone.focus();
		return false;
	}
	
	if (theform.contactfax.value.length > 0)
	{
		if (!IsPhone(theform.contactfax.value))
		{
			alert("Please enter a valid fax number.");
			theform.contactfax.focus();
			return false;
		}
	}
	
	if (!IsEmail(theform.contactemail.value))
	{
		alert("Please enter a valid email address.");
		theform.contactemail.focus();
		return false;
	}
	
	if (!IsEmail(theform.contactconfirmemail.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.contactconfirmemail.focus();
		return false;
	}
	
	if (theform.contactemail.value != theform.contactconfirmemail.value)
	{
		alert("Your email address and confirmation email address do not match.");
		theform.contactconfirmemail.focus();
		return false;
	}
	
	//make sure at least one check box is selected 
	for (var i=0;i<theform.contacthowcanwehelp.length;i++)
	{
		if (theform.contacthowcanwehelp[i].checked)
			item_checked=true;
	}

	if (item_checked == false)
	{
		alert("Please select a reason for contacing SMFC.");
		theform.contacthowcanwehelp[0].focus();
		return false;
	}
	
	return true;
}

/*
	purpose:
		used in the control panel
	page:
		all /module_setorder.cfm pages
	Parameters:
		theform - object reference to the form being passed
*/
function CheckDisplayOrderForm(theform)
{
	if (theform.orderlist.value <= 0)
	{
		alert("The order has not changed, no update required.");
		return false;
	}

	return true;
}



/*
	purpose:
		used in the control panel
	page:
		/admin/group/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckGroupForm(theform)
{
	var test=false;
	
	if (!IsWordSpace(theform.groupinfoname.value))
	{
		alert("Please enter a valid group name.");
		theform.groupinfoname.focus();
		return false;
	}

	if (!IsDescription(theform.groupinfodescription.value))
	{
		alert("Please enter a valid group description.");
		theform.groupinfodescription.focus();
		return false;
	}
						
	return true;
}


/*
	purpose:
		used in the control panel
	page:
		main control panel login page
	Parameters:
		theform - object reference to the form being passed
*/
function CheckLoginForm(theform)
{

	if (!IsUsername(theform.username.value))
	{
		alert("Please enter a valid username. (MIN. 5 characters)");
		theform.username.focus();
		return false;
	}

	if (!IsPassword(theform.password.value))
	{
		alert("Please enter a valid password. (MIN. 5 characters)");
		theform.password.focus();
		return false;
	}

	return true;
}




/*
	purpose:
		used in the front end 
	page:
		/enews/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/
function CheckMailingListForm(theform)
{
	
	if (!IsWordSpace(theform.mailinglistfirstname.value))
	{
		alert("Please enter a valid first name.");
		theform.mailinglistfirstname.focus();
		return false;
	}
	
	if (!IsWordSpace(theform.mailinglistlastname.value))
	{
		alert("Please enter a valid last name.");
		theform.mailinglistlastname.focus();
		return false;
	}
	
	if (!IsEmail(theform.mailinglistemailaddress.value))
	{
		alert("Please enter a valid email address.");
		theform.mailinglistemailaddress.focus();
		return false;
	}
	
	if (!IsEmail(theform.mailinglistemailaddressconfirm.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.mailinglistemailaddressconfirm.focus();
		return false;
	}
	
	if (theform.mailinglistemailaddress.value != theform.mailinglistemailaddressconfirm.value)
	{
		alert("Sorry, your email address and confirmation email address do not match, please try again.");
		theform.mailinglistemailaddress.focus();
		return false;
	}
	
	
	if (!CheckDate(theform,'mailinglisthoneymoondate','Honeymoon Date'))
		return false;
		
	/*
	if (theform.mailinglistoptin.checked == false)
	{
		alert("Please check the box indicating you have read and agree to our privacy policy.");
		theform.mailinglistoptin.focus();
		return false;
	}
	*/

	return true;
}


/*
	purpose:
		used in the front end 
	page:
		/enews/removal.cfm
	Parameters:
		theform - object reference to the form being passed
*/
function CheckMailingListRemovalForm(theform)
{
	
	if (!IsEmail(theform.emailaddress.value))
	{
		alert("Please enter a valid email address.");
		theform.emailaddress.focus();
		return false;
	}
	
	if (!IsEmail(theform.emailaddressconfirm.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.emailaddressconfirm.focus();
		return false;
	}
	
	if (theform.emailaddress.value != theform.emailaddressconfirm.value)
	{
		alert("Sorry, your email address and confirmation email address do not match, please try again.");
		theform.emailaddress.focus();
		return false;
	}
	
	return true;
}



/*
	purpose:
		used in the control panel
	page:
		/admin/photo/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckPhotoForm(theform)
{
	var thumbnail_value="";
	var image_value="";
	
	if (!IsWordNumberSpecial(theform.photoname.value))
	{
		alert("Please enter a valid Photo Name.");
		theform.photoname.focus();
		return false;
	}
	
	if (theform.photodescription.value.length <4)
	{
		alert("Please enter some valid Photo Description.");
		theform.photodescription.focus();
		return false;
	}

	
	//if we are supposed to upload an thumbnail
	if (theform.uploadthumbnail.value == 1)
	{
		thumbnail_value=theform.photothumbnailfile_file.value;
		
		if (!IsImageExtension(thumbnail_value.substring(thumbnail_value.lastIndexOf("."),thumbnail_value.length)))
		{
			alert("Please select an thumbnail file for uploading (must be .jpg or .gif).");
			theform.photothumbnailfile_file.focus();
			return false;
		}
	}
						
	//if we are supposed to upload an image
	if (theform.uploadimage.value == 1)
	{
	 	image_value=theform.photoimagefile_file.value;
		
		if (!IsImageExtension(image_value.substring(image_value.lastIndexOf("."),image_value.length)))
		{
			alert("Please select an image file for uploading (must be .jpg or .gif).");
			theform.photoimagefile_file.focus();
			return false;
		}
	}
		
	return true;
}


/*
	purpose:
		used in the control panel
	page:
		/admin/user/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckUserForm(theform)
{
	
	if (!IsWordSpace(theform.userinfofirstname.value))
	{
		alert("Please enter a valid first name.");
		theform.userinfofirstname.focus();
		return false;
	}
	
	if (!IsWordSpace(theform.userinfolastname.value))
	{
		alert("Please enter a valid last name.");
		theform.userinfolastname.focus();
		return false;
	}

	if (!IsUsername(theform.userinfousername.value))
	{
		alert("Please enter a valid username.");
		theform.userinfousername.focus();
		return false;
	}

	if ((theform.updatepassword.checked == 1) || (theform.submit_type.value == "add"))
	{
		if (!IsPassword(theform.userinfopassword.value))
		{
			alert("Please enter a valid password.");
			theform.userinfopassword.focus();
			return false;
		}
		
		if (!IsPassword(theform.userinfopasswordconfirm.value))
		{
			alert("Please enter a valid password confirmation password.");
			theform.userinfopasswordconfirm.focus();
			return false;
		}
	 	
		if (theform.userinfopassword.value != theform.userinfopasswordconfirm.value)
		{
		 	alert ("You Password and Confirm Password do not match");
			theform.userinfopasswordconfirm.focus();
			return false;
		}
	}

	if (!IsWordSpace(theform.userinfojobtitle.value))
	{
		alert("Please enter a valid job title.");
		theform.userinfojobtitle.focus();
		return false;
	}
	
	if (!IsEmail(theform.userinfoemailaddress.value))
	{
		alert("Please enter a valid email address.");
		theform.userinfoemailaddress.focus();
		return false;
	}

	if (theform.groupinfoid.selectedIndex == -1)
	{
		alert("Please select at least one group.");
		theform.groupinfoid[0].focus();
		return false;
	}

	return true;
}
