

/*FUNCION PARA LA PARTE DE DISCAPACIDAD*/

function cambiaDiscapacidad(var1){
	if(var1=='S'){
		infopersonal.discapacidad.disabled="";
	}else{
		infopersonal.discapacidad.disabled="disabled";
	}
}


/*  PARA QUE JAVA SCRIPT FUNCIONE DEBE ESTAR ACTIVADA DICHA OPCION EN EL EXPLORADOR*/

//funcion para expandir el menu al momento de hacer click
function menuExpand ( item ) {
        // lista de elementos
        // si no esta aqui no va
        items = new Array ( 'elem1', 'elem2','elem3','elem4', 'elem5','elem6');
        for ( i = 0; i < items.length; i++ ){
          if ( ( items[i] == item ) && ( document.getElementById(items[i]).style.visibility=='hidden' ) ){
            document.getElementById(items[i]).style.visibility='visible';
            document.getElementById(items[i]).style.position='relative';
          } else {
            document.getElementById(items[i]).style.visibility='hidden';
            document.getElementById(items[i]).style.position='absolute';
          }
        }
      }


//funcion para validar el ingreso de solo mayusculas, esta hecha para ie y para mozilla firefox
function validate_form(current_form){
	 var ctr_error = 0;
		for(var ctr = 0; c_form = current_form[ctr];ctr++){
			if(c_form.type == "text"){
			  if(c_form.value.search(/[a-zñá-ú]/) == -1) {
			  alert("Todo el texto está en mayúsculas\n" +
			  "en el campo " + c_form.name);
			  
			  }
			  else {
			  alert("El texto no está escrito en su totalidad en mayúsculas\n" +
			  "en el campo " + c_form.name);
			  
			  ctr_error++;
			  }
			}
		
			
		}
		if(ctr_error > 0) return false;
		else return true;
}
 //Valida mayusculas
function pulsar(e) {
	  tecla = (document.all) ? e.keyCode : e.which;
	  if(tecla == 9 || tecla == 0) return false;
	  if(tecla == 8) return true;
	  if(window.Event){
	      var pst = e.currentTarget.selectionStart;
	      var string_start = e.currentTarget.value.substring(0,pst);
	      var string_end = e.currentTarget.value.substring(pst ,e.currentTarget.value.length);
	      e.currentTarget.value = string_start+ String.fromCharCode(tecla).toUpperCase()+ string_end;
	      e.currentTarget.selectionStart = pst + 1;
	      e.currentTarget.selectionEnd = pst + 1;
	      e.stopPropagation();
	      return false;
	  }
	  else if (window.event){
	  
	  return e.keyCode =   String.fromCharCode( e.keyCode ).toUpperCase().charCodeAt(0);
	  }
	}


//--------------------------------------- SECCION 1  --------------------------------------------------------
//funcion para cambiar las opciones cuando se ha modificado en el curriculum en los combo-box



function CambiaOpcionNacionalidad(var1){
	
	if(var1=="OTROS" ){
		
		infopersonal.nacionalidad.readOnly=false;
		infopersonal.nacionalidad.style.visibility='visible';
		infopersonal.nacionalidad.style.position='relative';
		infopersonal.nacionalidad.value='';
		
	}else{
		infopersonal.nacionalidad.readOnly=true;
		infopersonal.nacionalidad.style.visibility='hidden';
		infopersonal.nacionalidad.style.position='absolute';
	}
}

	

//--------------------------------------- SECCION DATOS PERSONALES --------------------------------------------------------
//funcion para cambiar de un readonly=true a un readonly=false


//------------------------------- SECCION HIJOS --------------------------
function seleccionar(elemento,combo) {
	   var cantidad = combo.length;
	//   alert('Cantidad: '+cantidad);
	 //  alert('Elemento: '+elemento);
	   for (i = 0; i < cantidad; i++) {
	      if (combo[i].value == elemento) {
	         combo[i].selected = true;
	      }   
	   }
	}

