
/*
 * jQuery onImagesLoaded plugin v1.1.0
 * Fires callback functions when images have loaded within a particular selector.
 *
 * Copyright (c) Cirkuit Networks, Inc. (http://www.cirkuit.net), 2008.
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * For documentation and usage, visit "http://includes.cirkuit.net/js/jquery/plugins/onImagesLoad/1.1/documentation/"'
 */
 
(function($){$.fn.onImagesLoad=function(options){var self=this;self.opts=$.extend({},$.fn.onImagesLoad.defaults,options);self.bindEvents=function($imgs,container,callback){if($imgs.length===0){if(self.opts.callbackIfNoImagesExist&&callback){callback(container);}}else{var loadedImages=[];if(!$imgs.jquery){$imgs=$($imgs);}$imgs.each(function(i,val){$(this).bind('load',function(){if(jQuery.inArray(i,loadedImages)<0){loadedImages.push(i);if(loadedImages.length==$imgs.length){if(callback){callback(container);}}}}).each(function(){if(this.complete||this.complete===undefined){this.src=this.src;}});});}};var imgAry=[];self.each(function(){if(self.opts.itemCallback){var $imgs;if(this.tagName=="IMG"){$imgs=this;}else{$imgs=$('img',this);}self.bindEvents($imgs,this,self.opts.itemCallback);}if(self.opts.selectorCallback){if(this.tagName=="IMG"){imgAry.push(this);}else{$('img',this).each(function(){imgAry.push(this);});}}});if(self.opts.selectorCallback){self.bindEvents(imgAry,this,self.opts.selectorCallback);}return self.each(function(){});};$.fn.onImagesLoad.defaults={selectorCallback:null,itemCallback:null,callbackIfNoImagesExist:false};})(jQuery);












$.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();
				});
			}
			
			*/
		}
	}
});
