  
var req;
// var reg = /(^[a-zA-Z]{1}[\d]{0,2}\.{0,1}[\d]{0,3})$/;
var reg = /(^[e,v,E,V,0-9]{0,3}\.{0,1}[\d]{0,3})$/;
var activeLookup = null;

function loadXMLDoc(url) {

   try { req = new ActiveXObject("Msxml2.XMLHTTP"); }
   catch(e) {
      try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
      catch(oc) { req = null; }
   }

   if (!req && typeof XMLHttpRequest != "undefined") { req = new XMLHttpRequest(); }

   if (req != null) {
      req.onreadystatechange = processChange;
      req.open("GET", url, true);
      req.send(null);
   }
}

function processChange() {
   if (req.readyState == 4 && req.status == 200) {
      getObject("searchResult").innerHTML = req.responseText;
   }
}

function getObject(name) {
   var ns4 = (document.layers) ? true : false;
   var w3c = (document.getElementById) ? true : false;
   var ie4 = (document.all) ? true : false;

   if (ns4) return eval('document.' + name);
   if (w3c) return document.getElementById(name);
   if (ie4) return eval('document.all.' + name);
   return false;
}

function lookup(value) {
   if(reg.test(value)) {
      loadXMLDoc('php/icd-9_hint.php?q='+value);
      document.getElementById('show-shadow').className = "show-shadow";
      document.getElementById('searchResult').className = "show_lookup";
   }
   else {
     document.getElementById('searchResult').className = "hide_lookup";
     document.getElementById('show-shadow').className = "hide_show-shadow";
   }
}

function mayLookup(value) {
   if (activeLookup != null) window.clearTimeout(activeLookup);
   activeLookup = window.setTimeout('lookup(\'' + value + '\')', 450);
}

function highlight(identifier, css) {
   document.getElementById(identifier).className = css;
}

