$(document).ready(function () {
	var x, y, $elie, pos, nowX, nowY, i, vel, deg, curve, maxH, maxW;               
});

    // Returns a random integer between min and max      
    function ran(min, max)  
    {  
        return Math.floor(Math.random() * (max - min + 1)) + min;  
    }

    function setContainerSize(elie){
	maxW = elie.parent().parent().parent().find('.bubble_container').width() - elie.width();
	maxH = elie.parent().parent().parent().find('.bubble_container').height() - elie.height();
    }

    function moveIt()
    {
        $(".circles .spec").each(function (i, v) {
	    var elie = $(v);
            if (elie.data('move')) {
                if (!elie.data("vel")) {

                    setContainerSize(elie);

                    elie.data("deg", ran(-179, 180));
                    elie.data("curve", ran(0, 1));
                    
                    elie.data("vel", elie.attr("speed"));
                    elie.data("maxWidth", maxW);
                    elie.data("maxHeight", maxH);
                    elie.css({'left': ran(1,maxW)});
                    elie.css({'top': ran(1,maxH)});
                }
                if (!elie.data("time")) {

                    elie.data("time", ran(10, 20));
                    elie.data("curve", ran(0, 1));
                }


                var vel = elie.data("vel");
                var deg = elie.data("deg");
                var curve = elie.data("curve");
                var pos = elie.position();
                elie.data("time", elie.data("time") - 1);

                if (curve == 0)
                    elie.data("deg", (deg + 2));
                else
                    elie.data("deg", (deg - 2));

                var nowX = pos.left;
                var nowY = pos.top;

                var x = vel * Math.cos(deg * Math.PI / 180);
                var y = vel * Math.sin(deg * Math.PI / 180);

                var nowX = nowX + x;
                var nowY = nowY + y;

                if (nowX < 0) {
                    elie.data("deg", 180 - deg);
                    nowX = 0;
                }
                if (nowX > elie.data("maxWidth")) {
                    elie.data("deg", 180 - deg);
                    nowX = elie.data("maxWidth");
                }                
                if (nowY < 0) {
                    elie.data("deg", deg * (-1));
                    nowY = 0;
                }
                else if (nowY > elie.data('maxHeight')) {
                    elie.data("deg", deg * (-1));
                    nowY = elie.data('maxHeight');
                }

                elie.css({"left":nowX, "top":nowY});
            } 
        });
    }


// Here is a bit for li items ---- don't want this to be modified
    function setListDisplay(item)
    {
        $(item).find('ul li:nth-child(5n+1)').css({'background-image': 'url(/wp-includes/img/bg/li_circle_1.png)'});
        $(item).find('ul li:nth-child(5n+2)').css({'background-image': 'url(/wp-includes/img/bg/li_circle_2.png)'});
        $(item).find('ul li:nth-child(5n+3)').css({'background-image': 'url(/wp-includes/img/bg/li_circle_3.png)'});
        $(item).find('ul li:nth-child(5n+4)').css({'background-image': 'url(/wp-includes/img/bg/li_circle_4.png)'});
        $(item).find('ul li:nth-child(5n+5)').css({'background-image': 'url(/wp-includes/img/bg/li_circle_5.png)'});
    }


    function colorList(ele){
        $(ele).find('li:nth-child(6n+1)').hover(function() {$(this).find('a').css({'background':'#87994C'});} ,function () {$(this).find('a').css({'background':'#FFF'});});
        $(ele).find('li:nth-child(6n+2)').hover(function() {$(this).find('a').css({'background':'#E39925'});} ,function () {$(this).find('a').css({'background':'#FFF'});});
        $(ele).find('li:nth-child(6n+3)').hover(function() {$(this).find('a').css({'background':'#B9425F'});} ,function () {$(this).find('a').css({'background':'#FFF'});});
        $(ele).find('li:nth-child(6n+4)').hover(function() {$(this).find('a').css({'background':'#D46328'});} ,function () {$(this).find('a').css({'background':'#FFF'});});
        $(ele).find('li:nth-child(6n+5)').hover(function() {$(this).find('a').css({'background':'#0B7675'});} ,function () {$(this).find('a').css({'background':'#FFF'});});
        $(ele).find('li:nth-child(6n+6)').hover(function() {$(this).find('a').css({'background':'#634938'});} ,function () {$(this).find('a').css({'background':'#FFF'});});
    }

