// LOAD 'GENERALVALIDATE.JS' BEFORE
// THIS FILE IN YOUR HTML PAGE

// ERROR CHECK HOLDER FOR FIELD CHECKING FUNCTIONS BELOW
var isOkay = true;

aFieldList = new Array();
aFieldList[0] = "isLetter(document.forms[\"f1\"].name, \"your last name\");"
aFieldList[1] = "isLetter(document.forms[\"f1\"].firstname, \"your first name\");"
aFieldList[2] = "isAlpha(document.forms[\"f1\"].address, \"your address\");"
aFieldList[3] = "isLetter(document.forms[\"f1\"].city, \"your city\");"
aFieldList[4] = "isLetter(document.forms[\"f1\"].state, \"your state\");"
aFieldList[5] = "isAlpha(document.forms[\"f1\"].zip, \"a valid ZIP code\");"
aFieldList[6] = "isSelected(document.forms[\"f1\"].country, \"your country\");"
aFieldList[7] = "isAlpha(document.forms[\"f1\"].daytimephone, \"your daytime phone\");"
aFieldList[8] = "isAlpha(document.forms[\"f1\"].email, \"a valid email address\");"
//aFieldList[9] = "isChecked(document.forms[\"f1\"].billing, \"0\", \"a billing method\");"
aFieldList[9] = "isAlpha(document.forms[\"f1\"].ccname, \"the payment card holder name\");"
//aFieldList[11] = "isDigit(document.forms[\"f1\"].ccnumber, \"a valid payment card number\");"
//aFieldList[12] = "isAlpha(document.forms[\"f1\"].ccexpiration, \"the payment card expiration date\");"


function CheckForm(){

	calc_total();

	if ((qty_sails == 0) && (qty_acc == 0)) {
		alert ("No item has been selected.");
		document.f1.main1.focus();
		return false;
		}
	else
		{
    	iLength = aFieldList.length;
   		 for(i = 0; i < iLength; i++){
      		  if(isOkay){
           	 //alert("i = " + i);
			 
           	 isOkay = eval(aFieldList[i]);
			
        	}
    	}
	}
	
   if(isOkay){
		if (document.f1.caller.value == "client") {
	 	 CheckCCInformation();
		}
  	 	}
  
   
   
   if(isOkay){
//        alert("Congratulations!\n\nYou successfully completed the form");
      
        document.forms["f1"].submit();
    } else {
        fax_errors = false;
        isOkay = true;
    }

}