function objetoAjax(){
	var xmlhttp=false;
	try{
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e){
		try	{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(E){
			if (!xmlhttp && typeof XMLHttpRequest!='undefined') xmlhttp=new XMLHttpRequest();
		}
	}
	return xmlhttp; 
}

/**Aqui vienen las validaciones*/
function vNumero(e){
	tecla=(document.all)?e.keyCode : e.which;
	if(tecla==8) return true;
		patron = /\d/;
		te = String.fromCharCode(tecla);
	return patron.test(te);
}
function vLetra(e){
	tecla=(document.all)?e.keyCode : e.which;
	if(tecla==8) return true;
	    patron =/[A-Za-z-ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ ]/;
		te = String.fromCharCode(tecla);
	return patron.test(te);
}
function vCorreo(e){
	tecla=(document.all)?e.keyCode : e.which;
	if(tecla==8) return true;
	    patron =/[A-Za-z0-9@_.]/;
		te = String.fromCharCode(tecla);
	return patron.test(te);
}
function vUsuario(e){
	tecla=(document.all)?e.keyCode : e.which;
	if(tecla==8) return true;
	    patron =/[A-Za-z0-9_-]/;
		te = String.fromCharCode(tecla);
	return patron.test(te);
}
function vDireccion(e){
	tecla=(document.all)?e.keyCode : e.which;
	if(tecla==8) return true;
	    patron =/[A-Za-z0-9# ]/;
		te = String.fromCharCode(tecla);
	return patron.test(te);
}
function Correo(elemento,nombre){
	var s = nombre.value;
	var filtro = /^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-Za-z]$/;
	if(s.length==0){
		return true;
	}
	if(filtro.test(s)){
		return true;
	}
	else{
		alert("La direccion de cooreo no cumple espectativas");
		elemento.focus();
		return false;
	}
}
function eventoEs(valor){
  if(valor==true){
   alert("Su hoja de vida se adjuntara al final del proceso");
  }
  else{
   alert("No se adjuntara hoja de vida");
  }
}
function eventoEn(valor){
  if(valor==true){
   alert("The CV is attached at the end off the process");
  }
  else{
   alert("The CV is not attached");
  }
}
/* function error(campo, mensaje,validacion){
	var hoy = new Date;
	hoy = hoy.getFullYear();
	if(campo=="" ){
		var msj="El campo " + mensaje + " no puede ser enviado vacio.";
		alert(msj);
		return 1;
	}
	if(campo=="Elige"){
		var msj="El campo " + msj + " no puede ser enviado vacio.";
		alert(msj);
		return 1;
	}
	if(mensaje=="e-mail"){
//		if(Correo(campo,mensaje)==false){
			alert("Estructura de correo no valida");
		}//
	}
	if(validacion < (hoy-100) || validacion > hoy){
		alert("anio " + validacion + " es incoherente");
		return 1;
	}
	return 0;
} */
//matriz = new Array (); 
//matriz[0] = new Array ('e00', 'e01', 'e02'); 
//Funciones sobre curriculum
function validar(){
var mensaje = "";
var cont = new Array();
	cont = new Array('cedula','nombres','apellidos','tel casa','e-mail','direccion','secundaria instituto','Año secundaria','universidad instituto','Año universidad','titulo');
	cont2 = new Array(document.curriculum.cedula.value, document.curriculum.nombres.value, document.curriculum.apellidos.value, document.curriculum.telcasa.value, document.curriculum.correo.value, document.curriculum.direccion.value, document.curriculum.secundaria_inst.value, document.curriculum.secundaria_anio.value, document.curriculum.universidad_inst.value, document.curriculum.universidad_anio.value, document.curriculum.titulo.value);

  
for(var i=0;i<15;i++){
 if(cont2[i]==""){
  mensaje = mensaje + cont[i]+ ", ";
 }
}  
if(mensaje!=""){
  alert("Los siguientes campos no pueden ser vacios: " + mensaje);
	return false;
}
else{
	return true;
}
}
function enviarCurriculum(){
	var validacion = validar();
	divFormulario = document.getElementById('formulario');
	if(validacion==true){
		var fec = document.curriculum.anio.value + "/" + document.curriculum.mes.value + "/" + document.curriculum.dia.value;
		ced=document.curriculum.cedula.value;
		tip=document.curriculum.tipocedula.value;
		nom=document.curriculum.nombres.value;
		ape=document.curriculum.apellidos.value;
		tcas=document.curriculum.telcasa.value;
		tofi=document.curriculum.teloficina.value;
		tcel=document.curriculum.telcelular.value;
		corr=document.curriculum.correo.value;
		dire=document.curriculum.direccion.value;
		ciu=document.curriculum.ciudad.value;
		prof=document.curriculum.profesion.value;
		are1=document.curriculum.area1.value;			
		are2=document.curriculum.area2.value;
		are3=document.curriculum.area3.value;
		anio=document.curriculum.anios.value;
		idio=document.curriculum.idioma.value;
		porc=document.curriculum.porcentaje.value;
		sala=document.curriculum.salario.value;
		sec_i=document.curriculum.secundaria_inst.value;
		sec_a=document.curriculum.secundaria_anio.value;
		uni_i=document.curriculum.universidad_inst.value;
		uni_a=document.curriculum.universidad_anio.value;
		pos_i=document.curriculum.posgrado_inst.value;
		pos_a=document.curriculum.posgrado_anio.value;
		titul=document.curriculum.titulo.value;
    hoja=document.curriculum.hojavida.checked;
	
exper1="Empresa: " + document.curriculum.empresa1.value+"@@"+ "Fec Ingreso: " + document.curriculum.ingreso1.value+"@@"+ "Fec Retiro: "+document.curriculum.retiro1.value+"@@"+"Responsabilidades: "+document.curriculum.respons1.value+"@@@@";
exper2="Empresa: "+document.curriculum.empresa2.value+"@@"+ "Fec Ingreso: " + document.curriculum.ingreso2.value+"@@"+ "Fec Retiro: "+document.curriculum.retiro2.value+"@@"+"Responsabilidades: " + document.curriculum.respons2.value+"@@@@";
exper3="Empresa: " + document.curriculum.empresa3.value+"@@"+ "Fec Ingreso: "  + document.curriculum.ingreso3.value+"@@"+ "Fec Retiro: "+document.curriculum.retiro3.value+"@@"+"Responsabilidades: " + document.curriculum.respons3.value+"@@@@";
exper4="Empresa: " + document.curriculum.empresa4.value+"@@"+ "Fec Ingreso: " + document.curriculum.ingreso4.value+"@@"+ "Fec Retiro: "+document.curriculum.retiro4.value+"@@"+"Responsabilidades: " + document.curriculum.respons4.value+"@@@@";
exper =  exper1+exper2+exper3+exper4;
  	
//alert(exper);
//userfile=document.curriculum.userfile.value;
		ajax=objetoAjax();
		divFormulario.innerHTML= "<img src='/Imagenes/_barra.gif'>";
		ajax.open("POST","Registrar.php",true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				divFormulario.innerHTML = ajax.responseText
				//Retornar();
        if(hoja==true){
      //     var ventana = window.open("../HojasVida/index.php?ced="+ced+'&tced='+tip,"Adjuntar Hoja de Vida","menubar=no,status=yes,scrollbars=yes,resizable=no,width=400,height=150,toolbar=no,directories=no");
          window.open("../HojasVida/index.php?ced="+ced+"&tced="+tip) 
        }
        /*document.location.href="http://www.logros.com.co";*/ //Cambio Zetta Ingenieria Jun 2009
		alert("Gracias por enviarnos su hoja de vida"+ced+tip);
		document.location.href="http://www.logros.com.co/Zetta-Logros/gracias.php";
		
      }
		}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("cedula="+ced+"&tipocedula="+tip+"&nombres="+nom+"&apellidos="+ape+"&fecha="+fec+"&telcasa="+tcas+"&teloficina="+tofi+"&telcelular="+tcel+"&correo="+corr+"&direccion="+dire+"&ciudad="+ciu+"&profesion="+prof+"&area1="+are1+"&area2="+are2+"&area3="+are3+"&anios="+anio+"&idioma="+idio+"&porcentaje="+porc+"&salario="+sala+"&secundaria_inst="+sec_i+"&secundaria_anio="+sec_a+"&universidad_inst="+uni_i+"&universidad_anio="+uni_a+"&posgrado_inst="+pos_i+"&posgrado_anio="+pos_a+"&titulo="+titul+"&experiencia="+exper+"&hoja="+hoja);
	}

}