function editaHijo( var1 ){
	sitems=new Array ('scodigoHijo'+ var1, 'shijo'+ var1, 'sfechahijo'+var1, 'ssexohijo'+var1,'fila'+var1, 'calendarioHijo'+var1 );
	items=new Array ('codigoHijo'+ var1, 'hijo'+ var1, 'fechahijo'+var1, 'sexohijo'+var1 );
	var cod = 'codigoHijo'+var1;
	var name = 'hijo'+var1;
	var fh = 'fechahijo'+var1;
	var sex = 'sexohijo'+var1;
	
		  if (document.getElementById(sitems[4]).style.visibility=='hidden' ){
			 
			  document.getElementById(sitems[1]).disabled='';
			  document.getElementById(sitems[1]).readOnly=false;
			  document.getElementById(sitems[2]).disabled='';
			 // document.getElementById(sitems[2]).readOnly=false;
			  document.getElementById(sitems[3]).disabled='';
			  document.getElementById(sitems[5]).disabled='';
			 
			  document.getElementById('operacionHijo').value='actualiza';
			  //alert('entra if');
			 // alert('valores: ' + document.getElementById(sitems[3]).value + " 2do: "+document.getElementById(sitems[3]));
		    seleccionar(document.getElementById(sitems[3]).value,document.getElementById(sitems[3]));
		   // alert('entra if 2');
		  }else{
			//  alert('entra else');	 
			 //infoHijos.boton.disabled="disabled";
		  }
		 // alert('llega');
		  infoHijos.boton1G.disabled="";
}


function agregafila(num){
	//var num=1;
	
	if(num=='0'){
		num += parseInt(1);
		var numfila='fila'+num;
			while(document.getElementById(numfila).style.visibility=='visible'){
				num += parseInt(1);
				numfila='fila'+num;
			}
			document.getElementById(numfila).style.visibility='visible';
	    	document.getElementById(numfila).style.position='relative';
	}else {
		num += parseInt(1);
		var numfila='fila'+num;
			while(document.getElementById(numfila).style.visibility=='visible'){
				num += parseInt(1);
				numfila='fila'+num;
			}
			document.getElementById(numfila).style.visibility='visible';
	    	document.getElementById(numfila).style.position='relative';
	}
	infoHijos.boton1G.disabled="";
	infoHijos.quitarf.disabled="";
}

function quitarfilas(){
	var i = 1;
	var numfila='fila';
	while(i != 16){
		//numfila +i;
		if(document.getElementById('fila'+i).style.visibility=='visible'){
			document.getElementById('fila'+i).style.visibility='hidden';
			document.getElementById('fila'+i).style.position='absolute';
		}
		i += parseInt(1);
	}
	infoHijos.boton1G.disabled="disabled";
	infoHijos.quitarf.disabled="disabled";
}
//--------------------------------------- SECCION FORMACION --------------------------------------------------------

function formTitulo(item){
	var max='max';
	items = new Array ('nuevoT');
	for ( i = 0; i < items.length; i++ ){
	  if ( ( items[i] == item ) && ( document.getElementById(items[i]).style.visibility=='hidden' ) ){
		
		document.getElementById(items[i]).style.visibility='visible';
	    document.getElementById(items[i]).style.position='relative';
	    
	    formacion.institucion.value="";
	    formacion.titulo.value="";
	    formacion.botonSec2.value="Deshacer";
	    formacion.botonSec2.disabled="";
	    formacion.boton2G.disabled="";
		formacion.itemIns.value= document.getElementById(max).value;
		
		var campo =document.getElementById('operacion').value;
		
		if(campo!=''){
			document.getElementById('institucion'+campo).disabled="disabled";
			document.getElementById('titulo'+campo).disabled="disabled";
			document.getElementById('anio'+campo).disabled="disabled";
			document.getElementById('selCombo4'+campo).disabled="disabled";
			
			document.getElementById('institucion'+campo).readOnly=true;
			document.getElementById('titulo'+campo).readOnly=true;
			document.getElementById('anio'+campo).readOnly=true;
		}
		
		document.getElementById('operacion').value="";
	  }else{
		 document.getElementById(items[i]).style.visibility='hidden';
		 document.getElementById(items[i]).style.position='absolute';
		 formacion.botonSec2.value="Agregar Instruccion";
		 formacion.boton2G.disabled="disabled";
	  }
	}
}



