function ShowDropDown(displayElement, displayMode) {
  //alert('ShowDropDown');
  document.getElementById(displayElement).style.visibility = displayMode;
  //alert('ShowDropDown 2');
  if(displayMode == "hidden") {
    document.getElementById('DropDownCustomerLabel').setAttribute("onClick", "event.cancelBubble=true; ShowDropDown('DropDownCustomer', 'visible');");
  }
  else {
    document.getElementById('DropDownCustomerLabel').setAttribute("onClick", "event.cancelBubble=true; ShowDropDown('DropDownCustomer', 'hidden');");
  }
}  

function displayElement(displayElement, displayMode) {
  document.getElementById(displayElement).style.display = displayMode;
}  

function displayElements(displayElement1, displayMode1, displayElement2, displayMode2, displayElement3, displayMode3) {
  element = document.getElementById(displayElement1);
  element.style.display = displayMode1;
  element = document.getElementById(displayElement2);
  element.style.display = displayMode2;
  element = document.getElementById(displayElement3);
  element.style.display = displayMode3;
}

function HashChanged() {       
  //alert("HashChanged: " + window.location.hash);
  if(document.getElementById("fLoadData").value == 1) {
    var hashString = window.location.hash;
    var id = hashString.substr(hashString.lastIndexOf('/') + 1);
    if(hashString.search("#!detail/") == 0) {
      ShowProductDetails(id);
      //alert("ShowProductDetails: " + id);
    }
    else if(hashString.search("#!") == 0) {
      ShowProducts(id, 0);
      //alert("ShowProducts: " + id);
    }
  }
  document.getElementById("fLoadData").value = "1";
}

function BodyLoaded () {
  //alert('BodyLoaded: ' + window.location.hash);

  xmlHttp=GetXmlHttpObject();
  if (xmlHttp == null) {
    alert ("Your browser does not support AJAX!");
    return;
  }

  var hashString = window.location.hash;
  var id = hashString.substr(hashString.lastIndexOf('/') + 1);
  if(hashString.search("#!detail/") == 0) {
    var url = "/CategoryList.php";
    url = url + "?sid=" + Math.random();
    xmlHttp.open('GET', url, false);
    xmlHttp.send(null);
    var response = xmlHttp.responseText.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,"");
    document.getElementById('categoryBar').innerHTML = response;

    ShowProductDetails(id);
    //alert("ShowProductDetails: " + id);
  }
  else if(hashString.search("#!") == 0) {
    var url = "/CategoryList.php";
    url = url + "?cc=" + id;
    url = url + "&sid=" + Math.random();
    xmlHttp.open('GET', url, false);
    xmlHttp.send(null);
    var response = xmlHttp.responseText.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,"");
    document.getElementById('categoryBar').innerHTML = response;

    ShowProducts(id, 0);
    //alert("ShowProducts: " + id);
  }
}
