
/*
	purpose:
		used in the contact page
	page:
		/contact_us/more_information.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckContactForm(theform)
{

	if (!IsWordNumberSpecial(theform.contactname.value))
	{
		alert("Please enter your name.");
		theform.contactname.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 (!IsWordNumberSpecial(theform.contactcomments.innerHTML))
	{
		alert("Please enter additional comments.");
		theform.contactcomments.focus();
		return false;
	}
	
	
	theform.submit();
	//return true;
}

/*
	purpose:
		used in the be_pressure contact form page
	page:
		/replacement_parts/be_pressure.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckContactBEForm(theform)
{

	if (!IsWordNumberSpecial(theform.contactbename.value))
	{
		alert("Please enter your name.");
		theform.contactbename.focus();
		return false;
	}
	
	if (!IsPhone(theform.contactbephone.value))
	{
		alert("Please enter a valid phone number.");
		theform.contactbephone.focus();
		return false;
	}
	
	if (!IsEmail(theform.contactbeemail.value))
	{
		alert("Please enter a valid email address.");
		theform.contactbeemail.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contactbepartnumber.value))
	{
		alert("Please enter the part number.");
		theform.contactbepartnumber.focus();
		return false;
	}

	theform.submit();
	//return true;
}

/*
	purpose:
		used in the chainsaw contact form page
	page:
		/replacement_parts/chainsaw.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckContactChainsawForm(theform)
{

	if (!IsWordNumberSpecial(theform.contactchainsawname.value))
	{
		alert("Please enter your name.");
		theform.contactchainsawname.focus();
		return false;
	}
	
	if (!IsPhone(theform.contactchainsawphone.value))
	{
		alert("Please enter a valid phone number.");
		theform.contactchainsawphone.focus();
		return false;
	}
	
	if (!IsEmail(theform.contactchainsawemail.value))
	{
		alert("Please enter a valid email address.");
		theform.contactchainsawemail.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contactchainsawmake.value))
	{
		alert("Please enter the make.");
		theform.contactchainsawmake.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contactchainsawmodel.value))
	{
		alert("Please enter the model.");
		theform.contactchainsawmodel.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contactchainsawbarlength.value))
	{
		alert("Please enter the bar length.");
		theform.contactchainsawbarlength.focus();
		return false;
	}
	

	/*
	if (!IsWordNumberSpecial(theform.contactchainsawtangnumber.value))
	{
		alert("Please enter the drive tang number on chain.");
		theform.contactchainsawtangnumber.focus();
		return false;
	}
	*/
	
	theform.submit();
	//return true;
}

