/* 2007 05 18
   Sets maximal newloginbox user profile image width and height.
*/

function setMaxWidthAndHeight()
{
	
	var maxH = 150;
	var maxW = 300;
	var img = document.getElementById("user_profile_img");

	// Grab the image's dimensions
	var imgH = img.clientHeight;
	var imgW = img.clientWidth;
	var scaleH = imgH/maxH; 
	var scaleW = imgW/maxW; 
	var maxscale = 0;
	
	//document.write("imgH, imgW, scaleH, scaleW-" + imgH+", "+imgW+", "+scaleH+", "+scaleW);
	
	if (scaleH > scaleW){
		maxscale = scaleH;
	}else{
		maxscale = scaleW;
	}
	if (scaleH > scaleW){	
		img.style.height = maxH + "px";
		img.style.width = Math.round(imgW / maxscale) + "px";
		//document.write("imgW, imgW, scaleH, scaleW-" + imgH+", "+imgW+", "+Math.round(imgW / maxscale)+", "+maxscale);
	} else {
		
		img.style.width = maxW + "px";
		img.style.height = Math.round(imgH / maxscale) + "px";
		//document.write("imgH, imgW, scaleH, scaleW-" + imgH+", "+imgW+", "+Math.round(imgH / maxscale)+", "+maxscale);
	}

	//document.getElementById("user_profile_img").style.maxWidth="300px";
	//document.getElementById("user_profile_img").style.maxHeight="150px";
}