/*
	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'))
		return false;
		
	return true;
}


/*
	purpose:
		used in the control panel
	page:
		/admin/productdetail/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckAdminProductDetailForm(theform)
{
		
	if (!IsWordNumberSpecial(theform.productdetailcode.value))
	{
		alert("Please enter a valid product code.");
		theform.productdetailcode.focus();
		return false;
	}
	
	if (theform.productdetailname.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.productdetailname.value))
		{
			alert("Please enter a valid product detail name.");
			theform.productdetailname.focus();
			return false;
		}
	}
	
	if (theform.productdetaillabel.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.productdetaillabel.value))
		{
			alert("Please enter a valid product detail label.");
			theform.productdetaillabel.focus();
			return false;
		}
	}
	
	if (theform.productdetailamount.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.productdetailamount.value))
		{
			alert("Please enter a valid product detail amount.");
			theform.productdetailamount.focus();
			return false;
		}
	}
	
	if (!IsPrice(theform.productdetailpriceusd.value))
	{
		alert("Please enter a valid product price.");
		theform.productdetailpriceusd.focus();
		return false;
	}
	
	if (!IsPrice(theform.productdetailshippingusd.value))
	{
		alert("Please enter a valid shipping price.");
		theform.productdetailshippingusd.focus();
		return false;
	}
	
	return true;
}



/*
	purpose:
		used in the contact page
	page:
		/about/roi/bdc_doctor/
	Parameters:
		theform - object reference to the form being passed
*/

function CheckBDCDoctorForm(theform)
{

	if (!IsDescription(theform.bdcdoctorquestion.value))
	{
		alert("Please enter your question for the BDC Doctor.");
		theform.bdcdoctorquestion.focus();
		return false;
	}
	
	theform.submit();
	//return true;
}

/*
	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.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 (!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.  i.e. xxx-xxx-xxxx ext xxxx");
		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;
	}
	
	theform.submit();
	//return true;
}


/*
	purpose:
		used in the employment page
	page:
		/employment/employment_form.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckEmploymentApplicationForm(theform)
{
	var temp_value="";

	if (!IsWordNumberSpecial(theform.employmentapplicationfirstname.value))
	{
		alert("Please enter your first name.");
		theform.employmentapplicationfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.employmentapplicationlastname.value))
	{
		alert("Please enter your last name.");
		theform.employmentapplicationlastname.focus();
		return false;
	}

	if (!IsWordNumberSpecial(theform.employmentapplicationaddress.value))
	{
		alert("Please enter your address.");
		theform.employmentapplicationaddress.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.employmentapplicationcity.value))
	{
		alert("Please enter your city.");
		theform.employmentapplicationcity.focus();
		return false;
	}
	
	if (theform.stateid[theform.stateid.selectedIndex].value == "")
	{
		alert("Please select a valid state/province.");
		theform.stateid.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.employmentapplicationpostal.value))
	{
		alert("Please enter your postal/zip code.");
		theform.employmentapplicationpostal.focus();
		return false;
	}

	if (!IsPhone(theform.employmentapplicationphone.value))
	{
		alert("Please enter a valid phone number.  i.e. xxx-xxx-xxxx ext xxxx");
		theform.employmentapplicationphone.focus();
		return false;
	}
	
	if (!IsEmail(theform.employmentapplicationemail.value))
	{
		alert("Please enter a valid email address.");
		theform.employmentapplicationemail.focus();
		return false;
	}
	
	if (!IsEmail(theform.employmentapplicationconfirmemail.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.employmentapplicationconfirmemail.focus();
		return false;
	}
	
	if (theform.employmentapplicationemail.value != theform.employmentapplicationconfirmemail.value)
	{
		alert("Your email address and confirmation email address do not match.");
		theform.employmentapplicationconfirmemail.focus();
		return false;
	}
	
	
	temp_value=theform.employmentapplicationresumefile.value;
		
	if (temp_value.length > 0)
	{
		if (!IsFileExtensionDocument(temp_value.substring(temp_value.lastIndexOf("."),temp_value.length)))
		{
			alert("Please select a valid file for uploading (must be .doc, .txt, .pdf or .rtf).");
			theform.employmentapplicationresumefile.focus();
			return false;
		}
	}
	
	theform.submit();
	//return true;
}


/*
	purpose:
		used in the control panel page
	page:
		/admin/employment/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckEmploymentForm(theform)
{
	var temp_value="";
	
	if (!IsWordNumberSpecial(theform.jobtitle.value))
	{
		alert("Please enter a job title.");
		theform.jobtitle.focus();
		return false;
	}

	if (!IsWordNumberSpecial(theform.jobsalary.value))
	{
		alert("Please enter a job salary.");
		theform.jobsalary.focus();
		return false;
	}	
	

	if (!IsDescription(theform.jobdescription.value))
	{
		alert("Please enter a job description.");
		theform.jobdescription.focus();
		return false;
	}

	if (!CheckDate(theform,'jobposteddate','Posted Date'))
		return false;
		
	if (!CheckDate(theform,'jobclosingdate','Closing Date'))
		return false;
	
	//if we are supposed to upload a file
	if (theform.uploadfile.value == 1)
	{
		temp_value=theform.jobattachment_file.value;
		
		if (temp_value.length > 0)
		{
			if (!IsFileExtension(temp_value.substring(temp_value.lastIndexOf("."),temp_value.length)))
			{
				alert("Please select an valid file for uploading (must be .doc, .txt, .pdf, .ppt, .xls, .zip).");
				theform.jobattachment_file.focus();
				return false;
			}
		}
	}

	return true;
}

/*
	purpose:
		used in the inquiry form (training and workshop directories)signup page
	page:
		/training OR workshop/
	Parameters:
		theform - object reference to the form being passed
*/

