		var popupStatus = 0;
		
		function switch_saalplan() {
			document.getElementById("saalplanImg").src = "/.img/saalplaene/"+(document.getElementById("show").options[document.getElementById("show").selectedIndex].value);
		}
		
		function loadPopup(){
			if(popupStatus == 0){
				$("#backgroundPopup").css({
				"opacity": "0.65"
				});
				$("#backgroundPopup").fadeIn("fast");
				$("#popupSaalplan").fadeIn("normal");
				popupStatus = 1;
			}
		}
		
		function disablePopup(){
			if(popupStatus == 1){
				$("#backgroundPopup").fadeOut("fast");
				$("#popupSaalplan").fadeOut("normal");
				popupStatus = 0;
			}
		}

		function centerPopup(){
			var windowWidth = document.documentElement.clientWidth;
			var windowHeight = document.documentElement.clientHeight;			
			var popupHeight = $("#popupSaalplan").height();
			var popupWidth = $("#popupSaalplan").width();
			
			$("#popupSaalplan").css({
				"top": windowHeight/2-popupHeight/2,
				"left": windowWidth/2-popupWidth/2
			});

			$("#backgroundPopup").css({
				"height": windowHeight
			});
		}
		
		$(document).ready(function(){
			$("#openSaalPlan").click(function(){
				centerPopup();
				loadPopup();
				myTimeout = window.setTimeout("switch_saalplan()", 1000);
			});
			
			$("#popupClose").click(function(){
				disablePopup();
			});
			$("#backgroundPopup").click(function(){
				disablePopup();
			});
			$(document).keypress(function(e){
				if(e.keyCode==27 && popupStatus==1){
					disablePopup();
				}
			});
		});