// JavaScript Document
function validateRegister(form){
	if(form.nombres.value == ""){
		alert("Debe llenar el campo NOMBRES !!!");
		form.nombres.focus();
		return false;
	}
	if(form.registro.value== ""){
		alert("Debe llenar el campo REGISTRO !!!");
		form.registro.focus();
		return false;
	} else {
		correo = validateEmail(form.email.value);
		if(correo==false){
			form.email.focus();
			return correo;	
		}
	}
	
	return true;
}

function validateContact(form){
	if(form.nombres.value == ""){
		alert("Debe llenar el campo NOMBRES !!!");
		form.nombres.focus();
		return false;
	}
	if(form.apellidos.value== ""){
		alert("Debe llenar el campo APELLIDOS !!!");
		form.apellidos.focus();
		return false;
	}
	if(form.correo.value== ""){
		alert("Debe llenar el campo CORREO !!!");
		form.correo.focus();
		return false;
	} else {
		correo = validateEmail(form.correo.value);
		if(correo==false){
			form.correo.focus();
			return correo;	
		}
	}
	if(form.telefono.value== ""){
		alert("Debe llenar el campo TELEFONO !!!");
		form.telefono.focus();
		return false;
	}
	if(form.mensaje.value== ""){
		alert("Debe llenar el campo MENSAJE !!!");
		form.mensaje.focus();
		return false;
	}	
	return true;
}

function validateEmail(email){
	var m = unescape(email);
	var i = 1;
	var mLength = m.length;
	while ((i < mLength) && (m.charAt(i) != "@")){
		i++
	}
	if ((i >= mLength) || (m.charAt(i) != "@")){
		alert("Correo inválido");
		return false;
	} else {
		i += 2;
	}
	while ((i < mLength) && (m.charAt(i) != ".")){
		i++
	}
	if ((i >= mLength - 1) || (m.charAt(i) != ".")){
		alert("Correo inválido");
		return false;
	}	
}