function CheckInquiryForm(theform)
{

	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.inquirycompany.value))
	{
		alert("Please enter your company name.");
		theform.inquirycompany.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.inquirytitle.value))
	{
		alert("Please enter your title.");
		theform.inquirytitle.focus();
		return false;
	}
	
	if (theform.stateid[theform.stateid.selectedIndex].value == "")
	{
		alert("Please select a valid state/province.");
		theform.stateid.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.inquirypostal.value))
	{
		alert("Please enter your zip/postal code.");
		theform.inquirypostal.focus();
		return false;
	}

	
	if (!IsPhone(theform.inquiryphone.value))
	{
		alert("Please enter a valid phone number.  i.e. xxx-xxx-xxxx ext xxxx");
		theform.inquiryphone.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;
	}
	
	if (theform.inquirycomments.value.length > 0)
	{
		if (!IsDescription(theform.inquirycomments.value))
		{
			alert("Please enter some comments.");
			theform.inquirycomments.focus();
			return false;
		}
	}
	
	theform.submit();
	//return true;
}



/*
	purpose:
		used in the front end 
	page:
		/bin/cf_display_header_navigation.cfm
	Parameters:
		theform - object reference to the form being passed
*/
function CheckKeywordSearchForm(theform)
{
	if (!IsWordNumberSpecial(theform.searchtext.value))
	{
		alert("Please enter a valid keyword.");
		theform.searchtext.focus();
		return false;
	}
	
	
	return true;
}


