var _img_max_width				= 650; //change this if you want another size
var _img_mouseover_title	= 'Click here to view full size image.'; //Change here for the message to display when the mouse is over the resized image

//Don't touch anything after here if you don't know what are you doing.
function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function()
		{
			if (oldonload)
			{
				oldonload();
			}
			func();
		}
	}
}

var resize_image = function(width, height)
{
	return function()
	{
		var _w = width + 20;
		var _h = height + 20;
		var pop = window.open(this.src, 'imgbig', 'width='+ _w +',height='+ _h + ', scrollbars=0,resizable=0,toolbar=0');
		if (!pop)
		{
			return false;
		}
		pop.resizeBy(pop.document.body.clientWidth - _w + 20, pop.document.body.clientHeight - _h + 20);
		var _top	= (screen.height / 2) - (_h / 2);
		var _left	= (screen.width / 2) - (_w / 2);
		pop.moveTo(_left, _top);
		pop.focus();
	}
}

addLoadEvent(function ()
{
	var imgs = document.getElementsByTagName('img');
	for (var i = 0, _length = imgs.length; i < _length; i++)
	{
		var im = imgs[i];
		if (im.getAttribute('rel') != 'resize')
		{
			continue;
		}
		var _width	= im.width;
		var _height	= im.height;
		if (_width > _img_max_width)
		{
			im.width					= _img_max_width;
			im.onclick				= resize_image(_width, _height);
			im.style.cursor		= document.all ? 'hand' : 'pointer' ;
			im.style.border		= '1px dotted #000';
			im.style.margin		= '2px';
			im.title					= _img_mouseover_title;
		}
	}
});