// JavaScript Document
<!--
function ValidationClass()
{	
	this.ValidTextField = function(frmName,fieldName,required,aMessage)
	{
		var isEmpty = document[frmName][fieldName].value == "";
		if (required)
		{
			if(isEmpty)
			{
				this.showValidationMessage(aMessage);
				this.setFieldFocus(frmName,fieldName);
				this.assignRequiredFieldClass(frmName,fieldName);
				return false;
			}
		}
		return true;
	}
	
	this.ValidPasswordField = function(frmName,fieldName,matchFieldName,required,aMessage,aMatchMessage)
	{
		var isEmpty = false;
		var isMatch = false;
		if (required)
		{
			isEmpty = document[frmName][fieldName].value == "";
			isMatch = this.isPasswordMatch(frmName,fieldName,matchFieldName);

			if(isEmpty)
			{
				this.showValidationMessage(aMessage);
				this.setFieldFocus(frmName,fieldName);
				this.assignRequiredFieldClass(frmName,fieldName);
				return false;
			}
			
			if (!isMatch)
			{
				this.showValidationMessage(aMatchMessage);
				this.setFieldFocus(frmName,matchFieldName);
				this.assignRequiredFieldClass(frmName,matchFieldName);
				return false;
			}
		}
		return true;
	}
	
	this.isPasswordMatch = function(frmName,fieldName,matchFieldName)
		{return document[frmName][fieldName].value == document[frmName][matchFieldName].value;}
	
	this.ValidNumericTextField = function(frmName,fieldName,required,aMessage)
	{
		var isEmpty = document[frmName][fieldName].value == "";
		var isNumeric = this.onlyNumbers(document[frmName][fieldName].value);
		if (required)
		{
			if(isEmpty)
			{
				this.showValidationMessage(aMessage);
				this.setFieldFocus(frmName,fieldName);
				this.assignRequiredFieldClass(frmName,fieldName);
				return false;
			}
			
			if(!isNumeric)
			{
				this.showValidationMessage(aMessage);
				this.setFieldFocus(frmName,fieldName);
				this.assignRequiredFieldClass(frmName,fieldName);
				return false;
			}
		}
		return true;
	}
	
	this.ValidNumericFirstCharTextField = function(frmName,fieldName,required,aMessage)
	{
		var isEmpty = document[frmName][fieldName].value == "";
		var isNumeric = this.onlyNumbers(document[frmName][fieldName].value.substring(0,1));
				
		if (required)
		{
			if(isEmpty)
			{
				this.showValidationMessage(aMessage);
				this.setFieldFocus(frmName,fieldName);
				this.assignRequiredFieldClass(frmName,fieldName);
				return false;
			}
			
			if(!isNumeric)
			{
				this.showValidationMessage(aMessage);
				this.setFieldFocus(frmName,fieldName);
				this.assignRequiredFieldClass(frmName,fieldName);
				return false;
			}
		}
		return true;
	}
	
	this.ValidEmailField = function(frmName,fieldName,required,aMessage)
	{
		var isEmpty = document[frmName][fieldName].value == "";
		if (required)
		{
			if(isEmpty)
			{
				this.showValidationMessage(aMessage);
				this.setFieldFocus(frmName,fieldName);
				this.assignRequiredFieldClass(frmName,fieldName);
				return false;
			}
		}
		return true;
	}
	
	this.showValidationMessage = function(aString){alert(aString);}

	this.resetRequiredTextInput = function(inputObj)
	{
		if (document.frmContact[inputObj.name].value == "")
		{
			document.frmContact[inputObj.name].className = "txtRequiredField";
		} else {
			document.frmContact[inputObj.name].className = "txtField";
		}
	}
	
	this.assignRequiredFieldClass = function(frmName,fieldName)
		{
			// stop the CSS effect
			//return true;
			if( !!document.all && !!document[frmName] && !!document[frmName][fieldName] ) document[frmName][fieldName].className = "txtRequiredField";
		}
		
	this.setFieldFocus = function(frmName,fieldName)
		{document[frmName][fieldName].focus();}
		
	this.ValidPOBoxAddressField = function(frmName,fieldName)
	{
		var inputString = document[frmName][fieldName].value;
		if (inputString.indexOf("PO BOX") == -1)
		{
			var s = "You have indicated this is PO BOX address in the Continental U.S.\n"
				+ "To prevent delays in shipping your order, please type PO BOX in all\n"
				+ " capital letters followed by your PO BOX number. See example below."
				+ "\n "
				+ "\nExample:"
				+ "\nPO BOX 200";
			this.showValidationMessage(s);
			this.setFieldFocus(frmName,fieldName);
			this.assignRequiredFieldClass(frmName,fieldName);
			return false;
		}
		return true;
	}
	
	this.gbblnPoBox = function(inputString)
	{
		return (/^\W*p\W*o\W*box.*$/i.test(inputString));
	}
	
	this.onlyNumbers = function(inputString)
	{
	  var regExpObj = /(^\d+$)|(^\d+\.\d+$)/;
	  if (regExpObj.test(inputString)){ return true;}
	  return false;
	} 
}
//-->