	function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
	{
		if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0){
			aVersion0 = navigator.appVersion.split(';');
			aVersion1 = aVersion0[1].split(' ');
			Version = aVersion1[2]
			if(Version < 5.5 || Version >= 7)return false;
			for(var i=0; i<document.images.length; i++)
			{
				var img = document.images[i]
				var imgName = img.src.toUpperCase()
				if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
				{
				var imgID = (img.id) ? "id='" + img.id + "' " : ""
				var imgClass = (img.className) ? "class='" + img.className + "' " : ""
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
				var imgStyle = "display:inline-block;" + img.style.cssText
				if (img.align == "left") imgStyle = "float:left;" + imgStyle
				if (img.align == "right") imgStyle = "float:right;" + imgStyle
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
				var strNewHTML = "<span " + imgID + imgClass + imgTitle
				+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
				+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
				img.outerHTML = strNewHTML
				i = i-1
				}
			}
		}
	}

	function sendRequest(sInput) {

		if(callInProgress(req))return false;

		req.open('POST', "../ImageRequest.php?h="+sInput, true);
		req.onreadystatechange = handleResponse;
		req.send(null);
		iImageNumber = sInput;
		return false;
	}

//	function handleResponse() {
//		if(req.readyState == 4){
//			aResponse = req.responseText.split("||");
//			document.getElementById('IMAGEBOX').style.width 		= aResponse[1] + "px";
//			document.getElementById('IMAGEBOX').style.height 		= aResponse[2] + "px";
//			document.getElementById('IMAGEBOX').style.marginLeft 	= "-" + parseInt(aResponse[1]/2) + "px";
//			document.getElementById('IMAGEBOX').style.marginTop 	= "-" + parseInt( aResponse[2]/2 - document.body.scrollTop) + "px";
//			document.getElementById('IMAGEBOX').innerHTML 			= aResponse[0];
//			bAllowNextKey = (aResponse[3] == 1)?1:0;
////			SetOverlaySize();
//			if(aResponse[4]){
//				preloadImages(aResponse[4]);
//			}
//		}
//	}
	function handleResponse() {
		if(req.readyState == 4){



			aResponse = req.responseText.split("||");
			document.getElementById('IMAGEBOX').style.width 		= aResponse[2] + "px";
			document.getElementById('IMAGEBOX').style.height 		= aResponse[3] + "px";
			document.getElementById('IMAGEBOX').style.marginLeft 	= "-" + parseInt(aResponse[2]/2) + "px";
			document.getElementById('IMAGEBOX').style.marginTop 	= "-" + parseInt( aResponse[3]/2 - document.body.scrollTop) + "px";
			document.getElementById('IMAGEBOX').innerHTML 			= aResponse[1];



			if(aResponse[0] == 'IMAGE'){
				bAllowNextKey = (aResponse[4] == 1)?1:0;
				if(aResponse[5]){
					preloadImages(aResponse[5]);
				}
			}

			if(aResponse[0] == 'MOVIE'){
				var s1 = new SWFObject("/flash/player.swf","ply","570","474","9.0.0", "#AAAAAA");
				s1.addParam("allowfullscreen","true");
				s1.addParam("allownetworking","all");
				s1.addParam("allowscriptaccess","always");
				s1.addParam("flashvars","file="+aResponse[1]+"&image="+aResponse[6]+"&autostart=true");
				s1.write("IMAGEBOX");

				var pTag = document.createElement("p");
				pTag.setAttribute("align","center");
				pTag.innerHTML = aResponse[7];
				document.getElementById("IMAGEBOX").appendChild(pTag);
			}
		}
	}

	function showBox(e){
		Body_Overlay();
		sendRequest(e)
		return false;
	}

	function preloadImages(){
		document.Vorladen = new Array();
		aImages = preloadImages.arguments[0].split(',');
    	if(document.images){
	        for(var i = 0; i < aImages.length; i++){
	            document.Vorladen[i] = new Image();
	            document.Vorladen[i].src = aImages[i];
	        }
    	}
	}

	function SetOverlaySize(){
		if(document.body.scrollHeight && document.body.clientHeight && document.getElementById){
			if(document.body.scrollHeight > document.body.clientHeight)
				document.getElementById('OVERLAY').style.height = document.body.scrollHeight+"px"
			if(document.body.scrollWidth > document.body.clientWidth)
				document.getElementById('OVERLAY').style.width = document.body.scrollWidth+"px"
		}
	}

	function ResizeOverlay(){
		if( document.getElementById && document.getElementById('OVERLAY') ){
			document.getElementById('OVERLAY').style.width 	= "100%";
//			document.getElementById('OVERLAY').style.height = "100%";

			de = document.documentElement;
			h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
			YOffset = window.pageYOffset || (de&&de.scrollTop) || document.body.scrollTop;
			document.getElementById('OVERLAY').style.height = parseInt(YOffset + h) + "px";

		}
	}

	function Body_Overlay(){
		var y 	= document.createElement('div');
		y.id 	= 'OVERLAY';
		y.onclick = CloseOverlay

		var a 	= document.createElement('div');
		a.id 	= 'IMAGEBOX';
		a.innerHTML = '';

		document.body.appendChild(y)
		document.body.appendChild(a)

		addEvent(window, "resize", ResizeOverlay,0);
		addEvent(document, "keydown", GoOnKey,0);

		de = document.documentElement;
		h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
		YOffset = window.pageYOffset || (de&&de.scrollTop) || document.body.scrollTop;
		document.getElementById('OVERLAY').style.height = parseInt(YOffset + h) + "px";
	}

	function removeElement(id)   {
		var Node = document.getElementById(id);
		Node.parentNode.removeChild(Node);
	}

	function CloseOverlay(){
		removeElement('IMAGEBOX')
		removeElement('OVERLAY')
		removeEvent( window, "resize", ResizeOverlay )
		removeEvent( document, "keydown", GoOnKey);
		bAllowNextKey = 1;
	}

	function GoOnKey(e){
		if (!e)
			e = event || window.event;
		if (e.which) {
			charCode = e.which;
		} else if (e.keyCode) {
			charCode = e.keyCode;
		}
//		alert(charCode);
		switch (charCode) {
//			case 32: // space
//			case 33: // Bild hoch
			case 39: // Pfeil rechts
//			case 38: // Pfeil hoch
				if(bAllowNextKey == 1)
					sendRequest(++iImageNumber);
				break;
			case 37: // Pfeil links
//			case 40: // Pfeil runter
//			case 34: // Bild runter
				if(iImageNumber > 0)
					sendRequest(--iImageNumber);
			break;
		}

		return true;
	}

	var req = createXMLHttpRequest();
	var iImageNumber = 0;
	var bAllowNextKey = 1;


