function Browser()
{
	this.opera = navigator.userAgent.indexOf('Opera') > -1;
	this.ie = !this.opera && document.all && navigator.userAgent.indexOf('MSIE') > -1;
	this.ie50 = this.ie && navigator.userAgent.indexOf('MSIE 5.0') > -1;
}
var browser = new Browser();

var resized_images_width = new Array();
var resized_images_height = new Array();
var max_width = 550;

function image_full()
{
	scrollbars = 0;
	src = this.src;
	width = this.naturalWidth;
	height = this.naturalHeight;

	url = "http://www.zootycoon.nl/image.php?src=" + escape(src) + "&width=" + width + "&height=" + height;

	if ( width > screen.availWidth )
	{
		width = screen.availWidth;
		scrollbars = 1;
	}
	
	if ( height > screen.availHeigth )
	{
		height = screen.availHeight;
		scrollbars = 1;	
	}

	full = window.open(url, "_image", "toolbar=no, location=no, menubar=no, fullscreen=" + scrollbars + ", channelmode=" + scrollbars + ", scrollbars=" + scrollbars + ", status=no, width=" + width + ", height=" + height);
}

function image_resize(e, img)
{
	if (!img) img = this;
	var imgwidth = 0, imgheight = 0, el;

	if (img.width || img.complete)
	{
		if (img.naturalWidth)
		{
			imgwidth = img.naturalWidth;
			imgheight = img.naturalHeight;
		}
		else if (img.complete)
		{
			var dum = new Image(); dum.src = img.src;
			imgwidth = dum.width;
			imgheight = dum.height;
		}
		if (imgwidth && img.onreadystatechange) img.onreadystatechange = null;

		if (img.width > max_width)
		{
			if (img.parentNode.tagName.toLowerCase() != 'a')
			{
				if (!img.naturalWidth) img.naturalWidth = imgwidth;
				if (!img.naturalHeight) img.naturalHeight = imgheight;
				img.className += ' resized';
				img.onclick = image_full;
				el = img;
			}
			else
			{
				img.className += ' resized';
				el = img.parentNode;
			}
			
			img.title = 'Originele grootte: ' + img.width + 'x' + img.height;

			if (img.height) img.height = Math.round(max_width / img.width * img.height);
			img.width = max_width;
		}
	}
}

function image_check()
{
	var im = document.getElementsByTagName('img'), i = im.length;
	while (i--)
	{
		if (im[i].naturalWidth || im[i].complete)
			image_resize(0,im[i]);
		else if (typeof im[i].onreadystatechange != 'undefined')
			im[i].onreadystatechange = image_resize;
		else
			im[i].onload = image_resize;
		im[i].onerror = image_resize;
		im[i].onabort = image_resize;
	}

	if (browser.ie && window.attachEvent) window.attachEvent('onload', image_check); 
}

function image_check_ie()
{
	var im = document.images, i = im.length;
	while (i--)
	{
		image_check(0,im[i]);
	}
}