(function(b){b.fn.apriPopup=function(a){a=jQuery.extend({target:"",width:"400",height:"400",wname:"popup"},a);return this.each(function(){var c=(screen.width-a.width)/2,d=(screen.height-a.height)/2,i=a.target?a.target:b(this).attr("href");window.open(i,a.wname,"height="+a.height+", width="+a.width+", top="+d+",left="+c+",scrollbars=no, resizable=0, menubar=0, toolbar=0, location=0, statusbar=0, fullscreen=0")})};b.fn.blocca=function(a){a=jQuery.extend({color:"#000",opacity:"0.2",cursor:"wait",spinner:"spinner.gif"}, a);return this.each(function(){var c=b(this),d=c.css("position"),i=b.browser.msie&&parseInt(b.browser.version)==6&&typeof window.XMLHttpRequest!="object",e=c.innerWidth(),h=c.innerHeight();if(c.find(".elemOverlay").length==0){d=="static"&&c.css({position:"relative",zoom:"1"});if(i){d=c.height()+"px";c.find("select").hide();c.css({height:d})}c.prepend('<div class="elemOverlay" />');c.find(".elemOverlay").css({width:e+"px",height:h+"px","z-index":"5001",background:a.color+' url("img/'+a.spinner+'") 50% 50% no-repeat', position:"absolute",top:"0",left:"0",filter:"alpha(opacity="+a.opacity*100+")","-khtml-opacity":a.opacity,"-moz-opacity":a.opacity,opacity:a.opacity,cursor:a.cursor,display:"none"}).fadeIn()}})};b.fn.sblocca=function(){return this.each(function(){if(b(this).find(".elemOverlay").length!=0){b(this).find(".elemOverlay").fadeOut().remove();b(this).find("select").show()}})};b.fn.apriModale=function(a){a=jQuery.extend({target:"",color:"#fff",opacity:"0.8",divToLoad:"#modale",spinner:"spinner.gif",altClose:"#chiudi"}, a);var c=b.browser.msie&&parseInt(b.browser.version)==6&&typeof window.XMLHttpRequest!="object";return this.each(function(){function d(j){var f=b(j).outerHeight()/2;if(f==0){alert("Il contenuto che si vuole aprire non esiste!");i()}else{a.prepend!=undefined&&a.prepend();b(j).css({margin:"0 auto",position:"relative",top:-1*Math.abs(f-40)+"px",display:"block",opacity:"0"}).append('<a href="#" id="btn_modal_close">Chiudi</a>').animate({opacity:"1"},500,function(){b.support.opacity||b(this).get(0).style.removeAttribute("filter"); a.callback!=undefined&&a.callback()})}}function i(){if(b(g).length){b(g).appendTo("body");b(g).hide();b("#modaleOverlay").remove();b("#btn_modal_close").remove()}b("#modaleOverlay").remove();b("#orizzonte").remove()}(function(){var j=b("body").outerHeight(),f=b(window).height(),l=b("html").scrollTop();if(c){var k="absolute";f=l+f/2}else{k="fixed";f=f/2}b("body").append('<div id="modaleOverlay" /><div id="orizzonte" />');b("#modaleOverlay").css({width:"100%",height:j+"px","z-index":"5000",background:a.color, position:k,top:"0",left:"0","text-align":"center",filter:"alpha(opacity="+a.opacity*100+")","-khtml-opacity":a.opacity,"-moz-opacity":a.opacity,opacity:a.opacity});b("#orizzonte").css({width:"100%",height:"50px","z-index":"5001",position:k,top:f-25+"px",left:"0","text-align":"center",overflow:"visible",background:'url("img/'+a.spinner+'") 50% 50% no-repeat'})})();if(a.target)var e=a.target,h=a.target;else{e=b(this).attr("href");h=b(this).attr("target")}if(e.length>1&&e.substr(0,1)=="#"){a.mode="locale"; var g=b(e);b(g).appendTo("div#orizzonte");d(e)}else{a.mode="remoto";if(h.length>1&&h.substr(0,1)=="#"){g=e+" "+h;b("div#orizzonte").load(g,null,function(){d(h)})}else{g=e+" "+a.divToLoad;b("div#orizzonte").load(g,null,function(){d(a.divToLoad)})}}b("a#btn_modal_close, "+a.altClose).live("click",function(){i();return false})})}})(jQuery);
