// JavaScript Document

$(document).ready(function(){
 
     if(window.location.hash!=""){
        var hashpage = window.location.hash.split("#");
        window.location.pathname = hashpage[1];
     }
     //navigation
     $("#navigate li a").unbind("click").click(function(){
		$(".post").empty().append("<div id='loading'><img src='images/loading.gif' alt='Loading' /></div>");
		$("#navigate li a").removeClass('current');
        $(this).addClass('current');
        //get href attribute
        var page = $(this).attr("href");
        //load contents of all children of the #content div
        $(".post").load(page+" .latest-post > *");
        //append hash to the url for bookmarking
        window.location.hash="#"+page;
        //cancel browser default so the page doesn't reload
        return false;
 
     });
});

