$(function() { var secId = location.href.match(/\#(.*)$/) ? RegExp.$1 : "overview"; _update(secId); $(".tab nav li,.next em").click(function() { var secId = $(this).find("a").attr("href").substr(1); _update(secId); $("html,body").animate({ scrollTop : 0 }, "fast"); }); // function _update(secId) { $(".tab").hide(); $(".tab#section-" + secId).show(); var j1, j2; $("header .bg").each(function(i, elem) { var j = $(elem); if(elem._active) { j.animate({ opacity : 0.0 }); elem._active = false; } else if(j.hasClass(secId)) { j.animate({ opacity : 1.0 }); elem._active = true; } else { j.css("opacity", 0); } }); } });