
// Background image slide show
// http://www.willmaster.com/
// Copyright 2008 Bontrager Connection, LLC

var imageArray = new Array(); // leave as is.

// Specify number of milliseconds between image switches.
var switchMilliseconds = 5000;

// Specify the id of the div or other HTML tag with the 
//   background image to switch.

var divID = 'hg_bild';

// To add more images, continue the pattern below.
/*
imageArray[0] = 'fileadmin/template/images_hg/1.jpg';
imageArray[1] = 'fileadmin/template/images_hg/2.jpg';
imageArray[2] = 'fileadmin/template/images_hg/3.jpg';
imageArray[3] = 'fileadmin/template/images_hg/4.jpg';
imageArray[4] = 'fileadmin/template/images_hg/5.jpg';
imageArray[5] = 'fileadmin/template/images_hg/6.jpg';
imageArray[6] = 'fileadmin/template/images_hg/8.jpg';
imageArray[7] = 'fileadmin/template/images_hg/9.jpg';
imageArray[8] = 'fileadmin/template/images_hg/10.jpg';
imageArray[9] = 'fileadmin/template/images_hg/11.jpg';
imageArray[10] = 'fileadmin/template/images_hg/12.jpg';
imageArray[11] = 'fileadmin/template/images_hg/13.jpg'
imageArray[12] = 'fileadmin/template/images_hg/14.jpg';
imageArray[13] = 'fileadmin/template/images_hg/17.jpg';
imageArray[14] = 'fileadmin/template/images_hg/18.jpg';
imageArray[15] = 'fileadmin/template/images_hg/20.jpg';
imageArray[16] = 'fileadmin/template/images_hg/21.jpg';
imageArray[17] = 'fileadmin/template/images_hg/22.jpg';
imageArray[18] = 'fileadmin/template/images_hg/23.jpg';
imageArray[19] = 'fileadmin/template/images_hg/24.jpg';
imageArray[20] = 'fileadmin/template/images_hg/25.jpg';
imageArray[21] = 'fileadmin/template/images_hg/26.jpg';
*/
for (BildNr=0; BildNr < 29; BildNr++) {
	BildNr30 = BildNr+30;
	imageArray[BildNr] = 'fileadmin/template/images_hg/'+BildNr30+'.jpg';
  }
  
function BilderVorladen()
{
  for (i=0; i < imageArray.length; i++) {
    var Bild = new Image();
    Bild.src = imageArray[i];
  }
}

BilderVorladen();



function randOrd(){
	return (Math.round(Math.random())-0.5);
} 
imageArray.sort( randOrd );

function publishPicture(i) {

	if (navigator.appName == 'Microsoft Internet Explorer' ) {
	fadeIn();
	}
	
	document.getElementById(divID).style.background = 'url("'+imageArray[i]+'")';
	
	if (navigator.appName == 'Microsoft Internet Explorer' ) {
	setTimeout('fadeOut()', 4200)
	}
	
	i++;
	if( i > (imageArray.length - 1) ) { i = 0; }
	setTimeout('publishPicture('+i+')',switchMilliseconds);
}

publishPicture(0);

function fadeIn(step) {
	
	step = step || 0;

	document.getElementById(divID).style.opacity = step/100;
	document.getElementById(divID).style.filter = "alpha(opacity=" + step + ")"; // IE

	step = step + 6;

	if (step <= 100) {
		window.setTimeout(function () { fadeIn(step); }, 1);
	}
}
function fadeOut(step) {
	step = step || 100;

	document.getElementById(divID).style.opacity = step/100;
	document.getElementById(divID).style.filter = "alpha(opacity=" + step + ")"; // IE

	step = step - 6;

	if (step >= 2) {
		window.setTimeout(function () { fadeOut(step); }, 1);
	}
}