/*
	purpose:
		used in the control panel
	page:
		/admin/news/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckNewsForm(theform)
{
	
	if (!IsWordNumberSpecial(theform.newstitle.value))
	{
		alert("Please enter a valid title.");
		theform.newstitle.focus();
		return false;
	}
	
	if (!IsDescription(theform.newstagline.value))
	{
		alert("Please enter a valid tagline.");
		theform.newstagline.focus();
		return false;
	}

	if (!IsDescription(theform.newsstory.value))
	{
		alert("Please enter a valid story.");
		theform.newsstory.focus();
		return false;
	}
	
	if (theform.newspage.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.newspage.value))
		{
			alert("Please enter a valid page.");
			theform.newspage.focus();
			return false;
		}
	}
	
	if (theform.newssection.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.newssection.value))
		{
			alert("Please enter a valid section.");
			theform.newssection.focus();
			return false;
		}
	}
	
	if (theform.newsbyline.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.newsbyline.value))
		{
			alert("Please enter a valid by line.");
			theform.newsbyline.focus();
			return false;
		}
	}
		
	if (!IsWordNumberSpecial(theform.newssource.value))
	{
		alert("Please enter a valid source.");
		theform.newssource.focus();
		return false;
	}
	
	if (!CheckDate(theform,'newsdate','News Date'))
		return false;
		
	if (!CheckDate(theform,'newsstartdate','News Start Date'))
		return false;
		
	if (!CheckDate(theform,'newsenddate','News End Date'))
		return false;
			
	//if we are supposed to upload a file
	if (theform.uploadimage.value == 1)
	{
		temp_value=theform.newsimage_file.value;
		
		if (temp_value.length > 0)
		{
			if (!IsImageExtension(temp_value.substring(temp_value.lastIndexOf("."),temp_value.length)))
			{
				alert("Please select an valid image for uploading (must be .gif or .jpg).");
				theform.newsimage_file.focus();
				return false;
			}
		}
	}		
			
	//if we are supposed to upload a file
	if (theform.uploadthumbnail.value == 1)
	{
		temp_value=theform.newsthumbnail_file.value;
		
		if (temp_value.length > 0)
		{
			if (!IsImageExtension(temp_value.substring(temp_value.lastIndexOf("."),temp_value.length)))
			{
				alert("Please select an valid thumbnail for uploading (must be .gif or .jpg).");
				theform.newsthumbnail_file.focus();
				return false;
			}
		}
	}				

	return true;
}


/*
	purpose:
		used in the newsletter signup section
	page:
		/newsletter/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckNewsletterSignupForm(theform)
{
	if (!IsWordNumberSpecial(theform.mailinglistdealername.value))
	{
		alert("Please enter a valid dealer name.");
		theform.mailinglistdealername.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.mailinglistfirstname.value))
	{
		alert("Please enter a valid first name.");
		theform.mailinglistfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.mailinglistlastname.value))
	{
		alert("Please enter a valid last name.");
		theform.mailinglistlastname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.mailinglistaddress.value))
	{
		alert("Please enter a valid address.");
		theform.mailinglistaddress.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.mailinglistcity.value))
	{
		alert("Please enter a valid city.");
		theform.mailinglistcity.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.mailinglistpostal.value))
	{
		alert("Please enter a valid zip/postal code.");
		theform.mailinglistpostal.focus();
		return false;
	}
	
	
	if (!IsPhone(theform.mailinglistphone.value))
	{
		alert("Please enter a valid phone number.  i.e. xxx-xxx-xxxx ext xxxx");
		theform.mailinglistphone.focus();
		return false;
	}
	
	
	if (!IsPhone(theform.mailinglistfax.value))
	{
		alert("Please enter a valid fax number.");
		theform.mailinglistfax.focus();
		return false;
	}
	
	
	if (!IsEmail(theform.mailinglistemail.value))
	{
		alert("Please enter a valid email address.");
		theform.mailinglistemail.focus();
		return false;
	}
	
	if (!IsEmail(theform.mailinglistemailconfirm.value))
	{
		alert("Please enter a valid confirm email address.");
		theform.mailinglistemailconfirm.focus();
		return false;
	}
	
	if ((theform.mailinglistemail.value) != (theform.mailinglistemailconfirm.value))
	{
		alert("Your email and confirmation email address are not the same.");
		theform.mailinglistemail.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.mailinglistwebsite.value))
	{
		alert("Please enter a valid web site address.");
		theform.mailinglistwebsite.focus();
		return false;
	}
	
	return true;
}

/*
	purpose:
		used in the control panel
	page:
		/admin/product/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckProductForm(theform)
{
	var thumbnail_value="";
	var image_value="";
	
	if (!IsWordNumberSpecial(theform.productname.value))
	{
		alert("Please enter a valid product name.");
		theform.productname.focus();
		return false;
	}
	
	if (!IsDescription(theform.productshortdescription.value))
	{
		alert("Please enter a valid short description.");
		theform.productshortdescription.focus();
		return false;
	}
	
	if (!IsDescription(theform.productdescription.value))
	{
		alert("Please enter a valid description.");
		theform.productdescription.focus();
		return false;
	}
	
	if (theform.productthumbnailtitle.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.productthumbnailtitle.value))
		{
			alert("Please enter a valid thumbnail title.");
			theform.productthumbnailtitle.focus();
			return false;
		}
	}
	
	
	if (theform.productimagetitle.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.productimagetitle.value))
		{
			alert("Please enter a valid product name.");
			theform.productimagetitle.focus();
			return false;
		}
	}
	
	//if we are supposed to upload an thumbnail
	if (theform.uploadthumbnail.value == 1)
	{
		thumbnail_value=theform.productthumbnail_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.productthumbnail_file.focus();
			return false;
		}
	}
			
	//if we are supposed to upload an image
	if (theform.uploadimage.value == 1)
	{
	 	image_value=theform.productimage_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.productimage_file.focus();
			return false;
		}
	}
						
	return true;
}



/*
	purpose:
		used in the cart page
	page:
		/<sectionname>/product_detail.cfm
	Parameters:
		theform - object reference to the form being passed
		is_edit - if the user is editing a quantity, 
*/

