var page_to_call = '/statistics/';
var request_type = "POST";


function ajax_init_object()
{
    var obj_ajax;
    
    var msxmlhttp = new Array(
	                'Msxml2.XMLHTTP.5.0',
				    'Msxml2.XMLHTTP.4.0',
				    'Msxml2.XMLHTTP.3.0',
				    'Msxml2.XMLHTTP',
				    'Microsoft.XMLHTTP');
				    
    for (var i = 0; i < msxmlhttp.length; i++)
    {
        try
        {
            obj_ajax = new ActiveXObject(msxmlhttp[i]);
        } 
            catch (e)
        {
            obj_ajax = null;
        }
    }

    // Mozilla / Firefox
    if(!obj_ajax && typeof XMLHttpRequest != "undefined")
    {
        obj_ajax = new XMLHttpRequest();
        obj_ajax.overrideMimeType('text/plain');
    }

	return obj_ajax;
} // End of function ajax_init_object


function ajax_do_call(args)
{
    
    
    var i, x;
	var post_data;

    // AJAX request type = POST
	post_data = "rsrnd=" + new Date().getTime();

	for (i = 0; i < args.length; i++) 
	   post_data = post_data + "&rsargs[" + i + "]=" + escape(args[i]);

	obj_ajax = ajax_init_object();

    if (obj_ajax != null)
    {
        obj_ajax.open(request_type, page_to_call, false); // Async mode

		obj_ajax.setRequestHeader("Method", request_type + " " + page_to_call + " HTTP/1.1");
		obj_ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    	obj_ajax.send(post_data);
    	delete obj_ajax;
    }

	return true;
}

function register_click()
{
    var arr = new Array(document.getElementById('carCountry').options[document.getElementById('carCountry').selectedIndex].text, 
                 document.getElementById('carCity').options[document.getElementById('carCity').selectedIndex].text);
    ajax_do_call(arr);
}
