




function validateFormOnSubmit(theForm) {
var reason = "";


  reason += validateEmail(theForm.emailnew);
  reason += validatePassword(theForm.passwordnew);
  reason += validatePasswordmatch(theForm.password2new);
  reason += validateUsernameSpaces(theForm.businessname);
  reason += validateUsernameNoSpaces(theForm.bizaddress);
  reason += validateDropdown(theForm.category1);
  reason += validateUsernameSpaces(theForm.firstname);
  reason += validateUsernameSpaces(theForm.lastname);
  reason += validateUsernameSpaces(theForm.address1);
  reason += validateUsernameIllegal(theForm.address2);
  reason += validateUsernameSpaces(theForm.city);
  reason += validateUsernameSpaces(theForm.state);
  reason += validateUsername(theForm.zip);
  reason += validateUsernameSpaces(theForm.country);
  reason += validatePhone(theForm.phone);
  reason += validateRadiocheck(theForm.sex[0]);
  reason += validateRadiocheck(theForm.sex[1]);
  reason += validateUsername(theForm.textnumber);
  reason += validateEula(theForm.eula[0]);
  reason += validateUsernameSpaces(theForm.securityquestion);
  reason += validateUsernameSpaces(theForm.securityanswer);



      
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}








function validateEmpty(fld) {
    var error = "";
  
    if (fld.value.length == 0) {
        fld.style.background = '#f96955'; 
        error = "The required field has not been filled in.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;   
}



function validatePasswordmatch(fld) {
    var error = "";
    var illegalChars = /[\W_]/; // allow only letters and numbers 
 
    if (fld.value == "" || fld.value != document.signupcheck.passwordnew.value) {
        fld.style.background = '#f96955';
        error = "Passwords do not Match.\n";
    } else if ((fld.value.length < 6) || (fld.value.length > 15)) {
        error = "The password must be 6 - 16 characters in length. \n";
        fld.style.background = '#f96955';
    } else if (illegalChars.test(fld.value)) {
        error = "The password contains illegal characters.\n";
        fld.style.background = '#f96955';
    }   else {
        fld.style.background = 'White';
    }
   return error;
}   






function validateRadiocheck(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "Illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}




function validateEula(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.checked == false || fld.value != "yes") {
        fld.style.background = '#f96955'; 
        error = "You Must Accept the Terms of Use.\n";
    } else if ((fld.value.length < 2) || (fld.value.length > 50)) {
        fld.style.background = '#f96955'; 
        error = "The username is the wrong length.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The username contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}





function validateDropdown(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.value == "" || fld.selectedIndex == 0) {
        fld.style.background = '#f96955'; 
        error = "You Must Select a Category.\n";
    } else if ((fld.value.length < 2) || (fld.value.length > 50)) {
        fld.style.background = '#f96955'; 
        error = "The Category.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Category contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}



function validateUsernameNoSpaces(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_-]/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = '#f96955'; 
        error = "Required Field.\n";
    } else if ((fld.value.length < 2) || (fld.value.length > 50)) {
        fld.style.background = '#f96955'; 
        error = "The Field must be 2 - 50 characters in length.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}


function validateUsernameSpaces(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s-.#]/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = '#f96955'; 
        error = "Required Field.\n";
    } else if ((fld.value.length < 2) || (fld.value.length > 50)) {
        fld.style.background = '#f96955'; 
        error = "The Field must be 2 - 50 characters in length.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}


function validateUsernameIllegal(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s-.#]/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "Illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}


function validateUsername(fld) {
    var error = "";
    var illegalChars = /\W/ ; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = '#f96955'; 
        error = "Required Field.\n";
    } else if ((fld.value.length < 2) || (fld.value.length > 50)) {
        fld.style.background = '#f96955'; 
        error = "The Field must be 2 - 50 characters in length.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}




function validatePassword(fld) {
    var error = "";
    var illegalChars = /[\W_]/; // allow only letters and numbers 
 
    if (fld.value == "") {
        fld.style.background = '#f96955';
        error = "You didn't enter a password.\n";
    } else if ((fld.value.length < 6) || (fld.value.length > 15)) {
        error = "The password must be 6 - 16 characters in length. \n";
        fld.style.background = '#f96955';
    } else if (illegalChars.test(fld.value)) {
        error = "The password contains illegal characters.\n";
        fld.style.background = '#f96955';
    } else {
        fld.style.background = 'White';
    }
   return error;
}   






function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
} 

function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
    
    if (fld.value == "") {
        fld.style.background = '#f96955';
        error = "You didn't enter an email address.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = '#f96955';
        error = "Please enter a valid email address.\n";
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = '#f96955';
        error = "The email address contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}




function validatePhone(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');     

   if (fld.value == "") {
        error = "You didn't enter a phone number.\n";
        fld.style.background = '#f96955';
    } else if (isNaN(parseInt(stripped))) {
        error = "The phone number contains illegal characters.\n";
        fld.style.background = '#f96955';
    } else if (!(stripped.length == 10)) {
        error = "The phone number is the wrong length. Make sure you included an area code.\n";
        fld.style.background = '#f96955';
    } 
    return error;
}


























































function validateFormOnSubmitControl(theForm) {
var reason = "";


  reason += validateEmail(theForm.email);
  reason += validatePassword(theForm.password);




      
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}




function validatePassword(fld) {
    var error = "";
    var illegalChars = /[\W_]/; // allow only letters and numbers 
 
    if (fld.value == "") {
        fld.style.background = '#f96955';
        error = "You didn't enter a password.\n";
    } else if ((fld.value.length < 6) || (fld.value.length > 15)) {
        error = "The password must be 6 - 16 characters in length. \n";
        fld.style.background = '#f96955';
    } else if (illegalChars.test(fld.value)) {
        error = "The password contains illegal characters.\n";
        fld.style.background = '#f96955';
    } else {
        fld.style.background = 'White';
    }
   return error;
}   




function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
} 

function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
    
    if (fld.value == "") {
        fld.style.background = '#f96955';
        error = "You didn't enter an email address.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = '#f96955';
        error = "Please enter a valid email address.\n";
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = '#f96955';
        error = "The email address contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}





















































function validateFormOnSubmitAddproductform(theForm) {
var reason = "";


  reason += validateSpacesAddprod(theForm.title);
  reason += validateSpacesAddprod(theForm.description);
  reason += validatePriceAddprod(theForm.price);
  reason += validateBrowseAddprod(theForm.upload);
  reason += validateIllegalAddprod(theForm.shipcost);
  reason += validateIllegalAddprod(theForm.shiptime);
  reason += validateIllegalAddprod(theForm.weight);
  reason += validateIllegalAddprod(theForm.shipco);
  reason += validateIllegalAddprod(theForm.productnumber);
  reason += validateIllegalAddprod(theForm.category);



      
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}






function validatePriceAddprod(fld) {
    var error = "";
    var illegalChars = /[^0-9.]/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = '#f96955'; 
        error = "Required Field.\n";
    }  else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else if ((fld.value.length < 1) || (fld.value.length > 10)) {
        error = "The Price must be 1 - 10 characters in length. \n";
        fld.style.background = '#f96955';
    } else {
        fld.style.background = 'White';
    } 
    return error;
}




function validateSpacesAddprod(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s.-]/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = '#f96955'; 
        error = "Required Field.\n";
    }  else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}



function validateBrowseAddprod(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s-\\.:]/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "Illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}


function validateIllegalAddprod(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Category contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}





















































function validateFormOnSubmitCategory(theForm) {
var reason = "";


  reason += validateSpaces(theForm.addcategory);
  reason += validateSpaces(theForm.subcatof);





      
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}



function validateSpaces(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s-]/; // allow letters, numbers, and underscores
 
    if (fld.value == ""  || fld.value.length < 1) {
        fld.style.background = '#f96955'; 
        error = "Required Field.\n";
    }  else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}






























































function validateFormOnSubmitCrmform(theForm) {
var reason = "";


  reason += validateSpacescrm(theForm.salutationcrm);
  reason += validateSpacescrm(theForm.firstnamecrm);
  reason += validateSpacescrm(theForm.lastnamecrm);
  reason += validateSpacescrm(theForm.biznamecrm);
  reason += validateSpacescrm(theForm.address1crm);
  reason += validateSpacescrm(theForm.address2crm);
  reason += validateSpacescrm(theForm.citycrm);
  reason += validateSpacescrm(theForm.statecrm);
  reason += validateSpacescrm(theForm.zipcrm);
  reason += validateSpacescrm(theForm.countrycrm);
  reason += validateSpacescrm(theForm.homecrm);
  reason += validateSpacescrm(theForm.cellcrm);
  reason += validateSpacescrm(theForm.officecrm);
  reason += validateSpacescrm(theForm.faxcrm);
  reason += validateEmailcrm(theForm.emailcrm);
  reason += validateSpacescrm(theForm.referralsourcecrm);
  reason += validateDatecrm(theForm.customersince);
  reason += validateSpacescrm(theForm.referralsprovidedcrm);
  reason += validateSpacescrm(theForm.notescrm);




      
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}










function validateSpacescrm(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s,-.]/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}


function validateEmailcrm(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s,-./@]/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}



function validateDatecrm(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s,-.:]/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}



































































