//******************************************
// 2010-07-21
// Luc Ledoux
// jQuery 1.2.6
// Tested : Firefox 3.6, Chrome, IE7, IE8
//******************************************

//Example***********************************
//$(document).ready(function(){
//        $("#slideshow").slideshow({rotationSpeed : 3000});
//    });
//******************************************

(function($){
    $.fn.extend({
        slideshow: function(options){

            var defaults = {
                rotationSpeed : 5000
                };

            var options = $.extend(defaults,options);

            return this.each(function() {

                $(this).children().css({position:'absolute',zIndex:'0'});
                $(this).children().removeAttr('class').eq(0).css('zIndex','10');
                $(this).children().find('img').css({position:'absolute',zIndex:'-1'});

                setTimeout("ShowSlide('" + options.rotationSpeed + "')", options.rotationSpeed);
            });
        }
    });
})(jQuery);

function ShowSlide(rotationSpeed){

    var $n=0;
    $('#slideshow > div').filter(function() { return $(this).attr('style'); }).each(function(){
        if($(this).attr('style').toLowerCase().indexOf('z-index: 10') !=-1){$n = $(this);}
    })

    var $nextSlide = $n.next();
    if($nextSlide.length==0){$nextSlide=$n.siblings().eq(0);}
    $nextSlide.css('zIndex','9');
    $n.fadeOut('normal',function(){
        $nextSlide.css('zIndex','10');
        $n.css('zIndex','0')
          .show('fast');
        setTimeout("ShowSlide('" + rotationSpeed + "')", rotationSpeed);
    })
}

