// <!--
// Each menu container must be listed here in the form of: i###:9&
// Where i = fixed letter indicating it is the image ID, 
//     ### = number of the menu entry 1-999,
//      : = Separator between identity and the menustate value
//      9 = one of 0 = Closed, 1 = Open state, Usually the menu list is closed at first open of page
//var MenuState='<%=mList%>';  This line must be placed on the page before this script is called.
//var PageName='<%=Request.ServerVariables("URL")%>'; This Line must be place with the above line to identify the page.
// This script allows the Sidebar menu state to be retained when a user changes the menu state. 
// The code in the page reads the cookie value if it exists to set the initial menu state.
// Script must be used with the Cookie.js script.

function MenuSelect(tPID,tLID,tMID) {
 var state='';
 if (navigator.appName=="Microsoft Internet Explorer" && navigator.appVersion.substr(0,3)<="4.0") {
  if (document.getElementById(tLID).style.display=='') {
   document.getElementById(tLID).style.display='none';
   document.getElementById(tPID).src='/Images/Icons/Plus.gif';
   state = '0';
  } 
  else {
   document.getElementById(tLID).style.display='';
   document.getElementById(tPID).src='/Images/Icons/Minus.gif';
   state = '1';
  }
 }
 else {                                               // IE does not recognize this tag.
  if (document.getElementById(tLID).style.display=='table-row') {
   document.getElementById(tLID).style.display='none';
   document.getElementById(tPID).src='/Images/Icons/Plus.gif';
   state = '0';
  } 
  else {
   document.getElementById(tLID).style.display='table-row';
   document.getElementById(tPID).src='/Images/Icons/Minus.gif';
   state = '1';
  }
 }

 var expdate = new Date()
 var tregexp = new RegExp(tMID+':\\d');
 MenuState=MenuState.replace(tregexp,tMID+':'+state);
 //alert("MenuState: "+MenuState);
 expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000)) // Set to 24 hours by milliseconds
 SetCookie(PageName,MenuState,expdate);
 if (typeof(DebugTxt2)=="object") {
  DebugTxt2.innerText=MenuState;
 }
}

function GetMenuState(name) { // Check for a prior cookie saved menu state
 var CookieVal=GetCookie(name);
 if (typeof(DebugTxt)=="object") {
  DebugTxt.innerText=CookieVal;
 }
 if (CookieVal.length>0) {
  MenuState = CookieVal;
  //alert("cookie MenuState:"+MenuState);
  var a = CookieVal.split('&'); // Split menu elements into an array
  for (var i = 0; i< a.length; i++) {
   var tImgID = document.all.item(a[i].substr(0,a[i].length-2));
   var tListID = document.all.item('L'+a[i].substr(1,a[i].length-3));
   if (a[i].substr(a[i].length-1,1)=='1') { // set menu state open
    if (navigator.appName=="Microsoft Internet Explorer" && navigator.appVersion.substr(0,3)<="4.0") {
     document.getElementById(tListID).style.display='';
    }
    else {                                               // IE does not recognize this tag.
     document.getElementById(tListID).style.display='table-row';
    }
    document.getElementById(tImgID).src='/Images/Icons/Minus.gif';
   }
   else {
    document.getElementById(tListID).style.display='none'; // set menu state closed
    document.getElementById(tImgID).src='/Images/Icons/Plus.gif';
   }
  }
 }
}

// -->

