/**
 * Vertical slide animation
 * 2010-12-10
 
 * @author Wim La Haye
 * @copyright Techtwo Webdevelopment 2010 - 2011
 * @version 0.0.1
 */
;(function($){
    
    // Vertical slide animation  
    $.fn.techtwoCaroussel.animations.slideVertical = function(options, caroussel) 
    {
        
        var animation = {},
            caroussel = caroussel;
            
        animation.settings  = $.extend({}, $.fn.techtwoCaroussel.animations.slideVertical.defaults, options);
            
        animation.initialize = function() 
        {
            
            animation.idx = 'idx' + Math.ceil(Math.random()*1000000);
            
            if (!animation.settings.panelWidth) {
                alert('Please define a panel width');
            }
            
            // Create animation wrapper
            animation.wrapper = $('<div id="' + animation.idx  +'"/>')
                .addClass('techtwo-slide-vertical-wrapper')
                .css({
                    overflow: 'hidden',
                    margin: animation.settings.wrapperMargin
                })
                .scrollLeft(0);
                
            // Wrap caroussel in animation wrapper
            caroussel.wrapper
                .css({width: (animation.settings.panelWidth) * caroussel.panels.length})
                .wrap(animation.wrapper);
                
            animation.wrapper = $('#' + animation.idx);
            
            // Position panels
            caroussel.panels
                .css({
                    width: animation.settings.panelWidth,
                    'float': 'left' 
                });

        };
        
        animation.gotoPanel = function (index)
        {
            animation.wrapper
                .stop()
                .animate({ 'scrollLeft': index * animation.settings.panelWidth}, caroussel.settings.duration);
        }
        
        animation.initialize();
        
        return animation;
              
    };
        
 
    // Vertical slide settings
    $.fn.techtwoCaroussel.animations.slideVertical.defaults = {
        direction: 'ltr',
        panelWidth: false, // either ltr or rtl
        wrapperMargin: 0
    };
    
})(jQuery);
    