/*
	purpose:
		used in the echo contact form page
	page:
		/replacement_parts/echo.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckContactEchoForm(theform)
{

	if (!IsWordNumberSpecial(theform.contactechoname.value))
	{
		alert("Please enter your name.");
		theform.contactechoname.focus();
		return false;
	}
	
	if (!IsPhone(theform.contactechophone.value))
	{
		alert("Please enter a valid phone number.");
		theform.contactechophone.focus();
		return false;
	}
	
	if (!IsEmail(theform.contactechoemail.value))
	{
		alert("Please enter a valid email address.");
		theform.contactechoemail.focus();
		return false;
	}
	
	
	theform.submit();
	//return true;
}

/*
	purpose:
		used in the titan contact form page
	page:
		/replacement_parts/titan.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckContactTitanForm(theform)
{

	if (!IsWordNumberSpecial(theform.contacttitanname.value))
	{
		alert("Please enter your name.");
		theform.contacttitanname.focus();
		return false;
	}
	
	if (!IsPhone(theform.contacttitanphone.value))
	{
		alert("Please enter a valid phone number.");
		theform.contacttitanphone.focus();
		return false;
	}
	
	if (!IsEmail(theform.contacttitanemail.value))
	{
		alert("Please enter a valid email address.");
		theform.contacttitanemail.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contacttitanmodel.value))
	{
		alert("Please enter the model.");
		theform.contacttitanmodel.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contacttitanpartnumber.value))
	{
		alert("Please enter the part number.");
		theform.contacttitanpartnumber.focus();
		return false;
	}
	
	theform.submit();
	//return true;
}


/*
	purpose:
		used in the wacker contact form page
	page:
		/replacement_parts/wacker.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckContactWackerForm(theform)
{

	if (!IsWordNumberSpecial(theform.contactwackername.value))
	{
		alert("Please enter your name.");
		theform.contactwackername.focus();
		return false;
	}
	
	if (!IsPhone(theform.contactwackerphone.value))
	{
		alert("Please enter a valid phone number.");
		theform.contactwackerphone.focus();
		return false;
	}
	
	if (!IsEmail(theform.contactwackeremail.value))
	{
		alert("Please enter a valid email address.");
		theform.contactwackeremail.focus();
		return false;
	}
	
	
	
	theform.submit();
	//return true;
}


/*
	purpose:
		used in the rental list page
	page:
		/rental_list/rental_customer_info.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckCustomerInformationForm(theform)
{
	
	if (!IsWordNumberSpecial(theform.billingname.value))
	{
		alert("Please enter a valid customer name.");
		theform.billingname.focus();
		return false;
	}
	
	if (!IsEmail(theform.billingemail.value))
	{
		alert("Please enter a valid customer email address.");
		theform.billingemail.focus();
		return false;
	}
	
	if (!IsEmail(theform.billingemailconfirm.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.billingemailconfirm.focus();
		return false;
	}
	
	if (theform.billingemail.value != theform.billingemailconfirm.value)
	{
		alert("Sorry, your customer email and confirmation email are not the same.");
		theform.billingemailconfirm.focus();
		return false;
	}
	
	/*
	if (!IsWordNumberSpecial(theform.billingaddress.value))
	{
		alert("Please enter a valid customer address.");
		theform.billingaddress.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.billingcity.value))
	{
		alert("Please enter a valid customer city.");
		theform.billingcity.focus();
		return false;
	}

	if (theform.billingstateid[theform.billingstateid.selectedIndex].value == "")
	{
		alert("Please select a valid state/province.");
		theform.billingstateid.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.billingpostal.value))
	{
		alert("Please enter a valid customer postal/zip code.");
		theform.billingpostal.focus();
		return false;
	}
	*/
	if (!IsPhone(theform.billingphone.value))
	{
		alert("Please enter a valid customer phone number.");
		theform.billingphone.focus();
		return false;
	}
	
	if (!CheckDate(theform,"rentalpickupdate","Rental Date Required"))
		return false;
		
	/*if (!IsWordNumberSpecial(theform.rentalpickuptime.value))
	{
		alert("Please enter a valid rental time required.");
		theform.rentalpickuptime.focus();
		return false;
	}	
	*/
	theform.submit();
}

