function Buscar() {
	var n = new Number();
	n = 0;
	if (document.FindSoc.nombres.value.length <= 0) {
		n = n + 1
	} else {
		if (document.FindSoc.nombres.value.length <= 1){
		    alert("el Nombre debe contener mas de 1 letra");
			n = 0
	    	document.FindSoc.nombres.focus();
			return false;
		}
	}
	if (document.FindSoc.ap.value.length <= 0) {
		n = n + 1
	} else {
		if (document.FindSoc.ap.value.length <= 1){
		    alert("el A. Paterno debe contener mas de 1 letra");
			n = 0
	    	document.FindSoc.ap.focus();
			return false;
		}
	} 
	if (document.FindSoc.am.value.length <= 0) {
		n = n + 1
	} else {
		if (document.FindSoc.am.value.length <= 1){
		    alert("el A. Materno debe contener mas de 1 letra");
			n = 0
	    	document.FindSoc.am.focus();
			return false;
		}
	}
	if (n == 3) {
	    alert("Ingrese por lo menos un dato de Busqueda");
    	document.FindSoc.nombres.focus();
		n = 0
	    return false;
	} else {
		n = 0
		return true;
	}
}

function ver() {
	x = window.open("http://www.construccion.org.pe/home/aulaicg01.htm", "ventana", "toolbar=no, status=no, scrollbars=no, width=755, height=547");
	x.focus();
}

function sistema() {
	y = window.open ("http://www.construccion.org.pe/wmedia/requisitos.htm", "evalua", "toolbar=no, status=no, scrollbars=yes, width=430, height=400");
	y.focus();
}

function acceso() {
 	y = window.open("http://www.construccion.org.pe/bdicg/asotil-t15/access.php", "access", "toolbar=no, status=no, scrollbars=no, width=240, height=130");
	y.focus();
}

function acceso2() {
 	y = window.open("http://www.construccion.org.pe/bdicg/asotil-t12/access.php", "access", "toolbar=no, status=no, scrollbars=no, width=240, height=130");
	y.focus();
}

function acceso3() {
 	y = window.open("http://www.construccion.org.pe/bdicg/bozzo01/access.php", "access", "toolbar=no, status=no, scrollbars=no, width=240, height=130");
	y.focus();
}

function acceso4() {
 	y = window.open("http://www.construccion.org.pe/bdicg/GabyRuiz01/access.php", "access", "toolbar=no, status=no, scrollbars=no, width=240, height=130");
	y.focus();
}

function entra(src, color_entrada)
{
    if (!src.contains(event.fromElement)) {
	    src.bgColor= color_entrada;
    }
}

function sale(src, color_default)
{
    if (!src.contains(event.toElement)) {
        src.bgColor=color_default;
    }
}

function solicita() {
	y = window.open ("http://www.construccion.org.pe/nosotros/socios/pedir-clave.php", "evalua", "toolbar=no, status=no, scrollbars=yes, width=430, height=240");
	y.focus();
}

function Solicitud() {
  if(document.FrmPedido.nom01.value == "") {
    alert("Por favor indique sus Nombres");
    document.FrmPedido.nom01.focus();
    return false;
  }
  if (!emailCheck(document.FrmPedido.correo01.value)) {
    document.FrmPedido.correo01.focus();
    return false;
  }
  if(document.FrmPedido.socio.value == "") {
    alert("Ingrese su Codigo de Socio ICG");
    document.FrmPedido.socio.focus();
    return false;
  }
  //return confirm("Desea Enviar ahora el Formulario");
	return true;
}

// FUNCION PARA VALIDAR EMAIL
function emailCheck (emailStr) {

var checkTLD = 1;
var knownDomsPat = /^(com|net|org|edu|int|mil|gov|gob|arpa|biz|aero|name|coop|info|pro|museum)$/;
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("El email es incorrecto, verificar arrobas(@) y puntos(.)");
	return false;
}
var user = matchArray[1];
var domain = matchArray[2];

for (i = 0; i < user.length; i++) {
	if (user.charCodeAt(i)>127) {
		alert("El nombre del EMAIL contiene caracteres invalidos.");
		return false;
   }
}
for (i = 0; i < domain.length; i++) {
	if (domain.charCodeAt(i)>127) {
		alert("El dominio del EMAIL contiene caracteres invalidos.");
		return false;
   }
}

if (user.match(userPat) == null) {
	alert("El nombre de EMAIL no es valido.");
	return false;
}

var IPArray = domain.match(ipDomainPat);
if (IPArray != null) {

for (var i = 1;i <= 4;i++) {
	if (IPArray[i] > 255) {
		alert("Direccion IP de Destino es invalido!");
		return false;
   }
}
return true;
}
 
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("El nombre del dominio no parece ser valido");
return false;
   }
}

if (checkTLD && domArr[domArr.length-1].length != 2 && 
domArr[domArr.length-1].search(knownDomsPat) == -1) {
	alert("La dirección debe terminar en dominio de pais conocido o en dos letras.");
	return false;
}

if (len < 2) {
	alert("El nombre del Hostname no existe!");
	return false;
}

return true;
}
