function getHTTPObject()
{
  var xmlhttp = false;

  /* Compilation conditionnelle d'IE */
  /*@cc_on
  @if (@_jscript_version >= 5)
     try
     {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     }
     catch (e)
     {
        try
        {
           xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (E)
        {
           xmlhttp = false;
        }
     }
  @else
     xmlhttp = false;
  @end @*/

  /* on essaie de créer l'objet si ce n'est pas déjà fait */
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
  {
     try
     {
        xmlhttp = new XMLHttpRequest();
     }
     catch (e)
     {
        xmlhttp = false;
     }
  }
  return xmlhttp;
}

function http_ping(url,session)
{
	var xmlhttp_ping = getHTTPObject(); 
	xmlhttp_ping.open("POST", url, true); 
	xmlhttp_ping.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlhttp_ping.send('Action=Q_PING&session='+session);
}

function disableForm(form,disabled)
{
	if(!defined(form.disabled2))
		form.disabled2=0;
	if(disabled)
	{
		if(++form.disabled2>1)
			return;
	}
	else
	{
		if(--form.disabled2>0)
			return;
		form.disabled2=0;
	}
	for(var i = 0; i < form.elements.length; i++)
	{
		if(disabled)
		{
			form.elements[i].disabled2 = form.elements[i].disabled;
			form.elements[i].disabled = true;
		}
		else
		{
			form.elements[i].disabled = form.elements[i].disabled2;
		}
	}
}

function disableForms(disabled)
{
	disableForm(getContext().forms["parameters"],disabled);
	for(var i = 0; i < parent.frames.length; i++)
		if(parent.frames[i].name.indexOf("sellist_")==0)
			if(defined(parent.frames[i].document.forms['list']))
				disableForm(parent.frames[i].document.forms['list'],disabled);
}

function http_js(url,args,async)
{
	var xmlhttp_js = getHTTPObject(); 
	xmlhttp_js.open("POST", url, !is.ie||async==null||async==true); 
	disableForms(true);
	xmlhttp_js.onreadystatechange = function()
	{ 
		try
	    {
			if(xmlhttp_js.readyState == 4 && xmlhttp_js.status == 200) 
			{
				disableForms(false);
				//alert(xmlhttp_js.responseText);
			    eval(xmlhttp_js.responseText); 
			}
		}
		catch(e)
		{
			alert("http_js:"+e.message+"=>"+xmlhttp_js.responseText);
			disableForms(false);
		}
	} 
	xmlhttp_js.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlhttp_js.send(args);
}

function http_html(elt,url,args)
{
	var xmlhttp_html = getHTTPObject(); 
	xmlhttp_html.open("POST", url, true); 
	xmlhttp_html.onreadystatechange = function()
	{ 
		try
	    {
			if(xmlhttp_html.readyState == 4 && xmlhttp_html.status == 200) 
			{
				//alert(xmlhttp_html.responseText);
			    elt.innerHTML=xmlhttp_html.responseText; 
			}
		}
		catch(e)
		{
			alert("http_html:"+e.message);
		}
	} 
	xmlhttp_html.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlhttp_html.send(args);
}

