var divs_to_fade = null;

var i = 0;
var wait = 5000;

function swapFade()
{
    if( divs_to_fade.length > 1 )
    {
        odiv = divs_to_fade[i];
        i++;

        if (i == divs_to_fade.length) i = 0;
        idiv = divs_to_fade[i];

        var myEffect1 = new Fx.Morph(idiv, {duration: 2000, 
            transition:  Fx.Transitions.Sine.easeOut});
        var myEffect2 = new Fx.Morph(odiv, {duration: 2000, 
            transition:  Fx.Transitions.Sine.easeOut});

        //The styles of myClassName will be applied to the target Element.
        showBlock(idiv);
        myEffect1.start({'opacity': 1});
        myEffect2.start({'opacity': 0}).
        addEvent('onComplete', function() { hideBlock(odiv); });	
    }
}

function hideBlock(e)
{
	$(e).setStyles
	({
		display: 'none',
		opacity: '0'
	});
}

function showBlock(e)
{
	$(e).setStyles
	({
		display: 'block',
		opacity: '0'
	});
}

function startPage()
{
	setInterval('swapFade()',wait);
}

window.addEvent('domready', function()
{
	divs_to_fade = $$('.fadebox');
});

function showHighlight()
{
	this.setStyle('cursor','pointer');
}

function noHighlight()
{
	this.setStyle('cursor','auto');
}
