
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 (document.getElementById(openingId))
	  {
   	  
	  x = openingId.replace("Accordion","") 
	  x = x.replace("Content","") 
	  document.getElementById("AccordionTitle"+x).style.background = "url(http://images.figleaves.com/uk/images/eng-gbr/products/prev_arrow.png) #d1d1d1 no-repeat 230px 5px" ;

	  }
	  if (document.getElementById(closingId))
	  {
	  x = closingId.replace("Accordion","") 
	  x = x.replace("Content","") 
	  document.getElementById("AccordionTitle"+x).style.background = "url(http://images.figleaves.com/uk/images/eng-gbr/products/next_arrow.png) #d1d1d1 no-repeat 230px 5px" ;
	  }
 
  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 runAccordion(index, xContentHeight)
{
	
 
 id="AccordionTitle1" 
  var nID = "Accordion" + index + "Content";
  var tID = "AccordionTitle"  + index ;
  
  //document.getElementById(tID).style.background = "url(images/prev_arrow.png) #d1d1d1 no-repeat 230px 2px"   
  for (i=1; i<10; i++)
  {
	  var tID = "AccordionTitle"  + i ;
	 
  }
  //var tID = "AccordionTitle"  + index ;
 // document.getElementById(tID).style.background = "url(images/next_arrow.png) #d1d1d1 no-repeat 230px 2px" 
  
  if(openAccordion == nID)
    nID = '';
    
  ContentHeight = xContentHeight;
  
  setTimeout("animate(" + new Date().getTime() + "," + TimeToSlide + ",'" 
      + openAccordion + "','" + nID + "')", 33 );
  
  openAccordion = nID;
}

//=======================================================================================================


