// JavaScript Document
function closeW()
{
window.close()
}





function validoSoloNumero(num)
{
	var i = 0;
	var largo = num.length;
	while ((num.charAt(i)) >= 0 && (num.charAt(i)) <= 9 && i<=largo -1)
	{
		i++;
	}
	if (i > largo - 1)	
		return true;
	else
		return false;	
}

function openForm(urlPage)
{
var wr
wr = window.open(urlPage, "wr" , "toolbar=no,scrollbars=no,resizable=no,top=100,left=45,height=300,width=700")
}

function viewEnlarge(urlPage,ancho,alto)
{
var wr
wr = window.open(urlPage, "wr" , "toolbar=no,scrollbars=no,resizable=no,top=0,left=0,height="+alto+",width="+ancho)
}

function openForm2(urlPage)
{
var wr
wr = window.open(urlPage, "wr" , "toolbar=no,scrollbars=no,resizable=no,top=200,left=300,height=50,width=200")
}

function openForm3(urlPage)
{
window.close
var wr
wr = window.open(urlPage, "wr" , "toolbar=no,scrollbars=no,resizable=no,top=200,left=300,height=50,width=200")
}


function enviarComentario(proy,sec,cli,nomcli,apecli)
{
var param = "?proyecto="+proy+"&seccion="+sec+"&cliente="+cli+"&nombreCliente="+nomcli+"&apellidoCliente="+apecli
var url = "comentarAvance.asp"+param
wr = window.open(url, "wr", "toolbar=no,top=100,left=190,scrollbars=no,resizable=no,height=180,width=400")
wr.focus()
}

function validoEmailPass(of)
{
email = of.email.value
pass = of.pass.value
if(email==""){
	alert("Por favor, ingrese su Email")
	of.email.focus()
	return false
}
else
	if(pass==""){
		alert("Por favor, ingrese su Contraseña")
		of.pass.focus()
		return false
	}
	else
		return true
}

function validoEmailVacio(of)
{
email = of.email.value
if(email==""){
	alert("Por favor, ingrese su Email")
	of.email.focus()
	return false
}
else
	return true
}

function validoNamPhoEma(of)
{
name = of.name.value
phone = of.phone.value
email = of.email.value
if(name==""){
		alert("Por favor, ingrese su Nombre")
		of.name.focus()
		return false
}
else
		if(phone==""){
			alert("Por favor, ingrese su teléfono")
			of.phone.focus()
			return false
		}
		else
			if(email==""){
				alert("Por favor, ingrese su Email")
				of.email.focus()
				return false
			}
			else
				if(!validoEmail(email)){
					r=confirm("La dirección de Email parece ser no valida\Desea ingresarla de todos modos?")
					if(r)
						return true
					else
						return false	
				}
				else
					return true
}

function validoEmail(Omail)
{
var largo = Omail.length;
var i = 1;
var arroba = false;
var punto = false;
var post_arroba = "";
var post_dominio = "";
var carac_no_valido=false;
var siguiente = 0;
var punto_post_dominio = "";
var dominio = "";
var post_punto = "";
var i2= 0;
var largo_pp = 0;
if (largo < 7)
	return false;
else
	if (valido_caracter (Omail.charCodeAt(0))) 
	{
		while ( (i<=largo -1) && (!arroba) && (!carac_no_valido) )
		{
			if (Omail.charCodeAt(i) == 64)
				{
				arroba = true;
				i++;
				}
			else
				if (valido_caracter(Omail.charCodeAt(i)) )
				{	i++;
					continue;
				}
				else
				{
					carac_no_valido = true;
					i++;
				}	
		}		
		if (carac_no_valido)
					
			return false;
			
		else
			if (arroba)
			{
				if (valido_caracter(Omail.charCodeAt(i)))
				{
					while (i <= largo - 1 && valido_caracter(Omail.charCodeAt(i)))
						i++;
					if (Omail.charCodeAt(i) == 46)
					{
						
						dominio = Omail.substr(i+1,3)
						if (valido_dominio(dominio) )
						{	
							
							if (Omail.substr(i+4,1)== "" )
								return true;
							else
							{
								punto_post_dominio = Omail.substr(i+4,1);
								if (punto_post_dominio == ".")
								{
								punto_post_dominio = Omail.substr(i+4);
								
								if (punto_post_dominio.length == 1)
									return false;
								else	
								{
								punto_post_dominio = Omail.substr(i+5);
								largo = punto_post_dominio.length; 
								
								i2 = 0;
								while( i2<= largo - 1 && valido_caracter(punto_post_dominio.charCodeAt(i2)))
									i2++;
								if (i2 == largo)
									return true;
								else
									return false;		
								}	
								} 
								else
									return false;	
							}	
						}
						else
							return false;	
					}	
					else
						return false;	
						
				}
				else
					return false;	
					
			}	
			else
				return false;
	}			
	else
		return false;
		
	
}

function valido_caracter(cod_caracter)
{

if ( (cod_caracter >=65 && cod_caracter <=90) || (cod_caracter >= 97 && cod_caracter<= 122) || (cod_caracter >= 48 && cod_caracter <= 57) || (cod_caracter == 45)  || (cod_caracter == 95 )) 
	return true;
else
	return false;
}		

