$(function()
{
  var lnks = $("a.contacts");
  var active = null;
  
  $("div.contacts").each(function()
  {
    var el = $(this);
    var lnk;
    
    lnks.each(function()
    {
      var hash = $(this).attr("href").split("#");
      if (hash.length > 0 && hash[1] == el.attr("id"))
      {
        lnk = $(this);
        return false;
      }
    });
    
    el.hide();
    lnk.click(function()
    {
      if (active)
      {
        active.slideUp().queue(function()
        {
          el.slideDown();
          $(this).dequeue();
        });
      }
      else
        el.slideDown();
      active = el;
    });
  });
});