﻿var myFx;
var ServiceIndex = 0;
var periodical;
var goNext;

window.addEvent('domready', function() {

    myFx = new Fx.Tween($("homeMooContentMoverDiv"));

    goNext = function() {
        //alert(ServiceIndex);
        $$('.MooHomeHover').each(function(item, index) {
            item.setStyle("opacity", "0.8");
        });
        $$('.MooHomeHover')[ServiceIndex].setStyle("opacity", "1");

        myFx.cancel();

        myFx.start('margin-top', -ServiceIndex * 365);

        if (ServiceIndex == $$('.MooHomeHover').length - 1) {
            ServiceIndex = 0;
        }
        else {
            ServiceIndex++;
        }
    }

    init_Home_Interface();
});

function init_Home_Interface() {

    $$('.MooHomeHover').each(function(item, index) {
        item.setStyle("opacity", "0.8");
        //Add Mouse Listner Events
        item.addEvent('mouseenter', function() {

            
            //Transitions the background color of the Element from black to red:
            $clear(periodical);
            ServiceIndex = index;
            //periodical = goNext.periodical(20000);
            goNext();
            periodical = goNext.periodical(10000);
            //            alert($("homeMooContentMoverDiv").getStyle('margin-top'));
        })

        item.addEvent('mouseleave', function() {
            //item.setStyle("opacity", "0.8");
        })
    });
}

function moveNextService() {

}