function validateFormOnSubmitAccntinfo(theForm) {
var reason = "";


  reason += validateEmailAccntinfo(theForm.emailnewaccntinfo);
  reason += validatePasswordAccntinfo(theForm.passwordnewaccntinfo);
  reason += validatePasswordmatchAccntinfo(theForm.password2newaccntinfo);
  reason += validateUsernameSpacesAccntinfo(theForm.businessnameaccntinfo);
  reason += validateUsernameNoSpacesAccntinfo(theForm.bizaddressaccntinfo);
  reason += validateDropdownAccntinfo(theForm.category1accntinfo);
  reason += validateUsernameSpacesAccntinfo(theForm.firstnameaccntinfo);
  reason += validateUsernameSpacesAccntinfo(theForm.lastnameaccntinfo);
  reason += validateUsernameSpacesAccntinfo(theForm.address1accntinfo);
  reason += validateUsernameIllegalAccntinfo(theForm.address2accntinfo);
  reason += validateUsernameSpacesAccntinfo(theForm.cityaccntinfo);
  reason += validateUsernameSpacesAccntinfo(theForm.stateaccntinfo);
  reason += validateUsernameSpacesAccntinfo(theForm.zipaccntinfo);
  reason += validateUsernameSpacesAccntinfo(theForm.countryaccntinfo);
  reason += validatePhoneAccntinfo(theForm.phoneaccntinfo);
  reason += validateRadiocheckAccntinfo(theForm.sexaccntinfo[0]);
  reason += validateRadiocheckAccntinfo(theForm.sexaccntinfo[1]);
  reason += validateUsernameSpacesAccntinfo(theForm.securityquestionaccntinfo);
  reason += validateUsernameSpacesAccntinfo(theForm.securityansweraccntinfo);



      
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}











