// JavaScript Document


function pop_up(url,name,width,height)
{
var izq = ((screen.availWidth/2)-(width/2))
var tope = ((screen.availHeight/2)-(height/2))
settings='top=' + tope + ',left=' + izq + ',toolbar=no,location=no,directories=no,status=no,maximize=no,resizable=no,menubar=no,scrollbars=auto,width=' + width + ',height='+ height;
window.open(url,name,settings);
}

function pop_upVer2(url,name,width,height)
{
var izq = ((screen.availWidth/2)-(width/2))
var tope = ((screen.availHeight/2)-(height/2))
settings='top=' + tope + ',left=' + izq + ',toolbar=no,location=no,directories=no,status=no,maximize=no,resizable=no,menubar=no,scrollbars=yes,width=' + width + ',height='+ height;
window.open(url,name,settings);
}

function popup(url, name, width, height)
{
settings='top=0,left=0,screenX=0,screenY=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=' + width + ',height=' + height;
window.open(url,name,settings);
}

function cerrar(){
window.close();
}

/****************************************************************************/
/***Funcion que valida que el text no sea solo espacios en blancos**********/
function isWhitespace (s)
{   var i;
    var whitespace = " \t\n\r";
    if (isEmpty(s)) return true;
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        // si el caracter en que estoy no aparece en whitespace,
        // entonces retornar falso
        if (whitespace.indexOf(c) == -1) return false;
    }
	
    return true;
}

/****************************************************************************/
/***Funcion que valida que el text no sea vacio**********/

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}
/****************************************************************************/
/***Funcion que valida las fechas de ingreso*********************************/

function validar_fechaespecial(dia,mes,ano)
{
 var resultado=true;
 var d,s;
 if ((dia!="d")&&(mes!="m")&&(ano!="a")){
   resultado=false;
  }
  return resultado;
}	

/****************************************************************************/
/***Funcion que valida que el text contenga una palabra valida**********/

function espalabra(s)
{   
	var log=true;
	var letras="abcdefghijklmnñopqrstuvwxyzáéíóúABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ -_.,1234567890"; 
	
	for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (letras.indexOf(c) == -1){ log=false;}
    }
    return log;
   
}

/****************************************************************************/
// Funcion que valida el campo Email
function ValFieMail2(theForm,theField) {
  
    var msg = "";
  apos=eval(theForm + '.' + theField + '.value.indexOf("@")');
  dotpos=eval(theForm + '.' + theField + '.value.lastIndexOf(".")');
  lastpos=eval(theForm + '.' + theField + '.value.length-1');
  chrba=eval(theForm + '.' + theField + '.value.charAt(apos-1)');
  chraa=eval(theForm + '.' + theField + '.value.charAt(apos+1)');
  chrblank=eval(theForm + '.' + theField + '.value.indexOf(" ")');
  chrcoma=eval(theForm + '.' + theField + '.value.indexOf(",")');
  chrslash=eval(theForm + '.' + theField + '.value.indexOf("/")');
  //chrbslash=eval(theForm + '.' + theField + '.value.indexOf("\")');
  chrpc=eval(theForm + '.' + theField + '.value.indexOf(";")');
  if (apos<1 || dotpos-apos<2 || lastpos-dotpos>4 || lastpos-dotpos<2
  	 || chrba == "." || chraa == "." || chrblank != -1 || chrcoma != -1
  	 || chrslash != -1 || chrpc != -1){  {
    msg = "1";
  }
    return msg;
 
}
}
//*************************Funcion que valida que sea numero

function esnumero(s)
{
	var log=true;
	var numero="1234567890";

	for (i = 0; i < s.length; i++)
    {
        var c = s.charAt(i);
        if (numero.indexOf(c) == -1){ log=false;}
    }
    return log;

}

//**********************************************************************
//******Función que permite ir a la sección de Comentarios**************

function ir_comentarios() 
{
  parent.parent.opener.top.location.replace('../comentarios/index.asp')
  window.parent.close();
}

//**********************************************************************
//*******Función que permite ir a el home*******************************

function ir_home() 
{
  parent.parent.opener.top.location.replace('/index.asp')
  window.parent.close();
}
//********************Función para validar un campo Cedula**************

function validar_registro(forma)
{
   if ((isWhitespace(forma.txtCedula.value)) || (isEmpty(forma.txtCedula.value)))
   {
   alert("ERROR: Debe ingresar su número de cédula de identidad\npara verificar su estado.");
   forma.txtCedula.select();
   forma.txtCedula.focus();
   return false;
   }
   else
   {     if (!(esnumero(forma.txtCedula.value)))
         { alert("ERROR: Debe utilizar solo números en su cédula de identidad,\nno utilice comas (,) ni puntos (.).");
		   forma.txtCedula.select();
           forma.txtCedula.focus();
		  
		   return false;

		 }

   }
   pop_up('about:blank','respuesta_firmas',375,100);
   forma.submit();
  
   return true;
}


//**********************************************************************
//*******Función que permite ir a una pagina externa*******************************


function goto_URL(object) {
  if (object.options[object.selectedIndex].value!='$')
  {
   window.open(object.options[object.selectedIndex].value,'windowName');   
   object.options[0].selected = true;
   return true;
   }
}
