// Scripts generales para RRHH


// Variables y funcion de entorno para el empleo de AJAX
var peticion = false; 
var  testPasado = false; 
try 
{ 
  peticion = new XMLHttpRequest(); 
} 
catch (trymicrosoft) 
{ 
  try 
  { 
    peticion = new ActiveXObject("Msxml2.XMLHTTP"); 
  } 
  catch (othermicrosoft) 
  { 
    try 
    { 
       peticion = new ActiveXObject("Microsoft.XMLHTTP"); 
    } 
    catch (failed) 
    { 
      peticion = false; 
    } 
  } 
} 

if (!peticion) 
{
   alert("ERROR AL INICIALIZAR!"); 
}

//***********************************************************************

// funcion que fuerza la obligatoriedad de introducir el email y clave para entrar.
function validarLogin() {
    // Elementos que conforman el sistema de login
    
    var forma = document.getElementById("forma-login");
    var email = document.getElementById("txtemail");
    var clave = document.getElementById("txtclave");
    
    // Evaluando el valor de cada elemento
    
    if(!isEmailAddress(email.value)) {
    	alert("Por favor introduzca una dirección de e-mail válida.");
      return;
    }   
   
    if(clave.value.replace(/ /g, '')=='') {
   	  alert("Por favor introduzca su clave de acceso.");
      return;
    }
    
    forma.action="validLogin.php"
    //se envia el formulario
    forma.submit();

}

// funcion que determina que una email tenga caracteres validos
// Tomada de un foro en internet
function isEmailAddress(theElement) {

	var s = theElement;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (s.length == 0 ) return false;
	if (filter.test(s)) {
   	return true;
	}
}

// Funcion que muestra un combo si el pais seleccionado es Ven, o una caja de texto si no lo es
// Se vale de las conexiones asincronicas de AJAX para lograr el efecto
function setCiudad(element_,element2,element3) {
	  // element_ = valor del id de la etiqueta DIV
	  // element2 = valor del id del combo paises 
	  // element3 = valor id que deberï¿½ tomar el combo estados
	   
	  // Tomando el valor seleccionado en el combo paises
	  var pais = document.getElementById(element2).value;
	  // elemento donde se pocisionara el resultado
	  var acciona = document.getElementById(element_);
	  
	  var url_parse="lugarnacimiento.php?value="+pais+"&ciudad="+element3;
	  peticion.open("GET", url_parse); 
	  peticion.onreadystatechange = function() 
    { 
        if (peticion.readyState == 4) 
        { 
             //escribimos la respuesta 
             acciona.innerHTML = peticion.responseText; 
        } 
     } 
     peticion.send(null);
}

// funcion que muestra una caja de texto, si el colegio o instituto no esta en el combo
function setInstituto(_element2,num) {
	// _element = id de la etiqueta DIV
	// _element2 = Id del combobox
	
	var cole =  document.getElementById(_element2).value;
	
	if(cole=='Otro') {
		mostrarOcultarElemento(num,true);
	} 
	else {
		mostrarOcultarElemento(num,false);;
	}
	
	
}

// Muestra u oculta un elemente identificado por el ID
function mostrarOcultarId(Id_elelement,ver) {
	// Id_elelement = Id del elemento a ocultar o mostrar
	if(ver==false) {
		dis='none';
	} else dis='block';
		
	var div = document.getElementById(Id_elelement).style;
	div.display=dis;
}

function mostrarTR(num,ver,tablen) {
	if(ver==false) {
		dis='none';
	} else {
		if(navigator.appName.indexOf("Explorer") != -1) {
			dis='block'
		} else {
			dis='table-row'
		}
	}
	//dis= ver ? '' : 'none';
  tab=document.getElementById(tablen);
  tab.getElementsByTagName('tr')[num].style.display=dis;
}

// Muestra u oculta un elemento. En este caso las filas de una tabla
function mostrarOcultarElemento(num,ver) {
	
	if(ver==false) {
		dis='none';
	} else {
		if(navigator.appName.indexOf("Explorer") != -1) {
			dis='block'
		} else {
			dis='table-row'
		}
	}
	//dis= ver ? '' : 'none';
  tab=document.getElementById('tabla');
  tab.getElementsByTagName('tr')[num].style.display=dis;
}

function mostrarEsconder(iddiv) {
	// iddiv es el elmento a esconder o mostrar

	var div = document.getElementById(iddiv).style;

	
	if(div.display=='block') {
		dis = 'none';
	} else {
		dis = 'block';
	}	
	div.display=dis;

}

// funcion que determina si una aï¿½o es bisiesto
function esBisiesto(ano) {
	// Un año es bisiesto si cumple las reglas a saber:
	// es divisible exacto entre 4, pero no divisible entre 100 y bien
	// divisible entre 400
	// SI (  (año divisible por 4) Y ((año no divisible por 100) O (año divisible por 400))  ) 
	if ((ano % 4 == 0) && ((ano % 100 != 0) || (ano % 400 == 0))) {
		return true;
	} else {
		return false;
	}
}

// Funcion para llenado del combo dias
function llenarComboDias(element_, element_2, element_3){
	// element_ = nombre del combo que se llenará
	// element_2 = nombre del combo mes
	// element_3 = nombre del combo año
	// combo dias
	var cb = document.getElementById(element_);
	// mes seleccionado
	var cbm = document.getElementById(element_2).value;
	// año seleccionado
	var cba = document.getElementById(element_3).value;
	
	// Un item del combo año debe haber sido seleccionado
	if (cba == '') {
		alert("El año no ha sido seleccionado, por favor selecciona el año.");
		return;
	}
	
	// necesario es vaciar el contenido que pueda tener el combo dias
	cb.options.length = 0;
	
	// determinamos cuantos dias corresponde al mes seleccionado.
	var total = 0;
	if (cbm == '') {
		total = 0;
	}
	else {
		if ((cbm == 3 || cbm == 5 || cbm == 6 || cbm == 10)) {
			total = 30; // Meses abril, junio, septiembre, noviembre
		}
		else {
			if (cbm == 1) { // Mes febrero. Ojo tomando en cuenta se arranca en 0 el primer mes
				if (esBisiesto(cba)) {
					total = 29;
				}
				else {
					total = 28;
					
				}
			}
			else {
				total = 31; // el resto de los meses
			}
		}
	}
	// ahora el combo dias debe ser cargado
	for (i = 1; i <= total; i++) {
		cb.options[i] = new Option(i, i);
	}
	
}

