var topText = null;
var newText = null;
var mouseouted = 1;

function rotateText(here, count) {
  if (document.all || document.getElementById){
    setTopTextLink(here);
    topText = document.getElementById("topText");
    newText = document.getElementById("topText-"+count);
    topText.innerHTML = newText.innerHTML;
    revealAllText();
    newText.style.display = "none";
    mouseouted = 0;
  }
}

function setTopTextLink(here) {
    oldlink = document.getElementById("topText-link");
    if (oldlink) {oldlink.setAttribute('id', '')}
    here.setAttribute('id','topText-link');
}

function revertText() {
    mouseouted = 1;
}

function revertText2() {
    mouseouted = 1;
    setInterval("revertTextNow()", 2000);
}

function revertTextNow() {
  if (mouseouted) {
    if (document.all || document.getElementById){
      topText = document.getElementById("topText");
      topTextList = document.getElementById("topTextList");
      topTextListElements = topTextList.getElementsByTagName("div");
      for (var x=0; x<topTextListElements.length; x++) {
        topTextListElements[x].style.display = "block";
      }
      topText.style.display = "none";
    }
  }
}

function revealAllText() {
  if (document.all || document.getElementById){
    topTextList = document.getElementById("topTextList");
    topTextListElements = topTextList.getElementsByTagName("div");
    for (var x=0; x<topTextListElements.length; x++) {
      topTextListElements[x].style.display = "block";
    }
  } 
}
