(function ($) {
    $.fn.mikeFadeInOut = function (options) {
        var o = $.extend({}, $.fn.mikeFadeInOut.defaultOptions, options);
        return this.each(function () {
            var $$ = $(this);
            var slide = [];            
            var oldslide = 0;
            var currentslide = 0;

            $$.find('img').each(function (i, el) { slide[i] = $(this); });
            
						$('#content_center').css({'margin-left': slide[0].width()});
            
            function nextSlide() {
                oldslide = currentslide;
                currentslide = currentslide < slide.length - 1 ? currentslide + 1 : 0;
                slide[currentslide].fadeIn(o.transitionSpeed);
                slide[oldslide].fadeOut(o.transitionSpeed);
								timer()
            }
						function timer()
						{
								window.setTimeout(nextSlide, o.showPictureFor);
						}
						slide[currentslide].fadeIn(o.transitionSpeed, timer);
        });
    };
    $.fn.mikeFadeInOut.defaultOptions = {
        transitionSpeed: 1500,
        showPictureFor: 3000
    };
})(jQuery);
