// Form Field Validation

function RequireNotZero(thefield, thename)
{
	if(thefield.value <= 0)
	{
		alert('Please enter a value in the \''+thename+'\' field');
		thefield.focus();
	} else {
		return true;
	}
		
}

function NotZeroNoFocus(thefield, thename)
{
	if(thefield.value <= 0)
	{
		alert('Please enter a value in the \''+thename+'\' field');
	} else {
		return true;
	}
		
}

function RequireNotEmpty(thefield, thename)
{
	if(thefield.value == "")
	{
		alert('Please enter your '+thename+' in the \''+thename+'\' field');
		thefield.focus();
	} else {
		return true;
	}
}

function RequireEmail(thefield, thename)
{
	var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
  	if (!re_mail.test(thefield.value))
  	{
    	alert("Please enter your email address in the \"Email\" field.");
    	thefield.focus();
  	} else {
		return true;
	}
}

function RequireCANPostal(thefield, thename) {
	var re_postal  = /^\s*[a-ceghj-npr-tvxy]\d[a-z](\s)?\d[a-z]\d\s*$/i;
  	//check for valid US Zipcode
	if(!re_postal.test(thefield.value))
	{
		alert('Please enter your '+thename+' in the \''+thename+'\' field');
		thefield.focus();
 	} else {
	  	return true;
	}
}

function RequireUSZip(thefield, thename) {
	var re_zip  = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
  	//check for valid US Zipcode
	if(!re_zip.test(thefield.value))
	{
		alert('Please enter your '+thename+' in the \''+thename+'\' field');
		thefield.focus();
 	} else {
	  	return true;
	}
}

function ValidateCard(thefield, theCard) {
	if(theCard == 'VISA') {
		var re_cc  = /^4[0-9]{15}$/;
	}
	if(theCard == 'Mastercard') {
		var re_cc  = /^5[1-5]{1}[0-9]{14}$/;
	}
	if(!re_cc.test(thefield.value))
	{
		alert('Your credit card number does not seem to match the card type you selected');
		thefield.focus();
	} else {
		return true;
	}
	
}