// www.sean.co.uk
if (location.hostname == 'localhost')
{
	var url_ec = 'http://localhost/estoy_cerca/';
}
else
{
	var url_ec = 'http://www.estoycerca.com/';
}

function getAjax(url,method,postdata,callback)
{
		var req = null;
		if (window.XMLHttpRequest)
		{
 			req = new XMLHttpRequest();
			if (req.overrideMimeType) 
			{
				req.overrideMimeType('text/xml');
			}
		} 
		else if (window.ActiveXObject) 
		{
			try {
				req = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e)
			{
				try {
					req = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
        	}

		req.onreadystatechange = function()
		{ 
			
			if(req.readyState == 4)
			{
				if(req.status == 200)
				{
				  var respuesta = req.responseText;
				  callback(respuesta);
			  
                 }
				else	
				{
					var error = "Error: returned status code " + req.status + " " + req.statusText;
					alert(error);
				}	
			} 
		};             
		
		if (method == 'GET'
			|| method == 'get')
		{
			req.open(method, url+'?'+postdata , true); 

			req.send(null);
		}
		else if (method == 'POST'
				|| method == 'post')
		{
			req.open(method, url, true); 
		
			//Send the proper header information along with the request 
			req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
			req.setRequestHeader("Content-length", postdata.length); 
			req.send(postdata);
		}
}

function http_build_query(param_array)
{
	var for_counter = 0;
	var param_string = '';
	
	for (var i in param_array)
	{
		if (for_counter > 0)
		{
			var param_string = param_string+'&';
		}
		var param_string = param_string + i + '=' + encodeURIComponent(unescape(param_array[i]));
		
		for_counter++;
	}
	
	return (param_string);
}