function CheckProductDetailForm(theform, is_edit)
{

	if (is_edit)
	{
		if (theform.quantity[theform.quantity.selectedIndex].value == 0)
		{
			return confirm("Selecting a quantity of 0 will remove this item from your cart.  Do you wish to proceed?");
		}
	}
	else
	{
		if (theform.quantity[theform.quantity.selectedIndex].value == 0)
		{
			alert("Please select a quantity greater than 0.");
			theform.quantity.focus();
			return false;
		}
	}
	
	return true;
}


/*
	purpose:
		used in the roi calculator pages
	page:
		/about/roi/roi_calculator/
	Parameters:
		theform - object reference to the form being passed
*/

function CheckROICalculatorForm(theform,thestep)
{
	//depending on which step of the form we are on
	switch (thestep){
		case 1: 
			if (!IsPrice(theform.current_budget.value))
			{
				alert("Please enter your current advertising budget.")
				theform.current_budget.focus()
				return false
			}
			
			if (!IsPrice(theform.total_gross_profit.value))
			{
				alert("Please enter your total gross profit.")
				theform.total_gross_profit.focus()
				return false
			}
			CalculateROI(theform,thestep)
			break;
		case 2: 
			if (!IsPrice(theform.total_monthly_sales.value))
			{
				alert("Please enter your current monthly sales.")
				theform.total_monthly_sales.focus()
				return false
			}
			
			if (!IsPrice(theform.closing_ratio.value))
			{
				alert("Please enter your approximate closing ration.")
				theform.closing_ratio.focus()
				return false
			}
			CalculateROI(theform,thestep)
			break;
		case 3: 
			if (!IsPrice(theform.current_repeat_referral.value))
			{
				alert("Please enter your current repeat and referral sales.")
				theform.current_repeat_referral.focus()
				return false
			}
			
			if (!IsPrice(theform.minimum_repeat_referral_bdr.value))
			{
				alert("Please enter your minimum repeat & referral sales per BDR.")
				theform.minimum_repeat_referral_bdr.focus()
				return false
			}
			
			CalculateROI(theform,thestep)
			break;
		case 4: 
			if (!IsPrice(theform.current_internet_leads.value))
			{
				alert("Please enter your current internet leads.")
				theform.current_internet_leads.focus()
				return false
			}
			
			CalculateROI(theform,thestep)
			break;
		default : 
			CalculateROI(theform,thestep)
	}
	
	
	theform.submit();
	//return true;
}


/*
	purpose:
		used in the roi signup page
	page:
		/about/roi/index
	Parameters:
		theform - object reference to the form being passed
*/

function CheckROIInfoForm(theform)
{

	if (!IsWordNumberSpecial(theform.roiinfofirstname.value))
	{
		alert("Please enter your first name.");
		theform.roiinfofirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.roiinfolastname.value))
	{
		alert("Please enter your last name.");
		theform.roiinfolastname.focus();
		return false;
	}

	if (!IsWordNumberSpecial(theform.roiinfocompany.value))
	{
		alert("Please enter your company name.");
		theform.roiinfocompany.focus();
		return false;
	}
	
	if (theform.stateid[theform.stateid.selectedIndex].value == "")
	{
		alert("Please select a valid state/province.");
		theform.stateid.focus();
		return false;
	}
	
	if (!IsPhone(theform.roiinfophone.value))
	{
		alert("Please enter a valid phone number.  i.e. xxx-xxx-xxxx ext xxxx");
		theform.roiinfophone.focus();
		return false;
	}
	
	if (!IsEmail(theform.roiinfoemail.value))
	{
		alert("Please enter a valid email address.");
		theform.roiinfoemail.focus();
		return false;
	}
	
	if (!IsEmail(theform.roiinfoemailconfirm.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.roiinfoemailconfirm.focus();
		return false;
	}
	
	if (theform.roiinfoemail.value != theform.roiinfoemailconfirm.value)
	{
		alert("Your email address and confirmation email address do not match.");
		theform.roiinfoemailconfirm.focus();
		return false;
	}
	
	theform.submit();
	//return true;
}




