// JavaScript Document
<!--

// -----------  Fonctions dédiées aux vérification (CK) de formulaires  ------------
msg_nb = new String("Veuillez saisir un nombre pour le champ ");
/* 
'champ_non_vide' vérifie que le champ 'id_champ' d'un formulaire est rempli (lenght != 0), 
sinon en se servant de la légende 'alt' attribuée à l'élément '<input>' une alerte est affichée 
*/
function champ_non_vide (id_champ){
	if(document.getElementById){
    	if (document.getElementById(id_champ).value == ""){
			alert( "Le champ " + document.getElementById(id_champ).alt + " est vide !");
			document.getElementById(id_champ).focus();
			return false;
		} else { return true; }
    }//Fin if méthode 'getElementById' autorisée		
}

/* 
'ck_champ_num' vérifie que le champ 'id_champ' d'un formulaire est rempli (lenght != 0), 
et qu'il s'agit d'un nombre (entiers ou relatifs avec '.' = séparateur décimales).
Sinon en se servant de la légende 'alt' attribuée à l'élément '<input>' une alerte est affichée 
*/
function ck_champ_num (id_champ){
	if(document.getElementById){
    	if (document.getElementById(id_champ).value == ""){
			alert( "Champ " + document.getElementById(id_champ).alt + " vide !");
			document.getElementById(id_champ).focus();
			return false;
		} else { 
			//isNaN() pour Not a Number, renvoie 'true' si ce n'est pas un nb
			if (isNaN(document.getElementById(id_champ).value)){
				alert(msg_nb + document.getElementById(id_champ).alt +".");
				document.getElementById(id_champ).focus();
				return false;				
			} else { return true; }
		}//Fin Else NaN
    }//Fin if méthode 'getElementById' autorisée		
}


/* 
'ck_num' vérifie seulement que le champ 'id_champ' soit un nombre
(entiers ou relatifs avec '.' = séparateur décimales), et non qu'il soit rempli.
Si non, en se servant de la légende 'alt' attribuée à l'élément '<input>', une alerte est affichée 
*/
function ck_num (id_champ){
	if(document.getElementById){
    	if (document.getElementById(id_champ).value == ""){
			return true;
		} else { 
			//isNaN() pour Not a Number, renvoie 'true' si ce n'est pas un nb
			if (isNaN(document.getElementById(id_champ).value)){
				alert(msg_nb + document.getElementById(id_champ).alt +".");
				document.getElementById(id_champ).focus();
				return false;				
			} else { return true; }
		}//Fin Else NaN
    }//Fin if méthode 'getElementById' autorisée		
}

/* 
'ck_lg_champ' vérifie la longueur de la chaîne d'un champ si elle est remplie.
*/
function ck_lg_champ (id_champ, lg){
	if(document.getElementById){
		if (document.getElementById(id_champ).value.length != lg){			
			alert("Veuillez saisir "+ lg +" caractères pour le champ "+ document.getElementById(id_champ).alt +" SVP.");
			document.getElementById(id_champ).focus();
			return false;
		} else { return true; }
    }//Fin if méthode 'getElementById' autorisée	
}

/* 
'email_valid' vérifie seulement que la chaîne 'email' soit conforme (avec un '@' et un '.'), mais non qu'elle soit remplie.
*/
function email_valid(id_champ){
	if(document.getElementById){
		var email = document.getElementById(id_champ).value;
		if ((email.length) && (email.indexOf("@") == -1 || email.indexOf(".") == -1)) {
			alert("Veuillez entrer une adresse électronique valide SVP !");
			document.getElementById(id_champ).focus();
			return false;
		} else { return true; }
    }//Fin if méthode 'getElementById' autorisée		
}


/******   Vérification dédiée au formulaire   ******/
function ck_form(){
//Cas, des balise '<input>', où la fonction avec alert() JS comprenant le libellé provenant de la légende 'alt' est utiliséé.
	if (
		   !(champ_non_vide ('nom'))    // coord
		//|| !(champ_non_vide ('societe'))
		|| !(champ_non_vide ('email'))  //Email rempli
		|| !(email_valid ('email'))	  //Email valide
		//|| !(champ_non_vide ('tel'))       // vérif rempli
	   ) 
		{ return false; }
}

/******   la gelerie photo   ******/
	function updateImage(img, img_alt, titre, tab_txt, url, cat) {
		var elt = document.getElementById('descriptif_image');
		var htmlImg = '<img src="'+img+'" alt="'+img_alt+'" title="'+img_alt+'" /> ';
		var htmlTitle = '<div class="texte_gras">'+titre+'</div>';
		var htmlTexte = '';
		for (var txt in tab_txt) {
			htmlTexte += '<div class="texte">'+tab_txt[txt]+'</div>';
		}
		elt.innerHTML = htmlImg + htmlTitle + htmlTexte + '<div class="retour"><div class="retour_texte"><a href="'+url+'">retour au Portfolio '+cat+'</a></div></div>';
	}
	function updateImageEn(img, img_alt, titre, tab_txt, url, cat) {
		var elt = document.getElementById('descriptif_image');
		var htmlImg = '<img src="'+img+'" alt="'+img_alt+'" title="'+img_alt+'" /> ';
		var htmlTitle = '<div class="texte_gras">'+titre+'</div>';
		var htmlTexte = '';
		for (var txt in tab_txt) {
			htmlTexte += '<div class="texte">'+tab_txt[txt]+'</div>';
		}
		elt.innerHTML = htmlImg + htmlTitle + htmlTexte + '<div class="retour"><div class="retour_texte"><a href="'+url+'">Back to '+cat+' Portfolio</a></div></div>';
	}

/******   la gelerie photo metiers  ******/
	function updateImageMetier(img, img_alt, titre, tab_txt, url, cat) {
		var elt = document.getElementById('descriptif_image_metier');
		var htmlImg = '<img src="'+img+'" alt="'+img_alt+'" title="'+img_alt+'" /> ';
		var htmlTitle = '<div class="texte_gras">'+titre+'</div>';
		var htmlTexte = '';
		for (var txt in tab_txt) {
			htmlTexte += '<div class="texte">'+tab_txt[txt]+'</div>';
		}
		elt.innerHTML = htmlImg + htmlTitle + htmlTexte;
	}


