$(document).ready(function() {
						   
var status = 0;

function loadPopup(){
	if(status==0){
		$("#popup-background").css({"opacity" : "0.7"});
		$("#popup-background").fadeIn("normal");
		$("#popup").fadeIn("normal");
		status = 1;
	}  
}

function disablePopup(){
	if(status==1){
		$("#popup-background").fadeOut("normal");
		$("#popup").fadeOut("normal");
		status = 0;
	}
}

function centerPopup(){
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popup").height();
	var popupWidth = $("#popup").width();

	$("#popup").css({
		"position": "fixed",
		"top": (windowHeight/2)-(popupHeight/2),
		"left": (windowWidth/2)-(popupWidth/2)
	});

	$("#popup-background").css({
		"height": windowHeight
	});
}


$("#bestellbutton").click(function(){
	centerPopup();
	loadPopup();
	});

$("#popup-close").click(function(){
	disablePopup();
	});

$("#popup-background").click(function(){
	disablePopup();
	}); 
});
