function doHTTP(url, callback_function, element_id, return_xml)
{
    var http_request = false;

    if (window.XMLHttpRequest)
	{ // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType)
			http_request.overrideMimeType('text/xml');
   	}
	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, element_id)'); }
                else			{ eval(callback_function + '(http_request.responseText,element_id)'); }
           	}
			else
			{
                alert('There was a problem with the request.(Code: ' + http_request.status + ')');
           	}
       	}
   	}
    http_request.open('GET', url, true);
    http_request.send(null);
}
	
/**
 * Make an HTTP request and return XML data to a callback function
 */

function ajaxXML (params, container, no_callback)
{
	callback_function = 'makeXMLCallback';
	if (isNaN(no_callback) || no_callback == '')
	{
		callback_function = 'makeXML';
	}
	doHTTP('/utpc_ajax_xml.php?'+params, callback_function, container, 1);
}

/**
 * Parse result and call callback function defined in "method"
 */

function makeXMLCallback (s, elem)
{
    result = s.getElementsByTagName('result')[0].firstChild.nodeValue;
    method = s.getElementsByTagName('method')[0].firstChild.nodeValue;
	s = ''+method+'("'+result+'", "'+elem+'")';
	eval(s);
}

/**
 * Parse result and display it in the provided element (div)
 */

function makeXML (s, elem)
{
	r = s.getElementsByTagName('result')[0].firstChild;
	if (r && elem != '' && typeof(elem) != "undefined")
	{
		getRef(elem).innerHTML = r.nodeValue;
		if (getSty(elem).display == 'none')
		{
			getSty(elem).display = "block";
		}
	}
}


