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