$partnerslideshow = {
    init: function(fx_var, timeout_var, slideSpeed_var, tabSpeed_var, bgYes_var) {
		context = false;
		tabs = false;
		if(bgYes_var=="false") bgYes = false; 
		if(bgYes_var=="true") bgYes = true; 
		timeout = timeout_var;      // time before next slide appears (in ms)
		slideSpeed = slideSpeed_var;   // time it takes to slide in each slide (in ms)
		tabSpeed = tabSpeed_var;      // time it takes to slide in each slide (in ms) when clicking through tabs
		fx = fx_var;   // the slide effect to use
       
	   // set the context to help speed up selectors/improve performance
        this.context = $('#partnerslideshow');
        
        // set tabs to current hard coded navigation items
        this.tabs = $('ul.pslides-nav li.tab', 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();
    },
    
    prepareSlideshow: function() {
        // initialise the jquery cycle plugin -
        // for information on the options set below go to: 
        // http://malsup.com/jquery/cycle/options.html
        $('div.pslides > ul', $partnerslideshow.context).cycle({
            fx: fx,
            timeout: timeout,
            speed: slideSpeed,
            fastOnEvent: tabSpeed,
			prev: '#pcycle_prev',
			next: '#pcycle_next',
            pager: $('ul.pslides-nav', context),
           // pagerAnchorBuilder: $partnerslideshow.prepareTabs,
            before: $partnerslideshow.activateTab,
			cleartypeNoBg:  bgYes,
            pauseOnPagerHover: true,
            pause: true
			
        }); 

		//pause and esumebuttons
		$('#pcycle_resume').click(function() { 
			$('div.pslides > ul', $partnerslideshow.context).cycle('resume'); 
			$("#pcycle_resume").addClass("sresume");
			$("#pcycle_pause").removeClass("spause");
			$("#pcycle_resume").parents('p.pause').addClass("shide");
			$("#pcycle_pause").parents('p.pause').removeClass("shide");
		});
	
		$('#pcycle_pause').click(function() { 
			$('div.pslides > ul', $partnerslideshow.context).cycle('pause'); 
			$("#pcycle_pause").addClass("spause");
			$("#pcycle_resume").removeClass("sresume");
			$("#pcycle_resume").parents('p.pause').removeClass("shide");
			$("#pcycle_pause").parents('p.pause').addClass("shide");
		});
	
		
    },
    
    prepareTabs: function(i, slide) {
        // return markup from hardcoded tabs for use as jQuery cycle tabs
        // (attaches necessary jQuery cycle events to tabs)
        return $partnerslideshow.tabs.eq(i);
    },

    activateTab: function(currentSlide, nextSlide) {
        // get the active tab
        var activeTab = $('#partnerslideshow  a[href="#' + nextSlide.id + '"]', $partnerslideshow.context);
        
        // if there is an active tab
        if(activeTab.length) {
            // remove active styling from all other tabs
            $partnerslideshow.tabs.removeClass('on');
            
            // add active styling to active button
            activeTab.parent().addClass('on');
        }            
    } 
	
};
