//var ContentHeight = 50;

var TimeToSlide = 250.0;

var openAccordion = new Array();

function runAccordion(index, ContentHeight)
{
  var nID = "Accordion" + index + "Content";
 
 
  if(openAccordion[index] == nID)
    nID = '';
    
  setTimeout("animate(" + new Date().getTime() + "," + TimeToSlide + ",'"
      + openAccordion[index] + "','" + nID + "','" + ContentHeight + "')", 33);
 
  openAccordion[index] = nID;
}


function animate(lastTick, timeLeft, closingId, openingId, ContentHeight)
{  
  var curTick = new Date().getTime();
  var elapsedTicks = curTick - lastTick;
 
  var opening = (openingId == '') ? null : document.getElementById(openingId);
  var closing = (closingId == '') ? null : document.getElementById(closingId);
 
  
  if(timeLeft <= elapsedTicks)
  {
    if(opening != null)
     // opening.style.height = ContentHeight + 'px';    
  		opening.style.height = 'auto';
   
    if(closing != null)
    {
      closing.style.display = 'none';
      closing.style.height = '0px';
    }
    return;
  }
 
  timeLeft -= elapsedTicks; 
  var newClosedHeight = Math.round((timeLeft/TimeToSlide) * ContentHeight);

  if(opening != null)
  {
    if(opening.style.display != 'block')
      opening.style.display = 'block';
    opening.style.height = (ContentHeight - newClosedHeight) + 'px';
  }
 
  if(closing != null)
    closing.style.height = newClosedHeight + 'px';

  setTimeout("animate(" + curTick + "," + timeLeft + ",'"
      + closingId + "','" + openingId + "','" + ContentHeight + "')", 33);
}
