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