var _img_max_width = 650; //change this if you want another size
var _img_mouseover_title = 'Click here to view image in full size.'; //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 resizeImg = function(w, h) {
	return function() {
		var _w = w + 20;
		var _h = h + 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 (i = 0; i < imgs.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 = resizeImg(_width, _height);
			im.style.cursor = document.all ? 'hand' : 'pointer' ;
			im.style.border = '1px';
			im.style.margin = '2px';
			im.title = _img_mouseover_title;
		}
	}
});