var bgf = {'boxPageBA':{'slideshow':0,'image':'http://www.theatre-ouvert.net/bby_imagesBG/BA/1.jpg'},'boxPageBB':{'slideshow':0,'image':'http://www.theatre-ouvert.net/bby_imagesBG/BB/24.jpg'},'boxPageBC':{'slideshow':0,'image':'http://www.theatre-ouvert.net/bby_imagesBG/BC/35.jpg'},'boxPageBD':{'slideshow':0,'image':'http://www.theatre-ouvert.net/bby_imagesBG/BD/52.jpg'},'boxPageHPBA':{'slideshow':1,'index':0,'delay':3500,'speed':2500,'images':['http://www.theatre-ouvert.net/bby_imagesBG/HP_BA/12.jpg','http://www.theatre-ouvert.net/bby_imagesBG/HP_BA/13.jpg','http://www.theatre-ouvert.net/bby_imagesBG/HP_BA/14.jpg','http://www.theatre-ouvert.net/bby_imagesBG/HP_BA/15.jpg','http://www.theatre-ouvert.net/bby_imagesBG/HP_BA/16.jpg']},'boxPageHPBB':{'slideshow':1,'index':0,'delay':3000,'speed':2500,'images':['http://www.theatre-ouvert.net/bby_imagesBG/HP_BB/12.jpg','http://www.theatre-ouvert.net/bby_imagesBG/HP_BB/13.jpg','http://www.theatre-ouvert.net/bby_imagesBG/HP_BB/14.jpg','http://www.theatre-ouvert.net/bby_imagesBG/HP_BB/15.jpg']},'boxPageHPBC':{'slideshow':1,'index':0,'delay':4000,'speed':2500,'images':['http://www.theatre-ouvert.net/bby_imagesBG/HP_BC/11.jpg','http://www.theatre-ouvert.net/bby_imagesBG/HP_BC/12.jpg','http://www.theatre-ouvert.net/bby_imagesBG/HP_BC/13.jpg']}};
$(document).ready(function () {
  for (myclass in bgf) {
  	if (bgf[myclass].slideshow) {
	    $("." + myclass).css("background-image", "url('" + bgf[myclass].images[bgf[myclass].index] + "')");
		  if (!jQuery.browser.msie || jQuery.browser.version != "6.0") {
		  	setTimeout("changeBG('"+myclass+"');", bgf[myclass].delay - bgf[myclass].speed);
		  }
		}
		else {
			$("." + myclass).css("background-image", "url('" + bgf[myclass].image + "')");
		}
	}
});

var changeBG = function(myclass) {
	bgf[myclass].index += 1;
	if (bgf[myclass].index == bgf[myclass].images.length) {
		bgf[myclass].index = 0;
	}
	$("." + myclass).each(function () {
		var node = $(this);
		var offset = node.offset();
		var hover = node.clone(true);
		hover.css({
          position: 'absolute',
          left: offset.left,
          top: offset.top,
          zIndex: 1000
        }).hide().insertAfter(node);
		hover.css("background-image", "url('" + bgf[myclass].images[bgf[myclass].index] + "')");
		hover.fadeIn(bgf[myclass].speed, function() {
			node.css("background-image", "url('" + bgf[myclass].images[bgf[myclass].index] + "')");
			hover.remove();
		});
	});
	setTimeout("changeBG('"+myclass+"');", bgf[myclass].delay);
}