var slider = {
	
	current : 1,
	total : 0,
	url : "http://www.webation.fr/",
	timer : null,
	
	init : function()
	{
		this.total = $(".Slide").length;
		this.timer = setInterval("slider.next()",5000);
	},
	
	next : function()
	{
		window.clearInterval(this.timer);
		this.current++;
		
		if(this.current>this.total)
		{
			this.current = 1;
		}
		
		slider.show();
		
	},
	
	prev : function()
	{
	
		window.clearInterval(this.timer);
		
		this.current--;
		
		if(this.current<1)
		{
			this.current = this.total;
		}
		
		slider.show();
		
	},
	
	show : function()
	{
		window.clearInterval(this.timer);
//		alert(this.current);
		$("#slider .Slide").fadeOut(500);
		$("#slider").html("<img src = '"+this.url+"images/loader.gif' alt = 'chargement'/>").fadeIn(500);
		
		//alert('show');
		$.ajax({
		type : 'POST',
		url : this.url+'ajax/show/',
		data : '&id='+this.current,
		success : function(data)
		{
		$("#slider img").fadeOut(500);
		$("#slider").html(data).fadeIn(500);
		}
		});
		
		this.timer = setInterval("slider.next()",5000);
		
	}

}

$(function(){
slider.init();
});