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