/*
	purpose:
		used in the registration page
	page:
		/login/request_account.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckLoginRequestForm(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.loginaddress.value))
	{
		alert("Please enter an address.");
		theform.loginaddress.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.logincity.value))
	{
		alert("Please enter a valid city.");
		theform.logincity.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.loginpostal.value))
	{
		alert("Please enter a valid 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 (!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("Sorry, your email and confirmation email are not the same.");
		theform.loginconfirmemail.focus();
		return false;
	}
	
	if (!IsUsername(theform.loginusername.value))
	{
		alert("Please enter a valid username. (MIN. 5 characters)");
		theform.loginusername.focus();
		return false;
	}

	if (!IsPassword(theform.loginpassword.value))
	{
		alert("Please enter a valid password. (MIN. 5 characters)");
		theform.loginpassword.focus();
		return false;
	}
	
	if (!IsPassword(theform.loginpasswordconfirm.value))
	{
		alert("Please enter a valid confirmation password. (MIN. 5 characters)");
		theform.loginpasswordconfirm.focus();
		return false;
	}
	
	if (theform.loginpassword.value != theform.loginpasswordconfirm.value)
	{
		alert("Sorry, your password and confirmation password are not the same.");
		theform.loginpasswordconfirm.focus();
		return false;
	}
	
	return true;
}


/*
	purpose:
		used in the rental item section panel
	page:
		/rental_equipment/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckRentalItemForm(theform,theid,theproduct)
{
	var temp_field_name="rental_" + theid;
	var temp_field_message=theproduct + " Rental Date";
	
	if (!CheckDate(theform,temp_field_name,temp_field_message))
		return false;
	
	return true;
}


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

function CheckPickupForm(theform)
{
	if (!IsWordNumberSpecial(theform.pickupinvoicename.value))
	{
		alert("Please enter a the customers name on the invoice.");
		theform.pickupinvoicename.focus();
		return false;
	}
	
	if (!IsPhone(theform.pickupphone.value))
	{
		alert("Please enter a valid phone number.");
		theform.pickupphone.focus();
		return false;
	}
	
	
	if (!IsEmail(theform.pickupemail.value))
	{
		alert("Please enter a valid email address.");
		theform.pickupemail.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.pickuprequestname.value))
	{
		alert("Please enter your name.");
		theform.pickuprequestname.focus();
		return false;
	}
	
	if (!IsNumber(theform.pickupcontractnumber.value))
	{
		alert("Please enter a valid contract number.");
		theform.pickupcontractnumber.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.pickuptime.value))
	{
		alert("Please enter a pickup time.");
		theform.pickuptime.focus();
		return false;
	}
	
	if (!CheckDate(theform,"pickupdate","Pickup Date"))
		return false;
	
	if (!IsDescription(theform.pickupaddress.value))
	{
		alert("Please enter a valid pickup address.");
		theform.pickupaddress.focus();
		return false;
	}
	
	if (theform.pickupinstructions.value.length > 0)
	{
		if (!IsDescription(theform.pickupinstructions.value))
		{
			alert("Please enter any additional instructions.");
			theform.pickupinstructions.focus();
			return false;
		}
	}
	
	if (theform.terms_conditions.checked == false)
	{
		alert("Please indicate that you have read and agree to our Terms and Conditions.");
		theform.terms_conditions.focus();
		return false;
	}
	
	theform.submit();
	//return true;
}



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

function CheckCategoryForm(theform)
{
	if (!IsWordNumberSpecial(theform.categoryname.value))
	{
		alert("Please enter a valid category name.");
		theform.categoryname.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 control panel
	page:
		/admin/category/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckSearchForm(theform)
{
	if (!IsWordNumberSpecial(theform.search.value) || theform.search.value.length <= 1)
	{
		
		alert("Please enter valid search criteria.");
		theform.search.focus();
		return false;
	}
	return true;
}

/*
	purpose:
		used in the rental list 'cart' area
	page:
		/rental_list/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/


function CheckUpdateRentalList(theform)
{

	theform.submit();
}



/*
	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 cart page
	page:
		/shop/store/cart/index.cfm
	Parameters:
		thecategory - product category
		thesubcateogry - product subcategory
		theorderdetailid - orderdetail id
		thepage - step in the checkout process hte person came from
		
*/
	
function RemoveItemList(thecategory,thesubcategory,theorderdetailid,thepage)
{
	var delete_item=true;
	
	delete_item=confirm("Do you really want to remove this item from your rental list?");
	
	if (delete_item)
		window.location.href="/bin/cf_delete_from_list.cfm?requesttimeout=5000&categoryid"+thecategory+"&subcategoryid="+thesubcategory+"&recordid="+theorderdetailid+"&from="+thepage;
}

/*
	purpose:
		used in the cart page
	page:
		/cart/index.cfm
	Parameters:
		thecategory - product category
		thesubcateogry - product subcategory
		theorderdetailid - orderdetail id
		thepage - step in the checkout process hte person came from
		
*/
	
function RemoveItem(thecategory,thesubcategory,theorderdetailid,thepage)
{
	var delete_item=true;
	
	delete_item=confirm("Do you really want to remove this item from your cart?");
	
	if (delete_item)
		window.location.href="/bin/cf_delete_from_cart.cfm?requesttimeout=5000&categoryid"+thecategory+"&subcategoryid="+thesubcategory+"&recordid="+theorderdetailid+"&from="+thepage;
}