
// ajax.js

function ajaxSupported()
{
	// restituisce true se ajax è supportato	
	var o = null;
	o = getXmlHttpRequestObject();
	
	return (o != null);
}

function ajaxSend(method, url)
{
	// send sincrono
	var oXmlHttp = getXmlHttpRequestObject();	// istanzia xmlhttprequest
   	oXmlHttp.open(method, url, false);		    // send sincrono
    oXmlHttp.send(null);
	return oXmlHttp.responseText;			    // restituisce response
}

function getXmlHttpRequestObject()
{
	// funzione cross-browser per istanziare xmlHttpRequest
	// se handler != '' imposta handler per gestione evento readystatechange
    /*
        0: uninitialized
		1: loading
		2: loaded
		3: interactive
		4: complete 
    */
	var xmlhttp = null;
  
	try
	{
		xmlhttp = new XMLHttpRequest();					// all new browsers including IE7
    }
	catch(e)
	{
    		try
    		{
        		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
		    catch(e)
		    {
        		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");	// IE5 and IE6
            }        		
  	}

  	return xmlhttp;
}
