//////////////////////////////////////////////////
//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 LOADING
function loading(){
	var loading='<center><img src="images/loader.gif" border="0" /></center>';
	return loading;
}
//////////////////////////////////////////////////
//////////////////////////////////////////////////
//FUNCION USUARIO INGRESAR
function usuarioIngresar(frm){
	//CLASS
	var usu=frm.usu;
	var pass=frm.con;
	var btn=frm.ingresa;
	var div=document.getElementById("acceso");//div principal
	var img=document.getElementById("valida_ingreso");

	div.style.display="block";
	img.style.display="block";
	//usu.className="input_txt";
	//pass.className="input_txt";

	e=0;
	if (usu.value=="") {
		alert("Usuario o Clave invalida. Porfavor verifica tu datos");
		img.style.display="none";
		e++;
	}
	if (pass.value=="") {
		alert("Usuario o Clave invalida. Porfavor verifica tu datos");
		img.style.display="none";
		e++;
	}
	if (e==0) {
		img.style.display="block";
		var ajax=new objetoAjax();
		ajax.open("GET", "verifica.php?u="+usu.value+"&c="+pass.value, true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4 && ajax.status == 200) {
				if (ajax.responseText=="error") {
					frm.reset();
					alert("Usuario o Clave invalida. Porfavor verifica tu datos");
					usu.focus();
					img.style.display="none";
					btn.style.display="block";
				} else if (ajax.responseText=="exito") {
				   document.location.reload();
				} else {
					alert("Error al verificar usuario");
					document.location.reload();
				}
			}
		}
		ajax.send(null);
	}
}
//////////////////////////////////////////////////
//----------------------------------------------//
//----------------------------------------------//