// Be sure to bind to the "hashchange" event on document.ready, not
// before, or else it may fail in IE6/7. This limitation may be
// removed in a future revision.
$(function(){

  // Override the default behavior of all `a` elements so that, when
  // clicked, their `href` value is pushed onto the history hash
  // instead of being navigated to directly.
  $("#nav li a").click(function(){
	var href = $(this).attr( "href" );
    $.bbq.pushState({ url: href });
    return false;
  });
  
  $("#page0 a").click(function(){
    var href = $(this).attr( "href" );
    $.bbq.pushState({ url: href });
    return false;
  });
  
  

  // Bind a callback that executes when document.location.hash changes.
  $(window).bind( "hashchange", function(e) {
    // In jQuery 1.4, use e.getState( "url" );
    var url = $.bbq.getState( "url" );
	navTo(Number(url.substring(5,7)));
  });

  // Since the event is only triggered when the hash changes, we need
  // to trigger the event now, to handle the hash the page may have
  // loaded with.
 
});

