// JavaScript Document

	function hkp( evt )
	{
		_KeyCode = ( window.event ) ? evt.keyCode : evt.which;
		return( _KeyCode );
	}


//
// Carga opciones para busqueda de familia
//

function _cambiar_tipo_consulta(){
	var tipoNombres = document.getElementById('tipoNombres');
	var tipoDefecto = document.getElementById('tipoDefecto');
	var tipo = document.getElementById('id_tipoB');
	var opcionSeleccionada = tipo.options[tipo.selectedIndex].value;
	if( opcionSeleccionada == 'APELLIDOS' )
	{
		tipoNombres.style.display= 'block';
		tipoDefecto.style.display= 'none';
	}
	else
	{
		tipoNombres.style.display= 'none';
		tipoDefecto.style.display= 'block';
	}
	
}


function cambiar_tipo_consulta(){
	var tipoDefecto = document.getElementById( 'tipoDefecto' );
	var tipoFormulario = document.getElementById( 'tipoFormulario' );
	var tipoNombres = document.getElementById( 'tipoNombres' );

  var cmpDefecto = document.getElementById( 'cedula' );
  var cmpNombres = document.getElementById( 'formulario' );
  var cmpFormulario = document.getElementById( 'nombres' );
	
	var tipo = document.getElementById( 'id_tipoB' );
	var opcionSeleccionada = tipo.options[tipo.selectedIndex].value;

  //  Muestra el formulario de busqueda por cedula
	if( opcionSeleccionada == 'CEDULA' ){
		tipoDefecto.style.display = 'block';
		tipoNombres.style.display = 'none';
		tipoFormulario.style.display = 'none';
    cmpNombres.value = "";
    cmpFormulario.value = "";
	}

  //  Muestra el formulario de busqueda por nombres
	if( opcionSeleccionada == 'APELLIDOS' ){
		tipoNombres.style.display = 'block';
		tipoDefecto.style.display = 'none';
		tipoFormulario.style.display = 'none';
    cmpDefecto.value = "";
    cmpFormulario.value = "";
	}

  //  Muestra el formulario de busqueda por numero de formulario
	if( opcionSeleccionada == 'FORMULARIO' ){
		tipoFormulario.style.display = 'block';
		tipoNombres.style.display = 'none';
		tipoDefecto.style.display = 'none';
    cmpDefecto.value = "";
    cmpNombres.value = "";
	}
}



function cancelar_guardar_estado( id, id_estado, estado )
{
	var divDestino=document.getElementById( "divEstado" + id );
	
	var text = '<div id="estado_' + id + '"><a href="javascript: null;" onclick="carga_form_estado( \'' + id + '\', \'' + id_estado + '\' ); return false;">' + estado + '</a></div>';
	divDestino.innerHTML=text;
}


function check_cedula( id )
{
  var cedula = document.getElementById( id ).value;
  array = cedula.split( "" );
  num = array.length;
  if ( num == 10 )
  {
    total = 0;
    digito = (array[9]*1);
    for( i=0; i < (num-1); i++ )
    {
      mult = 0;
      if ( ( i%2 ) != 0 )
        total = total + ( array[i] * 1 );
      else
      {
        mult = array[i] * 2;
        if ( mult > 9 )
          total = total + ( mult - 9 );
        else
          total = total + mult;
      }
    }
    decena = total / 10;
    decena = Math.floor( decena );
    decena = ( decena + 1 ) * 10;
    final = ( decena - total );
    if ( ( final == 10 && digito == 0 ) || ( final == digito ) )
      return true;
    else
    {
      alert( "La c�dula no es valida!!!" );
      return false;
    }
  }
  else
  {
    alert("La c�dula no puede tener menos de 10 digitos");
    return false;
  }
}



	var time_pattern = new Array(2,2,2)
	var hour_pattern = new Array(2,2)
	var cedula_pattern = new Array(9,1)
	function mascara(d,sep,pat,nums){
	if(d.valant != d.value){
		val = d.value
		largo = val.length
		val = val.split(sep)
		val2 = ''
		for(r=0;r<val.length;r++){
			val2 += val[r]	
		}
		if(nums){
			for(z=0;z<val2.length;z++){
				if(isNaN(val2.charAt(z))){
					letra = new RegExp(val2.charAt(z),"g")
					val2 = val2.replace(letra,"")
				}
			}
		}
		val = ''
		val3 = new Array()
		for(s=0; s<pat.length; s++){
			val3[s] = val2.substring(0,pat[s])
			val2 = val2.substr(pat[s])
		}
		for(q=0;q<val3.length; q++){
			if(q ==0){
				val = val3[q]
			}
			else{
				if(val3[q] != ""){
					val += sep + val3[q]
					}
			}
		}
		d.value = val
		d.valant = val
		}
	}
