function create_http_object()
{
	var ActiveXTypes = [
	"Microsoft.XMLHTTP",
	"MSXML2.XMLHTTP.5.0",
   "MSXML2.XMLHTTP.4.0",
   "MSXML2.XMLHTTP.3.0",
   "MSXML2.XMLHTTP"
   ];

      for( var i = 0; i < ActiveXTypes.length; i++ )
      	{
         try
            {
            	return new ActiveXObject( ActiveXTypes[i] );
            }
            catch( e )
            { }
        }

        try
          {
           	return new XMLHttpRequest();
          }
          catch( e )
          { }

	return false;
}

function make_request(url, callback_function, http_method, post_values, return_xml)
{
	http = create_http_object();

	if(!http)
        {
            alert('Je browser ondersteunt deze feature niet.');
            return false;
        }

        http.onreadystatechange = function()
        {
            if(http.readyState == 4)
            {
                if(http.status == 200)
                {
                    if(callback_function)
                    {
                        if(return_xml)
                        {
                            eval(callback_function + '(http.responseXML)');
                        }
                        else
                        {
                            eval(callback_function + '(http.responseText)');
                        }
                    }
                }
                else
                {
                    alert('Error! (' + http.status + ')');
                }
            }
        }

        if(!post_values)
        {
            post_values = null;
        }
        if(!http_method)
        {
            http_method = "GET";
        }

        http.open(http_method, url, true);

        if(http_method == "POST")
        {
            http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        }

	http.send(post_values);
}

function handle_response(result)
{
	document.getElementById('main_content').innerHTML = result;
}
