function getImage()
{
  $uri = document.getElementById("feeduri").value;
  if ($uri)
  {
    $uri = $uri.toLowerCase();
    if (($index = $uri.indexOf("http://")) != -1)
    {
      $uri = $uri.substr($index + "http://".length, $uri.length);
    }
    if (($index = $uri.indexOf("feeds.feedburner.com/")) != -1)
    {
		$uri = $uri.substr($index + "feeds.feedburner.com/".length, $uri.length);
		$tokens = $uri.split("/");
		if ($tokens.length >= 1)
		{
		  // First check index 0, if it's not "~r" use it
		  // else if it is "~r", try index 1
		  if ($tokens[0] != "~r")
		  {
			setImgSource($tokens[0]);
			return;
		  }
		  else if ($tokens.length > 1)
		  {
			setImgSource($tokens[1]);
			return;
		  }
		}
    }
  }
  
  showHideImg(false);
}

function onImageError()
{
  showHideImg(false);
  return true;
}

function setImgSource($userid)
{
  $imgUri = "http://feeds.feedburner.com/~fc/" + $userid;
  $feedimg = document.getElementById("feedimg");
  $feedimg.src = $imgUri;
  showHideImg(true);
}

function showHideImg($show)
{
  $feedimg = document.getElementById("feedimg");
  $feedimg.style.display = ($show) ? 'block' : 'none';
}

function hideIfEmpty($el)
{
  if (!$el.value)
  {
    showHideImg(false);
  }
}