(function(){"use strict";if(!window.page){return}var e={rightPaneWidth:"176px"},i=true,n=null;page.onInit=function(){if(!u8.application||!u8.application.isLoaded||!u8.session||!u8.session.isLogin){return false}if(typeof window.rightPaneFormName=="undefined"||!window.rightPaneFormName){$("#right").hide()}$("#right-expand").children("span").sprite("u8-img-rightframeopen");page.bind("PreUnload",s);page.bind("Unload",u);f();c();o()};page.onLoad=function(){r(t)};function t(){P();var e=u8.services.jobs;if(e){e.setAdapter(new m);e.startPolling()}w();u8.tools.ready(page.children,a)}function a(){$("#left").addClass("u8-anim-left");$("#main").addClass("u8-anim-main");$("body").removeClass("u8-main-invisible")}function o(){n={showQuickSearch:true,isPhoneEnabled:window.isPhoneEnabled};if(window.headerHotKeys){u8.services.hotKeys.registerButtons(window.headerHotKeys.buttons)}var e=["Crm.TabHeader","Phone"];if(n.showQuickSearch){e.push("QuickSearch")}page.using={types:e}}function r(e){d();b();y();h();g();p();u8.tools.ready(page.children,e)}function s(){var e=u8.services.jobs;if(e){e.setAdapter(null)}u8.services.events.unbind("u8.services.requests.onStart",k).unbind("u8.services.requests.onEnd",N)}function u(){$(document.body).empty()}function c(){u8.navigate("home",{browserHistory:"replace"})}function d(){var e=u8.services.tabbedBrowsing;if(e){e.show()}}function f(){var e=u8.services.tabbedBrowsing;if(e){e.clear()}}function p(){u8.widget("NotificationPopup",$(".u8-main-notification"),{parent:page,firstOpenDelay:2e3,popup:{position:"left-middle",showArrow:true,alignTo:".u8-navigationpane-menuitem > [data-menu='System/Notifications'] .img"}})}function g(){if(typeof window.rightPaneFormName=="undefined"||!window.rightPaneFormName){return}var e=$el("right-container");if(!e){return}page.rightPaneForm=u8.widget("Form",e,{formName:window.rightPaneFormName,parent:page})}function h(){var e=$("<img />").wheel();$(".u8-main-busyindicator").empty().append(e);u8.services.events.bind("u8.services.requests.onStart",k).bind("u8.services.requests.onEnd",N)}function m(){this.onReminderClick=new u8.Base.Event}m.prototype={executeReminder:function(e){var i=$u(".NavigationPane")[0];if(!i){return}i.execute("System/Notifications",{activeView:e.job.infoAreaId})},updateReminder:function(e,i){},isReminderEnabled:function(e){}};page._onRightExpandClick=function(e){l()};function l(i){var n=$("#right-container"),t=$("#right-expand").children("span"),a=$("#right");if("undefined"==typeof i){i=n.css("display")=="none"}if(i){a.css("width",e.rightPaneWidth);n.show();t.sprite("u8-img-rightframeclose")}else{a.css("width","0px");n.hide();t.sprite("u8-img-rightframeopen")}w()}function w(){var e=$el("main");if(e){u8.Base.Dom.layout(e,{name:"dock"})}}page["TabbedBrowsing.onTabLoad"]=function(e,n){if(i){var t=n.elWindow;i=false;v(t)}};function v(e){if(!e){e=$el("work")}$(e).add("#tabs").css("visibility","inherit");u8.services.events.raise("u8.pages.main.onLoad",page,{})}function b(){$("#tabheader").css("display","").widget("TabHeader",{parent:page})}function y(){if(n.showQuickSearch){$("#quickSearchPane").css("display","").widget("QuickSearch",{parent:page})}}function P(){if(!n.isPhoneEnabled){return}u8.services.phone.create()}function k(){E(1)}function N(){E(-1)}var S=0;function E(e){var i=S==0&&e>0,n=S==1&&e<=0;S+=e;if(S<0){S=0}if(i||n){x(S>0)}}function x(e){if(e){$(".u8-main-busyindicator").stop(true,true).show()}else{$(".u8-main-busyindicator").fadeOut(u8.session.environment.isEnterpriseVersion?0:undefined)}F(e?"wait":"")}function F(e){document.body.style.cursor=e;var i=u8.application.getWorkWindow();try{if(i&&i.$){i.$(i.document.body).css("cursor",e)}}catch(e){}}})();