$('html').addClass('js');
$(function() {
    // Select section by location.hash
    // Example: http://www.clansuite.com/#page-news
    var match = 0;
    var hash_substr = window.location.hash.substr(1);
    if (hash_substr != '') {
        $('#content div.accordion').each(function(i) {
        if (hash_substr == $(this).attr('id')) {
            match = i;
        }
        });
    }
    $('#content .accordion:not(' + (match != 0 ? ':eq(' + match + ')' : ':first') + ')').hide();

    // Hoveranimations
    $('#sidebar a.menu_button').hover(function() {
        $(this).stop().animate({ width: '100px', paddingLeft: '40px' }, 225);
    }, function() {
        if (!$(this).is('.selected')) {
            $(this).stop().animate({ width: '100px', paddingLeft: '12px' }, 225);
        }
    });

    $('#sidebar a.menu_button').click(function() {
        $(this).animate({ width: '100px', paddingLeft: '40px' }, 225).addClass('selected');
            $('#sidebar a.menu_button:not(:eq(' + $('#sidebar a.menu_button').index(this) + '))').animate({ width: '100px', paddingLeft: '12px' }, 225).removeClass('selected');
        var hash = this.hash;
        // If the selected section isn't currently displayed, activate it
        if (!$('#content .accordion' + hash).is(':visible')) {
            $('#content .accordion:visible').animate({ height: 'hide', opacity: 'hide' }, 'fast');
            $('#content .accordion' + hash).animate({ height: 'show', opacity: 'show' }, 'slow');
        }
        return false;
    }).filter(':eq(' + match + ')').click();

    /**
      * setHeaderBanner
      *
      * This function picks a random element from the bannersarray and assigns it to the DOM Element with id "header".
      *
      * @access public
      * @return void
      **/

    function setHeaderBanner()
    {
        var bannersarray = ['http://www.clansuite.com/website/images/kubrickheader.png'];

        var i = Math.floor(Math.random()*bannersarray.length);
        var header = $('#header').css({backgroundImage: 'url(' + bannersarray[i] + ')' });
    }
    setHeaderBanner();
});