function setFocus(aField) {
document.forms[0][aField].focus();
}
function isAnEmailAddress(aTextField) {
// 1+@3+ [or x@x.x] is as close as we will test

if (document.forms[0][aTextField].value.length<5) {
return false;
}
else if (document.forms[0][aTextField].value.indexOf("@") < 1) {
return false;
}
else if (document.forms[0][aTextField].value.length - document.forms[0][aTextField].value.indexOf("@") < 4) {
return false;
}
else { return true; }
}

function isEmpty(aTextField) {
if ((document.forms[0][aTextField].value.length==0) || (document.forms[0][aTextField].value==null)) {
return true;
}
else { return false; 
}
}

function validate() {

// Step 1: check that required fields are
// filled in, alert and exit without
// submitting if not

// check that the name field is valued
if (isEmpty("nombre")) {
	alert("Ingrese su Nombre y Apellido");
	setFocus("nombre");
	return false;
}
if (isEmpty("email")) {
	alert("Ingrese su email");
	setFocus("email");
	return false;
}
// Step 2: check that the email address is
// even close, alert and exit without
// submitting if not
if (!isAnEmailAddress("email")) {
	alert("Esto es una dirección inválida, Ingrese su Email");
	setFocus("email");
	return false;
}
if (isEmpty("telefono")) {
	alert("Ingrese su Teléfono");
	setFocus("telefono");
	return false;
}
if (isEmpty("ciudad")) {
	alert("Ingrese su Ciudad");
	setFocus("ciudad");
	return false;
}
if (isEmpty("provincia")) {
	alert("Ingrese su Provincia");
	setFocus("provincia");
	return false;
}
if (isEmpty("pais")) {
	alert("Ingrese su País");
	setFocus("pais");
	return false;
}

// check that the email field is valued

if (isEmpty("consulta")) {
	alert("Ingrese se consulta");
	setFocus("consulta");
	return false;
}
document.formulario.submit()
// if we get this far everthing is ok, so
// let the form submit
return true;
}

