jQuery.fn.prettyPopin=function(a){a=jQuery.extend({modal:false,width:false,height:false,opacity:0.5,animationSpeed:"fast"},a);return this.each(function(){$(this).click(function(){if($("#openvid").length&&$("#openvid").hasClass("activeSlide")){$("#prodvideo").hide()}c();d();$.get($(this).attr("href"),function(h){$(".prettyPopin .prettyContent .prettyContent-container").html(h);if(!a.width){a.width=$(".prettyPopin .prettyContent .prettyContent-container").width()+parseFloat($(".prettyPopin .prettyContent .prettyContent-container").css("padding-left"))+parseFloat($(".prettyPopin .prettyContent .prettyContent-container").css("padding-right"));$(".prettyPopin .prettyContent .prettyContent-container").width(a.width)}else{$(".prettyPopin .prettyContent .prettyContent-container").width(a.width)}if(!a.height){a.height=$(".prettyPopin .prettyContent .prettyContent-container").height()+parseFloat($(".prettyPopin .prettyContent .prettyContent-container").css("padding-top"))+parseFloat($(".prettyPopin .prettyContent .prettyContent-container").css("padding-bottom"));$(".prettyPopin .prettyContent .prettyContent-container").height(a.height);a.height=$(".prettyPopin .prettyContent .prettyContent-container").height()+parseFloat($(".prettyPopin .prettyContent .prettyContent-container").css("padding-bottom"));$(".prettyPopin .prettyContent .prettyContent-container").width("auto").height("auto")}else{$(".prettyPopin .prettyContent .prettyContent-container").height(a.height);$(".prettyPopin .prettyContent .prettyContent-container").width("auto").height("auto")}g()});return false});var g=function(){var h=f();$(".prettyPopin").animate({top:($(window).height()/2)+h.scrollTop-(a.height/2),left:($(window).width()/2)+h.scrollLeft-(a.width/2),width:a.width,height:a.height},a.animationSpeed,function(){b()})};var d=function(){$("body").append('<div class="prettyPopin"><a href="#" id="b_close">Close</a><div class="prettyContent"><img src="/imagenes/prettyPopin/loader.gif" alt="Loading" class="loader" /><div class="prettyContent-container"></div></div></div>');var h=f();$(".prettyPopin").width(45).height(45).css({top:($(window).height()/2)+h.scrollTop,left:($(window).width()/2)+h.scrollLeft}).hide().fadeIn(a.animationSpeed);$("a#b_close").click(function(){e();return false})};var c=function(){$("body").append('<div id="overlay"></div>');$("#overlay").css("height",$(document).height());$("#overlay").css("opacity",0).fadeTo(a.animationSpeed,a.opacity);if(!a.modal){$("#overlay").click(function(){e()})}};var b=function(){var h=f();$c=$(".prettyPopin .prettyContent .prettyContent-container");$c.parent().find(".loader").hide();$c.parent().parent().find("#b_close").show();$c.fadeIn(function(){$(this).find("input[type=text]:first").trigger("focus");$("form").bind("submit",function(){$theForm=$(this);$c.fadeOut(function(){$c.parent().find(".loader").show();$.post($theForm.attr("action"),$theForm.serialize(),function(i){$c.html(i);a.width=$c.width()+parseFloat($c.css("padding-left"))+parseFloat($c.css("padding-right"));a.height=$c.height()+parseFloat($c.css("padding-top"))+parseFloat($c.css("padding-bottom"));$(".prettyPopin").animate({top:($(window).height()/2)+h.scrollTop-(a.height/2),left:($(window).width()/2)+h.scrollLeft-(a.width/2),width:a.width,height:a.height},a.animationSpeed,function(){b()})})});return false})});$("a#b_cancel").click(function(){e()})};var e=function(){$("#overlay").fadeOut(a.animationSpeed,function(){$(this).remove()});$(".prettyPopin").fadeOut(a.animationSpeed,function(){$(this).remove()});if($("#openvid").length&&$("#openvid").hasClass("activeSlide")){$("#prodvideo").show()}};var f=function(){scrollTop=window.pageYOffset||document.documentElement.scrollTop||0;scrollLeft=window.pageXOffset||document.documentElement.scrollLeft||0;return{scrollTop:scrollTop,scrollLeft:scrollLeft}}})};