function getxmlhttp (){
	//Create a boolean variable to check for a valid Microsoft active x instance.
	var xmlhttp = false;
	//Check if we are using internet explorer.
	try {
		//If the javascript version is greater than 5.
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		//If not, then use the older active x object.
		try {
			//If we are using internet explorer.
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			//Else we must be using a non-internet explorer browser.
			xmlhttp = false;
		}
	}
	// If not using IE, create a
	// JavaScript instance of the object.
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}//cierra getxmlhttp

//funcion para cargar ajax con POST
function loadajax(serverPage, str, obj){

	xmlhttp = getxmlhttp();
	xmlhttp.open("POST", serverPage, true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlhttp.onreadystatechange = function(){
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				if (xmlhttp.responseText == 1){
					window.location = "verordenes.php";
				}else{
					obj.innerHTML = xmlhttp.responseText;		
				}
			}//cierra if
		}// cierra function de onreadystatechagne
	xmlhttp.send(str);
}//cierra loadajax

//funcion para cargar ajax con GET
function processajax(serverPage, objID) {
	xmlhttp = getxmlhttp();
	var obj = document.getElementById(objID);
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function() {
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		obj.innerHTML = xmlhttp.responseText;
	}
}
	xmlhttp.send(null);
}

function Registrate(){
	processajax('registrarempleador.php', 'contenidos');
}

function Logout(){
	processajax('logout.php', 'contenidos');
	}

function ProcesaEmpleador(){
	nombre = document.getElementById('txtNombre').value;
	clave = document.getElementById('txtClave').value;
	confclave = document.getElementById('txtConfClave').value;
	puesto = document.getElementById('txtPuesto').value;
	empresa = document.getElementById('txtEmpresa').value;
	direccion = document.getElementById('txtDireccion').value;
	telefono = document.getElementById('txtTelefono').value;
	ext = document.getElementById('txtExt').value;
	celular = document.getElementById('txtCelular').value;
	fax = document.getElementById('txtFax').value;
	email =document.getElementById('txtEmail').value;
	obj = document.getElementById('contenidos');

	str = "txtNombre="+nombre+"&txtClave="+clave+"&txtPuesto="+puesto+"&txtEmpresa="+empresa+"&txtDireccion="+direccion+"&txtTelefono="+telefono+"&txtExt="+ext+"&txtCelular="+celular+"&txtFax="+fax+"&txtEmail="+email;
	serverPage = "procesaEmpleador.php";
	loadajax(serverPage, str, obj);
}


function GuardaOferta(){
	puesto = document.getElementById("txtPuesto").value;
	sexo = document.getElementById("cmbSexo").value;
	edad = document.getElementById("cmbEdad").value;
	estudios = document.getElementById("cmbEstudios").value;
	experiencia = document.getElementById("txtExperiencia").value;
	actividades = document.getElementById("txtActividades").value;
	sueldo = document.getElementById("txtSueldo").value;
	horario = document.getElementById("txtHorario").value;
	prestaciones = document.getElementById("txtPrestaciones").value;
	requisitos = document.getElementById("txtRequisitos").value;
	obj = document.getElementById("msg");
	
	str = "txtPuesto="+puesto+"&cmbSexo="+sexo+"&cmbEdad="+edad+"&cmbEstudios="+estudios+"&txtExperiencia="+experiencia+"&txtActividades="+actividades+"&txtSueldo="+sueldo+"&txtHorario="+horario+"&txtPrestaciones="+prestaciones+"&txtRequisitos="+requisitos;
	serverPage = "procesaOferta.php";
	loadajax(serverPage, str, obj);
	}
	
function CheckPass(){
	var clave1 = document.getElementById('txtClave').value;
	var clave2 = document.getElementById('txtConfClave').value;
	var divmsg = document.getElementById('divMsg');

	if (!(clave1 == clave2)){
		divmsg.innerHTML = 'claves no coinciden';
	}else{
		divmsg.innerHTML = '';	
	}
}

function CheckLogin(){
	username = document.getElementById("txtUsername").value;
	pass = document.getElementById("txtPass").value;
	obj = document.getElementById("contenidos");
	str = "txtUsername="+username+"&txtPass="+pass;
	serverPage = "checklogin.php";
	loadajax(serverPage, str, obj);
}



function removeTextError(){
	obj = document.getElementById("info");
	obj.innerHTML = "";
	}

function hideInfo(){
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		eval( "document.all.info.style.visibility = 'hidden'");
	}

	if (document.layers) { //IS NETSCAPE 4 or below
		document.layers[info].visibility = 'hidden';
	}

	if (document.getElementById && !document.all) {
		obj = document.getElementById(info);
		obj.style.visibility = 'hidden';
	}
}


function llenaCombo(){
	var comboValue
	var selIndex = document.signup.categoria.selectedIndex;
	comboValue = document.signup.categoria.options[selIndex].value;
	processajax('scripts/llenacombo.php?id=' + comboValue, 'subcategoria');
}






	

