var Window=Class.create();Window.keepMultiModalWindow=false;Window.hasEffectLib=typeof Effect!="undefined";Window.resizeEffectDuration=0.4;
Window.prototype={initialize:function(){var a,b=0;arguments.length>0&&(typeof arguments[0]=="string"?(a=arguments[0],b=1):a=arguments[0]?arguments[0].id:null);a||(a="window_"+(new Date).getTime());$(a)&&alert("Window "+a+" is already registered in the DOM! Make sure you use setDestroyOnClose() or destroyOnClose: true in the constructor");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),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);this.options.destroyOnClose&&this.destroy()}.bind(this);if(this.options.parent!=document.body)this.options.parent=$(this.options.parent);this.element=this._createWindow(a);
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 c=this;[this.topbar,this.topbar.up().previous(),this.topbar.up().next()].each(function(a){a.observe("mousedown",
c.eventMouseDown);a.addClassName("top_draggable")});[this.bottombar.up(),this.bottombar.up().previous(),this.bottombar.up().next()].each(function(a){a.observe("mousedown",c.eventMouseDown);a.addClassName("bottom_draggable")})}if(this.options.resizable)this.sizer=$(this.element.id+"_sizer"),Event.observe(this.sizer,"mousedown",this.eventMouseDown);this.useTop=this.useLeft=null;typeof this.options.left!="undefined"?(this.element.setStyle({left:parseFloat(this.options.left)+"px"}),this.useLeft=true):
(this.element.setStyle({right:parseFloat(this.options.right)+"px"}),this.useLeft=false);typeof this.options.top!="undefined"?(this.element.setStyle({top:parseFloat(this.options.top)+"px"}),this.useTop=true):(this.element.setStyle({bottom:parseFloat(this.options.bottom)+"px"}),this.useTop=false);this.storedLocation=null;this.setOpacity(this.options.opacity);this.options.zIndex&&this.setZIndex(this.options.zIndex);this.options.destroyOnClose&&this.setDestroyOnClose(true);this._getWindowBorderSize();
this.width=this.options.width;this.height=this.options.height;this.constraint=this.visible=false;this.constraintPad={top:0,left:0,bottom:0,right:0};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){for(var a=this.getContent(),b=null,c=0;c<a.childNodes.length;c++){b=a.childNodes[c];if(b.nodeType==1)break;b=null}b&&this._oldParent.appendChild(b);this._oldParent=null}this.sizer&&Event.stopObserving(this.sizer,"mousedown",this.eventMouseDown);
if(this.options.url)this.content.src=null;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(a,b,c){var d=$(a);if(null==d)throw"Unable to find element '"+a+"' in DOM";this._oldParent=d.parentNode;var e=a=null;b&&(a=Element.getDimensions(d));c&&(e=Position.cumulativeOffset(d));var f=this.getContent();this.setHTMLContent("");f=this.getContent();
f.appendChild(d);d.show();b&&this.setSize(a.width,a.height);c&&this.setLocation(e[1]-this.heightN,e[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(a,b,c,d){this.showFunction=c?"showCenter":"show";this.showModal=
d||false;b=b||{};this.setHTMLContent("");this.onComplete=b.onComplete;if(!this._onCompleteHandler)this._onCompleteHandler=this._setAjaxContent.bind(this);b.onComplete=this._onCompleteHandler;new Ajax.Request(a,b);b.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;a=
"<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=a;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(a,b,c,d,e){a=a||this.element.id;this.cookie=[a,b,c,d,e];if(a=
WindowUtilities.getCookie(a)){var f=a.split(","),a=f[0].split(":"),b=f[1].split(":"),c=parseFloat(f[2]),d=parseFloat(f[3]),e=f[4],f=f[5];this.setSize(c,d);if(e=="true")this.doMinimize=true;else if(f=="true")this.doMaximize=true;this.useLeft=a[0]=="l";this.useTop=b[0]=="t";this.element.setStyle(this.useLeft?{left:a[1]}:{right:a[1]});this.element.setStyle(this.useTop?{top:b[1]}:{bottom:b[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||{});this.useTop&&this.useLeft&&this.setLocation(parseFloat(this.element.style.top),parseFloat(this.element.style.left))},_initDrag:function(a){if(!(Event.element(a)==this.sizer&&this.isMinimized())&&!(Event.element(a)!=this.sizer&&this.isMaximized())){Prototype.Browser.IE&&this.heightN==0&&this._getWindowBorderSize();this.pointer=[this._round(Event.pointerX(a),this.options.gridX),this._round(Event.pointerY(a),this.options.gridY)];
this.currentDrag=this.options.wiredDrag?this._createWiredElement():this.element;if(Event.element(a)==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 b=$(this.getId()+"_close");if(b&&Position.within(b,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(a)}},_round:function(a,b){return b==1?a:Math.floor(a/b)*b},_updateDrag:function(a){var b=[this._round(Event.pointerX(a),this.options.gridX),
this._round(Event.pointerY(a),this.options.gridY)],c=b[0]-this.pointer[0],d=b[1]-this.pointer[1];if(this.doResize){var b=this.widthOrg+c,e=this.heightOrg+d,c=this.width-this.widthOrg,d=this.height-this.heightOrg;this.useLeft?b=this._updateWidthConstraint(b):this.currentDrag.setStyle({right:this.rightOrg-c+"px"});this.useTop?e=this._updateHeightConstraint(e):this.currentDrag.setStyle({bottom:this.bottomOrg-d+"px"});this.setSize(b,e);this._notify("onResize")}else this.pointer=b,this.useLeft?(c=parseFloat(this.currentDrag.getStyle("left"))+
c,b=this._updateLeftConstraint(c),this.pointer[0]+=b-c,this.currentDrag.setStyle({left:b+"px"})):this.currentDrag.setStyle({right:parseFloat(this.currentDrag.getStyle("right"))-c+"px"}),this.useTop?(d=parseFloat(this.currentDrag.getStyle("top"))+d,c=this._updateTopConstraint(d),this.pointer[1]+=c-d,this.currentDrag.setStyle({top:c+"px"})):this.currentDrag.setStyle({bottom:parseFloat(this.currentDrag.getStyle("bottom"))-d+"px"}),this._notify("onMove");this.iefix&&this._fixIEOverlapping();this._removeStoreLocation();
Event.stop(a)},_endDrag:function(a){WindowUtilities.enableScreen("__invisible__");this.doResize?this._notify("onEndResize"):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(a){if(this.constraint&&this.useLeft&&this.useTop){var b=this.options.parent==
document.body?WindowUtilities.getPageSize().windowWidth:this.options.parent.getDimensions().width;if(a<this.constraintPad.left)a=this.constraintPad.left;a+this.width+this.widthE+this.widthW>b-this.constraintPad.right&&(a=b-this.constraintPad.right-this.width-this.widthE-this.widthW)}return a},_updateTopConstraint:function(a){if(this.constraint&&this.useLeft&&this.useTop){var b=this.options.parent==document.body?WindowUtilities.getPageSize().windowHeight:this.options.parent.getDimensions().height,
c=this.height+this.heightN+this.heightS;if(a<this.constraintPad.top)a=this.constraintPad.top;a+c>b-this.constraintPad.bottom&&(a=b-this.constraintPad.bottom-c)}return a},_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,c=parseFloat(this.element.getStyle("left"));c+a+this.widthE+this.widthW>b-this.constraintPad.right&&(a=b-this.constraintPad.right-
c-this.widthE-this.widthW)}return a},_updateHeightConstraint:function(a){if(this.constraint&&this.useLeft&&this.useTop){var b=this.options.parent==document.body?WindowUtilities.getPageSize().windowHeight:this.options.parent.getDimensions().height,c=parseFloat(this.element.getStyle("top"));c+a+this.heightN+this.heightS>b-this.constraintPad.bottom&&(a=b-this.constraintPad.bottom-c-this.heightN-this.heightS)}return a},_createWindow:function(a){var b=this.options.className,c=document.createElement("div");
c.setAttribute("id",a);c.className="dialog";c.innerHTML=(this.options.closable?"<div class='"+b+"_close' id='"+a+"_close' onclick='Windows.close(\""+a+"\", event)'> </div>":"")+(this.options.minimizable?"<div class='"+b+"_minimize' id='"+a+"_minimize' onclick='Windows.minimize(\""+a+"\", event)'> </div>":"")+(this.options.maximizable?"<div class='"+b+"_maximize' id='"+a+"_maximize' onclick='Windows.maximize(\""+a+"\", event)'> </div>":"")+"<table id='"+a+"_row1' class=\"top table_window\"><tr><td class='"+
b+"_nw'></td><td class='"+b+"_n'><div id='"+a+"_top' class='"+b+"_title title_window'>"+this.options.title+"</div></td><td class='"+b+"_ne'></td></tr></table><table id='"+a+"_row2' class=\"mid table_window\"><tr><td class='"+b+"_w'></td><td id='"+a+"_table_content' class='"+b+"_content' valign='top'>"+(this.options.url?'<iframe frameborder="0" name="'+a+'_content"  id="'+a+'_content" src="'+this.options.url+'"> </iframe>':'<div id="'+a+'_content" class="'+b+'_content"> </div>')+"</td><td class='"+
b+"_e'></td></tr></table><table id='"+a+"_row3' class=\"bot table_window\"><tr><td class='"+b+"_sw'></td><td class='"+b+"_s'><div id='"+a+"_bottom' class='status_bar'><span style='float:left; width:1px; height:1px'></span></div></td><td "+(this.options.resizable?"class='"+b+"_sizer' id='"+a+"_sizer'":"class='"+b+"_se'")+"></td></tr></table>";Element.hide(c);this.options.parent.insertBefore(c,this.options.parent.firstChild);Event.observe($(a+"_content"),"load",this.options.onload);return c},changeClassName:function(a){var b=
this.options.className,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(c){c.className=c.className.sub(b,a)});this.options.className=a},_toggleClassName:function(a,b,c){a&&(a.removeClassName(b),a.addClassName(c))},setLocation:function(a,b){var a=this._updateTopConstraint(a),b=this._updateLeftConstraint(b),c=this.currentDrag||
this.element;c.setStyle({top:a+"px"});c.setStyle({left:b+"px"});this.useTop=this.useLeft=true},getLocation:function(){var a={},a=this.useTop?Object.extend(a,{top:this.element.getStyle("top")}):Object.extend(a,{bottom:this.element.getStyle("bottom")});return a=this.useLeft?Object.extend(a,{left:this.element.getStyle("left")}):Object.extend(a,{right:this.element.getStyle("right")})},getSize:function(){return{width:this.width,height:this.height}},setSize:function(a,b,c){a=parseFloat(a);b=parseFloat(b);
if(!this.minimized&&a<this.options.minWidth)a=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&&a>this.options.maxWidth)a=this.options.maxWidth;if(this.useTop&&this.useLeft&&Window.hasEffectLib&&Effect.ResizeWindow&&c)new Effect.ResizeWindow(this,null,null,a,b,{duration:Window.resizeEffectDuration});else if(this.width=a,this.height=b,c=this.currentDrag?this.currentDrag:
this.element,c.setStyle({width:a+this.widthW+this.widthE+"px"}),c.setStyle({height:b+this.heightN+this.heightS+"px"}),!this.currentDrag||this.currentDrag==this.element)c=$(this.element.id+"_content"),c.setStyle({height:b+"px"}),c.setStyle({width:a+"px"})},updateHeight:function(){this.setSize(this.width,this.content.scrollHeight,true)},updateWidth:function(){this.setSize(this.content.scrollWidth,this.height,true)},toFront:function(){this.element.style.zIndex<Windows.maxZIndex&&this.setZIndex(Windows.maxZIndex+
1);this.iefix&&this._fixIEOverlapping()},getBounds:function(a){(!this.width||!this.height||!this.visible)&&this.computeBounds();var b=this.width,c=this.height;a||(b+=this.widthW+this.widthE,c+=this.heightN+this.heightS);return Object.extend(this.getLocation(),{width:b+"px",height:c+"px"})},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);this.height?this.width=a+5:this.height=
a+5}this.setSize(this.width,this.height);this.centered&&this._center(this.centerTop,this.centerLeft)},show:function(a){this.visible=true;if(a){if(typeof this.overlayOpacity=="undefined"){var b=this;setTimeout(function(){b.show(a)},10);return}Windows.addModalWindow(this);this.modal=true;this.setZIndex(Windows.maxZIndex+1);Windows.unsetOverflow(this)}else this.element.style.zIndex||this.setZIndex(Windows.maxZIndex+1);this.oldStyle&&this.getContent().setStyle({overflow:this.oldStyle});this.computeBounds();
this._notify("onBeforeShow");this.options.showEffect!=Element.show&&this.options.showEffectOptions?this.options.showEffect(this.element,this.options.showEffectOptions):this.options.showEffect(this.element);this._checkIEOverlapping();WindowUtilities.focusedWindow=this;this._notify("onShow")},showCenter:function(a,b,c){this.centered=true;this.centerTop=b;this.centerLeft=c;this.show(a)},isVisible:function(){return this.visible},_center:function(a,b){var c=WindowUtilities.getWindowScroll(this.options.parent),
d=WindowUtilities.getPageSize(this.options.parent);typeof a=="undefined"&&(a=(d.windowHeight-(this.height+this.heightN+this.heightS))/2);a+=c.top;typeof b=="undefined"&&(b=(d.windowWidth-(this.width+this.widthW+this.widthE))/2);b+=c.left;this.setLocation(a,b);this.toFront()},_recenter:function(){if(this.centered){var a=WindowUtilities.getPageSize(this.options.parent),b=WindowUtilities.getWindowScroll(this.options.parent);if(!this.pageSize||!(this.pageSize.windowWidth==a.windowWidth&&this.pageSize.windowHeight==
a.windowHeight&&this.windowScroll.left==b.left&&this.windowScroll.top==b.top))this.pageSize=a,this.windowScroll=b,$("overlay_modal")&&$("overlay_modal").setStyle({height:a.pageHeight+"px"}),this.options.recenterAuto&&this._center(this.centerTop,this.centerLeft)}},hide:function(){this.visible=false;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);this.iefix&&this.iefix.hide();this.doNotNotifyHide||this._notify("onHide")},close:function(){if(this.visible&&(!this.options.closeCallback||this.options.closeCallback(this))){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){var a=$(this.getId()+"_row2");if(this.minimized)this.minimized=false,b=this.r2Height,this.r2Height=null,this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow?new Effect.ResizeWindow(this,null,null,null,this.height+b,{duration:Window.resizeEffectDuration}):(c=this.element.getHeight()+b,this.height+=b,this.element.setStyle({height:c+"px"}),a.show()),this.useTop||
(a=parseFloat(this.element.getStyle("bottom")),this.element.setStyle({bottom:a-b+"px"})),this.toFront();else{this.minimized=true;var b=a.getDimensions().height;this.r2Height=b;var c=this.element.getHeight()-b;this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow?new Effect.ResizeWindow(this,null,null,null,this.height-b,{duration:Window.resizeEffectDuration}):(this.height-=b,this.element.setStyle({height:c+"px"}),a.hide());this.useTop||(a=parseFloat(this.element.getStyle("bottom")),this.element.setStyle({bottom:a+
b+"px"}))}this._notify("onMinimize");this._saveCookie()}},maximize:function(){if(!this.isMinimized()&&!this.resizing){Prototype.Browser.IE&&this.heightN==0&&this._getWindowBorderSize();if(this.storedLocation!=null)this._restoreLocation(),this.iefix&&this.iefix.hide();else{this._storeLocation();Windows.unsetOverflow(this);var a=WindowUtilities.getWindowScroll(this.options.parent),b=WindowUtilities.getPageSize(this.options.parent),c=a.left,a=a.top;if(this.options.parent!=document.body)c=this.options.parent.getDimensions(),
b.windowWidth=c.width,b.windowHeight=c.height,c=a=0;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),c+=Math.max(0,this.constraintPad.left),a+=Math.max(0,this.constraintPad.top));var d=b.windowWidth-this.widthW-this.widthE,b=b.windowHeight-this.heightN-this.heightS;this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow?new Effect.ResizeWindow(this,
a,c,d,b,{duration:Window.resizeEffectDuration}):(this.setSize(d,b),this.element.setStyle(this.useLeft?{left:c}:{right:c}),this.element.setStyle(this.useTop?{top:a}:{bottom:a}));this.toFront();this.iefix&&this._fixIEOverlapping()}this._notify("onMaximize");this._saveCookie()}},isMinimized:function(){return this.minimized},isMaximized:function(){return this.storedLocation!=null},setOpacity:function(a){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(a){$(this.getId()+"_bottom");typeof a=="object"?this.bottombar.firstChild?this.bottombar.replaceChild(a,this.bottombar.firstChild):this.bottombar.appendChild(a):this.bottombar.innerHTML=a},_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");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(){var a=this._createHiddenDiv(this.options.className+"_n");this.heightN=Element.getDimensions(a).height;a.parentNode.removeChild(a);a=this._createHiddenDiv(this.options.className+"_s");this.heightS=Element.getDimensions(a).height;a.parentNode.removeChild(a);a=this._createHiddenDiv(this.options.className+"_e");this.widthE=Element.getDimensions(a).width;a.parentNode.removeChild(a);a=this._createHiddenDiv(this.options.className+"_w");this.widthW=Element.getDimensions(a).width;
a.parentNode.removeChild(a);a=document.createElement("div");a.className="overlay_"+this.options.className;document.body.appendChild(a);var b=this;setTimeout(function(){b.overlayOpacity=$(a).getStyle("opacity");a.parentNode.removeChild(a)},10);if(Prototype.Browser.IE)this.heightS=$(this.getId()+"_row3").getDimensions().height,this.heightN=$(this.getId()+"_row1").getDimensions().height;Prototype.Browser.WebKit&&Prototype.Browser.WebKitVersion<420&&this.setSize(this.width,this.height);this.doMaximize&&
this.maximize();this.doMinimize&&this.minimize()},_createHiddenDiv:function(a){var b=document.body,c=document.createElement("div");c.setAttribute("id",this.element.id+"_tmp");c.className=a;c.style.display="none";c.innerHTML="";b.insertBefore(c,b.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,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}):(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="";a+=this.useLeft?"l:"+(this.storedLocation?this.storedLocation.left:this.element.getStyle("left")):"r:"+(this.storedLocation?this.storedLocation.right:this.element.getStyle("right"));
a+=this.useTop?",t:"+(this.storedLocation?this.storedLocation.top:this.element.getStyle("top")):",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){Prototype.Browser.IE&&this._getWindowBorderSize();
var a=document.createElement("div");a.className="wired_frame "+this.options.className+"_wired_frame";a.style.position="absolute";this.options.parent.insertBefore(a,this.options.parent.firstChild);this.wiredElement=$(a)}this.useLeft?this.wiredElement.setStyle({left:this.element.getStyle("left")}):this.wiredElement.setStyle({right:this.element.getStyle("right")});this.useTop?this.wiredElement.setStyle({top:this.element.getStyle("top")}):this.wiredElement.setStyle({bottom:this.element.getStyle("bottom")});
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)this.currentDrag==this.element?this.currentDrag=null:(this.useLeft?this.element.setStyle({left:this.currentDrag.getStyle("left")}):this.element.setStyle({right:this.currentDrag.getStyle("right")}),this.useTop?this.element.setStyle({top:this.currentDrag.getStyle("top")}):
this.element.setStyle({bottom:this.currentDrag.getStyle("bottom")}),this.currentDrag.hide(),this.currentDrag=null,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){this.modalWindows.length==0?WindowUtilities.disableScreen(a.options.className,"overlay_modal",a.overlayOpacity,a.getId(),a.options.parent):(Window.keepMultiModalWindow?($("overlay_modal").style.zIndex=Windows.maxZIndex+1,Windows.maxZIndex+=1,WindowUtilities._hideSelect(this.modalWindows.last().getId())):this.modalWindows.last().element.hide(),
WindowUtilities._showSelect(a.getId()));this.modalWindows.push(a)},removeModalWindow:function(){this.modalWindows.pop();this.modalWindows.length==0?WindowUtilities.enableScreen():Window.keepMultiModalWindow?(this.modalWindows.last().toFront(),WindowUtilities._showSelect(this.modalWindows.last().getId())):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){a&&a.close()})},minimize:function(a,b){var c=this.getWindow(a);c&&c.visible&&c.minimize();Event.stop(b)},maximize:function(a,b){var c=this.getWindow(a);c&&c.visible&&c.maximize();Event.stop(b)},close:function(a,b){var c=this.getWindow(a);c&&c.close();b&&Event.stop(b)},blur:function(a){if(a=this.getWindow(a)){a.options.blurClassName&&a.changeClassName(a.options.blurClassName);if(this.focusedWindow==a)this.focusedWindow=
null;a._notify("onBlur")}},focus:function(a){if(a=this.getWindow(a))this.focusedWindow&&this.blur(this.focusedWindow.getId()),a.options.focusClassName&&a.changeClassName(a.options.focusClassName),this.focusedWindow=a,a._notify("onFocus")},unsetOverflow:function(a){this.windows.each(function(a){a.oldOverflow=a.getContent().getStyle("overflow")||"auto";a.getContent().setStyle({overflow:"hidden"})});a&&a.oldOverflow&&a.getContent().setStyle({overflow:a.oldOverflow})},resetOverflow:function(){this.windows.each(function(a){a.oldOverflow&&
a.getContent().setStyle({overflow:a.oldOverflow})})},updateZindex:function(a,b){if(a>this.maxZIndex)this.maxZIndex=a,this.focusedWindow&&this.blur(this.focusedWindow.getId());(this.focusedWindow=b)&&this.focus(this.focusedWindow.getId())}},Dialog={dialogId:null,onCompleteFunc:null,callFunc:null,parameters:null,confirm:function(a,b){if(a&&typeof a!="string")Dialog._runAjaxRequest(a,b,Dialog.confirm);else{var a=a||"",b=b||{},c=b.okLabel?b.okLabel:"Ok",d=b.cancelLabel?b.cancelLabel:"Cancel",b=Object.extend(b,
b.windowParameters||{});b.windowParameters=b.windowParameters||{};b.className=b.className||"alert";a="<div class='"+b.className+"_message'>"+a+"</div><div class='"+b.className+"_buttons'><input type='button' value='"+c+"' onclick='Dialog.okCallback()' "+("class ='"+(b.buttonClass?b.buttonClass+" ":"")+" ok_button'")+"/><input type='button' value='"+d+"' onclick='Dialog.cancelCallback()' "+("class ='"+(b.buttonClass?b.buttonClass+" ":"")+" cancel_button'")+"/></div>";return this._openDialog(a,b)}},
alert:function(a,b){if(a&&typeof a!="string")Dialog._runAjaxRequest(a,b,Dialog.alert);else return a=a||"",b=b||{},b=Object.extend(b,b.windowParameters||{}),b.windowParameters=b.windowParameters||{},b.className=b.className||"alert",a="<div class='"+b.className+"_message'>"+a+"</div>",this._openDialog(a,b)},info:function(a,b){if(a&&typeof a!="string")Dialog._runAjaxRequest(a,b,Dialog.info);else return a=a||"",b=b||{},b=Object.extend(b,b.windowParameters||{}),b.windowParameters=b.windowParameters||{},
b.className=b.className||"alert",a="<div id='modal_dialog_message' class='"+b.className+"_message'>"+a+"</div>",b.showProgress&&(a+="<div id='modal_dialog_progress' class='"+b.className+"_progress'>  </div>"),b.ok=null,b.cancel=null,this._openDialog(a,b)},setInfoMessage:function(a){$("modal_dialog_message").update(a)},closeInfo:function(){Windows.close(this.dialogId)},_openDialog:function(a,b){var c=b.className;if(!b.height&&!b.width)b.width=WindowUtilities.getPageSize(b.options.parent||document.body).pageWidth/
2;b.id?this.dialogId=b.id:(this.dialogId="modal_dialog_"+(new Date).getTime(),b.id=this.dialogId);if(!b.height||!b.width)c=WindowUtilities._computeSize(a,this.dialogId,b.width,b.height,5,c),b.height?b.width=c+5:b.height=c+5;b.effectOptions=b.effectOptions;b.resizable=b.resizable||false;b.minimizable=b.minimizable||false;b.maximizable=b.maximizable||false;b.draggable=b.draggable||false;b.closable=b.closable||false;c=new Window(b);c.getContent().innerHTML=a;c.showCenter(true,b.top,b.left);c.setDestroyOnClose();
c.cancelCallback=b.onCancel||b.cancel;c.okCallback=b.onOk||b.ok;return c},_getAjaxContent:function(a){Dialog.callFunc(a.responseText,Dialog.parameters)},_runAjaxRequest:function(a,b,c){if(a.options==null)a.options={};Dialog.onCompleteFunc=a.options.onComplete;Dialog.parameters=b;Dialog.callFunc=c;a.options.onComplete=Dialog._getAjaxContent;new Ajax.Request(a.url,a.options)},okCallback:function(){var a=Windows.focusedWindow;if(!a.okCallback||a.okCallback(a))$$("#"+a.getId()+" input").each(function(a){a.onclick=
null}),a.close()},cancelCallback:function(){var a=Windows.focusedWindow;$$("#"+a.getId()+" input").each(function(a){a.onclick=null});a.close();a.cancelCallback&&a.cancelCallback(a)}};if(Prototype.Browser.WebKit){var array=navigator.userAgent.match(RegExp(/AppleWebKit\/([\d\.\+]*)/));Prototype.Browser.WebKitVersion=parseFloat(array[1])}
var WindowUtilities={getWindowScroll:function(a){var b,c,d,a=a||document.body;if(a!=document.body)b=a.scrollTop,c=a.scrollLeft,d=a.scrollWidth,a=a.scrollHeight;else{a=window;with(a.document){if(a.document.documentElement&&documentElement.scrollTop)b=documentElement.scrollTop,c=documentElement.scrollLeft;else if(a.document.body)b=body.scrollTop,c=body.scrollLeft;a.innerWidth?(d=a.innerWidth,a=a.innerHeight):a.document.documentElement&&documentElement.clientWidth?(d=documentElement.clientWidth,a=documentElement.clientHeight):
(d=body.offsetWidth,a=body.offsetHeight)}}return{top:b,left:c,width:d,height:a}},getPageSize:function(a){var a=a||document.body,b,c,d;if(a!=document.body)b=a.getWidth(),c=a.getHeight(),d=a.scrollWidth,a=a.scrollHeight;else{window.innerHeight&&window.scrollMaxY?(d=document.body.scrollWidth,a=window.innerHeight+window.scrollMaxY):document.body.scrollHeight>document.body.offsetHeight?(d=document.body.scrollWidth,a=document.body.scrollHeight):(d=document.body.offsetWidth,a=document.body.offsetHeight);
if(self.innerHeight)b=self.innerWidth,c=self.innerHeight;else if(document.documentElement&&document.documentElement.clientHeight)b=document.documentElement.clientWidth,c=document.documentElement.clientHeight;else if(document.body)b=document.body.clientWidth,c=document.body.clientHeight;a=a<c?c:a;d=d<b?b:d}return{pageWidth:d,pageHeight:a,windowWidth:b,windowHeight:c}},disableScreen:function(a,b,c,d,e){WindowUtilities.initLightbox(b,a,function(){this._disableScreen(a,b,c,d)}.bind(this),e||document.body)},
_disableScreen:function(a,b,c,d){var a=$(b),e=WindowUtilities.getPageSize(a.parentNode);d&&Prototype.Browser.IE&&(WindowUtilities._hideSelect(),WindowUtilities._showSelect(d));a.style.height=e.pageHeight+"px";a.style.display="none";b=="overlay_modal"&&Window.hasEffectLib&&Windows.overlayShowEffectOptions?(a.overlayOpacity=c,new Effect.Appear(a,Object.extend({from:0,to:c},Windows.overlayShowEffectOptions))):a.style.display="block"},enableScreen:function(a){var a=a||"overlay_modal",b=$(a);if(b)a=="overlay_modal"&&
Window.hasEffectLib&&Windows.overlayHideEffectOptions?new Effect.Fade(b,Object.extend({from:b.overlayOpacity,to:0},Windows.overlayHideEffectOptions)):(b.style.display="none",b.parentNode.removeChild(b)),a!="__invisible__"&&WindowUtilities._showSelect()},_hideSelect:function(a){Prototype.Browser.IE&&$$((a==null?"":"#"+a+" ")+"select").each(function(a){if(!WindowUtilities.isDefined(a.oldVisibility))a.oldVisibility=a.style.visibility?a.style.visibility:"visible",a.style.visibility="hidden"})},_showSelect:function(a){Prototype.Browser.IE&&
$$((a==null?"":"#"+a+" ")+"select").each(function(a){if(WindowUtilities.isDefined(a.oldVisibility)){try{a.style.visibility=a.oldVisibility}catch(c){a.style.visibility="visible"}a.oldVisibility=null}else if(a.style.visibility)a.style.visibility="visible"})},isDefined:function(a){return typeof a!="undefined"&&a!=null},initLightbox:function(a,b,c,d){if($(a))Element.setStyle(a,{zIndex:Windows.maxZIndex+1}),Windows.maxZIndex++,c();else{var e=document.createElement("div");e.setAttribute("id",a);e.className=
"overlay_"+b;e.style.display="none";e.style.position="absolute";e.style.top="0";e.style.left="0";e.style.zIndex=Windows.maxZIndex+1;Windows.maxZIndex++;e.style.width="100%";d.insertBefore(e,d.firstChild);Prototype.Browser.WebKit&&a=="overlay_modal"?setTimeout(function(){c()},10):c()}},setCookie:function(a,b){document.cookie=b[0]+"="+escape(a)+(b[1]?"; expires="+b[1].toGMTString():"")+(b[2]?"; path="+b[2]:"")+(b[3]?"; domain="+b[3]:"")+(b[4]?"; secure":"")},getCookie:function(a){var b=document.cookie;
a+="=";var c=b.indexOf("; "+a);if(c==-1){if(c=b.indexOf(a),c!=0)return null}else c+=2;var d=document.cookie.indexOf(";",c);if(d==-1)d=b.length;return unescape(b.substring(c+a.length,d))},_computeSize:function(a,b,c,d,e,f){var h=document.body,g=document.createElement("div");g.setAttribute("id",b);g.className=f+"_content";d?g.style.height=d+"px":g.style.width=c+"px";g.style.position="absolute";g.style.top="0";g.style.left="0";g.style.display="none";g.innerHTML=a;h.insertBefore(g,h.firstChild);a=d?$(g).getDimensions().width+
e:$(g).getDimensions().height+e;h.removeChild(g);return a}};
