function validar(f,idioma)
{
    var errores = new Array();
    var num_err = 0;
    var n;
    var s = new String();
    var nombre = new String(document.getElementById("nombre").value);
    var tlf = new String(document.getElementById("telefono").value);
    var correo = new String(document.getElementById("correo").value);
	var referencias = f.referencias.value//new String(document.getElementById("referencias").value);
	var comentarios = new String(document.getElementById("comentarios").value);
    
    if(nombre == "")
    {
        if(idioma == "es")
			errores.push("Debe introducir su nombre y apellidos");
		else
		if(idioma == "de")
			errores.push("Es muß seinen vollen Namen vorstellen");
		else
		if(idioma == "en")
			errores.push("It must introduce its full name");
        num_err++;
        document.getElementById("nombretxt").style.color = "red";
    }
    else
    {
        document.getElementById("nombretxt").style.color = "white";
    }
    if(tlf == "")
    {
        if(idioma == "es")
			errores.push("Debe introducir un teléfono de contacto");
		else
		if(idioma == "de")
			errores.push("Es muß ein Kontakttelefon einführen");
		else
		if(idioma == "en")
			errores.push("It must introduce a contact telephone");
        num_err++;
        document.getElementById("telefonotxt").style.color = "red";
    }
    else
    {
        document.getElementById("telefonotxt").style.color = "white";
    }
    if(correo == "")
    {
        if(idioma == "es")
			errores.push("Debe introducir un e. mail de contacto");
		else
		if(idioma == "de")
			errores.push("Es muß ein Kontakt-email einführen");
		else
		if(idioma == "en")
			errores.push("It must introduce a contact email");
        num_err++;
        document.getElementById("correotxt").style.color = "red";
    }
    else
	if(!check_email(correo))
    {
        if(idioma == "es")
			errores.push("El e. mail es incorrecto");
		else
		if(idioma == "de")
			errores.push("Das email ist falsch");
		else
		if(idioma == "en")
			errores.push("The email is incorrect");
        num_err++;
        document.getElementById("correotxt").style.color = "red";
    }
    else
    {
        document.getElementById("correotxt").style.color = "white";
    }
//    if(referencias == "")
//    {
//        if(idioma == "es")
//			errores.push("Debe introducir las referencias de las obras");
//		else
//		if(idioma == "de")
//			errores.push("Es muß die Hinweise der Arbeiten vorstellen");
//		else
//		if(idioma == "en")
//			errores.push("It must introduce the references of works");
//        num_err++;
//        document.getElementById("referenciastxt").style.color = "red";
//    }
//    else
//    {
//        document.getElementById("referenciastxt").style.color = "white";
//    }
    
    if(num_err > 0)
    {
        for(n in errores)
        {
			var indi = n - (1-2);
            s = s.concat(indi).concat(". ").concat(errores[n]).concat("\n");
        }
        window.alert(s);
        return false;
    }
    else
        return true;
}


function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
			return (false);
		} 
	} 

	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
		return (-1); 
		} 

	}
}

