<!--

function checkWholeForm(theForm) {
    var why = "";
    why += isEmpty(theForm.fname.value, 'First name');
    why += isEmpty(theForm.lname.value, 'Last name');
    why += checkEmail(theForm.email.value);
    why += isDifferent(theForm.passwd.value,theForm.passwd1.value);
    why += isEmpty(theForm.phone.value, 'Phone number');
    why += checkPassword(theForm.passwd.value);
    why += isEmpty(theForm.address.value, 'Address');
    why += isEmpty(theForm.city.value, 'City');
    why += isEmpty(theForm.state.value, 'State');
    why += isEmpty(theForm.zip.value, 'Zip');
    why += isEmpty(theForm.country.value, 'Country');
    if(!theForm.sameshipping.checked) {
    	why += isEmpty(theForm.shipfname.value, 'Shipping First name');
    	why += isEmpty(theForm.shiplname.value, 'Shipping Last name');
    	why += isEmpty(theForm.shipphone.value, 'Shipping Phone number');
    	why += isEmpty(theForm.shipaddress.value, 'Shipping Address');
    	why += isEmpty(theForm.shipcity.value, 'Shipping City');
    	why += isEmpty(theForm.shipstate.value, 'Shipping State');
    	why += isEmpty(theForm.shipzip.value, 'Shipping Zip');
    	why += isEmpty(theForm.shipcountry.value, 'Shipping Country');
    }

       if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function checkUserBillingForm(theForm) {
    var why = "";
    why += isEmpty(theForm.shipfname.value, 'First name');
    why += isEmpty(theForm.shiplname.value, 'Last name');
    why += isEmpty(theForm.shipphone.value, 'Phone number');
    why += isEmpty(theForm.shipaddress.value, 'Address');
    why += isEmpty(theForm.shipcity.value, 'City');
    why += isEmpty(theForm.shipstate.value, 'State');
    why += isEmpty(theForm.shipzip.value, 'Zip');
    why += isEmpty(theForm.shipcountry.value, 'Country');
       if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function checkUserProfileForm(theForm) {
    var why = "";
    why += isEmpty(theForm.fname.value, 'First name');
    why += isEmpty(theForm.lname.value, 'Last name');
    why += checkEmail(theForm.email.value);
    why += isEmpty(theForm.phone.value, 'Phone number');
    why += isEmpty(theForm.address.value, 'Address');
    why += isEmpty(theForm.city.value, 'City');
    why += isEmpty(theForm.state.value, 'State');
    why += isEmpty(theForm.zip.value, 'Zip');
    why += isEmpty(theForm.country.value, 'Country');
       if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function checkCardForm(theForm) {

    var why = "";
    why += checkRadio(theForm.regtype, 'Registration type');

	
    if(theForm.regtype[1].checked && theForm.regtype[1].value == "Firm") {
	
	
    	why += isEmpty(theForm.firm_name.value, 'Firm name');
    	why += isEmpty(theForm.firm_address.value, 'Firm address');
    }
    else if(theForm.regtype[0].checked && theForm.regtype[0].value == "Individual") {
    	why += checkDropdown(theForm.card_type.selectedIndex, 'Credit card type ');
    	why += isEmpty(theForm.card_number.value, 'Credit card number');
    	why += isEmpty(theForm.card_name.value, 'Name on credit card');
    	why += checkDropdown(theForm.card_month.selectedIndex, 'Credit card month ');
    	why += checkDropdown(theForm.card_year.selectedIndex, 'Credit card year ');
    }
       	if (why != "") {
      	 alert(why);
       	 return false;
       }


return true;
}

function checkLocation(theForm) {
    var why = "";
    why += isEmpty(theForm.state.value, 'State');
    why += isEmpty(theForm.city.value, 'City');
    why += checkDropdown(theForm.country.selectedIndex, 'Country');
       if (why != "") {
       alert(why);
       return false;
    }
return true;
}


// non-empty textbox

function isEmpty(strng,errorcode) {
var error = "";
  if (strng.length == 0) {
     error =  errorcode + " field has not been filled in.\n";
  }
return error;	  
}

function isDifferent(strng, strng2) {
  var error = "";
  if (strng != strng2) {
     error = "Passwords do not match.\n";
  }
return error;
}

function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "You didn't enter an email address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}

function checkPassword (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a password.\n";
}

    
    if ((strng.length < 6) || (strng.length > 8)) {
       error = "The password must be 6-8 characters.\n";
    }

return error;    
}    


// valid selector from dropdown list

function checkDropdown(choice, fieldname) {
var error = "";
    if (choice == 0) {
    error =  fieldname + "field is missing. Please choose an option from the drop-down list.\n";
    }    
return error;
}    

function checkRadio(choice, errorcode) {
var error = "";
var radiock = -1;
for (i=0; i<choice.length; i++)
{
    if (choice[i].checked) {
        radiock = i
    }
}
    if(radiock == -1) {
            error =  "Please indicate \"" + errorcode + "\".\n";
    }
return error;
}



//-->

