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