 function AutoResizeImage(objImg,Size_Right,Size_Bottom,DecW,DecH){ 
 var hRatio = objImg.getBoundingClientRect().width/objImg.getBoundingClientRect().height; 
 var wRatio = objImg.getBoundingClientRect().height/objImg.getBoundingClientRect().width; 
 var w = objImg.getBoundingClientRect().width - DecW; 
 var h = objImg.getBoundingClientRect().height - DecH;  
 var pw = objImg.parentNode.getBoundingClientRect().width; 
 var ph = objImg.parentNode.getBoundingClientRect().height;  
 if(ph==0) {
   var pw = document.documentElement.clientWidth || document.body.clientWidth; 
   var ph = document.documentElement.clientHeight || document.body.clientHeight;  
 }
 var w = objImg.getBoundingClientRect().width - DecW; 
 var h = objImg.getBoundingClientRect().height - DecH;  
var Change = false;  
 if (pw < w + 3){ 
 w = pw; 
 h = objImg.getBoundingClientRect().height - (objImg.getBoundingClientRect().width - w)*wRatio; 
 Change = true;
} 
 if (ph < h + 3){ 
 h = ph;
 w = objImg.getBoundingClientRect().width - (objImg.getBoundingClientRect().height - h)*hRatio; 
 Change = true;
} 
if(Change) {w = w - Size_Right}
 w = w - Size_Right;
if(Change) {h = h - Size_Bottom}
 h = h - Size_Bottom;
 objImg.style.setProperty('width', w + "px", 'important');  
 objImg.style.setProperty('height', h + "px", 'important'); 
var centerleft = (- (w/2)) + 'px'; 
 objImg.style.setProperty('margin-left', centerleft, 'important');  
  
} 

