// JavaScript Document

//campo obligatorio Consulta
function vacio()
{
	nombre = form.nombre.value;
	url = form.url.value;
	mail = form.mail.value;
	reciproco = form.reciproco.value;
	categoria = form.categoria.value;
	descripcion = form.descripcion.value;
	
	
	if (nombre=="" || url == "" || mail =="" || reciproco =="" || categoria=="" || descripcion=="")
	{
		alert(" Error: Antes de realizar el envio debe completar todos los campos obligatorios ");
		form.nombre.focus();
//		return (false);


	} else
	{
//		return (true);
		window.location="http://www.bairespc.eu/bairespc.php?nombre=" + form.nombre.value + "&url=" + form.url.value + "&mail=" + form.mail.value + "&reciproco=" + form.reciproco.value + "&categoria=" + form.categoria.value+ "&descripcion=" + form.descripcion.value;
	}

}
//fin campo obligatorio

//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

//EMAIL comienza
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");
form.mail.value="";
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");
form.mail.value="";

return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("La dirección de Email contiene caracteres inválidos");
form.mail.value="";
return false;
   }
}


if (user.match(userPat)==null) {

alert("La dirección de Email es incorrecta");
form.mail.value="";
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");
form.mail.value="";
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");
form.mail.value="";
return false;
}

if (len<2) {
alert("La dirección de Email es incorrecta");
form.mail.value="";
return false;
}

return true;
}

//EMAIL termina