function loadurl(dest) { 
  
  try { 
    
    // Moz supports XMLHttpRequest. IE uses ActiveX.  
    // browser detction is bad. object detection works for any browser  
    
    xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP"); 
  
  } catch (e) { 
    
    // browser doesn't support ajax. handle however you want  
  
  } 
  
  // the xmlhttp object triggers an event everytime the status changes  
  // triggered() function handles the events  
    
  xmlhttp.onreadystatechange = triggered; 
  
  // open takes in the HTTP method and url.  
  
  xmlhttp.open("GET", dest); 
  
  // send the request. if this is a POST request we would have  
  // sent post variables: send("name=aleem&gender=male)  
  
  // Moz is fine with just send(); but  
  // IE expects a value here, hence we do send(null);  
  
  xmlhttp.send(null); 

} 

function triggered() { 
  
  // if the readyState code is 4 (Completed)  
  // and http status is 200 (OK) we go ahead and get the responseText  
  // other readyState codes:  
  // 0=Uninitialised 1=Loading 2=Loaded 3=Interactive  
  
  if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) { 
  
    // xmlhttp.responseText object contains the response.  
    
    update = xmlhttp.responseText.split('||');
    
    var urltosearch = '/processsearch.php?searchterms=' + document.srchfrm.searchterms.value + '&includedescription=' + getUseDesc() + '&allterms=' + getAllOrAny() + '&categoryid=' + document.srchfrm.categoryid.options[document.srchfrm.categoryid.selectedIndex].value + '&soundex=' + getUseSoundex();
    
    document.getElementById("numresults").innerHTML = "<a href='" + urltosearch + "'>" + update[0] + " Products Match</a><br><a href='" + urltosearch + "'>" + update[1] + " Fitments Match</a>"; 
  } 
}

function getAllOrAny() {
  for (i=0; i<document.srchfrm.allterms.length; i++){
    if(document.srchfrm.allterms[i].checked) {
      return document.srchfrm.allterms[i].value;
    }
  }
}

function getUseDesc() {
  if(document.srchfrm.includedescription.checked) {
    return "on";
  }
  return "";  
}

function getUseSoundex() {
  if(document.srchfrm.soundex.checked) {
    return "on";
  } 
  return "";  
}

function getNumResults() {
  if ( document.srchfrm.searchterms.value != '' ) {
    document.getElementById("numresults").innerHTML = '<img src="/images/loading.gif">'
    loadurl( '/search.php?ajax=1&searchterms=' + document.srchfrm.searchterms.value + '&includedescription=' + getUseDesc() + '&allterms=' + getAllOrAny() + '&categoryid=' + document.srchfrm.categoryid.options[document.srchfrm.categoryid.selectedIndex].value + '&soundex=' + getUseSoundex() );
  } else {
    document.getElementById("numresults").innerHTML = "";
  }
}