function editaInstruccion(var1,var2){
	items = new Array ('itemIns'+var1,'institucion'+var1, 'titulo'+var1, 'anio'+var1, 'selCombo4'+var1 );
	var max=var2;
	max = parseInt(parseInt(max) + parseInt(1));
	
	document.getElementById('nuevoT').style.visibility='hidden';
	document.getElementById('nuevoT').style.position='absolute';
	//alert('El maximo valor es: '+max);
	var i=1;
	while(i!=max){
		
		if(i==var1){
			
			document.getElementById(items[1]).disabled="";
			document.getElementById(items[2]).disabled="";
			document.getElementById(items[3]).disabled="";
			document.getElementById(items[4]).disabled="";
			
			document.getElementById(items[1]).readOnly=false;
			document.getElementById(items[2]).readOnly=false;
			document.getElementById(items[3]).readOnly=false;
			
		}
		else{
			
			document.getElementById('institucion'+i).disabled="disabled";
			document.getElementById('titulo'+i).disabled="disabled";
			document.getElementById('anio'+i).disabled="disabled";
			document.getElementById('selCombo4'+i).disabled="disabled";
			
			document.getElementById('institucion'+i).readOnly=true;
			document.getElementById('titulo'+i).readOnly=true;
			document.getElementById('anio'+i).readOnly=true;
		}
		i += parseInt(1);
	}
	
	document.getElementById('operacion').value=var1;
	formacion.boton2G.disabled="";
	formacion.anio.value='1900';
	//alert(document.getElementById('operacion').value);
}





//-----------------------------------------SECCION CAPACITACION INTERNA Y EXTERNA -----------------------------------------------
//function para mostrar el formulario de ingreso de nuevo curso al curriculumEmpleado 
function formularioCurso ( item ) {
items = new Array ('curso');
for ( i = 0; i < items.length; i++ ){
  if ( ( items[i] == item ) && ( document.getElementById(items[i]).style.visibility=='hidden' ) ){
    document.getElementById(items[i]).style.visibility='visible';
    document.getElementById(items[i]).style.position='relative';
    capacitacion.evento2.value="";
    capacitacion.institucion2.value="";
    capacitacion.lugar2.value="";
    capacitacion.anio2.value="";
    capacitacion.boton3G.disabled ="";
    capacitacion.botonSec3.value ="Deshacer";
  } else {
    document.getElementById(items[i]).style.visibility='hidden';
    document.getElementById(items[i]).style.position='absolute';
    capacitacion.boton3G.disabled="disabled";
    capacitacion.botonSec3.value="Agregar Evento";
  }
}
}


function formularioCursoExt ( item, max ) {
	items = new Array ('cursoExt');
	for ( i = 0; i < items.length; i++ ){
	  if ( ( items[i] == item ) && ( document.getElementById(items[i]).style.visibility=='hidden' ) ){
	    document.getElementById(items[i]).style.visibility='visible';
	    document.getElementById(items[i]).style.position='relative';
	    capacitacionExterna.eventon.value="";
	    capacitacionExterna.institucionn.value="";
	    capacitacionExterna.lugarn.value="";
	    capacitacionExterna.anion.value="";
	    capacitacionExterna.horasn.value="";
	    capacitacionExterna.boton3G.disabled ="";
	    capacitacionExterna.botonSec3_1.value ="Deshacer";
	    
	    document.getElementById('capacitacionOperacion').value="";
	    document.getElementById('anioOperacion').value="";
	    capacitacionExterna.actualizarCExt.value="";
	  } else {
	    document.getElementById(items[i]).style.visibility='hidden';
	    document.getElementById(items[i]).style.position='absolute';
	    capacitacionExterna.boton3G.disabled="disabled";
	    capacitacionExterna.botonSec3_1.value="Agregar Curso";
	  }
	}
	for (j = 0 ; j < parseInt(max); j++){
		
		document.getElementById('evento'+j).disabled ="disabled";
		document.getElementById('evento'+j).readOnly=true;
		document.getElementById('institucionCExt'+j).disabled ="disabled";
		document.getElementById('institucionCExt'+j).readOnly=true;
		document.getElementById('lugar'+j).disabled ="disabled";
		document.getElementById('lugar'+j).readOnly=true;
		document.getElementById('anioCExt'+j).disabled ="disabled";
		document.getElementById('anioCExt'+j).readOnly=true;
		document.getElementById('horas'+j).disabled ="disabled";
		document.getElementById('horas'+j).readOnly=true;
	}
}