// Funcion para llenado del combo dias
function llenarComboDias2(element_,element_2,element_3,diaactual_) {
	// element_ = nombre del combo que se llenará
	// element_2 = nombre del combo mes
	// element_3 = nombre del combo año
	// combo dias
	var cb = document.getElementById(element_);
	// mes seleccionado
	var cbm = document.getElementById(element_2);
	// año seleccionado
	var cba = document.getElementById(element_3);
	
	// Un item del combo año debe haber sido seleccionado
	if(cba.value=='') { 
		 alert("Por favor indique el año");
		 cbm.selectedIndex=0;
		 cba.focus();
		 return;
  }
  
	// necesario es vaciar el contenido que pueda tener el combo dias
	cb.options.length=0;
	
	// determinamos cuantos dias corresponde al mes seleccionado.
	var total = 0;
	if(cbm.value=='') {
		total = 0;
  } else {
  	  if((cbm.value==3 || cbm.value==5 || cbm.value==8 || cbm.value==10)) {
  	     total = 30; // Meses abril, junio, septiembre, noviembre
  	  } 
  	  else {
  	  	if(cbm.value==1) { // Mes febrero. Ojo tomando en cuenta se arranca en 0 el primer mes
  	  		if(esBisiesto(cba.value)) {
  	  			total = 29;
  	  		} else {
  	  			total = 28;
  	  			
  	  		}
  	  	} else { 
  	  		total = 31; // el resto de los meses
  	  	}
  	  }
  }
	// ahora el combo dias debe ser cargado
	
	// ahora el combo dias debe ser cargado
	for (i=1; i<=total; i++){
      cb.options[i]= new Option(i,i);
      if(diaactual_!='') {
        if(cb.options[i].value==parseInt(document.getElementById(diaactual_).value)) {
        	cb.options[i].selected=true;
        }
      }
  }

}

// funcion para validar los datos del aspirante
function validarDatosAspirante(accion) {
	// accion = valor que determina si la funciona es activada por el boton
	// "Guardar y continuar" o por el boton "Guardar"

	// tomamos el valor de cada elemento del formulario
	var forma = document.getElementById('forma-login');
	// Obligatorios
	var nombre1 = document.getElementById('txtnombre1');
	var ape = document.getElementById('txtape');
	var ci = document.getElementById('txtci');
	var sexo = document.getElementById('sexo');
	var civil = document.getElementById('civil');
	var years = document.getElementById('years');
	var meses = document.getElementById('meses');
	var dias = document.getElementById('dias');
	var paisnac = document.getElementById('paisnac');
	var ciudadnac = document.getElementById('ciudadnac');
	var paisvive = document.getElementById('paisvive');
	var ciudadvive = document.getElementById('ciudadvive');
	var urbanizacion = document.getElementById('txturb');
	var avenida = document.getElementById('txtav');
	var casa = document.getElementById('txtcasa');
	var nrocasa = document.getElementById('txtcasanro');
	
	var tel1 = document.getElementById('txttel1');
	var tel2 = document.getElementById('txttel2');
	var tel3 = document.getElementById('txttel3');
	var hijos = document.getElementById('txthijos');
	var vehi = document.getElementById('vehi');
	var viaje = document.getElementById('viaje');
	var foto = document.getElementById('fotoActual');
	var fotoin = document.getElementById('txtfoto');
	var email = document.getElementById('txtmail');
	var clave = document.getElementById('txtclave');
	var reclave = document.getElementById('txtreclave');
	var codecaptcha = document.getElementById('code');
	var captcha = document.getElementById('imageText');
	
	// Proceso de evaluaciñn
	if(nombre1.value.replace(/ /g, '')=='') {
		alert("Por favor indique su primer nombre");
		nombre1.focus();
		return;
	}
	
	if(ape.value.replace(/ /g, '')=='') {
		alert("Debe colocar su primer apellido");
		ape.focus();
		return;
	}
	
	if(ci.value.replace(/ /g, '')=='') {
		alert("Debe colocar su número de cñdula de identidad o su rif");
		ci.focus();
		return;
	}
	
	if(!siRadioMarcado(forma.sexo)) {
		 alert("Por favor indique su genero o sexo");
	   return;
	}
	
	if(!siRadioMarcado(forma.civil)) {
		 alert("Por favor indique su estado civil");
	   return;
	}
	
	if(years.value.replace(/ /g, '')=='' || meses.value.replace(/ /g, '')=='' || dias.value.replace(/ /g, '')=='') {
		alert("Debes indicar todos los datos de tu fecha de nacimiento: Año, Mes, Dia");
		return;
	}
	
	if(paisnac.value.replace(/ /g, '')=='') {
		alert("Por favor indique su pañs de nacimiento");
		paisnac.focus();
		return;
	}
	
	if(ciudadnac.value.replace(/ /g, '')=='') {
		alert("Por favor indique su ciudad de nacimiento");
		ciudadnac.focus();
		return;
	}
	
	if(paisvive.value.replace(/ /g, '')=='') {
		alert("Por favor indique su país donde vive");
		paisvive.focus();
		return;
	}
	
	if(ciudadvive.value.replace(/ /g, '')=='') {
		alert("Por favor indique la ciudad donde vive");
		ciudadvive.focus();
		return;
	}
	
	if(urbanizacion.value.replace(/ /g, '')=='') {
		alert("Por favor indique el nombre de la urbanización donde vive");
		urbanizacion.focus();
		return;
	}
	
	if(avenida.value.replace(/ /g, '')=='') {
		alert("Por favor indique el nombre de la avenida/calle donde vive");
		avenida.focus();
		return;
	}
	
	if(casa.value.replace(/ /g, '')=='') {
		alert("Por favor indique el nombre de la casa/edificio donde vive");
		casa.focus();
		return;
	}
	
	if(nrocasa.value.replace(/ /g, '')=='') {
		alert("Por favor indique el número de la casa/edificio donde vive");
		nrocasa.focus();
		return;
	}
	
	if(tel1.value.replace(/ /g, '')=='' && tel2.value.replace(/ /g, '')=='' && tel3.value.replace(/ /g, '')=='') {
		alert("Debe indicar al menos un número telefónico");
		return;
	}
	
	/*
	if(hijos.value.replace(/ /g, '')!='') {
		if(isNaN(hijos.value)) {
			alert("Debe colocar un valor nñmerico para indicar el Nro. de hijos");
		  return;
		}
  }
  */
  
  if(!siRadioMarcado(forma.vehi)) {
		 alert("Por favor indique si posees vehiculo");
	   return;
	}
	
	if(!siRadioMarcado(forma.viaje)) {
		 alert("Por favor indique su disponibilidad para viajar");
	   return;
	}
  /**
  if(foto.value.replace(/ /g, '')=='') {
		alert("Debes enviar una fotografña reciente");
		return;
	}
	*/
	if(!isEmailAddress(email.value)) {
    	alert("Por favor introduzca una dirección de e-mail válida.");
      return;
  } 
  
  if(clave.value.replace(/ /g, '')=='') {
		alert("Debes introducir una clave");
		return;
	}  else {
		if(reclave.value != clave.value) {
			alert("La clave no ha sido bien validada, debes repetirla con exactitud");
		  return;
		}
	}
	
	
	// sugiere enviar una foto

	if(foto.value.replace(/ /g, '')=='' && fotoin.value.replace(/ /g, '')=='') {
		var textconfirm = "Si desea proyectar mejor su curriculum, le sugerimos adjuntar un fotografía reciente.\n\n";
		textconfirm+="Para adjuntar su foto haga click en 'Acpetar', si desea continuar haga click en 'Cancelar'"; 
		if(!confirm(textconfirm)) {

	  		               forma.action = "datosAspirante.php?option=" + accion
                                    forma.submit();

		  	
		} else {
			document.getElementById('txtfoto').focus();
		}
	} else {
		 
  		  forma.action="datosAspirante.php?option="+accion
	         forma.submit();
			
	}
		
}

