var baseLM = 0;
var marginL = 0;
var oldXPos = 0;
var page = "racine";

function seekPage () {

	// -------------------------------------------------- //
	// Cette fonction verifie si la page en cours est l'une de celle entree dans le tableau. 
	// Si oui, elle retourne son nom. Si non, elle retourne pageNeutre
	// -------------------------------------------------- //
	
	var url = String(window.location);
	var aPages = new Array("index.php", "aProposDeNous.php", "presentation.php", "contact.php");
	
	for (var int=0; int<aPages.length; int++){

		var seekP = url.indexOf(aPages[int]);
		
		if (seekP != -1){
			
			page = aPages[int];
			int = aPages.length;
		}
	}
	
	// -------------------------------------------------- //
	
	application();
}

function application () {

	switch (page) {
	
		case "index.php" :
		case "racine" :
		lancerMinuterie();
		activeBtMenu();
		movePterMenu();
		break;
		
		case "aProposDeNous.php" :
		lancerMinuterie();
		activeBtMenu();
		movePterMenu();
		break;
				
		case "presentation.php" :
		activePage();
		activeBtMenu();
		movePterMenu();
		break;
		
		case "contact.php" :
		activePage();
		activeBtMenu();
		movePterMenu();
		break;
	}
}

function activeBtMenu () {

	var aIdBtMenu = new Array("index", "aProposDeNous", "presentation", "contact");
	
	for (var cpt=0; cpt<aIdBtMenu.length; cpt++) {
	
		var source = $("#"+aIdBtMenu[cpt]).attr("src");
		var ipoint = source.lastIndexOf(".");
		var imtype = source.charAt(ipoint-1);
		
		if (imtype != "s") {
		
		$("#"+aIdBtMenu[cpt]).bind("mouseout", {newsta : "n"}, managBoutonMenu);
		$("#"+aIdBtMenu[cpt]).bind("mouseover", {newsta : "s"}, managBoutonMenu);
		}
	}
}

function managBoutonMenu (argument) {
		
		var source = $(this).attr("src");	
		var statut = argument.data.newsta;
		var ipoint = source.lastIndexOf(".");
		var islash = source.lastIndexOf("/");
		var cleans = source.substring(0, ipoint-1);
		var imgtyp = source.substring(ipoint, source.length);
		
		$(this).attr("src", cleans+statut+imgtyp);
		
}

function movePterMenu () {

	/*$("#menu").bind("mousemove", function(e){
		
		var newXPos = e.pageX -8;
		var speed = (Math.abs((newXPos - parseInt($("#flecheMenuD").css("margin-left").split("px")[0])))/200) * 200;
				
			$("#flecheMenuD").animate ({
		
			'margin-left' : newXPos
			
			}, { queue: false, duration: speed });
	});
	
	$("#bgContenu").bind("mouseover", function(e) {
		
		var speed = (Math.abs((oldXPos - parseInt($("#flecheMenuD").css("margin-left").split("px")[0])))/200) * 200;
		
		$("#flecheMenuD").animate ({
		
		'margin-left' : oldXPos
		
		}, { queue: false, duration: speed });
	});
	
	$("#cHeader").bind("mouseover", function(e) {
		
		var speed = (Math.abs((oldXPos - parseInt($("#flecheMenuD").css("margin-left").split("px")[0])))/200) * 200;
		
		$("#flecheMenuD").animate ({
		
		'margin-left' : oldXPos
		
		}, { queue: false, duration: speed });
	});*/
}

window.onload = seekPage;
