$gediz_likeshow = {
    context: false,
    tabs: false,
    timeout: 10000,      // time before next slide appears (in ms)
    gediz_likespeed: 1000,   // time it takes to slide in each slide (in ms)
    tabSpeed: 300,      // time it takes to slide in each slide (in ms) when clicking through tabs
    fx: 'scrollLeft',   // the slide effect to use
    
    init: function() {
        // set the context to help speed up selectors/improve performance
        this.context = $('#gediz_likeshow');
        
        // set tabs to current hard coded navigation items
        this.tabs = $('ul.gediz_likes-nav li', this.context);
        
        // remove hard coded navigation items from DOM 
        // because they aren't hooked up to jQuery cycle
        this.tabs.remove();
        
        // prepare gediz_likeshow and jQuery cycle tabs
        this.preparegediz_likeshow();
    },
    
    preparegediz_likeshow: function() {
        // initialise the jquery cycle plugin -
        // for information on the options set below go to: 
        // http://malsup.com/jquery/cycle/options.html
        $('div.gediz_likes > ul', $gediz_likeshow.context).cycle({
            fx: $gediz_likeshow.fx,
            timeout: $gediz_likeshow.timeout,
            speed: $gediz_likeshow.gediz_likespeed,
            fastOnEvent: $gediz_likeshow.tabSpeed,
            pager: $('ul.gediz_likes-nav', $gediz_likeshow.context),
            pagerAnchorBuilder: $gediz_likeshow.prepareTabs,
            before: $gediz_likeshow.activateTab,
            pauseOnPagerHover: true,
            pause: true
        });            
    },
    
    prepareTabs: function(i, slide) {
        // return markup from hardcoded tabs for use as jQuery cycle tabs
        // (attaches necessary jQuery cycle events to tabs)
        return $gediz_likeshow.tabs.eq(i);
    },

    activateTab: function(currentSlide, nextSlide) {
        // get the active tab
        var activeTab = $('a[href="#' + nextSlide.id + '"]', $gediz_likeshow.context);
        
        // if there is an active tab
        if(activeTab.length) {
            // remove active styling from all other tabs
            $gediz_likeshow.tabs.removeClass('on');
            
            // add active styling to active button
            activeTab.parent().addClass('on');
        }            
    }            
};


$(function() {
    // add a 'js' class to the body
    $('body').addClass('js');
    
    // initialise the gediz_likeshow when the DOM is ready
    $gediz_likeshow.init();
});  
