function imgFit(imageArr,width,height)
{
    sWidth=imageArr.offsetWidth;
    sHeight=imageArr.offsetHeight;
    imageRate1=parseInt(imageArr.offsetWidth)/width;
    imageRate2=parseInt(imageArr.offsetHeight)/height;
    if(sWidth>width || sHeight>height)
    {
        if(imageRate2>imageRate1)
        {
            imageArr.style.height = sHeight/imageRate2+"px";
            imageArr.style.marginRight = imageArr.style.marginLeft = (width-sWidth/imageRate2)/2+"px";
        }
        else
        {
            imageArr.style.width = sWidth/imageRate1 +"px";
            imageArr.style.marginBottom = imageArr.style.marginTop = (height-sHeight/imageRate1)/2+"px";
        }
    }
    else
    {
        imageArr.style.marginRight = imageArr.style.marginLeft = (width-sWidth)/2+"px";
        imageArr.style.marginBottom = imageArr.style.marginTop = (height-sHeight)/2+"px";
    }
}