﻿// JScript File

var _currentCat = queryString("c");
var _currentSubCat = queryString("sc");

HideAllDivs(); 

if (_currentCat != "") {    
  ShowDiv(_currentCat);
}

if (_currentSubCat != "") {
  var mySub = "sub" + _currentSubCat 
  mySub = document.getElementById(mySub);  
  if (mySub != null) { 
    mySub.setAttribute("class", "subcategory selectedsubcat");
    mySub.setAttribute("className", "subcategory selectedsubcat");    
  }
}

function ShowDiv(aDiv) {   
  HideAllDivs(); 
  var myDiv = "mnu" + aDiv; 
  var myParent = "mnuTL" + aDiv;   
  if (document.getElementById) {
    myObj = document.getElementById(myDiv);      
    if (myObj != null) {  
      myObj.style.display = 'block';
      myObj.style.height = '200px';      
    }    
    myObj2 = document.getElementById(myParent);      
    if (myObj2 != null) {      
      myObj2.setAttribute("class", "category selectedcat");
      myObj2.setAttribute("className", "category selectedcat");      
    }
//    myObj3 = document.getElementById("mnuTL0"); 
//    if (myObj3 != null) {      
//      myObj3.setAttribute("class", "category selectedcat");
//      myObj3.setAttribute("className", "category selectedcat");      
//    }
//    myObj4 = document.getElementById("mnu0"); 
//    if (myObj4 != null) {  
//      myObj4.style.display = 'block';
//      myObj4.style.height = '200px';      
//    } 
  } 
  else if(document.all){ //IS IE 4 or 5 (or 6 beta)  
    eval("document.all." +myDiv+ ".style.display = 'block'");
    eval("document.all." +myDiv+ ".style.height = '200px'");
    eval("document.all." +myParent+ ".setAttribute('class', 'category selectedcat')");
//    eval("document.all." +"mnuTL0"+ ".setAttribute('class', 'category selectedcat')");
//    eval("document.all." +"mnu0"+ ".style.display = 'block'");
//    eval("document.all." +"mnu0"+ ".style.height = '200px'");
  }
  else if (document.layers) { //IS NETSCAPE 4 or below
    document.layers[myDiv].display = 'block';
    document.layers[myDiv].height = '200px';
    document.layers[myParent].setAttribute("class", "category selectedcat");
//    document.layers["mnuTL0"].setAttribute("class", "category selectedcat");
//    document.layers["mnu0"].display = 'block';
//    document.layers["mnu0"].height = '200px';
  }
    
}

function HideAllDivs() {
  var allDivs = document.getElementsByTagName("div");
  var len = allDivs.length;
  for(var x=0;x<len;x++){    
    var singleDiv = allDivs[x];
    if (singleDiv.id.substring(0,5) == "mnuTL" ){        
      document.getElementById(singleDiv.id).setAttribute("class", "category");
      document.getElementById(singleDiv.id).setAttribute("className", "category");    
    }
    else if (singleDiv.id.substring(0,3) == "mnu") {
      if (document.getElementById &&!document.all) {
        myDiv = document.getElementById(singleDiv.id);
        myDiv.style.display = 'none';
        myDiv.style.height = '0px';            
      } 
      else if(document.all){ //IS IE 4 or 5 (or 6 beta)
        eval("document.all." +singleDiv.id+ ".style.display = 'none'");
        eval("document.all." +singleDiv.id+ ".style.height = '0px'");
      }
      else if (document.layers) { //IS NETSCAPE 4 or below
        document.layers[singleDiv.id].display = 'none';
        document.layers[singleDiv.id].height = '0px';          
      }      
    }         
  }

}

function queryString(parameter) { 
  var loc = location.search.substring(1, location.search.length);
  var param_value = false;

  var params = loc.split("&");
  for (i=0; i<params.length;i++) {
      param_name = params[i].substring(0,params[i].indexOf('='));
      if (param_name == parameter) {
          param_value = params[i].substring(params[i].indexOf('=')+1)
      }
  }
  if (param_value) {
      return param_value;
  }
  else {
      return false;
  }
}