function datosHabilidad(accion) {
	var forma = document.getElementById('f-infohabilidad');
	forma.action="datosHabilidad.php?option="+accion
	forma.submit();
}

function datosAcademicos(boton) {
	// boton = determina si el boton que envia es Guardar y continuar o Guardar
	
	var forma = document.getElementById('f-infoacademica');
	var nivelactual = document.getElementById('nivelactual');
	var institutos = document.getElementById('institutos');
	var colegio = document.getElementById('colegio');
	var tituloobtenido = document.getElementById('tituloobtenido');
	var obtenido = document.getElementById('obtenido');
	var coleyears = document.getElementById('coleyears');
	var mesescole = document.getElementById('mesescole');
	var cursa = document.getElementById('cursa');
	var institutosac = document.getElementById('institutosac');
	var colegioactual = document.getElementById('colegioactual');
	var tituloobtener = document.getElementById('tituloobtener');
	var obtener = document.getElementById('obtener');
	var nivel1 = document.getElementById('nivel1');
	var nivel2 = document.getElementById('nivel2');
	var horarioactual = document.getElementById('horarioactual');
	
	if(nivelactual.value=='Seleccione') {
		alert("Por favor indique el nivel educativo que posee");
		return;
	}
	
	var inst="";
	if(institutos.value=='' || institutos.value=='Otro') {
		
		if(colegio.value.replace(/ /g, '')=='') {
			alert("Por favor indique el nombre del instituto donde estudió");
			return;
		} else {
			inst=colegio.value;
		}
	} else {
		inst=institutos.value;
		
	}
		
	var tituloObt="";
	if(tituloobtenido.value=='' || tituloobtenido.value=='Otro') {
		if(obtenido.value.replace(/ /g, '')=='') {
		   alert("Por favor indique el titulo obtenido");
		   return;
		} else {
			if(coleyears.value=='' || mesescole.value=='') {
				 alert("Por favor indique la fecha de egreso"); 
			   return;
			} else {
			   tituloObt=obtenido.value;
			}
		}
	} else {
		if(coleyears.value=='' || mesescole.value=='') {
			alert("Por favor indique la fecha de egreso"); 
			return;
		} else { 
		  tituloObt=tituloobtenido.value;
		}  
	}
	
	if(cursa.checked) {
		
		var instAct="";
		if(institutosac.value=='' || institutosac.value=='Otro') {
			if(colegioactual.value.replace(/ /g, '')=='') {
			   alert("Por favor indique el nombre del instituto donde cursa estudios actualmente");
			   return;
			} else {
			   instAct=colegioactual.value;
			}
		} else {
			instAct=institutosac.value;
		}

		var titObtener="";
		if(tituloobtener.value=='' || tituloobtener.value=='Otro') {
			if(obtenido.value.replace(/ /g, '')=='') {
				alert("Por favor indique titulo a obtener al finalizar sus estudios");
				return;
			} else {
				titObtener=obtenido.value;
			}
		} else {
			titObtener=tituloobtener.value;
		}
		
		if(nivel1.value=='' || nivel2.value=='') {
			alert("Por favor indique el nivel, año o semestre que cursa actualmente");
			return;
		}
		
		if(horarioactual.value.replace(/ /g, '')=='') {
			alert("Por favor indique los días y horario de estudio actual");
			return;
		}
		
	}
	
	forma.action="datosAcademicos.php?option="+boton;
	forma.submit();
}

