var openSubMenuId = getcookie("openSubMenuId"); // which submenu is open // new

function getexpirydate( nodays) {
  var UTCstring;
  Today = new Date();
  nomilli=Date.parse(Today);
  Today.setTime(nomilli+nodays*24*60*60*1000);
  UTCstring = Today.toUTCString();
  return UTCstring;
}

function getcookie(cookiename) {
  var cookiestring=""+document.cookie;
  var index1=cookiestring.indexOf(cookiename);
  if (index1==-1 || cookiename=="") return ""; 
  var index2=cookiestring.indexOf(';',index1);
  if (index2==-1) index2=cookiestring.length; 
  return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}

function setcookie(name,value,duration) {
  cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);
  document.cookie=cookiestring;
  if(!getcookie(name))
    return false;
  else
    return true;
}

function menuToggle(id) {
  ul = "ul_" + id;
  ulElement = document.getElementById(ul);
  if (ulElement) {
    if (ulElement.className == 'closed') {
      ulElement.className = "open";
      setcookie("ul_" + id, 'open', 20);
      if (openSubMenuId) { // new
        toggle(openSubMenuId); // new
        //alert("openSubMenuId = " + openSubMenuId);
      } // new
      else { // new
        //alert("openSubMenuId not defined");
      } // new 
      openSubMenuId = id; // new
      setcookie("openSubMenuId", id, 20); // new
    }
    else {
      ulElement.className = "closed";
      openSubMenuId = null; // new
      setcookie("openSubMenuId", null, 20);
      setcookie("ul_" + id, 'closed', 20);
    }
  }
}

function CheckStatus(id) {
  ulElement = document.getElementById(id);
  if (getcookie(id) == "open")
    ulElement.className = "open";
}

function menuCheck() {
    CheckStatus('ul_item1');
    CheckStatus('ul_item2');
    CheckStatus('ul_item3');
    CheckStatus('ul_item4');
}
// getting the passed variable  //
function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (
aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
}
// opening a floating window  //
function MM_openBrWindow(theURL,winName,features) { //v2.0
  var floatingplayer = window.open(theURL,winName,features);
}

