﻿function resizePictures(){
    var ContentPane = document.getElementById('MMContent');
    if(ContentPane){
        var images = ContentPane.getElementsByTagName('img');
        // loop through all anchor tags
        for (var i=0; i<images.length; i++){
	        var img = images[i];
		    reSize(img,280,280);
        }
    }
    var CommentPane = document.getElementById('MMComment');
    if(CommentPane){
        var images = CommentPane.getElementsByTagName('img');
        // loop through all anchor tags
        for (var i=0; i<images.length; i++){
	        var img = images[i];
		    reSize(img,280,280);
        }
    }
}
function reSize(myImg, maxWidth, maxHeight)
{
    var iniPicWidth = myImg.width;
    var iniPicHeight = myImg.height;
    var iniRate = iniPicHeight/iniPicWidth;
    if(iniPicWidth>maxWidth || iniPicHeight>maxHeight){
        var newW = maxWidth;
        var newH = Math.floor(newW*iniRate);
        if (newH>maxHeight)
        {
	        var newH = maxHeight;
	        var newW = Math.floor(newH/iniRate);
        }
        myImg.width = newW;
        myImg.height = newH;
    }
}
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
	        oldonload();
	        func();
        }
    }
}