// JavaScript Document
//window.history.forward(1);
 function esIntegerOnly(e) {
                    var charCode;
                    var statusa;
                    if (navigator.appName == "Netscape")
                    { // Veo si es Netscape o Explorer (mas adelante lo explicamos)
                        charCode = e.which; // leo la tecla que ingreso
                    }
                    else
                    {
                      charCode = e.keyCode; // leo la tecla que ingreso
                      statusa = charCode;
                        if (charCode > 31 && (charCode < 48 || charCode > 57)) 
                        { // Chequeamos que sea un numero comparandolo con los valores ASCII
                            //alert("SOLO SE PERMITEN NUMEROS");
                            return false;
                         }
                         else
                         {
                            return true;
                         }
                        }
                      }
                      
                      //para el login usuario


                      
 
                     
function esIntegerOnlyFlotante(e) {
                    var charCode;
                    var statusa;
                    if (navigator.appName == "Netscape")
                    { // Veo si es Netscape o Explorer (mas adelante lo explicamos)
                        charCode = e.which; // leo la tecla que ingreso
                    }
                    else
                    {
                      charCode = e.keyCode; // leo la tecla que ingreso
                      statusa = charCode;
                        if (charCode > 31 && (charCode < 46 || charCode > 57)) 
                        { // Chequeamos que sea un numero comparandolo con los valores ASCII
                            //alert("SOLO SE PERMITEN NUMEROS");
                            return false;   
                         }
                         else
                         {
                            return true;
                         }
                        }
                      }                      
                      
function verificaCaracter( e )
{
var charCode
var statusa
if (navigator.appName == "Netscape"){ // Veo si es Netscape o Explorer (mas adelante lo explicamos)
charCode = e.which // leo la tecla que ingreso
}else{
    charCode = e.keyCode // leo la tecla que ingreso
        statusa = charCode
       if (!((charCode >= 47 && charCode <= 57) || (charCode >= 65 && charCode <= 90) || (charCode >= 97 && charCode <= 122) || (charCode==32) || (charCode==95) || (charCode==45)|| (charCode==209)|| (charCode==241) || (charCode==46) || (charCode==164) || (charCode==165))) { // Chequeamos que sea un numero comparandolo con los valores ASCII
        //alert("CARACTERES ESPECIALES NO PERMITIDOS");
        return false
        }else{
            return true
         }
    }
}		


function verificaUsuario( e )
{
var charCode
var statusa
if (navigator.appName == "Netscape"){ // Veo si es Netscape o Explorer (mas adelante lo explicamos)
charCode = e.which // leo la tecla que ingreso
}else{
    charCode = e.keyCode // leo la tecla que ingreso
        statusa = charCode
        if (!((charCode >= 48 && charCode <= 57) || (charCode >= 65 && charCode <= 90) || (charCode >= 97 && charCode <= 122) || (charCode == 241) || (charCode == 209) || (charCode == 64))) 
       { 
        // Chequeamos que sea un numero comparandolo con los valores ASCII
        //alert("CARACTERES ESPECIALES NO PERMITIDOS"); 
                return false
       }
       else
       {
            return true
       }
    }
}	


function verificaPassword(e)
{
var charCode
var statusa
if (navigator.appName == "Netscape"){ // Veo si es Netscape o Explorer (mas adelante lo explicamos)
charCode = e.which // leo la tecla que ingreso
}else{
    charCode = e.keyCode // leo la tecla que ingreso
        statusa = charCode
       if (!((charCode >= 48 && charCode <= 57) || (charCode >= 65 && charCode <= 90) || (charCode >= 97 && charCode <= 122)  || 
                (charCode==95) || (charCode==45)|| (charCode ==37)||(charCode ==36)||(charCode ==47)||
                (charCode ==63)||(charCode ==168)||(charCode ==33)||(charCode ==44)||(charCode ==46)||(charCode ==59)||
                (charCode ==58)||(charCode ==35)||(charCode ==241)||(charCode ==209)))
      { // Chequeamos que sea un numero comparandolo con los valores ASCII
        //alert("CARACTERES ESPECIALES NO PERMITIDOS")
        return false
        }else{
            return true
         }
    }
}		

