(function(i){var v;var n;var e;var D;var f;var b;var y;var x;var j;var C;var A=function(){if(!n){i("body").append('<div id="jg_popup_overlay"></div><div id="jg_popup_inner"><table id="jg_popup_table" cellpadding="0" cellspacing="0" border="0"><tr><td id="jg_popup_tl"></td><td id="jg_popup_title"></td><td id="jg_popup_tr"><div id="jg_popup_close"></div></td></tr><tr><td id="jg_popup_l"></td><td><div id="jg_popup_content"></div><div id="jg_popup_loader"><div></div></div></td><td id="jg_popup_r"></td></tr><tr><td id="jg_popup_bl"></td><td id="jg_popup_b"></td><td id="jg_popup_br"></td></tr></table><div id="jg_popup_garbage" style="display:none"></div></div>');D=300;v=[];n=true}};var h=function(L){if(v.length>0){var E=v[v.length-1];var F={position:E.fixed?"fixed":"absolute"};if(L){i("#jg_popup_inner").css(E.css)}else{var K=i(window);var J=K.scrollLeft();var I=K.scrollTop();if(E.left!=undefined){F.right="auto";F.left=E.fixed?E.left+"px":J+E.left+"px"}else{if(E.right!=undefined){F.left="auto";F.right=E.fixed?E.right+"px":E.right-J+"px"}else{if(E.center){F.right="auto";var H=(K.width()-i("#jg_popup_inner").outerWidth())/2;F.left=E.fixed?H+"px":J+H+"px"}else{F.right="auto";F.left=E.fixed?"0px":J+"px"}}}if(E.top!=undefined){F.bottom="auto";F.top=E.fixed?E.top+"px":I+E.top+"px"}else{if(E.bottom!=undefined){F.top="auto";F.bottom=E.fixed?E.bottom+"px":E.bottom-I+"px"}else{if(E.center){F.bottom="auto";var G=(K.height()-i("#jg_popup_inner").outerHeight())/2;F.top=E.fixed?G+"px":I+G+"px"}else{F.bottom="auto";F.top=E.fixed?"0px":I+"px"}}}i("#jg_popup_inner").css(F);E.css=F}}};var g=function(G){if(v&&v.length>0){var F=v.length-1;var E=v[F].onClose;v.pop();var J=i("#jg_popup_content > div:eq("+F+")");try{var K=J.find("iframe");for(var H=0;H<K.length;H++){i(K[H]).attr("src","about:blank")}}catch(I){}setTimeout(function(){J.appendTo("#jg_popup_garbage")},0);if(F==0){i("#jg_popup_close").unbind("click.jg_popup");i("#jg_popup_title").unbind("mousedown.jg_popup");i(".jg_popup_scroller").removeClass("jg_popup_scroller").css("overflow","auto")}u(true);if(E){if(G){E.apply(window,G)}else{E()}}}};var d=function(){var F=i("#jg_popup_content");var E=v[v.length-1].width;F.css("width",E=="auto"?"auto":E+"px")};var p=function(){var F=i("#jg_popup_content");var E=v[v.length-1].height;if(v[v.length-1].url){if(E!="auto"){i("#jg_popup_content div:eq("+(v.length-1)+") > iframe.jg_popup_iframe").attr("height",E);var G=(E-i("#jg_popup_loader div").height())/2;i("#jg_popup_loader").css("top",(G+v[v.length-1].loaderVerticalOffset)+"px")}else{i("#jg_popup_content div:eq("+(v.length-1)+") > iframe.jg_popup_iframe").removeAttr("height")}i("#jg_popup_content").height("auto")}else{i("#jg_popup_content").height(E)}};var r=function(){var F=v[v.length-1].title;var E=v[v.length-1].maxTitleLength;if(E&&F&&F.length>E){i("#jg_popup_title").html(F.substring(0,E)+"...")}else{i("#jg_popup_title").html(F||"")}};var s=function(){var F=v[v.length-1].parentScrolling;if(F){i(".jg_popup_scroller").removeClass("jg_popup_scroller").css("overflow","auto")}else{var E=i("body");if(E.css("overflow")=="hidden"){E=E.find("*").filter(function(){return i(this).css("overflow")=="auto"}).first()}E.addClass("jg_popup_scroller").css("overflow","hidden")}};var B=function(){i("#jg_popup_table").removeClass().addClass(v[v.length-1].skinClass)};var c=function(){i("#jg_popup_content").removeClass().addClass(v[v.length-1].contentClass)};var w=function(){i("#jg_popup_inner").removeClass().addClass(v[v.length-1].innerClass)};var q=function(){i("#jg_popup_title")[v[v.length-1].draggable?"addClass":"removeClass"]("jg_popup_draggable")};var t=function(){i("#jg_popup_br")[v[v.length-1].resizable?"addClass":"removeClass"]("jg_popup_resizable")};var a=function(){i("#jg_popup_overlay").css("display",v[v.length-1].overlay?"block":"none")};var z=function(){i("#jg_popup_overlay").css("backgroundColor",v[v.length-1].overlayColor)};var m=function(){i("#jg_popup_overlay").css("opacity",v[v.length-1].opacity/100)};var u=function(H){if(v.length<=0){e=false;i("#jg_popup_overlay, #jg_popup_inner").hide()}else{var E=i("#jg_popup_content > div:eq("+(v.length-1)+")");if(!e){i("#jg_popup_inner").css("visibility","hidden")}else{i("#jg_popup_content > div:lt("+(v.length-1)+")").hide();E.show()}r();d();p();s();B();c();w();q();t();a();z();m();if((v[v.length-1].width=="auto"||v[v.length-1].height=="auto")&&v[v.length-1].center&&E.find("img").length>0&&document.createElement("img").complete!=undefined){var G=E.find("img:eq(0)").get()[0];var F=setInterval(function(){if(G.complete){clearInterval(F);if(v.length>0){h(H);i("#jg_popup_inner").css({visibility:"visible",display:"none"});i("#jg_popup_inner").fadeIn(D,function(){if(v.length>0&&v[v.length-1].onOpen){v[v.length-1].onOpen()}})}}},50)}else{h(H);if(!e){i("#jg_popup_inner").css({visibility:"visible",display:"none"});i("#jg_popup_inner").fadeIn(D,function(){if(v.length>0&&v[v.length-1].onOpen){v[v.length-1].onOpen()}})}else{if(v.length>0&&v[v.length-1].onOpen){v[v.length-1].onOpen()}}}e=true}};var o=function(G){var E=v[v.length-1];if(!E.draggable){return}y=G.pageX;x=G.pageY;var I=i("#jg_popup_inner").offset();var F=i("#jg_popup_inner").css("position")=="fixed";var H=i(window);f=I.left-(F?H.scrollLeft():0);b=I.top-(F?H.scrollTop():0);if(E.onDragStart){E.onDragStart(E)}i('<div id="jg_drag_aid"></div>').css({opacity:0,background:"#000",width:"100%",height:"100%",position:"fixed",left:0,top:0,cursor:"move"}).appendTo("#jg_popup_content");i(document).unbind("mousemove.jg_popup_drag").bind("mousemove.jg_popup_drag",function(M){var L=(f+(M.pageX-y));var K=(b+(M.pageY-x));var J={left:L+"px",top:K+"px",right:"auto",bottom:"auto"};i("#jg_popup_inner").css(J);E.left=L;E.top=K;E.css=J;if(E.onDrag){E.onDrag(E)}}).unbind("mouseup.jg_popup_drag").bind("mouseup.jg_popup_drag",function(J){i("#jg_drag_aid").remove();i(this).unbind(".jg_popup_drag");if(E.onDragEnd){E.onDragEnd(E)}})};var k=function(F){var E=v[v.length-1];if(!E.resizable){return}y=F.pageX;x=F.pageY;j=E.width;if(j=="auto"){j=i("#jg_popup_content").width()}C=v[v.length-1].height;if(C=="auto"){C=i("#jg_popup_content").height()}if(E.onResizeStart){E.onResizeStart(E)}i('<div id="jg_drag_aid"></div>').css({opacity:0,background:"#000",width:"100%",height:"100%",position:"fixed",left:0,top:0,cursor:"move"}).appendTo("#jg_popup_content");i(document).unbind("mousemove.jg_popup_resize").bind("mousemove.jg_popup_resize",function(G){v[v.length-1].width=j+(G.pageX-y);v[v.length-1].height=C+(G.pageY-x);d();p();if(E.onResize){E.onResize(E)}}).unbind("mouseup.jg_popup_resize").bind("mouseup.jg_popup_resize",function(G){i("#jg_drag_aid").remove();i(this).unbind(".jg_popup_resize");if(E.onResizeEnd){E.onResizeEnd(E)}})};var l=function(E){return(v&&v.length>0)?v[v.length-1][E]:null};i.jeegoopopup={open:function(F){A();try{i("#jg_popup_garbage").empty()}catch(G){}var E=i.extend({width:"auto",height:"auto",scrolling:"auto",skinClass:"jg_popup_basic",contentClass:"customContentStyle",innerClass:"customInnerClass",fixed:true,center:true,overlay:true,overlayColor:"#000",opacity:50,loaderVerticalOffset:0,parentScrolling:true,draggable:true,resizable:true},F||{});v.push(E);if(F&&F.fadeIn!=undefined){D=F.fadeIn}if(v.length>1&&!E.center){var H=i("#jg_popup_inner").offset();if(E.top==undefined&&E.bottom==undefined){E.top=E.fixed?H.top-i(window).scrollTop():H.top}if(E.left==undefined&&E.right==undefined){E.left=E.fixed?H.left-i(window).scrollLeft():H.left}}if(E.url){var J="jgpopup"+Math.random().toString().replace(/\D/,"");i("#jg_popup_loader").css("visibility","visible");i("#jg_popup_content").append('<div><iframe id="'+J+'" class="jg_popup_iframe" onload="(function(){$(\'#jg_popup_loader\').css(\'visibility\', \'hidden\');})()" frameborder="0" scrolling="'+E.scrolling+'" width="100%" '+(E.height=="auto"?"":'height="'+E.height+'px" ')+'src="'+E.url+'"></iframe></div>')}else{var I=E.scrolling;if(I=="yes"){I="scroll"}else{if(I=="no"){I="hidden"}}i("#jg_popup_content").append('<div style="width:100%;height:100%;overflow:'+I+'">'+(E.html||"")+"</div>")}if(v.length==1){i("#jg_popup_close").unbind("click.jg_popup").bind("click.jg_popup",function(){g()});i("#jg_popup_title").unbind("mousedown.jg_popup").bind("mousedown.jg_popup",o);i("#jg_popup_br").unbind("mousedown.jg_popup").bind("mousedown.jg_popup",k)}u()},close:function(){g(arguments)},opacity:function(E){if(E==undefined){return l("opacity")}else{if(v&&v.length>0){v[v.length-1].opacity=E;m()}}return this},overlay:function(E){if(E==undefined){return l("overlay")}else{if(v&&v.length>0){v[v.length-1].overlay=E;a()}}return this},overlayColor:function(E){if(E==undefined){return l("overlayColor")}else{if(v&&v.length>0){v[v.length-1].overlayColor=E;z()}}return this},draggable:function(E){if(E==undefined){return l("draggable")}else{if(v&&v.length>0){v[v.length-1].draggable=E;q()}}return this},resizable:function(E){if(E==undefined){return l("resizable")}else{if(v&&v.length>0){v[v.length-1].resizable=E;t()}}return this},fixed:function(E){if(E==undefined){return l("fixed")}else{if(v&&v.length>0){v[v.length-1].fixed=E;h()}}return this},height:function(E){if(E==undefined){return l("height")}else{if(v&&v.length>0){v[v.length-1].height=E;p()}}return this},width:function(E){if(E==undefined){return l("width")}else{if(v&&v.length>0){v[v.length-1].width=E;d()}}return this},top:function(E){if(E==undefined){return l("top")}else{if(v&&v.length>0){v[v.length-1].top=E;i("#jg_popup_inner").css({top:l("fixed")?E+"px":i(window).scrollTop()+E+"px",bottom:"auto"})}}return this},left:function(E){if(E==undefined){return l("left")}else{if(v&&v.length>0){v[v.length-1].left=E;i("#jg_popup_inner").css({left:l("fixed")?E+"px":i(window).scrollLeft()+E+"px",right:"auto"})}}return this},right:function(E){if(E==undefined){return l("right")}else{if(v&&v.length>0){v[v.length-1].right=E;v[v.length-1].left=undefined;i("#jg_popup_inner").css({right:l("fixed")?E+"px":E-i(window).scrollLeft()+"px",left:"auto"})}}return this},bottom:function(E){if(E==undefined){return l("bottom")}else{if(v&&v.length>0){v[v.length-1].bottom=E;v[v.length-1].top=undefined;i("#jg_popup_inner").css({bottom:l("fixed")?E+"px":E-i(window).scrollTop()+"px",top:"auto"})}}return this},title:function(E){if(E==undefined){return l("title")}else{if(v&&v.length>0){v[v.length-1].title=E;r(E,v[v.length-1].maxTitleLength)}}return this},maxTitleLength:function(E){if(E==undefined){return l("maxTitleLength")}else{if(v&&v.length>0){v[v.length-1].maxTitleLength=E;r(v[v.length-1].title,E)}}return this},skinClass:function(E){if(E==undefined){return l("skinClass")}else{if(v&&v.length>0){v[v.length-1].skinClass=E;B()}}return this},contentClass:function(E){if(E==undefined){return l("contentClass")}else{if(v&&v.length>0){v[v.length-1].contentClass=E;c()}}return this},innerClass:function(E){if(E==undefined){return l("innerClass")}else{if(v&&v.length>0){v[v.length-1].innerClass=E;w()}}return this},parentScrolling:function(E){if(E==undefined){return l("parentScrolling")}else{if(v&&v.length>0){v[v.length-1].parentScrolling=E;s()}}return this},center:function(){if(v&&v.length>0){var I=i(window);var E=v[v.length-1];var H=(I.width()-i("#jg_popup_inner").outerWidth())/2;var G=(I.height()-i("#jg_popup_inner").outerHeight())/2;var F={left:E.fixed?H+"px":I.scrollLeft()+H+"px",top:E.fixed?G+"px":I.scrollTop()+G+"px",right:"auto",bottom:"auto"};E.css=F;i("#jg_popup_inner").css(F)}return this},refresh:function(){if(v&&v.length>0){var E=i("#jg_popup_content div:eq("+(v.length-1)+") > iframe.jg_popup_iframe");if(E.length>0){E[0].contentDocument.location.reload(true)}}return this}}})(jQuery);