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

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION OBTIENE ELEMENTOS DEL FORMULARIO
function getFormValues(x) { 
	var str = ""; var valueArr = null; var val = ""; var cmd = ""; 
	for(var i = 0; i < document.forms[x].elements.length;i++) { 
		switch(document.forms[x].elements[i].type) { 
			case "hidden": 
				str += document.forms[x].elements[i].name + "=" + escape(document.forms[x].elements[i].value) + "&"; 
				break;
			case "text":
				cmd = "(" + 'document.forms[x].elements[i].value' + ")"; 
				val = eval(cmd)
				str += document.forms[x].elements[i].name + "=" + escape(document.forms[x].elements[i].value) + "&";
				break;
			case "textarea": 
				cmd = "(" + 'document.forms[x].elements[i].value' + ")"; 
				val = eval(cmd) 
				str += document.forms[x].elements[i].name + "=" + escape(document.forms[x].elements[i].value) + "&"; 
				break;                                  
			case "radio": 
				var nombre=document.forms[x].elements[i].name;
				var form_nombre=document.forms[x].name;
				var numero_radios = eval("(" + 'document.'+form_nombre+'.'+nombre+'.length' + ")"); 
				var elvalor; var aux; var k = 0;
				while(k < numero_radios) {
					aux = eval("(" + 'document.'+form_nombre+'.'+nombre+'[' + k + ']' + ")")
					if(aux.checked) elvalor = aux.value;
					k++;
				}
				str += nombre + "=" + escape(elvalor) + "&"; 
				break;
			case "checkbox": 
                if (document.forms[x].elements[i].checked) {
	                str += document.forms[x].elements[i].name + "=" + document.forms[x].elements[i].value + "&";
                }
                break;
			case "select-one": 
				str += document.forms[x].elements[i].name + "=" + document.forms[x].elements[i].options[document.forms[x].elements[i].selectedIndex].value + "&"; 
				break; 
		} 
	} 
	str = str.substr(0,(str.length - 1)); 
	return str; 
}
//
//////////////////////////////////////////////////
/////////////////////////////////////////////////
//FUNCION LOADING
//
function loading(){
	var loadingc='<center><img src="http://www.espacioaereo.com.mx/2/images/activity.gif" /></center>';
	return loadingc;
}
//
/////////////////////////////////////////////////

////////////////////////////////////////////////
//FUNCION LOADING VALIDA
//
function loading_valida(){
	var loadingc='<b>Validando...</b>';
	return loadingc;
}
//
/////////////////////////////////////////////////

//----------------------------------------------//

