/*
This little script handles the homepage banners and menu.
Hovering over a link changes what is displayed in the menu
*/

var cycle_counter = 1;
var cycle_interval = 0;
var cycle_duration = 2000;
var cycle_max = 9;
var cycle_current = 1;


/*
This function displays the banner requested in argument (integer from 1 to n)
*/
function show_banner(number) {
    $('#banner-' + cycle_current).fadeOut('slow');
    $('#banner-' + number).fadeIn('slow');
    cycle_current = number;
}


/* This function hides all the banners */
function hide_all_banners() {
    var b = '';
    var l = '';
    for (i = 1; i <= cycle_max; i++) {
        b = b + ((b.length !== 0) ? ', ' : '') + '#banner-' + i;
        }
    $(b).css('display', 'none');
}

/* This function cycles through the banners */
function cycle_banners() {
    show_banner((cycle_counter % cycle_max) + 1);
    cycle_counter++;
}


/*
This function initialises the home-page banner cycling.
*/
cycle_interval = setInterval(cycle_banners, cycle_duration);

