﻿
(function(jQuery) {


    var defaults = {
        interval: 5000,
        transitionDelay: 1000,
        compensateWidth: 0,
        compensateHeight: 0
    }

    jQuery.fn.superSimpleSlideShow = function(options) {

        $.extend(defaults, options);

        return this.each(
				function() {

				    var options = $.extend({}, defaults);
				    var jRef = jQuery(this);
				    var children = jRef.children();
				    var firstChild = jQuery(children[0]);

				    if (children.length > 0) {
				        setTimeout(
			                function() {
			                    jRef.show();
			                    jRef.height((firstChild.height() + options.compensateHeight) + "px");
			                    jRef.width((firstChild.width() + options.compensateWidth) + "px");

			                }, 300
					     );
				    }
				    else
				        jRef.parent().hide();

				    options.currentItem = 0;

				    if (children.length > 1) {
				        options.intervalRef = setInterval(

							function() {

							    var currentChild = jQuery(children[options.currentItem]);
							    options.currentItem++;
							    if (options.currentItem > children.length - 1) options.currentItem = 0;

							    var nextChild = jQuery(children[options.currentItem]);

							    nextChild.fadeIn(options.transitionDelay,
									function() {
									    jRef.append(currentChild.hide());
									}
								);

							}
							, options.interval
						);
				    }

				}
			);

    };


}
)
(jQuery);


	