/////////////////////////////////////////////////
//FUNCION MUESTRA FORMULARIO PUESTO
function mostrarPuesto(id) {
	document.getElementById("piloto").style.display="none";
	document.getElementById("ingeniero_aeronautico").style.display="none";
	document.getElementById("sobrecargo").style.display="none";
	document.getElementById("oficial_operaciones").style.display="none";
	document.getElementById("mecanico").style.display="none";
	document.getElementById("otra").style.display="none";
	if (id==1) {
		document.getElementById("piloto").style.display="";
	} else if (id==2) {
		document.getElementById("ingeniero_aeronautico").style.display="";
	} else if (id==3) {
		document.getElementById("sobrecargo").style.display="";
	} else if (id==4) {
		document.getElementById("oficial_operaciones").style.display="";
	} else if (id==5) {
		document.getElementById("mecanico").style.display="";
	} else if (id==6) {
		document.getElementById("otra").style.display="";
	}
}
//
/////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION AGREGAR FAVORITOS CANDIDATO(RECLUTADOR)
function candidatoFavoritosAgregar(idreclutador, idcandidato){
	
	divResultado = document.getElementById('favoritos'+idcandidato);
	divResultado.innerHTML="";
	ajax=objetoAjax();
	ajax.open("GET", "http://www.espacioaereo.com.mx/bolsa_trabajo/paginas/reclutador_favoritosagregar.php?idr="+idreclutador+"&idc="+idcandidato);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4 && ajax.status == 200) {
			divResultado.innerHTML=ajax.responseText;
		}
	}
	ajax.send(null);
}
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION QUITAR FAVORITOS CANDIDATO (RECLUTADOR)
function candidatoFavoritosQuitar(idreclutador, idcandidato, idfavoritos, misfav){
	if (misfav=="") {
		divResultado = document.getElementById('favoritos'+idcandidato);
		divResultado.innerHTML="";
	}
	ajax=objetoAjax();
	ajax.open("GET", "http://www.espacioaereo.com.mx/bolsa_trabajo/paginas/reclutador_favoritosquitar.php?idr="+idreclutador+"&idc="+idcandidato+"&idf="+idfavoritos);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4 && ajax.status == 200) {
			if (misfav!="") {
				document.location.reload();
			} else {
				divResultado.innerHTML=ajax.responseText;
			}
		}
	}
	ajax.send(null);
}
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION AGREGAR FAVORITOS OFERTA (CANDIDATO)
function ofertaFavoritosAgregar(idusuario, idoferta){
	
	divResultado = document.getElementById('favoritos'+idoferta);
	divResultado.innerHTML="";
	ajax=objetoAjax();
	ajax.open("GET", "http://www.espacioaereo.com.mx/bolsa_trabajo/paginas/candidato_favoritosagregar.php?idu="+idusuario+"&ido="+idoferta);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4 && ajax.status == 200) {
			divResultado.innerHTML=ajax.responseText;
		}
	}
	ajax.send(null);
}
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION QUITAR FAVORITOS OFERTA (CANDIDATO)
function ofertaFavoritosQuitar(idusuario, idoferta, idfavoritos, misfav){
	if (misfav=="") {
		divResultado = document.getElementById('favoritos'+idoferta);
		divResultado.innerHTML="";
	}
	ajax=objetoAjax();
	ajax.open("GET", "http://www.espacioaereo.com.mx/bolsa_trabajo/paginas/candidato_favoritosquitar.php?idf="+idfavoritos+"&idu="+idusuario+"&ido="+idoferta);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4 && ajax.status == 200) {
			if (misfav!="") {
				document.location.reload();
			} else {
				divResultado.innerHTML=ajax.responseText;
			}
		}
	}
	ajax.send(null);
}
//////////////////////////////////////////////////

//----------------------------------------------//

/////////////////////////////////////////////////
//FUNCION MUESTRA FORMULARIO PROFESION
function mostrarProfesion(id) {
	document.getElementById("piloto").style.display="none";
	document.getElementById("ingeniero_aeronautico").style.display="none";
	document.getElementById("sobrecargo").style.display="none";
	document.getElementById("oficial_operaciones").style.display="none";
	document.getElementById("mecanico").style.display="none";
	document.getElementById("otra").style.display="none";
	if (id==1) {
		document.getElementById("piloto").style.display="";
	} else if (id==2) {
		document.getElementById("ingeniero_aeronautico").style.display="";
	} else if (id==3) {
		document.getElementById("sobrecargo").style.display="";
	} else if (id==4) {
		document.getElementById("oficial_operaciones").style.display="";
	} else if (id==5) {
		document.getElementById("mecanico").style.display="";
	} else if (id==6) {
		document.getElementById("otra").style.display="";
	}
}
//
/////////////////////////////////////////////////

//----------------------------------------------//

