function validLength(item,len) {
  return(item.length>=len);
}

function validEmail(item) {
  var emailRegEx = /^[0-9A-Za-z][_\.0-9A-Za-z-]*[0-9A-Za-z]@([0-9A-Za-z][0-9A-Za-z-]*[0-9A-Za-z]\.)*[A-Za-z]{2,6}$/;
  return emailRegEx.test(item);
}

function validDomain(item) {
  var domainRegEx = /^([0-9A-Za-z][0-9A-Za-z-]+[0-9A-Za-z]\.)*[A-Za-z]{2,6}$/;
  return domainRegEx.test(item);
}

function Validate() {
  document.getElementById('submit_form').disabled=true;
  var errortext = "";
  var errcolor = "#FE8A19";
  var normalcolor = "#FFFFFF";

  if(!validLength(document.regform.company.value, 2)) {
    errortext = errortext + "Please enter your company name.\n";
    document.regform.company.style.background = errcolor;
    document.regform.company.onclick = function() {this.style.background = normalcolor; this.onclick="";}
  }
if(!validLength(document.regform.fname.value, 2)) {
    errortext = errortext + "Please enter your first name.\n";
    document.regform.fname.style.background = errcolor;
    document.regform.fname.onclick = function() {this.style.background = normalcolor; this.onclick="";}
  }
  if(!validLength(document.regform.lname.value, 2)) {
    errortext = errortext + "Please enter your last name.\n";
    document.regform.lname.style.background = errcolor;
    document.regform.lname.onclick = function() {this.style.background = normalcolor; this.onclick="";}
  }
  if(!validLength(document.regform.address1.value, 2)) {
    errortext = errortext + "Please enter your address.\n";
    document.regform.address1.style.background = errcolor;
    document.regform.address1.onclick = function() {this.style.background = normalcolor; this.onclick="";}
  }
  if(!validLength(document.regform.city.value, 3)) {
    errortext = errortext + "Please enter your city.\n";
    document.regform.city.style.background = errcolor;
    document.regform.city.onclick = function() {this.style.background = normalcolor; this.onclick="";}
  }
  if(!validLength(document.regform.state.value, 2)) {
    errortext = errortext + "Please enter your state or province.\n";
    document.regform.state.style.background = errcolor;
    document.regform.state.onclick = function() {this.style.background = normalcolor; this.onclick="";}
  }
  if(!validLength(document.regform.zip.value, 5)) {
    errortext = errortext + "Please enter your zip code.\n";
    document.regform.zip.style.background = errcolor;
    document.regform.zip.onclick = function() {this.style.background = normalcolor; this.onclick="";}
  }
  if(!validEmail(document.regform.email.value)) {
    errortext = errortext + "Please enter a valid email address.\n";
    document.regform.email.style.background = errcolor;
    document.regform.email.onclick = function() {this.style.background = normalcolor; this.onclick="";}
  }
  if(!validLength(document.regform.office_phone.value, 7)) {
    errortext = errortext + "Please enter your phone number.\n";
    document.regform.office_phone.style.background = errcolor;
    document.regform.office_phone.onclick = function() {this.style.background = normalcolor; this.onclick="";}
  }


  
  
  
  
  /*
  if(!validDomain(document.regform.theURL.value)) {
    errortext = errortext + "Please enter a valid domain.\n";
    document.regform.theURL.style.background = errcolor;
    document.regform.theURL.onclick = function() {this.style.background = normalcolor; this.onclick="";}
  }
  */
  /*
  if(!validLength(document.regform.agent.value, 6)) {
    errortext = errortext + "Please enter a valid Agent User ID.\n";
    document.regform.agent.style.background = errcolor;
    document.regform.agent.onclick = function() {this.style.background = normalcolor; this.onclick="";}
  }  
  */
  /*
  if(!validLength(document.regform.captchatext.value, 6)) {
    errortext = errortext + "Please enter the security code.\n";
    document.regform.captchatext.style.background = errcolor;
    document.regform.captchatext.onclick = function() {this.style.background = normalcolor; this.onclick="";}
  }
  */
  if(errortext != "") {
    document.getElementById('submit_form').disabled=false;
    document.getElementById('required_field_indicator').style.color = errcolor;
    alert(errortext);
    return false;
  } else {
    return true;
  }
  return false;
}


