Ajax hash navigation with default page switch and transition animation
var container_div = ".container", content_div = ".content", default_hash = "#main";
function anchorRefresh() {
var a = location.hash.substring(1);
$(".active").removeClass("active");
$(content_div).css({opacity:0.5});
$(content_div).load("ajax/" + a + ".html", function() {
$(location.hash).addClass("active");
$(content_div).animate({opacity:1})
})
}
$(window).on("hashchange", function() {
anchorRefresh()
});
"" == location.hash ? location.hash = default_hash : anchorRefresh();