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

