﻿// JavaScript Document
var flag_img=false;
function DrawImage(ImgD,int_width,int_height){
	var image=new Image();
	//var int_width=323;
	//var int_height=316;
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		flag_img=true;
		if(image.width/image.height>= int_width/int_height){
			if(image.width>int_width){ 
				ImgD.width=int_width;
				ImgD.height=(image.height*int_width)/image.width;
			}else{
				ImgD.width=image.width; 
				ImgD.height=image.height;
			}

			var m_top = (int_height-ImgD.height)/2;
			//ImgD.style.margin= m_top+"px 0px";
			//alert($(ImgD).css('margin'));
			//$(ImgD).css("margin","auto 0px");
			//ImgD.alt=image.width+"×"+image.height;
		}
		else{
			if(image.height>int_height){ 
				ImgD.height=int_height;
				ImgD.width=(image.width*int_height)/image.height; 
			}else{
				ImgD.width=image.width; 
				ImgD.height=image.height;
			}
			var m_height = (int_width-ImgD.width)/2;
			//ImgD.style.margin="0px "+m_height+"px";
			//$(ImgD).css("margin","auto 0px");
			//ImgD.alt=image.width+"×"+image.height;
		}
	}
} 