var x1, x;
var parchemin, contenu, photo, oldparchemin, princ0, bdpage, cd, ouvert, couv, couv2, to, principale;
var code;

function init()
{
  ouvert = false;
  code = 0;
  parchemin = document.getElementById("parchemin");
  contenu = document.getElementById("contenu");
  photo = document.getElementById("photo");
  princ0 = document.getElementById("princ0");
  principale = document.getElementById("principale");
  bdpage = document.getElementById("bdpage");
  couv = document.getElementById("couv");
  couv2 = document.getElementById("couvd");
  envoieeven("init=init");
  cd = false;
}

function afficheparchemin()
{
  clearTimeout(to);
  if (ouvert) 
  {
   if (cd) {princ0.removeChild(oldparchemin); cd = false;}
   oldparchemin = parchemin.cloneNode(true);
   princ0.appendChild(oldparchemin); cd = true;
   oldparchemin.style.display = "block";
   contenu.innerHTML = "";
   x1 = 866;
   bdpage.style.left = (x1+51) + "px";
   bdpage.style.display = "block";
   parchemin.style.clip = "rect(0px, 871px, 514px, " + (x1+2) + "px)";
   to = setTimeout("agranditparchemin();", 25);
  }
  else afficheparchemin2()
}

function agranditparchemin()
{
  x1 = Math.max(1, x1 - 10);
  if (x1 > 1) to = setTimeout("agranditparchemin();", 50); else {princ0.removeChild(oldparchemin); cd = false; bdpage.style.display = "none"; parchemin.style.clip = "rect(0px, 871px, 514px, " + (x1+2) + "px)";}
  oldparchemin.style.clip = "rect(0px, " + (x1-1) + "px, 514px, 0px)";
  bdpage.style.left = (x1+51) + "px";
  parchemin.style.clip = "rect(0px, 871px, 514px, " + (x1+2) + "px)";
}

function afficheparchemin2()
{
  parchemin.style.display='block';
  couv.style.display='block';
  x = 0;
  x1 = Math.floor(921*(1+Math.cos(x))/2);
  parchemin.style.clip = "rect(0px, 871px, 514px, " + Math.min(Math.max(0,x1-10), 871) + "px)";
  principale.style.backgroundImage = "url('images/carte12.jpg')";
  couv.style.width = (x1 - 442)+"px";
  to = setTimeout("agranditparchemin2();", 25);
}

function agranditparchemin2()
{
  x = Math.min(3.1415, x + .06);
  x1 = Math.floor(921*(1+Math.cos(x))/2);
  if (x1 > 0) to = setTimeout("agranditparchemin2();", 50); else {ouvert = true; couv.style.display = "none"; couv2.style.display = "none"; principale.style.backgroundImage = "url('images/carte2.jpg')";}
  if (x1 > 475)
  {
   couv.style.width = (x1 - 442)+"px";
  }
  else
  {
   couv.style.display = "none";
   couv2.style.width = (475 - x1)+"px";
   couv2.style.left = (8 + x1)+"px";
  }
  parchemin.style.clip = "rect(0px, 871px, 514px, " + Math.min(Math.max(0,x1-10), 871) + "px)";
}


function fermeparchemin()
{
  parchemin.style.display = "none";
}

function envoieeven(commande)
{
  var xmlhttp = false;

  /*@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 @*/

  if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
  {
     try
     {
        xmlhttp = new XMLHttpRequest();
     }
     catch (e)
     {
        xmlhttp = false;
     }
  }

  if (xmlhttp)
  {
     xmlhttp.onreadystatechange = function()
     {
       if (xmlhttp.readyState == 4) if (xmlhttp.status == 200) {eval(xmlhttp.responseText);}
     }
     xmlhttp.open("POST", "jeu.php", true);
     xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
     xmlhttp.send("code=" + code + "&" + commande);
  }
  return xmlhttp;
}

function urlencode(str) {
 return escape(str).replace(/\+/g,'%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40');
}

