/* Copyright (c) 2009 Alvaro A. Lima Jr http://alvarojunior.com
 * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * Version: 0.1b (Fev 20, 2009)
 * Requires: jQuery 1.3+
 */
(function($){$.fn.jOverlay=function(b){var c=$.browser.msie&&parseInt($.browser.version)==6;var b=$.extend({},$.fn.jOverlay.options,b);var d=c?"<iframe id='jOverlayIframe'></iframe><div id='jOverlay'></div><div id='jOverlayContent'></div>":"<div id='jOverlay'></div><div id='jOverlayContent'></div>";var e=$(window).width();var f=$(document).height();$('body').prepend(d);$("#jOverlayContent").css({position:'absolute',zIndex:b.zIndex+1});if(this.is('*')){$('#jOverlayContent').css({height:this.height()+'px',width:this.width()+'px'}).append(this.hide().clone().attr('id','jOverlayClone').show('show'))}if(this.is('*')&&b.url){$("#jOverlayClone").load(b.url,b.data)}else{if(b.url){$.ajax({type:b.method,data:b.data,url:b.url,success:function(a){$("#jOverlayContent").hide().html(a);if(b.center){$.center("#jOverlayContent")}$("#jOverlayContent").show('show')}})}else if(!this.is('*')){$('#jOverlayContent').append("<div style='background:#FFF;'>Element not found!<br/>Press ESC!</div>")}}if(c){$('#jOverlayIframe').css({backgroundColor:'#FFF',border:'none',filter:'alpha(opacity=0)',opacity:0,position:'absolute',top:'0px',left:'0px',zIndex:'100',width:e+'px',height:f+'px'}).show()}$('#jOverlay').css({backgroundColor:b.color,display:'block',position:'absolute',top:'0px',left:'0px',filter:'alpha(opacity='+(b.opacity*100)+')',opacity:b.opacity,zIndex:b.zIndex,width:e+'px',height:f+'px'}).fadeTo(300,b.opacity);$(window).scroll(function(){if(b.center){$.center('#jOverlayContent')}});$(window).resize(function(){e=$(window).width();f=$(document).height();if(c){$('#jOverlayIframe').css({width:e+'px',height:f+'px'})}$('#jOverlay').css({width:e+'px',height:f+'px'});if(b.center){$.center('#jOverlayContent')}});$(document).keydown(function(a){if(a.keyCode==27){$.closeOverlay()}});if(b.center){$.center('#jOverlayContent')}};$.center=function(a){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!=null&&i>0)?i:'0')+'px';var l=((h!=null&&h>0)?h:'0')+'px';a.css({top:t,left:l,position:'absolute'})};$.fn.jOverlay.options={method:'GET',data:'',url:'',color:'#000',opacity:'0.6',zIndex:9999,center:true};$.closeOverlay=function(){$('#jOverlayClone, #jOverlayContent, #jOverlayIframe, #jOverlay').remove()}})(jQuery);

