/*the base image directory location*/
var base = "/images/";

/*********
pop up a new window
*********/
function openWindow(url,x,y,toolbar,scrollbars,resizable)
{
	if(x == 0)
	{
		x = 720;
	}

	if(y == 0)
	{
		y = 520;
	}

	new_x=x+20;
	new_y=y+20;
	var options = "toolbar=" + toolbar + ",scrollbars=" + scrollbars + ",resizable=" + resizable + ",width=" + new_x + ",height=" + new_y;
	newWindow=window.open(url,"WinOpen",options);
}

/*********
switch an image by changing the src name from 'off' to 'on' and vice versa
*********/
function toggleImage(obj)
{
	// The image is currently in the OFF state
	if (obj.src.indexOf('_off.') < 0)
	{
		obj.src = obj.src.replace('_on', '_off');
	}
	// The image is currently in the ON state
	else
	{
		obj.src = obj.src.replace('_off', '_on');
	}
}

/*********
switch an image with an ID
*********/
function switchImage(thisId,thisImageSlice)
{
	//is the text "_off" inside this btn?
	if (document.getElementById(thisId).src.indexOf('_off.') < 0)
	{
		thisImg=base+thisImageSlice+thisId+'_off.gif';
	}
	else
	{
		thisImg=base+thisImageSlice+thisId+'_on.gif';
	}
	//set the image
	document.getElementById(thisId).src=thisImg;
}

/*********
change the main image depending on the number given to the function
*********/
function changeMainImage(imageNum)
{
	obj = document.getElementById("homeMainImage");
	obj.src = base + 'home_main_img_' + imageNum + '.jpg';
}

function changeMainImageDelayed(imageNum)
{
	setTimeout('changeMainImage(' + imageNum + ')',100);
}

/*********
expand code for both browsers
*********/
function expandIt(whichEl){
	var browser=navigator.userAgent.toLowerCase();
	var pos=browser.indexOf("gecko");
	var myElement = document.getElementById(whichEl);
	//do for Gecko Browsers
	if (pos>=0) {
		if (myElement.style.visibility == 'visible') {
			myElement.style.visibility = 'hidden';
			myElement.style.position = 'absolute';
			}
		else {
			myElement.style.position = 'relative';
			myElement.style.visibility = 'visible';
			}
	//do for IE
	} else {
		myElement.style.display = (myElement.style.display == "none" ) ? "" : "none";
	}
}


/*********
switch an image by changing the src name from 'off' to 'on' and vice versa
*********/
function changeBenefitsChart(obj)
{
	// Get all the html objects
	titleObj = document.getElementById('benefitsChartTitle');
	imageObj = document.getElementById('benefitsChartImage');
	linkObj = document.getElementById('benefitsChartLink');

	dogIconObj = document.getElementById('beneftsChartIconDog');
	catIconObj = document.getElementById('beneftsChartIconCat');
	horseIconObj = document.getElementById('beneftsChartIconHorse');
	birdIconObj = document.getElementById('beneftsChartIconBird');

	// set the title
	titleObj.src = "images/home_benefitschart_text_" + obj + ".gif";

	// set the image
	imageObj.src = "images/img_benefitschart_" + obj + ".gif";

	// set the image's href link
	if(obj == 'dog')
	{
		linkObj.href = "/#dog";
	}
	else if(obj == 'cat')
	{
		linkObj.href = "/#cat";
	}
	else if(obj == 'horse')
	{
		linkObj.href = "/#horse";
	}
	else if(obj == 'bird')
	{
		linkObj.href = "/#bird";
	}

	// set all icons to the off state
	dogIconObj.src = dogIconObj.src.replace('_on', '_off');
	catIconObj.src = catIconObj.src.replace('_on', '_off');
	horseIconObj.src = horseIconObj.src.replace('_on', '_off');
	birdIconObj.src = birdIconObj.src.replace('_on', '_off');

	// set selected icon to the on state
	selectedIcon = eval(obj + 'IconObj');
	selectedIcon.src = selectedIcon.src.replace('_off', '_on');
}

/*********
expand code for both browsers
*********/
function expandIt(whichEl){
	var browser=navigator.userAgent.toLowerCase();
	var pos=browser.indexOf("gecko");
	var myElement = document.getElementById(whichEl);
	//do for Gecko Browsers
	if (pos>=0) {
		if (myElement.style.visibility == 'visible') {
			myElement.style.visibility = 'hidden';
			myElement.style.position = 'absolute';
			}
		else {
			myElement.style.position = 'relative';
			myElement.style.visibility = 'visible';
			}
	//do for IE
	} else {
		myElement.style.display = (myElement.style.display == "none" ) ? "" : "none";
	}
}

/*********
toggle the text inside a form on/off
*********/
function toggleFormText(thisId, thisText)
{
	//alert(document.getElementById(thisId).value + ',' + thisText);
	if (document.getElementById(thisId).value == thisText)
	{
		document.getElementById(thisId).value='';
	}
	else if (document.getElementById(thisId).value == '')
	{
		document.getElementById(thisId).value=thisText;
	}
}