function verificaCaracterGeneral(e)
{
var charCode
var statusa
if (navigator.appName == "Netscape"){ // Veo si es Netscape o Explorer (mas adelante lo explicamos)
charCode = e.which // leo la tecla que ingreso
}else{
    charCode = e.keyCode // leo la tecla que ingreso
        statusa = charCode
       if (!((charCode >= 47 && charCode <= 57) || (charCode >= 65 && charCode <= 90) || (charCode >= 97 && charCode <= 122)  || 
                (charCode==95) || (charCode==45)|| (charCode ==37)||(charCode ==36)||(charCode ==47)||
                (charCode ==63)||(charCode ==64)||(charCode ==168)||(charCode ==33)||(charCode ==44)||
                (charCode ==46)||(charCode ==59)||(charCode ==58)||(charCode ==35)||(charCode ==32)||(charCode ==241)||(charCode ==209)))
      { // Chequeamos que sea un numero comparandolo con los valores ASCII
        //alert("CARACTERES ESPECIALES NO PERMITIDOS");
        return false
        }else{
            return true
         }
    }
}		


function verificaRFC(e)
{
var charCode
var statusa
if (navigator.appName == "Netscape"){ // Veo si es Netscape o Explorer (mas adelante lo explicamos)
charCode = e.which // leo la tecla que ingreso
}else{
    charCode = e.keyCode // leo la tecla que ingreso
        statusa = charCode
       if (!((charCode >= 48 && charCode <= 57) || (charCode >= 65 && charCode <= 90) || (charCode >= 97 && charCode <= 122)  || 
                (charCode==45) ||(charCode ==241)||(charCode ==209) ))
      { // Chequeamos que sea un numero comparandolo con los valores ASCII
        //alert("CARACTERES ESPECIALES NO PERMITIDOS");
        return false
        }else{
            return true
         }
    }
}	


function verificaTelefonos(e)
{
var charCode
var statusa
if (navigator.appName == "Netscape"){ // Veo si es Netscape o Explorer (mas adelante lo explicamos)
charCode = e.which // leo la tecla que ingreso
}else{
    charCode = e.keyCode // leo la tecla que ingreso
        statusa = charCode
       if (!((charCode >= 48 && charCode <= 57) || (charCode >= 65 && charCode <= 90) || (charCode >= 97 && charCode <= 122)  || 
                (charCode==45)||(charCode==32) ||(charCode ==241)||(charCode ==209)))
      { // Chequeamos que sea un numero comparandolo con los valores ASCII
        //alert("CARACTERES ESPECIALES NO PERMITIDOS");
        return false
        }else{
            return true
         }
    }
}	




function verificaCaracterIdentificacion( e )
{
var charCode
var statusa
if (navigator.appName == "Netscape"){ // Veo si es Netscape o Explorer (mas adelante lo explicamos)
charCode = e.which // leo la tecla que ingreso
}else{
    charCode = e.keyCode // leo la tecla que ingreso
        statusa = charCode
       if (charCode > 31 && (charCode < 45 || charCode > 57)) 
       {
        
        //alert("CARACTERES ESPECIALES NO PERMITIDOS");
        return false
        }else{
            return true
         }
    }
}		




 ///
                      
 function leeIdCliente(msg){
     if((Request.QueryString("&basis").Count > 0) ||(Request.QueryString("basis").Count > 0))
     {
      return true;
     }
     else
     { 
        alert(msg) ;
       return false;
     }    
 }                     
	
                      
 function leeIdFuncionario(msg){
     if((Request.QueryString("&funcionario").Count > 0) ||(Request.QueryString("funcionario").Count > 0))
     {
      return true;
     }
     else
     { 
        alert(msg) ;
       return false;
     }    
 }    	
	
function registrarLlamada(msgTexts,msgChecks)
{
    if (validaTextBoxes(msgTexts)==true)
    {    
           if(document.getElementById("txtComentario").value=="")
           {
                alert(msgTexts); 
                return false;
           }
           else
           {
              if (validaCheckBoxes(msgChecks)==true)
                 {
                  return true;
                 }
                 else
                 {
                   return false;
                 }
                
           }      
    }
    else
    {
      return false;
    }

}	
function checkSize(obj, limite,msg) 
{
    if(obj.value.length > limite)
    {
    alert(msg); 
     var a=obj.value;
     obj.value=obj.value;
     obj.value=a.substring(0,limite);
     return false;
    }
return true;
}
	
