var newwindow = '';
function popitup(url)
  {
    if (!newwindow.closed && newwindow.location)       
      {
        newwindow.location.href = url;
      }
    else
      {
        newwindow=window.open(url,'name','height=500,width=325,menubar=no,scrollbars=yes');
        if (!newwindow.opener) newwindow.opener = self;
      }
    if (window.focus) {newwindow.focus()}
    return false;
  }

var url = "xmlgetSubcategory.php?param=";
function changeSubcategory()
  {
    var cat1id = document.getElementById("category1").value;
    http.open("GET", url + escape(cat1id), true);
    http.onreadystatechange = handleHttpResponse;
    http.send(null);  
  }

function addFormElements()
  {
  }

function handleHttpResponse() {
  if (http.readyState == 4) {
    document.searchfoods.subcategory.options.length = 0;
    document.searchfoods.subcategory[0]=new Option('Select Subcategory', '0', false);
    results = http.responseText.split("*");
    subcatid = results[0];
    subcatname = results[1];
    document.searchfoods.subcategory[1]=new Option(subcatname, subcatid, false);
    
    i=2;
    i2=2
    while (subcatid > 0)
      {
        subcatid = results[i];
        i++;
        subcatname = results[i];
        if (subcatid > 0)
          {
            document.searchfoods.subcategory[i2]=new Option(subcatname, subcatid, false);
            i++;
            i2++;
          }
      }
   }
}



function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
var http = getHTTPObject();