var ContentWidth = 515;
var TimeToSlide = 250.0;

var openAccordion = '';

function runAccordion(index)
{
  var praxiszeiten = document.getElementById('praxis_zeiten');
  var nID = "Accordion" + index + "Content";
  if(openAccordion == nID)
    nID = '';
  else
  {
     praxiszeiten.style.display = 'none';
     praxiszeiten.style.width = '0px';
    }
    
  setTimeout("animate(" 
      + new Date().getTime() + "," + TimeToSlide + ",'" 
      + openAccordion + "','" + nID + "')", 33);
  
  openAccordion = nID;
}


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

  if(opening != null)
  {
    if(opening.style.display != 'block')
      opening.style.display = 'block';
    opening.style.width = 
        (ContentWidth - newClosedWidth) + 'px';
  }
  
  if(closing != null)
    closing.style.width = newClosedWidth + 'px';

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