﻿var FADE_DELAY = 100;
var TABTIMER_DELAY = 10000;
var tabtimer;
var newsActive = true;

function alertNewsTab() {
    document.getElementById("newsHomeContainer").style.display = 'block';
    document.getElementById("agendaHomeContainer").style.display = 'none';

    $(".img_actueel").show();
    $(".img_agenda").hide();

    $(".nieuwsAgendaLeft").fadeIn(FADE_DELAY);
    $(".nieuwsAgendaRight").fadeOut(FADE_DELAY);
}
function alertAgendaTab() {
    document.getElementById("newsHomeContainer").style.display = 'none';
    document.getElementById("agendaHomeContainer").style.display = 'block';

    $(".img_actueel").hide();
    $(".img_agenda").show();

    $(".nieuwsAgendaRight").fadeIn(FADE_DELAY);
    $(".nieuwsAgendaLeft").fadeOut(FADE_DELAY);
}

function onTabTimeout() {
    if (newsActive)
        alertAgendaTab();
    else
        alertNewsTab();

    newsActive = !newsActive;

    resetTabTimeout();
}

function resetTabTimeout() {
    if (tabtimer)
        clearTimeout(tabtimer);

    tabtimer = setTimeout("onTabTimeout()", TABTIMER_DELAY);
}

$(function () {
    $(".nieuwsAgendaRight").click(function () {
        alertNewsTab();
        resetTabTimeout();
    });
    $(".nieuwsAgendaLeft").click(function () {
        alertAgendaTab();
        resetTabTimeout();
    });

    $(".nieuwsAgendaRight, .nieuwsAgendaLeft").css("cursor", "pointer");

    resetTabTimeout();
});