/************
toggleSelectMenus - This function hides all select menus on an html page. In IE the select box is always on top so this function counters that bug by
			   hiding the select boxes so drop down menus aren't trumped. Toggle needs to be either: 'hidden' or 'visible'.
************/
function toggleSelectMenus(toggle) {

	// Loop through all the forms on the page
	for (i=0; i < document.forms.length; i++) {

		// Loop through the form's fields
		for (j=0; j < document.forms[i].length; j++) {

			// Test whether form object is a drop down menu
			if (getFormType(document.forms[i].elements[j]) == 'select') {

				document.forms[i].elements[j].style.visibility = toggle;
			}
		}

	}
}

/************
getFormType - Returns a string name of the type of form object. The types are: select, radio, button, submit, hidden, textarea, text
************/
function getFormType(formObject)
{
	type = formObject.type;

	// Make the select type simpler, we don't care which kind of select as long as it's a select
	if ((formObject.type == 'select-one') || (formObject.type == 'select-multiple'))
		type = 'select';

	return type;
}

/*********
validates an email address
*********/
function validateEmail(thisEmail)
{
	//initiate returnMessage variable
	var returnMessage="";

	if(thisEmail == '')
	{
		// alert the user
		returnMessage = "Please type in a valid email address.";
	}
	else
	{
		// function to check email address vilidity
		function emailCheck(emailStr)
		{
			/* The following pattern is used to check if the entered e-mail address
			   fits the user@domain format.  It also is used to separate the username
			   from the domain. */
			var emailPat=/^(.+)@(.+)$/
			/* The following string represents the pattern for matching all special
			   characters.  We don't want to allow special characters in the address.
			   These characters include ( ) < > @ , ; : \ " . [ ]    */
			var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
			/* The following string represents the range of characters allowed in a
			   username or domainname.  It really states which chars aren't allowed. */
			var validChars="\[^\\s" + specialChars + "\]"
			/* The following pattern applies if the "user" is a quoted string (in
			   which case, there are no rules about which characters are allowed
			   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
			   is a legal e-mail address. */
			var quotedUser="(\"[^\"]*\")"
			/* The following pattern applies for domains that are IP addresses,
			   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
			   e-mail address. NOTE: The square brackets are required. */
			var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
			/* The following string represents an atom (basically a series of
			   non-special characters.) */
			var atom=validChars + '+'
			/* The following string represents one word in the typical username.
			   For example, in john.doe@somewhere.com, john and doe are words.
			   Basically, a word is either an atom or quoted string. */
			var word="(" + atom + "|" + quotedUser + ")"
			// The following pattern describes the structure of the user
			var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
			/* The following pattern describes the structure of a normal symbolic
			   domain, as opposed to ipDomainPat, shown above. */
			var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


			/* Finally, let's start trying to figure out if the supplied address is
			   valid. */

			/* Begin with the coarse pattern to simply break up user@domain into
			   different pieces that are easy to analyze. */
			var matchArray=emailStr.match(emailPat);
			//alert(emailStr);
			var checkMatch='-' + matchArray + '-';
			if (checkMatch == "-null-")
			{
			  /* Too many/few @'s or something; basically, this address doesn't
				 even fit the general mould of a valid e-mail address. */
				returnMessage = "The email address seems incorrect (check @ and .'s).";
			}
			else
			{
				var user=matchArray[1];
				var domain=matchArray[2];

				// See if "user" is valid
				if (user.match(userPat)==null)
				{
					// user is not valid
					returnMessage = "The email's username doesn't seem to be valid (before the @).";
				}

				/* if the e-mail address is at an IP address (as opposed to a symbolic
				   host name) make sure the IP address is valid. */
				var IPArray=domain.match(ipDomainPat)
				if (IPArray!=null) {
					// this is an IP address
					  for (var i=1;i<=4;i++) {
						if (IPArray[i]>255) {
							returnMessage = "The email's destination IP address is invalid.";
						}
					}
				}

				// Domain is symbolic name
				var domainArray=domain.match(domainPat)
				if (domainArray==null) {
					returnMessage = "The email's domain name doesn't seem to be valid (after the @).";
				}

				/* domain name seems valid, but now make sure that it ends in a
				   three-letter word (like com, edu, gov) or a two-letter word,
				   representing country (uk, nl), and that there's a hostname preceding
				   the domain or country. */

				/* Now we need to break up the domain to get a count of how many atoms
				   it consists of. */
				var atomPat=new RegExp(atom,"g")
				var domArr=domain.match(atomPat)
				var len=domArr.length
				if (domArr[domArr.length-1].length<2 ||
					domArr[domArr.length-1].length>4) {
				   // the address must end in a two letter or three letter word.
				   returnMessage = "The email must end in a four-letter domain, three-letter domain, or two letter country.";
				}

				// Make sure there's a host name preceding the domain.
				if (len < 2) {
				   returnMessage="This email is missing a hostname!";
				}
			}
		}
		// call the validation function and return its result
		val=emailCheck(thisEmail);
		// if it returns val=no_submit, stop form
	}
	return returnMessage;
}

