function AutoSizeImage(ImgD,MyType,MyValue)
{ 
	var image=new Image(); 
	var w,h,b;
	image.src=ImgD.src; 
	if (MyType=="Width")
	{
		if (image.width<MyValue)
		{
			ImgD.width=image.width;
			ImgD.height=image.height;
		}
		else
		{
			w=MyValue;
			b=w/image.width;
			h=image.height*b
			ImgD.width=w;
			ImgD.height=h;
		}
	}
	else if (MyType=="Height")
	{
		if (image.height<MyValue)
		{
			ImgD.width=image.width;
			ImgD.height=image.height;
		}
		else
		{
			h=MyValue;
			b=h/image.height;
			w=image.width*b;
			ImgD.width=w;
			ImgD.height=h;
		}
	}
}

