if (!Array.prototype.sortRandom) 
    Array.prototype.sortRandom = function() { this.sort(function(elmt1, elmt2) { return ((2 * Math.round(Math.random())) - 1) }); }

var sources = new Array("match1", "pieds", "adultes", "futsal"); // Ne pas mettre l'image initialisée dans le HTML
var bandeau = document.getElementById("bandeau");
var images  = makeUrl(sources);
texts2  = new Array(); // Liste des textes dans l'ordre aléatoire
var id      = 0;
var opacite = 0;
var affiche = 0;
var bandeauT= document.getElementById("bandeauT");
setTimeout("changeFond()", 5000);

function makeUrl(arrayImgIdx) {
	var preload = new Array();
	arrayImgIdx.sortRandom();
	for (var i=0; i<arrayImgIdx.length; i++){
		preload[i] = 'http://www.maisons-laffitte-football.com/img/bandeaux/'+arrayImgIdx[i]+'.jpg';
	}
	if(bandeau.src != "")
	{
		preload[preload.length] = bandeau.src;
	}
	else
	{
		bandeau.src = preload[(preload.length)-1];
	}
	return preload;
}

function setOpacity(obj,xOpacity){
  obj.style.opacity = xOpacity;
  obj.style.MozOpacity = xOpacity;
  obj.style.KHTMLOpacity = xOpacity;
  obj.style.filter = 'alpha(opacity=' + (xOpacity*100) + ')';
}

function transition(){
opacite += 0.07;
setOpacity(bandeauT, opacite);
if (opacite > 1){
	opacite = 0;
	bandeau.src = images[id];
	setOpacity(bandeauT, 0);
	}
else{
	var timerT  = setTimeout("transition()", 30);}
}

function changeFond() {
	setOpacity(bandeauT, 0);
	id++;
	if (id == images.length) id = 0;
	bandeauT.src = images[id];
	transition()
	var timerC  = setTimeout("changeFond()", 5000);
}

function GetId(id)
{
return document.getElementById(id);
}



function move(e) 
{
  if(affiche) 
  {  // Si la bulle est visible, on calcul en temps reel sa position ideale
    if (navigator.appName!="Microsoft Internet Explorer") 
    {
    GetId("infobulle").style.left=e.pageX + 5+"px";
    GetId("infobulle").style.top =e.pageY + 10+"px";
    }
    else 
    { 
		if(document.documentElement.clientWidth>0) 
		{
			GetId("infobulle").style.left=20+event.x+document.documentElement.scrollLeft+"px";
			GetId("infobulle").style.top=10+event.y+document.documentElement.scrollTop+"px";
		} 
		else 
		{
			GetId("infobulle").style.left=20+event.x+document.body.scrollLeft+"px";
			GetId("infobulle").style.top=10+event.y+document.body.scrollTop+"px";
		}
    }
  }
}

function note_montre() {
  if(affiche==false) {
  GetId("infobulle").style.display="block"; // Si il est cacher (la verif n'est qu'une securité) on le rend visible.
  GetId("infobulle").innerHTML = 'Diaporama photo<br /><em>Bientôt disponible : Cliquez sur l\'image pour voir l\'album '; // Cette fonction est a améliorer, il parait qu'elle n'est pas valide (mais elle marche)
  affiche=true;
  }
}

function note_cache() {
if(affiche==true) {
GetId("infobulle").style.display="none"; // Si la bulle etais visible on la cache
affiche=false;
}
}

function overBarre(i)
{
	menu = document.getElementById('item'+i);
	menu.style.display = 'block';
	barre = document.getElementById('barre');
	barre.style.height = "34px";
}