function validaTextBoxes(msg)
{   formulario = document.getElementById("form1"); 
    for(var i=0; i<formulario.elements.length; i++) 
    {      
       var elemento = formulario.elements[i];      
       if(elemento.type == "text") 
       {
              if(elemento.value=="") 
              { 
                 alert(msg);
                 return false;                 
              }              
       }       
    }
    return true;
 }   
	
function validaCheckBoxes(msg)
{
    formulario = document.getElementById("form1"); 
    for(var i=0; i<formulario.elements.length; i++) 
    {      
       var elemento = formulario.elements[i];      
       if(elemento.type == "checkbox") 
       {
              if(elemento.checked) 
              { 
                 return true;
              }
              
       }
    }
    alert(msg);
    return false;
}		
	
	
function limpiaCheckBoxes()
{
  formulario = document.getElementById("form1"); 
    for(var i=0; i<formulario.elements.length; i++) 
    {      
       var elemento = formulario.elements[i];      
       if(elemento.type == "checkbox") 
       {
              if(elemento.checked) 
              { 
                elemento.checked="";               
              }
              
       }
    }
  
}


function habilitarFechasNacimiento	(form)
{

 if(form.txtNombrePropietario2.value=="")
 {
 form.txtFechaNacimientoPropietario2.disabled=true; 
 form.txtFechaNacimientoPropietario2.value="";
 }
 else
 {
 form.txtFechaNacimientoPropietario2.disabled=false; 
 }
 
 if(form.txtNombrePropietario3.value=="")
 {
 form.txtFechaNacimientoPropietario3.disabled=true; 
 form.txtFechaNacimientoPropietario3.value="";
 }
 else
 {
 form.txtFechaNacimientoPropietario3.disabled=false; 
 }
 
 if(form.txtNombrePropietario4.value=="")
 {
 form.txtFechaNacimientoPropietario4.disabled=true; 
 form.txtFechaNacimientoPropietario4.value="";
 }
 else
 {
 form.txtFechaNacimientoPropietario4.disabled=false; 
 }
}