/************
verify Contact Form
************/
function verifyContactForm()
{
	//form variables
	submitBtnMessage='Saving... Please Wait';
	formName='formContact';

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";

	//check first name
	if (submitForm)
	{
		formElement="name_first";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your first name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check last name
	if (submitForm)
	{
		formElement="name_last";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your last name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check the email
	if (submitForm)
	{
		formElement="email_address";
		thisDOM=eval('document.' + formName + '.' + formElement);
		//check the email address
		thisMessage=validateEmail(thisDOM.value);
		//if there is no message sent back, set the alert.
		if (thisMessage.length != 0)
		{
			warningMessage=thisMessage;
			formFocus=formElement;
			submitForm=false;
		}
	}
	//check comment
	if (submitForm)
	{
		formElement="comments";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in a comment.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//disable the form if the form checks out
	if (!submitForm)
	{
		alert(warningMessage);
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}

/************
verify Newsletter
************/
function verifyNewsletterSubscribe(checkboxCount)
{
	//form variables
	submitBtnMessage='Saving... Please Wait';
	formName='formNewsletterSubscribe';

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";

	//check name_first
	if (submitForm)
	{
		formElement="name_first";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your first name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check name
	if (submitForm)
	{
		formElement="name_last";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your last name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check the email
	if (submitForm)
	{
		formElement="email_address";
		thisDOM=eval('document.' + formName + '.' + formElement);
		//check the email address
		thisMessage=validateEmail(thisDOM.value);
		//if there is no message sent back, set the alert.
		if (thisMessage.length != 0)
		{
			warningMessage=thisMessage;
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check for newsletter category checked
	if (submitForm)
	{
		newsletterSelected=false;
		formElement="newsletter_categories";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// loop thru all the checkboxes in the page
		for (var i=1; i <= checkboxCount; i++)
		{
			if (document.getElementById('checkbox' + i).checked)
			{
				newsletterSelected=true;
			}
		}
		// no newsletter selected, don't submit the form
		if (!newsletterSelected)
		{
			warningMessage="Please select a newsletter to subscribe to.";
			submitForm=false;
		}
	}

	//disable the form if the form checks out
	if (!submitForm)
	{
		alert(warningMessage);
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}

/************
verify Send to a Friend
************/
function verifySendToAFriend()
{
	//form variables
	submitBtnMessage='Sending... Please Wait';
	formName='formSendToAFriend';

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";
	toEmailFound=false;

	//check friends_emails
	if (submitForm)
	{
		formElement="to_email_1";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in an email address.';
			formFocus=formElement;
			submitForm=false;
		}
		// verify correctly formed email
		else
		{
			// set variable so next function knows a to_email has been found
			toEmailFound=true;
			//check the email address
			thisMessage=validateEmail(thisDOM.value);
			//if there is no message sent back, set the alert.
			if (thisMessage.length != 0)
			{
				warningMessage=thisMessage;
				formFocus=formElement;
				submitForm=false;
				toEmailFound=true;
			}
		}
	}

	//check the second email
	if (!toEmailFound)
	{
		formElement="to_email_2";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in an email address.';
			formFocus="to_email_1";
			submitForm=false;
		}
		// verify correctly formed email
		else
		{
			// set variable so next function knows a to_email has been found
			toEmailFound=true;
			//check the email address
			thisMessage=validateEmail(thisDOM.value);
			//if there is no message sent back, set the alert.
			if (thisMessage.length != 0)
			{
				warningMessage=thisMessage;
				formFocus=formElement;
				submitForm=false;
			}
		}
	}

	//check the third email
	if (!toEmailFound)
	{
		formElement="to_email_3";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in an email address.';
			formFocus="to_email_1";
			submitForm=false;
		}
		// verify correctly formed email
		else
		{
			//check the email address
			thisMessage=validateEmail(thisDOM.value);
			//if there is no message sent back, set the alert.
			if (thisMessage.length != 0)
			{
				warningMessage=thisMessage;
				formFocus=formElement;
				submitForm=false;
			}
		}
	}

	//check from name
	if (submitForm)
	{
		formElement="from_name";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check the email
	if (submitForm)
	{
		formElement="from_email";
		thisDOM=eval('document.' + formName + '.' + formElement);
		//check the email address
		thisMessage=validateEmail(thisDOM.value);
		//if there is no message sent back, set the alert.
		if (thisMessage.length != 0)
		{
			warningMessage=thisMessage;
			formFocus=formElement;
			submitForm=false;
		}
	}

	//disable the form if the form checks out
	if (!submitForm)
	{
		alert(warningMessage);
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}

/************
verify Wholesale Form
************/
function verifyWholesaleForm()
{
	//form variables
	submitBtnMessage='Submitting Request... Please Wait';
	formName='formWholesale';

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";

	//check the title
	if (submitForm)
	{
		formElement="name";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please type in your company name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check the email
	if (submitForm)
	{
		formElement="email_address";
		thisDOM=eval('document.' + formName + '.' + formElement);
		//check the email address
		thisMessage=validateEmail(thisDOM.value);
		//if there is no message sent back, set the alert.
		if (thisMessage.length != 0)
		{
			warningMessage=thisMessage;
			formFocus=formElement;
			submitForm=false;
		}
	}

	//phone
	if (submitForm)
	{
		formElement="phone";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please type in your phone number.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//address
	if (submitForm)
	{
		formElement="address";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please type in your address.';
			formFocus=formElement;
			submitForm=false;
		}
	}
	//city
	if (submitForm)
	{
		formElement="city";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please type in your city.';
			formFocus=formElement;
			submitForm=false;
		}
	}
	//state
	if (submitForm)
	{
		formElement="state";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please type in your state.';
			formFocus=formElement;
			submitForm=false;
		}
	}
	//disable the form if the form checks out
	if (!submitForm)
	{
		alert(warningMessage);
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}

/************
set the same shipping address
************/
function setSameShippingAddress()
{
	// name
	document.getElementById('shipName').value=document.getElementById('cardName').value;
	// address
	document.getElementById('shipAddress').value=document.getElementById('billAddress').value;
	// city
	document.getElementById('shipCity').value=document.getElementById('billCity').value;
	// zip
	document.getElementById('shipZip').value=document.getElementById('billZip').value;
	// select the right state
	document.getElementById('shipState').selectedIndex=document.getElementById('billState').selectedIndex;
}

/************
set number to 2 decimal places
************/
function numberToHundredths(thisNumber)
{
        thisNumberFix = Math.round(thisNumber*100).toString();
        thisNumberFix = thisNumberFix.substring(0,thisNumberFix.length-2)+'.'+
        thisNumberFix.substring(thisNumberFix.length-2,thisNumberFix.length);
        return thisNumberFix;
}

/************
calculate all the Totals
************/
function calculateTotal()
{
        taxAmount=0;
        if (document.getElementById('billState').value == 'CA')
        {
                taxAmount=numberToHundredths(document.getElementById('chargeSubtotal').value * .0975);
        }
        // set the tax form field
        document.getElementById('chargeTax').value=taxAmount;
        // show the tax
        document.getElementById('taxHTML').innerHTML=taxAmount;
        // get the subtotal
        subtotal=document.getElementById('chargeSubtotal').value;
        // get the shipping cost
        shipping=document.getElementById('chargeShipping').value;
        // set the total
        total=parseFloat(taxAmount) + parseFloat(subtotal) + parseFloat(shipping);
        // set the total field
        document.getElementById('chargeTotal').value=total;
        // show the total
        document.getElementById('totalHTML').innerHTML=numberToHundredths(total);
		setCardNumber();
}

/************
set the full credit card number
************/
function setCardNumber()
{
	document.getElementById('cardNumber').value = document.getElementById('cardNumber_1').value + '-' + document.getElementById('cardNumber_2').value + '-' + document.getElementById('cardNumber_3').value + '-' + document.getElementById('cardNumber_4').value;
}
/************
verify Checkout Form
************/
function verifyCheckoutForm()
{
	//form variables
	submitBtnMessage='Submitting Request... Please Wait';
	formName='formCheckout';

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";

	//cardName
	if (submitForm)
	{
		formElement="cardName";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please type in the name on your credit card.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//cardNumber_1
	if (submitForm)
	{
		formElement="cardNumber_1";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please type in the first four numbers of your credit card.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//cardNumber_2
	if (submitForm)
	{
		formElement="cardNumber_2";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please type in the second four numbers of your credit card.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//cardNumber_3
	if (submitForm)
	{
		formElement="cardNumber_3";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please type in the third four numbers of your credit card.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//cardNumber_4
	if (submitForm)
	{
		formElement="cardNumber_4";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please type in the last four numbers of your credit card.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//cardVerificationNumber
	if (submitForm)
	{
		formElement="cardVerificationNumber";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please type in your card verification number.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//expiration_month
	if (submitForm)
	{
		formElement="expiration_month";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please select the month your credit card expires.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//expiration_year
	if (submitForm)
	{
		formElement="expiration_year";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please select the year your credit card expires.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//billAddress
	if (submitForm)
	{
		formElement="billAddress";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please type in your billing address.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//billCity
	if (submitForm)
	{
		formElement="billCity";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please type in your billing city.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//billState
	if (submitForm)
	{
		formElement="billState";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please select your billing state.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//billZip
	if (submitForm)
	{
		formElement="billZip";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please type in your billing zip.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//billPhone
	if (submitForm)
	{
		formElement="billPhone";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please type in your billing phone number.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	// billEmail
	if (submitForm)
	{
		formElement="billEmail";
		thisDOM=eval('document.' + formName + '.' + formElement);
		//check the email address
		thisMessage=validateEmail(thisDOM.value);
		//if there is no message sent back, set the alert.
		if (thisMessage.length != 0)
		{
			warningMessage=thisMessage;
			formFocus=formElement;
			submitForm=false;
		}
	}

	//shipName
	if (submitForm)
	{
		formElement="shipName";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please type in the name/company of the person receiving the shipment.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//shipAddress
	if (submitForm)
	{
		formElement="shipAddress";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please type in your shipping address.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//shipCity
	if (submitForm)
	{
		formElement="shipCity";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please type in your shipping city.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//shipState
	if (submitForm)
	{
		formElement="shipState";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please select your shipping state.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//shipZip
	if (submitForm)
	{
		formElement="shipZip";
		thisDOM=eval('document.' + formName + '.' + formElement);
		// make sure this value has a non-space character in it.
		if (thisDOM.value.search(/\S/) == -1)
		{
			warningMessage='Please type in your shipping zip.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	// set the cardnumber from the four credit card fields
	setCardNumber();

	// alert the user if there is a problem
	if (!submitForm)
	{
		alert(warningMessage);
	}
	// disable the form button
	else
	{
		document.getElementById('cartBtnOrder').src = '/images/btn_order_processing.gif';
		document.getElementById('cartBtnOrder').disabled = true;
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}

/************
verify Confirmation Form
************/
function verifyConfirmForm()
{
	//form variables
	submitBtnMessage = 'Submitting Request... Please Wait';
	formName = 'formConfirm';

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";
	shippingSelected = false;

	//shipping_type
	/*if (submitForm)
	{
		formElement="ship_select";
		thisDOM=eval('document.' + formName + '.' + formElement);
		for (i=0; i < thisDOM.length; i++)
		{
			if (thisDOM[i].checked)
			{
				shippingSelected = true;
				break;
			}
		}
		if (!shippingSelected)
		{
			warningMessage = 'Please select the shipping method for your products.';
			submitForm = false;
		}
	}*/

	//disable the form if the form checks out
	if (!submitForm)
	{
		alert(warningMessage);
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}


// loop thru all links in the page, and disable them only if not media library
function disableAllLinks ()
{
	for (var i=0; i < document.links.length; i++)
	{
		document.links[i].onclick=function () { return false; };
		document.links[i].title="All links are disabled while previewing a document.";
	}
	return true;
}
// loop thru all forms in the page, and disable them
function disableAllFormElements ()
{
	for (var i=0; i < document.forms.length; i++)
	{
		for (var j=0; j < document.forms[i].length; j++)
		{
			document.forms[i].elements[j].disabled = true;
		}
		document.forms[i].onfocus = function () {return false; };
		document.forms[i].onclick = function () { return false; };
		document.forms[i].title="All forms are disabled while previewing a document.";
	}
	return true;
}

/*********
Creates the verification code for a form
	DIRECTIONS:
	1. Add "return createFormVerification('FormName')" to the form's onSubmit. -- Where 'FormName' is the form's name.
	 OR
	1. Add this bit of HTML code somewhere on your form page, and click the link:
		<a href="javascript:createFormVerification('FormName')">Generate Form Verification</a>
	2. Make sure the form's action is disabled or the form is prevented from sending
	3. Submit the form
	4. Every field in the form will popup a message asking whether that field is required. Click 'yes' if it is required, 'no' if it is not required
	5. A new window or tab will be opened in the browser with the code for the form's javascript verification function. Copy and paste that code into the site's js_site.js
	6. Replace the form's onSubmit function call from the createFormVerification to the newly generated function's name

	NOTES:
	* This function only creates Enthusiast's default javascript verification for form fields. If additional verification is required, add the verification to the generated function. Also the warning messages for a required form element use the form element's name in the message. If this is not desired, it needs to be manually changed
	* The "getFormType" function (near the top of this file) is required for this function to work.

	LIMITS:
	This function DOES NOT do the following things:
	1. It does not check associated form elements. Example: Would not check a form field only if a certain checkbox is checked.
	2. It does not do "special" checking of form fields. Example: Would not verify that a form field only has numbers rather than text
*********/
function createFormVerification(form)
{
	// variables
	formDOM = eval('document.' + form);	// form object reference
	tab = '&nbsp;&nbsp;&nbsp;'
	checkboxesDone = '';	// list of checkboxes that have been processed
	radioButtonsDone = '';	// list of radio buttons that have been processed

	// create a new window for writing the verification code
	newWindow = window.open('', 'newWin')

	newWindow.document.write("function verify" + form.charAt(0).toUpperCase( ) + form.substr(1) + "()<BR>");
	newWindow.document.write("{<BR>");
	newWindow.document.write(tab + "// form variables<BR>");
	newWindow.document.write(tab + "submitBtnMessage = 'Saving... Please Wait';<BR>");
	newWindow.document.write(tab + "formName = '" + form + "';<BR><BR>");
	newWindow.document.write(tab + "submitForm = true;<BR><BR>");
	newWindow.document.write(tab + "// initialize submitForm value<BR>");
	newWindow.document.write(tab + "warningMessage = '';<BR>");
	newWindow.document.write(tab + "formFocus = '';<BR><BR>");

	// loop through all form elements
	for (i = 0; i < formDOM.length; i++)
	{
		formObj = formDOM[i]; // get form object reference
		elementType = getFormType(formObj); // get the type of form element (e.g. text, textarea, select, radio, checkbox, button, submit, hidden)

		// Don't do anything with hidden, submit, or button form types
		if(elementType != 'hidden' && elementType != 'submit' && elementType != 'button')
		{
			// CHECKBOXES
			if(elementType == 'checkbox')
			{
				// if we haven't added verification for this checkbox group, process it (otherwise it will do this for each checkbox)
				if(checkboxesDone.indexOf(formObj.name + ',') == -1)
				{
					// Is this checkbox group required?
					if(confirm("Is the form element, " + formObj.name + ", of type: '" + elementType + "' required?"))
					{
						newWindow.document.write(tab + "// check " + formObj.name + "<BR>");
						newWindow.document.write(tab + "if (submitForm)<BR>");
						newWindow.document.write(tab + "{<BR>");
						newWindow.document.write(tab + tab + "elementChecked = false;<BR>");
						newWindow.document.write(tab + tab + "i = 0;<BR>");
						newWindow.document.write(tab + tab + "formElement = '" + formObj.name + "';<BR>");
						newWindow.document.write(tab + tab + "thisDOM = eval('document.' + formName + '.' + formElement);<BR><BR>");
						newWindow.document.write(tab + tab + "// if there is only a single checkbox with this name<BR>");
						newWindow.document.write(tab + tab + "if(thisDOM.length == undefined)<BR>");
						newWindow.document.write(tab + tab + "{<BR>");
						newWindow.document.write(tab + tab + tab + "// if no element was checked, set message<BR>");
						newWindow.document.write(tab + tab + tab + "if (!thisDOM.checked)<BR>");
						newWindow.document.write(tab + tab + tab + "{<BR>");
						newWindow.document.write(tab + tab + tab + tab + "warningMessage = 'Please select a " + formObj.name.replace("_"," ") + ".';<BR>");
						newWindow.document.write(tab + tab + tab + tab +  "formFocus = formElement;<BR>");
						newWindow.document.write(tab + tab + tab + tab +  "submitForm = false;<BR>");
						newWindow.document.write(tab + tab + tab + "}<BR>");
						newWindow.document.write(tab + tab + "}<BR>");
						newWindow.document.write(tab + tab + "// else there are multiple checkboxes with this name<BR>");
						newWindow.document.write(tab + tab + "else<BR>");
						newWindow.document.write(tab + tab + "{<BR>");
						newWindow.document.write(tab + tab + tab + "// loop through each checkbox in the group and see if any of them are checked<BR>");
						newWindow.document.write(tab + tab + tab + "while (!elementChecked && (i < thisDOM.length))<BR>");
						newWindow.document.write(tab + tab + tab + "{<BR>");
						newWindow.document.write(tab + tab + tab + tab + "if (thisDOM[i].checked)<BR>");
						newWindow.document.write(tab + tab + tab + tab + "{<BR>");
						newWindow.document.write(tab + tab + tab + tab + tab + "elementChecked = true;<BR>");
						newWindow.document.write(tab + tab + tab + tab + "}<BR>");
						newWindow.document.write(tab + tab + tab + tab + "i++;<BR>");
						newWindow.document.write(tab + tab + tab + "}<BR>");
						newWindow.document.write(tab + tab + tab + "// if no element was checked, set message<BR>");
						newWindow.document.write(tab + tab + tab + "if (!elementChecked)<BR>");
						newWindow.document.write(tab + tab + tab + "{<BR>");
						newWindow.document.write(tab + tab + tab + tab + "warningMessage = 'Please select a " + formObj.name.replace("_"," ") + ".';<BR>");
						newWindow.document.write(tab + tab + tab + tab + "formFocus = formElement + '[0]';<BR>");
						newWindow.document.write(tab + tab + tab + tab + "submitForm = false;<BR>");
						newWindow.document.write(tab + tab + tab + "}<BR>");
						newWindow.document.write(tab + tab + "}<BR>");
						newWindow.document.write(tab + "}<BR><BR>");
					}
				}

				// Add checkbox object name to the checkboxsDone list
				checkboxesDone = checkboxesDone.concat(formObj.name + ',');
			}
			// RADIO BUTTONS
			else if(elementType == 'radio')
			{
				// if we haven't added verification for this checkbox group, process it (otherwise it will do this for each checkbox)
				if(radioButtonsDone.indexOf(formObj.name + ',') == -1)
				{
					// Is this checkbox group required?
					if(confirm("Is the form element, " + formObj.name + ", of type: '" + elementType + "' required?"))
					{
						newWindow.document.write(tab + "// check " + formObj.name + "<BR>");
						newWindow.document.write(tab + "if (submitForm)<BR>");
						newWindow.document.write(tab + "{<BR>");
						newWindow.document.write(tab + tab + "selected = false;<BR>");
						newWindow.document.write(tab + tab + "i = 0;<BR>");
						newWindow.document.write(tab + tab + "formElement = '" + formObj.name + "';<BR>");
						newWindow.document.write(tab + tab + "thisDOM = eval('document.' + formName + '.' + formElement);<BR><BR>");
						newWindow.document.write(tab + tab + "// loop through all radio buttons, if any button is selected, set the 'selected' variable to true<BR>");
						newWindow.document.write(tab + tab + "for(i = 0; i < thisDOM.length; i++)<BR>");
						newWindow.document.write(tab + tab + "{<BR>");
						newWindow.document.write(tab + tab + tab + "if (thisDOM[i].checked)<BR>");
						newWindow.document.write(tab + tab + tab + "{<BR>");
						newWindow.document.write(tab + tab + tab + tab + "selected = true;<BR>");
						newWindow.document.write(tab + tab + tab + "}<BR>");
						newWindow.document.write(tab + tab + "}<BR>");
						newWindow.document.write(tab + tab + "// If no radio button is selected<BR>");
						newWindow.document.write(tab + tab + "if (selected == false)<BR>");
						newWindow.document.write(tab + tab + "{<BR>");
						newWindow.document.write(tab + tab + tab + "warningMessage = 'Please select a " + formObj.name.replace("_"," ") + ".';<BR>");
						newWindow.document.write(tab + tab + tab + "formFocus = formElement + '[0]';<BR>");
						newWindow.document.write(tab + tab + tab + "submitForm = false;<BR>");
						newWindow.document.write(tab + tab + "}<BR>");
						newWindow.document.write(tab + "}<BR><BR>");
					}
				}

				// Add radio object name to the radioButtonsDone list
				radioButtonsDone = radioButtonsDone.concat(formObj.name + ',');
			}
			// ask user whether form element should be verified
			else if (confirm("Is the form element, " + formObj.name + ", of type: '" + elementType + "' required?"))
			{
				// TEXT
				if(elementType == 'text')
				{
					// Email Address Field
					// search for the word 'email' in the form object's name (Ignore case) and then ask the user if email verfication should be done to it
					if((formObj.name.search(/email/i) != -1) && (confirm("Should email verification be done to the '" + formObj.name + "' field?")))
					{
						newWindow.document.write(tab + "// check " + formObj.name + "<BR>");
						newWindow.document.write(tab + "if (submitForm)<BR>");
						newWindow.document.write(tab + "{<BR>");
						newWindow.document.write(tab + tab + "formElement = '" + formObj.name + "';<BR>");
						newWindow.document.write(tab + tab + "thisDOM = eval('document.' + formName + '.' + formElement);<BR><BR>");
						newWindow.document.write(tab + tab + "thisMessage = validateEmail(thisDOM.value);<BR>");
						newWindow.document.write(tab + tab + "if (thisMessage.length != 0)<BR>");
						newWindow.document.write(tab + tab + "{<BR>");
						newWindow.document.write(tab + tab + tab + "warningMessage = thisMessage;<BR>");
						newWindow.document.write(tab + tab + tab + "formFocus = formElement;<BR>");
						newWindow.document.write(tab + tab + tab + "submitForm = false;<BR>");
						newWindow.document.write(tab + tab + "}<BR>");
						newWindow.document.write(tab + "}<BR><BR>");
					}
					// Not an Email Address Field
					else
					{
						newWindow.document.write(tab + "// check " + formObj.name + "<BR>");
						newWindow.document.write(tab + "if (submitForm)<BR>");
						newWindow.document.write(tab + "{<BR>");
						newWindow.document.write(tab + tab + "formElement = '" + formObj.name + "';<BR>");
						newWindow.document.write(tab + tab + "thisDOM = eval('document.' + formName + '.' + formElement);<BR><BR>");
						newWindow.document.write(tab + tab + "if (thisDOM.value.search(/\\S/) == -1) // Check for at least one non-space character<BR>");
						newWindow.document.write(tab + tab + "{<BR>");
						newWindow.document.write(tab + tab + tab + "warningMessage = 'Please enter in your " + formObj.name.replace("_"," ") + ".';<BR>");
						newWindow.document.write(tab + tab + tab + "formFocus = formElement;<BR>");
						newWindow.document.write(tab + tab + tab + "submitForm = false;<BR>");
						newWindow.document.write(tab + tab + "}<BR>");
						newWindow.document.write(tab + "}<BR><BR>");
					}
				}
				// TEXTAREA
				else if(elementType == 'textarea')
				{
					newWindow.document.write(tab + "// check " + formObj.name + "<BR>");
					newWindow.document.write(tab + "if (submitForm)<BR>");
					newWindow.document.write(tab + "{<BR>");
					newWindow.document.write(tab + tab + "formElement = '" + formObj.name + "';<BR>");
					newWindow.document.write(tab + tab + "thisDOM = eval('document.' + formName + '.' + formElement);<BR><BR>");
					newWindow.document.write(tab + tab + "if (thisDOM.value.search(/\\S/) == -1) // Check for at least one non-space character<BR>");
					newWindow.document.write(tab + tab + "{<BR>");
					newWindow.document.write(tab + tab + tab + "warningMessage = 'Please enter in your " + formObj.name.replace("_"," ") + ".';<BR>");
					newWindow.document.write(tab + tab + tab + "formFocus = formElement;<BR>");
					newWindow.document.write(tab + tab + tab + "submitForm = false;<BR>");
					newWindow.document.write(tab + tab + "}<BR>");
					newWindow.document.write(tab + "}<BR><BR>");
				}
				// SELECT
				// Preconditions: This assumes that the default (non-selected) value is an empty string
				else if(elementType == 'select')
				{
					newWindow.document.write(tab + "// check " + formObj.name + "<BR>");
					newWindow.document.write(tab + "if (submitForm)<BR>");
					newWindow.document.write(tab + "{<BR>");
					newWindow.document.write(tab + tab + "formElement = '" + formObj.name + "';<BR>");
					newWindow.document.write(tab + tab + "thisDOM = eval('document.' + formName + '.' + formElement);<BR><BR>");
					newWindow.document.write(tab + tab + "if (thisDOM.value.search(/\\S/) == -1) // Check for at least one non-space character<BR>");
					newWindow.document.write(tab + tab + "{<BR>");
					newWindow.document.write(tab + tab + tab + "warningMessage = 'Please select a " + formObj.name.replace("_"," ") + ".';<BR>");
					newWindow.document.write(tab + tab + tab + "formFocus = formElement;<BR>");
					newWindow.document.write(tab + tab + tab + "submitForm = false;<BR>");
					newWindow.document.write(tab + tab + "}<BR>");
					newWindow.document.write(tab + "}<BR><BR>");
				}
			}
		}
	}

	newWindow.document.write(tab + "// disable the form if the form checks out<BR>");
	newWindow.document.write(tab + "if (!submitForm)<BR>");
	newWindow.document.write(tab + "{<BR>");
	newWindow.document.write(tab + tab + "alert(warningMessage);<BR>");
	newWindow.document.write(tab + "}<BR><BR>");
	newWindow.document.write(tab + "// focus the form if necessary<BR>");
	newWindow.document.write(tab + "if (formFocus.length > 0)<BR>");
	newWindow.document.write(tab + "{<BR>");
	newWindow.document.write(tab + tab + "thisDOM = eval('document.' + formName + '.' + formFocus);<BR>");
	newWindow.document.write(tab + tab + "thisDOM.focus();<BR>");
	newWindow.document.write(tab + "}<BR><BR>");
	newWindow.document.write(tab + "// return the boolean value whether or not we should submit this form<BR>");
	newWindow.document.write(tab + "return submitForm;<BR>");

	newWindow.document.write("}");

	// Close the document so everything will be written to window
	newWindow.document.close()
}

/*********
returns true if the phone number is valid, false otherwise
Valid:
(343) 234-3432
2342342342
234-242-2342
*********/
function isPhoneValid(phone_number)
{
	valid = true;

	if (thisDOM.value.search(/^(?:\([2-9]\d{2}\)\ ?|[2-9]\d{2}(?:\-?|\ ?))[2-9]\d{2}[- ]?\d{4}$/) == -1)
	{
		valid = false;
	}

	return valid;
}


/************
verify Store Locator Form
************/
function verifyStoreLocatorForm()
{
	//form variables
	submitBtnMessage='Saving... Please Wait';
	formName='formStoreLocator';
	wholeNumber = /\D/;

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";

	//check name
	if (submitForm)
	{
		formElement="area_code";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in an area code or zip code.';
			formFocus=formElement;
			submitForm=false;
		}
		// check the zip code
		formElement="zip";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (wholeNumber.exec(thisDOM.value))
		{
			warningMessage='Please type in an area code or zip code in numbers only.';
			formFocus=formElement;
			submitForm=false;
		}
		else
		{
			submitForm=true;
		}
	}


	//disable the form if the form checks out
	if (!submitForm)
	{
		alert(warningMessage);
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}

/************
verify Contact Form
************/
function verifyRetailerApplicationForm()
{
	//form variables
	submitBtnMessage='Saving... Please Wait';
	formName='formRetailer';

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";

	//check first name
	if (submitForm)
	{
		formElement="name_first";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your first name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check last name
	if (submitForm)
	{
		formElement="name_last";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your last name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check the position
	if (submitForm)
	{
		formElement="position";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your position name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check the company
	if (submitForm)
	{
		formElement="company";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your company\'s name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check the phone
	if (submitForm)
	{
		formElement="phone";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your phone number.';
			formFocus=formElement;
			submitForm=false;
		}
	}
	//check the email
	if (submitForm)
	{
		formElement="email_address";
		thisDOM=eval('document.' + formName + '.' + formElement);
		//check the email address
		thisMessage=validateEmail(thisDOM.value);
		//if there is no message sent back, set the alert.
		if (thisMessage.length != 0)
		{
			warningMessage=thisMessage;
			formFocus=formElement;
			submitForm=false;
		}
	}

	//disable the form if the form checks out
	if (!submitForm)
	{
		alert(warningMessage);
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}


/************
verify Sample Form
************/
function verifySampleForm()
{
	//form variables
	submitBtnMessage='Saving... Please Wait';
	formName='formSample';

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";

	//check name
	if (submitForm)
	{
		formElement="name";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check address
	if (submitForm)
	{
		formElement="address";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your address.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check city
	if (submitForm)
	{
		formElement="city";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your city.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check state
	if (submitForm)
	{
		formElement="state";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your state.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check zip
	if (submitForm)
	{
		formElement="zip";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your zip code.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check phone
	if (submitForm)
	{
		formElement="phone";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your phone number.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check the email
	if (submitForm)
	{
		formElement="email_address";
		thisDOM=eval('document.' + formName + '.' + formElement);
		//check the email address
		thisMessage=validateEmail(thisDOM.value);
		//if there is no message sent back, set the alert.
		if (thisMessage.length != 0)
		{
			warningMessage=thisMessage;
			formFocus=formElement;
			submitForm=false;
		}
	}

	//disable the form if the form checks out
	if (!submitForm)
	{
		alert(warningMessage);
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}

/************
verify Ask the Vet Form
************/
function verifyAskTheVetForm()
{
	//form variables
	submitBtnMessage='Saving... Please Wait';
	formName='formAskTheVet';

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";

	//check name
	if (submitForm)
	{
		formElement="pets_name";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your pet\'s name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check breed
	if (submitForm)
	{
		formElement="breed";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your pet\'s breed.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check weight
	if (submitForm)
	{
		formElement="weight";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your pet\'s weight.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check what_food_are_you_feeding
	if (submitForm)
	{
		formElement="what_food_are_you_feeding";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in what food you are feeding your pet.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check explanation_of_the_problem
	if (submitForm)
	{
		formElement="explanation_of_the_problem";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in a brief explanation of the problem.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check name
	if (submitForm)
	{
		formElement="name";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check the email
	if (submitForm)
	{
		formElement="email_address";
		thisDOM=eval('document.' + formName + '.' + formElement);
		//check the email address
		thisMessage=validateEmail(thisDOM.value);
		//if there is no message sent back, set the alert.
		if (thisMessage.length != 0)
		{
			warningMessage=thisMessage;
			formFocus=formElement;
			submitForm=false;
		}
	}

	//disable the form if the form checks out
	if (!submitForm)
	{
		alert(warningMessage);
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}

