$(document).ready(function(){WEMenuCoreJs.Initialize()});$(document).bind("OEReload",function(n){for(ElemID in OEConfWEMenu){var t=OEConfWEMenu[Elem];ElemID==n.ID&&WEMenuCoreJs.IniMenu(ElemID);WEMenuCoreJs.IniHook(Elem);t!=null&&t.Hook==n.ID&&WEMenuCoreJs.IniHook(ElemID)}});var WEMenuCoreJs={$CurentElem:null,$CurentGroup:null,HideTimer:null,ShowAnimTimer:null,HideAnimTimer:null,ShowTimer:null,zindex:1e5,Initialize:function(){for(Elem in OEConfWEMenu)WEMenuCoreJs.IniMenu(Elem)},IniHook:function(n){var t=OEConfWEMenu[n],i,r,u,f;return t==undefined||t.Hook==null?!1:(i=$("#"+t.Hook),i.length<1)?!1:(r=t.StartX,r==null&&(r=0),u=t.StartY,u==null&&(u=0),f={X:r,Y:u},i.data("WEDataStartXY",f),i.data("WEDataStartPosition",t.StartPosition),i)},IniTrigger:function(n,t){var r=$("#"+n),f=OEConfWEMenu[n],u="",i;for(TriggerID in f.Trigger)u+=(u?", ":"")+"#"+f.Trigger[TriggerID];if(u&&(i=$(u),!(i.length<1))){switch(f.EventType){case 0:i.click(function(){return WEMenuCoreJs.ShowMenuBase(t,r,!0),!1});break;case 1:i.mouseenter(function(){return WEMenuCoreJs.ShowMenuBase(t,r),!1});i.unbind("click").attr("onclick","").click(function(){return WEMenuCoreJs.ShowMenuBase(t,r),!1});break;case 2:i.dblclick(function(){return WEMenuCoreJs.ShowMenuBase(t,r,!0),!1});break;case 3:i.mouseenter(function(){return WEMenuCoreJs.ShowMenuBase(t,r),!1})}return i.mouseenter(function(){WEMenuCoreJs.$CurentElem=r}),i.mouseleave(function(){WEMenuCoreJs.$CurentElem=null;WEMenuCoreJs.SetAutoHide(r)}),i}},IniMenu:function(n){var t=$("#"+n),i=OEConfWEMenu[n],r,u;if((t.data("ConfWEMenu",i),i.MenuGroup!=null)&&(r=t.find("#"+i.MenuGroup.ID+":first"),!(r.length<1))){if(WEInfoPage.RenderMode=="Editor")t.bind("WEEdSelectHiddenElement",function(){var i=WEMenuCoreJs.IniHook(n);i!=!1&&WEMenuCoreJs.ShowMenuBase(i,t)}),t.bind("WEEdUnSelectHiddenElement",function(){t.find(".OESZ_WEMenuGroup:first").hide()});else{if(u=WEMenuCoreJs.IniHook(n),u==!1)return;WEMenuCoreJs.IniTrigger(n,u)}t.mouseenter(function(){WEMenuCoreJs.$CurentElem=$(this)});t.mouseleave(function(){WEMenuCoreJs.$CurentElem=null;WEMenuCoreJs.SetAutoHide($(this))});this.CreateMenuItemEvent(t,r)}},CreateMenuItemEvent:function(n,t){t.mouseover(function(){$(this).queue("fx").length>0&&($(this).stop(!0,!0),$(this).show())});t.children(".OESZ_WEMenuItem, .OESZ_WEMenuTop, .OESZ_WEMenuBottom, .WEMenuSeparator").each(function(){$(this).mouseenter(function(t){t.stopPropagation();n.trigger("mouseenter")});var t=$(this).children(".OESZ_WEMenuGroup:first");if($(this).mouseenter(function(){WEMenuCoreJs.CloseAllMenuThisLevel($(this),n)}),$(this).click(function(){WEMenuCoreJs.CloseAllMenuThisLevel($(this),n)}),t.length==0)return!0;$(this).mouseenter(function(){return WEMenuCoreJs.ShowMenu(n,$(this)),!1});$(this).click(function(){return WEMenuCoreJs.ShowMenu(n,$(this)),!1});WEMenuCoreJs.CreateMenuItemEvent(n,t)})},CloseAllMenuThisLevel:function(n,t){var r=n.children(".OESZ_WEMenuGroup:first"),i=n.parent().find(".OESZ_WEMenuGroup");r.length>0&&(i=i.not(r));WEMenuCoreJs.HideAnim(t,i)},ShowMenuBase:function(n,t,i){var r=t.find(".OESZ_WEMenuGroup:first"),u;if(r.is(":visible")){i&&(clearTimeout(this.HideTimer),WEMenuCoreJs.HideAnim(t,t.find(".OESZ_WEMenuGroup")));return}$(".OESZ_WEMenuGroup").hide();t.css("display","block");u=WEMenuCoreJs.StartPosition(t,n,r);r.css("top",u.Y).css("left",u.X);this.zindex=1e5;t.css("z-index",this.zindex);this.$CurentGroup=r;WEMenuCoreJs.ShowAnim(t,r)},ShowMenu:function(n,t){var i=t.children(".OESZ_WEMenuGroup:first"),r=this.ChildStartPosition(n,t);i.css("top",r.Y).css("left",r.X);this.zindex+=1;i.css("z-index",this.zindex);this.$CurentGroup=i;WEMenuCoreJs.ShowAnim(n,i)},SetAutoHide:function(n){WEInfoPage.RenderMode!="Editor"&&(clearTimeout(this.HideTimer),this.HideTimer=setTimeout(function(){WEMenuCoreJs.$CurentElem==null&&WEMenuCoreJs.HideAnim(n,n.find(".OESZ_WEMenuGroup"))},n.data("ConfWEMenu").AutoHidePeriod))},StartPosition:function(n,t,i){var r={X:0,Y:0},s=t.data("WEDataStartPosition"),c=t.data("WEDataStartXY").X,h=t.data("WEDataStartXY").Y,u,f,e,o;if(s==null)return r;u=t.offset().left-n.offset().left;f=t.offset().top-n.offset().top;switch(s){case 0:r.X=u+t.outerWidth(!0);r.Y=f;break;case 1:r.X=u+t.outerWidth(!0);r.Y=f+t.outerHeight(!0);break;case 2:r.X=u;r.Y=f+t.outerHeight(!0);break;case 3:r.X=u;r.Y=f}return e=r.X+i.outerWidth()-$(document).scrollLeft()+15,e>$(window).width()?r.X-=e-$(window).width():r.X+=c,o=r.Y+i.outerHeight()-$(document).scrollTop()+15,o>$(window).height()?(r.Y-=o-$(window).height(),r.Y-=h):r.Y+=h,r},ChildStartPosition:function(n,t){var i={X:0,Y:0},r=t.children(".OESZ_WEMenuGroup:first"),s=t.parent().find(".OESZ_WEMenuTop:first").outerHeight(!0),u=parseInt(t.css("margin-top")),f=n.data("ConfWEMenu"),e,o;return u!=NaN&&(i.Y=u*-1),i.X=t.outerWidth()+f.SubMenuStartX,e=t.offset().left+i.X+r.outerWidth()-$(document).scrollLeft(),e>$(window).width()&&(i.X=(r.outerWidth()+f.SubMenuStartX)*-1),o=t.offset().top+r.outerHeight()-$(document).scrollTop(),o>$(window).height()?i.Y=$(window).height()-(t.offset().top+i.Y+r.outerHeight())+$(document).scrollTop():i.Y-=s,i},ShowAnim:function(n,t){clearTimeout(this.ShowAnimTimer);this.ShowAnimTimer=setTimeout(function(){t.stop(!0,!0);t.fadeIn(WEMenuCoreJs.SpeedEffectConvertor(n.data("ConfWEMenu").OpenSpeedEffect),function(){})},n.data("ConfWEMenu").OpenSpeed)},HideAnim:function(n,t){clearTimeout(this.HideAnimTimer);this.HideAnimTimer=setTimeout(function(){t.stop(!0,!0);t.fadeOut(WEMenuCoreJs.SpeedEffectConvertor(n.data("ConfWEMenu").HideSpeedEffect),function(){})},n.data("ConfWEMenu").HideSpeed)},SpeedEffectConvertor:function(n){var t=0;switch(n){case 0:t="200";break;case 1:t="600";break;case 2:t="50"}return t}}