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 = "http://www.autoweek.nl/image.php?src="+escape(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>800){
			resized_images_width[url] = width;
			resized_images_height[url] = height;
			image.width = 800;
			image.alt = 'Origineel: '+width+'x'+height;
			image.style.border = "dashed 1px black";
			image.style.cursor = "hand";
			image.onclick = fullscreen;
			image.height = Math.floor(height/(width/800));
		}
	}

	function check_images(){
		count = document.images.length;
		i = 0;

		while(count>i){
			url = document.images[i].src;
            match = url.search('spacer.gif');

            if (match==-1)
			    if(document.images[i].complete){
				    resize(document.images[i]);
			    }else{
				    document.images[i].onload = resize;
			    }

			i++;
		}
	}