/* Copyright (c) 2009 Alvaro A. Lima Jr http://alvarojunior.com/jquery/joverlay.html
 * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * Version: 0.5 (Abr 22, 2009)
 * Requires: jQuery 1.3+
 */
(function($){var j=$.browser.msie&&parseInt($.browser.version)==6;var k=null;$.fn.jOverlay=function(c){if(k!=null){clearTimeout(k)}var c=$.extend({},$.fn.jOverlay.options,c);var d=c.imgLoading?"<img id='jOverlayLoading' src='"+c.imgLoading+"' />":'';var e=d+"<div id='jOverlay'></div><div id='jOverlayContent' style='display:none;'></div>";e=j?"<iframe id='jOverlayIframe'></iframe>"+e:e;var f=$(window).width();var g=$(document).height();var h=j?'absolute':'fixed';$('body').prepend(e);$('#jOverlayLoading').css({position:h,zIndex:c.zIndex+50}).load(function(){if(c.center){$.center(this)}});$('#jOverlayContent').css({position:h,zIndex:c.zIndex+1}).show();if(this.is('*')){$('#jOverlayContent').css({height:this.height(),width:this.width()}).html(this.addClass('jOverlayChildren').show()).show();if(c.center){$.center('#jOverlayContent')}}if(this.is('*')&&c.url){$(this).load(c.url,c.data,function(a){$('#jOverlayLoading').fadeOut(600);if($.isFunction(c.success)){c.success(a)}})}else{if(c.url){$.ajax({type:c.method,data:c.data,url:c.url,success:function(a){$('#jOverlayLoading').fadeOut(600);$('#jOverlayContent').html(a).show();if(c.center){$.center('#jOverlayContent')}if($.isFunction(c.success)){c.success(a)}}})}else if(!this.is('*')){$('#jOverlayContent').html("<div style='background:#FFF;'>Element not found!<br/>Press ESC!</div>")}else{$('#jOverlayLoading').fadeOut(600);$('#jOverlayContent').show();if($.isFunction(c.success)){c.success(this.html())}}}if(j){$('#jOverlayIframe').css({backgroundColor:'#FFF',border:'none',filter:'alpha(opacity=0)',opacity:0,position:'absolute',top:'0px',left:'0px',zIndex:c.zIndex-5,width:f+'px',height:g+'px'}).show()}$('#jOverlay').css({backgroundColor:c.color,position:h,top:'0px',left:'0px',filter:'alpha(opacity='+(c.opacity*100)+')',opacity:c.opacity,zIndex:c.zIndex,width:f+'px',height:!j?$(window).height()+'px':g+'px'}).show('fast');if(j){$(window).scroll(function(){if(c.center){$.center('#jOverlayContent')}})}$(window).resize(function(){var a=$(window).width();var b=$(document).height();if(j){$('#jOverlayIframe').css({width:a+'px',height:b+'px'})}$('#jOverlay').css({width:a+'px',height:b+'px'});if(c.center){$.center('#jOverlayContent')}});$(document).keydown(function(a){if(a.keyCode==27){$.closeOverlay()}});if(c.bgClickToClose){$('#jOverlay').click($.closeOverlay)}if(Number(c.timeout)>0){k=setTimeout($.closeOverlay,Number(c.timeout))}};$.center=function(a){var a=$(a);var b=a.height();var c=a.width();var d=$(window).width();var e=$(window).height();var f=$(window).scrollLeft();var g=$(window).scrollTop();var h=(f+Math.floor((d-c)/2));var i=(g+Math.floor((e-b)/2));var t=i-g;var l=h-f;if(j){t=((i!=null&&i>0)?i:'0');l=((h!=null&&h>0)?h:'0')}a.css({top:t+'px',left:l+'px'})};$.fn.jOverlay.options={method:'GET',data:'',url:'',color:'#000',opacity:'0.6',zIndex:9999,center:true,imgLoading:'',bgClickToClose:true,success:null,timeout:0};$.closeOverlay=function(){$('#jOverlayContent .jOverlayChildren').hide().prependTo($('body'));$('#jOverlayLoading, #jOverlayContent, #jOverlayIframe, #jOverlay').remove()}})(jQuery);
