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