function VerifMail(TheMail) {
	ChaineReg=/^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/;
 	if (ChaineReg.exec(TheMail.toLowerCase()) == null) return false; else return true;
}

function Trim(string) { 
	return string.replace(/(^\s*)|(\s*$)/g,''); 
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function KeyBlocked (start, end) {
	if (window.event.keyCode < start || window.event.keyCode > end)
		event.returnValue = false;
	else
		return true;
}

function goSearch() {
	if (verifSearch()==true) document.search.submit();
}

function verifSearch() {
	if (document.getElementById("txtSearch").value.length < 3) {
		alert("Please enter a valid keyword (more than 2 caracters).");
		document.getElementById("txtSearch").focus();
		return false;
	}
	return true;
}

function verifReturn() {
	if (document.getElementById("txtSearch").value.length < 3) {
		alert("Please enter a valid keyword (more than 2 caracters).");
		document.getElementById("txtSearch").focus();
		event.returnValue=false;
	}
	return true;
}

function fenCentre(Url,nomFen,tailleX,tailleY,scrol) {
	ecranX=screen.width;
	ecranY=screen.height;
	posX=(ecranX-tailleX)/2;
	posY=(ecranY-tailleY)/2;
	if (scrol=='oui')
		param='\' scrollbars=yes, resizable=yes, width='+tailleX+' ,height='+tailleY+'\'';
	else
		param='\' resizable=no, width='+tailleX+' ,height='+tailleY+'\'';	
	window.open(Url,nomFen,param).moveTo(posX,posY);
}

function validerModif() {  
	if (verifModif()==true) {
		if (confirm("Do you want to update your informations ? ")) 
			document.client.submit();
	}
}

function verifModif()	{
	document.getElementById("nom").value = Trim(document.getElementById("nom").value);
	document.getElementById("prenom").value = Trim(document.getElementById("prenom").value);
	document.getElementById("fonction").value = Trim(document.getElementById("fonction").value);
	document.getElementById("societe").value = Trim(document.getElementById("societe").value);
	document.getElementById("email").value = Trim(document.getElementById("email").value);
	document.getElementById("mdp").value = Trim(document.getElementById("mdp").value);
	document.getElementById("mdp2").value = Trim(document.getElementById("mdp2").value);

	if (document.getElementById("nom").value.length < 1) {
		alert("Please, enter your nom. ");
		document.getElementById("nom").focus();
		return false;
	}
	if (document.getElementById("prenom").value.length < 1) {
		alert("Please, enter your firstname. ");
		document.getElementById("prenom").focus();
		return false;
	}
	if (document.getElementById("fonction").value.length < 1) {
		alert("Please, enter your position. ");
		document.getElementById("fonction").focus();
		return false;
	}
	if (document.getElementById("societe").value.length < 1) {
		alert("Please, enter your company name. ");
		document.getElementById("societe").focus();
		return false;
	}
	if (VerifMail(document.getElementById("email").value)==false) {
		alert("Please, enter your email address. ");
		document.getElementById("email").focus();
		return false;
	}
	if (document.getElementById("mdp").value.length < 6) {
		alert("Please, enter your password (min: 6 chars). ");
		document.getElementById("mdp").focus();
		return false;
	}
	if (document.getElementById("mdp2").value.length < 1) {
		alert("Please, enter your password for confirmation. ");
		document.getElementById("mdp2").focus();
		return false;
	}
	if (document.getElementById("mdp").value != document.getElementById("mdp2").value) {
		alert("Password are not correct. ");
		document.getElementById("mdp").value = "";
		document.getElementById("mdp2").value = "";
		document.getElementById("mdp").focus();
		return false;
	}

	return true;
}