function validaIdentificacionCadastro(form,msgOblCadastro,msgIncCadastro,msgIncContato,msgOblContato,msgIncProp1,msgOblProp1,msgIncProp2,msgOblProp2,msgIncProp3,msgOblProp3,msgIncProp4,msgOblProp4)
{ 
  //formulario = document.getElementById("form1"); 
  var cnpj = form.txtIdentificacion.value;
  var tipoDocumento=form.ddTipoIdentificacion.value;
  var contador;
  var mensaje='';
  
  contador=0;
  var exp = /\.|\/|\s|\-/g
  cnpj = cnpj.toString().replace( exp, "" ); 
  
   var valido=false;
   
   if(cnpj!="")
   {
   if(tipoDocumento==3)
   {
   //alert ('es cpf');
    valido=validaCPF(cnpj);
    //alert (valido);
    
   }
   else
   {
   //alert ('es cnpj');
    valido=validaCNPJ(cnpj);
   }
   
   }
   else
   {
    alert (msgOblCadastro);
    return false;
   }
   if(valido==false)
   {
     contador=contador+1;
     mensaje=msgIncCadastro;
     if(confirm(mensaje)==false)
     {
        return false;
     }
   }
     
     //contacto
   var cpfContacto = form.txtIdentificacionContacto.value;  
   cpfContacto = cpfContacto.toString().replace( exp, "" ); 
   if(cpfContacto!="")
   {
    valido=validaCPF(cpfContacto);
     
    if(valido==false)
    {
     contador=contador+1;
     mensaje=msgIncContato;
     if(confirm(mensaje)==false)
     {
        return false;
     }

    }
    }
    else
    {
     alert (msgOblContato);
     return false;
    }
    
   var cpfPropietario1 = form.txtCPFPropietario.value;  
   cpfPropietario1 = cpfPropietario1.toString().replace( exp, "" ); 
   
   valido=validaCPF(cpfPropietario1);
   if(cpfPropietario1!="") 
   {
    if(valido==false)
    {
     contador=contador+1;
     mensaje=msgIncProp1;
     if(confirm(mensaje)==false)
     {
        return false;
     }

   }
   }
   else
   {
    alert (msgOblProp1);
    return false;
   } 
    
    
   var cpfPropietario2 = form.txtCPFPropietario2.value;  
   if(form.txtCPFPropietario2.disabled==false)
   {
        cpfPropietario2 = cpfPropietario2.toString().replace( exp, "" ); 
       if(cpfPropietario2!="")
       {
           
           valido=validaCPF(cpfPropietario2);
             
           if(valido==false)
           {
             contador=contador+1;
             mensaje=msgIncProp2;
             if(confirm(mensaje)==false)
             {
                return false;
             }

           }
       } 
       else
       {
        alert (msgOblProp2);
        return false;
       }
  }
  
  
  var cpfPropietario3 = form.txtCPFPropietario3.value; 
  if(form.txtCPFPropietario3.disabled==false)
  {
        cpfPropietario3 = cpfPropietario3.toString().replace( exp, "" ); 
      if(cpfPropietario3!="")
      { 
           
           valido=validaCPF(cpfPropietario3);
             
           if(valido==false)
           {
             contador=contador+1;
             mensaje=msgIncProp3;
             if(confirm(mensaje)==false)
             {
                return false;
             }

           } 
      }
      else
        {
            alert (msgOblProp3);
            return false;
         }
  }
  
  
   var cpfPropietario4 = form.txtCPFPropietario4.value;  
   if(form.txtCPFPropietario4.disabled==false)
   {
   cpfPropietario4 = cpfPropietario4.toString().replace( exp, "" ); 
       if(cpfPropietario4!="")
       {
           
           valido=validaCPF(cpfPropietario4);
             
           if(valido==false)
           {
            contador=contador+1;
             mensaje=msgIncProp4;
             if(confirm(mensaje)==false)
             {
                return false;
             }

           } 
       }
       else
        {
            alert (msgOblProp4);
            return false;
        }
    }
    
        return true;
       
  
   
}	


   function validaCPF(str) {   
                str = str.replace("-","");   
             str = str.replace(".","");   
                 str = str.replace(".","");   
             cpf = str;   
             erro = new String;   
                if (cpf.length < 11)
                {
                    return false;
                }
                var nonNumbers = /\D/;   
               if (nonNumbers.test(cpf))
               { 
                return false;
               }
                if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999")
                {   
                        return false;
                }   
              var a = [];   
              var b = new Number;   
              var c = 11;   
              for (i=0; i<11; i++){   
                      a[i] = cpf.charAt(i);   
                      if (i < 9) b += (a[i] * --c);   
              }   
              if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }   
              b = 0;   
              c = 11;   
              for (y=0; y<10; y++) b += (a[y] * c--);   
              if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }   
              if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10]))
              {   
                      return false;   
              }   
              
              return true;   
      } 




function validaCNPJ( s )
{
	var a	=	new Array();	
	var b	=	new Number;	
	var c	=	[ 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2 ];		
	for ( i = 0; i < 12; i++ )	
	{		
	    a[ i ]	=	s.charAt( i );		
	    b	+= a[ i ] * c[ i + 1 ];	
	}
	if ( ( x = b % 11 ) < 2 )	
	{		
	    a[ 12 ] = 0	
	}	
	else	
	{
	    a[ 12 ] = 11 - x	
	}		
	b = 0;		
	for ( y = 0; y < 13; y++ )	
	{		
	    b	+=	( a[ y ] * c[ y ] );	
	}		
	if ( ( x = b % 11 ) < 2 )	
	{		
	    a[ 13 ] = 0;	
	}	
	else	
	{		
	    a[ 13 ] = 11 - x;	
	}		
	if ( ( s.charAt( 12 ) != a[ 12 ] ) || ( s.charAt( 13 ) != a[ 13 ] ) )	
	{		return false;	}		
	
	return true;
	
	}









window.onunload = function()
{
    if(self.screenTop>9000)
     {    
            location.href="desbloqueo.aspx";       
 
      }
 }

function desbloqueo(){
location.href='desbloqueo.aspx'
}

function salir(msg){
    if(window.confirm(msg)==true)
       { 
          desbloqueo(); 
          location.href="login.aspx";       
          return true;
        }
    else{
             return false;
        }
}