function editaCursoExt(var1, max){
	//alert('El valor de var1 es: '+var1);
	//alert('El valor de max es: '+max);
	var i = 0;
	items = new Array ('evento'+var1, 'institucionCExt'+var1, 'lugar'+var1, 'anioCExt'+var1, 'horas'+var1 );
	for (i = 0 ; i < parseInt(max); i++){
		if(i==var1){
		//	alert('El valor de i en el if es: '+i);
			document.getElementById(items[0]).disabled ="";
			document.getElementById(items[0]).readOnly=false;
			document.getElementById(items[1]).disabled ="";
			document.getElementById(items[1]).readOnly=false;
			document.getElementById(items[2]).disabled ="";
			document.getElementById(items[2]).readOnly=false;
		//	alert(document.getElementById(items[1]).value);
			document.getElementById(items[3]).disabled ="";
			document.getElementById(items[3]).readOnly=false;
			document.getElementById(items[4]).disabled ="";
			document.getElementById(items[4]).readOnly=false;
		//	alert(document.getElementById(items[3]).value);
			
			capacitacionExterna.actualizarCExt.value=var1;
			document.getElementById('capacitacionOperacion').value=document.getElementById(items[0]).value;
			 document.getElementById('anioOperacion').value=document.getElementById(items[3]).value;
			//document.getElementById('paramOperacion').value=document.getElementById(items[1]).value + "/" + document.getElementById(items[2]).value + "/" + document.getElementById(items[3]).value;
			//alert('El curso a cambiar es: ' + capacitacionExterna.actualizarCExt.value);
			capacitacionExterna.boton3G.disabled = "";
		    
			//alert('Hay que editar el: ' + capacitacionExterna.capacitacionOperacion.value);
		}

		if(i!=var1){
		//	alert('El valor de i en el else es: '+i);
			document.getElementById('evento'+i).disabled ="disabled";
			document.getElementById('evento'+i).readOnly=true;
			document.getElementById('institucionCExt'+i).disabled ="disabled";
			document.getElementById('institucionCExt'+i).readOnly=true;
			document.getElementById('lugar'+i).disabled ="disabled";
			document.getElementById('lugar'+i).readOnly=true;
			document.getElementById('anioCExt'+i).disabled ="disabled";
			document.getElementById('anioCExt'+i).readOnly=true;
			document.getElementById('horas'+i).disabled ="disabled";
			document.getElementById('horas'+i).readOnly=true;
		}

		//alert('El valor de i es: '+i);
	}
	
	capacitacionExterna.anion.value="1900";
	capacitacionExterna.horasn.value="0";
	
}
// -----------------------------------------SECCION IDIOMAS -----------------------------------------------
//funcion para mostrar el formulario para agregar otro idioma
function formularioIdioma ( item , max) {
	items = new Array ('idioma' );
	for ( i = 0; i < items.length; i++ ){
	  if ( ( items[i] == item ) && ( document.getElementById(items[i]).style.visibility=='hidden' ) ){
	    document.getElementById(items[i]).style.visibility='visible';
	    document.getElementById(items[i]).style.position='relative';
	    idiomas.idioman.value ="";
	    idiomas.boton4G.disabled = "";
	    idiomas.botonSec4.value ="Deshacer";
	    
	    document.getElementById('operacion').value="";
		document.getElementById('idiomaOperacion').value="";
		//document.getElementById('paramOperacion').value="";
	    
	  } else {
	    document.getElementById(items[i]).style.visibility='hidden';
	    document.getElementById(items[i]).style.position='absolute';
	    idiomas.boton4G.disabled ="disabled";
	    idiomas.botonSec4.value ="Agregar Idioma";
	  }
	}
	for (j = 0 ; j < parseInt(max); j++){
		document.getElementById('idioma'+j).disabled ="disabled";
		document.getElementById('idioma'+j).readOnly=true;
		document.getElementById('comboRedaccion'+j).disabled ="disabled";
		document.getElementById('comboConversacion'+j).disabled ="disabled";
		document.getElementById('comboLectura'+j).disabled ="disabled";
	}
}

