$(function() {

    // for the hompage page, swap out images and shows correct caption
    numOfImages = 9;
    
    if ( $("body").attr("id") == "front" ) {
        var randNum=(Math.floor(Math.random()*numOfImages)) + 1;
        $("#content").css("background-image","url(/docs/i/home/"+randNum+".jpg)");
        $("#content .img-caption").eq(randNum - 1).show();
    }

    // Add lines to code
    $("pre").each(function(i) {
        var preHeight = $(this).height();
        var preLineHeight = $(this).css("lineHeight");
        // convert to integer
        var preLineHeight = parseInt(preLineHeight, 10);
        // calculate number of lines
        var lineNums = preHeight / preLineHeight;
        // inject a ul into each pre to hold the line numbers
        $(this).prepend("<ul class='line-nums'></ul>")
        // add the list items in
        for (j = 1; j <= lineNums; j++) {
            $(this).find(".line-nums").append("<li>" + j + "</li>")
        }
    })

    // Uses CSS transition to move the menu down
    $("#menu-drop").click(function(){
        $("#nav, #menu-drop").toggleClass("clicked");
    });


});
