/**
 * jQuery simpleSlideShow
 * 
 * @author mfiocca
 */
(function($)
{
	$.fn.simpleSlideShow = function(options)
	{
		var settings = {
			width:600,
			height:300,
			speed:5,
			fade:1
		};
		
		return this.each(function()
		{
			var main = $(this);
			
			$.extend(settings, options);
			
			$(main)
				.css({
					'display':'inline-block',
					'position':'relative',
					'width':settings.width + 'px',
					'height':settings.height + 'px',
					'overflow':'hidden'
				})
				.children()
				.each(function(i, el)
				{
					$(el).css({
						'display':'inline-block',
						'position':'absolute',
						'width':settings.width + 'px',
						'height':settings.height + 'px',
						'overflow':'hidden'
					});
					
					$(main).prepend($(el));
				});
			
			var start = function(el)
			{
				stop(el);
				$.data($(el), 'interval', setInterval(function()
				{
					$(main).children().last().fadeOut((settings.fade * 1000), function()
					{
						$(main).prepend($(this).show());
					});
				},(settings.speed * 1000)));
			};
			
			var stop = function(el)
			{
				clearInterval($.data($(el), 'interval'));
				$.data($(el), 'interval', 0);
			};
			
			start();
		});
	};
	
})(jQuery);
