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 validaRegistro(){
	
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	var nombre = trim(document.contacto.nombre.value);
	var apellido = trim(document.contacto.apellido.value);
	var telefono = trim(document.contacto.telefono.value);
	var comentarios = trim(document.contacto.comentarios.value);
	
	if (document.contacto.subject.value == 0){
		alert("Por favor seleccione Contactarnos Sobre.")
        document.contacto.subject.focus();
		return 0;

	}

	if (nombre == "") {
        alert("Por favor ingrese nombre.")
        document.contacto.nombre.focus();
		return 0;
	}
	
	if (apellido == "") {
        alert("Por favor ingrese apellido.")
        document.contacto.apellido.focus();
		return 0;
	}
	
	
	if(!document.contacto.email.value.match(emailExp)){
		alert("Por favor ingrese E-Mail v\xE1lido.")
		document.contacto.email.focus()
		return 0;
	}
	
	
	if (telefono == "") {
        alert("Por favor ingrese telefono.")
        document.contacto.telefono.focus();
		return 0;
	}
	
	if (comentarios == "") {
        alert("Por favor ingrese comentarios.")
        document.contacto.comentarios.focus();
		return 0;
	}
	
	//el form se envia
	document.contacto.submit();
}
