$slideshow = {
	context: false,
	tabs: false,
	timeout: 7000,      // time before next slide appears (in ms)
	slideSpeed: 1000,   // time it takes to slide in each slide (in ms)
	tabSpeed: 1000,      // time it takes to slide in each slide (in ms) when clicking through tabs
	fx: 'fade',   // the slide effect to use
    
    init: function() {
        // set the context to help speed up selectors/improve performance
        this.context = $('#content-slideshow');
        
        // set tabs to current hard coded navigation items
        //this.tabs = $('ul.slideshow-nav li', this.context);
		this.tabs = $('ul.slideshow-nav li');
        
        // 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();
    },
    
    prepareSlideshow: function() {
        // initialise the jquery cycle plugin -
        // for information on the options set below go to: 
        // http://malsup.com/jquery/cycle/options.html
        $('div.slideshow > ul', $slideshow.context).cycle({
            fx: $slideshow.fx,
            timeout: $slideshow.timeout,
            speed: $slideshow.slideSpeed,
            fastOnEvent: $slideshow.tabSpeed,
            //pager: $('ul.slideshow-nav', $slideshow.context),
			pager: $('ul.slideshow-nav'),
            pagerAnchorBuilder: $slideshow.prepareTabs,
            before: $slideshow.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 $slideshow.tabs.eq(i);
    },

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

function tabTo() 
{
	alert($slideshow.activateTab);
}


window.onload = function() 
{   
	// add a 'js' class to the body
    $('body').addClass('js');
    
    // initialise the slideshow when the DOM is ready
    $slideshow.init();
} 










