//Applies behaviour rules to the classes
//Author: Brian R Miedlar (c) 2006-2009

var AppBehavior = Class.create();
AppBehavior.Load = function() {
    OS.RegisterBehaviour(AppBehavior.CarouselRules);
}
AppBehavior.CarouselRules = {
    '#carouselNovedadesHome': function(element) {
        //Pictures
        AppBehavior.PictureCarousel = new Carousel('PictureCarousel', element, 415, 70, AppBehavior, {
            setSize: 2,
            duration: .5,
            direction: 'horizontal',
            itemParser: function(item) {
                //Given html element you can build a data object for the item if needed for later activation
				return {};
            },
            setItemEvents: function(carousel, itemElement, carouselItem, observer) {
                //This allows you to set events to the item like rollovers/mouse events
                Event.observe(itemElement, 'click', function() {
                    carousel.activate(carouselItem);
                });
            },
            allowAutoLoopOnSet: true,
            allowAutoLoopOnIndividual: true
        });
        AppBehavior.PictureCarousel.load();
    },
	'#carouselNovedadesCompania': function(element) {
        //Pictures
        AppBehavior.PictureCarousel = new Carousel('PictureCarousel', element, 264, 247, AppBehavior, {
            setSize: 2,
            duration: .5,
            direction: 'horizontal',
            itemParser: function(item) {
                //Given html element you can build a data object for the item if needed for later activation
				return {};
            },
            setItemEvents: function(carousel, itemElement, carouselItem, observer) {
                //This allows you to set events to the item like rollovers/mouse events
                Event.observe(itemElement, 'click', function() {
                    carousel.activate(carouselItem);
                });
            },
            allowAutoLoopOnSet: true,
            allowAutoLoopOnIndividual: true
        });
        AppBehavior.PictureCarousel.load();
    },
	'#carouselPorqueWe': function(element) {
        //Pictures
        AppBehavior.PictureCarousel = new Carousel('PictureCarousel', element, 228, 383, AppBehavior, {
            setSize: 2,
            duration: .5,
            direction: 'horizontal',
            itemParser: function(item) {
                //Given html element you can build a data object for the item if needed for later activation
				return {};
            },
            setItemEvents: function(carousel, itemElement, carouselItem, observer) {
                //This allows you to set events to the item like rollovers/mouse events
                Event.observe(itemElement, 'click', function() {
                    carousel.activate(carouselItem);
                });
            },
            allowAutoLoopOnSet: true,
            allowAutoLoopOnIndividual: true
        });
        AppBehavior.PictureCarousel.load();
    },
	'#carouselClientes': function(element) {
        //Pictures
        AppBehavior.PictureCarousel = new Carousel('PictureCarousel', element, 262, 55, AppBehavior, {
            setSize: 6,
            duration: .5,
            direction: 'vertical',
            itemParser: function(item) {
                //Given html element you can build a data object for the item if needed for later activation
				return {};
            },
            setItemEvents: function(carousel, itemElement, carouselItem, observer) {
                //This allows you to set events to the item like rollovers/mouse events
                Event.observe(itemElement, 'click', function() {
                    carousel.activate(carouselItem);
                });
            },
            allowAutoLoopOnSet: true,
            allowAutoLoopOnIndividual: true
        });
        AppBehavior.PictureCarousel.load();
    },
    '#Cmd_NextItem': function(element) {
        Event.observe(element, 'click', function() {
            AppBehavior.PictureCarousel.next();
        });
    },
    '#Cmd_PreviousItem': function(element) {
        Event.observe(element, 'click', function() {
            AppBehavior.PictureCarousel.previous();
        });
    }
}

//EVENT OBSERVATION
AppBehavior.fireActiveCarouselLoaded = function(carousel) {
}
AppBehavior.fireActiveCarouselItem = function(carousel, element, item) {
    element.addClassName('selected');

    // Here we can update any part of the DOM to represent our data
    // In this sample we will use the same generic viewer element for all carousels
//     switch(carousel.key) {
//         case 'ProfileCarousel': 
//             $('ViewerCaption').update(item.value.name);
//             $('ViewerData').update(item.value.email);
//             Element.show('Viewer');
//             break;
//             
//         case 'PictureCarousel':
//             $('ViewerCaption').update(item.value.name);
//             $('ViewerData').update(item.value.pictureHtml);
//             Element.show('Viewer');
//             break;
// 
//         case 'GroupCarousel':
//             $('ViewerCaption').update(item.value.name);
//             $('ViewerData').update(item.value.email);
//             Element.show('Viewer');
//             break;
//     }
}
AppBehavior.fireDeactiveCarouselItem = function(carousel, element, item) {
    element.removeClassName('selected');

//     switch(carousel.key) {
//         case 'ProfileCarousel': 
//             Element.hide('Viewer');
//             break;
// 
//         case 'PictureCarousel': 
//             Element.hide('Viewer');
//             break;
// 
//         case 'GroupCarousel': 
//             Element.hide('Viewer');
//             break;
//     }
}

AppBehavior.Load();
	