
var ContentHeight = 200;
var TimeToSlide = 250.0;
var x = [];
var open = []

var openAccordion = '';
for(i=0;i<3;i++)
{
x[i] = document.getElementById("Accordion" + (i+1) + "Content").offsetHeight;
}

for(j=0;j<3;j++)
{
open[j] = true;
}


function runAccordion(index)
{


ContentHeight = x[index-1];

 var nID = "Accordion" + index + "Content";
//alert(open[index-1]);


if(open[index-1] == true)
{
openAccordion = nID;
}


  if(openAccordion == nID)
{   
 nID = '';
open[index-1] = false;
}else if(openAccordion!="")
	{
	openAccordion = ""
	}  


  setTimeout("animate(" + new Date().getTime() + "," + TimeToSlide + ",'"
      + openAccordion + "','" + nID + "')", 33);
 
  openAccordion = nID;
if(nID)
{
open[index-1] =  true;
}

}

function animate(lastTick, timeLeft, closingId, openingId)
{  
  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';
   
    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 + "')", 33);
}
