function validacio(el)
{
	usuari = document.getElementById(el).value;

	if(usuari == "")
	{
		document.getElementById(el).style.backgroundColor = "#FF9D9D";
		document.getElementById(el).style.border = "1px red";
		document.getElementById("dades").style.display = "block";
	}
	else
		document.getElementById(el).style.backgroundColor = "#FFF";
}

function validar_camps_altre_usuari(form, idioma){
	if(form.nom.value == ""){
		if(idioma == 'en')
			alert('Please enter a name.');
		else
			alert('Por favor introduzca un nombre.');
		form.nom.focus();
	}
	else if(!validarEmail(form.login.value)){
		if(idioma == 'en')
			alert('Please enter a valid e-mail.');
		else
			alert('Por favor introduzca un e-mail correcto.');
		form.login.focus();
	}
	else {
		go(form, "nouUsr.php");
	}
}

function go(form,url) 
{
	form.action = url;
	form.submit();
}

function validarEmail(valor)
{
	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor))
	{
		//alert("La dirección de email " + valor    + " es correcta.") 
		return (true);
	}
  	else
  	{
		//alert("La dirección de email es incorrecta.");
   		return (false);
  	}
}

function validar(id, id2, id3, formulari, lang)
{
	valor = document.getElementById(id).value;
	$.post("mail.php",{
			email: valor, // Contingut email
			warning: id3,
			idioma: lang
			},function(data){
				$("#"+id3).html(data);    //Tomo el resultado de pagina e inserto los datos en el combo indicado
	})
	
	if(validarEmail(document.getElementById(id).value))
	{
		document.getElementById(id2).innerHTML = "<img src='./Images/ok.png' />";
		document.getElementById(id3).style.display= 'none';
	}
	else
	{
		document.getElementById(id2).innerHTML = "<img src='./Images/warning.png' width='24' height='24' />";
		document.getElementById(id3).style.display= 'block';
	}
}