/////////////////////////////////////////////////
//FUNCION MUESTRA FORMULARIO PROFESION REGISTRO CANDIDATO
function mostrarProfesionReg(id) {
	document.getElementById("pilotoreg").style.display="none";
	document.getElementById("ingeniero_aeronauticoreg").style.display="none";
	document.getElementById("sobrecargoreg").style.display="none";
	document.getElementById("oficial_operacionesreg").style.display="none";
	document.getElementById("mecanicoreg").style.display="none";
	document.getElementById("otrareg").style.display="none";
	if (id==1) {
		document.getElementById("pilotoreg").style.display="";
	} else if (id==2) {
		document.getElementById("ingeniero_aeronauticoreg").style.display="";
	} else if (id==3) {
		document.getElementById("sobrecargoreg").style.display="";
	} else if (id==4) {
		document.getElementById("oficial_operacionesreg").style.display="";
	} else if (id==5) {
		document.getElementById("mecanicoreg").style.display="";
	} else if (id==6) {
		document.getElementById("otrareg").style.display="";
	}
}
//
/////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION BORRAR CURRICULUM
function borrarCurriculum(id){
	
	var borrar = confirm("¿Desea Borrar su Curriculum?")
	if (borrar) {
		ajax=objetoAjax();
		ajax.open("GET", "http://www.espacioaereo.com.mx/bolsa_trabajo/paginas/candidato_borrar.php?id="+id);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4 && ajax.status==200) {
				document.location.reload();
			}
		}
		ajax.send(null);
	}
}
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION ACTIVAR CURRICULUM
function activarCurriculum(id){
	var activar=confirm("¿Desea Activar su Curriculum?")
	if (activar) {
		ajax=objetoAjax();
		ajax.open("GET", "http://www.espacioaereo.com.mx/bolsa_trabajo/paginas/candidato_activar.php?id="+id);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4 && ajax.status==200) {
				document.location.reload();
			}
		}
		ajax.send(null);
	}
}
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION DESACTIVAR CURRICULUM
function desactivarCurriculum(id){
	
	var desactivar = confirm("¿Desea Desactivar su Curriculum?")
	if (desactivar) {
		ajax=objetoAjax();
		ajax.open("GET", "http://www.espacioaereo.com.mx/bolsa_trabajo/paginas/candidato_desactivar.php?id="+id);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4 && ajax.status==200) {
				document.location.reload();
			}
		}
		ajax.send(null);
	}
}
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION BUSCAR OFERTAS
function buscarOfertas() {
	var form=document.forms["busqueda"]; 
	var profesion=form.elements["b_idprofesion"].value;
	var pais=form.elements["b_idpais"].value;
	if (profesion=="" && pais=="") {
		alert("Debe Especificar una búsqueda");
	} else {
		var oc="";
		if (form.elements["b_idoc"][0].checked) oc=form.elements["b_idoc"][0].value;
		else oc=form.elements["b_idoc"][1].value;
		if (oc==1) document.location="http://www.espacioaereo.com.mx/bolsa_trabajo/?s=3&m=bo&pa="+pais+"&pu="+profesion+"&p=1";
		else if (oc==2) document.location="http://www.espacioaereo.com.mx/bolsa_trabajo/?s=3&m=bc&pa="+pais+"&pr="+profesion+"&p=1";
	}
}
//
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION REPRODUCIR VIDEO
function reproducir(nombre) {
	var video='<object id="Player" name="Player" width="320" height="285" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" standby="Loading Stream..." type="application/x-oleobject"> <param name="URL" value="http://www.espacioaereo.com.mx/2/curriculum_video/'+nombre+'"> <param name="AllowChangeDisplaySize" value="True"> <param name="AutoSize" value="False"> <param name="DisplaySize" value=0> <param name="ShowControls" value="True"> <param name="showstatusbar" value="True"> <param name="AutoRewind" value="True"> <param name="AutoStart" value="False"> <embed name="Player" src="http://www.espacioaereo.com.mx/2/curriculum_video/'+nombre+'" type="application/x-mplayer2" width="320" height="285" ShowC."0" ShowStatusBar="1" loop="true" EnableC."0" DisplaySize="4" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/"></embed></object>';
	
	document.write(video);
}
//
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION AGREGAR A FAVORITOS
function agregarFavoritos(idc) {
	//idc => id del candidato
	var result = document.getElementById("nf");
	var ajax=new objetoAjax();
	ajax.open("GET", "http://www.espacioaereo.com.mx/2/paginas/reclutador_agregarfavorito.php?idc="+idc, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4 && ajax.status==200) {
			//alert(ajax.responseText);
			result.innerHTML=ajax.responseText;
		}
	}
	ajax.send(null);
}
//
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCIONES DRAG CITAS
function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  dragObj.elNode = document.getElementById(id);

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);

    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}