function editaIdioma(var1, max){
//	alert('El max es: '+ max);
	//alert('El var1 es: '+ var1);
	//max = parseInt(parseInt(max)- parseInt(1));
	var i = 0;
	items = new Array ('idioma'+var1, 'comboLectura'+var1, 'comboRedaccion'+var1, 'comboConversacion'+var1 );
	for (i = 0 ; i < parseInt(max); i++){
		if(i==var1){
		//	alert('El valor de i en el if es: '+i);
			document.getElementById(items[0]).disabled ="";
			document.getElementById(items[0]).readOnly=false;
			document.getElementById(items[1]).disabled ="";
			document.getElementById(items[2]).disabled ="";
			document.getElementById(items[3]).disabled ="";
			document.getElementById('operacion').value=var1;
			idiomas.operacion.value=var1;
			document.getElementById('idiomaOperacion').value=document.getElementById(items[0]).value;
			//document.getElementById('paramOperacion').value=document.getElementById(items[1]).value + "/" + document.getElementById(items[2]).value + "/" + document.getElementById(items[3]).value;
			//alert('El idioma a cambiar es: ' + idiomas.idiomaOperacion.value);
			idiomas.boton4G.disabled = "";
		  //  idiomas.botonSec4.value ="Deshacer";
		    
		//	alert('Hay que editar el: ' + idiomas.operacion.value);
		}

		if(i!=var1){
			//alert('El valor de i en el else es: '+i);
			document.getElementById('idioma'+i).disabled ="disabled";
			document.getElementById('idioma'+i).readOnly=true;
			document.getElementById('comboRedaccion'+i).disabled ="disabled";
			document.getElementById('comboConversacion'+i).disabled ="disabled";
			document.getElementById('comboLectura'+i).disabled ="disabled";
		}

		//alert('El valor de i es: '+i);
	}
	
}

//-----------------------------------------SECCION OFIMATICA -----------------------------------------------
//funcion para mostrar el formulario para agregar en ofimatica 
function formularioOfimatica ( item ) {
	var valorMax = document.getElementById('valorMaximo').value;
	var resultado = valorMax++;

	items = new Array ('nuevoOfimatica' );
	for ( i = 0; i < items.length; i++ ){
	  if ( ( items[i] == item ) && ( document.getElementById(items[i]).style.visibility=='hidden' ) ){
	    document.getElementById(items[i]).style.visibility='visible';
	    document.getElementById(items[i]).style.position='relative';
	    ofimatica.boton5G.disabled = "";
	    ofimatica.botonSec5.value ="Deshacer";
	    ofimatica.codigoPrograma.value = resultado;	
	    
	  //  seleccionar(.value,document.getElementById('comboNombre'));
	  } else {
	    document.getElementById(items[i]).style.visibility='hidden';
	    document.getElementById(items[i]).style.position='absolute';
	    document.getElementById('otrosform').style.visibility='hidden';
		document.getElementById('otrosform').style.position='absolute';
	    ofimatica.boton5G.disabled ="disabled";
	    ofimatica.botonSec5.value ="Agregar";
		//ofimatica.combo.value = "";
	  }
	}
	}

function editaOfimatica(var1){
	
	items = new Array ( ("codigoPrograma"+var1), ("comboNombre"+var1), ("comboNivelPrograma"+var1), ("nuevoOfimatica"));
	document.getElementById(items[3]).style.visibility='visible';
    document.getElementById(items[3]).style.position='relative';
	var valorMax = document.getElementById('valorMaximo').value;
	var i=1;
	while (i!=valorMax){
		if(i==var1){
			document.getElementById('codigoPrograma').value=i;
			if(document.getElementById(items[1]).value != 'INTERNET' && document.getElementById(items[1]).value != 'WORD' && document.getElementById(items[1]).value != 'EXCEL' && document.getElementById(items[1]).value != 'POWER POINT' && document.getElementById(items[1]).value != 'VISIO' && document.getElementById(items[1]).value != 'PROJECT'){
				seleccionar(document.getElementById(items[2]).value, document.getElementById('comboNivelPrograma'));
				seleccionar("OTROS", document.getElementById('comboNombre'));
				
				document.getElementById('otrosform').value = document.getElementById(items[1]).value;
				//alert('El valor asignado a otrosform es:'+document.getElementById('otrosform').value);
				
				document.getElementById('otrosform').style.visibility='visible';
				document.getElementById('otrosform').style.position='relative';

			}else{
				seleccionar(document.getElementById(items[1]).value, document.getElementById('comboNombre'));
				seleccionar(document.getElementById(items[2]).value, document.getElementById('comboNivelPrograma'));
	
				document.getElementById('otrosform').style.visibility='hidden';
				document.getElementById('otrosform').style.position='absolute';
			}
			
		}
		i += parseInt(1);
	}
		
		ofimatica.boton5G.disabled = "";
		ofimatica.botonSec5.value ="Deshacer";
   
}

