(function(d){function x(){var c=d("div.popup");d("#shortcut>span[target]").each(function(){var b=d(this),a=c.filter('[name="'+b.attr("target")+'"]'),e=a.find("form"),i=0,j=function(){if(i){i=0;d(document.body).unbind("mousedown",l);a.css("display","none");b.removeClass("sc_now")}},l=function(h){h=h.target;h==b[0]||b.find("*").index(h)!=-1||h==a[0]||a.find("*").index(h)!=-1||j()};e.submit(function(){e.ajaxSubmit({dataType:"json",type:"post",success:function(h){h.state?ct.ok("\u4fdd\u5b58\u6210\u529f"):
ct.error("\u4fdd\u5b58\u5931\u8d25")},beforeSubmit:j});return false});var k=b.attr("callback");k=k&&k in q?q[k]:function(){};a.find(".closer").click(j);b.click(function(){k(a,e);if(!i){i=1;b.addClass("sc_now");a.css({visibility:"hidden",display:"block"});var h=b.offset();a.css({top:b.outerHeight(true)+h.top+1,left:h.left-a.outerWidth()+b.outerWidth(),visibility:"visible"});d(document.body).mousedown(l)}})})}var r=null,g=null,s=null,o=null,m=null,n=null,f=null,t=null,u=null,y=d.browser.msie&&parseInt(d.browser.version)<
8,z={url:"?app=system&controller=index&action=menu&root=%s",paramId:"id",paramHaschild:"hasChildren",active:function(c,b,a){if(a.url){b=p(c);for(m.empty();;){a=d('<a href="javascript:;">'+c.text()+"</a>").click(function(){superAssoc.show(d.data(this,"path"),true)}).data("path",[].concat(b));m.prepend(a);b.pop();if(b.length==0)break;c=c.closest("ul").prev()}}o.html(c.text())},click:function(c,b,a){a.url&&g.open(a.url,"current",p(c))}},p=function(c){var b=c.data("path");if(b&&b.length)return[].concat(b);
var a=c[0].parentNode;for(b=[a.getAttribute("idv")];;){a=a.parentNode.parentNode;b.unshift(a.getAttribute("idv"));if(!d.nodeName(a,"LI"))break}c.data("path",b);return b},v=function(c,b){d(">li[id^=menu]",c).each(function(){var a=this.id.substr(4),e=b?[].concat(b):[];e.push(a);(y?d(">a",this).focus(function(){this.blur()}):d(">a",this).css("outline","none")).click(function(){superAssoc.show(e,true)});a=d(">ul",this);a.length&&a.each(function(){v(this,e)})})},w=function(){try{var c=ct.innerWidth(),
b=ct.innerHeight();if(c>920){t.width(c);u.width(c-150);g&&g.adaptWidth()}n.css("height",b-61);s.css("height",b-88)}catch(a){}},q={fillData:function(c,b){var a=g.get();if(a){var e=a.btn.attr("title");a=a.btn.attr("url");b[0].name.value=e;b[0].url.value=a}},getNote:function(c,b){b[0].note.disabled=true;d.getJSON("?app=system&controller=my&action=getNote",function(a){c.find(".time").text(a.time);b[0].note.value=a.note;b[0].note.disabled=false})}};window.superAssoc={init:function(){o=d("#root_menu_name");
r=d("#tab_container");s=d("#frame_container");m=d("#position");n=d("#browser");t=d("#head");u=d("#right");w();v("#menu");var c=function(a){a||(a=window.event);var e=a.keyCode?a.keyCode:a.charCode;if(e==116||a.ctrlKey&&e==82){if(document.all)a.keyCode=0;a.preventDefault&&a.preventDefault();a.returnValue=false;a.stopPropagation&&a.stopPropagation();a.cancelBubble=true;superAssoc.reload()}},b=function(a){if(a.addEventListener)a.addEventListener("keydown",c,false);else a.attachEvent&&a.attachEvent("onkeydown",
c)};g=r.tabview({defaultTab:{url:"?app=system&controller=index&action=newtab",path:null},saveSessUrl:"?app=system&controller=index&action=savetab",saveRecentUrl:"?app=system&controller=index&action=recent",switched:function(a){(a=a.btn.data("path"))&&a.length&&superAssoc.show(a)},loaded:function(a){a=a.iframe;try{var e=a.doc();e[0]&&b(e[0])}catch(i){}}});b(document);d.ajax({url:"?app=system&controller=index&action=gettab",dataType:"json",success:function(a){a.length?g.initTabs(a):d("#menu>li:eq(0)>a").click()},
error:function(){d("#menu>li:eq(0)>a").click()}});d(window).bind("resize",w);x()},refresh:function(c,b){if(!c&&f){var a=f.find("div.active");c=a.length?p(a):[f.attr("idv")]}n.empty();f=null;superAssoc.show(d.isArray(c)?[].concat(c):[],b)},reload:function(c){g.reload(c)},get:function(c){g.get(c)},show:function(c,b){if(d.isArray(c)&&c.length){var a=c[0],e,i=c.length>1?function(){f.tree("open",c.slice(1),b)}:function(){f.triggerHandler(b?"clk":"active")};if(f&&a==(e=f.attr("idv")))return i();if(e){f.hide();
d("#menu"+e).removeClass("focused")}e=d("#menu"+a);e.addClass("focused");f=d("#treemenu_"+a);if(f.length){f.show();return i()}var j=d(">a",e).text(),l=e.attr("url");f=d('<div class="tree" id="treemenu_'+a+'" idv="'+a+'"><div style="display:none">'+j+"</div></div>").appendTo(n).tree(d.extend({prepared:i},z)).bind("clk",function(){f.triggerHandler("active");l&&g.open(l,"current",[a])}).bind("active",function(){f.tree("resetActive");var k=d('<a href="javascript:;">'+j+"</a>").click(function(){superAssoc.show([a],
true)});m.html(k);o.html(j)})}},open:function(c,b,a){if(!d.isArray(a)){var e=g.get();e&&(a=e.btn.data("path"))}g.open(c,b,a)},close:function(c){g.close(c)},call:function(c,b,a){(a=g.get(a))&&ct.func(c,a.iframe.win()[0])(b)}}})(jQuery);
