Prototype.require("jojoPopup.js");Prototype.require("buttons.js?10");adminOverlay=Class.create({options:{},oPopup:null,oWaitPopup:null,initialize:function(c,d){Prototype.require("superadmin/overlay.css");try{this.options={id:c,zIndex:105,showWaitingPopup:false,divAppend:null,onHide:function(){},onShow:function(){},headercolor:"headerOverlayBlue",automoveToBody:false,sLanguage:"auto"};Object.extend(this.options,d||{});var b=this;if(this.options.sLanguage=="auto"){if(typeof sJavascriptLang!="undefined"){this.options.sLanguage=sJavascriptLang}else{this.options.sLanguage="fr"}}Prototype.require("langs/superadmin."+this.options.sLanguage+".js");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{if(typeof(listCalendar)!="undefined"&&Object.isArray(listCalendar)){listCalendar.each(function(b){if(b!=null){b.hide()}})}}catch(a){}},repositionCalendar:function(){try{if(typeof(listCalendar)!="undefined"&&Object.isArray(listCalendar)){listCalendar.each(function(b){if(b!=null){b.reposition()}})}}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);if(this.options.divAppend==null){this.oPopup.element.insert({after:a})}else{$(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"})}if(this.oPopup.visible()){this.oPopup.onResize()}},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).updateEx(xhr.responseText);thisParent.hideBackgroundWaitingPopup();try{eval(afterFinish)}catch(ex){Prototype.alertError("Overlay afterFinish : "+ex)}thisParent.reposition();thisParent.hideWaiting()}catch(Exc){Prototype.alertWarning("contenu overlay frelate, updateEx(): "+Exc)}}})}catch(exception){Prototype.alertError("updateDivContent - "+exception+"\n"+Prototype.Browser.backtrace().join("nn"))}},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(){}});
