	function bildwechsel()
	{
		var	checkInterval = null,
			bildwechselInterval = null,
			currentImage = -1;
			images = new Array(
				'images/main_hohenlimburg.jpg',
				'images/main_schwerin.jpg',
				'images/main_radbod.jpg',
				'images/main_rolandhalde.jpg'
				
			);
			loadingImages = new Array();
		
		this.run = function()
		{
			checkInterval = window.setInterval('this.checkIfLoaded();', 100);
			for(i = 0;i < images.length;i++)
			{
				image = images[i];
				loadingImages.push(new Image);
				loadingImages[i].src = image;
			}
		}
		this.checkIfLoaded = function()
		{
			allLoaded = true;
			for(i = 0;i < loadingImages.length;i++)
			{
				loadingImage = loadingImages[i];
				if(!loadingImage.complete)
					allLoaded = false;
			}
			if(allLoaded)
			{
				window.clearInterval(checkInterval);
				this.startbildwechsel();
				// Bildwechsel A
				window.setInterval('this.startbildwechsel();', 8000);
			}
		}
		this.startbildwechsel = function()
		{
			this.showImage();
			if(currentImage == (loadingImages.length - 1))
				currentImage = 0;
			else
				currentImage += 1;
			element = document.getElementById('bildwechsel');
			element.style.height = loadingImages[currentImage].height + 'px';
			element.style.width = loadingImages[currentImage].width + 'px';
			element.style.backgroundImage = 'url(' + loadingImages[currentImage].src + ')';
			// Bildwechsel B
			window.setTimeout('this.hideImage();', 7000);
			}
		this.hideImage = function()
		{
			element = document.getElementById('bildwechsel');
			for(i = 0;i <= 100;i++)
				window.setTimeout('element.style.filter = "Alpha(opacity=' + (100 - i) + ')"; element.style.MozOpacity = ' + (1 - i / 100) + '; element.style.opacity = ' + (1 - i / 100) + ';', i * 10);
		}
		this.showImage = function()
		{
			element = document.getElementById('bildwechsel');
			for(i = 0;i <= 100;i++)
				window.setTimeout('element.style.filter = "Alpha(opacity=' + i + ')"; element.style.MozOpacity = ' + i / 100 + '; element.style.opacity = ' +  i / 100 + ';', i * 10);
		}	
		this.run();
	}
	window.onload = function()
	{
		bildwechsel();
	}
