function changeSize(obj, width, height){
    if(obj.offsetWidth > width){
        obj.style.width = width + 'px';
        obj.style.height = (obj.offsetHeight / obj.offsetWidth * width) + 'px';
    }
    if(obj.offsetHeight > height){
        obj.style.height = height + 'px';
        obj.style.width = (obj.offsetWidth / obj.offsetHeight * height) + 'px';
    }
    if(obj.offsetWidth < width){
        obj.style.marginLeft = ((width - obj.offsetWidth) / 2) + 'px';
    }
    if(obj.offsetHeight < height){
        obj.style.marginTop = ((height - obj.offsetHeight) / 2) + 'px';
    }
}
