function verif1Inputs() {
	//1 pseudo
	var input=document.form.posted_name.value;
	
	//width
	if (input.length<3) {
		document.getElementById('verif1').innerHTML='<font color="red">Taille minimale : 3 !</font>';
		return false;
	}
	
	else if (input.length>25) {
		document.getElementById('verif1').innerHTML='<font color="red">Taille maximale : 25 !</font>';
		return false;
	}
	
	//regex
	var regexp=/[^A-Za-z0-9._-]/gi;
	if (regexp.exec(input)!=null) {
		document.getElementById('verif1').innerHTML='<font color="red">Présence de caractères interdits !</font>';
		return false;
	}
	
	//exist?
	if (window.XMLHttpRequest)
		xhr=new XMLHttpRequest();	
	else if (window.ActiveXObject)
		xhr=new ActiveXObject("Microsoft.XMLHTTP");
	
	xhr.open("GET", "ajax/pseudo_existence.php?pseudo="+input, false);
	xhr.send(null);
	
	if (xhr.responseText!='0') {		
		document.getElementById('verif1').innerHTML='<font color="red">Pseudonyme déjà utilisé !</font>';
		return false;
	}
	
	document.getElementById('verif1').innerHTML='<font color="green">Pseudonyme sélectionnable !</font>';
	return true;
}

function verif2Inputs() {
	var input=document.form.posted_pass1.value;
	
	//width
	if (input.length<5) {
		document.getElementById('verif2').innerHTML='<font color="red">Taille minimale : 5 !</font>';
		return false;
	}
	
	else if (input.length>25) {
		document.getElementById('verif2').innerHTML='<font color="red">Taille maximale : 25 !</font>';
		return false;
	}
	
	document.getElementById('verif2').innerHTML='<font color="green">Mot de passe acceptable !</font>';
	return true;
}

function verif3Inputs() {
	var input=document.form.posted_pass2.value;
	var input2=document.form.posted_pass1.value;
	
	//width
	if (input.length<5) {
		document.getElementById('verif3').innerHTML='<font color="red">Taille minimale : 5 !</font>';
		return false;
	}
	
	else if (input.length>25) {
		document.getElementById('verif3').innerHTML='<font color="red">Taille maximale : 25 !</font>';
		return false;
	}
	
	else if (input!=input2) {
		document.getElementById('verif3').innerHTML='<font color="red">Confirmation fausse !</font>';
		return false;
	}
	
	document.getElementById('verif3').innerHTML='<font color="green">Confirmation juste !</font>';
	return true;
}

function verif4Inputs() {
	var input=document.form.posted_mail1.value;
	
	//regex
	var regexp=/^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/;
	if (regexp.exec(input)==null) {
		document.getElementById('verif4').innerHTML='<font color="red">Mauvaise syntaxe !</font>';
		return false;
	}
	
	//exist?
	if (window.XMLHttpRequest)
		xhr=new XMLHttpRequest();	
	else if (window.ActiveXObject)
		xhr=new ActiveXObject("Microsoft.XMLHTTP");
	
	xhr.open("GET", "ajax/mail_existence.php?mail="+input, false);
	xhr.send(null);
	
	if (xhr.responseText!='0') {		
		document.getElementById('verif4').innerHTML='<font color="red">Mail déjà utilisé !</font>';
		return false;
	}
		
	document.getElementById('verif4').innerHTML='<font color="green">Bonne syntaxe !</font>';
	return true;
}

function verif5Inputs() {
	var input=document.form.posted_mail2.value;
	var input2=document.form.posted_mail1.value;
	
	//regex
	var regexp=/^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/;
	if (regexp.exec(input)==null) {
		document.getElementById('verif5').innerHTML='<font color="red">Mauvaise syntaxe !</font>';
		return false;
	}
	
	if (input!=input2) {
		document.getElementById('verif5').innerHTML='<font color="red">Confirmation fausse !</font>';
		return false;
	}	
	
	//exist?
	if (window.XMLHttpRequest)
		xhr=new XMLHttpRequest();	
	else if (window.ActiveXObject)
		xhr=new ActiveXObject("Microsoft.XMLHTTP");
	
	xhr.open("GET", "ajax/mail_existence.php?mail="+input, false);
	xhr.send(null);
	
	if (xhr.responseText!='0') {		
		document.getElementById('verif5').innerHTML='<font color="red">Mail déjà utilisé !</font>';
		return false;
	}
		
	document.getElementById('verif5').innerHTML='<font color="green">Bonne syntaxe !</font>';
	return true;
}

function checkAll() {
	var bool1=verif1Inputs();
	var bool2=verif2Inputs();
	var bool3=verif3Inputs();
	var bool4=verif4Inputs();
	var bool5=verif5Inputs();

	if (!bool1 || !bool2 || !bool3 || !bool4 || !bool5)
		document.form.elements['posted_submit'].disabled=true;
	else 
		document.form.elements['posted_submit'].disabled=false;
}
