var numCourant;
var stop;
$(document).ready(function(){
	
	var first = getUrlVars()["show"];
	
	if(first=="p")
	{
		$("#accueil").hide().fadeIn(2000);
	}else
	{
		$("#accueil").hide().delay(500).fadeIn(4000);
		$("#footer,#menuTop").hide().delay(2000).fadeIn(3000);;
	}	
	
	/*$("#myForm").submit(function()
		{	
		$("#resultAjax").empty();		
		$("#loader").show();
		$.post("unzip.php",function(data){
			$("#loader").hide();
			$("#resultAjax").append(data);
		});	
		return false;				
	});*/
		
	s = new slider();		
});

function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

var slider = function(){
 	
	
	
	//Initialiation des variables
	var self = this;
	this.div=$("#accueil");
	this.suiv=this.div.find("#suiv");
	this.prec=this.div.find("#prec");
	
	//initialisation des compteurs
	numCourant=1;	
	
	//initialisation des boutons
	this.prec.hide();
	
	// Avancer d'un cran
	this.next = function(){
		
		
		if(stop==true){return false;}
		
		numCourant++;
		if(numCourant==6){$("#suiv").hide()};
		if(numCourant>0){ self.prec.show();};	
		stop=true;
		
		self.div.find("#slider").animate({
			"left":-472*(numCourant-1)
		},3000,'easeOutElastic',function()
		{	
			stop=false;
		});
				
	}
	
	// Reculer d'un cran
	this.prev = function(){
		
		if(stop==true){return false;}
		
		numCourant--;
		if(numCourant<6){$("#suiv").show()};
		if(numCourant==1){$("#prec").hide()};	
		stop=true;
		
		
		self.div.find("#slider").animate({
			"left":-472*(numCourant-1)
		},3000,'easeOutElastic',function()
		{	
			stop=false;						
		});

	}
	
	this.prec.bind('click',this.prev);	
	this.suiv.bind('click',this.next);
	this.prec.hide();
}