//////////////////////////////////////////////////

//----------------------------------------------//

/////////////////////////////////////////////////
//FUNCION LOADING VENTANA
function loadingVentana(m){
	document.getElementById("cargador").style.visibility=(m==1)?"visible":"hidden";
}
//
/////////////////////////////////////////////////

//----------------------------------------------//

/////////////////////////////////////////////////
//FUNCION CENTRAR DIV
function centrarDiv(divObj){
	var ie=document.all && !window.opera;
	var dom=document.getElementById;
	standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
	var scroll_top=(ie)? standardbody.scrollTop : window.pageYOffset;
	var scroll_left=(ie)? standardbody.scrollLeft : window.pageXOffset;
	var docwidth=(ie)? standardbody.clientWidth : window.innerWidth-16;
	var docheight=(ie)? standardbody.clientHeight: window.innerHeight;
	var docheightcomplete=(standardbody.offsetHeight>standardbody.scrollHeight)? standardbody.offsetHeight : standardbody.scrollHeight;
	var objwidth=divObj.offsetWidth;
	var objheight=divObj.offsetHeight;
	var topposition=(docheight>objheight)? scroll_top+docheight/2-objheight/2+"px" : scroll_top+"px";
	divObj.style.left=docwidth/2-objwidth/2+"px";
	divObj.style.top=Math.floor(parseInt(topposition))+"px";
}
//
/////////////////////////////////////////////////

//----------------------------------------------//

