/*function refresh_div()
{
var xhr_object = null;
if(window.XMLHttpRequest)
{ // Firefox
xhr_object = new XMLHttpRequest();
}
else if(window.ActiveXObject)
{ // Internet Explorer
xhr_object = new ActiveXObject('Microsoft.XMLHTTP');
}
var method = 'POST';
var filename = 'ajax.ressources.php';
xhr_object.open(method, filename, true);
xhr_object.onreadystatechange = function()
{
if(xhr_object.readyState == 4)
{
var tmp = xhr_object.responseText;
document.getElementById('mon_div').innerHTML = tmp;
}
}
xhr_object.send(null);
setTimeout('refresh_div()', 1500);
}*/
 /*function ejs_box2_go()
     {
     if(document.getElementById)
         {
         ejs_box2_char = 1;
         ejs_box2_affich(ejs_box2_actual)
         ejs_box2_actual++;
         if(ejs_box2_actual >= ejs_box2_message.length)
             ejs_box2_actual = 0;
         }        
     }
 
 function ejs_box2_affich(lactual)
     {
     var pix = ejs_box2_message[lactual].charAt(ejs_box2_char);
     if(pix == "<")
         ejs_box2_html_flag = 1;
     if(pix == ">")
         ejs_box2_html_flag = 0;
     var texte = ejs_box2_message[lactual].substring(0,ejs_box2_char);
     document.getElementById("ejs_box2_box").innerHTML = texte;
     if(ejs_box2_char < ejs_box2_message[lactual].length)
         {
         ejs_box2_char++;
         if(ejs_box2_html_flag == 1)    
             ejs_box2_affich(lactual);
         else
             setTimeout("ejs_box2_affich("+lactual+")",50)
         }
     else
         setTimeout("ejs_box2_go()",3000)
     }*/
	  // <![CDATA[
function setContainerSize(truc) {
	var navroot = document.getElementById(truc);
	if ( navroot ) {
		var lis = navroot.getElementsByTagName("div");
		/* XXX : y a-t-il un moyen plus simple de ne détecter que les divs de rang 1 ?
		 *       ou, détecter selon une classe ? */
		var ok = 0; var nok = 0;
		for ( i = 0; i < lis.length; i++ ) {
			if ( lis[i].parentNode != navroot )
				nok++;
			else
				ok++;
		}
		navroot.style.width = ok * 70 + 10 + 'px';
	}
}
 // ]]>
/************************************************/
function redesign()
{
	var cont2 = document.getElementById("cont2");
	var cont1 = document.getElementById("cont1");
	var tav3 = document.getElementById('tav3');

	var alert1 = cont2.offsetHeight+20;

	if (cont1.offsetHeight > alert1){
		var alert1 = cont1.offsetHeight;
	}

	if (tav3.offsetHeight+100 > alert1){
		var alert1 = tav3.offsetHeight+100;
	}

	var alert2 = alert1+252;

	var menu1 = document.getElementById('menu1');
	var menu2 = document.getElementById('menu2');
	var tav2 = document.getElementById('tav2');
	var tav1 = document.getElementById('tav1');

	menu1.style.height = alert1+"px";
	menu2.style.height = alert1+"px";
	tav1.style.height = alert2+"px";
	tav2.style.height = alert2+"px";
	cont1.style.height = alert1+"px";
	cont2.style.height = alert1+"px";
}

function refresh_even()
{
var xhr_object = null;
if(window.XMLHttpRequest)
{ // Firefox
xhr_object = new XMLHttpRequest();
}
else if(window.ActiveXObject)
{ // Internet Explorer
xhr_object = new ActiveXObject('Microsoft.XMLHTTP');
}
var method = 'POST';
var filename = 'ajax.evenements.php';
xhr_object.open(method, filename, true);
xhr_object.onreadystatechange = function()
{
if(xhr_object.readyState == 4)
{
var tmp = xhr_object.responseText;
document.getElementById('evenements').innerHTML = tmp;
}
}
xhr_object.send(null);
setTimeout('refresh_even()', 2500);
}


function return_height()
{
var taverne_height=document.body.offsetHeight;
document.getElementById('taverne').height=taverne_height;
}



function PostSelect(liste){
// On compte le nombre d'item de la liste select
NbCol1 = document.forms[liste].elements.Col1.length;

// On lance une boucle pour selectionner tous les items
for(a=0; a<NbCol1; a++){
document.forms[liste].elements.Col1.options[a].selected = true;
}

// On modifie l'ID du champ select pour que PHP traite cette
// dernière comme un array
document.forms[liste].elements.Col1.name = "Col1[]";

// On soumet le formulaire
document.forms[liste].submit();
}



// Script réalisé par Eric Marcus - 2005
function TriListe(idNomListe,sens)
{	var objListe = document.getElementById(idNomListe);
	if (objListe.options.selectedIndex<0) return false;
	var objLigneADéplacer = new Option(objListe.options[objListe.options.selectedIndex].text, objListe.options[objListe.options.selectedIndex].value);
	var iPositionAvant = objListe.options.selectedIndex;
	var iPositionApres=(sens=="+")?iPositionAvant+1:iPositionAvant-1;
	if ((iPositionApres>=objListe.length)||(iPositionApres<0)) return false;
	var objLigneAChanger = new Option(objListe.options[iPositionApres].text, objListe.options[iPositionApres].value);
	objListe.options[iPositionAvant] = objLigneAChanger;
	objListe.options[iPositionApres] = objLigneADéplacer;
	objListe.options[iPositionApres].selected=true;
	objListe.focus();
}

	function doResize()
	{
		if (parseInt(navigator.appVersion)>3) {
			if (navigator.appName=="Netscape") {
			winW = window.innerWidth;
			winH = window.innerHeight;
			}
			if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
			}
		}
		document.image1.height= winH - 191;
	}
	

	function str_replace(a, b, str) {
    return str_replace2(str, a, b);
}
function str_replace2(SRs, SRt, SRu) {
  /*
  **  Replace a token in a string
  **    s  string to be processed
  **    t  token to be found and removed
  **    u  token to be inserted
  **  returns new String
  */
  SRRi = SRs.indexOf(SRt);
  SRRr = '';
  if (SRRi == -1) return SRs;
  SRRr += SRs.substring(0,SRRi) + SRu;
  if ( SRRi + SRt.length < SRs.length)
    SRRr += str_replace2(SRs.substring(SRRi + SRt.length, SRs.length), SRt, SRu);
  return SRRr;
}

function rep(text) {
        text = str_replace('_', ' ', text) + ' ';
                document.forms['post'].message.value  = text + '>';
                document.forms['post'].message.focus();
}