function otrosOfimatica(var1){
	if(var1=="OTROS"){
		document.getElementById('otrosform').style.visibility='visible';
		document.getElementById('otrosform').style.position='relative';
	}else{
		document.getElementById('otrosform').value="";
		document.getElementById('otrosform').style.visibility='hidden';
		document.getElementById('otrosform').style.position='absolute';
	}
}

//--------------------------------------- SECCION EXPERIENCIA LABORAL --------------------------------------------------------
//funcion para mostrar el formulario para agregar otra experiencia laboral
function formularioExp ( item ) {
	items = new Array ('experienciaLaboral');
	for ( i = 0; i < items.length; i++ ){
	  if ( ( items[i] == item ) && ( document.getElementById(items[i]).style.visibility=='hidden' ) ){
	    document.getElementById(items[i]).style.visibility='visible';
	    document.getElementById(items[i]).style.position='relative';
	    experiencia.empresa.value ="";
	    experiencia.sector.value ="";
	    experiencia.actividadEmpresa.value ="";
	    experiencia.referencia.value="";
	    experiencia.cargo.value ="";
	    experiencia.nombrejefe.value ="";
	    experiencia.telefonojefe.value ="";
	    experiencia.ingresomensual.value="";
	    experiencia.motivosalida.value="";
	    experiencia.fechaini.value="";
	    experiencia.fechafin.value="";
	    experiencia.boton6G.disabled = "";
	    experiencia.botonSec6.value ="Deshacer";
	    
	  } else {
	    document.getElementById(items[i]).style.visibility='hidden';
	    document.getElementById(items[i]).style.position='absolute';
	    experiencia.boton6G.disabled ="disabled";
	    experiencia.botonSec6.value ="Agregar";
	  }
	}
	}

function editarExp(var1){
	//                      0                 1                   2                     3                 4                    5                           6                   7                     8                      9             10                    11                          12                    13
	items = new Array ( ("empresa"+var1), ("sector"+var1),("actividadEmpresa"+var1),("cargo"+var1),("nombrejefe"+var1),("referencia"+var1),("telefonojefe"+var1),("ingresomensual"+var1),("motivosalida"+var1),("fechai"+var1),("fechas"+var1),("principalesfunciones"+var1), ("experienciaLaboral"), ("tablitaEmpresa"+var1));
		
		document.getElementById(items[12]).style.visibility='visible';
		document.getElementById(items[12]).style.position='relative';
		experiencia.boton6G.disabled = "";
	    experiencia.botonSec6.value ="Deshacer";
	    
		experiencia.empresa.value = document.getElementById(items[0]).value;
		experiencia.empresa.readOnly=true;
		//experiencia.empresa.disabled="disabled";
		experiencia.sector.value = document.getElementById(items[1]).value;
		experiencia.actividadEmpresa.value = document.getElementById(items[2]).value;
		experiencia.cargo.value = document.getElementById(items[3]).value;
		experiencia.nombrejefe.value = document.getElementById(items[4]).value;
		experiencia.referencia.value = document.getElementById(items[5]).value;
		experiencia.telefonojefe.value = document.getElementById(items[6]).value;
		experiencia.ingresomensual.value = document.getElementById(items[7]).value;
		experiencia.motivosalida.value = document.getElementById(items[8]).value;
		experiencia.fechaini.value = document.getElementById(items[9]).value;
		experiencia.fechafin.value = document.getElementById(items[10]).value;
		experiencia.principalesfunciones.value = document.getElementById(items[11]).value;
		
		
		document.getElementById(items[13]).style.visibility='hidden';
		document.getElementById(items[13]).style.position='absolute';
		
}

