(function($) {
 function pageload(hash) {

  var vars = hash.split("/");
  var _href = vars[1];

  if (_href == "making-of") {
   $("#making-of").fadeIn("slow");
  } else if (_href == "news") {
   // load news
   if (vars[2]) {
    var _url = "ajax/news.php?id="+vars[2];
   } else {
    var _url = "ajax/news.php";
   }

   $.ajax({
    url: _url,
    cache: false,
    success: function(html){
	 // set content (html)
	 //
    $("#news").html(html);
    // for new ajax links:
    $("a[class='ajax']").unbind("click");
    $("a[class='ajax']").click(function(){
     var hash = this.rel;
     hash = hash.replace(/^.*#/, '');
     $.historyLoad(hash);
     return false;
    });
    $("#news").fadeIn("slow");
    }
   });
   //

  } else {
   $("#making-of").css("display","none");	
   $("#news").css("display","none");	
  }
}

$(document).ready(function() {

 // Initialize history plugin.
 // The callback is called at once by present location.hash. 
 $.historyInit(pageload, "jquery_history.html");

 // set onlick event for buttons
 $("a[class='ajax']").click(function(){
 // 
  var hash = this.rel;
  hash = hash.replace(/^.*#/, '');
  // moves to a new page.
  // pageload is called at once.
  // hash don't contain "#", "?"
  $.historyLoad(hash);
  return false;
 });

});

})(jQuery);
