function commonProductDrawImage(ImgD,awidth,aheight){ 
	var image=new Image(); 
	image.src=ImgD.src; 
	
	// set width
	var v_width=awidth;
	// set height
	var v_height=aheight;
	
	
	var s_w = 0;
	var s_h = 0;

	if(image.width<=v_width && image.height<=v_height){
		// if smaller than..
		s_h=image.height;
		s_w=image.width;

	}else{
		//if biger than
		var v_wbh = v_width/v_height;
		var now_wbh = image.width/image.height;
		if(v_wbh>=now_wbh){
			s_h=v_height;
			s_w=v_height*now_wbh;
		}else{
			s_w=v_width;
			s_h=v_width/now_wbh;				
		}
	}
	
	ImgD.width=s_w;
	ImgD.height=s_h;	
	
	if(s_h<aheight){
		var top = (aheight-s_h)/2;
		
		ImgD.style.cssText="margin-top:"+top+"px;";
	}

} 
