function prepareExtLinks()
{
  var articles = document.getElementsByTagName("BODY");
  var n;
  
  for (n=0; n < articles.length; n++)
  {
    //if (articles[n].className == "blogentry")
    {
      var links = articles[n].getElementsByTagName("A");
      var l;
      
      for (l=0; l < links.length; l++)
      {
        if (links[l].href.length > 0 &&
            links[l].href.substr(0, 18) != "http://twitter.com" &&
            links[l].href.substr(0, 19) != "http://ratioblog.de" &&
            links[l].href.substr(0, 23) != "http://www.ratioblog.de" &&
            (links[l].target == "_blank" ||
             links[l].target == "_top" ||
             links[l].className == "external")
           )
        {
          links[l].setAttribute("onclick", "return extLinkClick(this);");
        }
      } 
    }
  }
}

function extLinkClick(anchor)
{
  var client = new XMLHttpRequest();
  client.open("POST", "/useraction");
  
  client.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  client.setRequestHeader("X-Request-Type", "internal");
  client.onreadystatechange = HandleUserActionResponse;
  
  var Params ="action=extlinkclick"+
              "&to=" + encodeURIComponent(anchor.href);
  client.send(Params);
  delete client;
  
  return true;
}

function HandleUserActionResponse()
{
  return;
}

