var bandeauClass;
if (!bandeauClass) bandeauClass = function(fichier, bandeau) {

//contient le maximum d'images
var imgTotal;
var fichier = fichier;
var vBandeau = bandeau;

//Ecrit dans le bandeau 
var writediv_bandeau = function(texte)
     {
     document.getElementById(vBandeau).innerHTML = texte;
     }

//Charge le XML bandeau
this.file_bandeau = function()
     {
     var xhr=null;
		
		if (window.XMLHttpRequest) { 
			xhr = new XMLHttpRequest();
		}
		else if (window.ActiveXObject) 
		{
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		xhr.open("GET", fichier, true); 
		xhr.onreadystatechange = function() {
												put_bandeau_pict(xhr);
											}	
		xhr.send(null);
	}
	
//mettre image dans bandeau
var put_bandeau_pict = function(xhr) {
	if (xhr.readyState==4 && xhr.status == 200) 
	{	
		response = xhr.responseXML;
		var images = response.getElementsByTagName("image");
		var html = '';
		var img = new Image();
		count = images.length;
		imgTotal = count;
		for (i=0;i<count;i++) {
			img.src = '../image/bandeau/'+images[i].getElementsByTagName("url")[0].firstChild.nodeValue;
			html += '<img id="bandeau_'+vBandeau+'_image_'+images[i].getElementsByTagName("order")[0].firstChild.nodeValue+'" class="bandeau_image" src="'+img.src+'" />'
		}
		
		writediv_bandeau(html);
		fonduImage(imgTotal, 4000);
	}
}


var compteur;

var fonduImage = function(imgTotal,time) {
var nombreAlea;
nombreAlea = Math.floor(Math.random() * imgTotal)+1;
compteur = nombreAlea;
var value = 10;
var valueB = 0;
waitPict(compteur,value,valueB,imgTotal,time);
}

var vWait = 0;
var waitTime;

var waitPict = function(compteur,value,valueB,imgTotal,time) {
	if (document.getElementById('bandeau_'+vBandeau+'_image_'+compteur).complete) {
		document.getElementById(vBandeau).style.backgroundImage='none';
		if (vWait==1) {
				vWait=0;
				clearTimeout(waitTime);				
			}		
		fade('bandeau_'+vBandeau+'_image_'+compteur,valueB);
		fonduOn('bandeau_'+vBandeau+'_image_'+compteur,valueB);
		document.getElementById('bandeau_'+vBandeau+'_image_'+compteur).style.width = 'auto';
		document.getElementById('bandeau_'+vBandeau+'_image_'+compteur).style.height = 'auto';
		mvtTime = setTimeout(function() {mvt(compteur,value,valueB,imgTotal,time)},time);
		}
		else {
			vWait = 1;
			waitTime = setTimeout(function() {waitPict(compteur,value,valueB,imgTotal,time)},80);
			}
}

var mvt = function(vCompteur,value,valueB,maximum,time) {
var compteur=vCompteur;
if (document.getElementById('bandeau_'+vBandeau+'_image_'+compteur).complete) {
	document.getElementById(vBandeau).style.backgroundImage='none';
	if ((compteur)<maximum) {
		fonduOff('bandeau_'+vBandeau+'_image_'+compteur,value);
		compteur++;
		fonduOn('bandeau_'+vBandeau+'_image_'+compteur,valueB);
	}
	else if ((compteur)>=maximum) {
		compteur=1;
		fonduOff('bandeau_'+vBandeau+'_image_'+maximum,value);
		fonduOn('bandeau_'+vBandeau+'_image_'+compteur,valueB);
	}
}
else {
		document.getElementById(vBandeau).style.backgroundImage='url(../images/waiting.gif)';
	}

mvtTime = setTimeout(function() {mvt(compteur,value,valueB,maximum,time)},time);
}

var fonduFlag = 0;
var fonduOn = function(id,value) {
	if (value<=10) {
		fonduFlag = 1;
		document.getElementById(id).style.width = 'auto';
		document.getElementById(id).style.height = 'auto';
		fade(id,value);
		value++;
		setTimeout(function() {fonduOn(id,value)},80);
	}
	else {
		fonduFlag = 0;
	}
}

var fonduOff = function(id,value) {
	if (value>=0) {
		fonduFlag = 1;
		fade(id,value);
		value--;
		setTimeout(function() {fonduOff(id,value)},80);
	}
	else {
		fonduFlag = 0;
		document.getElementById(id).style.width = '0px';
		document.getElementById(id).style.height = '0px';
	}
}

var fade = function(vid,value) {
obj = document.getElementById(vid);
	
// IE
obj.style.filter = 'alpha(opacity=' + value*10 + ')';
// Safari<1.2, Konqueror
obj.style.KHTMLOpacity = value/10;
// Mozilla and Firefox
obj.style.MozOpacity = value/10; 
// Safari 1.2, newer Firefox and Mozilla, CSS3
obj.style.opacity = value/10;
}

//taille de la fenêtre
var returnSize = function() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  var result = new Array(myWidth,myHeight);
  return result;
}

return this.file_bandeau();

}