function addOnloadEvent(fnc) {
if (typeof window.addEventListener != "undefined")
window.addEventListener("load", fnc, false);
else if (typeof window.attachEvent != "undefined") {
window.attachEvent("onload", fnc);
}
else {
if (window.onload != null) {
var oldOnload = window.onload;
window.onload = function(e) {
oldOnload(e);
window[fnc]();
};
}
else
window.onload = fnc;
}
}
function changeSize() {
MAX_WIDTH=400;
var imgs = document.getElementsByTagName("img");
var l = imgs.length;
for (i = 0; i < l; i++) {
var img = imgs.item(i);
cw = img.width;
if (cw > MAX_WIDTH) {
img.width = MAX_WIDTH;
img.height = img.height * MAX_WIDTH / cw;
}
}
}
addOnloadEvent(changeSize);