var resized_images_width = new Array();
var resized_images_height = new Array();

	function fullscreen(){
		scrollbars = 0;
		var oSource = window.event.srcElement.src;
		width = resized_images_width[oSource];
		height = resized_images_height[oSource];

		url = "img/source="+oSource+"&width="+width+"&height="+height;

		if(width > screen.availWidth){
			width = screen.availWidth;
			scrollbars = 1;
		}

		if(height > screen.availHeight){
			height = screen.availHeight;
			scrollbars = 1;
		}

		fullscr = window.open(url, "_blank","toolbar=no,location=no,menubar=no,fullscreen="+scrollbars+",channelmode="+scrollbars+",scrollbars="+scrollbars+",status=no,left=0,top=0,width="+width+",height="+height);
	}

	function resize(image){
		if(!image){
			var image = window.event.srcElement;
		}

		width = image.width;
		height = image.height;
		var url = image.src;

		if(width>500){
			resized_images_width[url] = width;
			resized_images_height[url] = height;
			image.width = 500;
			image.alt = 'Originele grootte: '+width+'x'+height+'. Klik voor de volledige versie van dit plaatje!';
			image.style.border = "dotted 1px black";
			image.style.cursor = "hand";
			image.onclick = fullscreen;
			image.height = Math.floor(height/(width/500));
			if (Math.floor(height/(width/500))>550)
			{
				image.height=550;
				image.width=Math.floor(500/((Math.floor(height/(width/500)))/550));
			}
		}
		else
		{
	                if (height>550){
	                        resized_images_width[url] = width;
	                        resized_images_height[url] = height;
	                        image.height = 550;
	                        image.alt = 'Originele grootte: '+width+'x'+height+'. Klik voor de volledige versie van dit plaatje!';
	                        image.style.border = "dotted 1px black";
	                        image.style.cursor = "hand";
	                        image.onclick = fullscreen;
	                        image.width = Math.floor(width/(height/550));
        	        }
		}
	}

	function check_images(){
		count = document.images.length;
		i = 0;

		while(count>i){
			url = document.images[i].src;

			if(!url.match(/e-progimg/)){
				if(document.images[i].complete){
					resize(document.images[i]);
				}else{
					document.images[i].onload = resize;
				}
			}

			i++;
		}
	}