function valido_dominio(dom)
{
var result = false;
switch (dom)
{
case "com": result = true; break;
case "gub": result = true; break;
case "net": result = true; break;
case "edu": result = true; break;
case "mil": result = true; break;
case "org": result = true; break;

}
return result;
}

function validoUsuPass(of)
{
usu = of.usuario.value
pas = of.pass.value
if(usu=="")
{
	alert("Ingrese Usuario")
	of.usuario.focus()
	return false}
else
	if (pas=="")
	{
		alert("Ingrese Contraseña")
		of.pass.focus()
		return false}
	else
		return true
}

function validoFormUpd1(of)
{
//Este form sirve para validar un formulario estandar de update de sitio con
//un titulo, una descripción y ancho alto de imagen
tit = of.titulo.value
des = of.descripcion.value
an = of.ancho.value
al = of.alto.value
if(tit==""){
	alert("Ingrese un Título")
	of.titulo.focus()
	return false}
else
	if(des==""){
		alert("Ingrese una Descripción")
		of.descripcion.focus()
		return false}
	else
		if(an==""){
			alert("Ingrese un ancho de Imagen")
			of.ancho.focus()
			return false}	
		else
			if(!validoSoloNumero(an)){
				alert("Ingrese solo números")
				of.ancho.focus()
				return false}
			else
				if(al==""){
					alert("Ingrese alto de Imagen")
					of.alto.focus()
					return false}
				else
					if(!validoSoloNumero(al)){
						alert("Ingrese solo números")
						of.alto.focus()
						return false}
					else
						return true	
}

function volver()
{
window.history.back();

}

function valDiaMes(oDia,oMes)
{
if ( (oDia >= 1) && (oDia <= finMes(oMes))) 
	return true;
	
else
	return false;
}

function valAno(oAno)
{
var fecact= new Date();	
fecact= fecact.getFullYear();
if ((oAno.length == 4) && (validoSoloNumero(oAno)) && (oAno >= 1900 && oAno >= fecact))
	return true;
	
else
	return false;	
}

function finMes(oMes)
{
var nRes = 0;
switch (oMes)
{
case "01": nRes = 31; break;
case "02": nRes = 29; break;
case "03": nRes = 31; break;
case "04": nRes = 30; break;
case "05": nRes = 31; break;
case "06": nRes = 30; break;
case "07": nRes = 31; break;
case "08": nRes = 31; break;
case "09": nRes = 30; break;
case "10": nRes = 31; break;
case "11": nRes = 30; break;
case "12": nRes = 31; break;
}
return nRes;
}

function validoFecha(dia,mes,ano)
{
if  ((valDiaMes(dia,mes)) && (valAno(ano)))
	return true;
else
	return false;
}

function validoForm2vFecha(of,msg1,msg2)
{
d1 = of.desc1.value
d2 = of.desc2.value
d = of.dia.value
m = of.mes.value
a = of.ano.value
if(d1==""){
	alert(msg1)
	of.desc1.focus()
	return false}
else
	if(d2==""){
		alert(msg2)
		of.desc2.focus()
		return false}
	else
		if(!validoFecha(d,m,a)){
			alert("Formato de Fecha invalido")
			of.dia.focus()
			return false}
		else
			return false		
	
}

function saltoDia(of)
{
var sdia= of.dia.value;	
var largo = sdia.length;
if (largo == 2)
	of.mes.focus();
}		

function saltoMes(of)
{
var smes= of.mes.value;	
var largo = smes.length;
if (largo == 2)
	of.ano.focus();
}		

function validoForm4v(of,msg1,msg2,msg3,msg4)
{
d1 = of.desc1.value
d2 = of.desc2.value
d3 = of.desc3.value
d4 = of.desc4.value
if(d1==""){
	alert(msg1)
	of.desc1.focus()
	return false}
else
	if(d2==""){
		alert(msg2)
		of.desc2.focus()
		return false}
	else
		if(d3==""){
			alert(msg3)
			of.desc3.focus()
			return false}
		else
			if(d4=="" || d4.length<5){
				alert(msg4)
				of.desc4.focus()
				return false}
			else
				return true
}

function checkFormPro(of)
{
pro = of.desc1.value
nom = of.desc2.value
a = of.ano.value
m = of.mes.value
d = of.dia.value
if(pro=="" || nom=="" || a=="" || m=="" || d==""){
	alert("Es obligatorio completar todos los datos del formulario")
	of.desc1.focus()
	return false}
else
	if (!validoFecha(d,m,a)){
		alert("Formato de fecha invalido")
		return false}
	else	
		return true	
}

function aviso(msg)
{
	alert(msg)
	
}

function validoNomApeEmaEng(of)
{
email = of.email.value
nombre = of.nombre.value
apellido = of.apellido.value
if(nombre==""){
		alert("Please, enter your Name")
		of.nombre.focus()
		return false
}
else
		if(apellido==""){
			alert("Please, enter your last name")
			of.apellido.focus()
			return false
		}
		else
			if(email==""){
				alert("Please, enter your Email")
				of.email.focus()
				return false
			}
			else
				if(!validoEmail(email)){
					r=confirm("The email could not be correct, do you want to continue?")
					if(r)
						return true
					else
						return false	
				}
				else
					return true
}
