function obj(el)
{
    var obj = document.getElementById(el);
    return obj;
}

//met dank aan Crisp van GoT voor dit script!
function checkImg(im) {
  var maxWidth = 450;
  if (typeof im.naturalWidth == 'undefined') im.naturalWidth = im.width;

  if (im.width > maxWidth) {

    im.width = maxWidth;

  }

}
// Script voor het resizen van de plaatjes op het forum
//  Met veel dank aan Crisp van Gathering of Tweakers (http://gathering.tweakers.net)
// © Crisp 2004
var incompetent_browser = document.all && navigator.userAgent.indexOf('MSIE') > -1 && navigator.userAgent.indexOf('Opera') == -1;

function user_images()
{
	var im = document.images, i = im.length;
	while (i--)
	{
		if (im[i].className == 'news_image' || im[i].className == 'special_image' || im[i].className == 'foto')
		{
			if (im[i].naturalWidth || im[i].complete)
				scaleImage(0,im[i]);
			else if (typeof im[i].onreadystatechange != 'undefined')
				im[i].onreadystatechange = scaleImage;
			else
				im[i].onload = scaleImage;
			im[i].onerror = scaleImage;
			im[i].onabort = scaleImage;
		}
	}
	if (incompetent_browser && window.attachEvent) window.attachEvent('onload', user_images_ie); 
}

function user_images_ie()
{
	var im = document.images, i = im.length;
	while (i--)
	{
		if (im[i].className == 'news_image' || im[i].className == 'special_image' || im[i].className == 'foto')
			scaleImage(0,im[i]);
	}
}

function scaleImage(e,img)
{
	if (!img) var img = this;
	var width = height = 0;

	if (img.width || img.complete)
	{
		if (img.naturalWidth)
		{
			width = img.naturalWidth;
			height = img.naturalHeight;
		}
		else if (img.complete)
		{
			var dum = new Image(); dum.src = img.src;
			width = dum.width;
			height = dum.height;
		}
		if (width && img.onreadystatechange) img.onreadystatechange = null;

		if (img.className == 'news_image') 
		{
			var maxWidth = 300;
			var maxHeight = 800;
		}
		else if (img.className == 'special_image') 
		{
			var maxWidth = 260;
			var maxHeight = 800;
		}
		else if (img.className == 'foto')
		{
			var maxWidth = 700;
			var maxHeight = 470;
		}
		
		 
		if (width > maxWidth)
		{
			if (!img.naturalWidth) img.naturalWidth = width;
			if (!img.naturalHeight) img.naturalHeight = height;
			if (img.className == 'news_image') 
			{
				img.className = 'news_image_resized';
			}
			else if (img.className == 'special_image') 
			{
				img.className = 'special_image_resized';
			}
			else if (img.className == 'foto'){
				img.className = 'foto_resized';
			}
		}
		else
		{
			if (!img.naturalWidth) img.naturalWidth = width;
			if (img.className == 'news_image') 
			{
				img.className = 'news_image_resized';
			}
			else if (img.className == 'special_image') 
			{
				img.className = 'special_image_resized';
			}
			else if (img.className == 'foto'){
				img.className = 'foto_resized';
			}
		}
		if (img.width > maxWidth && img.height <= maxHeight) img.width = maxWidth;
		if (img.width <= maxWidth && img.height > maxHeight) img.height = maxHeight;
		if (img.width > maxWidth && img.height > maxHeight) 
		{
			var factorHeight = (maxHeight / img.height);
			if((img.width * factorHeight) > maxWidth)
			{
				img.width = maxWidth;
			}
			else
			{
				img.height = maxHeight;
			}
		}
	}
}
