Cufon.replace('h1');

$(document).ready(function () {
    Cufon.now();

    $("#slider").cycle({
        fx: 'fade',
        timeout: 10000,
        random: 1
    });

    /*$("#fadeBox").cycle({
        fx: 'fade',
        timeout: 10000,
        random: 1
    });*/



    $('#fadeBox div').each(function () {
        $(this).addClass("hide");
    });

    var divNo = 1;

    $('#fadeBox div').each(function () {
        $(this).attr("id", divNo);
        divNo++;
    });



    randomAd();

});


function randomAd() {

    var pause = 10000; // define the pause for each ad(in milliseconds) 
    var length = $("#fadeBox div").length;
    var temp = -1;

    this.getRan = function () {
        // get the random number
        var ran = Math.floor(Math.random() * length) + 1;
        return ran;
    };
    this.show = function () {
        var ran = getRan();
        // to avoid repeating
        while (ran == temp) {
            ran = getRan();
        };
        temp = ran;
        $("#fadeBox div").hide();
        $("#fadeBox div:nth-child(" + ran + ")").show();
    };

    show(); setInterval(show, pause);

}

