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