/**
function datosAcademicos(boton) {
	// boton = determina si el boton que envia es Guardar y continuar o Guardar
	var forma = document.getElementById('f-infoacademica');
	var cole = document.getElementById('colegio').value;
	var colecb = document.getElementById('colegiocb').value;
	var secu = document.getElementById('secundaria').value;
	var secucb = document.getElementById('secundariacb').value;
	var tecnica = document.getElementById('tecnico').value;
	var tecnicacb = document.getElementById('tecnicocb').value;
	var tsu = document.getElementById('tsu').value;
	var tsucb = document.getElementById('tsucb').value;
	var uni = document.getElementById('uni').value;
	var unicb = document.getElementById('unicb').value;
	var post = document.getElementById('grado').value;
	var postcb = document.getElementById('gradocb').value;
	var diacole = document.getElementById('diascole').value;
	var diasecu = document.getElementById('diassecu').value;
	var diatec = document.getElementById('diastec').value;
	var diatsu = document.getElementById('diastsu').value;
	var diauni = document.getElementById('diasuni').value;
	var diapost = document.getElementById('diaspost').value;
	var actual = document.getElementById('actual').value;
	var actualcb = document.getElementById('actualcb').value;
	var titulobt = document.getElementById('tituloactual').value;
	var nivelobt = document.getElementById('nivelactual').value;
	var horario = document.getElementById('horarioactual').value;
	
	if(cole!='' || colecb!='') {
		if(diacole=='') {
			alert("Por favor escoge el año de egreso para Primaria");
			return;
		}
	}
	
	if(secu!='' || secucb!='') {
		if(diasecu=='') {
			alert("Por favor escoge el año de egreso para Secundaria");
			return;
		}
	}
	
	if(tecnica!='' || tecnicacb!='') {
		if(diatec=='') {
			alert("Por favor escoge el año de egreso para Nivel Tñcnico");
			return;
		}
	}
	
	if(tsu!='' || tsucb!='') {
		if(diatsu=='') {
			alert("Por favor escoge el año de egreso para Nivel TSU");
			return;
		}
	}
	
	if(uni!='' || unicb!='') {
		if(diauni=='') {
			alert("Por favor escoge el año de egreso para Nivel Universitario");
			return;
		}
	}
	
	if(post!='' || postcb!='') {
		if(diapost=='') {
			alert("Por favor escoge el año de egreso para Nivel Post Grado");
			return;
		}
	}
 
	if(actual!='' || actualcb!='') {
		if(titulobt=='') {
			alert("Por favor, escriba el titulo a obtener en sus estudias actuales");
			return;
		}
		
		if(nivelobt=='') {
			alert("Por favor, elija el nivel académico de sus estudios actuales");
			return;
		}
		if(horario=='') {
			alert("Por favor, escriba el horario de sus estudios actuales");
			return;
		}
		
	}
	
	forma.action="datosAcademicos.php?option="+boton;
	forma.submit();
	
}
*/

function getRadioButtonSelectedValue(ctrl)
{
    for(i=0;i<ctrl.length;i++)
        if(ctrl[i].checked) return ctrl[i].value;
}

