function $(elementId) {
	if (document.getElementById(elementId)) {
		return document.getElementById(elementId);
	} else {
		return false;
	}
}


function closeLayer (){
	parent.$('backendOverlayLayer').style.display = "none";
	parent.$("top").removeChild(parent.$("iframeLayer"));
}

function createNewLayer (targetURL, widthInPx, heightInPx){
	
	var pageSize = getPageSize();

	$('backendOverlayLayer').style.display = "block";
	$('backendOverlayLayer').style.height = pageSize[1]+"px";
	newLayer = document.createElement("iframe");
	newLayer.name = newLayer.id = "iframeLayer";
	newLayer.className = "iframeLayerStyle";
	newLayer.style.width = widthInPx+'px';
	newLayer.style.height = heightInPx+'px';
	newLayer.style.left = ((pageSize[2]-widthInPx)/2)+'px';
	newLayer.style.top = ((pageSize[3]-heightInPx)/2)+'px';

	newLayer.frameborder = 0;
	newLayer.src = targetURL;
	$("top").appendChild(newLayer);
}

function createNewFullsizeLayer(targetURL) {
	var pageSize = getPageSize();
	var widthInPx = pageSize[2]*1-60;
	var heightInPx = pageSize[3]*1-60;
	createNewLayer (targetURL, widthInPx, heightInPx);
}

function getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight) {
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	if (yScroll < windowHeight) {
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}
	if (xScroll < windowWidth) {
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight)
	return arrayPageSize;
}

function changeImage(imageUrl,imageTitel) {
	
	$("bild").src = imageUrl; 
	$("titel").innerHTML = imageTitel;

}

function changeMenu(showNr,allNr) {
	for ( var i = 1; i <= allNr; i++) {
		$("bilder"+i).style.display = "none";
	}
	$("bilder"+showNr).style.display = "block";
}