// These three prototypes remove white space.
		String.prototype.trim=function(){
		    return this.replace(/^\s*|\s*$/g,'');
		}
		
		String.prototype.ltrim=function(){
		    return this.replace(/^\s*/g,'');
		}
		
		String.prototype.rtrim=function(){
		    return this.replace(/\s*$/g,'');
		}

// Make sure they are entering a numeric value into a text field.
		function verifyNum(tField) {
			
			if(tField.value<0) tField.value = (tField.value * -1)
		
			var TO 	= tField.value;
			var nTO = 0;
			var nib = 0;
		
			if(isNaN(TO)){
				for (i=0;i<TO.length;i++) {
					nib = TO.substring(i,i+1);
					if(!isNaN(nib) && nib != " ") {
						nTO += nib;
					}
				}
			}
			else { nTO = TO }
			// Only change the form field if the value has changed.
			if (tField.value != nTO) tField.value = (nTO*1);
		}

// Make sure they are entering a numeric value into a text field, allowing for decimals.
		function verifyDec(tField) {
			
			if(tField.value<0) tField.value = (tField.value * -1)
		
			var TO 	= tField.value;
			var nTO = 0;
			var nib = 0;
		
			if(isNaN(TO)){
				for (i=0;i<TO.length;i++) {
					nib = TO.substring(i,i+1);
					if((!isNaN(nib) && nib != " ")||nib == ".") {
						nTO += nib;
					}
				}
			}
			else { nTO = TO }
			// Only change the form field if the value has changed.
			if (tField.value != nTO) tField.value = (nTO*1);
		}
		

// Default for ajax call
		var xmlHttp;

// Function for creating a new xml object.
		function GetXmlHttpObject() { 
			var objXMLHttp=null
			if (window.XMLHttpRequest) {
				objXMLHttp=new XMLHttpRequest()
			}
			else if (window.ActiveXObject) {
				objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
			}
			return objXMLHttp
		}

// Function for validating U.S. Zip codes
		function isZip(s) 
		{
		     // Check for correct zip code
		     reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
		 
		     if (!reZip.test(s)) {
		          return false;
		     }
		 
		return true;
		}
		
// Function for validating Canadian Postal Codes.
		function isPostal(postalcode) {
			if (postalcode.length == 6 && postalcode.search(/^[a-zA-Z]\d[a-zA-Z]\d[a-zA-Z]\d$/) != -1) return true;
			else if (postalcode.length == 7 && postalcode.search(/^[a-zA-Z]\d[a-zA-Z](-|\s)\d[a-zA-Z]\d$/) != -1) return true;
			else return false;
		}
 
// Function for formatting currency.
	function formatCurrency(num,dolSign) {
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		cents = "0" + cents;
		// If they want a dollar sign and commas include it, otherwise just format it.
		if (dolSign) {
			for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
			num = num.substring(0,num.length-(4*i+3))+','+
			num.substring(num.length-(4*i+3));
			return (((sign)?'':'-') + '$' + num + '.' + cents);
		} 
		else {
			return (((sign)?'':'-') + num + '.' + cents);
		}
	}

// Function for validating an email address.
	var testresults
	function checkEmail(emailIN){
		var str=emailIN
		//old email check
		//var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

		//regular expression to check valid email addy
		var filter=/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a-z]{2,3})|(aero|coop|info|museum|name))$/ 

		if (filter.test(str))
			return true
		else{
			return false
		}
	}


// Just as it sounds.
	function AddZero(num) {    
		return ((num >= 0)&&(num < 10))?"0"+num:num+"";
	} 

/*This function will split a value into an array using space as a delimiter,
convert the first letter of each word to upper case the respost the value.*/
	function capitalize(cIN) {
		// Split value into an array.
		var x = cIN.value.split(" ");
		//Loop through array.
		for(i=0;i<x.length;i++) {
			x[i] = x[i].substring(0,1).toUpperCase() + x[i].substring(1,x[i].length);
		}
		//Set the changed value
		cIN.value = x.join(" ");
	}

	

// this function will do a MOD check on the cc number.
	function ccModCheck(ccNumb) {
	
		var valid = "0123456789"  		// Valid digits in a credit card number
		var len = ccNumb.length;  		// The length of the submitted cc number
		var iCCN = parseInt(ccNumb);  	// integer of ccNumb
		var sCCN = ccNumb.toString();  	// string of ccNumb
		sCCN = sCCN.replace (/^\s+|\s+$/g,'');  // strip spaces
		var iTotal = 0;  // integer total set at zero
		var bNum = true;  // by default assume it is a number
		var bResult = false;  // by default assume it is NOT a valid cc
		var temp;  // temp variable for parsing string
		var calc;  // used for calculation of each digit
	
		// Determine if it is the proper length 
	    for(var i=len;i>0;i--){  // LOOP throught the digits of the card
			calc = parseInt(iCCN) % 10;  // right most digit
	      	calc = parseInt(calc);  // assure it is an integer
	      	iTotal += calc;  // running total of the card number as we loop - Do Nothing to first digit
	      	i--;  // decrement the count - move to the next digit in the card
	      	iCCN = iCCN / 10;                               // subtracts right most digit from ccNumb
	      	calc = parseInt(iCCN) % 10 ;    // NEXT right most digit
	      	calc = calc *2;                                 // multiply the digit by two
	      	// Instead of some screwy method of converting 16 to a string and then parsing 1 and 6 and then adding them to make 7,
	      // I use a simple switch statement to change the value of calc2 to 7 if 16 is the multiple.
	      	switch(calc){
	        	case 10: calc = 1; break;       //5*2=10 & 1+0 = 1
		        case 12: calc = 3; break;       //6*2=12 & 1+2 = 3
		        case 14: calc = 5; break;       //7*2=14 & 1+4 = 5
		        case 16: calc = 7; break;       //8*2=16 & 1+6 = 7
		        case 18: calc = 9; break;       //9*2=18 & 1+8 = 9
		        default: calc = calc;           //4*2= 8 &   8 = 8  -same for all lower numbers
			}                                               
		    iCCN = iCCN / 10;  // subtracts right most digit from ccNum
		    iTotal += calc;  // running total of the card number as we loop
		}  // END OF LOOP
	
		if ((iTotal%10)==0){  // check to see if the sum Mod 10 is zero
	    	bResult = true;  // This IS (or could be) a valid credit card number.
	  	} 
		else {
	    	bResult = false;  // This could NOT be a valid credit card number
	    }
		return bResult; // Return the results
	}
		
