		function ___getPageSize() {
			var xScroll, yScroll;
			if (window.innerHeight && window.scrollMaxY) {	
				xScroll = window.innerWidth + window.scrollMaxX;
				yScroll = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
			var windowWidth, windowHeight;
			if (self.innerHeight) {	// all except Explorer
				if(document.documentElement.clientWidth){
					windowWidth = document.documentElement.clientWidth; 
				} else {
					windowWidth = self.innerWidth;
				}
				windowHeight = self.innerHeight;
			} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} else if (document.body) { // other Explorers
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}	
			var pageHeightLight;
			// for small pages with total height less then height of the viewport
			if(yScroll < windowHeight){
				pageHeight =yScroll ;
				pageHeightLight=windowHeight;
			} else { 
				pageHeight = windowHeight;
				pageHeightLight=yScroll;
			}
			// for small pages with total width less then width of the viewport
			if(xScroll < windowWidth){	
				pageWidth = xScroll;		
			} else {
				pageWidth = windowWidth;
			}
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight,pageHeightLight);
			return arrayPageSize;
		};
		
		
		function _set_image_to_view(url) { // show the loading
			// Show the loading
			$('#lightbox-loading').show();
			$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
	
			var objImagePreloader = new Image();
			objImagePreloader.onload = function() {
				$('#lightbox-image').attr('src',url);
				// Perfomance an effect in the image container resizing it
				_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);
				//	clear onLoad, IE behaves irratically with animated gifs otherwise
				objImagePreloader.onload=function(){};
					
			};
			objImagePreloader.src = url;
		
			return objImagePreloader.height;
					
		};
	
		function _resize_container_image_box(intImageWidth,intImageHeight,resize) {
			
			$('#jquery-overlay').attr("imgawidthorg",intImageWidth);	
			$('#jquery-overlay').attr("imgaheightorg",intImageHeight);	
			
			var heightGreater=0;
			var widthGreater=0;
		
			// Get current width and height
			var intCurrentWidth = $('#lightbox-container-image-box').width();
			var intCurrentHeight = $('#lightbox-container-image-box').height();
						
			// Get the width and height of the selected image plus the padding
		
			var intWidth = (intImageWidth + (10 * 2)); // Plus the image´s width and the left and right padding value
			var intHeight = (intImageHeight + (10 * 2)); // Plus the image´s height and the left and right padding value
			// Diferences
			var intDiffW =intCurrentWidth - intWidth;
			var intDiffH =intCurrentHeight - intHeight;
		
			
			var arrPageSizes = ___getPageSize();
			var	widthWindows=arrPageSizes[0];
			var heightWindows=arrPageSizes[1];
		
			widthWindows=widthWindows;
			if(widthWindows<intWidth){
				intWidth=widthWindows-50;
				widthGreater=intImageWidth/intWidth;
				
			}
			heightWindows=heightWindows;
			if(heightWindows<intHeight){
				intHeight=heightWindows-80;
				heightGreater=intImageHeight/intHeight;
			}
			
			if(heightGreater<widthGreater){
				intHeight=intImageHeight/widthGreater;
			}
			
			if(widthGreater<heightGreater){
				intWidth=intImageWidth/heightGreater;
			}
			if(widthGreater==0 && heightGreater==0){
				$("#extraLink").hide();
			}else{
				$("#extraLink").show();
			}
			
			// Perfomance the effect
			$('#lightbox-container-image-box').animate({ width: intWidth, height: intHeight },400,function() {
				var w=intWidth-20;
				var h=intHeight-20;
				
				$('#lightbox-image').css({ width: w,height:h});
			  if(resize=="true"){
			  	$('#lightbox-container-image-data-box').css({ width: intWidth,height:0});
				}else{
					$('#lightbox-container-image-data-box').css({ width: intWidth});
			  }
		  $('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ height: intHeight});
				 _show_image(resize); });
			if ( ( intDiffW == 0 ) && ( intDiffH == 0 ) ) {
				if ( $.browser.msie ) {
					___pause(250);
				} else {
					___pause(100);	
				}
			} 
			
		};
		function ___pause(ms) {
			var date = new Date(); 
			curDate = null;
			do { var curDate = new Date(); }
			while ( curDate - date < ms);
		};
	
	function ___getPageScroll() {
			var xScroll, yScroll;
			if (self.pageYOffset) {
				yScroll = self.pageYOffset;
				xScroll = self.pageXOffset;
			} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
				yScroll = document.documentElement.scrollTop;
				xScroll = document.documentElement.scrollLeft;
			} else if (document.body) {// all other Explorers
				yScroll = document.body.scrollTop;
				xScroll = document.body.scrollLeft;	
			}
			arrayPageScroll = new Array(xScroll,yScroll);
			return arrayPageScroll;
		};
	
	function _finish() {
			$('#jquery-lightbox').remove();
			$('#jquery-overlay').fadeOut(function() { $('#jquery-overlay').remove(); });
			// Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
			$('embed, object, select').css({ 'visibility' : 'visible' });
		}
		
	function _show_image(resize) {
			$('#lightbox-loading').hide();
			
			$('#lightbox-container-image-data-box').css({height:38});	
			$('#lightbox-image').fadeIn(function() {
				_show_image_data(resize);
			});
	};	
	
		function _show_image_data(resize) {
			if(resize=="true"){}
			else{
				$('#lightbox-container-image-data-box').slideDown('fast');
			}
			$('#lightbox-image-details-caption').hide();
			$('#jquery-overlay').attr("loadAccess","true");
			
		}
	
	function fullscreenLightbox(img){
		var url;
		if(img.src == undefined){
			url=img.href;
		}else{
			url=img.src;
		}
		$('body').append('<div id="jquery-overlay" load="true"></div><div id="jquery-lightbox">	<div id="lightbox-container-image-box"><div id="lightbox-container-image" style=" height: 95%;">	<img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="/shared/images/jqueryUiImages/lightbox-ico-loading.gif"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="/shared/images/jqueryUiImages/lightbox-btn-close.gif"></a><center><b><a href="#" obj="'+url+'" onclick="fullImge(); return false" id="extraLink" >Klik hier voor ware grootte.</a> </b></center></div></div></div></div>');	
		$("#extraLink").hide();
		var arrPageSizes = ___getPageSize();
		$('#jquery-overlay').css({
				backgroundColor:'#000',
				opacity:			0.8,
				width:				arrPageSizes[0],
				height:				arrPageSizes[4]
			}).fadeIn();
			var arrPageScroll = ___getPageScroll();
			//alert(arrPageSizes[3]+"---"+arrPageScroll[1]);
			// Calculate top and left offset for the jquery-lightbox div object and show it
			$('#jquery-lightbox').css({
				top:	arrPageScroll[1] + (arrPageSizes[3] / 30),
				left:	arrPageScroll[0]
			}).show();
			// Assigning click events in elements to close overlay
			$('#jquery-overlay,#jquery-lightbox').click(function() {
				_finish();									
			});
			// Assign the _finish function to lightbox-loading-link and lightbox-secNav-btnClose objects
			$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function() {
				_finish();
				return false;
			});
			// If window was resized, calculate the new overlay dimensions
			$(window).resize(function() {
				// Get page sizes
				var arrPageSizes = ___getPageSize();
				$('#jquery-overlay').css({
					width:		arrPageSizes[0],
					height:		arrPageSizes[4]
				});
				// Get page scroll
				var arrPageScroll = ___getPageScroll();
				// Calculate top and left offset for the jquery-lightbox div object and show it
				$('#jquery-lightbox').css({
					top:	arrPageScroll[1] + (arrPageSizes[3] / 30),
					left:	arrPageScroll[0]
				});
			});
			var heightIm=0;
			heightIm=_set_image_to_view(url);
			
			if(heightIm < 300 && heightIm >1){
					$('#jquery-lightbox').css({
					top:	arrPageScroll[1] + (arrPageSizes[3] / 4)
				});
			}
	}
		
$(window).resize(function() {

	var imgaWidthOrg = $('#jquery-overlay').attr("imgawidthorg");	
	var imgaHeightOrg=$('#jquery-overlay').attr("imgaheightorg");	
	var loadAccess=$('#jquery-overlay').attr("loadAccess");	
	
	if(loadAccess=="true"){
		$('#jquery-overlay').attr("loadAccess","false");
		$('#lightbox-loading').show();
		$('#lightbox-container-image-data-box').css({ width: 0,height:0});
	 	imgaWidthOrg=parseInt(imgaWidthOrg);
		imgaHeightOrg=parseInt(imgaHeightOrg);
		var resize="true";
		_resize_container_image_box(imgaWidthOrg,imgaHeightOrg,resize);	
	}
});
function fullImge(){
	var url=$("#extraLink").attr("obj");
	window.open(url, "_blank", "status=yes,toolbar=no,resizable=yes,scrollbars=yes,menubar=no,width=700,height=500");
	_finish();		
	return false;
}
