Prototype.require("jojoPopup.js");Prototype.require("buttons.js");Prototype.require("superadmin/overlay.css");Prototype.require("superadmin.locale.js.php");adminOverlay=Class.create({options:{},oPopup:null,oWaitPopup:null,initialize:function(C,D){try{this.options={id:C,zIndex:105,showWaitingPopup:false,divAppend:"AdminContent",onHide:function(){},onShow:function(){},headercolor:"headerOverlayBlue",automoveToBody:false};Object.extend(this.options,D||{});var B=this;this.oPopup=new Popup(C,{zIndex:this.options.zIndex,fadeBackground:true,fadeBackgroundOption:{zIndex:this.options.zIndex*1-4,onHide:function(){$(C).hide()}},automoveToBody:this.options.automoveToBody,shadow:true,onShow:function(){B.closeCalendar();B.repositionFooter();B.options.onShow();this.onResize()},onHide:function(){B.closeCalendar();$(C).hide();B.options.onHide()},onResize:function(){B.checkHeight();B.repositionCalendar()},showEffect:{method:"appear",options:{duration:0.5}}});if(this.options.showWaitingPopup!=false&&$("wait_"+this.options.id)==null){this.createWaitPopup();this.oWaitPopup=new Popup("wait_"+this.options.id,{zIndex:this.options.zIndex*1+2,fadeBackground:true,shadow:true,onShow:function(){B.closeCalendar()},hideEffect:{method:"fade",options:{duration:0.3}}})}$(C).object=this}catch(A){Prototype.alertError("initAdminOverlay : "+A.description)}},deplaceHTML:function(){$$("BODY")[0].appendChild($(this.options.id))},reposition:function(){this.oPopup.onResize()},closeCalendar:function(){try{for(var C=0;C<listCalendar.length;C++){try{listCalendar[C].hide()}catch(B){}}}catch(A){}},repositionCalendar:function(){try{for(var C=0;C<listCalendar.length;C++){try{listCalendar[C].reposition()}catch(B){}}}catch(A){}},createWaitPopup:function(){var A=new Element("div",{id:"wait_"+this.options.id,style:"display:none;width:450px;","class":"Overlay"});var B=new Element("div",{"class":"ombrage_interieur"});var D=new Element("div",{"class":"headerOverlay header "+this.options.headercolor}).update('<div id="title_waitingOverlay_'+this.options.id+'" class="titleOverlay">'+Overlay_translation.loading+"</div>");var C=new Element("div",{align:"center",style:"padding:30px"}).update('<img src="/shared/images/ajax-loader.gif" width="48" height="48"/>');B.appendChild(D);B.appendChild(C);A.appendChild(B);$(this.options.divAppend).appendChild(A)},show:function(){try{this.oPopup.show()}catch(A){Prototype.alertError("show: "+A)}},hide:function(){try{if(this.oPopup!=null){this.oPopup.hide()}}catch(A){Prototype.alertError("hide: "+A)}},showWaiting:function(){if(this.oWaitPopup!=null&&this.options.showWaitingPopup){this.oWaitPopup.show();this.oWaitPopup.onResize()}},hideWaiting:function(){if(this.oWaitPopup!=null&&this.oWaitPopup.visible()){this.oWaitPopup.hide()}},hideBackgroundWaitingPopup:function(){if(this.oWaitPopup!=null){this.oWaitPopup.fadeBackgroundElement.hide();this.oWaitPopup.fadeBackgroundElement=null}},updateTitle:function(A){$("overlay_title_"+this.options.id).innerHTML=A},updateFooter:function(){},updateContentOnly:function(B,A,C){this.updateDivContent("overlay_content_"+this.options.id,B,A,C)},updateAll:function(B,A,C){this.updateDivContent("overlay_"+this.options.id,B,A,C)},setWidth:function(B){$(this.options.id).setStyle({width:B+"px"});var A=$("overlay_content_"+this.options.id);if(A!=null){A.setStyle({width:B+"px"})}},updateAlertContent:function(B){try{$("overlay_content_"+this.options.id).innerHTML=B}catch(A){Prototype.alertError("Error updateAlertContent - "+A)}},updateConfirmAction:function(A){try{$("btnok_"+this.options.id).object.updateBtnAction(A)}catch(B){Prototype.alertError("Error updateConfirmAction - "+B)}},updateDivContent:function(sContainer,sPage,sParam,afterFinish){try{this.showWaiting();var thisParent=this;req=new Ajax.Request(sPage,{method:"post",parameters:sParam,onSuccess:function(xhr){try{$(sContainer).innerHTML=xhr.responseText;xhr.responseText.evalScripts();thisParent.hideBackgroundWaitingPopup();try{eval(afterFinish)}catch(ex){Prototype.alertInfo("afterFinish : "+ex)}thisParent.reposition();thisParent.hideWaiting()}catch(Exc){Prototype.alertWarning("contenu overlay frelat�, updateEx(): "+Exc)}}})}catch(exception){Prototype.alertError("Error UpdateContentOverlay - "+exception)}},disable:function(){$("overlay-cancel-"+this.options.id).hide();$("overlay-cancel-disabled-"+this.options.id).show()},enable:function(){$("overlay-cancel-disabled-"+this.options.id).hide();$("overlay-cancel-"+this.options.id).show()},checkHeight:function(){try{var D=$("overlay_content_"+this.options.id);if(D!=null){var F=parseInt($(this.options.id).getStyle("width"));if(F!=0){widthValue=F-parseInt(D.getStyle("padding-left"))-parseInt(D.getStyle("padding-right"));D.setStyle({width:widthValue+"px"})}var E=Prototype.Browser.getDimensions().clientHeight;var C=$("overlay_header_"+this.options.id).getHeight();var H=D.scrollHeight;var G=$("overlay_bottom_"+this.options.id).getHeight();var J=C+H+G;var I=D.getHeight();var A=(E*1-50-C-G);if((J*1+30)>E){if(A!=I){$("overlay_content_"+this.options.id).setStyle({display:"block",height:A+"px",overflowY:"scroll",overflowX:"hidden"})}}else{if($("overlay_content_"+this.options.id).getStyle("overflowY")=="scroll"){$("overlay_content_"+this.options.id).setStyle({height:"auto",overflowY:"auto",overflowX:"auto"})}}}}catch(B){Prototype.alertError(B)}},repositionFooter:function(){try{var C=$("overlay_bottom_"+this.options.id);var B=$("overlay_bottom_content_"+this.options.id);if(B!=null){B.style.visibility="hidden";B.show();if(C!=null){var D=C.getDimensions().width;var F=0;B.descendants().each(function(G){if(G.id!=""&&G.style.display!="none"){F+=G.getDimensions().width*1+2}});var E=(D-F)/2;B.style.paddingLeft=E+"px"}B.hide();B.style.visibility="";Effect.Appear(B,{duration:0.3})}}catch(A){Prototype.alertError("show: "+A)}}});