// JavaScript Document

var tempsClignote = 60;
var etatClignote = 0;
var aClignote = new Array();

// fonction d'initialisaton qui recupere tous les styles 
// des classes clignote
//  appeler par la fonction  onload="init();" 

function setClignote() {
	//Si la fonction  getElementsByTagName()  n'est pas supporte
	// ce n'est pas la peine d'aller plus loin !
		if (document.getElementsByTagName) {
		aClignote = retourne_classes ("clignote"); 
		boucle ();
	}
}

// routine excute en boucle qui change l'tat des styles
//  visibility  entre  hidden  et  visible 
function boucle () {
	if (etatClignote){
		for (i = 0; i < aClignote.length; i++)
			aClignote[i].visibility = "hidden";
		etatClignote = 0;
		tempsClignote = 200;
	} else { 
		for (i = 0; i < aClignote.length; i++)
			aClignote[i].visibility = "visible";
		etatClignote = 1;
		tempsClignote = 900;
	}
	setTimeout("boucle()",tempsClignote);
}

// fonction qui retourne tous les styles du classe donne
function retourne_classes (nom_classe) {
	var j = 0;
	var a_resultats = new Array ();
	var aBalises = document.getElementsByTagName ("*"); 
	for (i = 0; i < aBalises.length; i++) {
		if (aBalises[i].className == nom_classe) { 
			a_resultats[j++] = aBalises[i].style;
		}
	}
	return a_resultats;
}




timer=0;
var x;
//x=0; //donner ici la position initiale du calque

function init_timer(){
	timer=1;
}
 
function stop_timer(){
	timer=0;
}
 
function avant(max,calq){
	maximum=max;
	calque=calq;
if (document.getElementById){
	document.getElementById(calque).style.left=x + 'px';
	//document.getElementById("ejs_texte").innerHTML = x +" :-: "+ max +" :-: "+ document.getElementById("listImgG").style.left;
	}
if (document.all && !document.getElementById){
	document.all.style.left=x + 'px';
	}
if (document.layers){
	document.layers.left=x + 'px';
	}
if(timer==1 && x<maximum){
	setTimeout("avant(maximum,calque)",40);
	x+=7;
	}
}

function arriere(max,calq){
	maximum=max;
	calque=calq;
if (document.getElementById){
	document.getElementById(calque).style.left = x + 'px';
	//document.getElementById("ejs_texte").innerHTML = x +" :-: "+ max + ":-:" +document.getElementById(calque).style.left;
	}
if (document.all && !document.getElementById){
	document.all.style.left = x + 'px';
	}
if (document.layers){
	document.layers.left = x + 'px';
	}
if(timer==1 && x>maximum){
	setTimeout("arriere(maximum,calque)",40);
	x-=7;
	}
}

function setBanCenter() {
	if (document.getElementById){
		var banniere = document.getElementById("listImgG");
		var largBan = banniere.offsetWidth;
		x= -1*(largBan-document.getElementById('cacheG').offsetWidth)/2;
		/*if(x>0) x=0;*/
		document.getElementById("listImgG").style.left = x + 'px';
		//document.getElementById("ejs_texte").innerHTML = x +" :-: " + document.getElementById("listImgG").style.left;
	}
	if (document.all && !document.getElementById){
		document.all.style.left = x + 'px';
	}
	if (document.layers){
		document.layers.left = x + 'px';
	}
}
		

/*** code menu gauche ***/
function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	} else {
		if (document.documentElement && document.documentElement.clientHeight) {
					windowHeight = document.documentElement.clientHeight;
				}

				else {
					if (document.body && document.body.clientHeight) {
						windowHeight = document.body.clientHeight;
					}
				}
	}
	return windowHeight;
}
function setGauche() {

	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		//var windowHeight = document.documentElement.clientHeight;
		//alert(windowHeight);
		if (windowHeight > 0) {
			var menuGauche = document.getElementById('leftMenu');
			var h = menuGauche.offsetHeight;
			
			if ((windowHeight - h >= 0) && document.documentElement.scrollTop > 155 ) {
				menuGauche.style.position = 'absolute';
				
				if(document.documentElement.scrollTop > 155) {
					menuGauche.style.top = document.documentElement.scrollTop + 'px';
				} else {
					menuGauche.style.top = '155 px';
				}
			} else {
				menuGauche.style.position = 'absolute';
				menuGauche.style.top = '155 px';
			}
		}
	}
}

window.onload = function() {
	
	//setGauche();
	//setMinMax();
	if(document.getElementById('cacheG')) {
		setBanCenter();
	}
	setClignote();
}

window.onresize = function() {
	//setGauche();
	//setMinMax();
	if(document.getElementById('cacheG')) {
		setBanCenter();
	}
}

window.onscroll = function() {
	//setGauche();
}





function ouvrirFenetre(adresse,nomPage,w,h,ws,fs) {
	var opt;
	//alert(navigator.appName);
	if (navigator.appName == "Netscape") {
		opt = "toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,scrollbars="+ws+",width="+screen.width+",height="+screen.height;
	} else {
		opt = "toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,fullscreen=1,scrollbars=0";
	}
	var popup = window.open(adresse, nomPage, opt);
	if(popup.focus){popup.focus();}
}


function expand(el) {
	whichEl=document.getElementById(el);
	if (whichEl.style.display == 'none'){
		whichEl.style.display = 'block';
	}
	else{
		whichEl.style.display = 'none';
	}
}