/////////////////////////////////////////////////
//FUNCION MOSTRAR TRANSPARENCIA
function transparent(){
	var trans=document.getElementById("transparencia");
	
	var ie=document.all && !window.opera;
	var dom=document.getElementById;
	standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
	var docwidth=(ie)? standardbody.clientWidth : window.innerWidth-16;
	var docheight=(ie)? standardbody.clientHeight: window.innerHeight;
	var docheightcomplete=(standardbody.offsetHeight>standardbody.scrollHeight)? standardbody.offsetHeight : standardbody.scrollHeight;
	
	trans.style.width=docwidth+"px";
	trans.style.height=docheightcomplete+"px";
	trans.style.visibility="visible";
}
//
/////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION CONTACTAR
function contactar(idc) {
	transparent();
	centrarDiv(document.getElementById("cargador"));
	loadingVentana(1);
	var divResultado=document.getElementById("contenido");
	
	var ajax=new objetoAjax();
	ajax.open("GET","http://www.espacioaereo.com.mx/2/paginas/reclutador_contacto.php?idc="+idc, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4 && ajax.status==200)	{ 
			divResultado.innerHTML=ajax.responseText;
			centrarDiv(divResultado);
			loadingVentana(2);
			divResultado.style.visibility="visible";
		} 
	}
	ajax.send(null);
}
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION CONTACTO ENVIO
function contactoEnvio(frm) {
	//limpiar errores
	var e=document.getElementById("exito");
	e.style.display="none";
	document.getElementById("error_1").style.visibility="hidden";
	document.getElementById("error_2").style.visibility="hidden";
	var btn=frm.enviar;
	btn.value="Enviando...";
	btn.disabled=true;
	//valida form
	var error=0;
	if(frm.asunto.value=="") {
		document.getElementById("error_1").style.visibility="visible";
		error++;
	}
	if(frm.mensaje.value=="") {
		document.getElementById("error_2").style.visibility="visible";
		error++;
	}
	if (error==0) {
		var str = getFormValues(frm.name);
		var ajax=new objetoAjax();
		ajax.open("POST", "http://www.espacioaereo.com.mx/2/paginas/reclutador_contactoenvio.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send(str);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4 && ajax.status==200) {
				e.style.display="block";
				frm.asunto.value="";
				frm.mensaje.value="";
				btn.value="Enviar";
				btn.disabled=false;
			}
		}
	} else {
		btn.value="Enviar"
		btn.disabled=false;
	}
}
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION CERRAR TRANSPARENT
function cerrarVentana() {
	var cont=document.getElementById("contenido");
	cont.style.visibility="hidden";
	
	var trans=document.getElementById("transparencia");
	trans.style.visibility="hidden";
}
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION RECLUTADOR QUITAR FAVORITO
function rQuitarFavorito(idf) {
	document.getElementById("favoritos").removeChild(document.getElementById("c"+idf));
	
	var ajax=new objetoAjax();
	ajax.open("GET","http://www.espacioaereo.com.mx/2/paginas/reclutador_quitarfavorito.php?idf="+idf, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4 && ajax.status==200)	{ 
			if (ajax.responseText=="0") {
				document.getElementById("favoritos").innerHTML='<font color="#FF0000"><b>No se encontraron Favoritos</b></font>';
			}
			document.getElementById("nf").innerHTML=ajax.responseText;
		} 
	}
	ajax.send(null);
}
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION RECLUTADOR ACTIVAR OFERTA
function ofertaActivarDesactivar(ido, a) {
	//ido => id de la oferta
	//a => accion a realizar
	var divResultado=document.getElementById("ao"+ido);
	divResultado.innerHTML=(a=="a")?'<span class="liga_rojo"><a href="Desactivar" onclick="ofertaActivarDesactivar(\''+ido+'\', \'d\'); return false;">Desactivar?</a></span>':'<span class="liga_vde"><a href="Activar" onclick="ofertaActivarDesactivar(\''+ido+'\', \'a\'); return false;">Activar?</a></span>';
	
	var ajax=new objetoAjax();
	ajax.open("GET","http://www.espacioaereo.com.mx/2/paginas/reclutador_adoferta.php?ido="+ido+"&a="+a, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4 && ajax.status==200)	{ 
			(a=="a")?document.getElementById("ex"+ido).innerHTML='<font color="#FF0000">'+ajax.responseText+'</font>':'';
		}
	}
	ajax.send(null);
}
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION BORRAR OFERTA
function borrarOferta(ido){
	var divResultado=document.getElementById("ofertas");
	divResultado.removeChild(document.getElementById("o"+ido));
	
	var ajax=new objetoAjax();
	ajax.open("GET", "http://www.espacioaereo.com.mx/2/paginas/reclutador_borraroferta.php?ido="+ido, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4 && ajax.status==200) {
			if (ajax.responseText=="0") {
				divResultado.innerHTML='<b><font color="#FF0000">No tienes ofertas publicadas.</font> <font class="txt_vde"> &iquest;Deseas publicar una? </font><span class="liga_login"><a href="http://www.espacioaereo.com.mx/2/index.php?s=r&m=po">Haz clic aqui</a>.</span></b>';
			}
			document.getElementById("no").innerHTML=ajax.responseText;
		}
	}
	ajax.send(null);
}
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION VALIDA NOMBRE DE USUARIO DE RECLUTADOR
function verificaUsuarioReclutador(usuario, id) {
	if (usuario!="") {
		document.getElementById("error_4").style.visibility="hidden";
		divResultado = document.getElementById('result_usuario');
		divResultado.innerHTML= loading_valida();
		var ajax=new objetoAjax();
		ajax.open("GET", "http://www.espacioaereo.com.mx/2/paginas/reclutador_usuario_verifica.php?u="+usuario+"&id="+id,true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4 && ajax.status==200) {
				divResultado.innerHTML = ajax.responseText;
			}
		}
		ajax.send(null);
	}
}
//
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION VALIDA EMPRESA
function verificaEmpresa(emp, id) {
	if (emp!="") {
		document.getElementById("error_7").style.visibility="hidden";
		divResultado = document.getElementById('result_empresa');
		divResultado.innerHTML=loading_valida();
		var ajax=new objetoAjax();
		ajax.open("GET", "http://www.espacioaereo.com.mx/2/paginas/reclutador_verifica_empresa.php?e="+emp+"&id="+id,true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4 && ajax.status==200) {
				divResultado.innerHTML=ajax.responseText;
			}
		}
		ajax.send(null);
	}
}
//
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION VALIDA NOMBRE DE USUARIO DE RECLUTADOR
function verificaUsuarioCandidato(usuario, id) {
	if (usuario!="") {
		document.getElementById("error_5").style.visibility="hidden";
		divResultado = document.getElementById('result_usuario');
		divResultado.innerHTML= loading_valida();
		var ajax=new objetoAjax();
		ajax.open("GET", "paginas/candidato_usuario_verifica.php?u="+usuario+"&id="+id,true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4 && ajax.status==200) {
				divResultado.innerHTML = ajax.responseText;
			}
		}
		ajax.send(null);
	}
}
//
//////////////////////////////////////////////////
//////////////////////////////////////////////////
//FUNCION VALIDA NOMBRE DE USUARIO DE RECLUTADOR
function verificaEmailCandidato(usuario, id) {
	if (usuario!="") {
		document.getElementById("error_2").style.visibility="hidden";
		divResultado = document.getElementById('result_mail');
		divResm = document.getElementById('mail');
		divdatos = document.getElementById('datos_personales');
		divdatos2 = document.getElementById('datos_personales_2');
		divResultado.innerHTML= loading_valida();
		var ajax=new objetoAjax();
		ajax.open("GET", "paginas/candidato_mail_verifica.php?u="+usuario+"&id="+id,true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4 && ajax.status==200) {
				var a= ajax.responseText;
				if(a!='<font class="txt_vde">Ok</font>'){
					divdatos.style.display="none";
			     	divdatos2.style.display="none";
					divResm.innerHTML=a;
				}else{
					divResultado.innerHTML=a;
				}
			}
		}
		ajax.send(null);
	}
}
//
//////////////////////////////////////////////////
//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION CANDIDATO ACTIVAR O DESACTIVAR CURRICULUM
function curriculumActivarDesactivar(ids, a) {
	//ids => id de la tabla curriculum status
	//a => accion a realizar
	var divResultado=document.getElementById("acde");
	divResultado.innerHTML=(a=="a")?'<span class="liga_rojo"><a href="Desactivar" onclick="curriculumActivarDesactivar(\''+ids+'\', \'d\'); return false;">Desactivar?</a></span>':'<span class="liga_vde"><a href="Activar" onclick="curriculumActivarDesactivar(\''+ids+'\', \'a\'); return false;">Activar?</a></span>';
	
	var ajax=new objetoAjax();
	ajax.open("GET","http://www.espacioaereo.com.mx/2/paginas/candidato_adcurriculum.php?ids="+ids+"&a="+a, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4 && ajax.status==200)	{ 
			(a=="a")?document.getElementById("expira").innerHTML='<font color="#FF0000">'+ajax.responseText+'</font>':'';
		}
	}
	ajax.send(null);
}
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION AGREGAR A FAVORITOS DE CANDIDATO
function agregarFavoritosCandidato(ido) {
	//ido => id de la oferta
	var result = document.getElementById("nfc");
	var ajax=new objetoAjax();
	ajax.open("GET", "http://www.espacioaereo.com.mx/2/paginas/candidato_aqfavorito.php?ido="+ido+"&a=a", true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4 && ajax.status==200) {
			result.innerHTML=ajax.responseText;
		}
	}
	ajax.send(null);
}
//
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION QUITAR FAVORITO DE CANDIDATO
function quitarFavoritoCandidato(idf) {
	document.getElementById("favoritos").removeChild(document.getElementById("o"+idf));
	
	var ajax=new objetoAjax();
	ajax.open("GET","http://www.espacioaereo.com.mx/2/paginas/candidato_aqfavorito.php?ido="+idf+"&a=q", true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4 && ajax.status==200)	{ 
			if (ajax.responseText=="0") {
				document.getElementById("favoritos").innerHTML='<font color="#FF0000"><b>No se encontraron Favoritos</b></font>';
			}
			document.getElementById("nfc").innerHTML=ajax.responseText;
		} 
	}
	ajax.send(null);
}
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION CARGA FABRICANTES
function cargaFabricantes(s, id, d) {
	//s => select a cargar
	//id => id del select padre
	//d => opcion seleccionada por default
	var divCombo=document.getElementById("fila_"+s);
	var ajax=new objetoAjax();
	ajax.open("GET", "paginas/carga_fabricantes.php?s="+s+"&idc="+id+"&idf="+d, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1){
			// Mientras carga elimino la opcion "Selecciona Opcion..." y pongo una que dice "Cargando..."
			var combo=document.getElementById(s);
			//alert(divCombo);
			combo.length=0;
			var nuevaOpcion=document.createElement("option");
			nuevaOpcion.value="";
			//
			nuevaOpcion.innerHTML="Cargando...";
			combo.appendChild(nuevaOpcion);
		}
		if (ajax.readyState==4){
				divCombo.innerHTML=ajax.responseText;
	    }
	}
	ajax.send(null);
}
//
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION CARGA MODELOS
function cargaModelos(s, id, d) {
	//alert("entro"+s+"id "+id+"d"+d);
	//s => select a cargar
	//id => id del select padre
	//d => opcion seleccionada por default
	var divCombo=document.getElementById("fila_"+s);
	var ajax=new objetoAjax();
	ajax.open("GET", "paginas/carga_modelos.php?s="+s+"&idc="+id+"&idf="+d, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1){
		    var combo=document.getElementById(s);
			combo.length=0;
			var nuevaOpcion=document.createElement("option");
			nuevaOpcion.value="";
			//
			nuevaOpcion.innerHTML="Cargando...";
			combo.appendChild(nuevaOpcion);
		}
		if (ajax.readyState==4){
				divCombo.innerHTML=ajax.responseText;
	    } 
	}
	ajax.send(null);
}
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION VISITAS CANDIDATO
function visitasCandidato(idc, pag) {
	var divResultado=document.getElementById("resultado_visitas");
	divResultado.innerHTML=loading();
	
	var ajax=new objetoAjax();
	ajax.open("GET","http://www.espacioaereo.com.mx/2/paginas/candidato_visitas.php?idc="+idc+"&p="+pag, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4 && ajax.status==200)	{ 
			divResultado.innerHTML=ajax.responseText;
		} 
	}
	ajax.send(null);
}
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION VISITAS OFERTA
function visitasOferta(ido, pag) {
	var divResultado=document.getElementById("resultado_visitas");
	divResultado.innerHTML=loading();
	
	var ajax=new objetoAjax();
	ajax.open("GET","http://www.espacioaereo.com.mx/v3/paginas/reclutador_visitas.php?ido="+ido+"&p="+pag, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4 && ajax.status==200)	{ 
			divResultado.innerHTML=ajax.responseText;
		} 
	}
	ajax.send(null);
}
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION MOSTRAR PROFESION
function mostrarProfesionBuscador(id) {
	//ocultar formularios
	document.getElementById("piloto").style.display="none";
	document.getElementById("sobrecargo").style.display="none";
	document.getElementById("ingeniero").style.display="none";
	document.getElementById("mecanico").style.display="none";
	if (id==1) {
		document.getElementById("piloto").style.display="block";
	} else if (id==2) {
		document.getElementById("ingeniero").style.display="block";
	} else if (id==3) {
		document.getElementById("sobrecargo").style.display="block";
	} else if (id==5) {
		document.getElementById("mecanico").style.display="block";
	}
}
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION MOSTRAR U OCULTAR CAMPOS
function mostrarOcultar(c, n) {
	if (c.checked==true) {
		//mostrar
		for (i=1; i<=n; i++) {
			document.getElementById(c.name+"_"+i).style.display="block";
		}
	} else {
		//ocultar
		for (i=1; i<=n; i++) {
			document.getElementById(c.name+"_"+i).style.display="none";
		}
	}
}
//////////////////////////////////////////////////

