




function shake(n) {
if (parent.moveBy) {
for (i = 10; i > 0; i--) {
for (j = n; j > 0; j--) {
parent.moveBy(0,i);
parent.moveBy(i,0);
parent.moveBy(0,-i);
parent.moveBy(-i,0);
         }
      }
   }
}  




  window.fbAsyncInit = function() {
    FB.init({appId: 'your app id', status: true, cookie: true,
             xfbml: true});
  };
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
      '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
  }());


var DHTML = (document.getElementById || document.all || document.layers);
function ap_getObj(name)
{
        if (document.getElementById)
        {
                return document.getElementById(name).style;
        }
        else if (document.all)
        {
                return document.all[name].style;
        }
        else if (document.layers)
        {
                return document.layers[name];
        }
}
 
function ap_showWaitMessage(div, flag)
{
        if (!DHTML) return;
        var x = ap_getObj(div);
        x.visibility = (flag) ? 'visible':'hidden'
        if(! document.getElementById)
                if(document.layers)
                        x.left=280/2;
        return true;
}
 
ap_showWaitMessage('waitDiv', 1);


function fbs_click(u,t) {
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	pageTracker._trackEvent("Actions", "Facebook", u);
	return false;

}

function request(url,cadre,ancre) {

request2('/load.php',cadre,ancre);

window.location.hash=ancre;
	
	var XHR = null;

	if(window.XMLHttpRequest) // Firefox
		XHR = new XMLHttpRequest();
	else if(window.ActiveXObject) // Internet Explorer
		XHR = new ActiveXObject("Microsoft.XMLHTTP");
	else { // XMLHttpRequest non supporté par le navigateur
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		return;
	}
		// envoie de la requête, methode GET et de l'url
	XHR.open("GET",url, true);

		// on guette les changements d'état de l'objet
	XHR.onreadystatechange = function attente() {

		// l'état est à 4, requête reçu !
	if(XHR.readyState == 4)     {

		// ecriture de la réponse
	document.getElementById(cadre).innerHTML = XHR.responseText;
   }
	}
	XHR.send(null);		// le travail est terminé
	return;
}
function request2(url,cadre,ancre) {

window.location.hash=ancre;
	
	var XHR = null;

	if(window.XMLHttpRequest) // Firefox
		XHR = new XMLHttpRequest();
	else if(window.ActiveXObject) // Internet Explorer
		XHR = new ActiveXObject("Microsoft.XMLHTTP");
	else { // XMLHttpRequest non supporté par le navigateur
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		return;
	}
		// envoie de la requête, methode GET et de l'url
	XHR.open("GET",url, true);

		// on guette les changements d'état de l'objet
	XHR.onreadystatechange = function attente() {

		// l'état est à 4, requête reçu !
	if(XHR.readyState == 4)     {

		// ecriture de la réponse
	document.getElementById(cadre).innerHTML = XHR.responseText;
   }
	}
	XHR.send(null);		// le travail est terminé
	return;
}






window.onload = function() {
	if (document.location.hash.length > 1) {
		page = "t65_illusions.php?id="+window.location.hash.split("#")[1];
		request(page,'illusions_area',window.location.hash);
	}
	}

function resultats(reponse,id)
{
  var OAjax;
  if (window.XMLHttpRequest) OAjax = new XMLHttpRequest();
  else if (window.ActiveXObject) OAjax = new ActiveXObject('Microsoft.XMLHTTP');
  OAjax.open('POST',"stats.php?t="id"",true);
  OAjax.onreadystatechange = function()
  {
      if (OAjax.readyState == 4 && OAjax.status==200)
      {
          if (document.getElementById)
          {   
              if (OAjax.responseText =='true') { /* OK */
                    document.getElementById('msg').innerHTML=''+OAjax.responseText+'';
              }else{                             /* PAS OK */
                    document.getElementById('msg').innerHTML=''+OAjax.responseText+'';
              }
          }     
      }
  }
  OAjax.setRequestHeader('Content-type','application/x-www-form-urlencoded');
  OAjax.send('reponse='+reponse);                 
} 
	
	function email(nom,email,objet,message,area)
{
  var OAjax;
  if (window.XMLHttpRequest) OAjax = new XMLHttpRequest();
  else if (window.ActiveXObject) OAjax = new ActiveXObject('Microsoft.XMLHTTP');
  OAjax.open('POST',"/formulaire_contact.php",true);
  OAjax.onreadystatechange = function()
  {
      if (OAjax.readyState == 4 && OAjax.status==200)
      {
          if (document.getElementById)
          {   
              if (OAjax.responseText =='true') { /* OK */
                    document.getElementById(area).innerHTML='<font>'+OAjax.responseText+'</font>';
              }else{                             /* PAS OK */
                    document.getElementById(area).innerHTML='<font>'+OAjax.responseText+'</font>';
              }
          }     
      }
  }
  OAjax.setRequestHeader('Content-type','application/x-www-form-urlencoded');
  OAjax.send('nom='+nom+'&email='+email+'&objet='+objet+'&message='+message);                 
}  

function AfficherOuCacher(obj)
	{
	if (Visible == false) // SI L'OBJET N'EST PAS VISIBLE
		{
		Afficher(obj) // RENVOIE A LA FONCTION AFFICHER
		}
	else // SINON
		{
		Cacher(obj) // RENVOIE A LA FONCTION CACHER
		}
	}

function Afficher(obj)
	{
	var id = 'boutton'+obj;
	document.getElementById(obj).style.display = ''; // AFFICHE LE COMPOSANT
	document.getElementById(id).innerHTML = '<a onclick="AfficherOuCacher();" style="cursor:pointer;" id="'+id+'">Cacher</a>'; // CHANGE "AFFICHER" EN "CACHER"
	Visible = true; // OBJET EST MAINTENANT VISIBLE
	}
	
function Cacher(obj)
	{
	var id = 'boutton'+obj;
	document.getElementById(obj).style.display = 'none'; // CACHE LE COMPOSANT
	document.getElementById(id).innerHTML = '<a onclick="AfficherOuCacher();" style="cursor:pointer;" id="'+id+'">Afficher</a>'; // CHANGE "CACHER" EN "AFICHER"
	Visible = false; // OBJET EST MAINTENANT CACHE
	}
	
