// JavaScript Document
if (document.cookie) {
	// Tout va bien
} else {
	document.cookie = "essai=cookie";
	if (document.cookie) {
		// Tout va bien
	} else {
		alert("AVERTISSEMENT\n\nVotre navigateur n'accepte pas les cookies.\n\nLa navigation sur ce site peut s'av?rer difficile voire impossible. Il est fortement recommand? de modifier la configuration de votre navigateur.\n\nRAPPEL : les cookies ne sont QUE des fichiers texte\nIls ne sont donc pas nuisibles !");
	}
}

function afficherHeure(page) {
	var today=new Date();
	var date_heure="";
	h = today.getHours();
	m = today.getMinutes();
	s = today.getSeconds();

	if(h<10) { h = '0'+h; }
	if(m<10) { m = '0'+m; }
	if(s<10) { s = '0'+s; }
	date_heure = ''+h+':'+m+':'+s+'';

	document.getElementById('heure').innerHTML = date_heure;
}

function addHover (elm) {
	elm.style.behavior = " ";
	elm.onmouseenter = function() {
		this.className+= ' hover';
	}
	elm.onmouseleave = function() {
		this.className = this.className.replace(/\bhover\b/,"" );
	}
}

function updatePwdForce() {
	var pwd = document.getElementById("signin_newpwd_id").value;
	var force = 0;

	locase_matches = pwd.match(/[a-z_]/g); // lowercase and '_' matches
	digit_matches = pwd.match(/[0-9]/g);   // numeric matches
	upcase_matches = pwd.match(/[A-Z]/g);  // uppercase matches
	special_matches = pwd.match(/\W/g);    // special matches (not in a-z, A-Z, 0-9, _)

	// Tant que moins de 5 caract?res, mot de passe trop court
	if (pwd.length>5) {
		// 1 point pour chaque caract?re en plus des 5 premiers
		force += pwd.length - 5;
		// 1 point pour charque caract?re en MAJ m?lang? avec des MIN
		if (locase_matches && upcase_matches) {
			force += upcase_matches.length;
		}
		// 1 point pour chaque chiffre m?lang? ? des MIN
		if (locase_matches && digit_matches) {
			force += digit_matches.length;
		}
		// 1 point pour chaque caract?re sp?cial
		if (special_matches) {
			force += special_matches.length;
		}
		
		// 2 points bonus points si il y a un m?lange de lettre, chiffre
		if ((locase_matches || upcase_matches) && digit_matches) {
			force += 2;
		}
	} else {
		force = 0;
	}
	
	
	if (force == 0) {
		document.getElementById('pwdSecurity').style.backgroundColor = "#ff0000";
		document.getElementById('pwdSecurity').innerHTML = 'Tr&eacute;s faible';
	} else if (force < 3) {
		document.getElementById('pwdSecurity').style.backgroundColor = "#b34b00";
		document.getElementById('pwdSecurity').innerHTML = 'Faible';
	} else if (force < 7) {
		document.getElementById('pwdSecurity').style.backgroundColor = "#7d8100";
		document.getElementById('pwdSecurity').innerHTML = 'Moyen';
	} else if (force < 10) {
		document.getElementById('pwdSecurity').style.backgroundColor = "#48b600";
		document.getElementById('pwdSecurity').innerHTML = 'Bon';
	} else {
		document.getElementById('pwdSecurity').style.backgroundColor = "#00ff00";
		document.getElementById('pwdSecurity').innerHTML = 'Elev&eacute;';
	}
}

function validCateg () {
	document.getElementById('tpValid').value = "OUI";
	document.getElementById("frmCpt").submit();
}

function validerSupression () {
	if (confirm("Etes-vous sur de vouloir supprimer cette(ces) annonce(s) ?" )) {
		document.getElementById("idSuppression").submit();
	}
	return false;
}

function closeInfoOnTop () {
	document.getElementById('infoOnTop').style.visibility = "hidden";
	document.getElementById('popupInfoOnTop').style.visibility = "hidden";
}

function changeLogo () {
	var tp = document.getElementById('signin_civ_id').value;
	document.images['pictSigle'].src = "/commun/design/"+tp+".png";
}

function validerSupressionImg (id, img) {
	if (confirm("Etes-vous sur de vouloir supprimer cette photo ?" )) {
		document.location.href="/enlever-image-"+img+"-"+id+".html";
	}
	return false;
}

function verifMoreMarque (nomTyp, nomLst, priorite) {
	var tempo;
	if ( document.getElementById(nomLst).value != undefined ) {
		tempo = document.getElementById(nomLst).value;
	} else {
		var tutu = nomLst+'IE';
		alert(document.getElementsByTagName(tutu).selectedIndex);
		tempo = document.tutu.value;
	}

	if (tempo == '999') {
		getLstMarque (nomTyp, nomLst, priorite);
	}
}