var rotateSpeed = 5000; // Milliseconds to wait until switching tabs.
var currentTab = 0; // Set to a different number to start on a different tab.
var numTabs; // These two variables are set on document ready.
var autoRotate;

function openTab(clickedTab) {
   var thisTab = $(".tabbed-box .tabs a").index(clickedTab);
   $(".tabbed-box .tabs li a").removeClass("active");
   $(".tabbed-box .tabs li a:eq("+thisTab+")").addClass("active");
   $(".tabbed-box .tabbed-content").fadeOut();
   $(".tabbed-box .tabbed-content:eq("+thisTab+")").fadeIn();
   currentTab = thisTab;
}

function rotateTabs() {
	/*
	Uncomment to enable auto tab rotation..
	
   var nextTab = (currentTab == (numTabs - 1)) ? 0 : currentTab + 1;
   openTab($(".tabbed-box .tabs li a:eq("+nextTab+")"));
   */
}

$(document).ready(function() {

	/* Tab box stuff */
   numTabs = $(".tabbed-box .tabs li a").length;
   $(".tabbed-box .tabs li a").click(function() { 
      openTab($(this)); return false; 
   });
   $(".tabbed-box").mouseover(function(){clearInterval(autoRotate)})
   .mouseout(function(){autoRotate = setInterval("rotateTabs()", rotateSpeed)});
   
   $(".tabbed-box .tabs li a:eq("+currentTab+")").click()
   $(".tabbed-box").mouseout();
   
   /* Home slider */
	$('.slideshow').cycle({
		fx: 'fade',
		pager: '#pager'
	});
	
	/* News slider */
	$('.newsitems').cycle({
		fx: 'scrollHorz',
	    timeout: 7000,
	    next:   '.slideright', 
    	prev:   '.slideleft',
		cleartype:  true,
	    cleartypeNoBg:  true,
		pause:   1 
   });
	
	/* Client logos slider */
	$('.logowrap').cycle({
		fx: 'fade',
		timeout: 1500
   });
	
	/* The big slideshow banner thing on the home page */
	
	$('#slider').cycle({
		fx: 'fade',
		timeout: 5500
	});

});
