(function(a){var b=function(b,c){var d=a.extend({},a.fn.nivoSlider.defaults,c);var e={currentSlide:0,currentImage:"",totalSlides:0,randAnim:"",running:false,paused:false};var f=a(b);var g=a("#loadingImage");f.data("nivo:vars",e);f.css("position","relative");f.addClass("nivoSlider");e.totalSlides=d.total;var h=new Array(d.total);var i=new Array(d.total);for(var j=0;j<e.totalSlides;j++){h[j]=j;i[j]="/Uploads/slideshow/photo_"+j+".jpg"}h.sort(function(){return Math.round(Math.random())-.5});e.currentSlide=h[0];var k;e.currentImage=i[e.currentSlide];a("<img />").attr("src",e.currentImage).load(function(){g.fadeOut();f.css("background",'url("'+e.currentImage+'") no-repeat');k=setTimeout(function(){n(f,d)},d.pauseTime)});if(d.directionNav){f.append('<div class="nivo-directionNav"><a class="nivo-prevNav">'+d.prevText+'</a><a class="nivo-nextNav">'+d.nextText+"</a></div>");if(d.directionNavHide){a(".nivo-directionNav",f).hide();f.hover(function(){a(".nivo-directionNav",f).show()},function(){a(".nivo-directionNav",f).hide()})}a("a.nivo-prevNav",f).live("click",function(){if(e.running)return false;clearTimeout(k);e.currentSlide-=2;n(f,d)});a("a.nivo-nextNav",f).live("click",function(){if(e.running)return false;clearTimeout(k);n(f,d)})}if(d.pauseOnHover){f.hover(function(){e.paused=true;clearTimeout(k)},function(){e.paused=false;k=setTimeout(function(){n(f,d)},d.pauseTime)})}f.bind("nivo:animFinished",function(){e.running=false;if(!e.paused){k=setTimeout(function(){n(f,d)},d.pauseTime)}d.afterChange.call(this)});var l=function(b,c,d){for(var e=0;e<c.slices;e++){var f=Math.round(b.width()/c.slices);if(e==c.slices-1){b.append(a('<div class="nivo-slice"></div>').css({left:f*e+"px",width:b.width()-f*e+"px",height:"0",opacity:"0",background:'url("'+d.currentImage+'") no-repeat -'+(f+e*f-f)+"px 0%"}))}else{b.append(a('<div class="nivo-slice"></div>').css({left:f*e+"px",width:f+"px",height:"0",opacity:"0",background:'url("'+d.currentImage+'") no-repeat -'+(f+e*f-f)+"px 0%"}))}}};var m=function(b,c,d){var e=Math.round(b.width()/c.boxCols);var f=Math.round(b.height()/c.boxRows);for(var g=0;g<c.boxRows;g++){for(var h=0;h<c.boxCols;h++){if(h==c.boxCols-1){b.append(a('<div class="nivo-box"></div>').css({opacity:0,left:e*h+"px",top:f*g+"px",width:b.width()-e*h+"px",height:f+"px",background:'url("'+d.currentImage+'") no-repeat -'+(e+h*e-e)+"px -"+(f+g*f-f)+"px"}))}else{b.append(a('<div class="nivo-box"></div>').css({opacity:0,left:e*h+"px",top:f*g+"px",width:e+"px",height:f+"px",background:'url("'+d.currentImage+'") no-repeat -'+(e+h*e-e)+"px -"+(f+g*f-f)+"px"}))}}}};var n=function(b,c){g.show();var d=b.data("nivo:vars");if(d&&d.currentSlide==d.totalSlides-1){c.lastSlide.call(this)}c.beforeChange.call(this);b.css("background",'url("'+d.currentImage+'") no-repeat');d.currentSlide++;if(d.currentSlide==d.totalSlides){d.currentSlide=0;c.slideshowEnd.call(this)}if(d.currentSlide<0)d.currentSlide=d.totalSlides-1;d.currentImage=i[d.currentSlide];a("<img />").attr("src",d.currentImage).load(function(){g.fadeOut();a(".nivo-slice",b).remove();a(".nivo-box",b).remove();if(c.effect=="random"){var e=new Array("sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse");d.randAnim=e[Math.floor(Math.random()*(e.length+1))];if(d.randAnim==undefined)d.randAnim="fade"}if(c.effect.indexOf(",")!=-1){var e=c.effect.split(",");d.randAnim=e[Math.floor(Math.random()*e.length)];if(d.randAnim==undefined)d.randAnim="fade"}d.running=true;if(c.effect=="sliceDown"||c.effect=="sliceDownRight"||d.randAnim=="sliceDownRight"||c.effect=="sliceDownLeft"||d.randAnim=="sliceDownLeft"){l(b,c,d);var f=0;var h=0;var i=a(".nivo-slice",b);if(c.effect=="sliceDownLeft"||d.randAnim=="sliceDownLeft")i=a(".nivo-slice",b)._reverse();i.each(function(){var d=a(this);d.css({top:"0"});if(h==c.slices-1){setTimeout(function(){d.animate({height:"100%",opacity:"1.0"},c.animSpeed,"",function(){b.trigger("nivo:animFinished")})},100+f)}else{setTimeout(function(){d.animate({height:"100%",opacity:"1.0"},c.animSpeed)},100+f)}f+=50;h++})}else if(c.effect=="sliceUp"||c.effect=="sliceUpRight"||d.randAnim=="sliceUpRight"||c.effect=="sliceUpLeft"||d.randAnim=="sliceUpLeft"){l(b,c,d);var f=0;var h=0;var i=a(".nivo-slice",b);if(c.effect=="sliceUpLeft"||d.randAnim=="sliceUpLeft")i=a(".nivo-slice",b)._reverse();i.each(function(){var d=a(this);d.css({bottom:"0"});if(h==c.slices-1){setTimeout(function(){d.animate({height:"100%",opacity:"1.0"},c.animSpeed,"",function(){b.trigger("nivo:animFinished")})},100+f)}else{setTimeout(function(){d.animate({height:"100%",opacity:"1.0"},c.animSpeed)},100+f)}f+=50;h++})}else if(c.effect=="sliceUpDown"||c.effect=="sliceUpDownRight"||d.randAnim=="sliceUpDown"||c.effect=="sliceUpDownLeft"||d.randAnim=="sliceUpDownLeft"){l(b,c,d);var f=0;var h=0;var j=0;var i=a(".nivo-slice",b);if(c.effect=="sliceUpDownLeft"||d.randAnim=="sliceUpDownLeft")i=a(".nivo-slice",b)._reverse();i.each(function(){var d=a(this);if(h==0){d.css("top","0");h++}else{d.css("bottom","0");h=0}if(j==c.slices-1){setTimeout(function(){d.animate({height:"100%",opacity:"1.0"},c.animSpeed,"",function(){b.trigger("nivo:animFinished")})},100+f)}else{setTimeout(function(){d.animate({height:"100%",opacity:"1.0"},c.animSpeed)},100+f)}f+=50;j++})}else if(c.effect=="fold"||d.randAnim=="fold"){l(b,c,d);var f=0;var h=0;a(".nivo-slice",b).each(function(){var d=a(this);var e=d.width();d.css({top:"0",height:"100%",width:"0"});if(h==c.slices-1){setTimeout(function(){d.animate({width:e,opacity:"1.0"},c.animSpeed,"",function(){b.trigger("nivo:animFinished")})},100+f)}else{setTimeout(function(){d.animate({width:e,opacity:"1.0"},c.animSpeed)},100+f)}f+=50;h++})}else if(c.effect=="fade"||d.randAnim=="fade"){l(b,c,d);var k=a(".nivo-slice:first",b);k.css({height:"100%",width:b.width()+"px"});k.animate({opacity:"1.0"},c.animSpeed*2,"",function(){b.trigger("nivo:animFinished")})}else if(c.effect=="slideInRight"||d.randAnim=="slideInRight"){l(b,c,d);var k=a(".nivo-slice:first",b);k.css({height:"100%",width:"0",opacity:"1"});k.animate({width:b.width()+"px"},c.animSpeed*2,"",function(){b.trigger("nivo:animFinished")})}else if(c.effect=="slideInLeft"||d.randAnim=="slideInLeft"){l(b,c,d);var k=a(".nivo-slice:first",b);k.css({height:"100%",width:"0",opacity:"1",left:"",right:"0"});k.animate({width:b.width()+"px"},c.animSpeed*2,"",function(){k.css({left:"0",right:""});b.trigger("nivo:animFinished")})}else if(c.effect=="boxRandom"||d.randAnim=="boxRandom"){m(b,c,d);var n=c.boxCols*c.boxRows;var h=0;var f=0;var p=o(a(".nivo-box",b));p.each(function(){var d=a(this);if(h==n-1){setTimeout(function(){d.animate({opacity:"1"},c.animSpeed,"",function(){b.trigger("nivo:animFinished")})},100+f)}else{setTimeout(function(){d.animate({opacity:"1"},c.animSpeed)},100+f)}f+=20;h++})}else if(c.effect=="boxRain"||d.randAnim=="boxRain"||c.effect=="boxRainReverse"||d.randAnim=="boxRainReverse"||c.effect=="boxRainGrow"||d.randAnim=="boxRainGrow"||c.effect=="boxRainGrowReverse"||d.randAnim=="boxRainGrowReverse"){m(b,c,d);var n=c.boxCols*c.boxRows;var h=0;var f=0;var q=0;var r=0;var s=new Array;s[q]=new Array;var p=a(".nivo-box",b);if(c.effect=="boxRainReverse"||d.randAnim=="boxRainReverse"||c.effect=="boxRainGrowReverse"||d.randAnim=="boxRainGrowReverse"){p=a(".nivo-box",b)._reverse()}p.each(function(){s[q][r]=a(this);r++;if(r==c.boxCols){q++;r=0;s[q]=new Array}});var t=c.boxCols*2;for(var u=0;u<t;u++){var v=u;for(var w=0;w<c.boxRows;w++){if(v>=0&&v<c.boxCols){(function(e,f,g,h,i){var j=a(s[e][f]);var k=j.width();var l=j.height();if(c.effect=="boxRainGrow"||d.randAnim=="boxRainGrow"||c.effect=="boxRainGrowReverse"||d.randAnim=="boxRainGrowReverse"){j.width(0).height(0)}if(h==i-1){setTimeout(function(){j.animate({opacity:"1",width:k,height:l},c.animSpeed/1.3,"",function(){b.trigger("nivo:animFinished")})},100+g)}else{setTimeout(function(){j.animate({opacity:"1",width:k,height:l},c.animSpeed/1.3)},100+g)}})(w,v,f,h,n);h++}v--}f+=100}}})};var o=function(a){var b=a.length;for(var c,d,e=b;e;c=parseInt(Math.random()*e),d=a[--e],a[e]=a[c],a[c]=d);return a};d.afterLoad.call(this);return this};a.fn.nivoSlider=function(c){return this.each(function(d,e){var f=a(this);if(f.data("nivoslider"))return f.data("nivoslider");var g=new b(this,c);f.data("nivoslider",g)})};a.fn.nivoSlider.defaults={total:5,effect:"random",slices:15,boxCols:8,boxRows:4,animSpeed:500,pauseTime:3e3,directionNav:true,directionNavHide:true,pauseOnHover:true,prevText:"Prev",nextText:"Next",beforeChange:function(){},afterChange:function(){},slideshowEnd:function(){},lastSlide:function(){},afterLoad:function(){}};a.fn._reverse=[].reverse})(jQuery)
