

/*
	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 career inquiry page
	page:
		/career inquiry/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckCareerInquiryForm(theform)
{
	var item_checked=false;
	
	if (!IsWordNumberSpecial(theform.careerinquiryfirstname.value))
	{
		alert("Please enter your first name.");
		theform.careerinquiryfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.careerinquirylastname.value))
	{
		alert("Please enter your last name.");
		theform.careerinquirylastname.focus();
		return false;
	}
	
	if (!IsEmail(theform.careerinquiryemail.value))
	{
		alert("Please enter a valid email address.");
		theform.careerinquiryemail.focus();
		return false;
	}
	
	if (!IsEmail(theform.careerinquiryemailconfirm.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.careerinquiryemailconfirm.focus();
		return false;
	}
	
	if (theform.careerinquiryemail.value != theform.careerinquiryemailconfirm.value)
	{
		alert("Your email address and confirmation email address do not match.");
		theform.careerinquiryemailconfirm.focus();
		return false;
	}
	
	
	if (!IsWordNumberSpecial(theform.careerinquirycity.value))
	{
		alert("Please enter your city.");
		theform.careerinquirycity.focus();
		return false;
	}
	
	file_value=theform.careerinquiryresume.value;
		
	if (file_value.length > 0)
	{
		if (!IsFileExtensionResume(file_value.substring(file_value.lastIndexOf("."),file_value.length)))
		{
			alert("Please select a valid file for uploading (must be be .rtf, .txt, .doc or .pdf).");
			theform.careerinquiryresume.focus();
			return false;
		}
		
	}
	
	return true;
}



/*
	purpose:
		used in the contact page
	page:
		/contact/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.contactcity.value))
	{
		alert("Please enter your city.");
		theform.contactcity.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;
	}
	
	
	return true;
}


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

function CheckContactSalesForm(theform)
{
	var item_checked=false;
	
	if (!IsWordNumberSpecial(theform.contactsalesfirstname.value))
	{
		alert("Please enter your first name.");
		theform.contactsalesfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contactsaleslastname.value))
	{
		alert("Please enter your last name.");
		theform.contactsaleslastname.focus();
		return false;
	}
	
	if (!IsEmail(theform.contactsalesemail.value))
	{
		alert("Please enter a valid email address.");
		theform.contactsalesemail.focus();
		return false;
	}
	
	if (!IsEmail(theform.contactsalesemailconfirm.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.contactsalesemailconfirm.focus();
		return false;
	}
	
	if (theform.contactsalesemail.value != theform.contactsalesemailconfirm.value)
	{
		alert("Your email address and confirmation email address do not match.");
		theform.contactsalesemailconfirm.focus();
		return false;
	}
	
	
	if (!IsWordNumberSpecial(theform.contactsalescity.value))
	{
		alert("Please enter your city.");
		theform.contactsalescity.focus();
		return false;
	}
	
	return true;
}



/*
	purpose:
		used in the parts and service  page
	page:
		/parts_service/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckContactPartsForm(theform)
{
	var item_checked=false;
	
	if (!IsWordNumberSpecial(theform.contactpartsfirstname.value))
	{
		alert("Please enter your first name.");
		theform.contactpartsfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contactpartslastname.value))
	{
		alert("Please enter your last name.");
		theform.contactpartslastname.focus();
		return false;
	}
	
	if (!IsEmail(theform.contactpartsemail.value))
	{
		alert("Please enter a valid email address.");
		theform.contactpartsemail.focus();
		return false;
	}
	
	if (!IsEmail(theform.contactpartsemailconfirm.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.contactpartsemailconfirm.focus();
		return false;
	}
	
	if (theform.contactpartsemail.value != theform.contactpartsemailconfirm.value)
	{
		alert("Your email address and confirmation email address do not match.");
		theform.contactpartsemailconfirm.focus();
		return false;
	}
	
	
	if (!IsWordNumberSpecial(theform.contactpartscity.value))
	{
		alert("Please enter your city.");
		theform.contactpartscity.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 contact page
	page:
		/inquiry/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckInquiryForm(theform)
{
	var item_checked=false;

	if (!IsWordNumberSpecial(theform.inquiryfirstname.value))
	{
		alert("Please enter your first name.");
		theform.inquiryfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.inquirylastname.value))
	{
		alert("Please enter your last name.");
		theform.inquirylastname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.inquiryaddress.value))
	{
		alert("Please enter your address.");
		theform.inquiryaddress.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.inquirycity.value))
	{
		alert("Please enter your city.");
		theform.inquirycity.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.inquirypostal.value))
	{
		alert("Please enter your postal/zip code.");
		theform.inquirypostal.focus();
		return false;
	}

	if (!IsPhone(theform.inquiryphone.value))
	{
		alert("Please enter a valid phone number. I.e. xxx-xxx-xxxx");
		theform.inquiryphone.focus();
		return false;
	}
	
	if (theform.inquiryfax.value.length > 0)
	{
		if (!IsPhone(theform.inquiryfax.value))
		{
			alert("Please enter a valid fax number.");
			theform.inquiryfax.focus();
			return false;
		}
	}
	
	if (!IsEmail(theform.inquiryemail.value))
	{
		alert("Please enter a valid email address.");
		theform.inquiryemail.focus();
		return false;
	}
	
	if (!IsEmail(theform.inquiryemailconfirm.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.inquiryemailconfirm.focus();
		return false;
	}
	
	if (theform.inquiryemail.value != theform.inquiryemailconfirm.value)
	{
		alert("Your email address and confirmation email address do not match.");
		theform.inquiryemailconfirm.focus();
		return false;
	}
	
	//make sure at least one check box is selected 
	for (var i=0;i<theform.inquiryservice.length;i++)
	{
		if (theform.inquiryservice[i].checked)
			item_checked=true;
	}

	if (item_checked == false)
	{
		alert("Please let us know which service you are interested in.");
		theform.inquiryservice[0].focus();
		return false;
	}
	
	return true;
}


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

function CheckInvestorNewsForm(theform)
{
	var item_checked=false;
	
	if (!IsWordNumberSpecial(theform.investornewsfirstname.value))
	{
		alert("Please enter your first name.");
		theform.investornewsfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.investornewslastname.value))
	{
		alert("Please enter your last name.");
		theform.investornewslastname.focus();
		return false;
	}
	
	if (!IsEmail(theform.investornewsemail.value))
	{
		alert("Please enter a valid email address.");
		theform.investornewsemail.focus();
		return false;
	}
	
	if (!IsEmail(theform.investornewsemailconfirm.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.investornewsemailconfirm.focus();
		return false;
	}
	
	if (theform.investornewsemail.value != theform.investornewsemailconfirm.value)
	{
		alert("Your email address and confirmation email address do not match.");
		theform.investornewsemailconfirm.focus();
		return false;
	}
	
	
	if (!IsWordNumberSpecial(theform.investornewscity.value))
	{
		alert("Please enter your city.");
		theform.investornewscity.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 login inquiry page
	page:
		/login/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckLoginInquiryForm(theform)
{
	
	if (!IsWordNumberSpecial(theform.loginfirstname.value))
	{
		alert("Please enter your first name.");
		theform.loginfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.loginlastname.value))
	{
		alert("Please enter your last name.");
		theform.loginlastname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.logincompany.value))
	{
		alert("Please enter your company name.");
		theform.logincompany.focus();
		return false;
	}

	if (!IsWordNumberSpecial(theform.loginmutualdealer.value))
	{
		alert("Please enter the name of your Mutual Fund Dealer.");
		theform.loginmutualdealer.focus();
		return false;
	}

	
	
	if (!IsWordNumberSpecial(theform.loginaddress.value))
	{
		alert("Please enter your address.");
		theform.loginaddress.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.logincity.value))
	{
		alert("Please enter your city.");
		theform.logincity.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.loginpostal.value))
	{
		alert("Please enter your postal/zip code.");
		theform.loginpostal.focus();
		return false;
	}

	if (!IsPhone(theform.loginphone.value))
	{
		alert("Please enter a valid phone number.");
		theform.loginphone.focus();
		return false;
	}
	
	if (theform.loginfax.value.length > 0)
	{
		if (!IsPhone(theform.loginfax.value))
		{
			alert("Please enter a valid fax number.");
			theform.loginfax.focus();
			return false;
		}
	}
	
	if (!IsEmail(theform.loginemail.value))
	{
		alert("Please enter a valid email address.");
		theform.loginemail.focus();
		return false;
	}
	
	if (!IsEmail(theform.loginconfirmemail.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.loginconfirmemail.focus();
		return false;
	}
	
	if (theform.loginemail.value != theform.loginconfirmemail.value)
	{
		alert("Your email address and confirmation email address do not match.");
		theform.loginconfirmemail.focus();
		return false;
	}
	
	
	return true;
}




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

function CheckPortfolioCategoryForm(theform)
{
				
	if (!IsWordNumberSpecial(theform.portfoliocategoryname.value))
	{
		alert("Please enter a portfolio category name.");
		theform.portfoliocategoryname.focus();
		return false;
	}

	
	return true;
}




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

function CheckAdminPortfolioPhotoForm(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 ("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;
}


/*
	purpose:
		used in the wedding calculator signup form
	page:
		/wedding_calculator/signup_form.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckWeddingCalculatorSignupForm(theform)
{
	if (!IsWordNumberSpecial(theform.wcsignupfirstname.value))
	{
		alert("Please enter your first name.");
		theform.wcsignupfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.wcsignuplastname.value))
	{
		alert("Please enter your last name.");
		theform.wcsignuplastname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.wcsignupaddress.value))
	{
		alert("Please enter your address.");
		theform.wcsignupaddress.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.wcsignupcity.value))
	{
		alert("Please enter your city.");
		theform.wcsignupcity.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.wcsignuppostal.value))
	{
		alert("Please enter your postal/zip code.");
		theform.wcsignuppostal.focus();
		return false;
	}

	if (!IsPhone(theform.wcsignupphone.value))
	{
		alert("Please enter a valid phone number. I.e. xxx-xxx-xxxx");
		theform.wcsignupphone.focus();
		return false;
	}
	
	if (theform.wcsignupfax.value.length > 0)
	{
		if (!IsPhone(theform.wcsignupfax.value))
		{
			alert("Please enter a valid fax number.");
			theform.wcsignupfax.focus();
			return false;
		}
	}
	
	if (!IsEmail(theform.wcsignupemail.value))
	{
		alert("Please enter a valid email address.");
		theform.wcsignupemail.focus();
		return false;
	}
	
	if (!IsEmail(theform.wcsignupconfirmemail.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.wcsignupconfirmemail.focus();
		return false;
	}
	
	if (theform.wcsignupemail.value != theform.wcsignupconfirmemail.value)
	{
		alert("Your email address and confirmation email address do not match.");
		theform.wcsignupconfirmemail.focus();
		return false;
	}
	
	if (!CheckDate(theform,'wcsignupweddingdate','Wedding Date'))
		return false;
	
	return true;
}
