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;
}
function f_evento(e,bus_texto){
	tecla = (document.all) ? e.keyCode : e.which;
	if (tecla==13){
		f_verifica_login();
	}
}
function f_verifica_login(){
	with(document){
		if(f_valida_datos()!=false){		
			var codigo=getElementById("txt_codigo").value;
			var clave=getElementById("txt_clave").value;
			cad='';
			cad="codigo="+codigo+"&clave="+clave;
			ajax1=objetoAjax();
			ajax1.open("POST", "index_action.php");
			ajax1.onreadystatechange=function() {
				if (ajax1.readyState==4) {
					eval(ajax1.responseText);
				}
			}
			ajax1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			ajax1.send(cad);    
		}
	}
}
function f_valida_datos(){
	with(document){
		getElementById("div_mensaje").innerHTML="";
		var codigo=getElementById("txt_codigo").value;
		var clave=getElementById("txt_clave").value;
		if(codigo==''){
			getElementById("div_mensaje").innerHTML="Ingrese su c\u00f3digo";
			getElementById("txt_codigo").focus();
			return false;
		}
		if(clave==''){
			getElementById("div_mensaje").innerHTML="Ingrese su contrase\u00f1a";
			getElementById("txt_clave").focus();
			return false;
		}
	}
}
function f_cambia_imagen(valor){
	with(document){
		if(valor=='1'){
			getElementById("imagen1").style.display='none';
			getElementById("imagen2").style.display='block';
		
		}else{
			getElementById("imagen2").style.display='none';
			getElementById("imagen1").style.display='block';
		}
	}
}
function f_mensaje_error(){
	document.getElementById("div_mensaje").innerHTML="C\u00f3digo y/o contrase\u00f1a incorrecta.";
}