// Script de navigation graphique
// Auteur: Axel QURIS - webmaster@alifsoundsystem.net


//Affichage des calques
function Affiche(NomCalque){
	document.getElementById(NomCalque).style.visibility="visible";
}

//Affichage du calque de prechargement
function AffichePreload(){
	var SITEVU=Lire("sitevu");
	if(SITEVU!=1) document.write("<div id='Preload' style='position:absolute; width:100%; height:100%; background-color: #000066; layer-background-color: #000066; visibility:visible; z-index:4'><div id='SOS' style='position:absolute; z-index:5'><a href='#' class='Style11' onClick='ChargementOk();'>SORTIE DE SECOURS (PRECHARGEMENT=30s@56K)</a></div><table width='100%' height='100%' border='0' align='center' bgcolor='#FFFFFF'><tr align='center' valign='middle'><td align='center' valign='middle'><img src='images/titre.gif' width='600' height='96' align='absmiddle'><br><br><img src='images/preload.gif' width='409' height='23'>&nbsp;&nbsp;<img name='cnt' id='cnt' src='images/0lcd.gif' width='11' height='23'><img name='dzn' id='dzn' src='images/0lcd.gif' width='11' height='23'><img name='unt' id='unt' src='images/0lcd.gif' width='11' height='23'><img src='images/pourcent.gif' width='16' height='23'></td></tr></table></div>");
	else document.write("<div id='Preload' style='position:absolute; width:100%; height:100%; background-color: #000066; layer-background-color: #000066; visibility:hidden; z-index:4'><div id='SOS' style='position:absolute; z-index:5'><a href='#' class='Style11' onClick='ChargementOk();'>SORTIE DE SECOURS (PRECHARGEMENT=30s@56K)</a></div><table width='100%' height='100%' border='0' align='center' bgcolor='#FFFFFF'><tr align='center' valign='middle'><td align='center' valign='middle'><img src='images/titre.gif' width='600' height='96' align='absmiddle'><br><br><img src='images/preload.gif' width='409' height='23'>&nbsp;&nbsp;<img name='cnt' id='cnt' src='images/0lcd.gif' width='11' height='23'><img name='dzn' id='dzn' src='images/0lcd.gif' width='11' height='23'><img name='unt' id='unt' src='images/0lcd.gif' width='11' height='23'><img src='images/pourcent.gif' width='16' height='23'></td></tr></table></div>");
}

//Décalage de la page au chargement
function Bouge(lecalque){
	document.getElementById(lecalque).style.left=0;
	document.getElementById(lecalque).style.top=0;
	Calcul_decal();
	document.getElementById(lecalque).style.left=parseInt(document.getElementById(lecalque).style.left)+decalx;
	document.getElementById(lecalque).style.top=parseInt(document.getElementById(lecalque).style.top)+decaly;
}

//Calcul du décalage en fonction de l'affichage
var decalx;
var decaly;
function Calcul_decal(){
	if(window.innerWidth) decalx=(window.innerWidth-800)/2;
	else decalx=(document.body.clientWidth-800)/2;
	if(decalx<0) decalx=0;
	if(window.innerHeight) decaly=(window.innerHeight-600)/2;
	else decaly=(document.body.clientHeight-600)/2;
	if(decaly<0) decaly=0;
}

//Popup centré
function center(la_page,nom,ix,yg,sc,loc,sta){
	var gau=(screen.width-18-ix)/2;
	var haut=(screen.height-10-yg)/2;
	window.open(la_page,nom,'width='+ix+',height='+yg+',left='+gau+',top='+haut+',menubar=no,location='+loc+',status='+sta+',scrolling='+sc);
}

//Effaçage du calque de préchargement
function ChargementOk(){
	document.cookie="sitevu=1";
	Affiche("fond");
	Efface("Preload");
	Efface("SOS");
}

