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