function IsNumeric(valor){
    var log = valor.length;
    var sw = "S";
    for (x = 0; x < log; x++) {
        v1 = valor.substr(x, 1);
        v2 = parseInt(v1);
        //Compruebo si es un valor numérico
        if (isNaN(v2)) {
            sw = "N";
        }
    }
    if (sw == "S") {
        return true;
    }
    else {
        return false;
    }
}


function ltrim(str) { 
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}
function rtrim(str) {
	for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
	return str.substring(0,j+1);
}
function trim(str) {
	return ltrim(rtrim(str));
}
function isWhitespace(charToCheck) {
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
}


function validaContactoFH(){
	
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	var nombre = trim(document.contacto.txtnom.value);
	var telefono = trim(document.contacto.txttel.value);
	var direccion = trim(document.contacto.txtdir.value);
	var comentarios = trim(document.contacto.txtcom.value);
	
	
	if (nombre == "") {
        alert("S'il vous pla\xEEt, entrez le nom et pr\xE9nom.")
        document.contacto.txtnom.focus();
		return 0;
	}
	
	if (telefono == "") {
        alert("S'il vous pla\xEEt entrer votre t\xE9l\xE9phone.")
        document.contacto.txttel.focus();
		return 0;
	}
	
	if (direccion == "") {
        alert("S'il vous pla\xEEt entrez l'adresse.")
        document.contacto.txtdir.focus();
		return 0;
	}
	
	
	if(!document.contacto.txtmai.value.match(emailExp)){
		alert("S'il vous pla\xEEt entrer une adresse e-mail valide.")
		document.contacto.txtmai.focus()
		return 0;
	}
	
	
	if (comentarios == "") {
        alert("S'il vous pla\xEEt entrer des commentaires.")
        document.contacto.txtcom.focus();
		return 0;
	}
	
	//el form se envia
	document.contacto.submit();
}