
function FensterOeffnen (Adresse,Breite,Hoehe,Top) {
	var Breite = (Breite == null) ? 600 : Breite;
    var Hoehe  = (Hoehe  == null) ? 400 : Hoehe;
    var Top    = (Top  == null)   ? 200 : Top;

	MeinFenster = window.open(Adresse, "popup", "width="+Breite+",height="+Hoehe+",left=100,top="+Top+",resizable=yes,scrollbars=yes,status=no,menubar=no,toolbar=no,dependent=yes");
	MeinFenster.focus();
}

function incCurIndex() {
	var curindex = jQuery.data(document.body, "curindex")+1;
	if (curindex > jQuery.data(document.body, "maxindex")) {
		var curindex = 0;
	}
	jQuery.data(document.body, "curindex", curindex);
	return curindex;
}

function runHeaderFade1() {
	curindex = incCurIndex();
	jQuery('#header_bg #header_img').css('background-image', 'url('+jQuery.data(document.body, "bg"+curindex)+')');
	jQuery('#header_bg #header_img').delay(std_delay);
	jQuery('#header_bg #header_img').fadeIn(std_fade, runHeaderFade2);
}

function runHeaderFade2() {
	curindex = incCurIndex();
	jQuery('#header_bg').css('background-image', 'url('+jQuery.data(document.body, "bg"+curindex)+')');
	jQuery("#header_bg #header_img").delay(std_delay);
	jQuery('#header_bg #header_img').fadeOut(std_fade, runHeaderFade1);
}

var std_delay = 6000;
var std_fade  = 'slow';

jQuery(document).ready(function() {
	jQuery.data(document.body, 'curindex', 0);
	if (jQuery.data(document.body, 'maxindex') > 0) {
		var zufallszahl = 0 + jQuery.data(document.body, 'maxindex')*(Math.random());
		jQuery.data(document.body, 'curindex', zufallszahl = Math.round(zufallszahl));
		jQuery('#header_bg').css('background-image', 'url('+jQuery.data(document.body, "bg"+zufallszahl)+')');
		
		jQuery('#header_bg').append('<div id="header_img"></div>');
		jQuery('#header_bg #header_img').fadeOut(0);
	
		runHeaderFade1();
	}
});

