﻿
var videos = {};
function VideosShow(index,indexlast) {    
    
    if (videos.Objects && videos.Objects.length > 0) {

        oo = videos.Objects;

        if (index < 0) index = 0;

        if (indexlast > (oo.length)) indexlast = oo.length;

        if (oo.length < 3) { indexlast = oo.length }

        videos.Current = index;

        oo.each(function(el) {
            el.setStyle('display', 'none');
        });
       
        for(i=index; i<indexlast; ++i) {
            oo[i].setStyle('display', 'block');            
        } 
    }
}

function VideosPrevious() {

    if (videos.Current - 1 >= 0) {
        VideosShow(videos.Current - 1, videos.Current + 2)
    }
}

function VideosNext() {    
    if (videos.Current + 4 <= videos.Objects.length) {
        VideosShow(videos.Current + 1, videos.Current + 4)
    }
}

function VideosFirst() { VideosShow(0, 3) }

window.addEvent("domready", function() {

    var oo = $$('.highlightVideos  .itemattach ')
    videos.Objects = oo;
    oo.each(function(el) {
        el.setStyle('display', 'none');
    });
    videos.ButtonBack = $$('.divVideos  .flecha_izquierda a').addEvent("click", function() {
        VideosPrevious()
        return false;
    }); 
    videos.ButtonFoward = $$('.divVideos  .flecha_derecha a').addEvent("click", function() {
        VideosNext();
        return false;
    });
    VideosFirst();
});