function muestrame(var1, max){
	
	max = parseInt(parseInt(max)- parseInt(1));
	//alert(var1 + " "+ max);
	var item = "tablitaEmpresa" + var1;
	var nuevaexperiencia= "experienciaLaboral";
	//items = new Array ( "tablitaEmpresa0", "tablitaEmpresa1", "tablitaEmpresa2", "tablitaEmpresa3", "tablitaEmpresa4", "tablitaEmpresa5" );
	//max = parseInt(parseInt(max)+ parseInt(1)); 
	var i=0;
	if(document.getElementById(item).style.visibility=='hidden'){
		for(i=0; i <= parseInt(max); i++){
			if(i==var1){
				document.getElementById(item).style.visibility='visible';
		        document.getElementById(item).style.position='relative';
		        document.getElementById(nuevaexperiencia).style.visibility='hidden';
		        document.getElementById(nuevaexperiencia).style.position='absolute';
			}
			if(i!=var1)
			{
				//alert('ingresa al else');
				document.getElementById('tablitaEmpresa'+i).style.visibility='hidden';
		        document.getElementById('tablitaEmpresa'+i).style.position='absolute';
		        document.getElementById(nuevaexperiencia).style.visibility='hidden';
		        document.getElementById(nuevaexperiencia).style.position='absolute';
			}
		}
	}else{
		document.getElementById(item).style.visibility='hidden';
		 document.getElementById(item).style.position='absolute';
	}

}

function CambiaActividad(var1){
	experiencia.actividadEmpresa.value=var1;
}

function CambiaSector(var1){
	experiencia.sector.value=var1;
}

function maximaLongitud(texto,maxlong){
	var int_value, out_value;
	if (texto.value.length > maxlong){
		/*con estas 3 sentencias se consigue que el texto se reduzca
		 * al tamaño maximo permitido, sustituyendo lo que se haya
		 * introducido, por los primeros caracteres hasta dicho limite*/
		in_value = texto.value;
		out_value = in_value.substring(0,maxlong);
		texto.value = out_value;
		alert("La longitud máxima es de " + maxlong + " caracteres");
		return false;
		}
	return true;
	}

// ------------------  ORGANIGRAMA -----------------------------------------------

function nivelOrganigrama(){
	
	if(nivelesOrganigrama.nivel.value=="" || nivelesOrganigrama.codCargo.value=="" || nivelesOrganigrama.codDepart.value=="" || nivelesOrganigrama.depend.value==""){
		alert("Los campos estan vacios.");
	}
	nivelesOrganigrama.nivel.value="";	
	nivelesOrganigrama.codCargo.value="1";
	nivelesOrganigrama.codDepart.value="1";
	nivelesOrganigrama.depend.value="1";
}



// VALIDACION DE CAMPOS VACIOS EN FORMULARIOS ANTES DE REALIZAR SUBMMIT.....

