var defaultContentHeight = 200;
var ContentHeight = defaultContentHeight;
var TimeToSlide = 250.0;
var accordionInterval;

var openAccordion = new Array;

function runAccordion(index,group,aHeight){


  var nID = "Accordion" + index + "Content" + group;

	if(aHeight!=null){
		ContentHeight = aHeight;
	}else{
		ContentHeight = defaultContentHeight;
	}
  if(openAccordion[group] == nID){
	  openAccordion[group] = '';
	  var opening = (nID == '') ? null : document.getElementById(nID);
          opening.style.display = 'block'; 
          opening.style.height = ContentHeight + 'px';
    
  }else{

   setTimeout("animateAccordion(" + new Date().getTime() + "," + TimeToSlide + ",'" + openAccordion[group]  + "','" + nID + "')", 33);
  }
   
      	if(accordionInterval){
		clearInterval(accordionInterval);
	}
	
 
  
  openAccordion[group] = nID;

}

function animateAccordion(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(closing != null)
    {
      closing.style.display = 'none';
      closing.style.height = '0px';
    }
    if(opening != null){
      opening.style.height = ContentHeight + 'px';
      opening.style.overflow = 'visible';   

      return;
      

    }
  }
 
  timeLeft -= elapsedTicks;
  var newClosedHeight = Math.round((timeLeft/TimeToSlide) * ContentHeight);

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


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