$slideshow = {
    // ADD 2009/10/22 >>>>
    timeouts: [  //1000=1sec
      10000,
      10000,
      10000,
      10000,
      10000,
    ],
    // ADD 2009/10/22 <<<<
    
    context: false,
    tabs: false,
//    timeout: 10000,      // time before next slide appears (in ms) DEL 2009/10/22
    slideSpeed: 700,   // time it takes to slide in each slide (in ms)
    tabSpeed: 400,      // time it takes to slide in each slide (in ms) when clicking through tabs
    fx: 'cover',   // the slide effect to use
    
    init: function() {
        // set the context to help speed up selectors/improve performance
        this.context = $('#slideshow');
        
        // set tabs to current hard coded navigation items
        this.tabs = $('ul.slides-nav li', this.context);
        
        // remove hard coded navigation items from DOM 
        // because they aren't hooked up to jQuery cycle
        this.tabs.remove();
        
        // prepare slideshow and jQuery cycle tabs
        this.prepareSlideshow();
		
		$(".slides-nav a").click(function(){
			$(this).blur();
		});
    },
    
    prepareSlideshow: function() {
        // initialise the jquery cycle plugin -
        // for information on the options set below go to: 
        // http://malsup.com/jquery/cycle/options.html
        $('div.slides > ul', $slideshow.context).cycle({
            fx: $slideshow.fx,
            //timeout: $slideshow.timeout, DEL 2009/10/22
            // ADD 2009/10/22 >>>>
            timeout: $slideshow.timeouts[0],
            timeoutFn: $slideshow.timeoutFn,
            // ADD 2009/10/22 <<<<
            speed: $slideshow.slideSpeed,
            fastOnEvent: $slideshow.tabSpeed,
            pager: $('ul.slides-nav', $slideshow.context),
            pagerAnchorBuilder: $slideshow.prepareTabs,
            before: $slideshow.activateTab,
            pauseOnPagerHover: false,
            pause: false
        });            
    },
    
    // ADD 2009/10/22 >>>>
    timeoutFn: function(currSlideElement, nextSlideElement, options, forwardFlag){
        for(i=0;i<$('div.slides > ul').children().length;i++){
          if(nextSlideElement == $('div.slides > ul').children()[i]){
            return $slideshow.timeouts[i];
          }
        }
        return $slideshow.timeouts[i];
    },
    // ADD 2009/10/22 <<<<
    
    prepareTabs: function(i, slide) {
        // return markup from hardcoded tabs for use as jQuery cycle tabs
        // (attaches necessary jQuery cycle events to tabs)
        return $slideshow.tabs.eq(i);
    },

    activateTab: function(currentSlide, nextSlide) {
        // get the active tab
        var activeTab = $('a[href="#' + nextSlide.id + '"]', $slideshow.context);
        
        // if there is an active tab
        if(activeTab.length) {
            // remove active styling from all other tabs
            $slideshow.tabs.removeClass('on');
            
            // add active styling to active button
            activeTab.parent().addClass('on');
        }            
    }            
};


$(function() {
    // initialise the slideshow when the DOM is ready
    $slideshow.init();
});  