var Window=Class.create();
Window.keepMultiModalWindow=false;
Window.prototype={initialize:function(id){
if($(id)){
alert("Window "+id+" is already register is the DOM!!, be sure to use setDestroyOnClose()");
}
this.hasEffectLib=String.prototype.parseColor!=null;
this.options=Object.extend({className:"dialog",minWidth:100,minHeight:20,resizable:true,closable:true,minimizable:true,maximizable:true,draggable:true,userData:null,showEffect:(this.hasEffectLib?Effect.Appear:Element.show),hideEffect:(this.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},arguments[1]||{});
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(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.destroyOnClose){
this.destroy();
}
}.bind(this);
}
this.element=this._createWindow(id);
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);
if(this.options.draggable){
var _2=this;
[this.topbar,this.topbar.up().previous(),this.topbar.up().next()].each(function(_3){
_3.observe("mousedown",_2.eventMouseDown);
_3.addClassName("top_draggable");
});
[this.bottombar,this.bottombar.up().previous(),this.bottombar.up().next()].each(function(_4){
_4.observe("mousedown",_2.eventMouseDown);
_4.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(arguments[1].left!=null){
this.element.setStyle({left:parseFloat(arguments[1].left)+"px"});
this.useLeft=true;
}
if(arguments[1].right!=null){
this.element.setStyle({right:parseFloat(arguments[1].right)+"px"});
this.useLeft=false;
}
if(this.useLeft==null){
this.element.setStyle({left:"0px"});
this.useLeft=true;
}
if(arguments[1].top!=null){
this.element.setStyle({top:parseFloat(arguments[1].top)+"px"});
this.useTop=true;
}
if(arguments[1].bottom!=null){
this.element.setStyle({bottom:parseFloat(arguments[1].bottom)+"px"});
this.useTop=false;
}
if(this.useTop==null){
this.element.setStyle({top:"0px"});
this.useTop=true;
}
this.storedLocation=null;
this.setOpacity(this.options.opacity);
if(this.options.zIndex){
this.setZIndex(this.options.zIndex);
}
this.destroyOnClose=false;
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(){
Windows.notify("onDestroy",this);
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 _5=this.getContent();
var _6=null;
for(var i=0;i<_5.childNodes.length;i++){
_6=_5.childNodes[i];
if(_6.nodeType==1){
break;
}
_6=null;
}
if(_6){
this._oldParent.appendChild(_6);
}
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);
},setDelegate:function(_8){
this.delegate=_8;
},getDelegate:function(){
return this.delegate;
},getContent:function(){
return this.content;
},setContent:function(id,_a,_b){
var _c=$(id);
if(null==_c){
throw "Unable to find element '"+id+"' in DOM";
}
this._oldParent=_c.parentNode;
var d=null;
var p=null;
if(_a){
d=Element.getDimensions(_c);
}
if(_b){
p=Position.cumulativeOffset(_c);
}
var _f=this.getContent();
_f.appendChild(_c);
_c.show();
if(_a){
this.setSize(d.width,d.height);
}
if(_b){
this.setLocation(p[1]-this.heightN,p[0]-this.widthW);
}
},setHTMLContent:function(_10){
if(this.options.url){
this.content.src=null;
this.options.url=null;
var _11="<div id=\""+this.getId()+"_content\" class=\""+this.options.className+"_content\"> </div>";
$(this.getId()+"_table_content").innerHTML=_11;
this.content=$(this.element.id+"_content");
}
this.getContent().innerHTML=_10;
},setAjaxContent:function(url,_13,_14,_15){
this.showFunction=_14?"showCenter":"show";
this.showModal=_15||false;
if(_13==null){
_13={};
}
this.onComplete=_13.onComplete;
if(!this._onCompleteHandler){
this._onCompleteHandler=this._setAjaxContent.bind(this);
}
_13.onComplete=this._onCompleteHandler;
new Ajax.Request(url,_13);
_13.onComplete=this.onComplete;
},_setAjaxContent:function(_16){
Element.update(this.getContent(),_16.responseText);
if(this.onComplete){
this.onComplete(_16);
}
this.onComplete=null;
this[this.showFunction](this.showModal);
},setURL:function(url){
if(!this.options.url){
this.options.url=url;
var _18="<iframe frameborder=\"0\" name=\""+this.getId()+"_content\"  id=\""+this.getId()+"_content\" src=\""+url+"\"> </iframe>";
$(this.getId()+"_table_content").innerHTML=_18;
this.content=$(this.element.id+"_content");
}else{
this.options.url=url;
$(this.element.getAttribute("id")+"_content").src=url;
}
},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(_19,_1a,_1b,_1c,_1d){
_19=_19||this.element.id;
this.cookie=[_19,_1a,_1b,_1c,_1d];
var _1e=WindowUtilities.getCookie(_19);
if(_1e){
var _1f=_1e.split(",");
var x=_1f[0].split(":");
var y=_1f[1].split(":");
var w=parseFloat(_1f[2]),h=parseFloat(_1f[3]);
var _24=_1f[4];
var _25=_1f[5];
this.setSize(w,h);
if(_24=="true"){
this.doMinimize=true;
}else{
if(_25=="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(){
var _26=this.destroy.bind(this);
if(this.options.hideEffectOptions.afterFinish){
var _27=this.options.hideEffectOptions.afterFinish;
this.options.hideEffectOptions.afterFinish=function(){
_27();
_26();
};
}else{
this.options.hideEffectOptions.afterFinish=function(){
_26();
};
}
this.destroyOnClose=true;
},setConstraint:function(_28,_29){
this.constraint=_28;
this.constraintPad=Object.extend(this.constraintPad,_29||{});
if(this.useTop&&this.useLeft){
this.setLocation(parseFloat(this.element.style.top),parseFloat(this.element.style.left));
}
},_initDrag:function(_2a){
if(isIE&&this.heightN==0){
this._getWindowBorderSize();
}
this.pointer=[Event.pointerX(_2a),Event.pointerY(_2a)];
if(this.options.wiredDrag){
this.currentDrag=this._createWiredElement();
}else{
this.currentDrag=this.element;
}
if(Event.element(_2a)==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"));
Windows.notify("onStartResize",this);
}else{
this.doResize=false;
var _2b=$(this.getId()+"_close");
if(_2b&&Position.within(_2b,this.pointer[0],this.pointer[1])){
this.currentDrag=null;
return;
}
this.toFront();
if(!this.options.draggable){
return;
}
Windows.notify("onStartMove",this);
}
Event.observe(document,"mouseup",this.eventMouseUp,false);
Event.observe(document,"mousemove",this.eventMouseMove,false);
WindowUtilities.disableScreen("__invisible__","__invisible__");
document.body.ondrag=function(){
return false;
};
document.body.onselectstart=function(){
return false;
};
this.currentDrag.show();
Event.stop(_2a);
},_updateDrag:function(_2c){
var _2d=[Event.pointerX(_2c),Event.pointerY(_2c)];
var dx=_2d[0]-this.pointer[0];
var dy=_2d[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);
Windows.notify("onResize",this);
}else{
this.pointer=_2d;
if(this.useLeft){
var _32=parseFloat(this.currentDrag.getStyle("left"))+dx;
var _33=this._updateLeftConstraint(_32);
this.pointer[0]+=_33-_32;
this.currentDrag.setStyle({left:_33+"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 _35=this._updateTopConstraint(top);
this.pointer[1]+=_35-top;
this.currentDrag.setStyle({top:_35+"px"});
}else{
this.currentDrag.setStyle({bottom:parseFloat(this.currentDrag.getStyle("bottom"))-dy+"px"});
}
}
if(this.iefix){
this._fixIEOverlapping();
}
this._removeStoreLocation();
Event.stop(_2c);
},_endDrag:function(_36){
WindowUtilities.enableScreen("__invisible__");
if(this.doResize){
Windows.notify("onEndResize",this);
}else{
Windows.notify("onEndMove",this);
}
Event.stopObserving(document,"mouseup",this.eventMouseUp,false);
Event.stopObserving(document,"mousemove",this.eventMouseMove,false);
Event.stop(_36);
this._hideWiredElement();
this._saveCookie();
document.body.ondrag=null;
document.body.onselectstart=null;
},_updateLeftConstraint:function(_37){
if(this.constraint&&this.useLeft&&this.useTop){
var _38=this.options.parent==document.body?WindowUtilities.getPageSize().windowWidth:this.options.parent.getDimensions().width;
if(_37<this.constraintPad.left){
_37=this.constraintPad.left;
}
if(_37+this.width+this.widthE+this.widthW>_38-this.constraintPad.right){
_37=_38-this.constraintPad.right-this.width-this.widthE-this.widthW;
}
}
return _37;
},_updateTopConstraint:function(top){
if(this.constraint&&this.useLeft&&this.useTop){
var _3a=this.options.parent==document.body?WindowUtilities.getPageSize().windowHeight:this.options.parent.getDimensions().height;
if(top<this.constraintPad.top){
top=this.constraintPad.top;
}
if(top+this.height+this.heightN+this.heightS>_3a-this.constraintPad.bottom){
top=_3a-this.constraintPad.bottom-this.height-this.heightS-this.heightN;
}
}
return top;
},_updateWidthConstraint:function(w){
if(this.constraint&&this.useLeft&&this.useTop){
var _3c=this.options.parent==document.body?WindowUtilities.getPageSize().windowWidth:this.options.parent.getDimensions().width;
var _3d=parseFloat(this.element.getStyle("left"));
if(_3d+w+this.widthE+this.widthW>_3c-this.constraintPad.right){
w=_3c-this.constraintPad.right-_3d-this.widthE-this.widthW;
}
}
return w;
},_updateHeightConstraint:function(h){
if(this.constraint&&this.useLeft&&this.useTop){
var _3f=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>_3f-this.constraintPad.bottom){
h=_3f-this.constraintPad.bottom-top-this.heightN-this.heightS;
}
}
return h;
},_createWindow:function(id){
var _42=this.options.className;
var win=document.createElement("div");
win.setAttribute("id",id);
win.className="dialog";
var _44;
if(this.options.url){
_44="<iframe frameborder=\"0\" name=\""+id+"_content\"  id=\""+id+"_content\" src=\""+this.options.url+"\"> </iframe>";
}else{
_44="<div id=\""+id+"_content\" class=\""+_42+"_content\"> </div>";
}
var _45=this.options.closable?"<div class='"+_42+"_close' id='"+id+"_close' onclick='Windows.close(\""+id+"\", event)'> </div>":"";
var _46=this.options.minimizable?"<div class='"+_42+"_minimize' id='"+id+"_minimize' onclick='Windows.minimize(\""+id+"\", event)'> </div>":"";
var _47=this.options.maximizable?"<div class='"+_42+"_maximize' id='"+id+"_maximize' onclick='Windows.maximize(\""+id+"\", event)'> </div>":"";
var _48=this.options.resizable?"class='"+_42+"_sizer' id='"+id+"_sizer'":"class='"+_42+"_se'";
win.innerHTML=_45+_46+_47+"      <table id='"+id+"_row1' class=\"top table_window\">        <tr>          <td class='"+_42+"_nw'>&nbsp;</td>          <td class='"+_42+"_n'><div id='"+id+"_top' class='"+_42+"_title title_window'>"+this.options.title+"</div></td>          <td class='"+_42+"_ne'>&nbsp;</td>        </tr>      </table>      <table id='"+id+"_row2' class=\"mid table_window\">        <tr>          <td class='"+_42+"_w'></td>            <td id='"+id+"_table_content' class='"+_42+"_content' valign='top'>"+_44+"</td>          <td class='"+_42+"_e'></td>        </tr>      </table>        <table id='"+id+"_row3' class=\"bot table_window\">        <tr>          <td class='"+_42+"_sw'>&nbsp;</td>            <td class='"+_42+"_s'><div id='"+id+"_bottom' class='status_bar'>&nbsp;</div></td>            <td "+_48+">&nbsp;</td>        </tr>      </table>    ";
Element.hide(win);
this.options.parent.insertBefore(win,this.options.parent.firstChild);
Event.observe($(id+"_content"),"load",this.options.onload);
return win;
},changeClassName:function(_49){
var _4a=this.options.className;
var id=this.getId();
var win=this;
$A(["_close","_minimize","_maximize","_sizer","_content"]).each(function(_4d){
win._toggleClassName($(id+_4d),_4a+_4d,_49+_4d);
});
$$("#"+id+" td").each(function(td){
td.className=td.className.sub(_4a,_49);
});
this.options.className=_49;
},_toggleClassName:function(_4f,_50,_51){
if(_4f){
_4f.removeClassName(_50);
_4f.addClassName(_51);
}
},setLocation:function(top,_53){
top=this._updateTopConstraint(top);
_53=this._updateLeftConstraint(_53);
this.element.setStyle({top:top+"px"});
this.element.setStyle({left:_53+"px"});
this.useLeft=true;
this.useTop=true;
},getLocation:function(){
var _54={};
if(this.useTop){
_54=Object.extend(_54,{top:this.element.getStyle("top")});
}else{
_54=Object.extend(_54,{bottom:this.element.getStyle("bottom")});
}
if(this.useLeft){
_54=Object.extend(_54,{left:this.element.getStyle("left")});
}else{
_54=Object.extend(_54,{right:this.element.getStyle("right")});
}
return _54;
},getSize:function(){
return {width:this.width,height:this.height};
},setSize:function(_55,_56){
_55=parseFloat(_55);
_56=parseFloat(_56);
if(_55<this.options.minWidth){
_55=this.options.minWidth;
}
if(_56<this.options.minHeight){
_56=this.options.minHeight;
}
if(this.options.maxHeight&&_56>this.options.maxHeight){
_56=this.options.maxHeight;
}
if(this.options.maxWidth&&_55>this.options.maxWidth){
_55=this.options.maxWidth;
}
this.width=_55;
this.height=_56;
var e=this.currentDrag?this.currentDrag:this.element;
e.setStyle({width:_55+this.widthW+this.widthE+"px"});
e.setStyle({height:_56+this.heightN+this.heightS+"px"});
if(!this.currentDrag||this.currentDrag==this.element){
var _58=$(this.element.id+"_content");
_58.setStyle({height:_56+"px"});
_58.setStyle({width:_55+"px"});
}
},updateHeight:function(){
this.setSize(this.width,this.content.scrollHeight);
},updateWidth:function(){
this.setSize(this.content.scrollWidth,this.height);
},toFront:function(){
if(Windows.focusedWindow==this){
return;
}
this.setZIndex(Windows.maxZIndex+20);
Windows.notify("onFocus",this);
},show:function(_59){
if(_59){
Windows.addModalWindow(this);
this.modal=true;
Windows.unsetOverflow(this);
}
if(this.oldStyle){
this.getContent().setStyle({overflow:this.oldStyle});
}
if(!this.width||!this.height){
var _5a=WindowUtilities._computeSize(this.content.innerHTML,this.content.id,this.width,this.height,0,this.options.className);
if(this.height){
this.width=_5a+5;
}else{
this.height=_5a+5;
}
}
this.setSize(this.width,this.height);
if(this.centered){
this._center(this.centerTop,this.centerLeft);
}
Windows.notify("onBeforeShow",this);
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();
this.visible=true;
WindowUtilities.focusedWindow=this;
Windows.notify("onShow",this);
},showCenter:function(_5b,top,_5d){
this.centered=true;
this.centerTop=top;
this.centerLeft=_5d;
this.show(_5b);
},isVisible:function(){
return this.visible;
},_center:function(top,_5f){
var _60=WindowUtilities.getWindowScroll();
var _61=WindowUtilities.getPageSize();
if(!top){
top=(_61.windowHeight-(this.height+this.heightN+this.heightS))/2;
}
top+=_60.top;
if(!_5f){
_5f=(_61.windowWidth-(this.width+this.widthW+this.widthE))/2;
}
_5f+=_60.left;
this.setLocation(top,_5f);
this.toFront();
},_recenter:function(_62){
if(this.modal&&this.centered){
var _63=WindowUtilities.getPageSize();
if(this.pageSize&&this.pageSize.pageWidth==_63.windowWidth&&this.pageSize.pageHeight==_63.windowHeight){
return;
}
this.pageSize=_63;
if($("overlay_modal")){
if(window.innerHeight&&window.scrollMaxY){
$("overlay_modal").style.height=((_63.pageHeight-18)+"px");
}else{
$("overlay_modal").style.height=(_63.pageHeight+"px");
}
$("overlay_modal").style.width=(_63.pageWidth+"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();
}
Windows.notify("onHide",this);
},minimize:function(){
var r2=$(this.getId()+"_row2");
var dh=r2.getDimensions().height;
if(r2.visible()){
var h=this.element.getHeight()-dh;
r2.hide();
this.element.setStyle({height:h+"px"});
if(!this.useTop){
var _67=parseFloat(this.element.getStyle("bottom"));
this.element.setStyle({bottom:(_67+dh)+"px"});
}
}else{
var h=this.element.getHeight()+dh;
this.element.setStyle({height:h+"px"});
if(!this.useTop){
var _67=parseFloat(this.element.getStyle("bottom"));
this.element.setStyle({bottom:(_67-dh)+"px"});
}
r2.show();
this.toFront();
}
Windows.notify("onMinimize",this);
this._saveCookie();
},maximize:function(){
if(this.storedLocation!=null){
this._restoreLocation();
if(this.iefix){
this.iefix.hide();
}
}else{
this._storeLocation();
Windows.unsetOverflow(this);
var _68=WindowUtilities.getWindowScroll();
var _69=WindowUtilities.getPageSize();
this.element.setStyle(this.useLeft?{left:_68.left}:{right:_68.left});
this.element.setStyle(this.useTop?{top:_68.top}:{bottom:_68.top});
this.setSize(_69.windowWidth-this.widthW-this.widthE,_69.windowHeight-this.heightN-this.heightS);
this.toFront();
if(this.iefix){
this._fixIEOverlapping();
}
}
Windows.notify("onMaximize",this);
this._saveCookie();
},isMinimized:function(){
var r2=$(this.getId()+"_row2");
return !r2.visible();
},isMaximized:function(){
return (this.storedLocation!=null);
},setOpacity:function(_6b){
if(Element.setOpacity){
Element.setOpacity(this.element,_6b);
}
},setZIndex:function(_6c){
this.element.setStyle({zIndex:_6c});
Windows.updateZindex(_6c,this);
},setTitle:function(_6d){
if(!_6d||_6d==""){
_6d="&nbsp;";
}
Element.update(this.element.id+"_top",_6d);
},setStatusBar:function(_6e){
var _6f=$(this.getId()+"_bottom");
if(typeof (_6e)=="object"){
if(this.bottombar.firstChild){
this.bottombar.replaceChild(_6e,this.bottombar.firstChild);
}else{
this.bottombar.appendChild(_6e);
}
}else{
this.bottombar.innerHTML=_6e;
}
},_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(_70){
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);
if(isIE){
this.heightS=$(this.getId()+"_row3").getDimensions().height;
this.heightN=$(this.getId()+"_row1").getDimensions().height;
}
if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){
this.setSize(this.width,this.height);
}
if(this.doMaximize){
this.maximize();
}
if(this.doMinimize){
this.minimize();
}
},_createHiddenDiv:function(_72){
var _73=document.body;
var win=document.createElement("div");
win.setAttribute("id",this.element.id+"_tmp");
win.className=_72;
win.style.display="none";
win.innerHTML="";
_73.insertBefore(win,_73.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;
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 _75="";
if(this.useLeft){
_75+="l:"+(this.storedLocation?this.storedLocation.left:this.element.getStyle("left"));
}else{
_75+="r:"+(this.storedLocation?this.storedLocation.right:this.element.getStyle("right"));
}
if(this.useTop){
_75+=",t:"+(this.storedLocation?this.storedLocation.top:this.element.getStyle("top"));
}else{
_75+=",b:"+(this.storedLocation?this.storedLocation.bottom:this.element.getStyle("bottom"));
}
_75+=","+(this.storedLocation?this.storedLocation.width:this.width);
_75+=","+(this.storedLocation?this.storedLocation.height:this.height);
_75+=","+this.isMinimized();
_75+=","+this.isMaximized();
WindowUtilities.setCookie(_75,this.cookie);
}
},_createWiredElement:function(){
if(!this.wiredElement){
if(isIE){
this._getWindowBorderSize();
}
var div=document.createElement("div");
div.className="wired_frame "+this.options.className+"_wired_frame";
div.style.position="absolute";
document.body.insertBefore(div,document.body.firstChild);
div=$(div);
var dim=this.element.getDimensions();
div.setStyle({width:dim.width+"px",height:dim.height+"px"});
if(this.useLeft){
div.setStyle({left:this.element.getStyle("left")});
}else{
div.setStyle({right:this.element.getStyle("right")});
}
if(this.useTop){
div.setStyle({top:this.element.getStyle("top")});
}else{
div.setStyle({bottom:this.element.getStyle("bottom")});
}
this.wiredElement=div;
}
this.wiredElement.setStyle({zIndex:Windows.maxZIndex+30});
return this.wiredElement;
},_hideWiredElement:function(){
if(!this.wiredElement){
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;
this.setSize(this.width,this.height);
}
}};
var Windows={windows:[],modalWindows:[],observers:[],focusedWindow:null,maxZIndex:0,addObserver:function(_78){
this.removeObserver(_78);
this.observers.push(_78);
},removeObserver:function(_79){
this.observers=this.observers.reject(function(o){
return o==_79;
});
},notify:function(_7b,win){
this.observers.each(function(o){
if(o[_7b]){
o[_7b](_7b,win);
}
});
},getWindow:function(id){
return this.windows.detect(function(d){
return d.getId()==id;
});
},getFocusedWindow:function(){
return this.focusedWindow;
},register:function(win){
this.windows.push(win);
},addModalWindow:function(win){
if(this.modalWindows.length==0){
WindowUtilities.disableScreen(win.options.className,"overlay_modal",win.getId());
}else{
if(Window.keepMultiModalWindow){
$("overlay_modal").style.zIndex=Windows.maxZIndex+20;
Windows.maxZIndex+=20;
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;
});
},close:function(id,_87){
var win=this.getWindow(id);
if(win&&win.visible){
if(win.getDelegate()&&!win.getDelegate().canClose(win)){
return;
}
this.focusedWindow=this.windows.length>=2?this.windows[this.windows.length-2]:null;
this.notify("onClose",win);
win.hide();
}
if(_87){
Event.stop(_87);
}
},closeAll:function(){
this.windows.each(function(w){
Windows.close(w.getId());
});
},closeAllModalWindows:function(){
WindowUtilities.enableScreen();
this.modalWindows.each(function(win){
win.hide();
});
},minimize:function(id,_8c){
var win=this.getWindow(id);
if(win&&win.visible){
win.minimize();
}
Event.stop(_8c);
},maximize:function(id,_8f){
var win=this.getWindow(id);
if(win&&win.visible){
win.maximize();
}
Event.stop(_8f);
},unsetOverflow:function(_91){
this.windows.each(function(d){
d.oldOverflow=d.getContent().getStyle("overflow")||"auto";
d.getContent().setStyle({overflow:"hidden"});
});
if(_91&&_91.oldOverflow){
_91.getContent().setStyle({overflow:_91.oldOverflow});
}
},resetOverflow:function(){
this.windows.each(function(d){
if(d.oldOverflow){
d.getContent().setStyle({overflow:d.oldOverflow});
}
});
},updateZindex:function(_94,win){
if(_94>this.maxZIndex){
this.maxZIndex=_94;
}
this.focusedWindow=win;
}};
var Dialog={dialogId:null,onCompleteFunc:null,callFunc:null,parameters:null,confirm:function(_96,_97){
if(typeof _96!="string"){
Dialog._runAjaxRequest(_96,_97,Dialog.confirm);
return;
}
_97=_97||{};
var _98=_97.okLabel?_97.okLabel:"Ok";
var _99=_97.cancelLabel?_97.cancelLabel:"Cancel";
var _9a=_97.windowParameters||{};
_9a.className=_9a.className||"alert";
var _9b="class ='"+(_97.buttonClass?_97.buttonClass+" ":"")+" ok_button'";
var _9c="class ='"+(_97.buttonClass?_97.buttonClass+" ":"")+" cancel_button'";
var _96="      <div class='"+_9a.className+"_message'>"+_96+"</div>        <div class='"+_9a.className+"_buttons'>          <input type='button' value='"+_98+"' onclick='Dialog.okCallback()'"+_9b+"/>          <input type='button' value='"+_99+"' onclick='Dialog.cancelCallback()' "+_9c+"/>        </div>    ";
return this._openDialog(_96,_97,_9a.className);
},alert:function(_9d,_9e){
if(typeof _9d!="string"){
Dialog._runAjaxRequest(_9d,_9e,Dialog.alert);
return;
}
_9e=_9e||{};
var _9f=_9e.okLabel?_9e.okLabel:"Ok";
var _a0=_9e.windowParameters||{};
_a0.className=_a0.className||"alert";
var _a1="class ='"+(_9e.buttonClass?_9e.buttonClass+" ":"")+" ok_button'";
var _9d="      <div class='"+_a0.className+"_message'>"+_9d+"</div>        <div class='"+_a0.className+"_buttons'>          <input type='button' value='"+_9f+"' onclick='Dialog.okCallback()'"+_a1+"/>        </div>";
return this._openDialog(_9d,_9e,_a0.className);
},info:function(_a2,_a3){
if(typeof _a2!="string"){
Dialog._runAjaxRequest(_a2,_a3,Dialog.info);
return;
}
_a3=_a3||{};
_a3.windowParameters=_a3.windowParameters||{};
var _a4=_a3.windowParameters.className||"alert";
var _a2="<div id='modal_dialog_message' class='"+_a4+"_message'>"+_a2+"</div>";
if(_a3.showProgress){
_a2+="<div id='modal_dialog_progress' class='"+_a4+"_progress'>  </div>";
}
_a3.windowParameters.ok=null;
_a3.windowParameters.cancel=null;
_a3.windowParameters.className=_a4;
return this._openDialog(_a2,_a3,_a4);
},setInfoMessage:function(_a5){
$("modal_dialog_message").update(_a5);
},closeInfo:function(){
Windows.close(this.dialogId);
},_openDialog:function(_a6,_a7,_a8){
if(!_a7.windowParameters.height&&!_a7.windowParameters.width){
_a7.windowParameters.width=WindowUtilities.getPageSize().pageWidth/2;
}
if(_a7.id){
this.dialogId=_a7.id;
}else{
var t=new Date();
this.dialogId="modal_dialog_"+t.getTime();
}
if(!_a7.windowParameters.height||!_a7.windowParameters.width){
var _aa=WindowUtilities._computeSize(_a6,this.dialogId,_a7.windowParameters.width,_a7.windowParameters.height,5,_a8);
if(_a7.windowParameters.height){
_a7.windowParameters.width=_aa+5;
}else{
_a7.windowParameters.height=_aa+5;
}
}
var _ab=_a7&&_a7.windowParameters?_a7.windowParameters:{};
_ab.resizable=_ab.resizable||false;
_ab.effectOptions=_ab.effectOptions||{duration:1};
_ab.minimizable=false;
_ab.maximizable=false;
_ab.closable=false;
var win=new Window(this.dialogId,_ab);
win.getContent().innerHTML=_a6;
win.showCenter(true,_a7.top,_a7.left);
win.setDestroyOnClose();
win.cancelCallback=_a7.cancel;
win.okCallback=_a7.ok;
return win;
},_getAjaxContent:function(_ad){
Dialog.callFunc(_ad.responseText,Dialog.parameters);
},_runAjaxRequest:function(_ae,_af,_b0){
if(_ae.options==null){
_ae.options={};
}
Dialog.onCompleteFunc=_ae.options.onComplete;
Dialog.parameters=_af;
Dialog.callFunc=_b0;
_ae.options.onComplete=Dialog._getAjaxContent;
new Ajax.Request(_ae.url,_ae.options);
},okCallback:function(){
var win=Windows.focusedWindow;
if(!win.okCallback||win.okCallback(win)){
$$("#"+win.getId()+" input").each(function(_b2){
_b2.onclick=null;
});
win.hide();
}
},cancelCallback:function(){
var win=Windows.focusedWindow;
$$("#"+win.getId()+" input").each(function(_b4){
_b4.onclick=null;
});
win.hide();
if(win.cancelCallback){
win.cancelCallback(win);
}
}};
var isIE=navigator.appVersion.match(/MSIE/)=="MSIE";
var WindowUtilities={getWindowScroll:function(){
var w=window;
var T,L,W,H;
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(){
var _ba,_bb;
if(window.innerHeight&&window.scrollMaxY){
_ba=document.body.scrollWidth;
_bb=window.innerHeight+window.scrollMaxY;
}else{
if(document.body.scrollHeight>document.body.offsetHeight){
_ba=document.body.scrollWidth;
_bb=document.body.scrollHeight;
}else{
_ba=document.body.offsetWidth;
_bb=document.body.offsetHeight;
}
}
var _bc,_bd;
if(self.innerHeight){
_bc=self.innerWidth;
_bd=self.innerHeight;
}else{
if(document.documentElement&&document.documentElement.clientHeight){
_bc=document.documentElement.clientWidth;
_bd=document.documentElement.clientHeight;
}else{
if(document.body){
_bc=document.body.clientWidth;
_bd=document.body.clientHeight;
}
}
}
var _be,_bf;
if(_bb<_bd){
_be=_bd;
}else{
_be=_bb;
}
if(_ba<_bc){
_bf=_bc;
}else{
_bf=_ba;
}
return {pageWidth:_bf,pageHeight:_be,windowWidth:_bc,windowHeight:_bd};
},disableScreen:function(_c0,_c1,_c2){
WindowUtilities.initLightbox(_c1,_c0);
var _c3=document.body;
var _c4=$(_c1);
var _c5=WindowUtilities.getPageSize();
if(_c2&&isIE){
WindowUtilities._hideSelect();
WindowUtilities._showSelect(_c2);
}
_c4.style.height=(_c5.pageHeight+"px");
_c4.style.width=(_c5.windowWidth+"px");
_c4.style.display="block";
},enableScreen:function(id){
id=id||"overlay_modal";
var _c7=$(id);
if(_c7){
_c7.style.display="none";
if(id!="__invisible__"){
WindowUtilities._showSelect();
}
_c7.parentNode.removeChild(_c7);
}
},_hideSelect:function(id){
if(isIE){
id=id==null?"":"#"+id+" ";
$$(id+"select").each(function(_c9){
if(!WindowUtilities.isDefined(_c9.oldVisibility)){
_c9.oldVisibility=_c9.style.visibility?_c9.style.visibility:"visible";
_c9.style.visibility="hidden";
}
});
}
},_showSelect:function(id){
if(isIE){
id=id==null?"":"#"+id+" ";
$$(id+"select").each(function(_cb){
if(WindowUtilities.isDefined(_cb.oldVisibility)){
try{
_cb.style.visibility=_cb.oldVisibility;
}
catch(e){
_cb.style.visibility="visible";
}
_cb.oldVisibility=null;
}else{
if(_cb.style.visibility){
_cb.style.visibility="visible";
}
}
});
}
},isDefined:function(_cc){
return typeof (_cc)!="undefined"&&_cc!=null;
},initLightbox:function(id,_ce){
if($(id)){
Element.setStyle(id,{zIndex:550});
}else{
var _cf=document.body;
var _d0=document.createElement("div");
_d0.setAttribute("id",id);
_d0.className="overlay_"+_ce;
_d0.style.display="none";
_d0.style.position="absolute";
_d0.style.top="0";
_d0.style.left="0";
_d0.style.zIndex=550;
_d0.style.width="100%";
_cf.insertBefore(_d0,_cf.firstChild);
}
},setCookie:function(_d1,_d2){
document.cookie=_d2[0]+"="+escape(_d1)+((_d2[1])?"; expires="+_d2[1].toGMTString():"")+((_d2[2])?"; path="+_d2[2]:"")+((_d2[3])?"; domain="+_d2[3]:"")+((_d2[4])?"; secure":"");
},getCookie:function(_d3){
var dc=document.cookie;
var _d5=_d3+"=";
var _d6=dc.indexOf("; "+_d5);
if(_d6==-1){
_d6=dc.indexOf(_d5);
if(_d6!=0){
return null;
}
}else{
_d6+=2;
}
var end=document.cookie.indexOf(";",_d6);
if(end==-1){
end=dc.length;
}
return unescape(dc.substring(_d6+_d5.length,end));
},_computeSize:function(_d8,id,_da,_db,_dc,_dd){
var _de=document.body;
var _df=document.createElement("div");
_df.setAttribute("id",id);
_df.className=_dd+"_content";
if(_db){
_df.style.height=_db+"px";
}else{
_df.style.width=_da+"px";
}
_df.style.position="absolute";
_df.style.top="0";
_df.style.left="0";
_df.style.display="none";
_df.innerHTML=_d8;
_de.insertBefore(_df,_de.firstChild);
var _e0;
if(_db){
_e0=$(id).getDimensions().width+_dc;
}else{
_e0=$(id).getDimensions().height+_dc;
}
_de.removeChild(_df);
return _e0;
}};

