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