var _img_max_width = 450; //change this if you want another size
var _img_mouseover_title = 'Clic 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();
		}
	}
}

addLoadEvent(function () {
	if (document.getElementsByTagName) {
		var imgs = document.getElementsByTagName('img');
		for (i = 0; i < imgs.length; i++) {
			var im = imgs[i];
			if (im.getAttribute('rel') != 'resize')	continue;
			var src = im.src;
			var width = im.width;
			var height = im.height;
			if (width > _img_max_width) {
				im.style.width = _img_max_width + 'px';
				im.onclick = function() {
					var pop = window.open(this.src, 'imgbig', 'width=640,height=480, scrollbars=0,resizable=1,toolbar=0');
					//pop.resizeBy(width-pop.document.body.clientWidth,height-pop.document.body.clientHeight);
					pop.focus();
				}
				im.style.cursor = document.all ? 'hand' : 'pointer' ;
				im.style.border = '1px dotted #000';
				im.style.margin = '2px';
				im.title = _img_mouseover_title;
			}
		}
	}
});