//-----------------------------------------------------------------------//
// fonction rollover pour le menu du site 
//-----------------------------------------------------------------------//

function change_img(num){
	var imag = document.getElementById('img'+num);
	imag.src = '../img/bouton/'+num+'a.jpg';
}

function rechange_img(num){
	var imag = document.getElementById('img'+num);
	imag.src = '../img/bouton/'+num+'.jpg';
}



//-----------------------------------------------------------------------//
// fonction pour valider et tester la valeur des champs du tab_contactaire de 
// contact
//-----------------------------------------------------------------------//

function switche(nom, url){


var champ_prin = document.getElementById('conteneur_prin');
	 champ_prin.style.opacity = 0.25;
	
	
var champ_masque = document.getElementById('conteneur_masq');
	champ_masque.style.opacity = 1;
	champ_masque.style.visibility = 'visible';
	champ_masque.style.zIndex = 20;
	
	champ_masque.innerHTML = '<img src="../img/'+url+'/'+nom+'" width="350"/><br /><span class="news_titre">Photo : '+nom+'</span>'; 

}


//-----------------------------------------------------------------------//
// fonction pour faire afficher les sous menu du site 
//-----------------------------------------------------------------------//
function appar_menu(num_id, hte, nb_max){
	var mx = nb_max;
	
	for(i=1; i<=mx; i++){
	var idd = 'sous_menu'+i;
	//alert (idd);
	
	if(i == num_id){
	//alert (num_id);
	var styl = document.getElementById(idd);
	//alert(idd);
	styl.style.height = hte+'px';
	styl.style.visibility = 'visible';
	//alert(idd+2);
	}
	else{
	//alert('test');
	var styl = document.getElementById(idd);
	styl.style.height = 5 +'px';
	styl.style.visibility = 'hidden';
	styl.style.overflow = 'hidden';
	}
	}

}

//-----------------------------------------------------------------------//
// fonction pour afficher l'heure par seconde   
//-----------------------------------------------------------------------//
function heure_local() {
	var identi = document.getElementById('testage');
	//alert('test');
	var date  = new Date();
	var heure = date.getHours();
	if( heure < 10 ){ heure = '0'+heure;}
	var minute = date.getMinutes();
	
	var mois = date.getMonth()+1; 
	if( mois < 10){ mois = '0'+mois;}
	var annee = date.getFullYear(); 
	var jour = date.getDate();
	if( jour < 10){ jour = '0'+jour;}
	
	var seconde = date.getSeconds();
	if( seconde < 10) {
	var seconde = '0'+seconde;
	}
	var timer = 'Metz : '+jour+'-'+mois+'-'+annee+'  '+heure+':'+minute+':'+seconde;
	//alert('tes2');
	identi.innerHTML = timer;
	
	window.setTimeout(heure_local, 1000);
}


//-----------------------------------------------------------------------//
// fonction pour valider et tester la valeur des champs du tab_contactaire de 
// contact
//-----------------------------------------------------------------------//
function valid_contact(){
	var msg = "";
		if (document.tab_contact.email.value != "")	{
		indexAroba = document.tab_contact.email.value.indexOf('@');
		indexPoint = document.tab_contact.email.value.indexOf('.');
		if ((indexAroba < 0) || (indexPoint < 0))		{
  
			document.tab_contact.email.style.backgroundColor = "#eca201";
			document.tab_contact.email.value = "adresse incorrect";
			msg += "Ceci n'est pas une adresse mail correct \n";
		}
		
	}
 

 
	else	{
		document.tab_contact.email.style.backgroundColor = "#eca201";
		document.tab_contact.email.value = "champ vide";
		msg += "Veuillez saisir votre adresse mail.\n";
	}
	
if (document.tab_contact.nom.value == "")	{
		msg += "Veuillez saisir votre nom\n";
		document.tab_contact.nom.style.backgroundColor = "#eca201";
		document.tab_contact.nom.value = "champ vide";
	}
if (document.tab_contact.prenom.value == "")	{
		msg += "Veuillez saisir le nom de l'entreprise\n";
		document.tab_contact.prenom.style.backgroundColor = "#eca201";
		document.tab_contact.prenom.value = "champ vide";
	}
if (document.tab_contact.adresse.value == "")	{
		msg += "Veuillez saisir le nom de l'entreprise\n";
		document.tab_contact.adresse.style.backgroundColor = "#eca201";
		document.tab_contact.adresse.value = "champ vide";
	}
if (document.tab_contact.ville.value == "")	{
		msg += "Veuillez saisir le nom de l'entreprise\n";
		document.tab_contact.ville.style.backgroundColor = "#eca201";
		document.tab_contact.ville.value = "champ vide";
	}
if (document.tab_contact.cp.value == "")	{
		msg += "Veuillez saisir le nom de l'entreprise\n";
		document.tab_contact.cp.style.backgroundColor = "#eca201";
		document.tab_contact.cp.value = "champ vide";
	}

if (msg ==""){document.tab_contact.submit(); }		
	}
	
	

//-----------------------------------------------------------------------//
// fonction pour fermer le conteneur masqué  
//-----------------------------------------------------------------------//

function close_trans(){
	
	var nav=(navigator.appName).toLowerCase();
	var champ_prin = document.getElementById('conteneur_prin');
	if (nav=="netscape"){ champ_prin.style.opacity = 1} else { champ_prin.style.filter="alpha(opacity=100)"; }
	
	var champ_masque = document.getElementById('conteneur_masq');
	if (nav=="netscape"){ champ_masque.style.opacity = 0;} else { champ_masque.style.filter="alpha(opacity=0)"; }
						champ_masque.style.visibility = "hidden";
						champ_masque.style.zIndex = 1;
}



//-----------------------------------------------------------------------//
// fonction pour valider le formulaire d'enregistrement d'un utilisateur 
//-----------------------------------------------------------------------//

function valid_create(){
	
	var pwd = document.valid_inscrip.password.value; 
	var repwd = document.valid_inscrip.repassword.value; 
	
	
	var msg = 0;
		if (document.valid_inscrip.mail.value != "")	{
		indexAroba = document.valid_inscrip.mail.value.indexOf('@');
		indexPoint = document.valid_inscrip.mail.value.indexOf('.');
		if ((indexAroba < 0) || (indexPoint < 0))		{
  
			document.valid_inscrip.mail.value = "adresse mail non valide";
			var msg = 1;
		}
		
	}
	else{ 
	document.valid_inscrip.mail.value = "saisir une adresse mail"; 
	var msg = 1;
	}


	if (document.valid_inscrip.login.value == ""){
	var msg = 1;	
	}
	
	if( pwd != repwd){
	var msg = 1;	
	alert("Le mot de passe est différent de celui re-saisi");
	}
	
	
	
	if(msg == 0){
	document.valid_inscrip.submit();
	}

}

