$.ajax({
	cache: false,
	url: "/lightbox.php",
	type: "POST",
	data: "template=staand",
	success: function (html) {
		if (html != "") {
			$("body").append("<div id='lightbox-container'><div id='overlay' class='png_bg'></div><div id='lightbox-content'><a class='png_bg close-lightbox'>Terug naar de website</a><div id='lightbox-content-container'><div class='png_bg' id='lightbox-hoek'></div>" + html + "</div></div></div>");
			
			//Function: Fades in the Lightbox
			function fadeInLightbox () {
				$("div#lightbox-container").css("z-index", "100").fadeIn("slow");
			}
			
			function resize (contentHeight) {
				$("#lightbox-container").hide();
				var heightLight = contentHeight / 2;
				var topt = ($(window).height() / 2) - heightLight;
				if ($(window).height() < contentHeight) {
					$("#lightbox-content").css({
						top: "50px"
					});
				} else {
					$("#lightbox-content").css({
						top: topt + "px"
					});
				}
				$("#lightbox-container").css("height", ($(document).height() + 66));
				fadeInLightbox();
			}
			
			function onResize (contentHeight) {
				var heightLight = contentHeight / 2;
				var topt = ($(window).height() / 2) - heightLight;
				if ($(window).height() < contentHeight) {
					$("#lightbox-content").css({
						top: "50px"
					});
				} else {
					$("#lightbox-content").css({
						top: topt + "px"
					});
				}
			}
			
			function itemImagesLoaded () {
       			var contentHeight = $("div#lightbox-content").height();
				resize(contentHeight);
				$(window).bind("resize", function () {
					onResize(contentHeight);
				});
       		}
			
			$('#lightbox-content-container').onImagesLoad({ 
           		itemCallback: itemImagesLoaded
       		}); 
			
			//Function: Fades out the lightbox
			function close () {
				$("#lightbox-container").fadeOut("slow", function () {
					$("this").remove();
				});
			}


			$(".close-lightbox, #overlay").click(function(){
				$("#lightbox-container").fadeOut();
			});

			/*
			//Buttons that remove the lightbox
			var closeBtns = new Array(".close-lightbox","#overlay");
			for (var i = 0; i < closeBtns.length; i++) {
				$(i).click(function () {
					close();
				});
			}
			
			*/
		}
	}
});
