var lang;
lang = "de"
if(window.location.search != "") {
	s = window.location.search.replace("?", "");
	if(s == "en" || s == "it" || s == "de") {
		lang = s;
	}
}

function selectButton(id, side) {
	button = parent.linkbar.document.getElementById(id);
	if(button != null) {
		parent.linkbar.linkClick(button, side);
	}
}

function getLang() {	
	return lang;
}

function getLink(link) {
	return link + "?" + getLang();
}

function openWindow(url,winName,features) { 
	url = getLink(url);
	win = window.open(url,winName,features);
	win.focus();
}

//Variables and functions for expanding and reducing.
var x;
var y;
function changeVisibility(imgName, id) {
	element = document.getElementById(id);
	
	if(element == null) {
		return;
	}
	
	if(element.style.display == "none") {
		element.style.display = "block";
		document.images[imgName].src = "images/graphic/hide.gif";
	}
	else {
		element.style.display = "none";
		document.images[imgName].src = "images/graphic/show.gif";
	}
}

function changeDisplay(id) {
	element = document.getElementById(id);
	
	if(element == null) {
		return;
	}
	
	if(element.style.display == "none") {
		element.style.display = "block";
	}
	else {
		element.style.display = "none";
	}
}


//Variables and functions for the link pages.
var bg1 = new Image();
bg1.src="images/graphic/kreis1.gif";
var bg2 = new Image();
bg2.src="images/graphic/kreis2.gif";
var bg3 = new Image();
bg3.src="images/graphic/kreis3.gif";
var bg4 = new Image();
bg4.src="images/graphic/kreis4.gif";

var images = new Array();
images[0] = "images/graphic/kreis1.gif";
images[1] = "images/graphic/kreis2.gif";
images[2] = "images/graphic/kreis3.gif";
images[3] = "images/graphic/kreis4.gif";

function setBgImage() {
	zahl = Math.round(Math.random() * (images.length - 1));
	window.document.body.style.backgroundImage="url(" + images[zahl] + ")";
}

//Variables and functions to choose the image on the start page.
var startImages;
var startIndex = 0;
function preloadStartImages() {
	var img0 = new Image();
	img0.src="images/photos/2011/idomeneo/elektra_5737.jpg";
	var img1 = new Image();
	img1.src="images/photos/2011/idomeneo/elektra_5743.jpg";
	var img2 = new Image();
	img2.src="images/photos/2011/idomeneo/elektra_5756.jpg";
	var img3 = new Image();
	img3.src="images/photos/2011/idomeneo/elektra_5762.jpg";
	var img4 = new Image();
	img4.src="images/photos/2011/idomeneo/elektra_5768.jpg";
	var img5 = new Image();
	img5.src="images/photos/2011/idomeneo/elektra_5796.jpg";
	var img6 = new Image();
	img6.src="images/photos/2011/idomeneo/elektra_5799.jpg";
	var img7 = new Image();
	img7.src="images/photos/2011/idomeneo/elektra_5810.jpg";
	var img8 = new Image();
	img8.src="images/photos/2011/idomeneo/elektra_5817.jpg";
	var img9 = new Image();
	img9.src="images/photos/2011/idomeneo/elektra_5822.jpg";
	var img10 = new Image();
	img10.src="images/photos/2011/idomeneo/elektra_5829.jpg";
	var img11 = new Image();
	img11.src="images/photos/2011/idomeneo/elektra_5837.jpg";
	var img12 = new Image();
	img12.src="images/photos/2011/idomeneo/elektra_5841.jpg";

	startImages = new Array();
	i = -1;
	startImages[++i] = img0.src;
	startImages[++i] = img1.src;
	startImages[++i] = img2.src;
	startImages[++i] = img3.src;
	startImages[++i] = img4.src;
	startImages[++i] = img5.src;
	startImages[++i] = img6.src;
	startImages[++i] = img7.src;
	startImages[++i] = img8.src;
	startImages[++i] = img9.src;
	startImages[++i] = img10.src;
	startImages[++i] = img11.src;
	startImages[++i] = img12.src;
}

function setStartImage() {
        preloadStartImages();
	window.document.startImg.src=startImages[0];
	//startIndex = Math.round(Math.random() * (startImages.length - 1));
	window.setTimeout("switchImage()", 5000);
}

function switchImage() {
	startIndex++;
	if(startIndex >= startImages.length) {
	    startIndex = 0;
	}
	window.document.startImg.src=startImages[startIndex];
	window.setTimeout("switchImage()", 5000);
}

var activeButton;
var buttonClass;
function linkClick(button, side) {
	if(button != activeButton) {
		if(activeButton != null) {
			activeButton.className  = buttonClass;
		}
		buttonClass = button.className;
		if(side == "left") {
			button.className = "viewLeft";
		}
		else {
			button.className = "viewRight";
		}
		activeButton = button;
		setBgImage();
	}
}

function reloadLinks() {
	parent.linkbar.location.reload();
}


//Preloads all images of the actual document
function preloadImages() {
	var img;
	for(i = 0; i < document.images.length; i++) {
		img = new Image();
		img.src = document.images[i].src;
	}
}

//Shows the given image at the center of the galery.
function showImage(img, info) {
	var height = 180;
	var width;
	var imgShow = new Image();
	imgShow.src = img.src;
	
	var imgWidth = imgShow.width;
	var imgHeight = imgShow.height;

	width = height/imgHeight * imgWidth;


	parent.image.document.big.src=imgShow.src;
	parent.image.document.big.width = width;
	parent.image.document.big.height = height
	parent.image.document.getElementById("imgInfo").firstChild.nodeValue = info;
}

//Opens a window with a photo album of all photos.
function openAlbum() {				
	var arg3 = "width=10, height=10, screenX=0, screenY=0, resizable=yes, status=yes";
	
	var imgWindow = window.open("album.htm", "album", arg3);
	imgWindow.focus();
}
