// Copyright Zikula Foundation 2010 - license GNU/LGPLv3 (or at your option, any later version).
Event.observe(window,"load",function(){if($("menuTreeImportOptions")){Zikula.Menutree.Tree.inst.tree.observeOnce("tree:item:save",function(){$("menuTreeImportOptions").blindUp()})}});document.observe("dom:loaded",menutree_init);function menutree_init(){menutree_treecontrols_onload();menutree_linkclasses_onload();menutree_stylehelper_onload()}function menutree_treecontrols_onload(){$("menutree_newnode").observe("click",function(a){a.stop();Zikula.Menutree.Tree.inst.newNode()});$("menutree_expandall").observe("click",function(a){a.stop();Zikula.Menutree.Tree.inst.expandAll()});$("menutree_collapseall").observe("click",function(a){a.stop();Zikula.Menutree.Tree.inst.collapseAll()});$$(".menutree_langcontrols").invoke("observe","click",menutree_onlangchange)}function menutree_linkclasses_onload(){if($("menutree_linkclass")){if($("menutree_linkclass").checked==true){$("menutree_linkclasses_group").show()}else{$("menutree_linkclasses_group").hide()}$("menutree_linkclass").observe("click",menutree_linkclasses_onchange);$("menutree_linkclass_add").observe("click",menutree_linkclass_add);$$(".menutree_linkclass_del").invoke("observe","click",menutree_linkclass_del)}}function menutree_linkclasses_onchange(){if($("menutree_linkclass").checked==true){showeffect("menutree_linkclasses_group")}else{hideeffect("menutree_linkclasses_group")}}function menutree_linkclass_add(c){c.stop();var d=$("menutree_linkclasses_list").childElements().last().cloneNode(true),e=Number(d.id.match(/\d+/)[0]),b=e+1,a=d.select("input");d.id=d.id.replace(/\d+/,b);a.invoke("clear");a.each(function(f){f.name=f.name.replace(/\d+/,b)});$("menutree_linkclasses_list").insert(d);d.down(".menutree_linkclass_del").observe("click",menutree_linkclass_del)}function menutree_linkclass_del(b){b.stop();var a=b.element();if($("menutree_linkclasses_list").select("li").size()>2){a.up("li").remove()}else{a.up("li").select("input").invoke("clear")}}function menutree_onlangchange(a){a.stop();var b=a.element();Zikula.Menutree.Tree.inst.changeLang(b.lang);$$(".activelang").invoke("removeClassName","activelang");$(b).addClassName("activelang")}function menutree_stylehelper_onload(){if($("menutree_tpl")&&$("menutree_stylesheet_helper")){$("menutree_tpl").observe("change",menutree_stylehelper);$("menutree_stylesheet_helper").hide();menutree_stylehelper()}}function menutree_stylehelper(c){if(c==undefined){return}var e=/blocks_block_menutree_(.+?)\.tpl/,b=(b=$("menutree_tpl").value.match(e))?b[1]:"",d=false;if(!b.empty()&&b!="default"){$("menutree_stylesheet").value="null";d=true;if(Prototype.Browser.IE){if($("menutree_stylesheet_backup")==undefined){var a=$("menutree_stylesheet").cloneNode(true);a.id="menutree_stylesheet_backup";a.name="menutree_stylesheet_backup";$(a).hide();document.body.appendChild(a)}else{while($("menutree_stylesheet").firstChild){$("menutree_stylesheet").removeChild($("menutree_stylesheet").firstChild)}$("menutree_stylesheet_backup").select("option").each(function(g){$("menutree_stylesheet").insert($(g.cloneNode(true)))})}$("menutree_stylesheet").select("option").select(function(g){return !(g.value.include("/"+b)||g.value=="null")}).invoke("remove")}else{$("menutree_stylesheet").select("option").invoke("show").select(function(g){return !(g.value.include("/"+b)||g.value=="null")}).invoke("hide")}var f=$("menutree_stylesheet").select("option").find(function(g){return g.value!="null"&&g.visible()});if(f!=undefined){f.selected=true}if(d&&!$("menutree_stylesheet_helper").visible()){showeffect("menutree_stylesheet_helper");$("menutree_stylesheet_helper").down("a").observe("click",menutree_stylehelper_reset)}}}function menutree_stylehelper_reset(a){a.stop();if(Prototype.Browser.IE){while($("menutree_stylesheet").firstChild){$("menutree_stylesheet").removeChild($("menutree_stylesheet").firstChild)}$("menutree_stylesheet_backup").select("option").each(function(b){$("menutree_stylesheet").insert($(b.cloneNode(true)))})}else{$("menutree_stylesheet").select("option").invoke("show")}hideeffect("menutree_stylesheet_helper")}function menutree_toogle(b){b.stop();var a=b.element().previous();if(a.visible()){hideeffect(a)}else{showeffect(a)}}function hideeffect(b){var a=$(b);if(typeof(Effect)!="undefined"){Effect.BlindUp(a)}else{a.hide()}}function showeffect(b){var a=$(b);if(typeof(Effect)!="undefined"){Effect.BlindDown(a)}else{a.show()}};