function getXMLHTTPRequest(){
var req = false;
	try {
	     req = new XMLHttpRequest();	
	}
	catch (err1){
		   try {
				req = new ActiveXObject("Msxml2.XMLHTTP");
		   }
		   catch (err2){
				  try {
					   req = new ActiXObject("Microsoft.XMLHTTP");
				  }
				  catch (err3){
					   req = false;
				  }
				  
		   }
	}

	return req;

}


function respGET(url,query,ajax){
  myRand=parseInt(Math.random()*9999999);
  var url_ok = url + "?" + query + "&myRand=" + myRand;

  ajax.open("GET",url_ok,true);
  ajax.send(null);

}

function respPOST(url,query,ajax){
  ajax.open("POST",url,true);
  ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  ajax.send(query);

}

function doCallback(callback, item){
   eval(callback + '(item)');
}

function llama_ajax(op,query,callback,get_post,xml_text){
   
	dir_sistema = 'sitio/';
	switch (op){
	    case 1:
		  url = dir_sistema + 'contacto_aviso.php';
	      break;
	    case 2:
		  url = dir_sistema + 'recomienda_aviso.php';
	      break;
	    case 3:
		  url = dir_sistema + 'envia_codigo.php';
	      break;
	    case 4:
		  url = dir_sistema + 'login.php';
	      break;

	}


var http = getXMLHTTPRequest();

	http.onreadystatechange = function() {
	 if (http.readyState == 4){
		 if (http.status == 200){

			     var item = http.responseText;
				 if (xml_text == 'xml')
					 var item = http.responseXML;
				 
//alert(item);
				     doCallback(callback, item);
		 }
		}  
                                     }

     if (get_post == 'POST'){
		 respPOST(url,query,http);
     }
     else {
		 respGET(url,query,http);
     }



}