	function formatCurrency(num) {
		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;
		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);
	}
	
	function valPassfrm() {
		var bad=''
		if(document.frmpass.Email.value==''||valEmail(document.frmpass.Email.value)==false){bad+='You must enter a valid email address.\n';}
		if(bad!=''){
			alert('You must correct a few things before submitting this form:\n\n'+bad);
			return false;
		}else{return true;}
	}
	
	function valRegform(frm) {
		var bad = ''
		if(document.frmreg.Company_Name.value==''){bad+='You must enter a company name.\n';}
		if(document.frmreg.Contact_FName.value==''){bad+='You must enter a contact first name.\n';}
		if(document.frmreg.Contact_LName.value==''){bad+='You must enter a contact last name.\n';}
		if(document.frmreg.Address1.value==''){bad+='You must enter a street address.\n';}
		if(document.frmreg.City.value==''){bad+='You must enter a city.\n';}
		if(document.frmreg.State.value==''){bad+='You must enter a state.\n';}
		if(document.frmreg.Zip_Code.value==''){bad+='You must enter a postal code.\n';}
		if(document.frmreg.Phone_number.value==''){bad+='You must enter a phone number.\n';}
		if(document.frmreg.Fax_number.value==''){bad+='You must enter a fax number.\n';}
		if(document.frmreg.Web_address.value==''){bad+='You must enter a web address.\n';}
		if((document.frmreg.Email.value=='')||(valEmail(document.frmreg.Email.value)==false)){bad+='You must enter a valid email.\n';}
		if(document.frmreg.Password.value==''||document.frmreg.Password.value.length<5){
			bad+='You must enter a password (atleast 5 characters).\n';
		}else{
			if(document.frmreg.Password.value!=document.frmreg.Password2.value){bad+='Your passwords do not match.\n';}
		}
        myOption = -1;
        for (i=document.frmreg.ADA_Needs.length-1; i > -1; i--) {
        if (document.frmreg.ADA_Needs[i].checked) {
        myOption = i; i = -1;
            }
        }
        if (myOption == -1) {bad+='You must select an ADA needs status';}



		if(bad!=''){
			alert('You must correct a few things before submitting this form:\n\n'+bad);
			return false;
		}else{return true;}
	}



                  	
	function valBoothform(frm){
		var bad='';
		
		        myOption = -1;
        for (i=document.frmbooth.BoothClass.length-1; i > -1; i--) {
        if (document.frmbooth.BoothClass[i].checked) {
        myOption = i; i = -1;
            }
        }
        if (myOption == -1) {bad+='You must select a booth size.\n';}
        
        
        myOption = -1;
        for (i=document.frmbooth.Corner_Request.length-1; i > -1; i--) {
        if (document.frmbooth.Corner_Request[i].checked) {
        myOption = i; i = -1;
            }
        }
        if (myOption == -1) {bad+='You must request or decline a Aisle Corner.\n';}
        myOption = -1;
        
        for (i=document.frmbooth.Insurance_Bought.length-1; i > -1; i--) {
        if (document.frmbooth.Insurance_Bought[i].checked) {
        myOption = i; i = -1;
            }
        }
        if (myOption == -1) {bad+='Please accept or decline insurance coverage.\n';}
        if (document.frmbooth.Loc_Pref_1.value =='0'&&document.frmbooth.Loc_Pref_2.value =='0'&&document.frmbooth.Loc_Pref_3.value =='0') {bad+='Please select at least on Booth Selection.\n';}
        if (document.frmbooth.Loc_Pref_1.value ==''&&document.frmbooth.Loc_Pref_2.value ==''&&document.frmbooth.Loc_Pref_3.value =='') {bad+='Please select at least on Booth Selection.\n';}
		if(bad!=''){
			alert('You must correct a few things before submitting this form:\n\n'+bad);
			return false;
		}else{return true;}
	}

	function valbuyersguide(frm) {
		var bad = ''
        myOption = -1;
        for (i=document.frmbuyersguide.Minor_League_Baseball_Licensee.length-1; i > -1; i--) {
        if (document.frmbuyersguide.Minor_League_Baseball_Licensee[i].checked) {
        myOption = i; i = -1;
            }
        }
        if (myOption == -1) {bad+='You must enter Minor League Licensee Status.\n';}

        myOption = -1;
        for (i=document.frmbuyersguide.Major_League_Baseball_Licensee.length-1; i > -1; i--) {
        if (document.frmbuyersguide.Major_League_Baseball_Licensee[i].checked) {
        myOption = i; i = -1;
            }
        }
        if (myOption == -1) {bad+='You must enter Major League Licensee Status.\n';}


		if(bad!=''){
			alert('You must correct a few things before submitting this form:\n\n'+bad);
			return false;
		}else{return true;}
	}
	
	function valEmail(email){
		return (email.indexOf(".") > 2) && (email.indexOf("@") > 0);
	}
	

	
	function valPayfrm() {
		var bad='';
		if(document.frmpay.Firstname.value==''){bad+='You must enter the name on card.\n';}
		if(document.frmpay.Lastname.value==''){bad+='You must enter the name on card.\n';}
		if(document.frmpay.CardNumber.value==''){bad+='You must enter the card number.\n';}
		if(document.frmpay.CardCVV2.value==''){bad+='You must enter the card CVV2.\n';}
		if(document.frmpay.Insurance.checked==0){bad+='You must acknowledge the Insurance Policy.\n';}
		if(document.frmpay.CardType.selectedIndex==0){bad+='You must select a card type.\n';}

		if(bad!=''){
			alert('You must correct a few things before submitting this form:\n\n'+bad);
			return false
		}else{return true;}
	}

	
