(function(a){var b=function(f,c){var s=a.extend({},a.fn.nivoSlider.defaults,c);var g={currentSlide:0,currentImage:"",totalSlides:0,randAnim:"",running:false,paused:false,stop:false};var n=a(f);n.data("nivo:vars",g);n.css("position","relative");n.addClass("nivoSlider");var h=n.children();h.each(function(){var t=a(this);var u="";if(!t.is("img")){if(t.is("a")){t.addClass("nivo-imageLink");u=t}t=t.find("img:first")}var v=t.width();if(v==0){v=t.attr("width")}var i=t.height();if(i==0){i=t.attr("height")}if(v>n.width()){n.width(v)}if(i>n.height()){n.height(i)}if(u!=""){u.css("display","none")}t.css("display","none");g.totalSlides++});if(s.startSlide>0){if(s.startSlide>=g.totalSlides){s.startSlide=g.totalSlides-1}g.currentSlide=s.startSlide}if(a(h[g.currentSlide]).is("img")){g.currentImage=a(h[g.currentSlide])}else{g.currentImage=a(h[g.currentSlide]).find("img:first")}if(a(h[g.currentSlide]).is("a")){a(h[g.currentSlide]).css("display","block")}n.css("background",'url("'+g.currentImage.attr("src")+'") no-repeat');n.append(a('<div class="nivo-caption"><p></p></div>').css({display:"none",opacity:s.captionOpacity}));var d=function(u){var i=a(".nivo-caption",n);if(g.currentImage.attr("title")!=""&&g.currentImage.attr("title")!=undefined){var t=g.currentImage.attr("title");if(t.substr(0,1)=="#"){t=a(t).html()}if(i.css("display")=="block"){i.find("p").fadeOut(u.animSpeed,function(){a(this).html(t);a(this).fadeIn(u.animSpeed)})}else{i.find("p").html(t)}i.fadeIn(u.animSpeed)}else{i.fadeOut(u.animSpeed)}};d(s);var e=0;if(!s.manualAdvance&&h.length>1){e=setInterval(function(){j(n,h,s,false)},s.pauseTime)}if(s.directionNav){n.append('<div class="nivo-directionNav"><a class="nivo-prevNav">'+s.prevText+'</a><a class="nivo-nextNav">'+s.nextText+"</a></div>");if(s.directionNavHide){a(".nivo-directionNav",n).hide();n.hover(function(){a(".nivo-directionNav",n).show()},function(){a(".nivo-directionNav",n).hide()})}a("a.nivo-prevNav",n).live("click",function(){if(g.running){return false}clearInterval(e);e="";g.currentSlide-=2;j(n,h,s,"prev")});a("a.nivo-nextNav",n).live("click",function(){if(g.running){return false}clearInterval(e);e="";j(n,h,s,"next")})}if(s.controlNav){var r=a('<div class="nivo-controlNav"></div>');n.append(r);for(var p=0;p<h.length;p++){if(s.controlNavThumbs){var l=h.eq(p);if(!l.is("img")){l=l.find("img:first")}if(s.controlNavThumbsFromRel){r.append('<a class="nivo-control" rel="'+p+'"><img src="'+l.attr("rel")+'" alt="" /></a>')}else{r.append('<a class="nivo-control" rel="'+p+'"><img src="'+l.attr("src").replace(s.controlNavThumbsSearch,s.controlNavThumbsReplace)+'" alt="" /></a>')}}else{r.append('<a class="nivo-control" rel="'+p+'">'+(p+1)+"</a>")}}a(".nivo-controlNav a:eq("+g.currentSlide+")",n).addClass("active");a(".nivo-controlNav a",n).live("click",function(){if(g.running){return false}if(a(this).hasClass("active")){return false}clearInterval(e);e="";n.css("background",'url("'+g.currentImage.attr("src")+'") no-repeat');g.currentSlide=a(this).attr("rel")-1;j(n,h,s,"control")})}if(s.keyboardNav){a(window).keypress(function(i){if(i.keyCode=="37"){if(g.running){return false}clearInterval(e);e="";g.currentSlide-=2;j(n,h,s,"prev")}if(i.keyCode=="39"){if(g.running){return false}clearInterval(e);e="";j(n,h,s,"next")}})}if(s.pauseOnHover){n.hover(function(){g.paused=true;clearInterval(e);e=""},function(){g.paused=false;if(e==""&&!s.manualAdvance){e=setInterval(function(){j(n,h,s,false)},s.pauseTime)}})}n.bind("nivo:animFinished",function(){g.running=false;a(h).each(function(){if(a(this).is("a")){a(this).css("display","none")}});if(a(h[g.currentSlide]).is("a")){a(h[g.currentSlide]).css("display","block")}if(e==""&&!g.paused&&!s.manualAdvance){e=setInterval(function(){j(n,h,s,false)},s.pauseTime)}s.afterChange.call(this)});var q=function(x,u,v){for(var w=0;w<u.slices;w++){var t=Math.round(x.width()/u.slices);if(w==u.slices-1){x.append(a('<div class="nivo-slice"></div>').css({left:(t*w)+"px",width:(x.width()-(t*w))+"px",height:"0px",opacity:"0",background:'url("'+v.currentImage.attr("src")+'") no-repeat -'+((t+(w*t))-t)+"px 0%"}))}else{x.append(a('<div class="nivo-slice"></div>').css({left:(t*w)+"px",width:t+"px",height:"0px",opacity:"0",background:'url("'+v.currentImage.attr("src")+'") no-repeat -'+((t+(w*t))-t)+"px 0%"}))}}};var m=function(x,t,v){var w=Math.round(x.width()/t.boxCols);var i=Math.round(x.height()/t.boxRows);for(var y=0;y<t.boxRows;y++){for(var u=0;u<t.boxCols;u++){if(u==t.boxCols-1){x.append(a('<div class="nivo-box"></div>').css({opacity:0,left:(w*u)+"px",top:(i*y)+"px",width:(x.width()-(w*u))+"px",height:i+"px",background:'url("'+v.currentImage.attr("src")+'") no-repeat -'+((w+(u*w))-w)+"px -"+((i+(y*i))-i)+"px"}))}else{x.append(a('<div class="nivo-box"></div>').css({opacity:0,left:(w*u)+"px",top:(i*y)+"px",width:w+"px",height:i+"px",background:'url("'+v.currentImage.attr("src")+'") no-repeat -'+((w+(u*w))-w)+"px -"+((i+(y*i))-i)+"px"}))}}}};var j=function(L,u,H,E){var D=L.data("nivo:vars");if(D&&(D.currentSlide==D.totalSlides-1)){H.lastSlide.call(this)}if((!D||D.stop)&&!E){return false}H.beforeChange.call(this);if(!E){L.css("background",'url("'+D.currentImage.attr("src")+'") no-repeat')}else{if(E=="prev"){L.css("background",'url("'+D.currentImage.attr("src")+'") no-repeat')}if(E=="next"){L.css("background",'url("'+D.currentImage.attr("src")+'") no-repeat')}}D.currentSlide++;if(D.currentSlide==D.totalSlides){D.currentSlide=0;H.slideshowEnd.call(this)}if(D.currentSlide<0){D.currentSlide=(D.totalSlides-1)}if(a(u[D.currentSlide]).is("img")){D.currentImage=a(u[D.currentSlide])}else{D.currentImage=a(u[D.currentSlide]).find("img:first")}if(H.controlNav){a(".nivo-controlNav a",L).removeClass("active");a(".nivo-controlNav a:eq("+D.currentSlide+")",L).addClass("active")}d(H);a(".nivo-slice",L).remove();a(".nivo-box",L).remove();if(H.effect=="random"){var z=new Array("sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse");D.randAnim=z[Math.floor(Math.random()*(z.length+1))];if(D.randAnim==undefined){D.randAnim="fade"}}if(H.effect.indexOf(",")!=-1){var z=H.effect.split(",");D.randAnim=z[Math.floor(Math.random()*(z.length))];if(D.randAnim==undefined){D.randAnim="fade"}}D.running=true;if(H.effect=="sliceDown"||H.effect=="sliceDownRight"||D.randAnim=="sliceDownRight"||H.effect=="sliceDownLeft"||D.randAnim=="sliceDownLeft"){q(L,H,D);var w=0;var A=0;var C=a(".nivo-slice",L);if(H.effect=="sliceDownLeft"||D.randAnim=="sliceDownLeft"){C=a(".nivo-slice",L)._reverse()}C.each(function(){var i=a(this);i.css({top:"0px"});if(A==H.slices-1){setTimeout(function(){i.animate({height:"100%",opacity:"1.0"},H.animSpeed,"",function(){L.trigger("nivo:animFinished")})},(100+w))}else{setTimeout(function(){i.animate({height:"100%",opacity:"1.0"},H.animSpeed)},(100+w))}w+=50;A++})}else{if(H.effect=="sliceUp"||H.effect=="sliceUpRight"||D.randAnim=="sliceUpRight"||H.effect=="sliceUpLeft"||D.randAnim=="sliceUpLeft"){q(L,H,D);var w=0;var A=0;var C=a(".nivo-slice",L);if(H.effect=="sliceUpLeft"||D.randAnim=="sliceUpLeft"){C=a(".nivo-slice",L)._reverse()}C.each(function(){var i=a(this);i.css({bottom:"0px"});if(A==H.slices-1){setTimeout(function(){i.animate({height:"100%",opacity:"1.0"},H.animSpeed,"",function(){L.trigger("nivo:animFinished")})},(100+w))}else{setTimeout(function(){i.animate({height:"100%",opacity:"1.0"},H.animSpeed)},(100+w))}w+=50;A++})}else{if(H.effect=="sliceUpDown"||H.effect=="sliceUpDownRight"||D.randAnim=="sliceUpDown"||H.effect=="sliceUpDownLeft"||D.randAnim=="sliceUpDownLeft"){q(L,H,D);var w=0;var A=0;var y=0;var C=a(".nivo-slice",L);if(H.effect=="sliceUpDownLeft"||D.randAnim=="sliceUpDownLeft"){C=a(".nivo-slice",L)._reverse()}C.each(function(){var i=a(this);if(A==0){i.css("top","0px");A++}else{i.css("bottom","0px");A=0}if(y==H.slices-1){setTimeout(function(){i.animate({height:"100%",opacity:"1.0"},H.animSpeed,"",function(){L.trigger("nivo:animFinished")})},(100+w))}else{setTimeout(function(){i.animate({height:"100%",opacity:"1.0"},H.animSpeed)},(100+w))}w+=50;y++})}else{if(H.effect=="fold"||D.randAnim=="fold"){q(L,H,D);var w=0;var A=0;a(".nivo-slice",L).each(function(){var i=a(this);var v=i.width();i.css({top:"0px",height:"100%",width:"0px"});if(A==H.slices-1){setTimeout(function(){i.animate({width:v,opacity:"1.0"},H.animSpeed,"",function(){L.trigger("nivo:animFinished")})},(100+w))}else{setTimeout(function(){i.animate({width:v,opacity:"1.0"},H.animSpeed)},(100+w))}w+=50;A++})}else{if(H.effect=="fade"||D.randAnim=="fade"){q(L,H,D);var G=a(".nivo-slice:first",L);G.css({height:"100%",width:L.width()+"px"});G.animate({opacity:"1.0"},(H.animSpeed*2),"",function(){L.trigger("nivo:animFinished")})}else{if(H.effect=="slideInRight"||D.randAnim=="slideInRight"){q(L,H,D);var G=a(".nivo-slice:first",L);G.css({height:"100%",width:"0px",opacity:"1"});G.animate({width:L.width()+"px"},(H.animSpeed*2),"",function(){L.trigger("nivo:animFinished")})}else{if(H.effect=="slideInLeft"||D.randAnim=="slideInLeft"){q(L,H,D);var G=a(".nivo-slice:first",L);G.css({height:"100%",width:"0px",opacity:"1",left:"",right:"0px"});G.animate({width:L.width()+"px"},(H.animSpeed*2),"",function(){G.css({left:"0px",right:""});L.trigger("nivo:animFinished")})}else{if(H.effect=="boxRandom"||D.randAnim=="boxRandom"){m(L,H,D);var F=H.boxCols*H.boxRows;var A=0;var w=0;var M=o(a(".nivo-box",L));M.each(function(){var i=a(this);if(A==F-1){setTimeout(function(){i.animate({opacity:"1"},H.animSpeed,"",function(){L.trigger("nivo:animFinished")})},(100+w))}else{setTimeout(function(){i.animate({opacity:"1"},H.animSpeed)},(100+w))}w+=20;A++})}else{if(H.effect=="boxRain"||D.randAnim=="boxRain"||H.effect=="boxRainReverse"||D.randAnim=="boxRainReverse"||H.effect=="boxRainGrow"||D.randAnim=="boxRainGrow"||H.effect=="boxRainGrowReverse"||D.randAnim=="boxRainGrowReverse"){m(L,H,D);var F=H.boxCols*H.boxRows;var A=0;var w=0;var t=0;var K=0;var B=new Array();B[t]=new Array();var M=a(".nivo-box",L);if(H.effect=="boxRainReverse"||D.randAnim=="boxRainReverse"||H.effect=="boxRainGrowReverse"||D.randAnim=="boxRainGrowReverse"){M=a(".nivo-box",L)._reverse()}M.each(function(){B[t][K]=a(this);K++;if(K==H.boxCols){t++;K=0;B[t]=new Array()}});for(var x=0;x<(H.boxCols*2);x++){var I=x;for(var J=0;J<H.boxRows;J++){if(I>=0&&I<H.boxCols){(function(O,P,S,R,Q){var v=a(B[O][P]);var N=v.width();var T=v.height();if(H.effect=="boxRainGrow"||D.randAnim=="boxRainGrow"||H.effect=="boxRainGrowReverse"||D.randAnim=="boxRainGrowReverse"){v.width(0).height(0)}if(R==Q-1){setTimeout(function(){v.animate({opacity:"1",width:N,height:T},H.animSpeed/1.3,"",function(){L.trigger("nivo:animFinished")})},(100+S))}else{setTimeout(function(){v.animate({opacity:"1",width:N,height:T},H.animSpeed/1.3)},(100+S))}})(J,I,w,A,F);A++}I--}w+=100}}}}}}}}}}};var o=function(u){for(var w,t,v=u.length;v;w=parseInt(Math.random()*v),t=u[--v],u[v]=u[w],u[w]=t){}return u};var k=function(i){if(this.console&&typeof console.log!="undefined"){console.log(i)}};this.stop=function(){if(!a(f).data("nivo:vars").stop){a(f).data("nivo:vars").stop=true;k("Stop Slider")}};this.start=function(){if(a(f).data("nivo:vars").stop){a(f).data("nivo:vars").stop=false;k("Start Slider")}};s.afterLoad.call(this);return this};a.fn.nivoSlider=function(c){return this.each(function(e,d){var g=a(this);if(g.data("nivoslider")){return g.data("nivoslider")}var f=new b(this,c);g.data("nivoslider",f)})};a.fn.nivoSlider.defaults={effect:"random",slices:15,boxCols:8,boxRows:4,animSpeed:500,pauseTime:3000,startSlide:0,directionNav:true,directionNavHide:true,controlNav:true,controlNavThumbs:false,controlNavThumbsFromRel:false,controlNavThumbsSearch:".jpg",controlNavThumbsReplace:"_thumb.jpg",keyboardNav:true,pauseOnHover:true,manualAdvance:false,captionOpacity:0.8,prevText:"Prev",nextText:"Next",beforeChange:function(){},afterChange:function(){},slideshowEnd:function(){},lastSlide:function(){},afterLoad:function(){}};a.fn._reverse=[].reverse})(jQuery);