function submitform(formulario){
	
	items = new Array ('nuevoT','curso','cursoExt','idioma','nuevoOfimatica');
	
	// ------------------- Para SECCION 1 ------------------------- 
	if(formulario =="infopersonal"){

		if(infopersonal.fechanacimiento.value =='' || infopersonal.cedula.value=='' || infopersonal.emergencia.value =='' ||infopersonal.emergenciaContacto.value =='' || infopersonal.lugarnacimiento.value==''){		
			alert ("Uno o mas campos está(n) vacío(s)");
			return false;
		}else{
			return true;
		}
	}

	// ----------------------- SECCION HIJOS -------------------
	
	if(formulario =="infoHijos"){
		var i=1;
		//document.getElementById('boton1G').disabled ="disabled";
		if($("#tablaesposa").css("display")=="block"){
			if(infoHijos.esposa.value=='' || infoHijos.ocupacionesposa.value=='' || infoHijos.fechaesposa.value=='null'){
				$("#boton1G").attr("Value","Guardar");
				alert ("Uno o mas campos del cónyugue está(n) vacío(s)");
					return false;
			}else{
				return true;
			}
		}
		while(i != 15){
			
			if(document.getElementById('fila'+i).style.visibility=='visible'){
					if(document.getElementById('codigoHijo'+i).value=='' || document.getElementById('hijo'+i).value=='' || document.getElementById('fechahijo'+i).value=='' || document.getElementById('sexohijo'+i).value==''){
						$("#boton1G").attr("Value","Guardar");
						alert ("Uno o mas campos está(n) vacío(s)");
							return false;
					}else{
						return true;
					}
			}
			i += parseInt(1);
		}
	}
	// ------------------- Para SECCION 2 FORMACION------------------------- 
	if(formulario =='formacion'){
		
		if(document.getElementById(items[0]).style.visibility=='visible'){
			if(formacion.institucion.value=='' || formacion.titulo.value==''){
				$("#boton2G").attr("Value","Guardar");
				alert("Uno o mas campos está(n) vacío(s)");
				return false;
			}else{
				return true;
			}
		}
		if(document.getElementById(items[0]).style.visibility=='hidden'){
			//alert('retorna true');
			return true;
		}
	}
	
	// ------------------- Para SECCION 3  CAPACITACION INTERNA------------------------- 
	
	if(formulario =="capacitacion"){
		
		if(document.getElementById(items[1]).style.visibility=='visible'){
			if(capacitacion.evento2.value=='' || capacitacion.institucion2.value=='' || capacitacion.lugar2.value=='' || capacitacion.anio2.value=='' || capacitacion.horas2.value==''){
				alert("Uno o mas campos está(n) vacío(s)");
				
				return false;
			}else{
				return true;
			}
		}else{
			return true;
		}
	}
	
	// ------------------- Para SECCION 3  CAPACITACION EXTERNA------------------------- 
	if(formulario =="capacitacionExterna"){
		
		if(document.getElementById(items[2]).style.visibility=='visible'){
			if(capacitacionExterna.eventon.value=='' || capacitacionExterna.institucionn.value=='' || capacitacionExterna.lugarn.value=='' || capacitacionExterna.anion.value=='' || capacitacionExterna.horasn.value==''){
				$("#boton3G").attr("Value","Guardar");
				alert("Uno o mas campos está(n) vacío(s)");
				return false;
			}else{
				return true;
			}
		}else{
			return true;
		}
	}
	// ------------------- Para SECCION 4 IDIOMAS------------------------- 
	
	if(formulario =="idiomas"){
		
		if(document.getElementById(items[3]).style.visibility=='visible'){
			if(idiomas.idioman.value==''){
				$("#boton4G").attr("Value","Guardar");
				alert("El campo de idioma está vacío");
				return false;
			}else{
				return true;
			}
		}else{
			return true;
		}
	}
	
	
	// ------------------- Para SECCION 5 OFIMATICA -------------------------
	
	if(formulario =="ofimatica"){
	
		if(document.getElementById(items[4]).style.visibility=='visible'){
			if(ofimatica.comboNombre.value=='OTROS'){
				if(ofimatica.otrosform.value==''){
					$("#boton5G").attr("Value","Guardar");
					alert("Especifique el conocimiento que posee.");
					return false;
				}else{
					return true;
					}
			}else{
				return true;
			}
		}else{
			return false;
		}
	}
	
	// ------------------- Para SECCION 6 EXPERIENCIA-------------------------
	if(formulario =="experiencia"){
		
			if(experiencia.empresa.value=='' || experiencia.sector.value=='' || experiencia.actividadEmpresa.value=='' || experiencia.referencia.value=='' || experiencia.cargo.value=='' || experiencia.nombrejefe.value=='' || experiencia.telefonojefe.value=='' || experiencia.ingresomensual.value=='' ||	experiencia.motivosalida.value=='' || experiencia.fechaini.value=='' ||	experiencia.fechafin.value=='' ||	experiencia.principalesfunciones.value==''){
				$("#boton6G").attr("Value","Guardar");
				alert("Uno o mas campos está(n) vacío(s)");	
				return false;
			}else{
				return true;
			}
	}
	
	if(formulario =="informacionControl"){
		
		if(informacionControl.nombre.value=='' || informacionControl.emp.value==''){
			
			alert("Uno o mas campos está(n) vacío(s)");				
			return false;
		}else{
			return true;
		}
}
	// ------------------- Para SECCION 7 ------------------------- 
	// ------------------- Para SECCION 8 ------------------------- 
}


