// $Id: dhtml_menu.js,v 1.9.2.4 2007/07/31 04:09:19 brmassa Exp $
//eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('3={};3.t=5(a,b){4($(b).17(".j")){4(z.v.3.u){$(a).R("r")}m{$(a).o("p","C")}$(b).B("j").n("w")}m{4(z.v.3.u){$(a).Z("r")}m{$(a).o("p","W")}$(b).B("w").n("j")}3.k()};3.s=5(a){6 b=a+"=";6 c="";4(8.9.g>0){f=8.9.F(b);4(f!=-1){f+=b.g;6 d=8.9.F(";",f);4(d==-1){d=8.9.g}c=11(8.9.10(f,d))}}A c};3.k=5(){6 a="";$("D.y").x(5(i){4(7.X.p!="C"){4(a!=""){a+=","}a+=7.h}});8.9="l="+a+";V=/"};$(5(){6 a=3.s("l");4(a!=""){6 b=a.U(",");T(6 i=0;i<b.g;i++){$("#"+b[i]).S();$("#q-"+b[i]).n("j")}}$("P.l O[@N!=Q] > a").x(5(){4($(7).M().L("D.y").g>0){$(7).o({K:"H",J:"-H",I:2}).Y(5(e){h=$(7).G()[0].h.15("q-","");3.t($("#"+h)[0],$(7).G()[0]);A 14}).13(5(e){E.12=7.16})}});$(E).18(3.k)});',62,71,'|||dhtmlMenu|if|function|var|this|document|cookie||||||offset|length|id||expanded|saveMenuState|dhtml_menu|else|addClass|css|display|menu|fast|getCookie|switchMenu|useEffects|settings|collapsed|each|submenu|Drupal|return|removeClass|none|div|window|indexOf|parents|2em|zIndex|marginLeft|paddingLeft|children|parent|class|li|ul|leaf|slideUp|show|for|split|path|inline|style|click|slideDown|substring|unescape|location|dblclick|false|replace|href|is|unload'.split('|'),0,{}))

// $Id: DEV-dhtml_menu.js,v 1.1.2.1 2007/07/31 04:09:19 brmassa Exp $

dhtmlMenu = {};

/**
 *  Changes the state of a submenu from open to close.
 */
dhtmlMenu.switchMenu = function(submenu, parent) {
  if($(parent).is(".expanded")) {
    if (Drupal.settings.dhtmlMenu.useEffects) {
      $(submenu).slideUp("fast");
    } else {
      $(submenu).css("display", "none");
    }
    $(parent).removeClass("expanded").addClass("collapsed");
  } else {
    if (Drupal.settings.dhtmlMenu.useEffects) {
      $(submenu).slideDown("fast");
    } else {
      $(submenu).css("display", "inline");
    }
    $(parent).removeClass("collapsed").addClass("expanded");
  }
  dhtmlMenu.saveMenuState();
};

/**
 * Grabs the cookie data.
 */
dhtmlMenu.getCookie = function(name) {
  var search = name + "=";
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search);
    if (offset != -1) {
      offset += search.length;
      var end = document.cookie.indexOf(";", offset);
      if (end == -1) {
        end = document.cookie.length;
      }
      returnvalue = unescape(document.cookie.substring(offset, end));
    }
  }
  return returnvalue;
};

/**
 * Saves the states of the menus.
 */
dhtmlMenu.saveMenuState = function() {
  var blocks = "";
  $("div.submenu").each(function(i) {
    if (this.style.display != "none") {
      if (blocks != "") {
        blocks += ",";
      }
      blocks += this.id;
    }
  });
  document.cookie = "dhtml_menu=" + blocks + ";path=/";
};

/**
 * Start everything: Attaches the online users autoupdate behaviour
 * to the block content.
 */
$(function() {
  var cookievalue = dhtmlMenu.getCookie("dhtml_menu");
  if (cookievalue != "") {
    var cookieList = cookievalue.split(",");
    for (var i = 0; i < cookieList.length; i++) {
      $("#"+ cookieList[i]).show();
      $("#menu-" + cookieList[i]).addClass("expanded");
    }
  }
  $("ul.dhtml_menu li[@class!=leaf] > a").each(function() {
    if ($(this).parent().children("div.submenu").length > 0) {
      $(this).css({paddingLeft: "0em", marginLeft: "0em", zIndex: 2}).click(function(e) {
        id = $(this).parents()[0].id.replace("menu-", "");
        dhtmlMenu.switchMenu($("#"+ id)[0], $(this).parents()[0]);
        return false;
      })
      .dblclick(function(e) {
        window.location = this.href;
      });
    }
  });
  $(window).unload(dhtmlMenu.saveMenuState);
});
