var musicShow = false;

$(function() { //page onload functions
    headerImage();
    stretchContent();
    $("#clickNotes").click(
        function () {
            if (musicShow) {
                $("#mp3Player").animate({
                    marginLeft: "-190px"
                });
                musicShow = false;
            } else {
                $("#mp3Player").animate({
                    marginLeft: "0px"
                });
                musicShow = true;
            }
        }
    );
//     $(window).scroll(
//         function() {
//             moveAudioPlayer();
//         }
//     );
    $(".navItem").click (
        function(e) {
            $("#leftContent").load("http://www.pinknoiseboys.co.uk/" + $(e.target).attr("name"));
            headerImage();
//$("#leftContent").html("<b>WHAT THE FUCK?</b>");
//             stretchContent();
//            alert($(e.target).attr("name"));
        }
    );
    $(".tooltip").each( function() {
        $(this).qtip({
            content: $(this).attr('tooltip'),
            position: { corner: { tooltip: 'rightTop', target: 'leftMiddle' } },
            style: { name: 'dark', tip: true }
        });
    });
});

function headerImage() {
    var imgArray = new Array();
    imgArray[0] = "header01.jpg";
    imgArray[1] = "header02.jpg";
    imgArray[2] = "header03.jpg";
    var randomNum = Math.floor(Math.random()*imgArray.length);
    $("#header").css("background", "url(assets/templates/pinkNoise/images/"+imgArray[randomNum]+") no-repeat");
}

function stretchContent() {
    var totalHeight = $("#rightBar").height();
    $("#leftContent").css("min-height", (totalHeight + 20)+"px");
//     $("#rightBar").css("min-height", ($("#content").height()+361)+"px");
}

function moveAudioPlayer() {
    var moveToHere = $(window).scrollTop();
    var newTop = $("#mp3Player").css("top", (moveToHere-30)+"px");
    $("#mp3Player").animate({
        top: moveToHere+"px"
    });
}

