function getElementsByClassName(cl, tag, node) {
	var retnode = [];
	var myclass = new RegExp('\\b'+cl+'\\b');
	var elem = node.getElementsByTagName(tag);
	for (var i = 0; i < elem.length; i++) {
		var classes = elem[i].className;
		if (myclass.test(classes)) retnode.push(elem[i]);
	}
	return retnode;
}

function resizeThumbnails(maxWidth, maxHeight) {
	var tnList = getElementsByClassName('k', 'img', document.body);
	
	for (var i=0; i<tnList.length; i++) {
		var imgO = new Image();
		imgO.src = tnList[i].src;
		if (imgO.width > maxWidth || imgO.height > maxHeight) {
			if (imgO.width/imgO.height > maxWidth/maxHeight) {
				var width = maxWidth;
				var height = imgO.height*maxWidth/imgO.width;
			} else {
				var height = maxHeight;
				var width = imgO.width*maxHeight/imgO.height;
			}
			tnList[i].style.width = width + "px";
			tnList[i].style.height = height + "px";
		}
	}
}

function resizeCells(maxWidth) {
	var cellList = getElementsByClassName('k', '*', document);
	//alert(document.getElementsByTagName('td').length);
	
	for (var i=0; i<cellList.length; i++) {
		if (cellList[i].style.width > maxWidth) {
			cellList[i].style.width = maxWidth + "px";
		}
	}
}

if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
	window.attachEvent("onload", function() {resizeThumbnails(105, 98);});
} else if (navigator.platform == "Win32" && navigator.appName == "Opera" && window.attachEvent) {
	resizeCells(109);

}
