owt.loadingOverlay=new YAHOO.widget.Overlay("owt-ov-loading",{visible:false,width:"40px",effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25}});var loadingOverlayAlign=function(){var ovWidth=owt.loadingOverlay.cfg.getProperty("width").replace("px","");owt.loadingOverlay.moveTo(Dom.getDocumentWidth()/2-ovWidth/2,Dom.getDocumentScrollTop())};owt.loadingOverlay.beforeShowEvent.subscribe(loadingOverlayAlign);owt.loadingOverlay.showEvent.subscribe(owt.loadingOverlay.bringToTop);owt.loadingOverlay.setBody('<div class="owt-loader"></div>');YAHOO.widget.Overlay.windowScrollEvent.subscribe(loadingOverlayAlign);YAHOO.widget.Overlay.windowResizeEvent.subscribe(loadingOverlayAlign);var miniDialogConfig={fixedcenter:true,visible:false,width:"300px",height:"200px",effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25}};owt.smallDialogs={};owt.smallDialogs.focusCloseLink=function(){Dom.getElementsByClassName("owt-confirm-dismiss","div",this.body,function(el){try{el.getElementsByTagName("a")[0].focus()}catch(e){}})};owt.smallDialogs.alert=new YAHOO.widget.Overlay("owt-ov-alert",miniDialogConfig);owt.smallDialogs.alert.setBody("");owt.smallDialogs.alert.hideEvent.subscribe(owt.dialogsManager.focusLastVisible,null,owt.dialogsManager);owt.smallDialogs.alert.showEvent.subscribe(owt.smallDialogs.focusCloseLink);owt.smallDialogs.alert.showEvent.subscribe(owt.smallDialogs.alert.bringToTop);owt.smallDialogs.message=new YAHOO.widget.Overlay("owt-ov-message",miniDialogConfig);owt.smallDialogs.message.setBody("");owt.smallDialogs.message.showEvent.subscribe(owt.smallDialogs.focusCloseLink);owt.smallDialogs.message.hideEvent.subscribe(owt.dialogsManager.focusLastVisible,null,owt.dialogsManager);owt.smallDialogs.information=new YAHOO.widget.Overlay("owt-ov-information",miniDialogConfig);owt.smallDialogs.information.setBody("");owt.smallDialogs.information.showEvent.subscribe(owt.smallDialogs.focusCloseLink);owt.smallDialogs.information.hideEvent.subscribe(owt.dialogsManager.focusLastVisible,null,owt.dialogsManager);owt.smallDialogs.dialogloading=new YAHOO.widget.Overlay("owt-ov-dialogloading",miniDialogConfig);owt.smallDialogs.dialogloading.cfg.height="20px";owt.smallDialogs.dialogloading.setBody("");owt.smallDialogs.dialogloading.showEvent.subscribe(owt.smallDialogs.dialogloading.bringToTop);owt.dialogsManager.register(owt.smallDialogs.alert);owt.dialogsManager.register(owt.smallDialogs.information);owt.dialogsManager.register(owt.smallDialogs.message);owt.dialogsManager.register(owt.smallDialogs.dialogloading);owt.smallDialogs.renderAll=function(){owt.smallDialogs.alert.render(owtRenderContainer);owt.smallDialogs.information.render(owtRenderContainer);owt.smallDialogs.message.render(owtRenderContainer);owt.smallDialogs.dialogloading.render(owtRenderContainer);owt.loadingOverlay.render(owtRenderContainer)};owt.notify=function(text){if(!arguments[1]){var config={type:"message",inline:false}}else{var config=arguments[1];if(!config.inline){config.inline=false}if(!config.type){config.type="message"}}if(config.inline){var alertP=document.createElement("p");alertP.innerHTML=text;alertP.setAttribute("title","Clicca per nascondere il messaggio.");Dom.addClass(alertP,"owt-message");Dom.addClass(alertP,"type-"+config.type);var hide=function(){var eff=new YAHOO.widget.Effects.Fade(alertP,{seconds:0.5});eff.onEffectComplete.subscribe(function(){Dom.get("owt-alert").removeChild(alertP)})};Event.addListener(alertP,"click",hide);Dom.get("owt-alert").appendChild(alertP);new YAHOO.widget.Effects.Appear(alertP,{seconds:1});if(config.type=="message"){setTimeout(function(){hide()},10000)}}else{var ov=owt.smallDialogs[config.type];var newBody=document.createElement("div");Dom.addClass(newBody,"owt-confirm");Dom.addClass(newBody,config.type);Event.addListener(newBody,"click",function(){ov.hide()});if(ov.cfg.getProperty("visible")){var bodyContent=ov.body.getElementsByTagName("p")[0];bodyContent.innerHTML=text+'<span class="hr"></span>'+bodyContent.innerHTML}else{newBody.innerHTML+="<p>"+text+"</p>";newBody.innerHTML+='<div class="owt-confirm-dismiss"><a href="#" onclick="return false;">Chiudi</a></div>';ov.setBody(newBody)}ov.show();if(config.timeout!==undefined){setTimeout(function(){ov.hide()},config.timeout)}owt.dialogsManager.focus(ov)}return true};owt.showError=function(txt){owt.notify(txt,{type:"error",inline:false})};owt.showMessage=function(txt){owt.notify(txt,{type:"message",inline:false})};owt.showLoading=function(message){var newBody=document.createElement("div");Dom.addClass(newBody,"owt-dialogloading");newBody.innerHTML=message;owt.smallDialogs.dialogloading.setBody(newBody);owt.smallDialogs.dialogloading.show()};owt.hideLoading=function(){owt.smallDialogs.dialogloading.hide()};
