function checkTLD() {
  s=document.whois1.sld.value;
  for(x=0;x<document.whois1.tld.length;x++) {
    tld=document.whois1.tld.options[x].value;
    if(s.substring(s.length-tld.length-1,s.length)=="."+tld) {
      if(document.whois1.tld.options[x].disabled) {
      } else {
        document.whois1.sld.value=s.substring(0,s.length-tld.length-1);
        document.whois1.tld.selectedIndex=x;
      }
    }
  }
}
function checkChars() {
  checkTLD();
  s=document.whois1.sld.value;   
  if(s.match(/[^a-zA-Z0-9_\-\.]/)) {
    alert("The domain contains an invalid character.");
    return false;
  } else if(s.match(/^[_-]/)) {
    alert("Domain names must start with letters or numbers.");
    return false;
  } else {
    tld=document.whois1.tld.options[document.whois1.tld.selectedIndex].value;
    if(tld=="name") {
      if(!(s.match(/\./))) {
        alert("Domain names ending in .name must contain a first name and a last name separated by a period.");
        return false;
      }
    } else {
      if(tld != "museum" && s.match(/\./)) {
        alert("Domain names must not contain more than one period.");
        return false;
      }
    }
    return true;
  }
}
function openBox() {
  window.open("/whois/whois2.pl?domain="+escape(document.whois2.domain.value)+"&server="+escape(document.whois2.server.value),
  "whoispopup","width=420,height=460,hotkeys=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0");
}
