/*
*	imageRotator
*	jQuery plugin
*	http://koggdal.com/extras/imagerotator/
*
*	by Johannes Koggdal, 2010
*	http://www.koggdal.com/
*
*
*	Free to distribute and edit any way you like, just keep my name in this comment.
*
*
*	See plugin website for more info on how to use it.
*/
(function(a,b){a.fn.imageRotator=function(k){if(this.length==0){return this}var k=k||{};var d=a.extend({timePerImage:3000,timeFadeIn:1000,timeFadeOut:0,timeOffsetFadeOut:k.timeFadeIn||1000},k),h=this.find("li").first(),e=h,c=e.next(),i=1,j=function(){var l=c.next();if(l.length>0){if(c==h){c.css({zIndex:100})}e=c;c=l}else{e=c;c=h;c.css({zIndex:1000})}},f=function(){var l=function(){if(d.timeOffsetFadeOut>=0){j()}setTimeout(f,d.timePerImage-(d.timeOffsetFadeOut<0?d.timeOffsetFadeOut:0)+(d.timeFadeIn-d.timeFadeOut))};if(d.timeFadeOut>0){e.fadeOut(d.timeFadeOut,l)}else{e.hide();l()}},g=function(){c.fadeIn(d.timeFadeIn,function(){if(d.timeOffsetFadeOut<0){j()}setTimeout(g,d.timePerImage-(d.timeOffsetFadeOut<0?d.timeOffsetFadeOut:0))})};setTimeout(f,d.timePerImage+d.timeOffsetFadeOut+(d.timeFadeIn-d.timeFadeOut));setTimeout(g,d.timePerImage);return this}})(jQuery);
