function openMain() {
	openWindowCentered('main.php', 970, 680, 'no', 'no', 'no', 'no', 'no');
}

function openImpressum() {
	var mainX = getWindowLeft(this);
	var mainY = getWindowTop(this);
	var impX = mainX + 220;
	var impY = mainY + 90;
	var tWin = openWindow('impressum.html', 549, 458, 'no', 'no', 'no', 'no', 'no');
	tWin.moveTo(impX, impY);
}

document.oncontextmenu=new Function('return false');

// Should the Pictures get preloaded?
var mustPreload = 0;

// Must use Fadeeffekt, if possible?
var mustFade = 0;

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 8000;

// Duration of crossfade (seconds)
var crossFadeDuration = 2;

var timeOutSlideShow;

var picIndexList = new Array();
var preLoadedPic = new Image();
var picIndex;

function getNextPicIndex() {
	if (picIndexList.length == 0) {
		for (i = 0; i < pics.length; i++) picIndexList[i] = i;
		for (i = 0; i < picIndexList.length; i++) {
			var randomIndex = Math.floor(Math.random() * picIndexList.length);
			var tmp = picIndexList[i];
			picIndexList[i] = picIndexList[randomIndex];
			picIndexList[randomIndex] = tmp;
		}
	}
	newIndex = picIndexList[0];
	var tempList = picIndexList.slice(1,picIndexList.length);
	picIndexList = tempList;
	picIndex = newIndex;
	return newIndex;
}

function getPicIndex() {
	var firstIndex = getNextPicIndex();
	picIndex = getNextPicIndex();
	preLoadedPic.src = pics[picIndex];
	return firstIndex;
}

function preLoadPics() {
	for (i = 0; i < pics.length; i++) {
		var tempImg = new Image();
		tempImg.src = pics[i];
	}
}

function startSlideShowBack() {
	if (mustPreload==1) preLoadPics();
	getNextPicIndex();
	timeOutSlideShow = window.setTimeout('runSlideShowBack()', slideShowSpeed);
}

function runSlideShowBack() {
	if ((document.all)&&(mustFade==1)) {
		document.images.SlideShowBackground.style.filter='blendTrans(duration=2)';
		document.images.SlideShowBackground.style.filter='blendTrans(duration=crossFadeDuration)';
		document.images.SlideShowBackground.filters.blendTrans.Apply();      
	}

	if (isN4) {
		document.layers['backLayer'].document.images['SlideShowBackground'].src = pics[picIndex];
	} else {
		document.images.SlideShowBackground.src = pics[picIndex];
	}

	if ((document.all)&&(mustFade==1)) document.images.SlideShowBackground.filters.blendTrans.Play();

	startSlideShowBack();
	picIndex = getNextPicIndex();
	preLoadedPic.src = pics[picIndex];
}

function checkKontaktForm() {
	if (document.kontakForm.bs_name.value == "")  {
		alert("Bitte geben Sie Ihren Namen an!");
		return false;
	} else if (document.kontakForm.bs_email.value == "") {
		alert("Bitte geben Sie Ihre E-Mail-Adresse an!");
		return false;
	} else if (document.kontakForm.bs_email.value.indexOf('@') == -1) {
   		alert("Die angebene E-Mail-Adresse ist nicht korrekt!");
		return false;
	} else if (document.kontakForm.bs_email.value.indexOf('.') == -1) {
   		alert("Die angebene E-Mail-Adresse ist nicht korrekt!");
		return false;
	}
}

function pauseSlideShowBack() {
	document.getElementById('playButton').className="show";
	document.getElementById('stopButton').className="hide";
	window.clearTimeout(timeOutSlideShow);
	timeOutSlideShow = 0;
}

function continueSlideShowBack() {
	document.getElementById('playButton').className="hide";
	document.getElementById('stopButton').className="show";
	if (!timeOutSlideShow) runSlideShowBack();
}

function showAnfahrt1() {
	document.getElementById('berlinGesamt').className="show";
	if (isN4) {
		document.layers['textInhaltLayer'].document.images['SlideShowBackground'].src = "images/berlingesamt_neu.jpg";
	} else {
		document.images.SlideShowBackground.src = "images/berlingesamt.jpg";
	}
}

function showAnfahrt2() {
	document.getElementById('berlinGesamt').className="hide";
	if (isN4) {
		document.layers['textInhaltLayer'].document.images['SlideShowBackground'].src = "images/wegbeschreibung_neu.jpg";
	} else {
		document.images.SlideShowBackground.src = "images/wegbeschreibung.jpg";
	}
}

function showImpressum() {
	document.getElementById('backgroundImpressum').className="show";
	document.getElementById('textRahmenLayerImpressum').className="show";
	document.getElementById('closeButtonImpressum').className="show";
	document.getElementById('upButtonImpressum').className="show";
	document.getElementById('downButtonImpressum').className="show";
}

function hideImpressum() {
	document.getElementById('backgroundImpressum').className="hide";
	document.getElementById('textRahmenLayerImpressum').className="hide";
	document.getElementById('closeButtonImpressum').className="hide";
	document.getElementById('upButtonImpressum').className="hide";
	document.getElementById('downButtonImpressum').className="hide";
}

