$(document).ready(function() {

	$('#lightboxbg, #lightboxclose')
	.click(function(){ 																													// WANNEER KLIK OP ACTIEVE TAB
		$('#lightboxkader, #lightboxbg').fadeOut("fast");	
	});

});

var imgHeight;
var imgWidth;
 
function lightboxafm(ScrollTopValue) {

	// SCROLLAFSTAND
	var ScrollTop = document.body.scrollTop;
	if (ScrollTop == 0)
	{
	    if (window.pageYOffset)
	    { ScrollTop = window.pageYOffset; }
	    else
	    { ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0; }
	}
	
	// VENSTERGROOTTE
	if( typeof( window.innerHeight ) == 'number' ) 
 	{
		//Non-IE
		windowheight = window.innerHeight;
  	}
	else if( document.documentElement &&  ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
		//IE 6+ in 'standards compliant mode'
		windowheight = document.documentElement.clientHeight;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		//IE 4 compatible
		windowheight = document.body.clientHeight;
  	}

	imgHeight = this.height; 
	imgWidth = this.width; 
	
	imgMarginY = windowheight-imgHeight;
	imgMarginTop = imgMarginY/2;
	
	halfwidth = imgWidth/2;
    
    // alert('venster: '+windowheight+' afbeelding: '+imgHeight+' verschil: '+imgMarginTop);
    
    kaderheight = imgHeight+90;
	kaderwidth = imgWidth+40;

	kaderMarginTop = imgMarginTop-45+ScrollTop; 
	halfkaderwidth = kaderwidth/2;

	document.getElementById('lightboxkader').style.width = kaderwidth+'px';
	document.getElementById('lightboxkader').style.height = kaderheight+'px';
	document.getElementById('lightboxkader').style.marginLeft = '-'+halfkaderwidth+'px';
	document.getElementById('lightboxkader').style.marginTop = kaderMarginTop+'px';
	
	$('#lightboxkader').fadeIn("fast");
	$('#lightboxbg').fadeIn("fast");

	return true;
	}
 
function lightbox(imgPath, imgTitle) {

	var myImage = new Image();
	myImage.name = imgPath;
	myImage.onload = lightboxafm;
	myImage.src = imgPath;
	document.getElementById('fotogroot').src = imgPath;
	document.getElementById('lightboxdesc').innerHTML = imgTitle;
	}

