// JavaScript Document
function Lancer(url,nom,largeur,hauteur,options) {
		var haut=(screen.height-hauteur)/2;
		var Gauche=(screen.width-largeur)/2;
		fencent=window.open(url,nom,"top="+haut+",left="+Gauche+",width="+largeur+",height="+hauteur+","+options);
};

function ecrire_cookie(nom, valeur, expires) {
  document.cookie=nom+"="+escape(valeur)+
  ((expires==null) ? "" : ("; expires="+expires.toGMTString()));
};

function ajax(div,url,temps) { 
        $.ajax({ 
          url: url, 
          cache: false,
          success: function(html){ 
            $(div).html(html);
             setTimeout('ajax("' + div + '","' + url + '","' + temps + '");',temps); 
          }, 
          error:function(XMLHttpRequest, textStatus, errorThrown){ 
            //alert(textStatus); 
          } 
          }) 
          return false; 
 }
 
function ajaxbis(div,url,temps) { 
        $.ajax({ 
          url: url, 
          cache: false,
          success: function(html){ 
            $(div).html(html);
             //setTimeout('ajax("' + div + '","' + url + '","' + temps + '");',temps); 
          }, 
          error:function(XMLHttpRequest, textStatus, errorThrown){ 
            //alert(textStatus); 
          } 
          }) 
          return false; 
 } 


function boardExtra(){
    var xhr; 
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }
 
    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
              if(xhr.status  == 200) 
                 document.getElementById("board").innerHTML= xhr.responseText; 
              else 
                 CloseExtra();
				 //document.getElementById("board").innerHTML ="Error code " + xhr.status;
         }
		 setTimeout("boardExtra();",20000);
    }; 

   xhr.open("GET", "./extra/code.php?x=board",  true); 
   xhr.send(null); 
};
function writeExtra(msg){
    var xhr; 
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }
 
    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
              if(xhr.status  == 200)
                //alert(xhr.responseText); 
				boardExtra(); 
              else 
                alert("Error code " + xhr.status);
         }
    }; 

   xhr.open("GET", "./extra/code.php?x=write&msg="+msg,  true); 
   xhr.send(null);
};

function showExtra(){
	var extra = document.getElementById("extra");
	extra.style.width = "350px";
	extra.style.height = "500px";
	extra.innerHTML = "<div class='e_titre'><a href='javascript:closeExtra();'>discussion en direct <img src='images/e_close.png' valign='middle'></a></div><div id='board'>board</div><div id='write'><textarea id='extraMSG' ></textarea><a href='javascript:writeExtra(document.all.extraMSG.value);clear();'>Poster !</a></div></div>";
	boardExtra();
};

function closeExtra(){
	var extra = document.getElementById("extra");
	extra.style.width = "200px";
	extra.style.height = "30px";
	extra.innerHTML = '<a href="javascript:showExtra();"><img src="images/extra.png" width="200" height="30" border="0px" /></a>';
};

function clear(){
	document.all.extraMSG.value ='';
};



