var AdvContentHeight = 200;
var AdvTimeToSlide = 500;

var AdvOpenAccordion = '';

function runAdvSearchAccordion()
{
  var nID = "rec_search_con_pull_down";

  if(AdvOpenAccordion == nID)
    nID = '';
   
  setTimeout("AdvSearchAnimate('" + new Date().getTime() + "'," + AdvTimeToSlide + ",'" + AdvOpenAccordion + "','" + nID + "')", 0);
 
  AdvOpenAccordion = nID;
}

function AdvSearchAnimate(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);
  var ul      = document.getElementById('rec_search_content');
  // Set Unordered List to hidden each time the 'change site' button is clicked.
  ul.style.display = 'none';

  //var arrow = document.images['imgChangeSiteArrow'];
 

  if(timeLeft <= elapsedTicks)
  {
    if(opening != null)
    {
      opening.style.height = AdvContentHeight + 'px';
      // Set change site arrow
      //if (arrow != null)
	//      arrow.src = '/Consumer/PublishingImages/buttons/arrow_down_dark_close.gif';
    }
   
    if(closing != null)
    {
      closing.style.display = 'none';
      closing.style.height = '0';
      // Set change site arrow
      //if (arrow != null)
	//      arrow.src = '/Consumer/PublishingImages/buttons/arrow_down_dark.gif';
    }

    // Set Unordered List to show after animation is complete.
    ul.style.display = 'block';

    return;
  }
 
  timeLeft -= elapsedTicks;

  var newClosedHeight = Math.round((timeLeft/AdvTimeToSlide) * AdvContentHeight);

  if(opening != null)
  {
    if(opening.style.display != 'block')
    {
      opening.style.display = 'block';
    }

    opening.style.height = (AdvContentHeight - newClosedHeight) + 'px';
  }
 
  if(closing != null)
  {
    closing.style.height = newClosedHeight + 'px';
  }

  setTimeout("AdvSearchAnimate(" + curTick + "," + timeLeft + ",'" + closingId + "','" + openingId + "')", 0);
}

