var headline_timer;

function doAnimateHeadline() {
    //Animate headline news
    current_active = $('#highlight_control li.active');
    next_active = $('#highlight_control li.active').next();
    if(!next_active.get(0)) {
        next_active = $('#highlight_control ul').children(":first");
    }
    current_active.removeClass('active');
    next_active.addClass('active');
    changeImageTitle(next_active.attr("news"));

    doTimerHeadline();
}


function doTimerHeadline() {
    headline_timer = setTimeout("doAnimateHeadline()",5000);
}

function changeImageTitle(Id) {
    $('#highlight1').hide();
    $('#highlight2').hide();
    $('#highlight3').hide();
    $('#highlight4').hide();

    $('#highlight' + Id).fadeIn(500);
    $('#highlight' + Id).show();
}


$(document).ready(function() {
    $('#highlight1').show();
    $('#highlight2').hide();
    $('#highlight3').hide();
    $('#highlight4').hide();

    //Sembunyikan & tampilkan video
    $('#video .video_file embed').hide();
    $('#video .video_file img').show();
    $('#video .video_file img').click(function() {
        $('#video .video_file embed').show();
        $('#video .video_file img').hide();
    });

    $('#highlight_control li').click(function() {
        clearTimeout(headline_timer);
        current_click = $(this);
        current_active = $(this).siblings('.active');
        current_active.removeClass('active');
        current_click.addClass('active');
        changeImageTitle(current_click.attr("news"));
        doTimerHeadline();
    });
});

doTimerHeadline();


