/**
* Main function to AJAX comunication 
*
* @param string url url to be called
* @param string callback_function function name that will process the data after receiving it
* @param string callback_function_data data to be sent to the callback function
* @param string method GET or POST
* @param string data to be sent
* @param boolean Should the data received be procesed as XML?
* @param boolean Asynchronous request (blocks if true)
* @return void
*/
function makeHttpRequest(url, callback_function, callback_function_data, method, data, return_xml, asynchronous)
{
	if (typeof(asynchronous) == "undefined" || asynchronous == true)
	{
		asynchronous = true;
	}
	else
	{
		asynchronous = false;
	}
	
   var http_request = false;
	if(method != 'GET')
	{
		method = 'POST';
	}

	
   if (window.XMLHttpRequest) 
   { // Mozilla, Safari,...
       http_request = new XMLHttpRequest();
       
       /*
       if (http_request.overrideMimeType) 
       {
			http_request.setRequestHeader('Content-Type', 'text/xml');   
			http_request.overrideMimeType('text/xml');
			http_request.overrideMimeType('application/x-www-form-urlencoded');
       }
       */
   } 
   else if (window.ActiveXObject) 
   { // IE
       try 
       {
           http_request = new ActiveXObject("Msxml2.XMLHTTP");
       } 
       catch (e) 
       {
           try 
           {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
           } 
           catch (e) 
           {}
       }
   }

   if (!http_request) 
   {
       //alert('Unfortunatelly you browser doesn\'t support this feature.');
       return false;
   }
   http_request.onreadystatechange = function() 
   {
       if (http_request.readyState == 4) 
       {
           if (http_request.status == 200) 
           {
               if (return_xml) 
               {
                   eval(callback_function + '(http_request.responseXML,callback_function_data)');
               } else 
               {
                   eval(callback_function + '(http_request.responseText,callback_function_data)');
               }
           } 
           else 
           {
               //alert('There was a problem with the request.(Code: ' + http_request.status + ')');
           }
       }
   }
   http_request.open(method, url, asynchronous);
   if(method == 'POST')
   {
   	//Use post method if you want to send any data
   	http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
   }
   else
   {
   	http_request.setRequestHeader('Content-Type', 'text/html');
   }
   	http_request.send(data);
}