(function(a){var b;var c;a(document).ready(function(){a("body").prepend('<div id="supersized-loader"></div>').prepend('<div id="supersized"></div>')});a.supersized=function(d){function u(){i=false;if(d.performance==1){f.removeClass("speed").addClass("quality")}r()}function t(){if(i)return false;else i=true;var b=d.slides;var c=f.find(".activeslide");c.removeClass("activeslide");if(c.length==0)c=a(f).find("a:first");var e=c.prev().length?c.prev():a(f).find("a:last");var g=e.next().length?e.next():a(f).find("a:first");a(".prevslide").removeClass("prevslide");g.addClass("prevslide");l==0?l=b.length-1:l--;if(d.performance==1)f.removeClass("quality").addClass("speed");loadSlide=false;l-1<0?loadSlide=b.length-1:loadSlide=l-1;q=d.slides[loadSlide].url?"href='"+d.slides[loadSlide].url+"'":"";a("<img/>").attr("src",d.slides[loadSlide].image).prependTo(f).wrap("<a "+q+m+"></a>");c.next().remove();if(d.slide_counter){a("#slidecounter .slidenumber").html(l+1)}if(d.slide_captions){d.slides[l].title?a("#slidecaption").html(d.slides[l].title):a("#slidecaption").html("")}e.hide().addClass("activeslide");switch(d.transition){case 0:e.show();i=false;break;case 1:e.fadeTo(d.transition_speed,1,function(){u()});break;case 2:e.animate({top:rootElement.height()},0).show().animate({top:0},d.transition_speed,function(){u()});break;case 3:e.animate({left:-rootElement.width()},0).show().animate({left:0},d.transition_speed,function(){u()});break;case 4:e.animate({top:-rootElement.height()},0).show().animate({top:0},d.transition_speed,function(){u()});break;case 5:e.animate({left:rootElement.width()},0).show().animate({left:0},d.transition_speed,function(){u()});break;case 6:e.animate({left:-rootElement.width()},0).show().animate({left:0},d.transition_speed,function(){u()});c.animate({left:rootElement.width()},d.transition_speed);break;case 7:e.animate({left:rootElement.width()},0).show().animate({left:0},d.transition_speed,function(){u()});c.animate({left:-rootElement.width()},d.transition_speed);break}}function s(){if(i)return false;else i=true;r();var b=d.slides;var c=f.find(".activeslide");c.removeClass("activeslide");if(c.length==0)c=f.find("a:last");var e=c.next().length?c.next():f.find("a:first");var g=e.prev().length?e.prev():f.find("a:last");a(".prevslide").removeClass("prevslide");g.addClass("prevslide");l+1==b.length?l=0:l++;if(d.performance==1)f.removeClass("quality").addClass("speed");loadSlide=false;if(h==true){l=0;h=false}l==b.length-1?loadSlide=0:loadSlide=l+1;q=d.slides[loadSlide].url?"href='"+d.slides[loadSlide].url+"'":"";a("<img/>").attr("src",d.slides[loadSlide].image).appendTo(f).wrap("<a "+q+m+"></a>");c.prev().remove();if(d.slide_counter){a("#slidecounter .slidenumber").html(l+1)}if(d.slide_captions){if(d.slides[l].title){a("#slidecaption").fadeOut(500,function(){a("#slidecaption").html(d.slides[l].title);a("#slidecaption").fadeIn(500)})}else{a("#slidecaption").fadeOut(500).html("")}}e.hide().addClass("activeslide");switch(d.transition){case 0:e.show();i=false;break;case 1:e.fadeTo(d.transition_speed,1,function(){u()});break;case 2:e.animate({top:-rootElement.height()},0).show().animate({top:0},d.transition_speed,function(){u()});break;case 3:e.animate({left:rootElement.width()},0).show().animate({left:0},d.transition_speed,function(){u()});break;case 4:e.animate({top:rootElement.height()},0).show().animate({top:0},d.transition_speed,function(){u()});break;case 5:e.animate({left:-rootElement.width()},0).show().animate({left:0},d.transition_speed,function(){u()});break;case 6:e.animate({left:rootElement.width()},0).show().animate({left:0},d.transition_speed,function(){u()});c.animate({left:-rootElement.width()},d.transition_speed);break;case 7:e.animate({left:-rootElement.width()},0).show().animate({left:0},d.transition_speed,function(){u()});c.animate({left:rootElement.width()},d.transition_speed);break}}function r(){return f.each(function(){var b=a("img",f);a(b).each(function(){function g(a){if(a){if(thisSlide.height()<e){if(thisSlide.height()/b>=d.min_width){thisSlide.height(d.min_height);thisSlide.width(thisSlide.height()/b)}else{f(true)}}}else{if(d.min_width>=c){if(e/b>=d.min_width||b>1){thisSlide.height(e);thisSlide.width(e/b)}else if(b<=1){thisSlide.width(d.min_width);thisSlide.height(thisSlide.width()*b)}}else{thisSlide.height(e);thisSlide.width(e/b)}}}function f(a){if(a){if(thisSlide.width()<c||thisSlide.width()<d.min_width){if(thisSlide.width()*b>=d.min_height){thisSlide.width(d.min_width);thisSlide.height(thisSlide.width()*b)}else{g()}}}else{if(d.min_height>=e&&!d.fit_landscape){if(c*b>=d.min_height||c*b>=d.min_height&&b<=1){thisSlide.width(c);thisSlide.height(c*b)}else if(b>1){thisSlide.height(d.min_height);thisSlide.width(thisSlide.height()/b)}else if(thisSlide.width()<c){thisSlide.width(c);thisSlide.height(thisSlide.width()*b)}}else{thisSlide.width(c);thisSlide.height(c*b)}}}var b=(a(this).height()/a(this).width()).toFixed(2);thisSlide=a(this);var c=rootElement.width();var e=rootElement.height();if(e<=d.min_height&&c<=d.min_width){if(e/c>b){d.fit_landscape&&b<=1?f(true):g(true)}else{d.fit_portrait&&b>1?g(true):f(true)}}else if(c<=d.min_width){if(e/c>b){d.fit_landscape&&b<=1?f(true):g()}else{d.fit_portrait&&b>1?g():f(true)}}else if(e<=d.min_height){if(e/c>b){d.fit_landscape&&b<=1?f():g(true)}else{d.fit_portrait&&b>1?g(true):f()}}else{if(e/c>b){d.fit_landscape&&b<=1?f():g()}else{d.fit_portrait&&b>1?g():f()}}if(d.horizontal_center){a(this).css("left",(c-a(this).width())/2)}if(d.vertical_center){a(this).css("top",(e-a(this).height())/2)}});if(d.image_protect){a("img",f).bind("contextmenu",function(){return false});a("img",f).bind("mousedown",function(){return false})}return false})}var e={slideshow:1,autoplay:1,start_slide:1,random:0,slide_interval:5e3,transition:1,transition_speed:750,new_window:1,pause_hover:0,keyboard_nav:1,performance:1,image_protect:1,image_path:"img/",min_width:0,min_height:0,vertical_center:1,horizontal_center:1,fit_portrait:0,fit_landscape:0,navigation:1,thumbnail_navigation:0,slide_counter:1,slide_captions:1};var f=a("#supersized");var g="#pauseplay";var h=false;if(d){var d=a.extend(e,d)}else{var d=a.extend(e)}var i=false;var j=false;var k=d.image_path;if(d.start_slide){var l=d.start_slide-1}else{var l=Math.floor(Math.random()*d.slides.length)}var m=d.new_window?' target="_blank"':"";if(d.performance==3){f.addClass("speed")}else if(d.performance==1||d.performance==2){f.addClass("quality")}if(d.random){arr=d.slides;for(var n,o,p=arr.length;p;n=parseInt(Math.random()*p),o=arr[--p],arr[p]=arr[n],arr[n]=o);d.slides=arr}if(d.slides.length>1){l-1<0?loadPrev=d.slides.length-1:loadPrev=l-1;var q=d.slides[loadPrev].url?"href='"+d.slides[loadPrev].url+"'":"";a("<img/>").attr("src",d.slides[loadPrev].image).appendTo(f).wrap("<a "+q+m+"></a>")}q=d.slides[l].url?"href='"+d.slides[l].url+"'":"";a("<img/>").attr("src",d.slides[l].image).appendTo(f).wrap('<a class="activeslide" '+q+m+"></a>");if(d.slides.length>1){l==d.slides.length-1?loadNext=0:loadNext=l+1;q=d.slides[loadNext].url?"href='"+d.slides[loadNext].url+"'":"";a("<img/>").attr("src",d.slides[loadNext].image).appendTo(f).wrap("<a "+q+m+"></a>")}f.hide();a("#controls-wrapper").hide();a(document).ready(function(){r()});a(window).load(function(){a("#supersized-loader").hide();f.fadeIn("fast");a("#controls-wrapper").show();r();if(d.slide_captions)a("#slidecaption").html(d.slides[l].title);if(!d.navigation)a("#navigation").hide();if(d.slideshow&&d.slides.length>1){if(d.slide_counter){a("#slidecounter .slidenumber").html(l+1);a("#slidecounter .totalslides").html(d.slides.length)}if(!d.autoplay){clearInterval(b);j=true;if(a(g).attr("src"))a(g).attr("src",k+"play_dull.png")}}});a(window).resize(function(){r()});rootElement="onorientationchange"in window?a(document):a(window);return{resizenow:r,stopSlideshow:function(){clearInterval(b)},setSlides:function(e,f){clearInterval(b);clearTimeout(c);d.slides=e;arr=d.slides;for(var g,i,j=arr.length;j;g=parseInt(Math.random()*j),i=arr[--j],arr[j]=arr[g],arr[g]=i);d.slides=arr;h=true;a("#supersized a:nth-child(3) img").load(function(){r();c=setTimeout(function(){s();b=setInterval(s,d.slide_interval)},1e3)})}}}})(jQuery)
