var active = -1;
var heights = [];
$(function()
{
  var i = 0;
  $(".accordion-child").each(function()
  {
    heights[i++] = this.offsetHeight;
    var _this = $(this);
    _this.css("height", "0px");
    _this.hide();
  });
});
function showPane(index)
{
  if(active == index) return;
  if(active != -1)
  {
    var div = $("#accordion > div:eq(" + active + ")");
    div.animate({height: 0}, 500, function()
    {
      div.hide();
      active = index;
      if(active != -1)
      {
        var div2 = $("#accordion > div:eq(" + active + ")");
        div2.show();
        div2.animate({height: heights[active] + "px"}, 500);
      }
    });
  }
  else
  {
    active = index;
    if(active != -1)
    {
      var div2 = $("#accordion > div:eq(" + active + ")");
      div2.show();
      div2.animate({height: heights[active] + "px"}, 500);
    }
  }
}