// JavaScript Document
function vrf_cto(contacto){
	if (contacto.nom.value == "" || EsNumero(contacto.nom.value)) {
		alert("Favor proporcione su nombre");
		return false;
	}else{
		if (contacto.eml.value == "" || CheckEmail(contacto.eml.value) == false) {
			alert("Introduzca su correo electrónico");
			return false;
		}else{
			if (contacto.msg.value == "" || EsNumero(contacto.msg.value)) {
				alert("Debe al menos escribir algún mensaje");
				return false;
			}else{
				return true;
			}
		}
	}
}

function vrf_news(news){
	if (news.eml.value == "" || CheckEmail(news.eml.value) == false) {
		alert("Introduzca su correo electrónico");
		return false;
	}else{
		return true;
	}
}

function checkLength(text, min, max){
 min = min || 1;
 max = max || 10000;
 if (text.length < min || text.length > max) {
  return false;
 }
 return true;
}

function EsNumero(valor){
	// Esta funcion verifica si el valor indicado es de tipo numérico
   var Numeros = "0123456789.";
   var Numero=true;
   var Char;

   for (i = 0; i < valor.length && Numero == true; i++) { 
      Char = valor.charAt(i); 
      if (Numeros.indexOf(Char) == -1) {
         Numero = false;
      }
    }
   return Numero;
   
}

function CheckEmail(valor) {
	// Esta función verifica si el valor introducido corresponde a una dirección de correo electrónico.
	email = valor
	AtPos = email.indexOf("@")
	StopPos = email.lastIndexOf(".")
	Estatus = true
	
	if (email == "") {
		Estatus = false
	}
	
	if (AtPos == -1 || StopPos == -1) {
		Estatus = false
	}
	
	if (StopPos < AtPos) {
		Estatus = false
	}
	
	if (StopPos - AtPos == 1) {
		Estatus = false
	}
	
	return Estatus
}
