
var BildListe = new Array();
BildListe[0] = "fileadmin/templates/images/bg_1.jpg";
BildListe[1] = "fileadmin/templates/images/bg_2.jpg";
BildListe[2] = "fileadmin/templates/images/bg_3.jpg";
BildListe[3] = "fileadmin/templates/images/bg_4.jpg";
BildListe[4] = "fileadmin/templates/images/bg_5.jpg";
BildListe[5] = "fileadmin/templates/images/bg_6.jpg";
BildListe[6] = "fileadmin/templates/images/bg_7.jpg";
BildListe[6] = "fileadmin/templates/images/bg_8.jpg";

function Vorladen()
{
  for (i = 0; i < BildListe.length; i++) {
    var Bild = new Image();
    Bild.src = BildListe[i];
  }
}

Vorladen();

//var bgImgNr = 1 + Math.floor(Math.random() * 2);
bgImgNr = 0;
function switchBackgroundImage(){
	var imgCount = 8;
	var newImgUrl = "url(fileadmin/templates/images/bg_"+(1+bgImgNr%imgCount)+".jpg)";
	$('content_header').style.background = newImgUrl;
	$('content_header').style.backgroundRepeat = "no-repeat";
	$('content_header').style.backgroundPosition = "top center";
	$('ch_transition').style.backgroundPosition = "top center";
        new Effect.Opacity('ch_transition', {
		duration:2,
		from:1.0,
		to:0.0,
		afterFinish: function () {
			$('ch_transition').style.backgroundImage = newImgUrl;
			new Effect.Opacity('ch_transition', {	
				duration:0.5,
				from:0.0,
				to:1.0
			});
		}
	});	
		++bgImgNr;

}
Event.observe(window, 'load', function() {
	switchBackgroundImage();
	new PeriodicalExecuter(switchBackgroundImage, 7);
});
