﻿jQuery.fn.auSize = function(width,height)
{
	var ImgArr = $(this).children("img");
    ImgArr.each(function(){
        var image = $(this);
        if(image.width()>width){
            image.width(width);
            image.height(width/image.width()*image.height());
        }
        if(image.height()>height){
            image.height(height);
            image.width(height/image.height()*image.width());
        }
		//让图片居中显示
		var margin_top	=(height-image.height())/2;
		var margin_left	=(width-image.width())/2;
		image.css({"margin-top":margin_top,"margin-left":margin_left});

    });
} 

