// Website Deprez.org Deprez.info
// Webmaster : Jean-Pierre DEPREZ
// File : ajax.js
// Purpose : Miscellaneous functions for xhrHttpRequest object


function request(url,divlocation)
{
	var xhr = null;
        // Firefox
	if(window.XMLHttpRequest)
        {
                xhr = new XMLHttpRequest();
        }
        // Internet Explorer
	else if(window.ActiveXObject)
        {
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
        }
	else
        {
                try
                {
                        xhr = new ActiveXObject('Msxml2.XMLHTTP');
                }
                catch (e) 
                {
                        // XMLHttpRequest is not available for the browser
                        alert("404 error");
                        return;
                }
	}
	// Send the request
	xhr.open("GET",url, true);

	// on guette les changements d'Žtat de l'objet
	xhr.onreadystatechange = function wait()
                        {
                                // state is 4, request is finished
                                if(xhr.readyState == 4)
                                {
                                        if(xhr.status  == 200)
                                        {
                                                // Load the request result in the document
                                                document.getElementById(divlocation).innerHTML = xhr.responseText;
                                        }
                                        else
                                        {
                                                alert("Error");
                                        }
                                }
                        }
        // End of request
	xhr.send(null);		
	return;
}