//General Ajax function related to any Ajax library call
var debug = false;

function GetXmlHttp() {
  var xmlhttp = false;
  if (window.XMLHttpRequest)
  {
    xmlhttp = new XMLHttpRequest()
  }
  else if (window.ActiveXObject)
  {
    try
    {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
    } catch (e) {
      try
      {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
      } catch (E) {
        xmlhttp=false
      }
    }
  }
  return xmlhttp;
}

function PassAjaxResponseToFunction(url, callbackFunction, params, nbrOfTry)
{
	
	if (nbrOfTry)
		nbrOfTry++
	else
		nbrOfTry = 1

	//document.write (url)
	//url= url + '&encodingMode=' + encodingMode
  var xmlhttp = new GetXmlHttp();
  if (xmlhttp)
  {
    xmlhttp.onreadystatechange = 
            function ()
            {	
				
			  if (xmlhttp && xmlhttp.readyState==4)
              {
				//alert(xmlhttp.status + url)
                if (xmlhttp.status==200)
                {
				 
				 var response = xmlhttp.responseText
				 
                 //je ne crois pas que ce truc a encore une raison d'etre la mais si jamais c'est la cas faut changer le split element
                 //if(!debug)
					//if(response.indexOf('*****') > 0)
						//response = response.substring(0, response.indexOf('*****'))
                   
				  
				 var functionToCall = callbackFunction + 
                                 '(response,'+params+')';
                  if(debug)
                  {
                    alert(response);
                    alert(functionToCall);
                  }
                 				  
                  eval(functionToCall);
                } else if(debug){
                  document.write(xmlhttp.responseText);
                }
                else
                {
					//errorProcess('PassAjaxResponseToFunction("' + url + '", "' + callbackFunction + '", "' + params + '", ' + nbrOfTry + ')', nbrOfTry)
					//return(xmlhttp.status)
				}

              }
            }
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
  }
}

function errorProcess(content, nbrOfTry)
{
	alert('error')
	if (nbrOfTry<3)
	{
		eval(content);
	}
	else
	{
		//eventually do something
	}
}
