	var currentLayer = false;

	function writeLayer(layer, htmlCode) {
	
		if( document.getElementById ) {
			document.getElementById( layer ).innerHTML = htmlCode;
		} else if( document.all ) {
			document.all[layer].innerHTML = htmlCode;
		} else {
			document[layer].document.open();
			document[layer].document.write( htmlCode );
			document[layer].document.close();
		}
	}	

	
	/**
	@description						swaps one open layer to an other layer and closes the first one
	@param string layer				the name of the layer
	@param string htmlCode		the HTML code
	@param string bgColor			the color of the background in hex color
	*/
	function swapLayer(layer, htmlCode, bgColor) {

		if(currentLayer!==false) {
			writeLayer(currentLayer, '');
			changeBgColor(currentLayer + 'Table', '#FFFFFF');
		}
		if(currentLayer==layer)		currentLayer = false;
		else {
			currentLayer = layer;
			writeLayer(layer, htmlCode);
			changeBgColor(layer + 'Table', bgColor);
		}
	}

	
	/**
	@description					empties the current layer
	*/
	function emptyCurrentLayer() {
		
		if(currentLayer!==false)		writeLayer(currentLayer, '');
		currentLayer = false;

	}

	
	/**
	@description					changes the background color of an element
	@param string element		name of the element
	@param string color			the color in hex code
	*/
	function changeBgColor(element, color) {

		var obj = getObject(element);
		obj.style.backgroundColor = color;

	}


	/**
	@description					gets a HTML element and returns the object
	@param string element		the name of the element
	@return object				gives the object back
	*/
	function getObject(element) {

		var obj = false;
		if(document.getElementById)		var obj = document.getElementById(element);
		else if(document.all)		var obj = document.all[element];
		else		var obj = document[element];
		return obj;

	}


	/**
	@description				finding the position of an object
	@param object obj		the object
	@return Array				key 0 the left position, key 1 the top position
	*/
	function findPos(obj) {

		var curleft = curtop = 0;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft
			curtop = obj.offsetTop
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
		}
		return [curleft,curtop];
	}

	
	/**	
	@description							displays a big screenshot above the smaller screenshot
	@param string imageName		name of the image
	@param string screenshot			path and filename to the big screenshot
	@param integer width				width of the big screenshot
	@param integer height				height of the big screenshot
	*/
	function displayBigScreenshot(imageName, screenshot, width, height) {

		var imagePosition = findPos(getObject(imageName));		
		var left = imagePosition[0] - ((width - 120)/2);
		var top = imagePosition[1] - ((height - 96)/2);
		var layer = 'preview';
		writeLayer(layer, '<a href="' + screenshot + '" target="_blank"><img src="' + screenshot + '" width="'+ width +'" height="'+ height +'" alt="" border=""></a>');

		var obj = getObject(layer);
		obj.style.visibility = 'visible';
		obj.style.width = width;
		obj.style.height = height;
		obj.style.left = left;
		obj.style.top = top;

	}

	
	/**
	@description				hides a layer by putting it on hidden, setting the dimension back to zero and putting it on the left corner
	@param string layer		the layer that needs to be hidden
	*/
	function hideLayer(layer) {

		writeLayer(layer, '');

		var obj = getObject(layer);
		obj.style.visibility = 'hidden';
		obj.style.width = 0;
		obj.style.height = 0;
		obj.style.left = 0;
		obj.style.top = 0;

	}