
Maxwidth = 100;
Maxheight = 100;	

function setImgDimensions(objImg)
{
	var startwidth;
    var startheight;
    var endwidth;
    var endheight;
    
	startwidth = objImg.clientWidth;
    startheight = objImg.clientHeight;
    
    endwidth = startwidth;
    endheight = startheight;
    
    if (startwidth>Maxwidth || startheight>Maxheight)
    {
		if(startwidth > startheight)
		{
			endheight = (Maxwidth / startwidth)*startheight;
			endwidth =  Maxwidth;
		}
		else
		{
			endwidth = (Maxheight / startheight)*startwidth;
			endheight =  Maxheight;
		}
		
		objImg.width = endwidth;
		objImg.height = endheight;
	}
}
