(function($){if(!$){return}var jqPopupID="jqPopup";$(function(){if($("#"+jqPopupID).length==0){var s="#"+jqPopupID+"{width: 100%; height: 100%; position: absolute; top: 0; left: 0; z-index: 1000; display: none;}#"+jqPopupID+"_bg{background-color: #000; opacity: 0; height: 100%; width: 100%; filter:alpha(opacity=0);}#"+jqPopupID+"_content{overflow: auto;background-color:#fafafa;position:absolute;padding:10px;-moz-box-shadow:0px 0px 5px #000;-webkit-box-shadow:0px 0px 5px #000;box-shadow:0px 0px 5px #000;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;height:auto;width:auto;}#"+jqPopupID+"_close{-moz-border-radius:25px; -webkit-border-radius:25px; border-radius:25px; background-color:#FAFAFA; color:#666666; cursor:pointer; font-family: Trebuchet MS; font-size: 14px; font-weight:bold; height:25px; line-height:22px; position:absolute; margin: -12px 0px 0px -13px; text-align:center; width:25px;}#"+jqPopupID+"_close.over{color: #FDFDFD; background-color:#666666;}#"+jqPopupID+"_close .shadow{-moz-box-shadow:0px 0px 5px #000; -webkit-box-shadow:0px 0px 5px #000; box-shadow:0px 0px 5px #000; -moz-border-radius:25px; -webkit-border-radius:25px; border-radius:25px; height:100%; position:absolute; width:100%; z-index:-1;}#"+jqPopupID+".error #"+jqPopupID+"_content{-moz-box-shadow:0px 0px 5px #800;-webkit-box-shadow:0px 0px 5px #800;box-shadow:0px 0px 5px #800;}#"+jqPopupID+".error #"+jqPopupID+"_close .shadow{-moz-box-shadow:0px 0px 8px #a00; -webkit-box-shadow:0px 0px 8px #a00; box-shadow:0px 0px 8px #a00;}";$('<style type="text/css">'+s+"</style>").appendTo("head");$('<div id="'+jqPopupID+'"/>').append('<div id="'+jqPopupID+'_bg"/><div id="'+jqPopupID+'_content"/><div id="'+jqPopupID+'_close"><div class="shadow"/>x</div>').appendTo("body");window.$jqPopup=$("#"+jqPopupID);window.$jqPopup_bg=$("#"+jqPopupID+"_bg");window.$jqPopup_close=$("#"+jqPopupID+"_close");window.$jqPopup_content=$("#"+jqPopupID+"_content");$jqPopup_close.hover(function(){$(this).addClass("over")},function(){$(this).removeClass("over")}).click(function(){$("*[popup-active]:first").unPopUp()});window.$jqPopup_interval={interval:null,exec:function(){var t=$jqPopup_content.offset().top,l=($jqPopup_content.offset().left+$jqPopup_content.outerWidth(false));$jqPopup_close.css({top:t,left:l})},init:function(){this.popupInterval=setInterval(this.exec,25)},stop:function(){clearInterval(this.popupInterval)}};window.jqPopupBusy=false}$.unPopUp=function(){$jqPopup_close.click()};$.fn.unPopUp=function(){var $t=$(this);if(window.$jqPopupHistory&&$jqPopupHistory.length>0){$jqPopup.removeClass("error");var $ret=$jqPopupHistory.pop();var size=$ret.attr("size").split("x");$ret.removeAttr("size");var retH=size[1],retW=size[0];var ctnH=$jqPopup_content.height(),ctnW=$jqPopup_content.width();var h=(retH-ctnH),w=(retW-ctnW);var wSum=w>0?"+=":"-=";var hSum=h>0?"+=":"-=";var $win=$(window),winH=$win.height(),winW=$win.width(),sT=$win.scrollTop();var top=(sT+(winH-retH)/2);var left=(winW-retW)/2;if(w>=0.9*winW){left=0}if(h>=0.9*winH){top=winH*0.05+sT}$t.removeAttr("popup-active");$t.css(eval("new Object("+$t.attr("popupCSS")+")")).removeAttr("popupCSS");$jqPopup_content.offset({top:"50%",left:"50%"});$jqPopup_content.width(ctnW).height(ctnH);$jqPopup_content.animate({height:hSum+Math.abs(h),width:wSum+Math.abs(w),top:top,left:left},500,function(){$ret.fadeIn(100);$jqPopup_content.css({width:"auto",height:"auto"});var queueIdx=$ret.attr("popup-queue");$ret.removeAttr("popup-queue");var $pb=$("[popup-back-queue="+queueIdx+"]");$pb.attr("popup-back",$pb.attr("popup-back-queue-el"));$pb.removeAttr("popup-back-queue");$pb.removeAttr("popup-back-queue-el");$ret.attr("popup-active","true")});var $back=$("*[popup-back]:first");if($back.attr("popup-back")=="parentElement"){$t.appendTo($back)}else{if($back.attr("popup-back")=="nextElement"){$t.insertBefore($back)}else{$t.appendTo("body")}}$back.removeAttr("popup-back");if($t.attr("popupClose")){var __fn=$t.attr("popupClose")+"('"+$t.attr("id")+"');";$t.removeAttr("popupClose");eval(__fn)}}else{$jqPopup.fadeOut(300,function(){$jqPopup.removeClass("error");$jqPopup_interval.stop();$jqPopup_bg.css("opacity",0);$t.removeAttr("popup-active");$t.css(eval("new Object("+$t.attr("popupCSS")+")")).removeAttr("popupCSS");var $back=$("*[popup-back]:first");if($back.attr("popup-back")=="parentElement"){$t.appendTo($back)}else{if($back.attr("popup-back")=="nextElement"){$t.insertBefore($back)}else{$t.appendTo("body")}}$back.removeAttr("popup-back");if($t.attr("popupClose")){var __fn=$t.attr("popupClose")+"('"+$t.attr("id")+"');";$t.removeAttr("popupClose");eval(__fn);$("object").css("visibility","")}})}};$.fn.popUp=function(options){var $el=$(this);if($el.attr("popup-active")){return}var h=$el.outerHeight(false);var w=$el.outerWidth(false);var $win=$(window),winH=$win.height(),winW=$win.width(),sT=$win.scrollTop();var top=(sT+(winH-h)/2);var left=(winW-w)/2;if(w>=0.9*winW){left=0}if(h>=0.9*winH){top=winH*0.05+sT}var settings=$.extend({opacity:"0.5",showClose:true,keepEditor:false,fnClose:function(){},fnOpen:function(){}},options);if($jqPopup.is(":visible")){var $t=$("*[popup-active]:first");var $back=$("*[popup-back]:first");$t.removeAttr("popup-active");$jqPopup.removeClass("error");if(settings.keepEditor){if(!window.$jqPopupHistory){window.$jqPopupHistory=[]}$back.attr("popup-back-queue",$jqPopupHistory.length);$back.attr("popup-back-queue-el",$back.attr("popup-back"));$back.removeAttr("popup-back");$t.attr("popup-queue",$jqPopupHistory.length);$t.attr("size",$t.outerWidth(false)+"x"+$t.outerHeight(false)).hide();$jqPopupHistory.push($t)}else{if($t.attr("popupClose")){$t.css(eval("new Object("+$t.attr("popupCSS")+")")).removeAttr("popupCSS");if($back.attr("popup-back")=="parentElement"){$t.appendTo($back)}else{if($back.attr("popup-back")=="nextElement"){$t.insertBefore($back)}else{$t.appendTo("body")}}$back.removeAttr("popup-back");var __fn=$t.attr("popupClose")+"('"+$t.attr("id")+"');";$t.removeAttr("popupClose");eval(__fn)}}$jqPopup_close.css({top:sT+winH/2,left:winW/2});$jqPopup_content.css({top:sT+winH/2,left:winW/2,height:0,width:0});if(!settings.showClose){$jqPopup_interval.stop();$jqPopup_close.hide()}if(settings.error){$jqPopup.addClass("error")}$jqPopup_content.animate({height:h,width:w,top:top,left:left},500,function(){$jqPopup_content.css({width:"auto",height:"auto"});$el.attr("popupClose",("("+settings.fnClose+")").replace(/\s+/g," "));if($el.next().length){$el.next().attr("popup-back","nextElement")}else{$el.parent().attr("popup-back","parentElement")}var style='{"float":"'+$el.css("float")+'","display":"'+$el.css("display")+'"}';$el.attr("popup-active","true").attr("popupCSS",style).css("float","left").show().appendTo($jqPopup_content);settings.fnOpen()})}else{$jqPopup_content.hide();$jqPopup_close.hide();var maxHeight=winH;$("html,body,#contentAll,#geral").each(function(){var $t=$(this);var h=0;try{h=$t.outerHeight(true)}catch(e){h=$t.height()}if(maxHeight<h){maxHeight=h}});$jqPopup.css("height",maxHeight).show();$("object").css("visibility","hidden");$jqPopup_bg.animate({opacity:settings.opacity},300,function(){if(settings.showClose){$jqPopup_interval.init();$jqPopup_close.css({top:sT+winH/2,left:winW/2}).show()}if(settings.error){$jqPopup.addClass("error")}$jqPopup_content.css({top:sT+winH/2,left:winW/2}).show().animate({height:h,width:w,top:top,left:left},500,function(){$jqPopup_content.css({width:"auto",height:"auto"});$el.attr("popupClose",("("+settings.fnClose+")").replace(/\s+/g," "));if($el.next().length){$el.next().attr("popup-back","nextElement")}else{$el.parent().attr("popup-back","parentElement")}var style='{"float":"'+$el.css("float")+'","display":"'+$el.css("display")+'"}';$el.attr("popup-active","true").attr("popupCSS",style).css("float","left").show().appendTo($jqPopup_content);settings.fnOpen()})})}}})})(jQuery);