function mod10_bak( cardNumber ) { // LUHN Formula for validation of credit card numbers.
	var ar = new Array( cardNumber.length );
	var i = 0,sum = 0;


    	for( i = 0; i < cardNumber.length; ++i ) {
    		ar[i] = parseInt(cardNumber.charAt(i));
    	}
    	for( i = ar.length -2; i >= 0; i-=2 ) { // you have to start from the right, and work back.
    		ar[i] *= 2;							 // every second digit starting with the right most (check digit)
    		if( ar[i] > 9 ) ar[i]-=9;			 // will be doubled, and summed with the skipped digits.
    	}										 // if the double digit is > 9, ADD those individual digits together 


        	for( i = 0; i < ar.length; ++i ) {
        		sum += ar[i];						 // if the sum is divisible by 10 mod10 succeeds
        	}
        	return (((sum%10)==0)?true:false);	 	
    }


function validateCard( cardNumber, cardType ) {
    for( var i = 0; i < cardNumber.length; ++i ) {		// make sure the number is all digits.. (by design)
  	    var c = cardNumber.charAt(i);
   		    if( c < '0' || c > '9' ) {
  		        return false;
   		        }
        } 
       	var length = cardNumber.length;			//perform card specific length and prefix tests
           	switch( cardType ) {
                case 2:
        			if( length != 16 ) {
              			return false;
               			}
           			var prefix = parseInt( cardNumber.substring(0,2));
           			if( prefix < 51 || prefix > 55) {
           				return false;
               			}
          			break;
           		case 1:
        			if( length != 16 && length != 13 ) {
          			    return false;
          		        }
           			var prefix = parseInt( cardNumber.substring(0,1));
			        if( prefix != 4 ) {
            			return false;
              			}
            		break;
               	}
               	if( !mod10( cardNumber ) ) { 		// run the check digit algorithm
               		return false;
                   	}
               	return true; // at this point card has not been proven to be invalid
      }
 
	
	
	function valCCexp(exp) {
		if(exp.indexOf('/')!=2){
			return false;
		}else{
			var arrdate = exp.split('/')
			if(arrdate.length==2){
				if(!isNaN(arrdate[0])||!isNaN(arrdate[1])){
					if(arrdate[0].length==2&&arrdate[1].length==2){return true;}else{return false;}
				}else{return false;}
			}else{return false;}
		}
	}
	

	function valDate(thedate){
		if(thedate.search('/')!=-1){
			var arrdate = thedate.split('/');
			if(arrdate.length==3){
				if((arrdate[0].length<3&&arrdate[0].length!=0)&&(arrdate[1].length<3&&arrdate[1].length!=0)&&(arrdate[2].length==4)){
					if(!isNaN(arrdate[0])&&!isNaN(arrdate[1])&&!isNaN(arrdate[2])){
						return true;
					}else{
						return false;
					}
				}else{
					return false;
				}
			}else{
				return false;
			}
		}else{
			return false;
		}
	}
	
	function disablePaymentfrm() {
		document.frmpay.CardType.disabled=true;
		document.frmpay.CardType.className='Box-Disabled';
		document.frmpay.NameOnCard.disabled=true;
		document.frmpay.NameOnCard.className='Box-Disabled';
		document.frmpay.CardNumber.disabled=true;
		document.frmpay.CardNumber.className='Box-Disabled';
		document.frmpay.CardCVV2.disabled=true;
		document.frmpay.CardCVV2.className='Box-Disabled';
		document.frmpay.ExpDate.disabled=true;
		document.frmpay.ExpDate.className='Box-Disabled';
		document.frmpay.action.disabled=true;
	}
	
	function y2k(number)    { return (number < 1000) ? number + 1900 : number; }
	var today = new Date();
	var day   = today.getDate();
	var month = today.getMonth();
	var year  = y2k(today.getYear());
	var mywindow;
	var curfield;
	function padout(number) { return (number < 10) ? '0' + number : number; }
	function restart() {
	    curfield.value = '' + padout(month - 0 + 1) + '/' + padout(day) + '/' + year;
	    mywindow.close();
	}
	
	function selDate(curf) {
		curfield = curf;
	    mywindow = window.open('_tools/datesel/datesel.asp','myname','resizable=0,width=350,height=165');
	    mywindow.location.href = '_tools/datesel/datesel.asp';
	    if (mywindow.opener == null) mywindow.opener = self;
	}

function cardval(s) {
// remove non-numerics
var v = "0123456789";
var w = "";
for (i=0; i < s.length; i++) {
x = s.charAt(i);
if (v.indexOf(x,0) != -1)
w += x;
}
// validate number
j = w.length / 2;
if (j < 6.5 || j > 8 || j == 7) return false;
k = Math.floor(j);
m = Math.ceil(j) - k;
c = 0;
for (i=0; i<k; i++) {
a = w.charAt(i*2+m) * 2;
c += a > 9 ? Math.floor(a/10 + a%10) : a;
}
for (i=0; i<k+m; i++) c += w.charAt(i*2+1-m) * 1;
return (c%10 == 0);
}
	