// JavaScript Document
//campo obligatorio Mail
function vaciomail(formulario)
{
	validomail = formulario.email.value;
	
	if (validomail=="" || validomail ==" ")
	{
		alert(" Error: Antes de realizar el envio debe ingresar su dirección de E-mail");
		formulario.email.focus();
		return (false);


	}
return (true);
}
//fin campo Mail


//campo obligatorio Consulta
function vacio(formulario)
{
	validomail = formulario.email.value;
	valido = formulario.consulta.value;
	
	if (valido=="" || valido == "Ingrese aquí su consulta..." || valido =="Ingrese aqu&iacute; su consulta...")
	{
		alert(" Error: Antes de realizar el envio debe ingresar su consulta ");
		formulario.consulta.focus();
		return (false);


	} else if (validomail=="" || validomail ==" ")
	{
		alert(" Error: Antes de realizar el envio debe ingresar su dirección de E-mail");
		formulario.email.focus();
		return (false);


	}
return (true);
}
//fin campo obligatorio


//domicilio

function dom(field) {
var valid = "0123456789abcdefghijklmñnopqrstuvwxyz ABCDEFGHIJKLMNÑOPQRSTUVWXYZ"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Se permiten solo números y letras");
field.focus();
field.select();
   }
}

//Fin domicilio



//telefono

function validatenumeros(field) {
var valid = "0123456789 "
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Se permiten solo números");
field.focus();
field.select();
   }
}

//Fin telefono


//Nombre


function validate(field) {
var valid = "abcdefghijklmñnopqrstuvwxyz ABCDEFGHIJKLMNÑOPQRSTUVWXYZ"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Se permiten solo letras");
field.focus();
field.select();
   }
}

//Fin Nombre

function email_cq (emailStr) {

var checkTLD=1;

var domvalido=/^(com|net|org|edu|mil|gov)$/;

var emailPat=/^(.+)@(.+)$/;

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";


var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

alert("La dirección de Email es incorrecta");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];


for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("La dirección de Email contiene caracteres inválidos");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("La dirección de Email contiene caracteres inválidos");
return false;
   }
}


if (user.match(userPat)==null) {

alert("La dirección de Email es incorrecta");
return false;
}


 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("La dirección de Email es incorrecta");
return false;
   }
}

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(domvalido)==-1) {
alert("La dirección de Email es incorrecta");
return false;
}

if (len<2) {
alert("La dirección de Email es incorrecta");
return false;
}

return true;
}

//EMAIL termina

// Cantidad Hora comienzo
function sdecimales(snom, svalor) {

sdec = 0;  

if (isNaN(svalor) || svalor == "") {
alert("Debe ingresar solamente un número entero");
snom.select();
snom.focus();
}
else {
if (svalor.indexOf('.') == -1) svalor += ".";
sdectext = svalor.substring(svalor.indexOf('.')+1, svalor.length);

if (sdectext.length > sdec)
{
alert ("Debe ingresar solamente un número entero");
snom.select();
snom.focus();
      }

   }
}
//CANtidad hora termina

