var Window=Class.create();Window.keepMultiModalWindow=false;Window.hasEffectLib=(typeof Effect!='undefined');Window.resizeEffectDuration=0.4;Window.prototype={initialize:function(){var id;var optionIndex=0;if(arguments.length>0){if(typeof arguments[0]=="string"){id=arguments[0];optionIndex=1;} else id=arguments[0]?arguments[0].id:null;} if(!id) id="window_"+new Date().getTime();if($(id)) alert("Window "+id+" 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:" ",url:null,onload:Prototype.emptyFunction,width:200,height:300,opacity:1,recenterAuto:true,wiredDrag:false,closeCallback:null,destroyOnClose:false,gridX:1,gridY:1},arguments[optionIndex]||{});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(id);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 that=this;[this.topbar,this.topbar.up().previous(),this.topbar.up().next()].each(function(element){element.observe("mousedown",that.eventMouseDown);element.addClassName("top_draggable");});[this.bottombar.up(),this.bottombar.up().previous(),this.bottombar.up().next()].each(function(element){element.observe("mousedown",that.eventMouseDown);element.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 content=this.getContent();var originalContent=null;for(var i=0;i ";$(this.getId()+"_table_content").innerHTML=content;this.content=$(this.element.id+"_content");} this.getContent().innerHTML=html;},setAjaxContent:function(url,options,showCentered,showModal){this.showFunction=showCentered?"showCenter":"show";this.showModal=showModal||false;options=options||{};this.setHTMLContent("");this.onComplete=options.onComplete;if(!this._onCompleteHandler) this._onCompleteHandler=this._setAjaxContent.bind(this);options.onComplete=this._onCompleteHandler;new Ajax.Request(url,options);options.onComplete=this.onComplete;},_setAjaxContent:function(originalRequest){Element.update(this.getContent(),originalRequest.responseText);if(this.onComplete) this.onComplete(originalRequest);this.onComplete=null;this[this.showFunction](this.showModal)},setURL:function(url){if(this.options.url) this.content.src=null;this.options.url=url;var content="";$(this.getId()+"_table_content").innerHTML=content;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(name,expires,path,domain,secure){name=name||this.element.id;this.cookie=[name,expires,path,domain,secure];var value=WindowUtilities.getCookie(name) if(value){var values=value.split(',');var x=values[0].split(':');var y=values[1].split(':');var w=parseFloat(values[2]),h=parseFloat(values[3]);var mini=values[4];var maxi=values[5];this.setSize(w,h);if(mini=="true") this.doMinimize=true;else if(maxi=="true") this.doMaximize=true;this.useLeft=x[0]=="l";this.useTop=y[0]=="t";this.element.setStyle(this.useLeft?{left:x[1]}:{right:x[1]});this.element.setStyle(this.useTop?{top:y[1]}:{bottom:y[1]});}},getId:function(){return this.element.id;},setDestroyOnClose:function(){this.options.destroyOnClose=true;},setConstraint:function(bool,padding){this.constraint=bool;this.constraintPad=Object.extend(this.constraintPad,padding||{});if(this.useTop&&this.useLeft) this.setLocation(parseFloat(this.element.style.top),parseFloat(this.element.style.left));},_initDrag:function(event){if(Event.element(event)==this.sizer&&this.isMinimized()) return;if(Event.element(event)!=this.sizer&&this.isMaximized()) return;if(Prototype.Browser.IE&&this.heightN==0) this._getWindowBorderSize();this.pointer=[this._round(Event.pointerX(event),this.options.gridX),this._round(Event.pointerY(event),this.options.gridY)];if(this.options.wiredDrag) this.currentDrag=this._createWiredElement();else this.currentDrag=this.element;if(Event.element(event)==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 closeButton=$(this.getId()+'_close');if(closeButton&&Position.within(closeButton,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(event);},_round:function(val,round){return round==1?val:val=Math.floor(val/round)*round;},_updateDrag:function(event){var pointer=[this._round(Event.pointerX(event),this.options.gridX),this._round(Event.pointerY(event),this.options.gridY)];var dx=pointer[0]-this.pointer[0];var dy=pointer[1]-this.pointer[1];if(this.doResize){var w=this.widthOrg+dx;var h=this.heightOrg+dy;dx=this.width-this.widthOrg dy=this.height-this.heightOrg if(this.useLeft) w=this._updateWidthConstraint(w) else this.currentDrag.setStyle({right:(this.rightOrg-dx)+'px'});if(this.useTop) h=this._updateHeightConstraint(h) else this.currentDrag.setStyle({bottom:(this.bottomOrg-dy)+'px'});this.setSize(w,h);this._notify("onResize");} else{this.pointer=pointer;if(this.useLeft){var left=parseFloat(this.currentDrag.getStyle('left'))+dx;var newLeft=this._updateLeftConstraint(left);this.pointer[0]+=newLeft-left;this.currentDrag.setStyle({left:newLeft+'px'});} else this.currentDrag.setStyle({right:parseFloat(this.currentDrag.getStyle('right'))-dx+'px'});if(this.useTop){var top=parseFloat(this.currentDrag.getStyle('top'))+dy;var newTop=this._updateTopConstraint(top);this.pointer[1]+=newTop-top;this.currentDrag.setStyle({top:newTop+'px'});} else this.currentDrag.setStyle({bottom:parseFloat(this.currentDrag.getStyle('bottom'))-dy+'px'});this._notify("onMove");} if(this.iefix) this._fixIEOverlapping();this._removeStoreLocation();Event.stop(event);},_endDrag:function(event){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(event);this._hideWiredElement();this._saveCookie() document.body.ondrag=null;document.body.onselectstart=null;},_updateLeftConstraint:function(left){if(this.constraint&&this.useLeft&&this.useTop){var width=this.options.parent==document.body?WindowUtilities.getPageSize().windowWidth:this.options.parent.getDimensions().width;if(leftwidth-this.constraintPad.right) left=width-this.constraintPad.right-this.width-this.widthE-this.widthW;} return left;},_updateTopConstraint:function(top){if(this.constraint&&this.useLeft&&this.useTop){var height=this.options.parent==document.body?WindowUtilities.getPageSize().windowHeight:this.options.parent.getDimensions().height;var h=this.height+this.heightN+this.heightS;if(topheight-this.constraintPad.bottom) top=height-this.constraintPad.bottom-h;} return top;},_updateWidthConstraint:function(w){if(this.constraint&&this.useLeft&&this.useTop){var width=this.options.parent==document.body?WindowUtilities.getPageSize().windowWidth:this.options.parent.getDimensions().width;var left=parseFloat(this.element.getStyle("left"));if(left+w+this.widthE+this.widthW>width-this.constraintPad.right) w=width-this.constraintPad.right-left-this.widthE-this.widthW;} return w;},_updateHeightConstraint:function(h){if(this.constraint&&this.useLeft&&this.useTop){var height=this.options.parent==document.body?WindowUtilities.getPageSize().windowHeight:this.options.parent.getDimensions().height;var top=parseFloat(this.element.getStyle("top"));if(top+h+this.heightN+this.heightS>height-this.constraintPad.bottom) h=height-this.constraintPad.bottom-top-this.heightN-this.heightS;} return h;},_createWindow:function(id){var className=this.options.className;var win=document.createElement("div");win.setAttribute('id',id);win.className="dialog";var content;if(this.options.url) content="";else content="
";var closeDiv=this.options.closable?"
":"";var minDiv=this.options.minimizable?"
":"";var maxDiv=this.options.maximizable?"
":"";var seAttributes=this.options.resizable?"class='"+className+"_sizer' id='"+id+"_sizer'":"class='"+className+"_se'";var blank="../themes/default/blank.gif";win.innerHTML=closeDiv+minDiv+maxDiv+"\ \ \ \ \ \ \
"+this.options.title+"
\ \ \ \ \ \ \
"+content+"
\ \ \ \ \ \ \
\ ";Element.hide(win);this.options.parent.insertBefore(win,this.options.parent.firstChild);Event.observe($(id+"_content"),"load",this.options.onload);return win;},changeClassName:function(newClassName){var className=this.options.className;var id=this.getId();$A(["_close","_minimize","_maximize","_sizer","_content"]).each(function(value){this._toggleClassName($(id+value),className+value,newClassName+value)}.bind(this));this._toggleClassName($(id+"_top"),className+"_title",newClassName+"_title");$$("#"+id+" td").each(function(td){td.className=td.className.sub(className,newClassName);});this.options.className=newClassName;},_toggleClassName:function(element,oldClassName,newClassName){if(element){element.removeClassName(oldClassName);element.addClassName(newClassName);}},setLocation:function(top,left){top=this._updateTopConstraint(top);left=this._updateLeftConstraint(left);var e=this.currentDrag||this.element;e.setStyle({top:top+'px'});e.setStyle({left:left+'px'});this.useLeft=true;this.useTop=true;},getLocation:function(){var location={};if(this.useTop) location=Object.extend(location,{top:this.element.getStyle("top")});else location=Object.extend(location,{bottom:this.element.getStyle("bottom")});if(this.useLeft) location=Object.extend(location,{left:this.element.getStyle("left")});else location=Object.extend(location,{right:this.element.getStyle("right")});return location;},getSize:function(){return{width:this.width,height:this.height};},setSize:function(width,height,useEffect){width=parseFloat(width);height=parseFloat(height);if(!this.minimized&&widththis.options.maxHeight) height=this.options.maxHeight;if(this.options.maxWidth&&width>this.options.maxWidth) width=this.options.maxWidth;if(this.useTop&&this.useLeft&&Window.hasEffectLib&&Effect.ResizeWindow&&useEffect){new Effect.ResizeWindow(this,null,null,width,height,{duration:Window.resizeEffectDuration});}else{this.width=width;this.height=height;var e=this.currentDrag?this.currentDrag:this.element;e.setStyle({width:width+this.widthW+this.widthE+"px"}) e.setStyle({height:height+this.heightN+this.heightS+"px"}) if(!this.currentDrag||this.currentDrag==this.element){var content=$(this.element.id+'_content');content.setStyle({height:height+'px'});content.setStyle({width:width+'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.zIndex0)&&(navigator.userAgent.indexOf('Opera')<0)&&(this.element.getStyle('position')=='absolute')){new Insertion.After(this.element.id,'');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(event){var div=this._createHiddenDiv(this.options.className+"_n") this.heightN=Element.getDimensions(div).height;div.parentNode.removeChild(div) var div=this._createHiddenDiv(this.options.className+"_s") this.heightS=Element.getDimensions(div).height;div.parentNode.removeChild(div) var div=this._createHiddenDiv(this.options.className+"_e") this.widthE=Element.getDimensions(div).width;div.parentNode.removeChild(div) var div=this._createHiddenDiv(this.options.className+"_w") this.widthW=Element.getDimensions(div).width;div.parentNode.removeChild(div);var div=document.createElement("div");div.className="overlay_"+this.options.className;document.body.appendChild(div);var that=this;setTimeout(function(){that.overlayOpacity=($(div).getStyle("opacity"));div.parentNode.removeChild(div);},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(className){var objBody=document.body;var win=document.createElement("div");win.setAttribute('id',this.element.id+"_tmp");win.className=className;win.style.display='none';win.innerHTML='';objBody.insertBefore(win,objBody.firstChild);return win;},_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 value="";if(this.useLeft) value+="l:"+(this.storedLocation?this.storedLocation.left:this.element.getStyle('left')) else value+="r:"+(this.storedLocation?this.storedLocation.right:this.element.getStyle('right')) if(this.useTop) value+=",t:"+(this.storedLocation?this.storedLocation.top:this.element.getStyle('top')) else value+=",b:"+(this.storedLocation?this.storedLocation.bottom:this.element.getStyle('bottom')) value+=","+(this.storedLocation?this.storedLocation.width:this.width);value+=","+(this.storedLocation?this.storedLocation.height:this.height);value+=","+this.isMinimized();value+=","+this.isMaximized();WindowUtilities.setCookie(value,this.cookie)}},_createWiredElement:function(){if(!this.wiredElement){if(Prototype.Browser.IE) this._getWindowBorderSize();var div=document.createElement("div");div.className="wired_frame "+this.options.className+"_wired_frame";div.style.position='absolute';this.options.parent.insertBefore(div,this.options.parent.firstChild);this.wiredElement=$(div);} 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 dim=this.element.getDimensions();this.wiredElement.setStyle({width:dim.width+"px",height:dim.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(eventName){if(this.options[eventName]) this.options[eventName](this);else Windows.notify(eventName,this);}};var Windows={windows:[],modalWindows:[],observers:[],focusedWindow:null,maxZIndex:0,overlayShowEffectOptions:{duration:0.3},overlayHideEffectOptions:{duration:0.3},addObserver:function(observer){this.removeObserver(observer);this.observers.push(observer);},removeObserver:function(observer){this.observers=this.observers.reject(function(o){return o==observer});},notify:function(eventName,win){this.observers.each(function(o){if(o[eventName])o[eventName](eventName,win);});},getWindow:function(id){return this.windows.detect(function(d){return d.getId()==id});},getFocusedWindow:function(){return this.focusedWindow;},updateFocusedWindow:function(){this.focusedWindow=this.windows.length>=2?this.windows[this.windows.length-2]:null;},register:function(win){this.windows.push(win);},addModalWindow:function(win){if(this.modalWindows.length==0){WindowUtilities.disableScreen(win.options.className,'overlay_modal',win.overlayOpacity,win.getId(),win.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(win.getId());} this.modalWindows.push(win);},removeModalWindow:function(win){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(win){this.windows.push(win);},unregister:function(win){this.windows=this.windows.reject(function(d){return d==win});},closeAll:function(){this.windows.each(function(w){Windows.close(w.getId())});},closeAllModalWindows:function(){WindowUtilities.enableScreen();this.modalWindows.each(function(win){if(win)win.close()});},minimize:function(id,event){var win=this.getWindow(id) if(win&&win.visible) win.minimize();Event.stop(event);},maximize:function(id,event){var win=this.getWindow(id) if(win&&win.visible) win.maximize();Event.stop(event);},close:function(id,event){var win=this.getWindow(id);if(win) win.close();if(event) Event.stop(event);},blur:function(id){var win=this.getWindow(id);if(!win) return;if(win.options.blurClassName) win.changeClassName(win.options.blurClassName);if(this.focusedWindow==win) this.focusedWindow=null;win._notify("onBlur");},focus:function(id){var win=this.getWindow(id);if(!win) return;if(this.focusedWindow) this.blur(this.focusedWindow.getId()) if(win.options.focusClassName) win.changeClassName(win.options.focusClassName);this.focusedWindow=win;win._notify("onFocus");},unsetOverflow:function(except){this.windows.each(function(d){d.oldOverflow=d.getContent().getStyle("overflow")||"auto";d.getContent().setStyle({overflow:"hidden"})});if(except&&except.oldOverflow) except.getContent().setStyle({overflow:except.oldOverflow});},resetOverflow:function(){this.windows.each(function(d){if(d.oldOverflow)d.getContent().setStyle({overflow:d.oldOverflow})});},updateZindex:function(zindex,win){if(zindex>this.maxZIndex){this.maxZIndex=zindex;if(this.focusedWindow) this.blur(this.focusedWindow.getId())} this.focusedWindow=win;if(this.focusedWindow) this.focus(this.focusedWindow.getId())}};var Dialog={dialogId:null,onCompleteFunc:null,callFunc:null,parameters:null,confirm:function(content,parameters){if(content&&typeof content!="string"){Dialog._runAjaxRequest(content,parameters,Dialog.confirm);return} content=content||"";parameters=parameters||{};var okLabel=parameters.okLabel?parameters.okLabel:"Ok";var cancelLabel=parameters.cancelLabel?parameters.cancelLabel:"Cancel";parameters=Object.extend(parameters,parameters.windowParameters||{});parameters.windowParameters=parameters.windowParameters||{};parameters.className=parameters.className||"alert";var okButtonClass="class ='"+(parameters.buttonClass?parameters.buttonClass+" ":"")+" ok_button'" var cancelButtonClass="class ='"+(parameters.buttonClass?parameters.buttonClass+" ":"")+" cancel_button'" var content="\
"+content+"
\
\ \ \
\ ";return this._openDialog(content,parameters)},alert:function(content,parameters){if(content&&typeof content!="string"){Dialog._runAjaxRequest(content,parameters,Dialog.alert);return} content=content||"";parameters=parameters||{};var okLabel=parameters.okLabel?parameters.okLabel:"Ok";parameters=Object.extend(parameters,parameters.windowParameters||{});parameters.windowParameters=parameters.windowParameters||{};parameters.className=parameters.className||"alert";var okButtonClass="class ='"+(parameters.buttonClass?parameters.buttonClass+" ":"")+" ok_button'" var content="\
"+content+"
\
\ \
";return this._openDialog(content,parameters)},info:function(content,parameters){if(content&&typeof content!="string"){Dialog._runAjaxRequest(content,parameters,Dialog.info);return} content=content||"";parameters=parameters||{};parameters=Object.extend(parameters,parameters.windowParameters||{});parameters.windowParameters=parameters.windowParameters||{};parameters.className=parameters.className||"alert";var content="";if(parameters.showProgress) content+="";parameters.ok=null;parameters.cancel=null;return this._openDialog(content,parameters)},setInfoMessage:function(message){$('modal_dialog_message').update(message);},closeInfo:function(){Windows.close(this.dialogId);},_openDialog:function(content,parameters){var className=parameters.className;if(!parameters.height&&!parameters.width){parameters.width=WindowUtilities.getPageSize(parameters.options.parent||document.body).pageWidth/2;} if(parameters.id) this.dialogId=parameters.id;else{var t=new Date();this.dialogId='modal_dialog_'+t.getTime();parameters.id=this.dialogId;} if(!parameters.height||!parameters.width){var size=WindowUtilities._computeSize(content,this.dialogId,parameters.width,parameters.height,5,className) if(parameters.height) parameters.width=size+5 else parameters.height=size+5} parameters.effectOptions=parameters.effectOptions;parameters.resizable=parameters.resizable||false;parameters.minimizable=parameters.minimizable||false;parameters.maximizable=parameters.maximizable||false;parameters.draggable=parameters.draggable||false;parameters.closable=parameters.closable||false;var win=new Window(parameters);win.getContent().innerHTML=content;win.showCenter(true,parameters.top,parameters.left);win.setDestroyOnClose();win.cancelCallback=parameters.onCancel||parameters.cancel;win.okCallback=parameters.onOk||parameters.ok;return win;},_getAjaxContent:function(originalRequest){Dialog.callFunc(originalRequest.responseText,Dialog.parameters)},_runAjaxRequest:function(message,parameters,callFunc){if(message.options==null) message.options={} Dialog.onCompleteFunc=message.options.onComplete;Dialog.parameters=parameters;Dialog.callFunc=callFunc;message.options.onComplete=Dialog._getAjaxContent;new Ajax.Request(message.url,message.options);},okCallback:function(){var win=Windows.focusedWindow;if(!win.okCallback||win.okCallback(win)){$$("#"+win.getId()+" input").each(function(element){element.onclick=null;}) win.close();}},cancelCallback:function(){var win=Windows.focusedWindow;$$("#"+win.getId()+" input").each(function(element){element.onclick=null}) win.close();if(win.cancelCallback) win.cancelCallback(win);}} 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(parent){parent=parent||document.body;var windowWidth,windowHeight;var pageHeight,pageWidth;if(parent!=document.body){windowWidth=parent.getWidth();windowHeight=parent.getHeight();pageWidth=parent.scrollWidth;pageHeight=parent.scrollHeight;} else{var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=document.body.scrollWidth;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;} if(self.innerHeight){windowWidth=self.innerWidth;windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;} if(yScroll