function validatePasswordmatchAccntinfo(fld) {
    var error = "";
    var illegalChars = /[\W_]/; // allow only letters and numbers 
 
    if (fld.value == "" || fld.value != document.signupcheck.passwordnew.value) {
        fld.style.background = '#f96955';
        error = "Passwords do not Match.\n";
    } else if ((fld.value.length < 6) || (fld.value.length > 15)) {
        error = "The password must be 6 - 16 characters in length. \n";
        fld.style.background = '#f96955';
    } else if (illegalChars.test(fld.value)) {
        error = "The password contains illegal characters.\n";
        fld.style.background = '#f96955';
    }   else {
        fld.style.background = 'White';
    }
   return error;
}   






function validateRadiocheckAccntinfo(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "Illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}




function validateEulaAccntinfo(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.checked == false || fld.value != "yes") {
        fld.style.background = '#f96955'; 
        error = "You Must Accept the Terms of Use.\n";
    } else if ((fld.value.length < 2) || (fld.value.length > 50)) {
        fld.style.background = '#f96955'; 
        error = "The username is the wrong length.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The username contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}





function validateDropdownAccntinfo(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Category contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}



function validateUsernameNoSpacesAccntinfo(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_-]/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = '#f96955'; 
        error = "Required Field.\n";
    } else if ((fld.value.length < 2) || (fld.value.length > 50)) {
        fld.style.background = '#f96955'; 
        error = "The Field must be 2 - 50 characters in length.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}


function validateUsernameSpacesAccntinfo(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s-.#]/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = '#f96955'; 
        error = "Required Field.\n";
    } else if ((fld.value.length < 2) || (fld.value.length > 50)) {
        fld.style.background = '#f96955'; 
        error = "The Field must be 2 - 50 characters in length.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}


function validateUsernameIllegalAccntinfo(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s-.#]/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "Illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}


function validateUsernameAccntinfo(fld) {
    var error = "";
    var illegalChars = /\W/ ; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = '#f96955'; 
        error = "Required Field.\n";
    } else if ((fld.value.length < 2) || (fld.value.length > 50)) {
        fld.style.background = '#f96955'; 
        error = "The Field must be 2 - 50 characters in length.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}




function validatePasswordAccntinfo(fld) {
    var error = "";
    var illegalChars = /[\W_]/; // allow only letters and numbers 
 
    if (fld.value == "") {
        fld.style.background = '#f96955';
        error = "You didn't enter a password.\n";
    } else if ((fld.value.length < 6) || (fld.value.length > 15)) {
        error = "The password must be 6 - 16 characters in length. \n";
        fld.style.background = '#f96955';
    } else if (illegalChars.test(fld.value)) {
        error = "The password contains illegal characters.\n";
        fld.style.background = '#f96955';
    } else {
        fld.style.background = 'White';
    }
   return error;
}   






function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
} 

function validateEmailAccntinfo(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
    
    if (fld.value == "") {
        fld.style.background = '#f96955';
        error = "You didn't enter an email address.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = '#f96955';
        error = "Please enter a valid email address.\n";
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = '#f96955';
        error = "The email address contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}




function validatePhoneAccntinfo(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');     

   if (fld.value == "") {
        error = "You didn't enter a phone number.\n";
        fld.style.background = '#f96955';
    } else if (isNaN(parseInt(stripped))) {
        error = "The phone number contains illegal characters.\n";
        fld.style.background = '#f96955';
    } else if (!(stripped.length == 10)) {
        error = "The phone number is the wrong length. Make sure you included an area code.\n";
        fld.style.background = '#f96955';
    } 
    return error;
}




























































function validateFormOnSubmitUpdateproductform(theForm) {
var reason = "";


  reason += validateSpacesUpdateprod(theForm.title);
  reason += validateSpacesUpdateprod(theForm.description);
  reason += validatePriceUpdateprod(theForm.price);
  reason += validateIllegalUpdateprod(theForm.shipcost);
  reason += validateIllegalUpdateprod(theForm.shiptime);
  reason += validateIllegalUpdateprod(theForm.weight);
  reason += validateIllegalUpdateprod(theForm.shipco);
  reason += validateIllegalUpdateprod(theForm.productnumber);
  reason += validateIllegalUpdateprod(theForm.category);




      
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}






function validatePriceUpdateprod(fld) {
    var error = "";
    var illegalChars = /[^0-9.]/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = '#f96955'; 
        error = "Required Field.\n";
    }  else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else if ((fld.value.length < 1) || (fld.value.length > 10)) {
        error = "The Price must be 1 - 10 characters in length. \n";
        fld.style.background = '#f96955';
    } else {
        fld.style.background = 'White';
    } 
    return error;
}




function validateSpacesUpdateprod(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s.-]/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = '#f96955'; 
        error = "Required Field.\n";
    }  else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}



function validateBrowseUpdateprod(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s-\\.:]/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "Illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}



function validateIllegalUpdateprod(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Category contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}


























































function validateFormOnSubmitUpdatephoto(theForm) {
var reason = "";


  reason += validateBrowseUpdatephoto(theForm.upload);




      
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}




function validateBrowseUpdatephoto(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s-\\.:]/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "Illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}






























































function validateFormOnSubmitInventory(theForm) {
var reason = "";


  reason += validateIllegalInventory(theForm.updateinv);
  reason += validateIllegalInventory(theForm.prodleadtime);





      
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}









function validateIllegalInventory(fld) {
    var error = "";
    var illegalChars = /[^0-9.]/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "Number in Days Only.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}






























































function validateFormOnSubmitSelectsupplier(theForm) {
var reason = "";


  reason += validateIllegalSelectsupplier(theForm.selectedsupplier);





      
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}



function validateIllegalSelectsupplier(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s.-]/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = '#f96955'; 
        error = "Required Field.\n";
    }  else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}






























































function validateFormOnSubmitAddsupplierform(theForm) {
var reason = "";


  reason += validateUsernameSpacesAddsupplier(theForm.biznameaddsup);
  reason += validateIllegalAddsupplier(theForm.contactnamesaddsup);
  reason += validateIllegalAddsupplier(theForm.address1addsup);
  reason += validateIllegalAddsupplier(theForm.address2addsup);
  reason += validateIllegalAddsupplier(theForm.cityaddsup);
  reason += validateIllegalAddsupplier(theForm.stateaddsup);
  reason += validateIllegalAddsupplier(theForm.zipaddsup);
  reason += validateIllegalAddsupplier(theForm.countryaddsup);
  reason += validateIllegalAddsupplier(theForm.phoneaddsup);
  reason += validateIllegalAddsupplier(theForm.faxaddsup);
  reason += validateEmailAddsupplier(theForm.emailaddsup);
  reason += validateIllegalAddsupplier(theForm.noteaddsup);
  reason += validateIllegalAddsupplier(theForm.referalsourceaddsup);
  reason += validateIllegalAddsupplier(theForm.leadtimestndrdaddsup);

      
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}











function validatePasswordmatchAddsupplier(fld) {
    var error = "";
    var illegalChars = /[\W_]/; // allow only letters and numbers 
 
    if (fld.value == "" || fld.value != document.signupcheck.passwordnew.value) {
        fld.style.background = '#f96955';
        error = "Passwords do not Match.\n";
    } else if ((fld.value.length < 6) || (fld.value.length > 15)) {
        error = "The password must be 6 - 16 characters in length. \n";
        fld.style.background = '#f96955';
    } else if (illegalChars.test(fld.value)) {
        error = "The password contains illegal characters.\n";
        fld.style.background = '#f96955';
    }   else {
        fld.style.background = 'White';
    }
   return error;
}   






function validateRadiocheckAddsupplier(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "Illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}




function validateEulaAddsupplier(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.checked == false || fld.value != "yes") {
        fld.style.background = '#f96955'; 
        error = "You Must Accept the Terms of Use.\n";
    } else if ((fld.value.length < 2) || (fld.value.length > 50)) {
        fld.style.background = '#f96955'; 
        error = "The username is the wrong length.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The username contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}





function validateDropdownAddsupplier(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Category contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}



function validateUsernameNoSpacesAddsupplier(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_-]/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = '#f96955'; 
        error = "Required Field.\n";
    } else if ((fld.value.length < 2) || (fld.value.length > 50)) {
        fld.style.background = '#f96955'; 
        error = "The Field must be 2 - 50 characters in length.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}


function validateUsernameSpacesAddsupplier(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s-.#]/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = '#f96955'; 
        error = "Required Field.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}


function validateUsernameIllegalAddsupplier(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s-.#]/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "Illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}


function validateUsernameAddsupplier(fld) {
    var error = "";
    var illegalChars = /\W/ ; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = '#f96955'; 
        error = "Required Field.\n";
    } else if ((fld.value.length < 2) || (fld.value.length > 50)) {
        fld.style.background = '#f96955'; 
        error = "The Field must be 2 - 50 characters in length.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}




function validatePasswordAddsupplier(fld) {
    var error = "";
    var illegalChars = /[\W_]/; // allow only letters and numbers 
 
    if (fld.value == "") {
        fld.style.background = '#f96955';
        error = "You didn't enter a password.\n";
    } else if ((fld.value.length < 6) || (fld.value.length > 15)) {
        error = "The password must be 6 - 16 characters in length. \n";
        fld.style.background = '#f96955';
    } else if (illegalChars.test(fld.value)) {
        error = "The password contains illegal characters.\n";
        fld.style.background = '#f96955';
    } else {
        fld.style.background = 'White';
    }
   return error;
}   






function validateEmailAddsupplier(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s,-./@]/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}




function validatePhoneAddsupplier(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');     

   if (fld.value == "") {
        error = "You didn't enter a phone number.\n";
        fld.style.background = '#f96955';
    } else if (isNaN(parseInt(stripped))) {
        error = "The phone number contains illegal characters.\n";
        fld.style.background = '#f96955';
    } else if (!(stripped.length == 10)) {
        error = "The phone number is the wrong length. Make sure you included an area code.\n";
        fld.style.background = '#f96955';
    } 
    return error;
}




function validateIllegalAddsupplier(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s,-.]/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "Illegal Characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}































































function validateFormOnSubmitCrmcall(theForm) {
var reason = "";


  reason += validateDateCrmcall(theForm.calldate);
  reason += validateIllegalCrmcall(theForm.callrating);
  reason += validateIllegalCrmcall(theForm.callmood);
  reason += validateIllegalCrmcall(theForm.callreferrals);
  reason += validateIllegalCrmcall(theForm.callnotes);
  reason += validateIllegalCrmcall(theForm.callmadeby);
  reason += validateIllegalCrmcall(theForm.donotcall);
  reason += validateIllegalCrmcall(theForm.donotemail);





      
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}



function validateIllegalCrmcall(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s,.-]/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}

function validateDateCrmcall(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s-,:.]/; // allow letters, numbers, and underscores
 
    if ((fld.value == "")  || (fld.value.length < 1)) {
        fld.style.background = '#f96955'; 
        error = "Required Field.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}

























































function validateFormOnSubmitCrmemail(theForm) {
var reason = "";


  reason += validateDateCrmemail(theForm.emaildate);
  reason += validateIllegalCrmemail(theForm.emailsubject);
  reason += validateIllegalCrmemail(theForm.emailmessage);
  reason += validateIllegalCrmemail(theForm.emailreason);
  reason += validateIllegalCrmemail(theForm.emailsentby);
  reason += validateBrowseCrmemail(theForm.emailupload);





      
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}



function validateIllegalCrmemail(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s,.-]/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}


function validateBrowseCrmemail(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s-\\.:]/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "Illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}

function validateDateCrmemail(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s-,:.]/; // allow letters, numbers, and underscores
 
    if ((fld.value == "")  || (fld.value.length < 1)) {
        fld.style.background = '#f96955'; 
        error = "Required Field.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}




























































function validateFormOnSubmitLogocheck(theForm) {
var reason = "";


  reason += validateBrowseLogocheck(theForm.logoimage);


      
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}




function validateBrowseLogocheck(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s-\\.:]/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "Illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}
























































function validateFormOnSubmitPreviewcheck(theForm) {
var reason = "";


  reason += validateBrowsePreviewcheck(theForm.preview);


      
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}




function validateBrowsePreviewcheck(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s-.-?,]/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "Illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}




































































function validateFormOnSubmitCheckoutcheck(theForm) {
var reason = "";


  reason += validateCheckoutcheckreqemail(theForm.emailco);
  reason += validateCheckoutcheckreq(theForm.firstnameco);
  reason += validateCheckoutcheckreq(theForm.lastnameco);
  reason += validateCheckoutcheck(theForm.businessnameco);
  reason += validateCheckoutcheckreq(theForm.address1co);
  reason += validateCheckoutcheck(theForm.address2co);
  reason += validateCheckoutcheckreq(theForm.cityco);
  reason += validateCheckoutcheckreq(theForm.stateco);
  reason += validateCheckoutcheckreq(theForm.zipco);
  reason += validateCheckoutcheckreq(theForm.countryco);
  reason += validateCheckoutcheck(theForm.phoneco);



      
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}




function validateCheckoutcheck(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s-.-/#,]/; // allow letters, numbers, and underscores
 
    if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "Illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}


function validateCheckoutcheckreq(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s-.-/#,]/; // allow letters, numbers, and underscores
 
    if ((fld.value == "")  || (fld.value.length < 1)) {
        fld.style.background = '#f96955'; 
        error = "Required Field.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "Illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}


function validateCheckoutcheckreqemail(fld) {
    var error = "";
    var illegalChars = /[^a-zA-Z0-9_\s-./@]/; // allow letters, numbers, and underscores
 
    if ((fld.value == "")  || (fld.value.length < 1)) {
        fld.style.background = '#f96955'; 
        error = "Required Field.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f96955'; 
        error = "The Field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    } 
    return error;
}


