// -------------------------------------- ELIMINAR ----------------------------------------

function Eliminar(id, elemento, tabla){
	if (window.confirm("Esta seguro que desea eliminar el " + elemento + "?")){
		var sParam = "?a=eliminar&id="+id+"&t="+tabla;
		window.location="/procesa.php"+sParam;
	}
}

//---------------------------- LOGIN ---------------------------------------------------

function verificaUsuario(){
	xmlHttp = crearXMLHttpRequest()
	if (xmlHttp == null) {
	  alert ("Tu navegador no soporta AJAX!");
	  return;
	}

	var valor = escape(document.getElementById("usuario").value);
	var valor2 = escape(document.getElementById("clave").value);
	var url = "/ajax.php?a=verificaLog&u="+ valor +"&c="+ valor2;
	url = url + "&sid="+Math.random();
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged() { 
	if (xmlHttp.readyState==4)
	{ 
		results = xmlHttp.responseText.split(","); 
		document.getElementById("campoMensaje").innerHTML = results[0];
		if (results[0] == ""){
			location.href= "/foro-listado.php"
		}
	}
	if (xmlHttp.readyState==1){
		document.getElementById("campoMensaje").innerHTML="Procesando";
	}
}

//---------------------------- XML HTTP REQUEST ----------------------------------------

function crearXMLHttpRequest(){
  var xmlHttp=null;
  if (window.ActiveXObject) 
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  else 
    if (window.XMLHttpRequest) 
      xmlHttp = new XMLHttpRequest();
  return xmlHttp;
}

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;
}