var g_ModalInstancesInternal=null;function GetTopModalWindow(){if("function"==typeof GetTopWindow){return GetTopWindow()}return window}function GetModalInstances(){if("function"==typeof GetTopWindow){var a=GetTopWindow();if(null==a.g_ModalInstancesInternal){a.g_ModalInstancesInternal=new Array()}return a.g_ModalInstancesInternal}if(window.g_ModalInstancesInternal){if(window.g_ModalInstancesInternal==null){window.g_ModalInstancesInternal=new Array()}return window.g_ModalInstancesInternal}ASSERT(false);if(g_ModalInstancesInternal==null){g_ModalInstancesInternal=new Array()}return g_ModalInstancesInternal}function CloseModalBox(){if(0!=GetModalInstances().length){ModalBoxProc("close")}}function ResizeModalBoxes(){var b=GetModalInstances();if(null!=b){for(var a=0;a<b.length;++a){b[a].OnResize()}}}function ModalBoxProc(e,c){switch(e.toLowerCase()){case"close":var d=GetModalInstances()[GetModalInstances().length-1];var b=true;if("function"==typeof c){var a=c(d.userdata,d.wnd);b=("undefined"==typeof a)||(a)}if(b){if(null!=d.OrgEnterEvt){SetEnterEvent(d.OrgEnterEvt)}if(null!=d.divBack){d.targetDoc.body.removeChild(d.divBack)}d.targetDoc.body.removeChild(d.divBox);if(d.bHideIframes){ShowAllHiddenElementsInArray(d.theHiddenSelects);ShowAllHiddenElementsInArray(d.theHiddenIframes);ShowAllHiddenElementsInArray(d.theHiddenEmbeds)}RemoveFromArray(GetModalInstances(),d);if(GetModalInstances().length!=0){GetModalInstances()[GetModalInstances().length-1].Enable()}if("function"==typeof d.OnAfterCloseEvent){d.OnAfterCloseEvent(d)}}else{d.OnResize()}break;default:break}}function MsgBoxAttribScriptEscape(a){return a.replace(/\\/g,"\\\\").replace(/\"/g,"&quot;").replace(/\'/g,"&#39;")}function ModalBoxInstance(a,q,n,l,h,j){this.bHideIframes=(("undefined"==typeof j)||(true==j));if(this.bHideIframes){this.theHiddenSelects=HideAllVisibleElementsByName("SELECT",true);this.theHiddenIframes=HideAllVisibleElementsByName("IFRAME");this.theHiddenEmbeds=HideAllVisibleElementsByName("EBMED")}this.targetDoc=GetTopWindow().document;this.wnd=(h)?h:window;this.OnResize=ModalBoxInstance_OnResize;this.Enable=ModalBoxInstance_Enable;this.Disable=ModalBoxInstance_Disable;this.OnAfterCloseEvent=null;this.divBack=null;this.divDisable=null;if(GetModalInstances().length!=0){GetModalInstances()[GetModalInstances().length-1].Disable()}else{this.divBack=this.targetDoc.createElement("div");AddCssClass(this.divBack,"msgboxcurtain");this.targetDoc.body.appendChild(this.divBack);SetElmHeight(this.divBack,GetClientHeight(this.targetDoc))}this.OrgEnterEvt=GetEnterEvent();if(null!=this.OrgEnterEvt){ClearEnterEvent()}this.divBox=this.targetDoc.createElement("div");AddCssClass(this.divBox,"msgbox");AddCssClass(this.divBox,"fmtSection colors1");this.targetDoc.body.appendChild(this.divBox);this.divHead=this.targetDoc.createElement("div");this.divCont=this.targetDoc.createElement("div");this.divFull=this.targetDoc.createElement("div");this.divBtns=this.targetDoc.createElement("div");this.divContent=this.targetDoc.createElement("div");AddCssClass(this.divHead,"head");AddCssClass(this.divCont,"cont");AddCssClass(this.divFull,"full");AddCssClass(this.divBtns,"btns");AddCssClass(this.divContent,"content");if(("string"==typeof l)&&(""!=l)){AddCssClass(this.divCont,l);AddCssClass(this.divFull,l)}this.divBox.appendChild(this.divHead);this.divBox.appendChild(this.divCont);this.divCont.appendChild(this.divFull);this.divFull.appendChild(this.divContent);this.divFull.appendChild(this.divBtns);var p="";p+="<p>"+q+"</p>";var f,b,o;var d="";var m="<p>";var g="";for(f=0;f<n.length;++f){b=n[f];g=(""!==b.code)?b.code:"return true;";g="function(aContext,aWnd){  var func   = function(aContext,aWnd) {"+MsgBoxAttribScriptEscape(g)+'};  var retval = func.apply( aWnd, [aContext,aWnd]);  return ("undefined" != typeof retval) ? retval : true;}';m+='<a href=\'javascript:ModalBoxProc("close",'+g+");'";m+=" "+AttribStr("class",b.css,"'");m+=" "+AttribStr("title",b.text,"'");o=("string"==typeof b.id)?b.id:"ModalButton"+(100*GetModalInstances().length+f).toString();m+=" "+AttribStr("id",o,"'");if((0==f)||b.focus){d=o}m+=g_sLinkCode+">";m+=b.text+"</a>"}m+="</p>";SetLayerContent(this.divHead,"<h1>"+a+"</h1>");SetLayerContent(this.divBtns,m);SetLayerContent(this.divContent,p);this.OnResize();SetElmHeight(this.divBox,30);window.setTimeout("ResizeModalBoxes();",50);if(""!=d){var c=this.targetDoc.getElementById(d);try{if(c){c.focus()}}catch(k){}}}function ModalBoxInstance_OnResize(){var h=new ResizeInfo(this.targetDoc);var e=h.clientH*0.3;SetElmTop(this.divBox,e);SetElmHeight(this.divContent,"auto");GetElmHeight(this.divContent);var f=GetElmHeight(this.divContent)+2;var d=h.clientH-e-e*0.3;var a=d-GetElmHeight(this.divHead);var g=a-GetElmHeight(this.divBtns);var c=Math.min(g,Math.max(30,f));var b=c-g;d+=b;a+=b;SetElmHeight(this.divBox,d);SetElmHeight(this.divCont,a);SetElmTop(this.divFull,0);SetElmTop(this.divContent,0);SetElmTop(this.divBtns,c);SetElmHeight(this.divFull,a);SetElmHeight(this.divContent,g);SetElmLeft(this.divContent,5);SetElmWidth(this.divContent,GetElmWidth(this.divFull)-10);if(null!=this.divDisable){SetElmHeight(this.divDisable,GetElmHeight(this.divBox))}if(null!=this.divBack){SetElmHeight(this.divBack,GetClientHeight(this.targetDoc))}}function ModalBoxInstance_Enable(){if(null==this.divDisable){return}this.divFull.removeChild(this.divDisable);this.divDisable=null;this.OnResize()}function ModalBoxInstance_Disable(){if(null!=this.divDisable){return}this.OnResize();this.divDisable=this.targetDoc.createElement("div");AddCssClass(this.divDisable,"msgboxcurtain");this.divFull.appendChild(this.divDisable);SetElmHeight(this.divDisable,GetElmHeight(this.divFull))}function ModalBox(a,h,g,i,e,c,d){var f=GetTopModalWindow().ModalBoxInstance;var b=new f(a,h,g,e,c,d);b.userdata=i?i:null;AddToArray(GetModalInstances(),b);return b};