function validDatosExpLaboral(boton) {
	var forma = document.getElementById('infolaboral');
	
	// si no ha trabajado anteriormente
	
	var ant = document.getElementById('trabajoant');
	

	if(getRadioButtonSelectedValue(document.infolaboral.trabajoant)=="" || getRadioButtonSelectedValue(document.infolaboral.trabajoant)=="No") { 
		window.location.href="http://rrhh.venezolano.com/procesor.aspirantes.php?accion=4";
    exit; 
	}
	
	// Los datos de la empresa 1
	
	var emp1 = document.getElementById('empresa1').value;
	var ciudademp1 = document.getElementById('ciudadempresa1').value;
	var diremp1 = document.getElementById('dirempresa1').value;
	var contratoemp1 = document.getElementById('telempresa1').value;
	var cargoemp1 = document.getElementById('cargoempresa1').value;
	var anoingresoemp1 = document.getElementById('anoingresoemp1').value;
	var mesingresoemp1 = document.getElementById('mesingresoemp1').value;
	var diaingresoemp1 = document.getElementById('diaingresoemp1').value;
	var anoegresoemp1 = document.getElementById('anoegresoemp1').value;
	var mesegresoemp1 = document.getElementById('mesegresoemp1').value;
	var diaegresoemp1 = document.getElementById('diaegresoemp1').value;
	var funcionesemp1 = document.getElementById('funcionesempresa1').value;
	var sueldoemp1 = document.getElementById('sueldoempresa1').value;
	var motivoemp1 = document.getElementById('motivoempresa1').value;
	
	// Los datos de la empresa 2
	var emp2 = document.getElementById('empresa2').value;
	var ciudademp2 = document.getElementById('ciudadempresa2').value;
	var diremp2 = document.getElementById('dirempresa2').value;
	var contratoemp2 = document.getElementById('telempresa2').value;
	var cargoemp2 = document.getElementById('cargoempresa2').value;
	var anoingresoemp2 = document.getElementById('anoingresoemp2').value;
	var mesingresoemp2 = document.getElementById('mesingresoemp2').value;
	var diaingresoemp2 = document.getElementById('diaingresoemp2').value;
	var anoegresoemp2 = document.getElementById('anoegresoemp2').value;
	var mesegresoemp2 = document.getElementById('mesegresoemp2').value;
	var diaegresoemp2 = document.getElementById('diaegresoemp2').value;
	var funcionesemp2 = document.getElementById('funcionesempresa2').value;
	var sueldoemp2 = document.getElementById('sueldoempresa2').value;
	var motivoemp2 = document.getElementById('motivoempresa2').value;
	
	// Los datos de la empresa 3
	var emp3 = document.getElementById('empresa3').value;
	var ciudademp3 = document.getElementById('ciudadempresa3').value;
	var diremp3 = document.getElementById('dirempresa3').value;
	var contratoemp3 = document.getElementById('telempresa3').value;
	var cargoemp3 = document.getElementById('cargoempresa3').value;
	var anoingresoemp3 = document.getElementById('anoingresoemp3').value;
	var mesingresoemp3 = document.getElementById('mesingresoemp3').value;
	var diaingresoemp3 = document.getElementById('diaingresoemp3').value;
	var anoegresoemp3 = document.getElementById('anoegresoemp3').value;
	var mesegresoemp3 = document.getElementById('mesegresoemp3').value;
	var diaegresoemp3 = document.getElementById('diaegresoemp3').value;
	var funcionesemp3 = document.getElementById('funcionesempresa3').value;
	var sueldoemp3 = document.getElementById('sueldoempresa3').value;
	var motivoemp3 = document.getElementById('motivoempresa3').value;

	if(emp1.replace(/ /g, '')!='') {
		if(ciudademp1.replace(/ /g, '')=='') {
			alert("Por favor escriba el nombre de la ciudad de ubicación para la empresa 1");
			return;
		}
		if(diremp1.replace(/ /g, '')=='') {
			alert("Por favor escriba la dirección para la empresa 1");
			return;
		}
		if(contratoemp1.replace(/ /g, '')=='') {
			alert("Por favor indique el tipo de contrato para la empresa 1");
			return;
		}
		if(cargoemp1.replace(/ /g, '')=='') {
			alert("Por favor escriba el cargo que ocupó para la empresa 1");
			return;
		}
		
		if(anoingresoemp1.replace(/ /g, '')=='') {
			alert("Por favor indique el año de ingreso para la empresa 1");
			return;
		}
		if(mesingresoemp1.replace(/ /g, '')=='') {
			alert("Por indique el mes de ingreso para la empresa 1");
			return;
		}
		if(diaingresoemp1.replace(/ /g, '')=='') {
			alert("Por indique el día de ingreso para la empresa 1");
			return;
		}
              if(funcionesemp1.replace(/ /g, '')=='') {
                  alert("Por indique las funciones que realizaba en la empresa 1");
 		    return;
              }
		
		if (getRadioButtonSelectedValue(document.infolaboral.actual1) == "" || getRadioButtonSelectedValue(document.infolaboral.actual1) == "No") {
			if (anoegresoemp1 != '') {
				if (mesegresoemp1.replace(/ /g, '') == '') {
					alert("Por indique el mes de egreso para la empresa 1");
					return;
				}
				else {
					if (diaegresoemp1.replace(/ /g, '') == '') {
						alert("Por indique el día de egreso para la empresa 1");
						return;
					}
				}
			} else {
				alert("Por favor indique el año de egreso para la empresa 1");
				return;
			}
		}
		
	} else {
			alert("Por favor indique el nombre de la empresa");
			return;
	}
	
	if(emp2.replace(/ /g, '')!='') {
		if(ciudademp2.replace(/ /g, '')=='') {
			alert("Por favor escriba el nombre de la ciudad de ubicación para empresa 2");
			return;
		}
		
		if(diremp2.replace(/ /g, '')=='') {
			alert("Por favor escriba la dirección para empresa 2");
			return;
		}
		
		if(contratoemp2.replace(/ /g, '')=='') {
			alert("Por favor indique el tipo de contrato para empresa 2");
			return;
		}
		
		if(cargoemp2.replace(/ /g, '')=='') {
			alert("Por favor escriba el cargo que ocupó para empresa 2");
			return;
		}
		
		
		if(anoingresoemp2.replace(/ /g, '')=='') {
			alert("Por favor indique el año de ingreso para empresa 2");
			return;
		}
		if(mesingresoemp2.replace(/ /g, '')=='') {
			alert("Por indique el mes de ingreso para empresa 2");
			return;
		}
		if(diaingresoemp2.replace(/ /g, '')=='') {
			alert("Por indique el día de ingreso para empresa 2");
			return;
		}
		
              if(funcionesemp2.replace(/ /g, '')=='') {
                  alert("Por indique las funciones que realizaba en la empresa 2");
 		    return;
              }


		if (getRadioButtonSelectedValue(document.infolaboral.actual2) == "" || getRadioButtonSelectedValue(document.infolaboral.actual2) == "No") {
			if (anoegresoemp2 != '') {
				if (mesegresoemp2.replace(/ /g, '') == '') {
					alert("Por indique el mes de egreso para la empresa 2");
					return;
				}
				else {
					if (diaegresoemp2.replace(/ /g, '') == '') {
						alert("Por indique el día de egreso para la empresa 2");
						return;
					}
				}
			} else {
				alert("Por favor indique el año de egreso para la empresa 2");
				return;
			}
		}
		
		
		/**
		if(funcionesemp2.replace(/ /g, '')=='') {
			alert("Por favor indique sus funciones en la empresa 2");
			return;
		}
		if(motivoemp2.replace(/ /g, '')=='') {
			alert("Por indique el motivo de retiro de la empresa 2");
			return;
		}
		if(isNaN(sueldoemp2) || sueldoemp2.replace(/ /g, '')=='') {
			alert("Por indique el ñltimo sueldo devengado (sñlo nñmeros) en la empresa 2");
			return;
		}
		*/
	}
	
	if(emp3.replace(/ /g, '')!='') {
		if(ciudademp3.replace(/ /g, '')=='') {
			alert("Por favor escriba el nombre de la ciudad de ubiciación para empresa 3");
			return;
		}
		
		if(diremp3.replace(/ /g, '')=='') {
			alert("Por favor escriba la dirección para empresa 2");
			return;
		}
		
		if(contratoemp3.replace(/ /g, '')=='') {
			alert("Por favor indique el tipo de contrato para empresa 3");
			return;
		}
		if(cargoemp3.replace(/ /g, '')=='') {
			alert("Por favor escriba el cargo que ocupó para empresa 3");
			return;
		}
		
		if(anoingresoemp3.replace(/ /g, '')=='') {
			alert("Por favor indique el año de ingreso para empresa 3");
			return;
		}
		
		if(mesingresoemp3.replace(/ /g, '')=='') {
			alert("Por indique el mes de ingreso para empresa 3");
			return;
		}
		
		if(diaingresoemp3.replace(/ /g, '')=='') {
			alert("Por indique el día de ingreso para empresa 3");
			return;
		}
		
		if(diaingresoemp3.replace(/ /g, '')=='') {
			alert("Por indique el día de ingreso para empresa 3");
			return;
		}

              if(funcionesemp3.replace(/ /g, '')=='') {
                  alert("Por indique las funciones que realizaba en la empresa 3");
 		    return;
              }

		if (getRadioButtonSelectedValue(document.infolaboral.actual3) == "" || getRadioButtonSelectedValue(document.infolaboral.actual3) == "No") {
			if (anoegresoemp3 != '') {
				if (mesegresoemp3.replace(/ /g, '') == '') {
					alert("Por indique el mes de egreso para la empresa 3");
					return;
				}
				else {
					if (diaegresoemp3.replace(/ /g, '') == '') {
						alert("Por indique el día de egreso para la empresa 3");
						return;
					}
				}
			} else {
				alert("Por favor indique el año de egreso para la empresa 3");
				return;
			}
		}
		
		/**
		if(funcionesemp3.replace(/ /g, '')=='') {
			alert("Por favor indique sus funciones en la empresa 3");
			return;
		}
		if(motivoemp3.replace(/ /g, '')=='') {
			alert("Por indique el motivo de retiro de la empresa 3");
			return;
		}
		
		if(isNaN(sueldoemp3) || sueldoemp3.replace(/ /g, '')=='') {
			alert("Por indique el ñltimo sueldo devengado (sñlo nñmeros) en la empresa 3");
			return;
		}
		*/
	}
	
	
	forma.action="datosExpLaboral.php?option="+boton;
	forma.submit();
	
}