/*
	purpose:
		used in the signup form (training and workshop directories)signup page
	page:
		/training OR workshop/
	Parameters:
		theform - object reference to the form being passed
*/

function CheckSignupForm(theform)
{

	if (!IsWordNumberSpecial(theform.signupfirstname.value))
	{
		alert("Please enter your first name.");
		theform.signupfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.signuplastname.value))
	{
		alert("Please enter your last name.");
		theform.signuplastname.focus();
		return false;
	}

	if (!IsWordNumberSpecial(theform.signupcompany.value))
	{
		alert("Please enter your company name.");
		theform.signupcompany.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.signuptitle.value))
	{
		alert("Please enter your title.");
		theform.signuptitle.focus();
		return false;
	}
	
	if (theform.stateid[theform.stateid.selectedIndex].value == "")
	{
		alert("Please select a valid state/province.");
		theform.stateid.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.signuppostal.value))
	{
		alert("Please enter your zip/postal code.");
		theform.signuppostal.focus();
		return false;
	}

	
	if (!IsPhone(theform.signupphone.value))
	{
		alert("Please enter a valid phone number.  i.e. xxx-xxx-xxxx ext xxxx");
		theform.signupphone.focus();
		return false;
	}
	
	if (!IsEmail(theform.signupemail.value))
	{
		alert("Please enter a valid email address.");
		theform.signupemail.focus();
		return false;
	}
	
	if (!IsEmail(theform.signupemailconfirm.value))
	{
		alert("Please enter a valid confirmation email address.");
		theform.signupemailconfirm.focus();
		return false;
	}
	
	if (theform.signupemail.value != theform.signupemailconfirm.value)
	{
		alert("Your email address and confirmation email address do not match.");
		theform.signupemailconfirm.focus();
		return false;
	}
	
	if (theform.signupcomments.value.length > 0)
	{
		if (!IsDescription(theform.signupcomments.value))
		{
			alert("Please enter some comments.");
			theform.signupcomments.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/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:
		/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="/form_action/cf_delete_from_cart.cfm?requesttimeout=5000&categoryid"+thecategory+"&subcategoryid="+thesubcategory+"&recordid="+theorderdetailid+"&from="+thepage;
}



/*
	purpose:
		used in the login section
	page:
		/login/forgot_password.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckStaffForgotPasswordForm(theform)
{
	
	if (!IsEmail(theform.loginemailaddress.value))
	{
		alert("Please enter a valid email address.");
		theform.loginemailaddress.focus();
		return false;
	}
	
	theform.submit();
}



/*
	purpose:
		used in the front of site
	page:
		/login/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckStaffLoginForm(theform)
{

	if (theform.loginusername.value.length < 5)
	{
		alert("Please enter a valid username.");
		theform.loginusername.focus();
		return false;
	}

	if (!IsPassword(theform.loginpassword.value))
	{
		alert("Please enter a valid password. (MIN. 5 characters)");
		theform.loginpassword.focus();
		return false;
	}

	theform.submit();
}


/*
	purpose:
		used in the control panel
	page:
		/admin/workshopcalendar/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckWorkshopCalendarForm(theform)
{
		
	if (theform.workshopcalendarsubtitle.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.workshopcalendarsubtitle.value))
		{
			alert("Please enter a valid sub title.");
			theform.workshopcalendarsubtitle.focus();
			return false;
		}
	}
	
	if (!CheckDate(theform,'workshopcalendarstartdate','Start Date'))
		return false;
		
	if (!CheckDate(theform,'workshopcalendarenddate','End Date'))
		return false;
		
	
	if (!IsWordNumberSpecial(theform.workshopcalendarcity.value))
	{
		alert("Please enter a valid city.");
		theform.workshopcalendarcity.focus();
		return false;
	}
	
	if (!IsPrice(theform.workshopcalendarprice.value))
	{
		alert("Please enter a valid price.");
		theform.workshopcalendarprice.focus();
		return false;
	}
	
	return true;
}


