function restoreScroll() {
  var element = document.getElementById(window.location.hash.substring(1));
  var selectedPosX = 0;
  var selectedPosY = 0;
  while(element != null){
    selectedPosX += element.offsetLeft;
    selectedPosY += element.offsetTop;
    element = element.offsetParent;
  }
  window.scrollTo(selectedPosX,selectedPosY);
}


$(document).ready(function() {
  var current = $(window.location.hash);
  $('div.entry').not(current).removeClass('active').
    children('.info').hide();
  restoreScroll();
  $('div.entry').addClass('clickable').click(function() {
    var self = $(this);
    var others = $('div.entry.active').not(this);
    if (others.length > 0) {
      others.removeClass('active').children('.info').slideUp()
        .queue(function() {
          self.addClass('active').children('.info').slideDown();
          $(this).dequeue();
        });
    }
    else {
        $(this).toggleClass('active').children('.info').slideToggle();
    }
    return false;
  });
  $('html').click(function() {
    $('div.entry').removeClass('active').children('.info').slideUp();
  });
  $('div.entry a').click(function() {
    window.location = $(this).attr('href');
    return false;
  });
  $('div.entry .info').click(function() {
      return false;
  });
  $('div.text').hide().fadeIn('slow');
  $('div.entry').hover(function() {
      $(this).addClass('hover');
  }, function() {
      $(this).removeClass('hover');
  });
});