// funcion que determina si algun item de radio ha sido seleccionado
function siRadioMarcado(ctrl) {
    for(i=0;i<ctrl.length;i++)
        if(ctrl[i].checked) return true;
}

// devuelve el valor seleccionado de un radio boton
function siRadioSeleccionado(ctrl) {
	  var valuereruturned="";
    for(i=0;i<ctrl.length;i++) {
        if(ctrl[i].checked) valuereruturned = ctrl[i].value;
    }
    return valuereruturned;
}

//funcion que valida los datos interface Otros
function validarDatosOtros() {
	var forma = document.getElementById('f-otros'); 
	var solicitud = document.getElementById('solicitudant');
	var mesant = document.getElementById('mesant');
	var anoant = document.getElementById('anoant');
	var trabajoant = document.getElementById('trabajoant');
	var anotrabajo = document.getElementById('anotrabajo');
	var mesestrabajo = document.getElementById('mesestrabajo');
	var inmediata = document.getElementById('inmediata');
	var disponible = document.getElementById('disponible');
	
	if(solicitud.checked) {
			if(mesant.value=='') {
				alert("Por favor indíque el mes de su solicitud anterior");
				mesant.focus();
				return;
			}
			if(anoant.value=='') {
				alert("Por favor indíque el año de su solicitud anterior");
				anoant.focus();
				return;
			}		
	}
	
	if(trabajoant.checked) {
			if(mesestrabajo.value=='') {
				alert("Por favor indíque el mes de ingreso anterior en el Banco");
				mesant.focus();
				return;
			}
			if(anotrabajo.value=='') {
				alert("Por favor indíque el año de ingreso anterior en el Banco");
				anoant.focus();
				return;
			}		
	}
  
	if(!inmediata.checked) {
		if(disponible.value.replace(/ /g, '')=='') {
			alert("Por favor indíque su disponibilidad");
			disponible.focus();
			return;
		} else {
			//validar el formato de fecha
			if(!fechas(disponible.value)) {
			   alert("fomato de fecha para disponibilidad no vñlido");
			   disponible.focus();
			   return;
			}
		}
	}
	forma.action="datosOtros.php";
	forma.submit();
}

