var Window=Class.create();Window.keepMultiModalWindow=false;Window.hasEffectLib=(typeof Effect!="undefined");Window.resizeEffectDuration=0.4;Window.prototype={initialize:function(){var C;var B=0;if(arguments.length>0){if(typeof arguments[0]=="string"){C=arguments[0];B=1}else{C=arguments[0]?arguments[0].id:null}}if(!C){C="window_"+new Date().getTime()}if($(C)){this.destroy();}this.options=Object.extend({className:"dialog",blurClassName:null,minWidth:100,minHeight:20,resizable:true,closable:true,minimizable:true,maximizable:true,draggable:true,userData:null,showEffect:(Window.hasEffectLib?Effect.Appear:Element.show),hideEffect:(Window.hasEffectLib?Effect.Fade:Element.hide),showEffectOptions:{},hideEffectOptions:{},effectOptions:null,parent:document.body,title:"&nbsp;",url:null,onload:Prototype.emptyFunction,width:200,height:300,opacity:1,recenterAuto:true,wiredDrag:false,closeCallback:null,destroyOnClose:false,gridX:1,gridY:1},arguments[B]||{});if(this.options.blurClassName){this.options.focusClassName=this.options.className}if(typeof this.options.top=="undefined"&&typeof this.options.bottom=="undefined"){this.options.top=this._round(Math.random()*500,this.options.gridY)}if(typeof this.options.left=="undefined"&&typeof this.options.right=="undefined"){this.options.left=this._round(Math.random()*500,this.options.gridX)}if(this.options.effectOptions){Object.extend(this.options.hideEffectOptions,this.options.effectOptions);Object.extend(this.options.showEffectOptions,this.options.effectOptions);if(this.options.showEffect==Element.Appear){this.options.showEffectOptions.to=this.options.opacity}}if(Window.hasEffectLib){if(this.options.showEffect==Effect.Appear){this.options.showEffectOptions.to=this.options.opacity}if(this.options.hideEffect==Effect.Fade){this.options.hideEffectOptions.from=this.options.opacity}}if(this.options.hideEffect==Element.hide){this.options.hideEffect=function(){Element.hide(this.element);if(this.options.destroyOnClose){this.destroy()}}.bind(this)}if(this.options.parent!=document.body){this.options.parent=$(this.options.parent)}this.element=this._createWindow(C);this.element.win=this;this.eventMouseDown=this._initDrag.bindAsEventListener(this);this.eventMouseUp=this._endDrag.bindAsEventListener(this);this.eventMouseMove=this._updateDrag.bindAsEventListener(this);this.eventOnLoad=this._getWindowBorderSize.bindAsEventListener(this);this.eventMouseDownContent=this.toFront.bindAsEventListener(this);this.eventResize=this._recenter.bindAsEventListener(this);this.topbar=$(this.element.id+"_top");this.bottombar=$(this.element.id+"_bottom");this.content=$(this.element.id+"_content");Event.observe(this.topbar,"mousedown",this.eventMouseDown);Event.observe(this.bottombar,"mousedown",this.eventMouseDown);Event.observe(this.content,"mousedown",this.eventMouseDownContent);Event.observe(window,"load",this.eventOnLoad);Event.observe(window,"resize",this.eventResize);Event.observe(window,"scroll",this.eventResize);Event.observe(this.options.parent,"scroll",this.eventResize);if(this.options.draggable){var A=this;[this.topbar,this.topbar.up().previous(),this.topbar.up().next()].each(function(D){D.observe("mousedown",A.eventMouseDown);D.addClassName("top_draggable")});[this.bottombar.up(),this.bottombar.up().previous(),this.bottombar.up().next()].each(function(D){D.observe("mousedown",A.eventMouseDown);D.addClassName("bottom_draggable")})}if(this.options.resizable){this.sizer=$(this.element.id+"_sizer");Event.observe(this.sizer,"mousedown",this.eventMouseDown)}this.useLeft=null;this.useTop=null;if(typeof this.options.left!="undefined"){this.element.setStyle({left:parseFloat(this.options.left)+"px"});this.useLeft=true}else{this.element.setStyle({right:parseFloat(this.options.right)+"px"});this.useLeft=false}if(typeof this.options.top!="undefined"){this.element.setStyle({top:parseFloat(this.options.top)+"px"});this.useTop=true}else{this.element.setStyle({bottom:parseFloat(this.options.bottom)+"px"});this.useTop=false}this.storedLocation=null;this.setOpacity(this.options.opacity);if(this.options.zIndex){this.setZIndex(this.options.zIndex)}if(this.options.destroyOnClose){this.setDestroyOnClose(true)}this._getWindowBorderSize();this.width=this.options.width;this.height=this.options.height;this.visible=false;this.constraint=false;this.constraintPad={top:0,left:0,bottom:0,right:0};if(this.width&&this.height){this.setSize(this.options.width,this.options.height)}this.setTitle(this.options.title);Windows.register(this)},destroy:function(){this._notify("onDestroy");Event.stopObserving(this.topbar,"mousedown",this.eventMouseDown);Event.stopObserving(this.bottombar,"mousedown",this.eventMouseDown);Event.stopObserving(this.content,"mousedown",this.eventMouseDownContent);Event.stopObserving(window,"load",this.eventOnLoad);Event.stopObserving(window,"resize",this.eventResize);Event.stopObserving(window,"scroll",this.eventResize);Event.stopObserving(this.content,"load",this.options.onload);if(this._oldParent){var C=this.getContent();var A=null;for(var B=0;B<C.childNodes.length;B++){A=C.childNodes[B];if(A.nodeType==1){break}A=null}if(A){this._oldParent.appendChild(A)}this._oldParent=null}if(this.sizer){Event.stopObserving(this.sizer,"mousedown",this.eventMouseDown)}if(this.options.url){this.content.src=null}if(this.iefix){Element.remove(this.iefix)}Element.remove(this.element);Windows.unregister(this)},setCloseCallback:function(A){this.options.closeCallback=A},getContent:function(){return this.content},setContent:function(G,F,B){var A=$(G);if(null==A){throw"Unable to find element '"+G+"' in DOM"}this._oldParent=A.parentNode;var E=null;var D=null;if(F){E=Element.getDimensions(A)}if(B){D=Position.cumulativeOffset(A)}var C=this.getContent();this.setHTMLContent("");C=this.getContent();C.appendChild(A);A.show();if(F){this.setSize(E.width,E.height)}if(B){this.setLocation(D[1]-this.heightN,D[0]-this.widthW)}},setHTMLContent:function(A){if(this.options.url){this.content.src=null;this.options.url=null;var B='<div id="'+this.getId()+'_content" class="'+this.options.className+'_content"> </div>';$(this.getId()+"_table_content").innerHTML=B;this.content=$(this.element.id+"_content")}this.getContent().innerHTML=A},setAjaxContent:function(B,A,D,C){this.showFunction=D?"showCenter":"show";this.showModal=C||false;A=A||{};this.setHTMLContent("");this.onComplete=A.onComplete;if(!this._onCompleteHandler){this._onCompleteHandler=this._setAjaxContent.bind(this)}A.onComplete=this._onCompleteHandler;new Ajax.Request(B,A);A.onComplete=this.onComplete},_setAjaxContent:function(A){Element.update(this.getContent(),A.responseText);if(this.onComplete){this.onComplete(A)}this.onComplete=null;this[this.showFunction](this.showModal)},setURL:function(A){if(this.options.url){this.content.src=null}this.options.url=A;var B="<iframe frameborder='0' name='"+this.getId()+"_content'  id='"+this.getId()+"_content' src='"+A+"' width='"+this.width+"' height='"+this.height+"'> </iframe>";$(this.getId()+"_table_content").innerHTML=B;this.content=$(this.element.id+"_content")},getURL:function(){return this.options.url?this.options.url:null},refresh:function(){if(this.options.url){$(this.element.getAttribute("id")+"_content").src=this.options.url}},setCookie:function(B,C,M,E,A){B=B||this.element.id;this.cookie=[B,C,M,E,A];var K=WindowUtilities.getCookie(B);if(K){var L=K.split(",");var I=L[0].split(":");var H=L[1].split(":");var J=parseFloat(L[2]),F=parseFloat(L[3]);var G=L[4];var D=L[5];this.setSize(J,F);if(G=="true"){this.doMinimize=true}else{if(D=="true"){this.doMaximize=true}}this.useLeft=I[0]=="l";this.useTop=H[0]=="t";this.element.setStyle(this.useLeft?{left:I[1]}:{right:I[1]});this.element.setStyle(this.useTop?{top:H[1]}:{bottom:H[1]})}},getId:function(){return this.element.id},setDestroyOnClose:function(){this.options.destroyOnClose=true},setConstraint:function(A,B){this.constraint=A;this.constraintPad=Object.extend(this.constraintPad,B||{});if(this.useTop&&this.useLeft){this.setLocation(parseFloat(this.element.style.top),parseFloat(this.element.style.left))}},_initDrag:function(B){if(Event.element(B)==this.sizer&&this.isMinimized()){return }if(Event.element(B)!=this.sizer&&this.isMaximized()){return }if(Prototype.Browser.IE&&this.heightN==0){this._getWindowBorderSize()}this.pointer=[this._round(Event.pointerX(B),this.options.gridX),this._round(Event.pointerY(B),this.options.gridY)];if(this.options.wiredDrag){this.currentDrag=this._createWiredElement()}else{this.currentDrag=this.element}if(Event.element(B)==this.sizer){this.doResize=true;this.widthOrg=this.width;this.heightOrg=this.height;this.bottomOrg=parseFloat(this.element.getStyle("bottom"));this.rightOrg=parseFloat(this.element.getStyle("right"));this._notify("onStartResize")}else{this.doResize=false;var A=$(this.getId()+"_close");if(A&&Position.within(A,this.pointer[0],this.pointer[1])){this.currentDrag=null;return }this.toFront();if(!this.options.draggable){return }this._notify("onStartMove")}Event.observe(document,"mouseup",this.eventMouseUp,false);Event.observe(document,"mousemove",this.eventMouseMove,false);WindowUtilities.disableScreen("__invisible__","__invisible__",this.overlayOpacity);document.body.ondrag=function(){return false};document.body.onselectstart=function(){return false};this.currentDrag.show();Event.stop(B)},_round:function(B,A){return A==1?B:B=Math.floor(B/A)*A},_updateDrag:function(B){var A=[this._round(Event.pointerX(B),this.options.gridX),this._round(Event.pointerY(B),this.options.gridY)];var J=A[0]-this.pointer[0];var I=A[1]-this.pointer[1];if(this.doResize){var H=this.widthOrg+J;var D=this.heightOrg+I;J=this.width-this.widthOrg;I=this.height-this.heightOrg;if(this.useLeft){H=this._updateWidthConstraint(H)}else{this.currentDrag.setStyle({right:(this.rightOrg-J)+"px"})}if(this.useTop){D=this._updateHeightConstraint(D)}else{this.currentDrag.setStyle({bottom:(this.bottomOrg-I)+"px"})}this.setSize(H,D);this._notify("onResize")}else{this.pointer=A;if(this.useLeft){var C=parseFloat(this.currentDrag.getStyle("left"))+J;var G=this._updateLeftConstraint(C);this.pointer[0]+=G-C;this.currentDrag.setStyle({left:G+"px"})}else{this.currentDrag.setStyle({right:parseFloat(this.currentDrag.getStyle("right"))-J+"px"})}if(this.useTop){var F=parseFloat(this.currentDrag.getStyle("top"))+I;var E=this._updateTopConstraint(F);this.pointer[1]+=E-F;this.currentDrag.setStyle({top:E+"px"})}else{this.currentDrag.setStyle({bottom:parseFloat(this.currentDrag.getStyle("bottom"))-I+"px"})}this._notify("onMove")}if(this.iefix){this._fixIEOverlapping()}this._removeStoreLocation();Event.stop(B)},_endDrag:function(A){WindowUtilities.enableScreen("__invisible__");if(this.doResize){this._notify("onEndResize")}else{this._notify("onEndMove")}Event.stopObserving(document,"mouseup",this.eventMouseUp,false);Event.stopObserving(document,"mousemove",this.eventMouseMove,false);Event.stop(A);this._hideWiredElement();this._saveCookie();document.body.ondrag=null;document.body.onselectstart=null},_updateLeftConstraint:function(B){if(this.constraint&&this.useLeft&&this.useTop){var A=this.options.parent==document.body?WindowUtilities.getPageSize().windowWidth:this.options.parent.getDimensions().width;if(B<this.constraintPad.left){B=this.constraintPad.left}if(B+this.width+this.widthE+this.widthW>A-this.constraintPad.right){B=A-this.constraintPad.right-this.width-this.widthE-this.widthW}}return B},_updateTopConstraint:function(C){if(this.constraint&&this.useLeft&&this.useTop){var A=this.options.parent==document.body?WindowUtilities.getPageSize().windowHeight:this.options.parent.getDimensions().height;var B=this.height+this.heightN+this.heightS;if(C<this.constraintPad.top){C=this.constraintPad.top}if(C+B>A-this.constraintPad.bottom){C=A-this.constraintPad.bottom-B}}return C},_updateWidthConstraint:function(A){if(this.constraint&&this.useLeft&&this.useTop){var B=this.options.parent==document.body?WindowUtilities.getPageSize().windowWidth:this.options.parent.getDimensions().width;var C=parseFloat(this.element.getStyle("left"));if(C+A+this.widthE+this.widthW>B-this.constraintPad.right){A=B-this.constraintPad.right-C-this.widthE-this.widthW}}return A},_updateHeightConstraint:function(B){if(this.constraint&&this.useLeft&&this.useTop){var A=this.options.parent==document.body?WindowUtilities.getPageSize().windowHeight:this.options.parent.getDimensions().height;var C=parseFloat(this.element.getStyle("top"));if(C+B+this.heightN+this.heightS>A-this.constraintPad.bottom){B=A-this.constraintPad.bottom-C-this.heightN-this.heightS}}return B},_createWindow:function(A){var F=this.options.className;var D=document.createElement("div");D.setAttribute("id",A);D.className="dialog";var E;if(this.options.url){E='<iframe frameborder="0" name="'+A+'_content"  id="'+A+'_content" src="'+this.options.url+'"> </iframe>'}else{E='<div id="'+A+'_content" class="'+F+'_content"> </div>'}var G=this.options.closable?"<div class='"+F+"_close' id='"+A+"_close' onclick='Windows.close(\""+A+"\", event)'> </div>":"";var H=this.options.minimizable?"<div class='"+F+"_minimize' id='"+A+"_minimize' onclick='Windows.minimize(\""+A+"\", event)'> </div>":"";var I=this.options.maximizable?"<div class='"+F+"_maximize' id='"+A+"_maximize' onclick='Windows.maximize(\""+A+"\", event)'> </div>":"";var C=this.options.resizable?"class='"+F+"_sizer' id='"+A+"_sizer'":"class='"+F+"_se'";var B="../themes/default/blank.gif";D.innerHTML=G+H+I+"      <table id='"+A+"_row1' class=\"top table_window\">        <tr>          <td class='"+F+"_nw'></td>          <td class='"+F+"_n'><div id='"+A+"_top' class='"+F+"_title title_window'>"+this.options.title+"</div></td>          <td class='"+F+"_ne'></td>        </tr>      </table>      <table id='"+A+"_row2' class=\"mid table_window\">        <tr>          <td class='"+F+"_w'></td>            <td id='"+A+"_table_content' class='"+F+"_content' valign='top'>"+E+"</td>          <td class='"+F+"_e'></td>        </tr>      </table>        <table id='"+A+"_row3' class=\"bot table_window\">        <tr>          <td class='"+F+"_sw'></td>            <td class='"+F+"_s'><div id='"+A+"_bottom' class='status_bar'><span style='float:left; width:1px; height:1px'></span></div></td>            <td "+C+"></td>        </tr>      </table>    ";Element.hide(D);this.options.parent.insertBefore(D,this.options.parent.firstChild);Event.observe($(A+"_content"),"load",this.options.onload);return D},changeClassName:function(A){var B=this.options.className;var C=this.getId();$A(["_close","_minimize","_maximize","_sizer","_content"]).each(function(D){this._toggleClassName($(C+D),B+D,A+D)}.bind(this));this._toggleClassName($(C+"_top"),B+"_title",A+"_title");$$("#"+C+" td").each(function(D){D.className=D.className.sub(B,A)});this.options.className=A},_toggleClassName:function(C,B,A){if(C){C.removeClassName(B);C.addClassName(A)}},setLocation:function(C,B){C=this._updateTopConstraint(C);B=this._updateLeftConstraint(B);var A=this.currentDrag||this.element;A.setStyle({top:C+"px"});A.setStyle({left:B+"px"});this.useLeft=true;this.useTop=true},getLocation:function(){var A={};if(this.useTop){A=Object.extend(A,{top:this.element.getStyle("top")})}else{A=Object.extend(A,{bottom:this.element.getStyle("bottom")})}if(this.useLeft){A=Object.extend(A,{left:this.element.getStyle("left")})}else{A=Object.extend(A,{right:this.element.getStyle("right")})}return A},getSize:function(){return{width:this.width,height:this.height}},setSize:function(C,B,A){C=parseFloat(C);B=parseFloat(B);if(!this.minimized&&C<this.options.minWidth){C=this.options.minWidth}if(!this.minimized&&B<this.options.minHeight){B=this.options.minHeight}if(this.options.maxHeight&&B>this.options.maxHeight){B=this.options.maxHeight}if(this.options.maxWidth&&C>this.options.maxWidth){C=this.options.maxWidth}if(this.useTop&&this.useLeft&&Window.hasEffectLib&&Effect.ResizeWindow&&A){new Effect.ResizeWindow(this,null,null,C,B,{duration:Window.resizeEffectDuration})}else{this.width=C;this.height=B;var E=this.currentDrag?this.currentDrag:this.element;E.setStyle({width:C+this.widthW+this.widthE+"px"});E.setStyle({height:B+this.heightN+this.heightS+"px"});if(!this.currentDrag||this.currentDrag==this.element){var D=$(this.element.id+"_content");D.setStyle({height:B+"px"});D.setStyle({width:C+"px"})}}},updateHeight:function(){this.setSize(this.width,this.content.scrollHeight,true)},updateWidth:function(){this.setSize(this.content.scrollWidth,this.height,true)},toFront:function(){if(this.element.style.zIndex<Windows.maxZIndex){this.setZIndex(Windows.maxZIndex+1)}if(this.iefix){this._fixIEOverlapping()}},getBounds:function(B){if(!this.width||!this.height||!this.visible){this.computeBounds()}var A=this.width;var C=this.height;if(!B){A+=this.widthW+this.widthE;C+=this.heightN+this.heightS}var D=Object.extend(this.getLocation(),{width:A+"px",height:C+"px"});return D},computeBounds:function(){if(!this.width||!this.height){var A=WindowUtilities._computeSize(this.content.innerHTML,this.content.id,this.width,this.height,0,this.options.className);if(this.height){this.width=A+5}else{this.height=A+5}}this.setSize(this.width,this.height);if(this.centered){this._center(this.centerTop,this.centerLeft)}},show:function(B){this.visible=true;if(B){if(typeof this.overlayOpacity=="undefined"){var A=this;setTimeout(function(){A.show(B)},10);return }Windows.addModalWindow(this);this.modal=true;this.setZIndex(Windows.maxZIndex+1);Windows.unsetOverflow(this)}else{if(!this.element.style.zIndex){this.setZIndex(Windows.maxZIndex+1)}}if(this.oldStyle){this.getContent().setStyle({overflow:this.oldStyle})}this.computeBounds();this._notify("onBeforeShow");if(this.options.showEffect!=Element.show&&this.options.showEffectOptions){this.options.showEffect(this.element,this.options.showEffectOptions)}else{this.options.showEffect(this.element)}this._checkIEOverlapping();WindowUtilities.focusedWindow=this;this._notify("onShow")},showCenter:function(A,C,B){this.centered=true;this.centerTop=C;this.centerLeft=B;this.show(A)},isVisible:function(){return this.visible},_center:function(C,B){var D=WindowUtilities.getWindowScroll(this.options.parent);var A=WindowUtilities.getPageSize(this.options.parent);if(typeof C=="undefined"){C=(A.windowHeight-(this.height+this.heightN+this.heightS))/2}C+=D.top;if(typeof B=="undefined"){B=(A.windowWidth-(this.width+this.widthW+this.widthE))/2}B+=D.left;this.setLocation(C,B);this.toFront()},_recenter:function(B){if(this.centered){var A=WindowUtilities.getPageSize(this.options.parent);var C=WindowUtilities.getWindowScroll(this.options.parent);if(this.pageSize&&this.pageSize.windowWidth==A.windowWidth&&this.pageSize.windowHeight==A.windowHeight&&this.windowScroll.left==C.left&&this.windowScroll.top==C.top){return }this.pageSize=A;this.windowScroll=C;if($("overlay_modal")){$("overlay_modal").setStyle({height:(A.pageHeight+"px")})}if(this.options.recenterAuto){this._center(this.centerTop,this.centerLeft)}}},hide:function(){this.visible=false;if(this.modal){Windows.removeModalWindow(this);Windows.resetOverflow()}this.oldStyle=this.getContent().getStyle("overflow")||"auto";this.getContent().setStyle({overflow:"hidden"});this.options.hideEffect(this.element,this.options.hideEffectOptions);if(this.iefix){this.iefix.hide()}if(!this.doNotNotifyHide){this._notify("onHide")}},close:function(){if(this.visible){if(this.options.closeCallback&&!this.options.closeCallback(this)){return }if(this.options.destroyOnClose){var A=this.destroy.bind(this);if(this.options.hideEffectOptions.afterFinish){var B=this.options.hideEffectOptions.afterFinish;this.options.hideEffectOptions.afterFinish=function(){B();A()}}else{this.options.hideEffectOptions.afterFinish=function(){A()}}}Windows.updateFocusedWindow();this.doNotNotifyHide=true;this.hide();this.doNotNotifyHide=false;this._notify("onClose")}},minimize:function(){if(this.resizing){return }var A=$(this.getId()+"_row2");if(!this.minimized){this.minimized=true;var D=A.getDimensions().height;this.r2Height=D;var C=this.element.getHeight()-D;if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow){new Effect.ResizeWindow(this,null,null,null,this.height-D,{duration:Window.resizeEffectDuration})}else{this.height-=D;this.element.setStyle({height:C+"px"});A.hide()}if(!this.useTop){var B=parseFloat(this.element.getStyle("bottom"));this.element.setStyle({bottom:(B+D)+"px"})}}else{this.minimized=false;var D=this.r2Height;this.r2Height=null;if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow){new Effect.ResizeWindow(this,null,null,null,this.height+D,{duration:Window.resizeEffectDuration})}else{var C=this.element.getHeight()+D;this.height+=D;this.element.setStyle({height:C+"px"});A.show()}if(!this.useTop){var B=parseFloat(this.element.getStyle("bottom"));this.element.setStyle({bottom:(B-D)+"px"})}this.toFront()}this._notify("onMinimize");this._saveCookie()},maximize:function(){if(this.isMinimized()||this.resizing){return }if(Prototype.Browser.IE&&this.heightN==0){this._getWindowBorderSize()}if(this.storedLocation!=null){this._restoreLocation();if(this.iefix){this.iefix.hide()}}else{this._storeLocation();Windows.unsetOverflow(this);var G=WindowUtilities.getWindowScroll(this.options.parent);var B=WindowUtilities.getPageSize(this.options.parent);var F=G.left;var E=G.top;if(this.options.parent!=document.body){G={top:0,left:0,bottom:0,right:0};var D=this.options.parent.getDimensions();B.windowWidth=D.width;B.windowHeight=D.height;E=0;F=0}if(this.constraint){B.windowWidth-=Math.max(0,this.constraintPad.left)+Math.max(0,this.constraintPad.right);B.windowHeight-=Math.max(0,this.constraintPad.top)+Math.max(0,this.constraintPad.bottom);F+=Math.max(0,this.constraintPad.left);E+=Math.max(0,this.constraintPad.top)}var C=B.windowWidth-this.widthW-this.widthE;var A=B.windowHeight-this.heightN-this.heightS;if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow){new Effect.ResizeWindow(this,E,F,C,A,{duration:Window.resizeEffectDuration})}else{this.setSize(C,A);this.element.setStyle(this.useLeft?{left:F}:{right:F});this.element.setStyle(this.useTop?{top:E}:{bottom:E})}this.toFront();if(this.iefix){this._fixIEOverlapping()}}this._notify("onMaximize");this._saveCookie()},isMinimized:function(){return this.minimized},isMaximized:function(){return(this.storedLocation!=null)},setOpacity:function(A){if(Element.setOpacity){Element.setOpacity(this.element,A)}},setZIndex:function(A){this.element.setStyle({zIndex:A});Windows.updateZindex(A,this)},setTitle:function(A){if(!A||A==""){A="&nbsp;"}Element.update(this.element.id+"_top",A)},getTitle:function(){return $(this.element.id+"_top").innerHTML},setStatusBar:function(B){var A=$(this.getId()+"_bottom");if(typeof (B)=="object"){if(this.bottombar.firstChild){this.bottombar.replaceChild(B,this.bottombar.firstChild)}else{this.bottombar.appendChild(B)}}else{this.bottombar.innerHTML=B}},_checkIEOverlapping:function(){if(!this.iefix&&(navigator.appVersion.indexOf("MSIE")>0)&&(navigator.userAgent.indexOf("Opera")<0)&&(this.element.getStyle("position")=="absolute")){new Insertion.After(this.element.id,'<iframe id="'+this.element.id+'_iefix" style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" src="javascript:false;" frameborder="0" scrolling="no"></iframe>');this.iefix=$(this.element.id+"_iefix")}if(this.iefix){setTimeout(this._fixIEOverlapping.bind(this),50)}},_fixIEOverlapping:function(){Position.clone(this.element,this.iefix);this.iefix.style.zIndex=this.element.style.zIndex-1;this.iefix.show()},_getWindowBorderSize:function(B){var C=this._createHiddenDiv(this.options.className+"_n");this.heightN=Element.getDimensions(C).height;C.parentNode.removeChild(C);var C=this._createHiddenDiv(this.options.className+"_s");this.heightS=Element.getDimensions(C).height;C.parentNode.removeChild(C);var C=this._createHiddenDiv(this.options.className+"_e");this.widthE=Element.getDimensions(C).width;C.parentNode.removeChild(C);var C=this._createHiddenDiv(this.options.className+"_w");this.widthW=Element.getDimensions(C).width;C.parentNode.removeChild(C);var C=document.createElement("div");C.className="overlay_"+this.options.className;document.body.appendChild(C);var A=this;setTimeout(function(){A.overlayOpacity=($(C).getStyle("opacity"));C.parentNode.removeChild(C)},10);if(Prototype.Browser.IE){this.heightS=$(this.getId()+"_row3").getDimensions().height;this.heightN=$(this.getId()+"_row1").getDimensions().height}if(Prototype.Browser.WebKit&&Prototype.Browser.WebKitVersion<420){this.setSize(this.width,this.height)}if(this.doMaximize){this.maximize()}if(this.doMinimize){this.minimize()}},_createHiddenDiv:function(B){var A=document.body;var C=document.createElement("div");C.setAttribute("id",this.element.id+"_tmp");C.className=B;C.style.display="none";C.innerHTML="";A.insertBefore(C,A.firstChild);return C},_storeLocation:function(){if(this.storedLocation==null){this.storedLocation={useTop:this.useTop,useLeft:this.useLeft,top:this.element.getStyle("top"),bottom:this.element.getStyle("bottom"),left:this.element.getStyle("left"),right:this.element.getStyle("right"),width:this.width,height:this.height}}},_restoreLocation:function(){if(this.storedLocation!=null){this.useLeft=this.storedLocation.useLeft;this.useTop=this.storedLocation.useTop;if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow){new Effect.ResizeWindow(this,this.storedLocation.top,this.storedLocation.left,this.storedLocation.width,this.storedLocation.height,{duration:Window.resizeEffectDuration})}else{this.element.setStyle(this.useLeft?{left:this.storedLocation.left}:{right:this.storedLocation.right});this.element.setStyle(this.useTop?{top:this.storedLocation.top}:{bottom:this.storedLocation.bottom});this.setSize(this.storedLocation.width,this.storedLocation.height)}Windows.resetOverflow();this._removeStoreLocation()}},_removeStoreLocation:function(){this.storedLocation=null},_saveCookie:function(){if(this.cookie){var A="";if(this.useLeft){A+="l:"+(this.storedLocation?this.storedLocation.left:this.element.getStyle("left"))}else{A+="r:"+(this.storedLocation?this.storedLocation.right:this.element.getStyle("right"))}if(this.useTop){A+=",t:"+(this.storedLocation?this.storedLocation.top:this.element.getStyle("top"))}else{A+=",b:"+(this.storedLocation?this.storedLocation.bottom:this.element.getStyle("bottom"))}A+=","+(this.storedLocation?this.storedLocation.width:this.width);A+=","+(this.storedLocation?this.storedLocation.height:this.height);A+=","+this.isMinimized();A+=","+this.isMaximized();WindowUtilities.setCookie(A,this.cookie)}},_createWiredElement:function(){if(!this.wiredElement){if(Prototype.Browser.IE){this._getWindowBorderSize()}var B=document.createElement("div");B.className="wired_frame "+this.options.className+"_wired_frame";B.style.position="absolute";this.options.parent.insertBefore(B,this.options.parent.firstChild);this.wiredElement=$(B)}if(this.useLeft){this.wiredElement.setStyle({left:this.element.getStyle("left")})}else{this.wiredElement.setStyle({right:this.element.getStyle("right")})}if(this.useTop){this.wiredElement.setStyle({top:this.element.getStyle("top")})}else{this.wiredElement.setStyle({bottom:this.element.getStyle("bottom")})}var A=this.element.getDimensions();this.wiredElement.setStyle({width:A.width+"px",height:A.height+"px"});this.wiredElement.setStyle({zIndex:Windows.maxZIndex+30});return this.wiredElement},_hideWiredElement:function(){if(!this.wiredElement||!this.currentDrag){return }if(this.currentDrag==this.element){this.currentDrag=null}else{if(this.useLeft){this.element.setStyle({left:this.currentDrag.getStyle("left")})}else{this.element.setStyle({right:this.currentDrag.getStyle("right")})}if(this.useTop){this.element.setStyle({top:this.currentDrag.getStyle("top")})}else{this.element.setStyle({bottom:this.currentDrag.getStyle("bottom")})}this.currentDrag.hide();this.currentDrag=null;if(this.doResize){this.setSize(this.width,this.height)}}},_notify:function(A){if(this.options[A]){this.options[A](this)}else{Windows.notify(A,this)}}};var Windows={windows:[],modalWindows:[],observers:[],focusedWindow:null,maxZIndex:0,overlayShowEffectOptions:{duration:0.5},overlayHideEffectOptions:{duration:0.5},addObserver:function(A){this.removeObserver(A);this.observers.push(A)},removeObserver:function(A){this.observers=this.observers.reject(function(B){return B==A})},notify:function(A,B){this.observers.each(function(C){if(C[A]){C[A](A,B)}})},getWindow:function(A){return this.windows.detect(function(B){return B.getId()==A})},getFocusedWindow:function(){return this.focusedWindow},updateFocusedWindow:function(){this.focusedWindow=this.windows.length>=2?this.windows[this.windows.length-2]:null},register:function(A){this.windows.push(A)},addModalWindow:function(A){if(this.modalWindows.length==0){WindowUtilities.disableScreen(A.options.className,"overlay_modal",A.overlayOpacity,A.getId(),A.options.parent)}else{if(Window.keepMultiModalWindow){$("overlay_modal").style.zIndex=Windows.maxZIndex+1;Windows.maxZIndex+=1;WindowUtilities._hideSelect(this.modalWindows.last().getId())}else{this.modalWindows.last().element.hide()}WindowUtilities._showSelect(A.getId())}this.modalWindows.push(A)},removeModalWindow:function(A){this.modalWindows.pop();if(this.modalWindows.length==0){WindowUtilities.enableScreen()}else{if(Window.keepMultiModalWindow){this.modalWindows.last().toFront();WindowUtilities._showSelect(this.modalWindows.last().getId())}else{this.modalWindows.last().element.show()}}},register:function(A){this.windows.push(A)},unregister:function(A){this.windows=this.windows.reject(function(B){return B==A})},closeAll:function(){this.windows.each(function(A){Windows.close(A.getId())})},closeAllModalWindows:function(){WindowUtilities.enableScreen();this.modalWindows.each(function(A){if(A){A.close()}})},minimize:function(C,A){var B=this.getWindow(C);if(B&&B.visible){B.minimize()}Event.stop(A)},maximize:function(C,A){var B=this.getWindow(C);if(B&&B.visible){B.maximize()}Event.stop(A)},close:function(C,A){var B=this.getWindow(C);if(B){B.close()}if(A){Event.stop(A)}},blur:function(B){var A=this.getWindow(B);if(!A){return }if(A.options.blurClassName){A.changeClassName(A.options.blurClassName)}if(this.focusedWindow==A){this.focusedWindow=null}A._notify("onBlur")},focus:function(B){var A=this.getWindow(B);if(!A){return }if(this.focusedWindow){this.blur(this.focusedWindow.getId())}if(A.options.focusClassName){A.changeClassName(A.options.focusClassName)}this.focusedWindow=A;A._notify("onFocus")},unsetOverflow:function(A){this.windows.each(function(B){B.oldOverflow=B.getContent().getStyle("overflow")||"auto";B.getContent().setStyle({overflow:"hidden"})});if(A&&A.oldOverflow){A.getContent().setStyle({overflow:A.oldOverflow})}},resetOverflow:function(){this.windows.each(function(A){if(A.oldOverflow){A.getContent().setStyle({overflow:A.oldOverflow})}})},updateZindex:function(A,B){if(A>this.maxZIndex){this.maxZIndex=A;if(this.focusedWindow){this.blur(this.focusedWindow.getId())}}this.focusedWindow=B;if(this.focusedWindow){this.focus(this.focusedWindow.getId())}}};var Dialog={dialogId:null,onCompleteFunc:null,callFunc:null,parameters:null,confirm:function(D,C){if(D&&typeof D!="string"){Dialog._runAjaxRequest(D,C,Dialog.confirm);return }D=D||"";C=C||{};var F=C.okLabel?C.okLabel:"Ok";var A=C.cancelLabel?C.cancelLabel:"Cancel";C=Object.extend(C,C.windowParameters||{});C.windowParameters=C.windowParameters||{};C.className=C.className||"alert";var B="class ='"+(C.buttonClass?C.buttonClass+" ":"")+" ok_button'";var E="class ='"+(C.buttonClass?C.buttonClass+" ":"")+" cancel_button'";var D="      <div class='"+C.className+"_message'>"+D+"</div>        <div class='"+C.className+"_buttons'>          <input type='button' value='"+F+"' onclick='Dialog.okCallback()' "+B+"/>          <input type='button' value='"+A+"' onclick='Dialog.cancelCallback()' "+E+"/>        </div>    ";return this._openDialog(D,C)},alert:function(C,B){if(C&&typeof C!="string"){Dialog._runAjaxRequest(C,B,Dialog.alert);return }C=C||"";B=B||{};var D=B.okLabel?B.okLabel:"Ok";B=Object.extend(B,B.windowParameters||{});B.windowParameters=B.windowParameters||{};B.className=B.className||"alert";var A="class ='"+(B.buttonClass?B.buttonClass+" ":"")+" ok_button'";var C="      <div class='"+B.className+"_message'>"+C+"</div>        <div class='"+B.className+"_buttons'>          <input type='button' value='"+D+"' onclick='Dialog.okCallback()' "+A+"/>        </div>";return this._openDialog(C,B)},info:function(B,A){if(B&&typeof B!="string"){Dialog._runAjaxRequest(B,A,Dialog.info);return }B=B||"";A=A||{};A=Object.extend(A,A.windowParameters||{});A.windowParameters=A.windowParameters||{};A.className=A.className||"alert";var B="<div id='modal_dialog_message' class='"+A.className+"_message'>"+B+"</div>";if(A.showProgress){B+="<div id='modal_dialog_progress' class='"+A.className+"_progress'>  </div>"}A.ok=null;A.cancel=null;return this._openDialog(B,A)},setInfoMessage:function(A){$("modal_dialog_message").update(A)},closeInfo:function(){Windows.close(this.dialogId)},_openDialog:function(E,D){var C=D.className;if(!D.height&&!D.width){D.width=WindowUtilities.getPageSize(D.options.parent||document.body).pageWidth/2}if(D.id){this.dialogId=D.id}else{var B=new Date();this.dialogId="modal_dialog_"+B.getTime();D.id=this.dialogId}if(!D.height||!D.width){var A=WindowUtilities._computeSize(E,this.dialogId,D.width,D.height,5,C);if(D.height){D.width=A+5}else{D.height=A+5}}D.effectOptions=D.effectOptions;D.resizable=D.resizable||false;D.minimizable=D.minimizable||false;D.maximizable=D.maximizable||false;D.draggable=D.draggable||false;D.closable=D.closable||false;var F=new Window(D);F.getContent().innerHTML=E;F.showCenter(true,D.top,D.left);F.setDestroyOnClose();F.cancelCallback=D.onCancel||D.cancel;F.okCallback=D.onOk||D.ok;return F},_getAjaxContent:function(A){Dialog.callFunc(A.responseText,Dialog.parameters)},_runAjaxRequest:function(C,B,A){if(C.options==null){C.options={}}Dialog.onCompleteFunc=C.options.onComplete;Dialog.parameters=B;Dialog.callFunc=A;C.options.onComplete=Dialog._getAjaxContent;new Ajax.Request(C.url,C.options)},okCallback:function(){var A=Windows.focusedWindow;if(!A.okCallback||A.okCallback(A)){$$("#"+A.getId()+" input").each(function(B){B.onclick=null});A.close()}},cancelCallback:function(){var A=Windows.focusedWindow;$$("#"+A.getId()+" input").each(function(B){B.onclick=null});A.close();if(A.cancelCallback){A.cancelCallback(A)}}};if(Prototype.Browser.WebKit){var array=navigator.userAgent.match(new RegExp(/AppleWebKit\/([\d\.\+]*)/));Prototype.Browser.WebKitVersion=parseFloat(array[1])}var WindowUtilities={getWindowScroll:function(parent){var T,L,W,H;parent=parent||document.body;if(parent!=document.body){T=parent.scrollTop;L=parent.scrollLeft;W=parent.scrollWidth;H=parent.scrollHeight}else{var w=window;with(w.document){if(w.document.documentElement&&documentElement.scrollTop){T=documentElement.scrollTop;L=documentElement.scrollLeft}else{if(w.document.body){T=body.scrollTop;L=body.scrollLeft}}if(w.innerWidth){W=w.innerWidth;H=w.innerHeight}else{if(w.document.documentElement&&documentElement.clientWidth){W=documentElement.clientWidth;H=documentElement.clientHeight}else{W=body.offsetWidth;H=body.offsetHeight}}}}return{top:T,left:L,width:W,height:H}},getPageSize:function(D){D=D||document.body;var C,G;var E,B;if(D!=document.body){C=D.getWidth();G=D.getHeight();B=D.scrollWidth;E=D.scrollHeight}else{var F,A;if(window.innerHeight&&window.scrollMaxY){F=document.body.scrollWidth;A=window.innerHeight+window.scrollMaxY}else{if(document.body.scrollHeight>document.body.offsetHeight){F=document.body.scrollWidth;A=document.body.scrollHeight}else{F=document.body.offsetWidth;A=document.body.offsetHeight}}if(self.innerHeight){C=self.innerWidth;G=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){C=document.documentElement.clientWidth;G=document.documentElement.clientHeight}else{if(document.body){C=document.body.clientWidth;G=document.body.clientHeight}}}if(A<G){E=G}else{E=A}if(F<C){B=C}else{B=F}}return{pageWidth:B,pageHeight:E,windowWidth:C,windowHeight:G}},disableScreen:function(C,A,D,E,B){WindowUtilities.initLightbox(A,C,function(){this._disableScreen(C,A,D,E)}.bind(this),B||document.body)},_disableScreen:function(C,B,E,F){var D=$(B);var A=WindowUtilities.getPageSize(D.parentNode);if(F&&Prototype.Browser.IE){WindowUtilities._hideSelect();WindowUtilities._showSelect(F)}D.style.height=(A.pageHeight+"px");D.style.display="none";if(B=="overlay_modal"&&Window.hasEffectLib&&Windows.overlayShowEffectOptions){D.overlayOpacity=E;new Effect.Appear(D,Object.extend({from:0,to:E},Windows.overlayShowEffectOptions))}else{D.style.display="block"}},enableScreen:function(B){B=B||"overlay_modal";var A=$(B);if(A){if(B=="overlay_modal"&&Window.hasEffectLib&&Windows.overlayHideEffectOptions){new Effect.Fade(A,Object.extend({from:A.overlayOpacity,to:0},Windows.overlayHideEffectOptions))}else{A.style.display="none";A.parentNode.removeChild(A)}if(B!="__invisible__"){WindowUtilities._showSelect()}}},_hideSelect:function(A){if(Prototype.Browser.IE){A=A==null?"":"#"+A+" ";$$(A+"select").each(function(B){if(!WindowUtilities.isDefined(B.oldVisibility)){B.oldVisibility=B.style.visibility?B.style.visibility:"visible";B.style.visibility="hidden"}})}},_showSelect:function(A){if(Prototype.Browser.IE){A=A==null?"":"#"+A+" ";$$(A+"select").each(function(B){if(WindowUtilities.isDefined(B.oldVisibility)){try{B.style.visibility=B.oldVisibility}catch(C){B.style.visibility="visible"}B.oldVisibility=null}else{if(B.style.visibility){B.style.visibility="visible"}}})}},isDefined:function(A){return typeof (A)!="undefined"&&A!=null},initLightbox:function(E,C,A,B){if($(E)){Element.setStyle(E,{zIndex:Windows.maxZIndex+1});Windows.maxZIndex++;A()}else{var D=document.createElement("div");D.setAttribute("id",E);D.className="overlay_"+C;D.style.display="none";D.style.position="absolute";D.style.top="0";D.style.left="0";D.style.zIndex=Windows.maxZIndex+1;Windows.maxZIndex++;D.style.width="100%";B.insertBefore(D,B.firstChild);if(Prototype.Browser.WebKit&&E=="overlay_modal"){setTimeout(function(){A()},10)}else{A()}}},setCookie:function(B,A){document.cookie=A[0]+"="+escape(B)+((A[1])?"; expires="+A[1].toGMTString():"")+((A[2])?"; path="+A[2]:"")+((A[3])?"; domain="+A[3]:"")+((A[4])?"; secure":"")},getCookie:function(C){var B=document.cookie;var E=C+"=";var D=B.indexOf("; "+E);if(D==-1){D=B.indexOf(E);if(D!=0){return null}}else{D+=2}var A=document.cookie.indexOf(";",D);if(A==-1){A=B.length}return unescape(B.substring(D+E.length,A))},_computeSize:function(E,A,B,G,D,F){var I=document.body;var C=document.createElement("div");C.setAttribute("id",A);C.className=F+"_content";if(G){C.style.height=G+"px"}else{C.style.width=B+"px"}C.style.position="absolute";C.style.top="0";C.style.left="0";C.style.display="none";C.innerHTML=E;I.insertBefore(C,I.firstChild);var H;if(G){H=$(C).getDimensions().width+D}else{H=$(C).getDimensions().height+D}I.removeChild(C);return H}};

