(function($){$.fn.nivoSlider=function(n){var o=$.extend({},$.fn.nivoSlider.defaults,n);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(o.startSlide>0){if(o.startSlide>=e.totalSlides)o.startSlide=e.totalSlides-1;e.currentSlide=o.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<o.slices;i++){var h=Math.round(f.width()/o.slices);if(i==o.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:o.captionOpacity}));if(e.currentImage.attr('title')!=''){var j=e.currentImage.attr('title');if(j.substr(0,1)=='#')j=$(j).html();$('.nivo-caption p',f).html(j);$('.nivo-caption',f).fadeIn(o.animSpeed)}var k=0;if(!o.manualAdvance&&g.length>1){k=setInterval(function(){nivoRun(f,g,o,false)},o.pauseTime)}if(o.directionNav){f.append('<div class="nivo-directionNav"><a class="nivo-prevNav"><img src="images/arrowprev.png" /></a><a class="nivo-nextNav"><img src="images/arrownext.png" /></a></div>');if(o.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(k);k='';e.currentSlide-=2;nivoRun(f,g,o,'prev')});$('a.nivo-nextNav',f).live('click',function(){if(e.running)return false;clearInterval(k);k='';nivoRun(f,g,o,'next')})}if(o.controlNav){var l=$('<div class="nivo-controlNav"></div>');f.append(l);for(var i=0;i<g.length;i++){if(o.controlNavThumbs){var m=g.eq(i);if(!m.is('img')){m=m.find('img:first')}if(o.controlNavThumbsFromRel){l.append('<a class="nivo-control" rel="'+i+'"><img src="'+m.attr('rel')+'" alt="" /></a>')}else{l.append('<a class="nivo-control" rel="'+i+'"><img src="'+m.attr('src').replace(o.controlNavThumbsSearch,o.controlNavThumbsReplace)+'" alt="" /></a>')}}else{l.append('<a class="nivo-control" rel="'+i+'">'+(i+1)+'</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(k);k='';f.css('background','url('+e.currentImage.attr('src')+') no-repeat');e.currentSlide=$(this).attr('rel')-1;nivoRun(f,g,o,'control')})}if(o.keyboardNav){$(window).keypress(function(a){if(a.keyCode=='37'){if(e.running)return false;clearInterval(k);k='';e.currentSlide-=2;nivoRun(f,g,o,'prev')}if(a.keyCode=='39'){if(e.running)return false;clearInterval(k);k='';nivoRun(f,g,o,'next')}})}if(o.pauseOnHover){f.hover(function(){e.paused=true;clearInterval(k);k=''},function(){e.paused=false;if(k==''&&!o.manualAdvance){k=setInterval(function(){nivoRun(f,g,o,false)},o.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(k==''&&!e.paused&&!o.manualAdvance){k=setInterval(function(){nivoRun(f,g,o,false)},o.pauseTime)}o.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('title')!=''){var h=g.currentImage.attr('title');if(h.substr(0,1)=='#')h=$(h).html();if($('.nivo-caption',c).css('display')=='block'){$('.nivo-caption p',c).fadeOut(e.animSpeed,function(){$(this).html(h);$(this).fadeIn(e.animSpeed)})}else{$('.nivo-caption p',c).html(h)}$('.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 j=new Array("sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade");g.randAnim=j[Math.floor(Math.random()*(j.length+1))];if(g.randAnim==undefined)g.randAnim='fade'}if(e.effect.indexOf(',')!=-1){var j=e.effect.split(',');g.randAnim=$.trim(j[Math.floor(Math.random()*j.length)])}g.running=true;if(e.effect=='sliceDown'||e.effect=='sliceDownRight'||g.randAnim=='sliceDownRight'||e.effect=='sliceDownLeft'||g.randAnim=='sliceDownLeft'){var k=0;var i=0;var l=$('.nivo-slice',c);if(e.effect=='sliceDownLeft'||g.randAnim=='sliceDownLeft')l=$('.nivo-slice',c)._reverse();l.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+k))}else{setTimeout(function(){a.animate({height:'100%',opacity:'1.0'},e.animSpeed)},(100+k))}k+=50;i++})}else if(e.effect=='sliceUp'||e.effect=='sliceUpRight'||g.randAnim=='sliceUpRight'||e.effect=='sliceUpLeft'||g.randAnim=='sliceUpLeft'){var k=0;var i=0;var l=$('.nivo-slice',c);if(e.effect=='sliceUpLeft'||g.randAnim=='sliceUpLeft')l=$('.nivo-slice',c)._reverse();l.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+k))}else{setTimeout(function(){a.animate({height:'100%',opacity:'1.0'},e.animSpeed)},(100+k))}k+=50;i++})}else if(e.effect=='sliceUpDown'||e.effect=='sliceUpDownRight'||g.randAnim=='sliceUpDown'||e.effect=='sliceUpDownLeft'||g.randAnim=='sliceUpDownLeft'){var k=0;var i=0;var v=0;var l=$('.nivo-slice',c);if(e.effect=='sliceUpDownLeft'||g.randAnim=='sliceUpDownLeft')l=$('.nivo-slice',c)._reverse();l.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+k))}else{setTimeout(function(){a.animate({height:'100%',opacity:'1.0'},e.animSpeed)},(100+k))}k+=50;v++})}else if(e.effect=='fold'||g.randAnim=='fold'){var k=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+k))}else{setTimeout(function(){a.animate({width:b,opacity:'1.0'},e.animSpeed)},(100+k))}k+=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:'_thumb.jpg',keyboardNav:true,pauseOnHover:true,manualAdvance:false,captionOpacity:0.8,beforeChange:function(){},afterChange:function(){},slideshowEnd:function(){}};$.fn._reverse=[].reverse})(jQuery);