//Excelente funcion para validar fechas
//Autor: LIBARDO DñAZ FLñREZ Bucaramanga(Colombia)
// ligeramente modificada por mi
function fechas(caja)
{ 
	
	 borrar=true;
   if (caja) {  
      //borrar = caja;
      if((caja.substr(2,1) == "/") && (caja.substr(5,1) == "/")) {
      	for (i=0; i<10; i++) {
      		  if(i != 2 && i != 5) { 
      		  	if(parseInt(caja.substr(i,1))<0 || parseInt(caja.substr(i,1))>9) {
      		  		borrar = false;
                break;
      		  	}
      		  }
      	} // Fin FOR

      	if (borrar) {
      		 a = caja.substr(6,4);
		   		 m = caja.substr(3,2);
		   		 d = caja.substr(0,2);
		   		 if((a < 1900) || (a > 2050) || (m < 1) || (m > 12) || (d < 1) || (d > 31)) {
		   		 	 borrar = false;
					 } else {
					 	 if((a%4 != 0) && (m == 2) && (d > 28)) {
					 	 	  borrar = false; // el año es biciesto
					 	 } else { 
					 	 	 if ((((m == 4) || (m == 6) || (m == 9) || (m==11)) && (d>30)) || ((m==2) && (d>29))) {
					 	 	 	   borrar = false;	
					 	   }
					 	}
					 }

      	} // fin if (borrar)
      
      } // caja.substr(2,1) == "/") && (caja.substr(5,1) == "/"
      else {
      	borrar = false;
      }
   } // if (caja)   
   else {
   	borrar = false;
  }
  
  if(!borrar) {
      	return false;
  } else {
  	return true;
  }
  
} // FUNCION

// esta funcion posibilita la eliminacion de los registros
// de las postulaciones seleccionadas por el usuario
function eliminarPostulacionesSeleccionadas(idaspirante) {
	
	  var acciona = document.getElementById('resultados'); 
	
	  // Toma el elemento form
	  var forma = document.getElementById('forma');
	  
	  // rutina que determina el nro de checkboxes presentes.
	  var ck=""; // va almacenando los valores id de cada elemento marcado, los separa con coma(,)
	  var checkmark = 0; // esto es un contador para determinar el nro de check marcados
	  for(x=0;x<forma.length;x++) {
	  	if(forma[x].type=='checkbox') {
	  	   var docname = document.getElementById(forma[x].id);
	  	   if(docname.checked) {
	  	   	  checkmark++;
	  	   	  // La trampa esta en que el id de los checkboxes el Id de la base de datos
	  	   	  // si es el primer box marcado
	  	   	  if(checkmark==1) {
	  	   	      ck=docname.name;
	  	   	  }
            else {
	  		      ck+=","+docname.name;
	  		    }
	  	   } // fin si esta marcado
	  	} // FIN si es un checkbox
	  } // FIN FOR
	  
	  if(checkmark==0) {
	  	alert("No ha opciones seleccionadas para eliminar");
	  	return;
	  }
	  
	  var url_parse="eliminarPostulacionesSeleccionadas.php?variable="+ck+"&asp="+idaspirante;
	  acciona.innerHTML = '<img src="http://rrhh.venezolano.com/images/eliminando.gif" />'; 
	  peticion.open("GET", url_parse); 
	  peticion.onreadystatechange = function() 
    { 
        if (peticion.readyState == 4) 
        { 
             //escribimos la respuesta 
             acciona.innerHTML = peticion.responseText; 
        } 
     } 
     peticion.send(null);
}

// esta funcion posibilita la eliminacion de los registros
// de las postulaciones no vigentes para un usuario
function eliminarPostulacionesNoVigentes(idaspirante) {
	
	  var acciona = document.getElementById('resultados'); 
	
	  var url_parse="eliminarPostulacionesNoVigentes.php?asp="+idaspirante;
	  acciona.innerHTML = '<img src="http://rrhh.venezolano.com/images/eliminando.gif" />'; 
	  peticion.open("GET", url_parse); 
	  peticion.onreadystatechange = function() 
    { 
        if (peticion.readyState == 4) 
        { 
             //escribimos la respuesta 
             acciona.innerHTML = peticion.responseText; 
        } 
     } 
     peticion.send(null);
}


// funcion AJAX que ejecuta una funcion puesta en el archivo php indicado en surl 
function mostrarOpcionesMenuAsp(surl,div_element,pag) {
	// surl = pagina php llamada
	// div_element = etiqueta div que muestra los resultados
	// pag =  pagina a buscar.
	
	  // elemento donde se pocisionara el resultado
	  var acciona = document.getElementById(div_element);
	  
	  var url_parse=surl+"?pag="+pag;
	  acciona.innerHTML = '<img src="http://rrhh.venezolano.com/images/buscando.gif" />'; 
	  peticion.open("GET", url_parse); 
	  peticion.onreadystatechange = function() 
    { 
        if (peticion.readyState == 4) 
        { 
             //escribimos la respuesta 
             acciona.innerHTML = peticion.responseText; 
        } 
     } 
     peticion.send(null);
	
}


// Determina que interface mostrar
function interfaceAspirante(accion){
	
	var acciona = document.getElementById('resultados');
	var url_parse="procesor.aspirantes.php?accion="+accion;
	
	acciona.innerHTML = '<img src="http://rrhh.venezolano.com/images/buscando.gif" />'; 
	peticion.open("GET", url_parse); 
	peticion.onreadystatechange = function() 
  { 
        if (peticion.readyState == 4) 
        { 
             //escribimos la respuesta 
             acciona.innerHTML = peticion.responseText; 
        } 
  } 
  peticion.send(null);
	
}

// funcion que envia una postulacion a un cargo
function postularACargo(idoferta,idaspirante) {
	// idoferta = Id de la oferta
	// idaspirante = Id del aspirante
	
	// elemento donde se pocisionara el resultado
	  var acciona = document.getElementById('resultados');
	  
	  var url_parse="postularACargo.php?idC="+idoferta+"&idA="+idaspirante;
	  acciona.innerHTML = '<img src="http://rrhh.venezolano.com/images/enviadatos.gif">'; 
	  peticion.open("GET", url_parse); 
	  peticion.onreadystatechange = function() 
    { 
        if (peticion.readyState == 4) 
        { 
             //escribimos la respuesta 
             acciona.innerHTML = peticion.responseText; 
        } 
     } 
     peticion.send(null);
}


