
$(document).ready(function(){

    timer_news();
    timer_bd();
});

function timer_news()
{
    window.setTimeout(function() { ajax_change_news(); }, 15000);
}

function timer_bd()
{
    window.setTimeout(function() { ajax_change_bd(); }, 12000);
}

var article = 1;

function ajax_change_news()
{
    $.ajax({
        url:  "/_xhr/next_news/" + article + "/",
        success: function(jsondata)
        {
            // insert the form to the appropriate location

            $("#article").fadeOut("slow", function() {
                $("#article").html(jsondata['html']).fadeIn("slow");
            });
            article = jsondata['article']
            timer_news();
        },
        dataType: "json"
    });
}

var bd = 0;

function ajax_change_bd()
{
    $.ajax({
        url:  "/_xhr/next_bd/" + bd + "/",
        success: function(jsondata)
        {
            // insert the form to the appropriate location

            $("#business-driver").fadeOut("slow", function() {
                $("#business-driver").html(jsondata['html']).fadeIn("slow");
            });
            bd = jsondata['driver']
            timer_bd();
        },
        dataType: "json"
    });
}

