﻿// JScript File

    function BuscarDoc()
    {
      window.open('dspBusquedaDocumento.aspx', 'CENFBUSQUEDA', 'width=391,height=185,scrollbars=yes');
      ReturnFalse();
    }
       
    function ReturnFalse()
    {
      return false;
    }
    
    function dspBancos (from) 
        { 
           var x = from;            
           var cadena ,comp, band, seleccion;
           cadena = document.form1.UcCriteriosBusqueda1$hdfTipoMedio.value;
           seleccion = document.form1.UcCriteriosBusqueda1$hdfTipoMedioTodos.value;
           comp = 42;
           band =  cadena.indexOf(comp);
           if(seleccion == 'T' || cadena =='')
            band = 0
          
           if ( band != -1 ) 
           {
            if (x == 'Emisor')  
                    window.open('lstBancos.aspx?From=BancoEmisor&Banco=', 'CENF', 'width=385,height=535,scrollbars=yes');                                              
                else        
                    window.open('lstBancos.aspx?From=BancoReceptor&Banco=', 'CENF', 'width=385,height=535,scrollbars=yes');
                    
           }
           else     
            {                
                     alert('Para seleccionar un banco debe escoger el tipo de medio !!Pago a una cuenta Bancaria (TEF)!!. ')            
                }
           
        }
        
       function removeLeadingZeros(str)
        {
          while (str.charAt(0) == '0')
            str = str.substr(1);
          return str;
        }

function isDate(str)
{
  try
  { 
    arr = str.split('/');
    year = parseInt(removeLeadingZeros(arr[0]));
    month = parseInt(removeLeadingZeros(arr[1]));
    day = parseInt(removeLeadingZeros(arr[2]));
    
    
   
    if (year  > 1900 && year  <= 2099)
    {  
        if (month  > 0 && month  <= 12)
        { 
           if (day  >= 1 && day  <=31 )      
                return true;
        }
    }
    else
        return false;
  }
  catch(err)
  {
    return false;
  }
}

 
        
        
        
        
 function fecha_valida()
    {	    
    var error = 0;
	
	if (error == 0)
	{		    
	    
		if (document.form1.UcCriteriosBusqueda1$cboTipoFecha.value == "FCDOC")
		{		   
			if (document.form1.UcCriteriosBusqueda1$txtFechaHoraInicial.value != "")
			{
			    if(isDate(document.form1.UcCriteriosBusqueda1$txtFechaHoraInicial.value))
			    {
				    if (document.form1.UcCriteriosBusqueda1$txtFechaHoraInicial.value > document.form1.UcCriteriosBusqueda1$hdfFechaHoy.value)
				    {			    
				        alert("La fecha inicial no puede ser mayor que la fecha actual");
				        error = 1;
				    }
				}
				else
				{
				     alert("Fecha Inicial Inválida");
				     error = 1;
				     }
			}
			if (document.form1.UcCriteriosBusqueda1$txtFechaHoraFinal.value != "")
			{
			    if(isDate(document.form1.UcCriteriosBusqueda1$txtFechaHoraFinal.value))
			    {
				    if (document.form1.UcCriteriosBusqueda1$txtFechaHoraFinal.value > document.form1.UcCriteriosBusqueda1$hdfFechaHoy.value)
			        {			     
			            alert("La fecha final no puede ser mayor que la fecha actual");
			            error = 1;
			        }
			    }
			    else
				{
				     alert("Fecha Final Inválida");
				     error = 1;
				}
			}
		}
		if ((document.form1.UcCriteriosBusqueda1$txtFechaHoraInicial.value != "") && (document.form1.UcCriteriosBusqueda1$txtFechaHoraFinal.value != ""))
		{
		    if(isDate(document.form1.UcCriteriosBusqueda1$txtFechaHoraInicial.value) && isDate(document.form1.UcCriteriosBusqueda1$txtFechaHoraFinal.value))
		    {
			    if (document.form1.UcCriteriosBusqueda1$txtFechaHoraInicial.value > document.form1.UcCriteriosBusqueda1$txtFechaHoraFinal.value)
			    {
				    alert("La fecha inicial no puede ser mayor que la fecha final");
				    error = 1;
			    }
			}
			else
				{
				     alert("Fechas Inválidas");
				     error = 1;
				}
		}
	}
	if (error == 0)
	{
		return true;
	}   
	else
	{
	    return false;
	    }
    	
	   
    }
    function CopyField(from)
    {
      document.form1.UcCriteriosBusqueda1$hdfOrdenamiento.value = from;     
    }
    
 
       
    function mostrar(nombreCapa){
    document.getElementById(nombreCapa).style.visibility="visible";
    }
    function ocultar(nombreCapa){
    document.getElementById(nombreCapa).style.visibility="hidden";
    }
    
    function MostrarInfo(strTxtValores,strPopup,imgBoton)
    {
        var posY = parseInt(event.clientY) + parseInt(imgBoton.style.height);
        var posX = parseInt(event.clientX) + parseInt(imgBoton.style.width);
        
        if(document.getElementById(strTxtValores).value.length > 0)
		{
			if(document.getElementById(strPopup))
			{
				document.getElementById(strPopup).style.position = 'absolute';
				document.getElementById(strPopup).style.top = posY;
				document.getElementById(strPopup).style.left = posX;
				document.getElementById(strPopup).style.zIndex = 1;
                document.getElementById(strPopup).style.display = 'block';
			    //document.getElementById(strPopup).style.visibility = "visible";
			}
	    }
    }
    
    function OcultarInfo(strPopup)
    {
        if(document.getElementById(strPopup))
        {
            document.getElementById(strPopup).style.display = 'none';
			//document.getElementById(strPopup).style.visibility = "hidden";
        }
    }
    
    
    
    function MM_reloadPage(init) {  //reloads the window if Nav4 resized
      if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
        document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
      else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
    }
    MM_reloadPage(true);

    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }

    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }

    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
