$(document).ready(function(){
    function fadeLI(elem) { 
      elem.fadeIn(200, function() { fadeLI($(this).next()); }); 
    }                            
    
    function path_info(href){
        /* split href into path and a category, which is the first element of the href
        /studio/profile/ = category:sudio
        */
        h = href.substring(10);
		short_href = h.substring(h.indexOf("/"));
		category = short_href.split("/")[1];
		return {href:short_href, category:category};
    }
	href = document.location.href;
	bits = href.split("/");
	if(bits.length==6){
		section = bits[3];
		$("#navigation ul li#"+section+" ul").show();
	}
	now = path_info(document.location.href);
	then = path_info(document.referrer);
	if((now.href=="/studio/profile/"||now.href=="/projects/")&&now.category!=then.category){
	    $("#separator ~ li").hide();
		fadeLI($("#separator ~ li:first"));
	}

});
