var lastID = 1;

$(document).ready(function() {
    loopBanner = setInterval("autoBanner()", 1000*6 );
});


function autoBanner() {
    x = (lastID % 4) + 1 ;
    bannerSwitch(x,700);
};


function bannerSwitch(id,speed) {
    if ( speed == "" ) { speed = "normal"; }
    $("#bannersection"+lastID).fadeOut(
        speed,
        function() {
            for ( i = 1; i < 5; i++ ) {
                $("#bannernav"+i).removeClass("active");
            }
            $("#bannernav"+id).addClass("active");
            $("#bannersection"+id).fadeIn(speed);
        }
    );   
    lastID = id;
};


function bannerNav(id) {
    if ( id == lastID ) {
        return false;
    } else {
        clearInterval(loopBanner);
        bannerSwitch(id,"fast");
    }
};


function killSwitch() {
    clearInterval(loopBanner);
};