function Adjuntar(hoja){

}

function Retornar(){
	alert("Su registro fue gravado exitosamente");
	//window.location = "http://www.logros.com.co";
}
function LimpiarEnvio(){
	document.acceder.User.value= null;
	document.acceder.Pass.value=null;
}
function actualizarCurriculum(){
	var validacion = validar();
	divFormulario = document.getElementById('formulario');
	if(validacion==true){
		var fec = document.curriculum.anio.value + "/" + document.curriculum.mes.value + "/" + document.curriculum.dia.value;
		ced=document.curriculum.cedula.value;
		tip=document.curriculum.tipocedula.value;
		nom=document.curriculum.nombres.value;
		ape=document.curriculum.apellidos.value;
		tcas=document.curriculum.telcasa.value;
		tofi=document.curriculum.teloficina.value;
		tcel=document.curriculum.telcelular.value;
		corr=document.curriculum.correo.value;
		dire=document.curriculum.direccion.value;
		ciu=document.curriculum.ciudad.value;
		prof=document.curriculum.profesion.value;
		are1=document.curriculum.area1.value;			
		are2=document.curriculum.area2.value;
		are3=document.curriculum.area3.value;
		anio=document.curriculum.anios.value;
		idio=document.curriculum.idioma.value;
		porc=document.curriculum.porcentaje.value;
		sala=document.curriculum.salario.value;
		sec_i=document.curriculum.secundaria_inst.value;
		sec_a=document.curriculum.secundaria_anio.value;
		uni_i=document.curriculum.universidad_inst.value;
		uni_a=document.curriculum.universidad_anio.value;
		pos_i=document.curriculum.posgrado_inst.value;
		pos_a=document.curriculum.posgrado_anio.value;
		titul=document.curriculum.titulo.value;
		exper1=document.curriculum.empresa1.value+"@@"+document.curriculum.ingreso1.value+"@@"+document.curriculum.retiro1.value+"@@"+document.curriculum.respons1.value+"@@@@";
exper2=document.curriculum.empresa2.value+"@@"+document.curriculum.ingreso2.value+"@@"+document.curriculum.retiro2.value+"@@"+document.curriculum.respons2.value+"@@@@";
exper3=document.curriculum.empresa3.value+"@@"+document.curriculum.ingreso3.value+"@@"+document.curriculum.retiro3.value+"@@"+document.curriculum.respons3.value+"@@@@";
exper4=document.curriculum.empresa4.value+"@@"+document.curriculum.ingreso4.value+"@@"+document.curriculum.retiro4.value+"@@"+document.curriculum.respons4.value+"@@@@";
exper =  exper1+exper2+exper3+exper4;

		ajax=objetoAjax();
		divFormulario.innerHTML= "<img src='/Imagenes/_barra.gif'>";
		ajax.open("POST","ActualizarForm.php",true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				divFormulario.innerHTML = ajax.responseText
				RetornarA();
			}
		}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("cedula="+ced+"&tipocedula="+tip+"&nombres="+nom+"&apellidos="+ape+"&fecha="+fec+"&telcasa="+tcas+"&teloficina="+tofi+"&telcelular="+tcel+"&correo="+corr+"&direccion="+dire+"&ciudad="+ciu+"&profesion="+prof+"&area1="+are1+"&area2="+are2+"&area3="+are3+"&anios="+anio+"&idioma="+idio+"&porcentaje="+porc+"&salario="+sala+"&secundaria_inst="+sec_i+"&secundaria_anio="+sec_a+"&universidad_inst="+uni_i+"&universidad_anio="+uni_a+"&posgrado_inst="+pos_i+"&posgrado_anio="+pos_a+"&titulo="+titul+"&experiencia="+exper)
	}
}
function RetornarA(){
	alert("Su registro fue modificado exitosamente");
	//window.location = "http://www.logros.com.co";
}
function elimcurriculum(codigo){
	var divResultado = document.getElementById("resultado");
	var divConsulta = document.getElementById("consulta");
	var codigo_d=codigo;
	if(confirm("Desea eliminar el registro numero "+codigo+"?")){
		var ajax=objetoAjax();
		ajax.open("POST", "Eliminar.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send("codigov="+codigo_d);	
		divResultado.innerHTML= "<img src='/Imagenes/_barra.gif'>";
		ajax.onreadystatechange=function(){
			if (ajax.readyState==4){
				alert("Eliminacion exitosa");
				window.location = "index.php";
			}
		}
	}
}

function valEnvio(){
	var divRespuesta = document.getElementById("respuesta");
	var user = document.getElementById("User").value;
	var pass = document.getElementById("Pass").value;
	if(user=="" || pass==""){
		window.location = "index.php";
		alert("No puede enviar datos vacios");
	}
}