//Compteur de préchargement graphique
var i_conten=1;
var augm_conten;
var avcm_conten;
var dizn_conten;
var unte_conten;
var d_conten;
var u_conten;
function Count_conten(elements){
	augm_conten=100/elements;
	if(i_conten>=elements){
		document.images["cnt"].src="images/1lcd.gif";
		document.images["dzn"].src="images/0lcd.gif";
		document.images["unt"].src="images/0lcd.gif";
		//Onload
		setTimeout("ChargementOk()",2000);
	}
	else{
		avcm_conten=Math.floor(i_conten*augm_conten);
		dizn_conten=Math.floor(avcm_conten/10);
		unte_conten=avcm_conten-(10*dizn_conten);
		d_conten="images/"+dizn_conten+"lcd.gif";
		u_conten="images/"+unte_conten+"lcd.gif";
		document.images["dzn"].src=d_conten;
		document.images["unt"].src=u_conten;
	}
	i_conten++;
}

//Effaçage des calques
function Efface(NomCalque){
	document.getElementById(NomCalque).style.visibility="hidden";
}

//Lecture cookies
function Lire(Nom){
	Nom+="=";
	Lu=document.cookie.indexOf(Nom,0);
	if(Lu<=-1) return("non");
	else{
		End=document.cookie.indexOf(";",Lu);
		if(End<=-1) return(unescape(document.cookie.substring(Lu+Nom.length,document.cookie.length)));
		else return(unescape(document.cookie.substring(Lu+Nom.length,End)));
	}
}

//Rollovers par positionnement de la souris
var champ_actif;
function mouseMove(evt){ 
	var x=0;
	var y=0;
	if(document.layers){
		x=evt.x; y=evt.y;
	} 
	if(document.all){
		x=event.clientX;
		y=event.clientY;
	}
	else{
		if(document.getElementById){
			x=evt.clientX;
			y=evt.clientY; 
		}
	}
	if(((x>84+decalx)&&(y>70+decaly))&&((x<84+46+decalx)&&(y<70+46+decaly))){
		Affiche("sommaire2");
		Efface("sommaire0");
		window.status="Sommaire";
		champ_actif=1;
		//TEST SWAP OVERRIDE
		Swap("internet","Out");
		Swap("graphisme","Out");
		Swap("maintenance","Out");
		Swap("email","Out");
		Swap("phone","Out");
	}
	if(champ_actif==1&&(x<84+decalx||y<70+decaly||x>84+46+decalx||y>70+46+decaly)){
		Affiche("sommaire0");
		Efface("sommaire2");
		window.status="";
		champ_actif=0;
	}
	if(((x>33+decalx)&&(y>156+decaly))&&((x<33+46+decalx)&&(y<156+46+decaly))){
		Affiche("internet2");
		Efface("internet0");
		window.status="Internet";
		champ_actif=2;
		//TEST SWAP OVERRIDE
		Swap("sommaire","Out");
		Swap("graphisme","Out");
		Swap("maintenance","Out");
		Swap("email","Out");
		Swap("phone","Out");
	}
	if(champ_actif==2&&(x<33+decalx||y<156+decaly||x>33+46+decalx||y>156+46+decaly)){
		Affiche("internet0");
		Efface("internet2");
		window.status="";
		champ_actif=0;
	}
	if(((x>13+decalx)&&(y>247+decaly))&&((x<13+46+decalx)&&(y<247+46+decaly))){
		Affiche("graphisme2");
		Efface("graphisme0");
		window.status="Graphisme";
		champ_actif=3;
		//TEST SWAP OVERRIDE
		Swap("sommaire","Out");
		Swap("internet","Out");
		Swap("maintenance","Out");
		Swap("email","Out");
		Swap("phone","Out");
	}
	if(champ_actif==3&&(x<13+decalx||y<247+decaly||x>13+46+decalx||y>247+46+decaly)){
		Affiche("graphisme0");
		Efface("graphisme2");
		window.status="";
		champ_actif=0;
	}
	if(((x>12+decalx)&&(y>342+decaly))&&((x<12+46+decalx)&&(y<342+46+decaly))){
		Affiche("maintenance2");
		Efface("maintenance0");
		window.status="Maintenance";
		champ_actif=4;
		//TEST SWAP OVERRIDE
		Swap("sommaire","Out");
		Swap("internet","Out");
		Swap("graphisme","Out");
		Swap("email","Out");
		Swap("phone","Out");
	}
	if(champ_actif==4&&(x<12+decalx||y<342+decaly||x>12+46+decalx||y>342+46+decaly)){
		Affiche("maintenance0");
		Efface("maintenance2");
		window.status="";
		champ_actif=0;
	}
	if(((x>23+decalx)&&(y>426+decaly))&&((x<23+46+decalx)&&(y<426+46+decaly))){
		Affiche("email2");
		Efface("email0");
		window.status="Contact e-mail";
		champ_actif=5;
		//TEST SWAP OVERRIDE
		Swap("sommaire","Out");
		Swap("internet","Out");
		Swap("graphisme","Out");
		Swap("maintenance","Out");
		Swap("phone","Out");
	}
	if(champ_actif==5&&(x<23+decalx||y<426+decaly||x>23+46+decalx||y>426+46+decaly)){
		Affiche("email0");
		Efface("email2");
		window.status="";
		champ_actif=0;
	}
	if(((x>51+decalx)&&(y>515+decaly))&&((x<51+46+decalx)&&(y<515+46+decaly))){
		Affiche("phone2");
		Efface("phone0");
		window.status="Contact téléphonique";
		champ_actif=6;
		//TEST SWAP OVERRIDE
		Swap("sommaire","Out");
		Swap("internet","Out");
		Swap("graphisme","Out");
		Swap("maintenance","Out");
		Swap("email","Out");
	}
	if(champ_actif==6&&(x<51+decalx||y<515+decaly||x>51+46+decalx||y>515+46+decaly)){
		Affiche("phone0");
		Efface("phone2");
		window.status="";
		champ_actif=0;
	}
} 

