var ContentHeight = 89;
var ContentHeight2 = 121;
var TimeToSlide = 250.0;

var openAccordion = '';
var openAccordion2 = '';

function runAccordion(index)
{

	if ((openAccordion=="Accordion" + index + "Content")) {
		return;
	}

  var nID = "Accordion" + index + "Content";
  if(openAccordion == nID)
    nID = '';

  setTimeout("animate(" + new Date().getTime() + "," + TimeToSlide + ",'" + openAccordion + "','" + nID + "')", 33);

  openAccordion = nID;
}

function runAccordion2(index)
{

	if ((openAccordion2=="Accordion" + index + "Content")) {
		return;
	}

  var nID = "Accordion" + index + "Content";
  if(openAccordion2 == nID)
    nID = '';

  setTimeout("animate2(" + new Date().getTime() + "," + TimeToSlide + ",'" + openAccordion2 + "','" + nID + "')", 33);

  openAccordion2 = nID;
}


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);
}


function animate2(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 = ContentHeight2 + 'px';

    if(closing != null)
    {
      closing.style.display = 'none';
      closing.style.height = '0px';
    }
    return;
  }

  timeLeft -= elapsedTicks;
  var newClosedHeight = Math.round((timeLeft/TimeToSlide) * ContentHeight2);

  if(opening != null)
  {
    if(opening.style.display != 'block')
      opening.style.display = 'block';
    opening.style.height = (ContentHeight2 - newClosedHeight) + 'px';
  }

  if(closing != null)
    closing.style.height = newClosedHeight + 'px';

  setTimeout("animate2(" + curTick + "," + timeLeft +",'" + closingId + "','" + openingId + "')", 33);
}
