// JavaScript Document
function mouseOver(obj) {
	obj.style.backgroundColor='#ecf7ff';
}

function mouseOut(obj) {
	obj.style.backgroundColor='#fff';
}

/**

 * 按照比例调整图片大小，限定了最大的宽高，并且设置了marginLeft和marginTop

 * （使用时请注意：1、原有margin样式；2、ie6的水平空白边加倍bug）

 * @param {Object} ImgD

 * @param {Object} iwidth	图片最大宽度

 * @param {Object} iheight	图片最大高度

 * @param {Object} mleft	图片以正方形算的左边空白边

 * @param {Object} mtop		图片以正方形算的顶部空白边

 */

function resizeimg(ImgD, iwidth, iheight, mleft, mtop){

    var image = new Image();

    image.src = ImgD.src;

    if (image.width > 0 && image.height > 0) {

        if (image.width / image.height >= iwidth / iheight) {//宽度比较大

            if (image.width > iwidth) {

                ImgD.width = iwidth;

                ImgD.height = (image.height * iwidth) / image.width;

            }

            else {

                ImgD.width = image.width;

                ImgD.height = image.height;

            }

        }

        else {//高度比较大

            if (image.height > iheight) {

                ImgD.height = iheight;

                ImgD.width = (image.width * iheight) / image.height;

            }

            else {

                ImgD.width = image.width;

                ImgD.height = image.height;

            }

        }

        //ImgD.alt = ImgD.width + '×' + ImgD.height;

		if(ImgD.width>0 && ImgD.height>0) {//过滤掉不能读出ImgD的情况

		    ImgD.style.marginLeft = (iwidth - ImgD.width) / 2 + mleft + 'px';

		    ImgD.style.marginTop = (iheight - ImgD.height) / 2 + mtop + 'px';

		    ImgD.style.float = 'left';

		    ImgD.style.display = 'inline';

		}

    }

}
