function showhide(showhideid)
  {
    var itemid = showhideid;
    var showhideid = 'showhide' + itemid;
    var check = document.getElementById(showhideid).checked;
    var param = itemid + '*' + check;
    var url = 'xmlgetShowHideMenu.php?param=';
    http.open("GET", url + escape(param), true);
    http.onreadystatechange = handleHttpResponse5;
    http.send(null);  
  }

function handleHttpResponse5() {
  if (http.readyState == 4) {
   }
}




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

var url = "xmlgetSubcategory.php?param="; // The server-side script
function handleHttpResponse() {
  if (http.readyState == 4) {
    document.addfood.subcategory.options.length = 0;
    document.addfood.subcategory[0]=new Option('Select Subcategory', '0', false);
    // Split the comma delimited response into an array
    results = http.responseText.split("*");
    subcatid = results[0];
    subcatname = results[1];
    // document.getElementById('groupname').value = results[1];
    document.addfood.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.addfood.subcategory[i2]=new Option(subcatname, subcatid, false);
            i++;
            i2++;
          }
      }
    // make sure form is disabled, because subcategory is not set
    document.addfood.foodname.disabled = 1;
    document.addfood.fooddescription.disabled = 1;
    document.addfood.manufacturer.disabled = 1;
    document.addfood.servingsize1.disabled = 1;
    document.addfood.servingsize2.disabled = 1;
    document.addfood.calories.disabled = 1;
    document.addfood.totalfat.disabled = 1;
    document.addfood.saturatedfat.disabled = 1;
    document.addfood.transfat.disabled = 1;
    document.addfood.cholesterol.disabled = 1;
    document.addfood.sodium.disabled = 1;
    document.addfood.carbohydrates.disabled = 1;
    document.addfood.fiber.disabled = 1;
    document.addfood.sugars.disabled = 1;
    document.addfood.protein.disabled = 1;
    document.addfood.vitamina.disabled = 1;
    document.addfood.vitaminc.disabled = 1;
    document.addfood.calcium.disabled = 1;
    document.addfood.iron.disabled = 1;
    document.addfood.submitbutton.disabled = 1;
   }
}

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


function addFormElements()
  {
    var subcatid = document.getElementById("subcategory").value;
    
    if (subcatid > 0)
      {
    document.addfood.foodname.disabled = 0;
    document.addfood.fooddescription.disabled = 0;
    document.addfood.manufacturer.disabled = 0;
    document.addfood.servingsize1.disabled = 0;
    document.addfood.servingsize2.disabled = 0;
    document.addfood.calories.disabled = 0;
    document.addfood.totalfat.disabled = 0;
    document.addfood.saturatedfat.disabled = 0;
    document.addfood.transfat.disabled = 0;
    document.addfood.cholesterol.disabled = 0;
    document.addfood.sodium.disabled = 0;
    document.addfood.carbohydrates.disabled = 0;
    document.addfood.fiber.disabled = 0;
    document.addfood.sugars.disabled = 0;
    document.addfood.protein.disabled = 0;
    document.addfood.vitamina.disabled = 0;
    document.addfood.vitaminc.disabled = 0;
    document.addfood.calcium.disabled = 0;
    document.addfood.iron.disabled = 0;
    document.addfood.submitbutton.disabled = 0;
      }
    else
      {
    document.addfood.servingsize1.disabled = 1;
    document.addfood.servingsize2.disabled = 1;
    document.addfood.calories.disabled = 1;
    document.addfood.totalfat.disabled = 1;
    document.addfood.saturatedfat.disabled = 1;
    document.addfood.transfat.disabled = 1;
    document.addfood.cholesterol.disabled = 1;
    document.addfood.sodium.disabled = 1;
    document.addfood.carbohydrates.disabled = 1;
    document.addfood.fiber.disabled = 1;
    document.addfood.sugars.disabled = 1;
    document.addfood.protein.disabled = 1;
    document.addfood.vitamina.disabled = 1;
    document.addfood.vitaminc.disabled = 1;
    document.addfood.calcium.disabled = 1;
    document.addfood.iron.disabled = 1;
    document.addfood.submitbutton.disabled = 1;
      }
  }



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(); // We create the HTTP Object