var slideBy = 10;
var height = "0";
var slideInterval;
var slideObject;
var currentlySliding = "";

function showAnswer (name) {
  if (slideInterval) window.clearInterval(slideInterval);
  var obj = document.getElementById (name);
  
  // if (currentlySliding == name)
    // return;

  currentlySliding = name;

  if (obj.style.visibility != "hidden")
    hide(obj);
  else
    show(obj);
}

function show (obj) {
  height = obj.offsetHeight;
  obj.style.overflow = "hidden";
  obj.style.height = "0px";

  obj.style.visibility = "visible";
  slideOpenToHeight (obj);
}

function hide (obj) {
  slideClose (obj);
}

function slideOpenToHeight (obj) {
  slideObject = obj;
  slideInterval = window.setInterval ("grow()", 5)
}

function slideClose (obj) {
  slideObject = obj;
  slideInterval = window.setInterval ("shrink()", 5)
}

function grow () {
  var thisHeight = parseInt(slideObject.style.height);
  slideObject.style.position = "relative";
  slideObject.style.top = "0px";
  slideObject.style.left = "0px";

  slideObject.style.height = thisHeight + slideBy;
  if (parseInt(slideObject.style.height) >= height) {
    slideObject.style.height = height;
    window.clearInterval(slideInterval);
    document.getElementById(currentlySliding + "img").src = "images/tri_up.gif";
    currentlySliding = "";
  }
}

function shrink () {
  var thisHeight = parseInt(slideObject.style.height);

  if (thisHeight > slideBy)
    slideObject.style.height = thisHeight - slideBy;
  else {
    slideObject.style.position = "absolute";
    slideObject.style.top = "-1000px";
    slideObject.style.left = "-1000px";
    slideObject.style.overflow = "visible";
    slideObject.style.visibility = "hidden";
    slideObject.style.height = "";
    window.clearInterval(slideInterval);
    document.getElementById(currentlySliding + "img").src = "images/tri_down.gif";
    currentlySliding = "";
  }
}