Popup=function(g,d,f,b,h,c){g=g||window.getTopWindow().document;var a=g.getElementsByTagName("body")[0];h=(h||{});this.useFixedPosition=c;var e=this;this.popupDiv=new Element("div",{"class":"popupDiv",style:"visibility:hidden;z-index:-9999;"});this.popupBackground=new Element("div",{"class":"popupBackground"});this.popupShadow=new Element("div",{"class":"popupShadow"});this.popupBox=new Element("div",{"class":"popupBox",boxclass:"popup",style:"visibility:hidden;"});this.popupTitle=new Element("div",{"class":"popupTitle",type:"boxtitle",closebutton:"true",unselectable:"on"});this.popupWindow=new Element("iframe",{"class":"popupWindow popup_window_dialog",frameBorder:"0",src:'javascript:"<html><body></body></html>"'});$(a).insert(this.popupDiv);this.popupDiv.insert(this.popupBackground);this.popupDiv.insert(this.popupShadow);this.popupDiv.insert(this.popupBox);this.popupBox.insert(this.popupTitle);this.popupBox.insert(this.popupWindow);if(typeof(doBoxLayout)=="function"){doBoxLayout(this.popupDiv,true)}this.popupCloseButton=this.popupDiv.select(".boxtitle_closebutton").first();this.setTitle("");this.resize(320,240);this.resizeFn=function(){e.resize()};this.scrollFn=function(){e.resize()};this.mouseDownFn=function(i){i=(window.event||i);if(e.isMoving){return}e.isMoving=true;e.initX=i.clientX;e.initY=i.clientY;e.distanceX=i.clientX-e.left;e.distanceY=i.clientY-e.top;e.getDocument().isPopupClient=true;if(window.attachEvent){document.attachEvent("onmousemove",e.mouseMoveFn);document.attachEvent("onmouseup",e.mouseUpFn);e.getDocument().attachEvent("onmousemove",e.mouseMoveFn);e.getDocument().attachEvent("onmouseup",e.mouseUpFn)}else{document.addEventListener("mousemove",e.mouseMoveFn,false);document.addEventListener("mouseup",e.mouseUpFn,false);e.getDocument().addEventListener("mousemove",e.mouseMoveFn,false);e.getDocument().addEventListener("mouseup",e.mouseUpFn,false)}};this.mouseUpFn=function(){if(!e.isMoving){return}e.isMoving=false;if(window.attachEvent){document.detachEvent("onmousemove",e.mouseMoveFn);document.detachEvent("onmouseup",e.mouseMoveFn);e.getDocument().detachEvent("onmousemove",e.mouseMoveFn);e.getDocument().detachEvent("onmouseup",e.mouseUpFn)}else{document.removeEventListener("mousemove",e.mouseMoveFn,false);document.removeEventListener("mouseup",e.mouseMoveFn,false);e.getDocument().removeEventListener("mousemove",e.mouseMoveFn,false);e.getDocument().removeEventListener("mouseup",e.mouseUpFn,false)}};this.mouseMoveFn=function(j,k){if(!e.isMoving||e.inMoving){return}e.inMoving=true;j=(window.event||j);var i=(j.srcElement||j.target);if(k||(i.ownerDocument&&i.ownerDocument.isPopupClient)){e.movedX=j.clientX+e.left-e.distanceX;e.movedY=j.clientY+e.top-e.distanceY}else{e.movedX=j.clientX-e.distanceX;e.movedY=j.clientY-e.distanceY}e.movedX=Math.max(0,e.movedX);e.movedY=Math.max(0,e.movedY);if(!this.timeout){this.timeout=(function(){e.resize();this.timeout=false}.bind(this)).defer()}e.inMoving=false};this.closeHandler=function(){var i=getTopWindow().getPopup(false);if(i){i.close()}};this.latency=function(i){if(i===true){this.popupBox.setStyle({visibility:"hidden"})}else{this.popupBox.setStyle({visibility:"visible"})}}};Popup.TOP=0;Popup.RIGHT=1;Popup.BOTTOM=2;Popup.LEFT=3;Popup.getWindowLayout=function(d,g){d=d||window;var j=d.document;var h,k,b,e;if(d.innerHeight&&d.scrollMaxY){h=j.body.scrollWidth;k=d.innerHeight+d.scrollMaxY;b=j.body.scrollTop;e=j.body.scrollLeft}else{if(j.body.scrollHeight>j.body.offsetHeight){h=j.body.scrollWidth;k=j.body.scrollHeight;b=j.body.scrollTop;e=j.body.scrollLeft}else{h=j.body.offsetWidth;k=j.body.offsetHeight;b=e=0}}var c,a;if(self.innerHeight){c=self.innerWidth;a=self.innerHeight}else{if(j.documentElement&&j.documentElement.clientHeight){c=j.documentElement.clientWidth;a=j.documentElement.clientHeight}else{if(j.body){c=j.body.clientWidth;a=j.body.clientHeight}}}if(g){b=e=0;h=c;k=a}var f=k<a?a:k;var i=h<c?c:h;return{pageWidth:i,pageHeight:f,windowWidth:c,windowHeight:a,scrollWidth:h,scrollHeight:k,scrollTop:b,scrollLeft:e}};Popup.prototype={shadow:[1,1,1,1],opener:null,loaded:null,closed:false,isVisible:false,callbackFunc:null,init:function(){this.title=null;this.arguments=null;this.movedX=this.movedY=-1},setOpener:function(a){this.opener=a},getOpener:function(){return this.opener},setLoaded:function(a){this.loaded=a},getWindow:function(){return this.popupWindow.contentWindow},getDocument:function(){if(!this.popupWindow){return null}if(this.popupWindow.contentDocument){return this.popupWindow.contentDocument}else{if(this.popupWindow.contentWindow){return this.popupWindow.contentWindow.document}}return null},load:function(b,c,a,d){this.fixTop=d||"";if(this.timer){clearTimeout(this.timer);this.timer=0}c=c?c:0;a=a?a:0;if(this.popupWindow){if(c&&a){this.resize(c,a)}this.popupBox.style.visibility="hidden";this.popupDiv.style.visibility="visible";this.popupDiv.style.zIndex="9999";this.popupWindow.observe("load",function(){this.popupWindow.stopObserving("load");this.show();this.onLoaded();try{var f=$(this.getWindow().document.body).select("iframe").first().contentWindow.document;Event.observe(f,"mousemove",function(g){this.mouseMoveFn(g,true)}.bind(this));Event.observe(f,"mouseup",this.mouseUpFn)}catch(e){if(window.Common&&window.Common.log){window.Common.log(e)}}}.bind(this));this.popupWindow.src=b}},onLoaded:function(){if(this.loaded){this.loaded(this.getDocument(),this.getWindow());this.loaded=null}},show:function(){if(this.isVisible){return}this.isVisible=true;this.start=new Date();if(this.timer){clearTimeout(this.timer);this.timer=0}if(this.popupBox){this.popupBox.style.visibility="visible";if(this.popupDiv&&this.popupDiv.style.visibility=="hidden"){this.popupDiv.style.visibility="visible";this.popupDiv.style.zIndex="9999"}if(window.addEventListener){window.addEventListener("resize",this.resizeFn,false);window.addEventListener("scroll",this.scrollFn,false);this.popupTitle.addEventListener("mousedown",this.mouseDownFn,false)}else{if(window.attachEvent){window.attachEvent("onresize",this.resizeFn);window.attachEvent("onscroll",this.scrollFn);this.popupTitle.attachEvent("onmousedown",this.mouseDownFn)}}if(this.popupCloseButton){this.popupCloseButton.onclick=this.closeHandler}}},detachEvents:function(){this.movedX=this.movedY=-1;var a=this.getDocument();if(window.removeEventListener){window.removeEventListener("resize",this.resizeFn,false);window.removeEventListener("scroll",this.scrollFn,false);this.popupTitle.removeEventListener("mousedown",this.mouseDownFn,false);document.removeEventListener("mouseup",this.mouseUpFn,false);document.removeEventListener("mousemove",this.mouseMoveFn,false);if(a){a.removeEventListener("mouseup",this.mouseUpFn,false);a.removeEventListener("mousemove",this.mouseMoveFn,false)}}else{if(window.detachEvent){window.detachEvent("onresize",this.resizeFn);window.detachEvent("onscroll",this.scrollFn);this.popupTitle.detachEvent("onmousedown",this.mouseDownFn);document.detachEvent("onmouseup",this.mouseUpFn);document.detachEvent("onmousemove",this.mouseMoveFn);if(a){a.detachEvent("onmouseup",this.mouseUpFn);a.detachEvent("onmousemove",this.mouseMoveFn)}}}},_hide:function(){this.detachEvents();if(this.popupWindow){var a="";a+="<html><body style='text-align:center;'>";a+="<img width='32' height='32' src='/res/js/util/img/ajax-big.gif' style='padding-top:120px;'/>";a+="</body></html>";this.setInnerHTML(a)}if(this.popupDiv&&this.popupDiv.style.visibility!="hidden"){this.popupDiv.style.visibility="hidden";this.popupBox.style.visibility="hidden";this.popupDiv.style.zIndex="-9999"}},hide:function(){var b=(new Date()-this.start);var a=100;if(b<500){a=600-b}this.timer=setTimeout(this._hide.bind(this),a)},setTitle:function(a){this.title=a;this.resize()},registerCloseHook:function(a){this.closeHandler=a},close:function(){if(this.closed){return}this.closed=true;if(getPopup()!=this){try{throw new Error("Please close popups in reverse order they have been opened!")}catch(a){if(console&&console.log){console.log(a.message)}}}this.title=null;this.callbackFunc=null;this.arguments=null;if(this.popupCloseButton){this.popupCloseButton.onclick=null}this.hide();closePopup();this.isVisible=false},resize:function(e,a){if(this.popupWindow){var i=0;if(this.title||this.popupCloseButton){this.popupTitle.style.display="";this.popupTitle.innerHTML="<p unselectable='on' class='popup_title'>"+(this.title||"&nbsp;")+"</p>";i=this.popupTitle.offsetHeight||28}else{this.popupTitle.style.display="none"}e=e||this.popupWindow.style.width;a=a||this.popupWindow.style.height;var b=parseInt(e,10);var d=parseInt(a,10);var c=Popup.getWindowLayout(getTopWindow(),this.useFixedPosition);var g=(this.movedX>=0?this.movedX:Math.floor((c.windowWidth-b)/2))+c.scrollLeft;var f=(this.movedY>=0?this.movedY:Math.floor((c.windowHeight-d)/2))+c.scrollTop;g=Math.max(0,Math.min(c.windowWidth-b+c.scrollLeft,g));f=Math.max(10,Math.min(c.windowHeight-d-i+c.scrollTop,f));if(this.fixTop){f=this.fixTop}this.left=g;this.top=f;this.popupBackground.style.width=c.pageWidth+"px";this.popupBackground.style.height=c.pageHeight+"px";if(isNaN(g)||isNaN(f)){return}this.popupShadow.style.left=(g-this.shadow[Popup.LEFT])+"px";this.popupShadow.style.top=(f-this.shadow[Popup.TOP])+"px";this.popupShadow.style.width=(b+this.shadow[Popup.RIGHT]+this.shadow[Popup.LEFT])+"px";this.popupShadow.style.height=(d+i+this.shadow[Popup.TOP]+this.shadow[Popup.BOTTOM])+"px";this.popupShadow.style.display="block";if(this.popupBox){this.popupBox.style.left=g+"px";this.popupBox.style.top=Math.round(f-(i+16)/2)+"px";this.popupWindow.style.left="";this.popupWindow.style.top="";if(c.windowHeight<d+i+16){this.popupBackground.style.width=(c.pageWidth-18)+"px";this.popupDiv.style.overflow="auto";this.popupBackground.style.height=this.popupDiv.scrollHeight+"px"}else{this.popupDiv.style.overflow=""}}else{this.popupWindow.style.left=g+"px";this.popupWindow.style.top=f+i+"px";this.popupTitle.style.left=g+"px";this.popupTitle.style.top=f+"px";this.popupTitle.style.width=b+"px";this.popupTitle.style.height=i+"px"}this.popupTitle.style.width=b+"px";this.popupWindow.style.width=b+"px";this.popupWindow.style.height=d+"px"}},setInnerHTML:function(b){var a=this.getDocument();if(a){this.show();a.open();a.write(b);a.close()}}};__getPreparedTopWindow=function(){var a=getTopWindow();if(!a.popupStack){a.popupStack=[]}return a};getPopup=function(a){var b=__getPreparedTopWindow();if(b.popupStack.length==0){if(a===false){return null}else{return createNewPopup()}}return b.popupStack[b.popupStack.length-1]};createNewPopup=function(){var b=__getPreparedTopWindow();var a=(new b.Popup());b.popupStack.push(a);return a};closePopup=function(){var b=__getPreparedTopWindow();if(b.popupStack.length>0){var a=b.popupStack.pop();(function(){if(a.popupDiv.parentNode){a.popupDiv.remove()}delete a}).defer()}};showSplashScreen=function(c){c=c||{};if(!c.url){return}c.title=c.title||"&nbsp;";c.hideDeactivateBox=c.hideDeactivateBox===true;c.showOnce=c.showOnce===true;c.width=(c.width||568);c.height=(c.height||390);if(!c.hideDeactivateBox||c.showOnce){var b="hide_splashscreen_"+escape(c.url);b=b.replace(/\//g,"_");var d=cm_getCookie(b);if(d=="true"){return}if(c.showOnce){cm_setCookie(b,"true",new Date("08/02/2033"),"/");c.hideDeactivateBox=true}}var a=createNewPopup();window.waitMessage.hide();a.arguments=c;a.resize(c.width,c.height);a.setTitle(c.title);a.load("/beng/res/html/splashscreen.html")};CMWaitMsg=function(){this.popup=getPopup();msg="";this.nbsp=String.fromCharCode(160);var a;for(a=0;a<7;a++){this.nbsp=this.nbsp+this.nbsp}this.title=this.nbsp;this.popupBlocked=false;this.useNormalOpen=false};CMWaitMsg.prototype.showWindow=function(){var d=getTopWindow();var a="";this.popup.resize(300,200);this.popup.show();if(this.lastMsg==this.msg){return}this.lastMsg=this.msg;if(d.styleDefinition){a=d.styleDefinition}if(d._def_title){this.title=d._def_title+this.nbsp}var b="";if(d.resDescription&&d.resDescription.main&&d.resDescription.main.alertStyle=="system"){b=" style='background-color:buttonface; font:menu;'"}a="";var c="<HTML><HEAD>"+a+"<TITLE>"+this.title+"</TITLE></HEAD><BODY"+b+"><BR/><BR/><DIV align='center'"+b+">";if(b!=""){c+=this.msg}else{c+="<FONT face='Arial, Helvetica, sans-serif' size='-1'>"+this.msg+"</FONT>"}c+="<BR/><BR/><BR/><IMG width='32' height='32' src='/res/js/util/img/ajax-big.gif'/>";c+="</DIV></BODY></HTML>";this.popup.setInnerHTML(c)};CMWaitMsg.prototype.closeWindow=function(){this.lastMsg=null;this.popup.hide()};CMWaitMsg.prototype.setMessage=function(a){this.msg=a;this.showWindow()};
