<!--
function reload_form(task){
	var url= 'etc/check_form.php?task='+task;
//alert(url);
	pop_hidden(url)
	return false;
}

function code_ok(cod0, cod1){
	var error= (cod0 == cod1) ? 0 : 8;
	return error;
}

function pwd_ok(pwd0, pwd1){
	var error= (pwd0 == pwd1) ? 0 : 6;
	return error;
}

function email_ok(email){
  var reg= /([a-z0-9]+([-_]?[a-z0-9]+)*.)*[a-z0-9]+([-_]?[a-z0-9]+)*@([a-z0-9]+([-_]?[a-z0-9]+)*.)+[a-z]{2,4}/gi;  
	var error= (email.match(reg) == email) ? 0 : 4;
	return error;
}

function cbx_ok(cur) {
	var error= 9;
//	var cb = document.getElementById('cbx[]');
	for (i=0; i<cur["cbx[]"].length; i++) {
		if(cur["cbx[]"][i].checked) {
			 error= 0;
		}
	}
	return error;
}
function v_form(pop, task, cur){
	var minchar=5
	var error= ((cur.log0.value == "") || (cur.log0.value.length<minchar)) ? 1 : 0;
	if (error==0)
		error= ((cur.pwd0.value == "") || (cur.pwd0.value.length<minchar)) ? 2 : 0;
	if (error==0){
		switch (task) {
			case 5:	// Devis
				error= ((cur.eml0.value == "") || (cur.eml0.value.length<minchar)) ? 3 : 0;
				if (error==0)
					error= email_ok(cur.eml0.value);
				if (error==0)
					error= (cur.txt0.value == "") ? 7 : 0;
				if (error==0)
					error= ((cur.cod0.value == "") || (cur.cod0.length<minchar)) ? 8 : 0;
				if (error==0)
					error= code_ok(cur.cod0.value, cur.codx.value);
				if (error==0)
					error= cbx_ok(cur);
			break;
			case 4:	// Me contacter
				error= ((cur.eml0.value == "") || (cur.eml0.value.length<minchar)) ? 3 : 0;
				if (error==0)
					error= email_ok(cur.eml0.value);
				if (error==0)
					error= (cur.txt0.value == "") ? 7 : 0;
				if (error==0)
					error= ((cur.cod0.value == "") || (cur.cod0.length<minchar)) ? 8 : 0;
				if (error==0)
					error= code_ok(cur.cod0.value, cur.codx.value);
			break;
			case 3:	// Enregistrement
				error= ((cur.cod0.value == "") || (cur.cod0.length<minchar)) ? 5 : 0;
				if (error==0)
					error= pwd_ok(cur.pwd0.value, cur.pwd1.value);
				if (error==0)
					error= code_ok(cur.cod0.value, cur.codx.value);
			case 2:	// Mot de passe oublié
			case 1:	// Identifiant oublié
				error= ((cur.eml0.value == "") || (cur.eml0.value.length<minchar)) ? 3 : 0;
				if (error==0)
					error= email_ok(cur.eml0.value);
			break;
			default: // Connexion
			break;
		}
	}

	if (error>0){
		msg= "-*- Champ obligatoire vide ou pas assez de caractères ! -*-";
		msg= msg+'\n1- Tous les champs obligatoires doivent être saisis.';
		msg= msg+'\n2- Saisissez au minimum -> '+minchar+' caractères.';
		switch (error) {
			case 9:
				msg= "-*- Merci de choisir une solutions informatiques -*-";
				cur["cbx[]"][0].focus();
			break;
			case 8:
				msg= "-*- Code incorrecte ! -*-";
				msg= msg+'\n Vérifiez votre saisi.';
				cur.cod0.select();
				cur.cod0.focus();
			break;
			case 7:
				cur.txt0.focus();
			break;
			case 6:
				msg= "-*- Les 2 mots de passe ne correspondent pas ! -*-";
				msg= msg+'\n Vérifiez votre saisi.';
				cur.pwd0.value='';
				cur.pwd1.value='';
				cur.pwd0.focus();
			break;
			case 5:
				cur.cod0.focus();
			break;
			case 4:
				msg= "-*- Adresse E-mail incorrecte ! -*-";
				msg= msg+'\n Vérifiez le format de votre saisi.';
				cur.eml0.select();
				cur.eml0.focus();
			break;
			case 3:
				cur.eml0.select();
				cur.eml0.focus();
			break;
			case 2:
				cur.pwd0.focus();
			break;
			default: 
				cur.log0.focus();
			break;
		}
		alert(msg);
		return false
	}
	else {
		if (pop==0) {
			switch (task){
				case 3:	// Enregistrement
					var cntx= (cur.cbx.checked == true) ? 1 : 0;
					var variables= '&eml0='+cur.eml0.value+'&pwd1='+cur.pwd1.value+'&cod0='+cur.cod0.value+'&cntx='+cntx;
					task=5;
				break;
				case 2:	// Mot de passe oublié
					var variables= '&eml0='+cur.eml0.value;
					task=4;
				break;
				case 1:	// Identifiant oublié
					var variables= '&eml0='+cur.eml0.value;
					task=3;
				break;
				default: // Connexion
					var cntx= (cur.cbx.checked == true) ? 1 : 0;
					var variables= '&cntx='+cntx;
				break;
			}
			var url= 'etc/check_form.php?task='+task+'&log0='+cur.log0.value+'&pwd0='+cur.pwd0.value+variables;
//alert(url);
			pop_hidden(url)
			return false;
		}
		else {
			return true;
		}
	}
}
// -->