function formolvidoClave() {
	  var acciona = document.getElementById('resultados');
	  
	  var url_parse="form.olvido.php";
	  peticion.open("GET", url_parse); 
	  peticion.onreadystatechange = function() 
    { 
        if (peticion.readyState == 4) 
        { 
             //escribimos la respuesta 
             acciona.innerHTML = peticion.responseText; 
        } 
     } 
     peticion.send(null);
	
}

function olvidoClave() {
	
	  var mail=document.getElementById('email');
	
	  var acciona = document.getElementById('resultados');
	  
	  var url_parse="procesor.olvido.php?mail="+mail.value;
	  peticion.open("GET", url_parse); 
	  peticion.onreadystatechange = function() 
    { 
        if (peticion.readyState == 4) 
        { 
             //escribimos la respuesta 
             acciona.innerHTML = peticion.responseText; 
        } 
     } 
     peticion.send(null);
}

function openExternal(php) {
             if(php=="DemoVol") {
   		    var secure="http://www.venezolano.com/index_demo.php";
                  w = 790;
                  h = 480;
                  jump="demo";
             } else if(php=="Online") {
   		    var secure="https://vol.venezolano.com";
                  w = 790;
                  h = 480;
		    jump="vol";
             } else if(php=="TDC") {
   		    var secure="https://tdc.venezolano.com/";
		    w = 790;
                  h = 480;
                 jump="tdc";
             } else if(php=="VOB") {
                  var secure="http://www.venezolano.com/demoMain.html"; 
		    w = 675;
                  h = 460;
                  jump="vob";
             } else if(php=="DemoVTexto") {
		    var secure="http://www.venezolano.com/vtexto/vtexto_new.html";
                  w = 550;
                  h = 400;
                  jump="vtexto";
             } else if(php=="SecureVol") {
		    var secure="http://www.venezolano.com/popup/SeguridadOnline.html";
                  w = 550;
                  h = 450;    
                  jump="seguro";             
             } else if(php=="DownVOB") {
                  var secure="http://www.venezolano.com/downloadMain.html";
                  w = 320;
                  h = 210;
		    jump="DemoVob";
             } 
              myWindowHandle = PopUp(secure,"VOL", w, h, 1, 1, 1, 0, 0, 1);
}


// Funcion para abrir pop-ups
function PopUp(url, name, width, height, center, resize, scroll, posleft, postop, urllocation) {		
		if (posleft != 0) { 
			var x = posleft;
		}
		if (postop  != 0) { 
			var y = postop;
		}
	
		if (!scroll) { scroll = 0 }
		if (!resize) { resize = 0 }
		if (!urllocation) { urllocation = 0 }
			
		if ((parseInt (navigator.appVersion) >= 4 ) && (center)) {
		  var X = (screen.width  - width ) / 2;
		  var Y = (screen.height - height) / 2;
		}
	
		if (scroll != 0) { scroll = 1 }
	
		var extra = 'width=' + width + ', height=' + height + ', top=' + Y + ', left=' + X + ', resizable=' + resize + ', scrollbars=' + scroll + ', location=' + urllocation + ', directories=no, status=yes, menubar=no, toolbar=no';
		window.open( url, name, extra );
	 }
	  
	function openPopup(url, name, width, heigth) {
		windows=PopUp(url, name, width, heigth, 1, 0);
	}

	function openPopup2(url, name, width, heigth,scroll) {
		windows=PopUp(url, name, width, heigth, 1, 0, scroll);
	}

function openOnline() {
             
              //var secure="https://online.venezolano.com";
		var secure="https://vol.venezolano.com";
		//var secure="vol.php";
	
		var xMax = 790, yMax=480;
	
		var width = xMax-20;
		var height = yMax-20;
		var X = (xMax - width ) / 2, Y = (yMax - height) / 2;
	  	var extra = 'width='+width+',height='+height+', top='+Y+', left='+X+ ', resizable=no, scrollbars=yes, location=yes, directories=no, status=yes, menubar=no, toolbar=no';
	
		myWindowHandle = PopUp(secure,'VOL', 780, 580, 1, 1, 1, 0, 0, 1);
		//myWindowHandle = PopUp(secure, 'VOL', 700, 700, 1, 0, 1, 0, 0)
		
		
              
          
             //alert("Estimado cliente \n\n En este momento el sistema se encuentra en mantenimiento. Por favor intente más tarde.\n Gracias");
	}

function FindResults(php,page) {
	// php = file name that process the information
	// page = current page to show
	var acciona = document.getElementById('resultados');
	var	url_parse=php+"?pg="+page;
  acciona.innerHTML="<b>Buscando datos...</b>"
	peticion.open("GET", url_parse); 
	peticion.onreadystatechange = function() 
  { 
        if (peticion.readyState == 4) 
        { 
             //escribimos la respuesta 
             acciona.innerHTML = peticion.responseText; 
        } 
  } 
  peticion.send(null);
}	
// SCRIPT Para MENU

//Contents for menu 1
var menu1=new Array()
menu1[0]='<a class="texto-rrhh" href="procesor.aspirantes.php?accion=1">Informaci&oacute;n Personal</a>'
menu1[1]='<a class="texto-rrhh" href="procesor.aspirantes.php?accion=2">Datos Acad&eacute;micos</a>'
menu1[2]='<a class="texto-rrhh" href="procesor.aspirantes.php?accion=3">Experiencia Laboral</a>'
menu1[3]='<a class="texto-rrhh" href="procesor.aspirantes.php?accion=4">Habilidades y destrezas</a>'
menu1[4]='<a class="texto-rrhh" href="procesor.aspirantes.php?accion=5">Otros</a>'

		
var menuwidth='80px' //default menu width
var menubgcolor='#ffffff'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="z-index:100;visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"

}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu


// FIN SCRIPT Menu

