mesa.Popup={};mesa.Popup.currentMessageWindowStack=[];mesa.Popup.getCurrentMessageWindow=function(){return mesa.Popup.currentMessageWindowStack.length>0?mesa.Popup.currentMessageWindowStack[mesa.Popup.currentMessageWindowStack.length-1]:null};mesa.Popup.onOpenClose;mesa.Popup.BaseMessageWindow=function(j,n,k,p,l,g){var r=mesa.WebUtils.getWindowSize().w;var i=mesa.WebUtils.getWindowSize().h;var q=mesa.WebUtils.getPageSize().w;var h=mesa.WebUtils.getPageSize().h;var o=mesa.WebUtils.getPageOffset().x;var b=mesa.WebUtils.getPageOffset().y;var d=document.createElement("div");d.className="vWindowShadow";d.style.display="none";d.onmousedown=d.onmousemove=d.onmouseup=function(t){var s=t||window.event;s.cancelBubble=true;if(s.stopPropagation){s.stopPropagation()}};document.body.appendChild(d);var f=0;if(mesa.WebUtils.isIE()){f=-2}var e=document.createElement("div");e.className="vFrame";var m=document.createElement("div");m.className="vWindowContainer";m.style.display="none";e.appendChild(m);document.body.appendChild(e);m.innerHTML=j;var c=this;var a=[];this.getContentDiv=function(){return m};this.show=function(){if(mesa.Popup.onOpenClose&&mesa.Popup.currentMessageWindowStack.length==0){mesa.Popup.onOpenClose(true)}mesa.Popup.currentMessageWindowStack.push(c);var t=document.getElementsByTagName("select");if(t){for(var s=0;s<t.length;++s){a[s]=t[s].style.visibility;t[s].style.visibility="hidden"}}if(p){$(d).show()}$(m).show();$(e).show()};this.hide=function(){mesa.Popup.currentMessageWindowStack.pop();if(mesa.Popup.onOpenClose&&mesa.Popup.currentMessageWindowStack.length==0){mesa.Popup.onOpenClose(false)}var t=document.getElementsByTagName("select");if(t){for(var s=0;s<t.length;++s){t[s].style.visibility=a[s]}}if(p){$(d).hide()}$(m).hide();$(e).hide()};this.ok=function(s){this.hide();if(l&&typeof(l)=="function"){setTimeout(function(){l(s)},0)}};this.cancel=function(){this.hide();if(g){setTimeout(function(){g()},0)}};this.setHeight=function(s){e.style.top=Math.max(0,(i-s)/2-10)+"px"};this.setWidth=function(s){m.style.width=s+"px"};this.setWidth(n);this.setHeight(k)};mesa.Popup.MessageWindow=function(l,g,j,b,k,h,a,e,i){var c=mesa.WebUtils.applyTemplate("iframePopup",{title:g});this.base=mesa.Popup.BaseMessageWindow;this.base(c,b,k,h,e,i);var f=this.show;this.show=function(){if(j.indexOf("/")!=0&&j.indexOf("http")!=0){j=pageContext.basePath+j}this.getContentDiv().getElementsByTagName("iframe")[0].src=j;f()};this.getChildWindow=function(){return this.getContentDiv().getElementsByTagName("iframe")[0].contentWindow};this.getArgument=function(){return a};this.setTitle=function(n){var m=this.getContentDiv().getElementsByClassName("title")[0];if(typeof(n)=="object"){m.innerHTML="<img src='"+n.icon+"'/> "+n.text.escapeHTML()}else{if(typeof(n)=="string"){m.innerHTML=n.escapeHTML()}}};var d=this.setHeight;this.setHeight=function(m){this.getContentDiv().getElementsByTagName("iframe")[0].height=m;d(m)};this.clear=function(){this.getContentDiv().getElementsByTagName("iframe")[0].src="about:blank"};this.setHeight(k)};mesa.Popup.getParentArgument=function(){return parent.mesa.Popup.getCurrentMessageWindow().getArgument()};mesa.Popup.ok=function(a){parent.mesa.Popup.getCurrentMessageWindow().ok(a)};mesa.Popup.cancel=function(){parent.mesa.Popup.getCurrentMessageWindow().cancel()};mesa.Popup.setPopupTitle=function(a){parent.mesa.Popup.getCurrentMessageWindow().setTitle(a)};mesa.Popup.eliminateScroll=function(b){var c=mesa.WebUtils.getPageSize().h;var a=mesa.WebUtils.getPageSize().w;if(b){c=Math.min(c,b)}parent.mesa.Popup.getCurrentMessageWindow().setHeight(c+5);parent.mesa.Popup.getCurrentMessageWindow().setWidth(a+5)};mesa.Popup.cancelOnEsc=function(a){var b=a||window.event;if(b.keyCode==27){mesa.Popup.cancel()}};mesa.Popup.ImagePreviewer=function(a,b){if(!b){b=0}var e=this;var c=mesa.WebUtils.applyTemplate("imagePreviewerPopup");this.base=mesa.Popup.BaseMessageWindow;this.base(c,50,50,true);var d=this.getContentDiv().getElementsByTagName("img")[0];d.onload=function(){e.setWidth(d.width+10);e.setHeight(d.height+35)};this.paint=function(){d.src=a[b];this.getContentDiv().getElementsByClassName("prevLink")[0].style.visibility=b>0?"visible":"hidden";this.getContentDiv().getElementsByClassName("nextLink")[0].style.visibility=b<a.length-1?"visible":"hidden"};this.previous=function(){if(b>0){b--;this.paint()}};this.next=function(){if(b<a.length-1){b++;this.paint()}};this.paint()};mesa.Popup.VideoPlayer=function(g,f,d,a,e){var c=mesa.WebUtils.applyTemplate("videoPlayerPopup");this.base=mesa.Popup.BaseMessageWindow;this.base(c,d+10,a,true);var b=this.show;this.show=function(){b();this.getContentDiv().getElementsByClassName("videoContainer")[0].innerHTML=mesa.WebUtils.getFlashScript(g,f,d,a,e)}};mesa.Popup.popupUnityPlayer=function(e,d,a){var c=mesa.WebUtils.applyTemplate("unityPlayerPopup",{width:d,height:a});this.base=mesa.Popup.BaseMessageWindow;this.base(c,d+10,a,true);var b=this.show;this.show=function(){b();var f=this.getContentDiv().getElementsByClassName("unityContainer")[0];mesa.UnityUtils.embedUnity(e,f,null,function(){f.innerHTML=mesa.UnityUtils.getInstallEmbed();f.getElementsByTagName("a")[0].style.margin="100px auto";f.style.height="200px"})}};mesa.Popup.alert=function(d,e,f,c){var b=new mesa.Popup.MessageWindow(c?c:"Muse Games","popup/alert.jsp",300,100,!e,d,function(g){if(a){clearTimeout(a);a=null}if(f){f()}},function(){if(a){clearTimeout(a);a=null}});var a;b.show();if(e){a=setTimeout(function(){a=null;b.ok()},e)}};