var tcTimer = new Array();
jQuery.fn.extend({
    tagCloud: function (a) {
        var b = {
            direction: 'random',
            easein: 'linear',
            speed: 3000
        };
        var a = $.extend(b, a);
        var c = "#" + $(this).attr("id");
        var d = parseInt($(this).css("width")) - 200;
        var e = parseInt($(this).css("height")) - 30;
        var f = '';
        $(this).css("list-style", "none");
        $(c).children().each(function (i) {
            $(this).css({
                "z-index": i,
                "position": "absolute"
            })
        });
        $(c).children().each(function () {
            $(this).animate({
                fontSize: ((Math.random() * 36) + 4) + "px",
                "top": (Math.random() * e) + "px",
                "left": (Math.random() * d) + "px"
            }, a.speed, a.easein)
        });
        $(this).mouseover(function () {
            $(this).stop();
			$(this).animate({fontSize: '40px'}, 1000);
			$(this).fadeTo('fast', 1, function() {}); 
            clearInterval(tcTimer[c])
        });
        

        switch (a.direction) {
        case 'vertical':
            {
                f = '$("' + c + '").children().each(function(){$(this).animate({fontSize: ((Math.random()*34)+6)+"px", "top": (Math.random()*' + e + ')+"px"}, ' + a.speed + ', "' + a.easein + '" );});';
                break
            }
        case 'horizontal':
            {
                f = '$("' + c + '").children().each(function(){$(this).animate({fontSize: ((Math.random()*34)+6)+"px", "left":(Math.random()*' + d + ')+"px"}, ' + a.speed + ', "' + a.easein + '" );});';
                break
            }
        default:
            {
                f = '$("' + c + '").children().each(function(){$(this).animate({fontSize: ((Math.random()*34)+6)+"px", "top": (Math.random()*' + e + ')+"px", "left":(Math.random()*' + d + ')+"px"}, ' + a.speed + ', "' + a.easein + '" );});'
            }
        }
        tcTimer[c] = setInterval(f, a.speed + 50);
        $(this).mouseout(function () {
            tcTimer[c] = setInterval(f, a.speed + 50)
        })
    }
});