//Rollovers par calques
var Visible="sommaire";
var VisibleContenu;
var VisibleHaut;
var CalqueOn;
var CalqueOff;
function Swap(Calque,Mode){
		if(Mode=="Over"){
		//Debug swap override
		Swap("sommaire","Out");
		Swap("internet","Out");
		Swap("graphisme","Out");
		Swap("maintenance","Out");
		Swap("email","Out");
		Swap("phone","Out");
		//Swap
		CalqueOn=Calque+"2";
		CalqueOff=Calque+"0";
		Efface(CalqueOff);
		Affiche(CalqueOn);
	}
	if(Mode=="Out"){
		CalqueOn=Calque+"0";
		CalqueOff=Calque+"2";
		Efface(CalqueOff);
		Affiche(CalqueOn);
	}
	if(Mode=="Click"){
		if(Visible=="sommaire"||Visible=="internet"||Visible=="graphisme"||Visible=="maintenance"){
			VisibleHaut="haut_"+Visible;
			Efface(VisibleHaut);
		}
		VisibleContenu="contenu"+Visible;
		Visible+="1";
		CalqueOn=Calque+"1";
		CalqueOff=Calque+"2";
		Efface(Visible);
		Efface(CalqueOff);
		Efface(VisibleContenu);
		Affiche(CalqueOn);
		Visible=Calque;
		if(Visible=="sommaire"||Visible=="internet"||Visible=="graphisme"||Visible=="maintenance"){
			VisibleHaut="haut_"+Visible;
			Affiche(VisibleHaut);
		}
		VisibleContenu="contenu"+Visible;
		Affiche(VisibleContenu);
	}
}

//Test de remplissage des formulaires
function test_form(nombre){
	if(document.forms[nombre].Expediteur.value==""||document.forms[nombre].Adresse_expediteur.value==""||document.forms[nombre].Sujet.value==""||document.forms[nombre].Message.value==""){
		alert("Veuillez SVP renseigner tous les champs du formulaire.");
	}
	else document.forms[nombre].submit();
}

//Lancement du suivi de la souris pour gestion des rollovers
if(document.layers) document.captureEvents(Event.MOUSEMOVE); 
if(document.layers||document.all) document.onmousemove=mouseMove; 
if(document.addEventListener) document.addEventListener('mousemove',mouseMove,true);
