if(typeof Forums=="undefined"){var Forums={}}if(!Forums.Controls){Forums.Controls={}}if(!Forums.Utils){Forums.Utils={}}[].indexOf||(Array.prototype.indexOf=function(B,D){D=(D==null)?0:D;var A=this.length;for(var C=D;C<A;C++){if(this[C]==B){return C}}return -1});Forums.Controls.Popup=function(C,B,D,F,E,A){this._backgroundID="_PopupBackground";this._backgroundClass="PopupBackground";this._elementID=C;this._showID=B;this._onShowScript=D;this._iFrameId=F;this._width=E;this._height=A;this._backgroundElement=null;this._element=null;this._showElement=null;this._initialized=false;this._Select=new Array();if(this._showID!=""){this.hookHandler()}};Forums.Controls.Popup.prototype={initialize:function(){this._backgroundElement=document.createElement("div");this._backgroundElement.className=this._backgroundClass;this._backgroundElement.id=this._backgroundID;this._backgroundElement.style.display="none";this._backgroundElement.style.position="absolute";this._backgroundElement.style.left="0px";this._backgroundElement.style.top="0px";this._backgroundElement.style.zIndex=9998999;this._element=document.getElementById(this._elementID);this._element.style.display="none";this._element.style.position="absolute";this._element.style.zIndex=9999999;this._resizeHandler=null;this._scrollHandler=null;this._element.parentNode.appendChild(this._backgroundElement);this._initialized=true},hookHandler:function(){this._showElement=document.getElementById(this._showID);this._showElement.onclick=Forums.Utils.Delegate(this,this.show)},show:function(){if(!this._initialized){this.initialize()}eval(this._onShowScript);this.resize();this._backgroundElement.style.display="block";this._element.style.visibility="visible";this._element.style.display="block";if(this._iFrameId){document.getElementById(this._iFrameId).style.display="block"}this._resizeHandler=Forums.Utils.Delegate(this,this.resize);this._scrollHandler=Forums.Utils.Delegate(this,this.resize);Forums.Utils.AddEvent(window,"resize",this._resizeHandler);Forums.Utils.AddEvent(window,"scroll",this._scrollHandler);this.hideSelect();return false},hideSelect:function(){var A=document.getElementsByTagName("SELECT");this._Select=new Array();for(var B=0;B<A.length;B++){this._Select[B]={tag:A[B],oldv:A[B].style.visibility};A[B].style.visibility="hidden"}},showSelect:function(){for(var A=0;A<this._Select.length;A++){this._Select[A].tag.style.visibility=this._Select[A].oldv}},close:function(){this._backgroundElement.style.display="none";this._element.style.visibility="hidden";if(this._iFrameId){document.getElementById(this._iFrameId).style.display="none";document.getElementById(this._iFrameId).src=""}Forums.Utils.RemoveEvent(window,"resize",this._resizeHandler);Forums.Utils.RemoveEvent(window,"scroll",this._scrollHandler);this.showSelect()},resize:function(){var C=GetWindowSize();var D=GetWindowScrollXY();var B=0;var A=0;this._backgroundElement.style.width=Math.max(Math.max(document.documentElement.scrollWidth,document.body.scrollWidth),C[0])+"px";this._backgroundElement.style.height=Math.max(Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),C[1])+"px";var B=(C[1]-this._height)/2;var A=(C[0]-this._width)/2;if(this._element.style.position=="absolute"){this._element.style.top=B+D[1]+"px";this._element.style.left=A+D[0]+"px"}else{this._element.style.top=B+"px";this._element.style.left=A+"px"}}};Forums.Utils.Delegate=function(B,A){return function(){return A.apply(B,arguments)}};Forums.Utils.AddEvent=function(C,B,A){if(C.attachEvent){C["e"+B+A]=A;C[B+A]=function(){C["e"+B+A](window.event)};C.attachEvent("on"+B,C[B+A])}else{C.addEventListener(B,A,false)}};Forums.Utils.RemoveEvent=function(C,B,A){if(C.detachEvent){C.detachEvent("on"+B,C[B+A]);C[B+A]=null}else{C.removeEventListener(B,A,false)}};Forums.Utils.TimedExecution=function(B,A){this.callback=B;this.interval=A;this.start=function(){this.timer=setInterval(this.callback,A)};this.stop=function(){if(!this.timer){return}clearInterval(this.timer)}};var objTimedExec;var cHeight;var maxHeight;var settingsIFrameId="SettingsIFrame";var SettingsPageSrc=function(A){var B=document.getElementById(settingsIFrameId);cHeight=0;B.style.height="0px";B.src=A};function SetIFrameHeight(){maxHeight=document.getElementById(settingsIFrameId).contentWindow.document.body.scrollHeight;objTimedExec=new Forums.Utils.TimedExecution(function(){changeHeight()},10);objTimedExec.start()}function changeHeight(){if(cHeight<=maxHeight){document.getElementById(settingsIFrameId).style.height=cHeight+"px";cHeight+=20}else{document.getElementById(settingsIFrameId).style.height=maxHeight+"px";objTimedExec.stop()}}Forums.Controls.PostPopup=function(G,H,J,F,I,B,D,E,L,A,K,C){this.subjectId=E;this.bodyId=L;this.closeID=J;this.showID=F;this.showPreviewId=I;this.postId=B;this.postPreviewId=D;this.message=C;this.okId=H;this._showElement=null;this._okElement=null;this._prevShowhandler=null;this._bodyElement=null;this.popup=new Forums.Controls.Popup(G,"","","",A,K);if(this._showID!=""){Forums.Utils.AddEvent(window,"load",Forums.Utils.Delegate(this,this.initialize))}};Forums.Controls.PostPopup.prototype={getTextArea:function(){var A=document.getElementById(this.bodyId);var B=A.getElementsByTagName("textarea");var C;if(B.length>=1){C=B[0]}return C},CheckAndShow:function(){window.onbeforeunload=null;var A=document.getElementById(this.subjectId);if((A&&A.value!="")||(this._bodyElement&&this._bodyElement.value!="")){this.popup.show();if(!this._closeElement){this._closeElement=document.getElementById(this.closeID);this._closeElement.onclick=Forums.Utils.Delegate(this,this.close)}if(!this._okElement){this._okElement=document.getElementById(this.okId);this._okElement.onclick=Forums.Utils.Delegate(this,this.ok)}return false}return true},initialize:function(){this._showElement=document.getElementById(this.showID);this._showElement.onclick=Forums.Utils.Delegate(this,this.CheckAndShow);var D=document.getElementById(this.showPreviewId);D.onclick=Forums.Utils.Delegate(this,this.CheckAndShow);var C=document.getElementById(this.postId);C.onclick=function(){window.onbeforeunload=null};var B=document.getElementById(this.postPreviewId);B.onclick=function(){window.onbeforeunload=null};var A=document.getElementById(this.bodyId);this._bodyElement=this.getTextArea();if(this._bodyElement){Forums.Utils.AddEvent(A,"keyup",Forums.Utils.Delegate(this,this.onBodyKeyPress))}},onBodyKeyPress:function(A){if(this._bodyElement.value!=""){window.onbeforeunload=Forums.Utils.Delegate(this,this.callBeforeUnload)}else{window.onbeforeunload=null}},close:function(){window.onbeforeunload=Forums.Utils.Delegate(this,this.callBeforeUnload);this.popup.close();return false},ok:function(){this.popup.close();window.location.replace(this._showElement.href)},callBeforeUnload:function(A){if(!A){A=window.event}A.returnValue=this.message}};