function PopupWin(J,I,H,G){this.editor=J;this.handler=H;var F=window.open("","__ha_dialog","toolbar=no,menubar=no,personalbar=no,width=600,height=600,left=20,top=40,scrollbars=no,resizable=yes");this.window=F;var E=F.document;this.doc=E;var D=this;var C=document.baseURI||document.URL;if(C&&C.match(/(.*)\/([^\/]+)/)){C=RegExp.$1+"/"}if(typeof _editor_url!="undefined"&&!(/^\//.test(_editor_url))&&!(/http:\/\//.test(_editor_url))){C+=_editor_url}else{C=_editor_url}if(!(/\/$/.test(C))){C+="/"}this.baseURL=C;E.open();var B="<html><head><title>"+I+"</title>\n";B+='<style type="text/css">@import url('+_editor_url+"Xinha.css);</style>\n";if(_editor_skin!=""){B+='<style type="text/css">@import url('+_editor_url+"skins/"+_editor_skin+"/skin.css);</style>\n"}B+="</head>\n";B+='<body class="dialog popupwin" id="--HA-body"></body></html>';E.write(B);E.close();function A(){var L=E.body;if(!L){setTimeout(A,25);return false}F.title=I;E.documentElement.style.padding="0px";E.documentElement.style.margin="0px";var K=E.createElement("div");K.className="content";D.content=K;L.appendChild(K);D.element=L;G(D);F.focus()}A()}PopupWin.prototype.callHandler=function(){var B=["input","textarea","select"];var A={};for(var F=B.length;--F>=0;){var H=B[F];var D=this.content.getElementsByTagName(H);for(var C=0;C<D.length;++C){var E=D[C];var G=E.value;if(E.tagName.toLowerCase()=="input"){if(E.type=="checkbox"){G=E.checked}}A[E.name]=G}}this.handler(this,A);return false};PopupWin.prototype.close=function(){this.window.close()};PopupWin.prototype.addButtons=function(){var D=this;var E=this.doc.createElement("div");this.content.appendChild(E);E.id="buttons";E.className="buttons";for(var C=0;C<arguments.length;++C){var B=arguments[C];var A=this.doc.createElement("button");E.appendChild(A);A.innerHTML=Xinha._lc(B,"Xinha");switch(B.toLowerCase()){case"ok":Xinha.addDom0Event(A,"click",function(){D.callHandler();D.close();return false});break;case"cancel":Xinha.addDom0Event(A,"click",function(){D.close();return false});break}}};PopupWin.prototype.showAtElement=function(){var A=this;setTimeout(function(){var B=A.content.offsetWidth+4;var E=A.content.offsetHeight+4;var D=A.content;var C=D.style;C.position="absolute";C.left=parseInt((B-D.offsetWidth)/2,10)+"px";C.top=parseInt((E-D.offsetHeight)/2,10)+"px";if(Xinha.is_gecko){A.window.innerWidth=B;A.window.innerHeight=E}else{A.window.resizeTo(B+8,E+70)}},25)};