function getXMLHTTP() {
    var xhr=null;
    if(window.XMLHttpRequest) // Firefox et autres
        xhr = new XMLHttpRequest();
    else if(window.ActiveXObject){ // Internet Explorer
        try {
            xhr = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xhr = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e1) {
      		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
          xhr = null;
      }
        }
    }
    return xhr;
}

function show_interface()
{
	document.getElementById('interface_popup').style.display = '';
}

function hide_interface()
{
	document.getElementById('interface_popup').style.display = 'none';
}

function interface_put(content)
{
    document.getElementById('itop').innerHTML = 'Avertissement';
    document.getElementById('icontent').innerHTML = content;
}

function interface_load(link, title, erase, city)
{
    if (city == 'paris/')
      link = 'http://www.zepeople.com/' + link;
    else if (city == 8)
      link = 'http://bordeaux.zepeople.com/' + link;
    else if (city == 12)
      link = 'http://lille.zepeople.com/' + link;
    else if (city == 13)
      link = 'http://orleans.zepeople.com/' + link;
    else if (city == 10)
      link = 'http://lyon.zepeople.com/' + link;
    else if (city == 11)
      link = 'http://nantes.zepeople.com/' + link;
    else if (city == 1)
      link = 'http://www.zepeople.com/' + link;
    else
      link = 'http://www.zepeople.com/' + link;
    if (erase == null)
      document.getElementById('icontent').innerHTML = '';
    document.getElementById('interface_popup').style.width = '434px';
    document.getElementById('interface_popup').style.height = '221px';
    document.getElementById('interface_popup').style.marginTop = '-180px';
    document.getElementById('interface_popup').style.marginLeft = '-217px';
    document.getElementById('itop').innerHTML = title;
    if (link.length > 0)
        {
            var xhr = getXMLHTTP();
            xhr.onreadystatechange = function() {

            if (xhr.readyState == 4 && xhr.status == 200)
            {
                setInnerHTML(document.getElementById('icontent'), xhr.responseText);
            }
        }
        xhr.open("GET", link, true);
        xhr.send(null);
    }
}

function interface_size_load(link, title, erase, city, width, height)
{

    if (city == 'paris/')
      link = 'http://www.zepeople.com/' + link;
    else if (city == 8)
      link = 'http://bordeaux.zepeople.com/' + link;
    else if (city == 12)
      link = 'http://lille.zepeople.com/' + link;
    else if (city == 13)
      link = 'http://orleans.zepeople.com/' + link;  
    else if (city == 10)
      link = 'http://lyon.zepeople.com/' + link;
    else if (city == 11)
      link = 'http://nantes.zepeople.com/' + link;
    else if (city == 1)
      link = 'http://www.zepeople.com/' + link;
    else
      link = 'http://www.zepeople.com/' + link;
    if (erase == null)
      document.getElementById('icontent').innerHTML = '';
    document.getElementById('interface_popup').style.width = width+'px';
    document.getElementById('interface_popup').style.height = height+'px';
    document.getElementById('interface_popup').style.marginTop = '-'+(height/2)+'px';
    document.getElementById('interface_popup').style.marginLeft = '-'+((width+50)/2)+'px';
    document.getElementById('itop').innerHTML = title;
    if (link.length > 0)
        {
            var xhr = getXMLHTTP();
            xhr.onreadystatechange = function() {

            if (xhr.readyState == 4 && xhr.status == 200)
            {
                setInnerHTML(document.getElementById('icontent'), xhr.responseText);
            }
        }
        xhr.open("GET", link, true);
        xhr.send(null);
    }
}

function uinterface_load(link, id, city)
{
    if (city == 'paris/')
      link = 'http://www.zepeople.com/' + link;
    else if (city == 8)
      link = 'http://bordeaux.zepeople.com/' + link;
    else if (city == 12)
      link = 'http://lille.zepeople.com/' + link;
    else if (city == 13)
      link = 'http://orleans.zepeople.com/' + link;
    else if (city == 10)
      link = 'http://lyon.zepeople.com/' + link;
    else if (city == 11)
      link = 'http://nantes.zepeople.com/' + link;
    else if (city == 1)
      link = 'http://www.zepeople.com/' + link;
    else
      link = 'http://www.zepeople.com/' + link;

    document.getElementById(id).style.display = 'inline';
    document.getElementById(id).innerHTML = '';
    if (link.length > 0)
        {
            var xhr = getXMLHTTP();
            xhr.onreadystatechange = function() {

            if (xhr.readyState == 4 && xhr.status == 200)
            {
                setInnerHTML(document.getElementById(id), xhr.responseText);
            }
        }
        xhr.open("GET", link, true);
        xhr.send(null);
    }
}

function setInnerHTML(divContent, HTML)
{
  divContent.innerHTML = HTML;
  var All = divContent.getElementsByTagName("*");
  for (var i = 0; i < All.length; i++)
    {
       All[i].id = All[i].getAttribute("id");
       All[i].name = All[i].getAttribute("name");
       All[i].className = All[i].getAttribute("class");
    }
  var AllScripts = divContent.getElementsByTagName("script");
  for (var i = 0; i < AllScripts.length; i++)
    {
       var s = AllScripts[i];
       if (s.src && s.src != "")
         eval(getFileContent(s.src));
       else
         eval(s.innerHTML)
    }
}

var pickRecentProgID = function (idList)
{
  var bFound = false;
  for(var i = 0; i < idList.length && !bFound; i++)
    {
      try
        {
          var oDoc = new ActiveXObject(idList[i]);
          o2Store = idList[i];
          bFound = true;
        }
      catch (objException)
        {
        };
    };
  if (!bFound)
    throw ("Aucun ActiveXObject n'est valide sur votre ordinateur, pensez e r votre navigateur");
  idList = null;
  return (o2Store);
}

var GetXmlHttpRequest_AXO = null;

var GetXmlHttpRequest = function()
{
  if (window.XMLHttpRequest)
    return (new XMLHttpRequest());
  else if (window.ActiveXObject)
    {
      if (!GetXmlHttpRequest_AXO)
        GetXmlHttpRequest_AXO = pickRecentProgID(["Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"]);
      return (new ActiveXObject(GetXmlHttpRequest_AXO));
    }
  return (false);
}

function getFileContent(url)
{
//  var Xhr = GetXmlHttpRequest();
  var Xhr = getXMLHTTP();
  Xhr.open("GET", url, false);
  Xhr.send(null);
  return (Xhr.responseText);
}