
/*
	purpose:
		used in the 1 on 1 booking page
	page:
		/1to1/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function Check1to1Form(theform)
{
	if (!IsWordNumberSpecial(theform.oneononefirstname.value))
	{
		alert("Please enter your first name.");
		theform.oneononefirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.oneononelastname.value))
	{
		alert("Please enter your last name.");
		theform.oneononelastname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.oneononeaddress.value))
	{
		alert("Please enter your address.");
		theform.oneononeaddress.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.oneononecity.value))
	{
		alert("Please enter your city.");
		theform.oneononecity.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.oneononepostal.value))
	{
		alert("Please enter your postal/zip code.");
		theform.oneononepostal.focus();
		return false;
	}

	if (!IsPhone(theform.oneononephone.value))
	{
		alert("Please enter a valid phone number.");
		theform.oneononephone.focus();
		return false;
	}
	
	if (!IsEmail(theform.oneononeemail.value))
	{
		alert("Please enter a valid email address.");
		theform.oneononeemail.focus();
		return false;
	}
	
	if (!IsEmail(theform.oneononeemailconfirm.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.oneononeemailconfirm.focus();
		return false;
	}
	
	if (theform.oneononeemail.value != theform.oneononeemailconfirm.value)
	{
		alert("Your email address and confirmation email address do not match.");
		theform.oneononeemailconfirm.focus();
		return false;
	}
	
	return true;
}


/*
	purpose:
		used in the booking page
	page:
		/bookings/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckBookingForm(theform)
{
	if (!CheckDate(theform,'date1','Request Date - 1st Choice'))
		return false;
	
	if (!CheckBookingDate(theform,'date1','1st Choice'))
		return false;
	
	if (!CheckDate(theform,'date2','Request Date - 2nd Choice'))
		return false;
		
	if (!CheckBookingDate(theform,'date2','2nd Choice'))
		return false;

	if (!CheckDate(theform,'date3','Request Date - 3rd Choice'))
		return false;	

	if (!CheckBookingDate(theform,'date3','3rd Choice'))
		return false;

	if (!IsWordNumberSpecial(theform.bookingorganizationname.value))
	{
		alert("Please enter your organization name.");
		theform.bookingorganizationname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.bookingcontactname.value))
	{
		alert("Please enter the contact persons name.");
		theform.bookingcontactname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.bookingjobtitle.value))
	{
		alert("Please enter the contact persons job title.");
		theform.bookingjobtitle.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.bookingaddress.value))
	{
		alert("Please enter your address.");
		theform.bookingaddress.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.bookingcity.value))
	{
		alert("Please enter your city.");
		theform.bookingcity.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.bookingpostal.value))
	{
		alert("Please enter your postal/zip code.");
		theform.bookingpostal.focus();
		return false;
	}

	if (!IsPhone(theform.bookingphone.value))
	{
		alert("Please enter a valid phone number.");
		theform.bookingphone.focus();
		return false;
	}
	
	if (!IsEmail(theform.bookingemail.value))
	{
		alert("Please enter a valid email address.");
		theform.bookingemail.focus();
		return false;
	}
	
	if (!IsEmail(theform.bookingemailconfirm.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.bookingemailconfirm.focus();
		return false;
	}
	
	if (theform.bookingemail.value != theform.bookingemailconfirm.value)
	{
		alert("Your email address and confirmation email address do not match.");
		theform.bookingemailconfirm.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)
{
	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 (!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;
	}
	
	/*if (theform.contactrep[theform.contactrep.selectedIndex].value == "")
	{
		alert("Please select a Representative or choose Other.");
		theform.contactrep.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/gallery/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckGalleryForm(theform)
{
				
	if (!IsWordNumberSpecial(theform.galleryname.value))
	{
		alert("Please enter a gallery name.");
		theform.galleryname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.gallerydate.value))
	{
		alert("Please enter a date for this gallery.");
		theform.gallerydate.focus();
		return false;
	}
	
	if (!IsDescription(theform.gallerydescription.value))
	{
		alert("Please enter a description.");
		theform.gallerydescription.focus();
		return false;
	}

	if (!IsWordNumberSpecial(theform.gallerylocation.value))
	{
		alert("Please enter a gallery location.");
		theform.gallerylocation.focus();
		return false;
	}
	
	return true;
}


/*
	purpose:
		used in the control panel
	page:
		/admin/event/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckEventForm(theform)
{
	var file_value="";
	var file_value_thumb="";
	
	if (!IsWordNumberSpecial(theform.eventtitle.value))
	{
		alert("Please enter a title.");
		theform.eventtitle.focus();
		return false;
	}
	
	
	if (theform.eventdescription.value.length <= 4)
	{
		alert("Please enter a description.");
		theform.eventdescription.focus();
		return false;
	}
	
	//if we are supposed to upload a thumbnail
	if (theform.uploadimage.value == 1)
	{
		file_value_thumb=theform.eventimage_file.value;
		
		if (file_value_thumb.length > 0)
		{
			if (!IsImageExtension(file_value_thumb.substring(file_value_thumb.lastIndexOf("."),file_value_thumb.length)))
			{
				alert("Please select a valid image for uploading (must be .jpg or .gif).");
				theform.eventimage_file.focus();
				return false;
			}
		}
	}
	
	//if we are supposed to upload a file
	if (theform.uploadfile.value == 1)
	{
		file_value=theform.eventattachment_file.value;
		
		if (file_value.length > 0)
		{
			if (!IsFileExtensionPdfDoc(file_value.substring(file_value.lastIndexOf("."),file_value.length)))
			{
				alert("Please select a valid file for uploading (must be .pdf or .doc).");
				theform.eventattachment_file.focus();
				return false;
			}
		}
	}
	
	
	//optional
	if (theform.eventlocation.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.eventlocation.value))
		{
			alert("Please enter a location.");
			theform.eventlocation.focus();
			return false;
		}
	}
	
	//optional
	if (theform.eventcontactperson.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.eventcontactperson.value))
		{
			alert("Please enter a contact person.");
			theform.eventcontactperson.focus();
			return false;
		}
	}
	
	if (theform.eventcontactphone.value.length > 0)
	{
		if (!IsPhone(theform.eventcontactphone.value))
		{
			alert("Please enter a contact phone number.");
			theform.eventcontactphone.focus();
			return false;
		}
	}
	
	if (theform.eventcontactfax.value.length > 0)
	{
		if (!IsPhone(theform.eventcontactfax.value))
		{
			alert("Please enter a contact fax number.");
			theform.eventcontactfax.focus();
			return false;
		}
	}
	
	if (theform.eventcontactemail.value.length > 0)
	{
		if (!IsEmail(theform.eventcontactemail.value))
		{
			alert("Please enter a valid email address.");
			theform.eventcontactemail.focus();
			return false;
		}
	}
	
	
	if (!CheckDate(theform,'eventstartdate','Event Start Date'))
		return false;

	if (!CheckDate(theform,'eventenddate','Event End Date'))
		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 order bracelet page
	page:
		/order/orderbracelets.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckOrderBraceletForm(theform)
{
	if (!IsWordNumberSpecial(theform.orderbraceletfirstname.value))
	{
		alert("Please enter your first name.");
		theform.orderbraceletfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.orderbraceletlastname.value))
	{
		alert("Please enter your last name.");
		theform.orderbraceletlastname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.orderbraceletaddress.value))
	{
		alert("Please enter your address.");
		theform.orderbraceletaddress.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.orderbraceletcity.value))
	{
		alert("Please enter your city.");
		theform.orderbraceletcity.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.orderbraceletpostal.value))
	{
		alert("Please enter your postal/zip code.");
		theform.orderbraceletpostal.focus();
		return false;
	}

	if (!IsPhone(theform.orderbraceletphone.value))
	{
		alert("Please enter a valid phone number.");
		theform.orderbraceletphone.focus();
		return false;
	}
	
	if (!IsEmail(theform.orderbraceletemail.value))
	{
		alert("Please enter a valid email address.");
		theform.orderbraceletemail.focus();
		return false;
	}
	
	if (!IsEmail(theform.orderbraceletemailconfirm.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.orderbraceletemailconfirm.focus();
		return false;
	}
	
	if (theform.orderbraceletemail.value != theform.orderbraceletemailconfirm.value)
	{
		alert("Your email address and confirmation email address do not match.");
		theform.orderbraceletemailconfirm.focus();
		return false;
	}
	
	return true;
}


/*
	purpose:
		used in the order dvd page
	page:
		/order/orderdvd.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckOrderDVDForm(theform)
{
	if (!IsWordNumberSpecial(theform.orderdvdfirstname.value))
	{
		alert("Please enter your first name.");
		theform.orderdvdfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.orderdvdlastname.value))
	{
		alert("Please enter your last name.");
		theform.orderdvdlastname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.orderdvdaddress.value))
	{
		alert("Please enter your address.");
		theform.orderdvdaddress.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.orderdvdcity.value))
	{
		alert("Please enter your city.");
		theform.orderdvdcity.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.orderdvdpostal.value))
	{
		alert("Please enter your postal/zip code.");
		theform.orderdvdpostal.focus();
		return false;
	}

	if (!IsPhone(theform.orderdvdphone.value))
	{
		alert("Please enter a valid phone number.");
		theform.orderdvdphone.focus();
		return false;
	}
	
	if (!IsEmail(theform.orderdvdemail.value))
	{
		alert("Please enter a valid email address.");
		theform.orderdvdemail.focus();
		return false;
	}
	
	if (!IsEmail(theform.orderdvdemailconfirm.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.orderdvdemailconfirm.focus();
		return false;
	}
	
	if (theform.orderdvdemail.value != theform.orderdvdemailconfirm.value)
	{
		alert("Your email address and confirmation email address do not match.");
		theform.orderdvdemailconfirm.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 (!IsDescription(theform.photodescription.value))
	{
		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 ("Your 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;
}
