Cobra.Page.currentFeatured = 0;

function rotateFeatured(){
    Effect.Fade($$('.featured-box')[Cobra.Page.currentFeatured].select("img")[0], {duration: 2.0});
    Cobra.Page.currentFeatured += 1;
    if(Cobra.Page.currentFeatured == 10){ Cobra.Page.currentFeatured = 0; }
    $('featured-paging-current').update(Cobra.Page.currentFeatured + 1);
    $('view-featured').writeAttribute('href', "/"  + Cobra.Page.rotatorVillaIDs[Cobra.Page.currentFeatured].link + "/");
    Effect.Appear($$('.featured-box')[Cobra.Page.currentFeatured].select("img")[0], { duration: 2.0, from: 0, to: 1 });
}

document.observe("dom:loaded", function(){
    var rotator = new PeriodicalExecuter(rotateFeatured, 5);

    $('featured-toggle').observe('click', function(e){
        Event.stop(e);
        if(rotator.currentlyExecuting){
            $('featured-toggle').update("Pause");
            rotator.currentlyExecuting = false;
        }else{
            $('featured-toggle').update("Play");
            rotator.currentlyExecuting = true;
        }
    });
});

