$(document).ready(function() {
    // Work out id of current section from file path
    var filePath = document.location.pathname.split("/");
    var fpLength = filePath.length;
    var fileSection = filePath[fpLength -2];
    var fileName = filePath[fpLength -1].split(".")[0];
    // Strip off trailing _cy (if any) from file name
    fileName = fileName.replace(/(.*)_cy$/, "$1");
    var sectionID;
    if (fileName == "index") { sectionID = fileSection; }
    else { sectionID = fileName; }
    $('#'+sectionID).addClass('active'); 

// Provide nice animation on menu (overriding css menu display on hover)
    $('#menu li ul').css({
        display: "none",
        left: "auto"
    });
    $('#menu li').hoverIntent(function(){
        $(this)
            .find('ul')
            .stop(true, true)
            .fadeIn(500)
    }, function() {
        $(this)
            .find('ul')
            .stop(true, true)
            .fadeOut(500)
    });
});



