(function($){$.fn.popup=function(options){var heightScreen=$(this).outerHeight();var widthScreen=$(this).outerWidth();var defaults={background:{id:'bg-popup',css:{'background':'#000','opacity':'0.5','z-index':'5000','position':'absolute','overflow':'hidden'},removeOnClick:true},popup:{id:'popup',css:{'width':'535px','height':'265px','z-index':'5500','position':'absolute','border':'3px solid #d02a26','background':'#ffffff'}}};options=$.extend(true,defaults,options);options.background.css.height=heightScreen;options.background.css.width='100%';options.background.css.top='0';options.popup.css.top=(($(window).height()/2)-(parseInt(options.popup.css.height)/2))+$(window).scrollTop();options.popup.css.left=(widthScreen/2)-(parseInt(options.popup.css.width)/2);var myBg=$("<div></div>").hide().attr("id",options.background.id).css(options.background.css).appendTo(this);var myPopup=$("<div></div>").hide().attr("id",options.popup.id).css(options.popup.css).appendTo(this);if(options.ajax){if(!options.data)options.data='';$.ajax({type:"POST",url:options.ajax,data:options.data,success:function(html){myPopup.html(html);popupClickRemove();if(options.callback){eval(options.callback);}}});}
if(options.content){myPopup.html(options.content);popupClickRemove();if(options.callback){eval(options.callback);}}
if(options.background.removeOnClick){myBg.click(function(event){removePopup();});}
$("select").css('visibility','hidden');myBg.show();myPopup.fadeIn();function popupClickRemove(){if(options.popup.removeOnClick){$.each(options.popup.removeOnClick,function(key,value){$(value).css("cursor","pointer").live('click',function(event){removePopup();});});}}
function removePopup(){myPopup.fadeOut(function(){myPopup.remove();myBg.remove();$("select").css('visibility','visible');});}};})(jQuery);
