function previewExternalAvatar(src)
{
	if (!document.getElementById("avatar"))
		return;
	
	var maxHeight = 65;
	var maxWidth = 65;
	var tempImage = new Image();

	tempImage.src = src;
	if (maxWidth != 0 && tempImage.width > maxWidth)
	{
		document.getElementById("avatar").style.height = parseInt((maxWidth * tempImage.height) / tempImage.width) + "px";
		document.getElementById("avatar").style.width = maxWidth + "px";
	}
	else if (maxHeight != 0 && tempImage.height > maxHeight)
	{
		document.getElementById("avatar").style.width = parseInt((maxHeight * tempImage.width) / tempImage.height) + "px";
		document.getElementById("avatar").style.height = maxHeight + "px";
	}
	document.getElementById("avatar").src = src;
}

// Find a specific radio button in its group and select it.
function selectRadioByName(radioGroup, name)
{
	if (typeof(radioGroup.length) == "undefined")
		return radioGroup.checked = true;

	for (var i = 0; i < radioGroup.length; i++)
	{
		if (radioGroup[i].value == name)
			return radioGroup[i].checked = true;
	}

	return false;
}