/**
* Girlings global JS
**/

var items = null;

var randomNumber = function(from, to) {
    var rand = Math.floor(Math.random() * (to + 1)) + from;
    return rand;
};

var doTicker = function(items) {
    items.each(function() {
        if($(this).css('display') == 'block') {
            $(this).fadeOut(3000);
            var c = parseInt($(this).attr('rel'));
            var next = c + 1;
            if(next > (items.length - 1)) {
                next = 0;
            }
            items.filter('rel="' + next + '"').fadeIn(3000);
        }
    });
    setTimeout("doTicker(items)", 10000);
};

$(function() {
    //Cloud...
    $('#cloud a').each(function() {
        var fontSize = randomNumber(9, 12);
        $(this).css({
            fontSize: fontSize + 'px'
        });
    });
    //Bottom fix
    var winHeight = $(window).height();
    var docHeight = $('body').eq(0).height();
    if(winHeight > docHeight) {
        var difference = winHeight - docHeight;
        $('#bottom').css({
            height: $('#bottom').height() + difference,
            minHeight: $('#bottom').height() + difference,
            maxHeight: $('#bottom').height() + difference
        });
    }
    $('#newsTicker').ticker();
});