//----------------------------------------------//

//////////////////////////////////////////////////
//FUNCION BUSCAR CANDIDATOS
function buscarCandidatos(frm) {
	document.location="?id=4";
}
//////////////////////////////////////////////////

//----------------------------------------------//
//FUNCION BUSCAR USUARIOS
function reclutaBuscar() {
	var b=document.getElementById("buscar").value;
	
	if (b!="") {
		var divResultado = document.getElementById('resultado');
		divResultado.innerHTML= loading();
			
		var ajax=new objetoAjax();
		ajax.open("GET","reclutador_suguiere.php?b="+b, true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4 && ajax.status==200)	{ 
				divResultado.innerHTML=ajax.responseText;
			} 
		}
		ajax.send(null);
	}
}
//////////////////////////////////////////////////
/////////////////////////////////////////////////
//FUNCION CARGA SECCIÓN
function cargaSeccion(file,div) {
	var divResultado = document.getElementById(div);
	divResultado.innerHTML= loading();
	var ajax=new objetoAjax();
	ajax.open("GET", file, true);
	ajax.onreadyStatechange=function () {
		if (ajax.readyState==4 && ajax.status==200) {
			divResultado.innerHTML= ajax.responseText;
		}
	}
	ajax.send(null);
}
/////////////////////////////////////////////////
//---------------------------------------------//
//////////////////////////////////////////////////
//FUNCION ACTUALIZA CHAT ASESORES
var ofc=0;
function actualizaChat() {	
	var divonline = document.getElementById('online');
	var divoffline = document.getElementById('offline');
	var ajax=new objetoAjax();
	ajax.open("GET", "verifica_asesor.php", true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4 && ajax.status==200)	{ 
			var actual = parseInt(ajax.responseText);
			if ((actual > 0 ) && (ofc == 0)){
				divoffline.style.display="none";
				divonline.style.display="block";
				ofc=1;
			}else if(actual == 0){
				divoffline.style.display="block";
				divonline.style.display="none";
				ofc=0;
			}
			setTimeout("actualizaChat()",30000)
		}
	}
	ajax.send(null);
}
//////////////////////////////////////////////////
/////////////////////////////////////////////////
//FUNCION MUESTRA FORMULARIO PUESTO
function mostrarPuesto2(id) {
	document.getElementById("pilotos").style.display="none";
	document.getElementById("ingeniero_aeronauticos").style.display="none";
	document.getElementById("sobrecargos").style.display="none";
	document.getElementById("oficial_operacioness").style.display="none";
	document.getElementById("mecanicos").style.display="none";
	document.getElementById("otras").style.display="none";
	if (id==1) {
		document.getElementById("pilotos").style.display="";
	} else if (id==2) {
		document.getElementById("ingeniero_aeronauticos").style.display="";
	} else if (id==3) {
		document.getElementById("sobrecargos").style.display="";
	} else if (id==4) {
		document.getElementById("oficial_operacioness").style.display="";
	} else if (id==5) {
		document.getElementById("mecanicos").style.display="";
	} else if (id==6) {
		document.getElementById("otras").style.display="";
	}
}
//
/////////////////////////////////////////////////
//----------------------------------------------//
function validar(e) { // 1
tecla = (document.all) ? e.keyCode : e.which; // 2
if (tecla==8) return true; // 3
patron =/[A-Za-z\s]/; // 4
te = String.fromCharCode(tecla); // 5
return patron.test(te); // 6
/////////////////////////////////////////////////
}