/**
 * @author gyoridavid
 * a plugin fugg a Timer plugintol !!!
 */
(function($) {
	
	$.fn.jSlider = function(options) {
		
		var defaults = {
			pause : 1500,
			speed : 1500,
            transition: "slide"
		};
		
		var config = $.extend(defaults, options);
		
		this.each(function() {
			
			var $this = $(this);
			
            if (defaults.transition == "slide") 
            {
    			var timer = new Timer((config.speed + config.pause), function() 
                {
                    $this.children(":first").animate({marginTop:-200}, config.speed, function() 
                    {
					   $this.children(":first").remove().appendTo($this).css("marginTop", 0);	
				    });
    			});
            } else
            {
                $this.children().css("position", "absolute");
                for(var i=0, j=1500; i<$this.children().length; i++, j--) 
                {
                    $this.children().eq(i).css("zIndex", j);
                }
                var timer = new Timer((config.speed + config.pause), function() 
                {
                    $this.children(":first").fadeOut(config.speed, function() 
                    {
                        var css = parseInt($this.children(":last").css("zIndex")) - 1;
                        $this.children(":first").remove().css("zIndex", css).appendTo($this).show();
                    });
    			});
            }
            timer.start();
			
            $this.hover(
                function() {
                    timer.pause();
                }, function() {
                    timer.start();
                }
            );
            
		});
        
		return this;
		
	};
	
})(jQuery);

