(function(A){A.fn.nivoSlider=function(C){var D=A.extend({},A.fn.nivoSlider.defaults,C);
return this.each(function(){var J={currentSlide:0,currentImage:"",totalSlides:0,randAnim:"",running:false,paused:false,stop:false};
var H=A(this);
H.data("nivo:vars",J);
H.css("position","relative");
H.width("1px");
H.height("1px");
H.addClass("nivoSlider");
var E=H.children();
E.each(function(){var O=A(this);
if(!O.is("img")){if(O.is("a")){O.addClass("nivo-imageLink")
}O=O.find("img:first")
}var N=O.width();
if(N==0){N=O.attr("width")
}var M=O.height();
if(M==0){M=O.attr("height")
}if(N>H.width()){H.width(N)
}if(M>H.height()){H.height(M)
}O.css("display","none");
J.totalSlides++
});
if(D.startSlide>0){if(D.startSlide>=J.totalSlides){D.startSlide=J.totalSlides-1
}J.currentSlide=D.startSlide
}if(A(E[J.currentSlide]).is("img")){J.currentImage=A(E[J.currentSlide])
}else{J.currentImage=A(E[J.currentSlide]).find("img:first")
}if(A(E[J.currentSlide]).is("a")){A(E[J.currentSlide]).css("display","block")
}H.css("background","url("+J.currentImage.attr("src")+") no-repeat");
for(var F=0;
F<D.slices;
F++){var I=Math.round(H.width()/D.slices);
if(F==D.slices-1){H.append(A('<div class="nivo-slice"></div>').css({left:(I*F)+"px",width:(H.width()-(I*F))+"px"}))
}else{H.append(A('<div class="nivo-slice"></div>').css({left:(I*F)+"px",width:I+"px"}))
}}if(D.caption==true){H.append(A('<div class="nivo-caption"><p></p></div>').css({display:"none",opacity:D.captionOpacity}))
}if(J.currentImage.attr("title")!=""){A(".nivo-caption p",H).html(J.currentImage.attr("title"));
A(".nivo-caption",H).fadeIn(D.animSpeed)
}var L=0;
if(!D.manualAdvance){L=setInterval(function(){B(H,E,D,false)
},D.pauseTime)
}if(D.directionNav){H.append('<div class="nivo-directionNav"><a class="nivo-prevNav"><img src="./images/icon_arrow-left.png" alt="&lt;" /></a><a class="nivo-nextNav"><img src="./images/icon_arrow.png" alt="&gt;" /></a></div>');
if(D.directionNavHide){A(".nivo-directionNav",H).hide();
H.hover(function(){A(".nivo-directionNav",H).show()
},function(){A(".nivo-directionNav",H).hide()
})
}A("a.nivo-prevNav",H).live("click",function(){if(J.running){return false
}clearInterval(L);
L="";
J.currentSlide-=2;
B(H,E,D,"prev")
});
A("a.nivo-nextNav",H).live("click",function(){if(J.running){return false
}clearInterval(L);
L="";
B(H,E,D,"next")
})
}if(D.controlNav){var G=A('<div class="nivo-controlNav"></div>');
H.append(G);
for(var F=0;
F<E.length;
F++){if(D.controlNavThumbs){var K=E.eq(F);
if(!K.is("img")){K=K.find("img:first")
}G.append('<a class="nivo-control" rel="'+F+'"><img src="'+K.attr("src").replace(D.controlNavThumbsSearch,D.controlNavThumbsReplace)+'"></a>')
}else{G.append('<a class="nivo-control" rel="'+F+'"></a>')
}}A(".nivo-controlNav a:eq("+J.currentSlide+")",H).addClass("active");
A(".nivo-controlNav a",H).live("click",function(){if(J.running){return false
}if(A(this).hasClass("active")){return false
}clearInterval(L);
L="";
H.css("background","url("+J.currentImage.attr("src")+") no-repeat");
J.currentSlide=A(this).attr("rel")-1;
B(H,E,D,"control")
})
}if(D.keyboardNav){A(window).keypress(function(M){if(M.keyCode=="37"){if(J.running){return false
}clearInterval(L);
L="";
J.currentSlide-=2;
B(H,E,D,"prev")
}if(M.keyCode=="39"){if(J.running){return false
}clearInterval(L);
L="";
B(H,E,D,"next")
}})
}if(D.pauseOnHover){H.hover(function(){J.paused=true;
clearInterval(L);
L=""
},function(){J.paused=false;
if(L==""&&!D.manualAdvance){L=setInterval(function(){B(H,E,D,false)
},D.pauseTime)
}})
}H.bind("nivo:animFinished",function(){J.running=false;
A(E).each(function(){if(A(this).is("a")){A(this).css("display","none")
}});
if(A(E[J.currentSlide]).is("a")){A(E[J.currentSlide]).css("display","block")
}if(L==""&&!J.paused&&!D.manualAdvance){L=setInterval(function(){B(H,E,D,false)
},D.pauseTime)
}D.afterChange.call(this)
})
});
function B(E,F,H,J){var K=E.data("nivo:vars");
if((!K||K.stop)&&!J){return false
}H.beforeChange.call(this);
if(!J){E.css("background","url("+K.currentImage.attr("src")+") no-repeat")
}else{if(J=="prev"){E.css("background","url("+K.currentImage.attr("src")+") no-repeat")
}if(J=="next"){E.css("background","url("+K.currentImage.attr("src")+") no-repeat")
}}K.currentSlide++;
if(K.currentSlide==K.totalSlides){K.currentSlide=0;
H.slideshowEnd.call(this)
}if(K.currentSlide<0){K.currentSlide=(K.totalSlides-1)
}if(A(F[K.currentSlide]).is("img")){K.currentImage=A(F[K.currentSlide])
}else{K.currentImage=A(F[K.currentSlide]).find("img:first")
}if(H.controlNav){A(".nivo-controlNav a",E).removeClass("active");
A(".nivo-controlNav a:eq("+K.currentSlide+")",E).addClass("active")
}if(K.currentImage.attr("title")!=""){if(A(".nivo-caption",E).css("display")=="block"){A(".nivo-caption p",E).fadeOut(H.animSpeed,function(){A(this).html(K.currentImage.attr("title"));
A(this).fadeIn(H.animSpeed)
})
}else{A(".nivo-caption p",E).html(K.currentImage.attr("title"))
}A(".nivo-caption",E).fadeIn(H.animSpeed)
}else{A(".nivo-caption",E).fadeOut(H.animSpeed)
}var I=0;
A(".nivo-slice",E).each(function(){var O=Math.round(E.width()/H.slices);
A(this).css({height:"0px",opacity:"0",background:"url("+K.currentImage.attr("src")+") no-repeat -"+((O+(I*O))-O)+"px 0%"});
I++
});
if(H.effect=="random"){var L=new Array("sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade");
K.randAnim=L[Math.floor(Math.random()*(L.length+1))];
if(K.randAnim==undefined){K.randAnim="fade"
}}K.running=true;
if(H.effect=="sliceDown"||H.effect=="sliceDownRight"||K.randAnim=="sliceDownRight"||H.effect=="sliceDownLeft"||K.randAnim=="sliceDownLeft"){var G=0;
var I=0;
var N=A(".nivo-slice",E);
if(H.effect=="sliceDownLeft"||K.randAnim=="sliceDownLeft"){N=A(".nivo-slice",E).reverse()
}N.each(function(){var O=A(this);
O.css("top","0px");
if(I==H.slices-1){setTimeout(function(){O.animate({height:"100%",opacity:"1.0"},H.animSpeed,"",function(){E.trigger("nivo:animFinished")
})
},(100+G))
}else{setTimeout(function(){O.animate({height:"100%",opacity:"1.0"},H.animSpeed)
},(100+G))
}G+=50;
I++
})
}else{if(H.effect=="sliceUp"||H.effect=="sliceUpRight"||K.randAnim=="sliceUpRight"||H.effect=="sliceUpLeft"||K.randAnim=="sliceUpLeft"){var G=0;
var I=0;
var N=A(".nivo-slice",E);
if(H.effect=="sliceUpLeft"||K.randAnim=="sliceUpLeft"){N=A(".nivo-slice",E).reverse()
}N.each(function(){var O=A(this);
O.css("bottom","0px");
if(I==H.slices-1){setTimeout(function(){O.animate({height:"100%",opacity:"1.0"},H.animSpeed,"",function(){E.trigger("nivo:animFinished")
})
},(100+G))
}else{setTimeout(function(){O.animate({height:"100%",opacity:"1.0"},H.animSpeed)
},(100+G))
}G+=50;
I++
})
}else{if(H.effect=="sliceUpDown"||H.effect=="sliceUpDownRight"||K.randAnim=="sliceUpDown"||H.effect=="sliceUpDownLeft"||K.randAnim=="sliceUpDownLeft"){var G=0;
var I=0;
var M=0;
var N=A(".nivo-slice",E);
if(H.effect=="sliceUpDownLeft"||K.randAnim=="sliceUpDownLeft"){N=A(".nivo-slice",E).reverse()
}N.each(function(){var O=A(this);
if(I==0){O.css("top","0px");
I++
}else{O.css("bottom","0px");
I=0
}if(M==H.slices-1){setTimeout(function(){O.animate({height:"100%",opacity:"1.0"},H.animSpeed,"",function(){E.trigger("nivo:animFinished")
})
},(100+G))
}else{setTimeout(function(){O.animate({height:"100%",opacity:"1.0"},H.animSpeed)
},(100+G))
}G+=50;
M++
})
}else{if(H.effect=="fold"||K.randAnim=="fold"){var G=0;
var I=0;
A(".nivo-slice",E).each(function(){var O=A(this);
var P=O.width();
O.css({top:"0px",height:"100%",width:"0px"});
if(I==H.slices-1){setTimeout(function(){O.animate({width:P,opacity:"1.0"},H.animSpeed,"",function(){E.trigger("nivo:animFinished")
})
},(100+G))
}else{setTimeout(function(){O.animate({width:P,opacity:"1.0"},H.animSpeed)
},(100+G))
}G+=50;
I++
})
}else{if(H.effect=="fade"||K.randAnim=="fade"){var I=0;
A(".nivo-slice",E).each(function(){A(this).css("height","100%");
if(I==H.slices-1){A(this).animate({opacity:"1.0"},(H.animSpeed*2),"",function(){E.trigger("nivo:animFinished")
})
}else{A(this).animate({opacity:"1.0"},(H.animSpeed*2))
}I++
})
}}}}}}};
A.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,caption:true,captionOpacity:0.8,beforeChange:function(){},afterChange:function(){},slideshowEnd:function(){}};
A.fn.reverse=[].reverse
})(jQuery);
