/*!
 * jQuery JavaScript Library v1.4.2
 * http://jquery.com/
 *
 * Copyright 2010, John Resig
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * Includes Sizzle.js
 * http://sizzlejs.com/
 * Copyright 2010, The Dojo Foundation
 * Released under the MIT, BSD, and GPL Licenses.
 *
 * Date: Sat Feb 13 22:33:48 2010 -0500
 */

(function(){
  $(function() {
    var currentTime, openTime, originalPosition, slidebox;
    currentTime = function() {
      return (new Date()).getTime();
    };
    slidebox = $('#slidebox');
    originalPosition = slidebox.css('right');
    openTime = null;
    //$('nav#more').hide();
    $(window).scroll(function() {
      var distanceTop;
      distanceTop = $('#slidebox').offset().top - $(window).height();

      if ($(window).scrollTop() + 800 > distanceTop) {
        slidebox.animate({
          'right': '0px'
        }, 300);
        if (!openTime) {          
          openTime = currentTime();
          return openTime;
        }
      } else {	
        return slidebox.stop(true).animate({	
          'right': originalPosition
        }, 100);
      }
    });
    slidebox.find('.close').click(function() {
      var elapsedTime;
      $(this).parent().remove();
      elapsedTime = currentTime() - openTime;
      return;
    });
    slidebox.find('.related a').click(function() {
      var elapsedTime;
      elapsedTime = currentTime() - openTime;
      return;
    });
  });
})();
