function CanviIdioma(cat,cast,eng,Idioma)
{
if(Idioma == 1 ) window.location=cat;
if(Idioma == 2 ) window.location=cast;
if(Idioma == 3 ) window.location=eng;
}

function obligatorisContacte(Idioma){
	var nom_cognoms=document.getElementById('txt_noms_cognoms').value;
	var mail=document.getElementById('txt_mail').value;
	var telefon=document.getElementById('txt_telefon').value;
	var acceptar=document.getElementById('chk_acceptar').checked;
	var sms='';

	if (nom_cognoms == ''){

		switch(Idioma){
			case 1: 
				sms+='Has d’omplir el camp Nom i Cognoms!\n';
				break;

			case 2: 
				sms+='Debes rellenar el campo Nombre y Apellidos!\n';
				break;
			
			case 3: 
				sms+='Please fill in the Name and Surname field!\n';
				break;
		}
	}

	if (mail == ''){
		sms+='Has d’omplir el camp E-mail!\n';
	}
	else {
		if(!validarEmail(mail)){
			sms+='E-mail incorrecte!\n';
		}
	}

	if (telefon == ''){
		sms+='Has d’omplir el camp Telèfon!\n';
	}

	if (acceptar == false){
		sms+='Has d’acceptar la Normativa Vigent de seguretat de Dades Personals!\n';
	}

	if (sms == ''){
		return true;
	}else{
		alert(sms);
		return false;
	}
}

function validarEmail(valor) {
	var ok=false;
	//if (/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/.test(valor)){
	if (/[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])/i.test(valor)){
		ok=true;
	}

	return ok;
}

