  var newstickerReady = false;
  var xmlTitles = null;
  var xmlHeadlines = null;
  var xmlLinks = null;
  var actualNewsItem = 0;
  var newstickerTitleElement = null;
  var newstickerElement = null;  
  
  function getNews() {
    var url = "newsticker.xml?dummy=" + new Date().getTime();
    anfrage.open("GET", url, true);
    anfrage.onreadystatechange = updateNewsTicker;
    anfrage.send(null);
  }
  
  function updateNewsTicker() {
    if (anfrage.readyState == 4) {
      if (anfrage.status == 200) {
        var xmlDoc = anfrage.responseXML;
        xmlTitles = xmlDoc.getElementsByTagName("title");
        xmlHeadlines = xmlDoc.getElementsByTagName("headline");
        xmlLinks = xmlDoc.getElementsByTagName("newslink");
        newstickerReady = true;
      } else {

      }
    }
  }
  
  function displayNews() {
    if (xmlTitles != null) {
      var title = xmlTitles[actualNewsItem].firstChild.nodeValue;
      var headline = xmlHeadlines[actualNewsItem].firstChild.nodeValue;
      var href = xmlLinks[actualNewsItem].firstChild.nodeValue;
      //var link = "<a class=\"newsticker\" href=\"" + href + "\">" + headline + "</a>";
     replaceText(newstickerTitleElement, title);
      var oldLinkElement = document.getElementById("newsticker").firstChild;
      var aElement = document.createElement("a");
      var classAttribute = document.createAttribute("class");
      classAttribute.nodeValue = "newsticker";
      aElement.setAttributeNode(classAttribute);
      var hrefAttribute = document.createAttribute("href");
      hrefAttribute.nodeValue = href;
      aElement.setAttributeNode(hrefAttribute);
      var textElement = document.createTextNode(headline);
      aElement.appendChild(textElement);
      newstickerElement.replaceChild(aElement, oldLinkElement);
      //replaceText(newstickerElement, link);
      actualNewsItem = (actualNewsItem + 1) % xmlTitles.length;
    }
    setTimeout("displayNews()", 5000);
  }
  
  function runNewsTicker() {
    newstickerTitleElement = document.getElementById("newsticker_title");
    newstickerElement = document.getElementById("newsticker");
    getNews();
    setTimeout("displayNews()", 1000);
  }
  
  window.onload = runNewsTicker;
