(function(a){a.fn.popeye=function(b){function d(a,b){if(window.console&&window.console.log&&c.debug){if(b=="info"&&window.console.info){window.console.info(a)}else if(b=="warn"&&window.console.warn){window.console.warn(a)}else{window.console.log(a)}}}var c=a.extend({},a.fn.popeye.defaults,b);return this.each(function(){function V(){b.find(".ppy-imglist").remove();n.css(G);b.css(D);b.wrap(n);var d=a("#templateDir").val();r=r.prepend('<a class="ppy-nextBig"><img src="'+d+'/images/transparent.png" alt="Invisible Image" style="width: 100%; height: 285px;" /></a>');o=r.wrap(o).parent();p=y.wrapInner(p).children().eq(0);K();if(c.navigation=="hover"){P();b.hover(function(){O()},function(){P()});s.hover(function(){O()},function(){P()})}if(!h){t.click(T);u.click(U);b.find(".ppy-nextBig").click(U)}else{b.addClass(m);t.remove();u.remove();v.remove();A.remove()}if(c.caption=="hover"){S();b.hover(function(){R(H[j])},function(){S(true)})}w.click(function(){L();return false});x.click(function(){K(j);return false})}function U(){if(j<g-1){j++}else{j=0}if(i){L(j)}else{K(j,true)}if(j+1<g){var a=f[j+1];e[j+1].src=a}return j}function T(){if(j<=0){j=g-1}else{j--}if(i){L(j)}else{K(j,true)}return j}function S(){var a={visibility:"hidden",overflow:"hidden"};y.animate({height:"0px"},{queue:false,duration:90,easing:c.easing,complete:function(){y.css(a)}})}function R(a,b){if(a&&c.caption){Q(a);d("$.fn.popeye.showCaption -> ppyCaptionWrap.outerHeight(true): "+p.outerHeight(true));var e={visibility:"visible"};y.css(e);if(c.caption==="permanent"&&!i){y.css(F)}else{y.animate({height:p.outerHeight(true)},{queue:false,duration:90,easing:c.easing})}}else if(!a&&!b){S()}}function Q(a){if(c.caption){z.html(a)}}function P(){s.stop().fadeTo(150,0)}function O(){s.stop().fadeTo(150,c.opacity)}function N(a){a=a||j;var b=new Image;var c=new Image;var d=a;if(d<g-1){d++}else{d=0}b.src=f[a].href[d];d=a;if(d<=0){d=g-1}else{d--}c.src=f[a].href[d]}function M(a){a=a||j;C.text(g);B.text(a+1);d("$.fn.popeye.updateCounter: Displaying image "+(a+1)+" of "+g)}function L(e){e=e||j;o.addClass(l);r.fadeTo(c.duration/2,0);var g=a("."+k);g.css("z-index",c.zindex-1);b.css("z-index",c.zindex);var h=new Image;h.onload=function(){o.removeClass(l);var g={width:h.width,height:h.height};var j={backgroundImage:"url("+f[e].href+")",backgroundPosition:"left top"};S();r.animate(g,{queue:false,duration:c.duration,easing:c.easing,complete:function(){if(c.navigation=="hover"){O()}i=true;d("$.fn.popeye.showImage: Entering ENLARGED MODE","info");b.addClass(k);x.removeClass("ppy-hidden");w.addClass("ppy-hidden");M();a(this).css(j).fadeTo(c.duration/2,1);R(H[e]);N()}})};h.src=f[e].href}function K(g,h){h=h||false;g=g||j;var m={backgroundImage:"url("+e[g].src+")"};var n={height:"+=0"};if(i){S();r.fadeTo(c.duration/2,0).animate(E,{queue:false,duration:c.duration,easing:c.easing,complete:function(){i=false;d("$.fn.showThumb: Entering COMPACT MODE","info");b.removeClass(k);b.css("z-index","");w.removeClass("ppy-hidden");x.addClass("ppy-hidden");K();a(this).fadeTo(c.duration/2,1)}})}else{if(h){o.addClass(l);r.fadeTo(c.duration/2,0);var p=new Image;p.onload=function(){d("$.fn.popeye.showThumb: Thumbnail "+g+" loaded","info");o.removeClass(l);r.animate(n,1,"linear",function(){r.css(m);a(this).fadeTo(c.duration/2,1);if(c.caption=="hover"){R(H[g])}else if(c.caption=="permanent"){Q(H[g])}M()});p.onload=function(){}};p.src=e[g].src}else{r.css(m);M();R(H[g],true)}var q=new Image;q.onload=function(){d("$.fn.popeye.showThumb: Image "+g+" loaded","info");q.onload=function(){}};q.src=f[g].href}}a(this).addClass("ppy-active");var b=a(this),e=b.find(".ppy-imglist > li > a > img"),f=b.find(".ppy-imglist > li > a"),g=e.length,h=g==1?true:false,i=false,j=0,k="ppy-expanded",l="ppy-loading",m="ppy-single-image",n=a('<div class="ppy-placeholder"></div>'),o=a('<div class="ppy-stagewrap"></div>'),p=a('<div class="ppy-captionwrap"></div>'),q=b.find(".ppy-outer"),r=b.find(".ppy-stage"),s=b.find(".ppy-nav"),t=b.find(".ppy-prev"),u=b.find(".ppy-next"),v=b.find(".ppy-nextBig"),w=b.find(".ppy-switch-enlarge"),x=b.find(".ppy-switch-compact").addClass("ppy-hidden"),y=b.find(".ppy-caption"),z=b.find(".ppy-text"),A=b.find(".ppy-counter"),B=b.find(".ppy-current"),C=b.find(".ppy-total"),D={position:"absolute",width:"auto",height:"auto",margin:0,top:0,left:c.direction=="right"?0:"auto",right:c.direction=="left"?0:"auto"},E={height:r.height(),width:r.width()},F={height:y.height()},G={height:c.caption=="hover"||false?q.outerHeight():b.outerHeight(),width:c.caption=="hover"||false?q.outerWidth():b.outerWidth(),"float":b.css("float"),marginTop:b.css("margin-top"),marginRight:b.css("margin-right"),marginBottom:b.css("margin-bottom"),marginLeft:b.css("margin-left")};var H=[];for(var I=0;I<e.length;I++){var J=b.find(".ppy-imglist li").eq(I).find(".ppy-extcaption");H[I]=J.length>0?J.html():e[I].alt}if(!r.length||!s.length||!q.length){d("$.fn.popeye: Incorrect HTML structure","warn")}else if(g===0){d("$.fn.popeye: No images found","warn")}else{h?d("$.fn.popeye -> SingleImageMode started"):d("$.fn.popeye -> "+g+" thumbnails found.");V()}})};a.fn.popeye.defaults={navigation:"hover",caption:"hover",zindex:1e4,direction:"right",duration:240,opacity:.8,easing:"swing",debug:true}})(jQuery);jQuery("head").append('<style type="text/css"> .ppy-imglist { position: absolute; top: -1000em; left: -1000em; } </style>')
