function CreateRequest()
{
    var request = null;

    try
    {
        request = new XMLHttpRequest();
	}
    catch (trymicrosoft)
    {
        try
        {
            request = new ActiveXObject('Msxml2.XMLHTTP');
		}
        catch (othermicrosoft)
        {
            try
            {
                request = new ActiveXObject('Microsoft.XMLHTTP');
			}
            catch (failed)
            {
                request = null;
			}
        }
    }

    return request;
}

/**
 * Create the ajax url with the php script name
 *
 * @return (string)		the web url with the php script name
 */
function buildAjaxUrl()
{
	var host = 'http://' + window.location.host;

	// get current url path without the script name
	var pathParts = window.location.pathname.split( '/' );

	// last element before script name
	var siteSection = pathParts[(pathParts.length-2)];

	// all elements before siteSection
	var documentRoot = '/';
	for (var i=1; i<(pathParts.length-2); i++)
		documentRoot += pathParts[i]+'/';

	var ajaxUrl = host + documentRoot + 'inc/' + siteSection + '/';

	// get current section to build ajax script url
	var section = getUrlParameter('section');
	var action = getUrlParameter('action');

	ajaxUrl += section + "/" + action + "_ajax.php";

	return ajaxUrl;
}

/**
 * Function used to get the url parameter value
 *
 * @param (string) name		the url parameter name
 *
 * @return (string) 	the value of the parameter if exist.
 */
function getUrlParameter(name)
{
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if (results != null && results != "")
		return results[1];
	else
		return '';
}


/**
 * Add a body onLoad javascript function call
 *
 * @param (string) func			The function to call
 */
var onLoadFunctions = new Array();
function addLoadEvent(func)
{
	var oldonload = window.onload;

	if (typeof window.onload != 'function')
	{
		//alert(func);
		//alert('no onload');
		window.onload = func;
	}
	else
	{
		//alert('onload');
    	window.onload = function()
    	{
			if (onLoadFunctions.lenght >= 1)
			{
				// load la toute onLoadFunctions
				for (i=0; i<onLoadFunctions.lenght; i++)
				{
					onLoadFunctions(i);
					alert(onLoadFunctions(i));
				}
			}

      		func;
    	}
  	}

  	onLoadFunctions[onLoadFunctions.lenght] = func;
}
