﻿$(function() {
	$("a#tabLink").attr("href","http://www.bbc.co.uk/0"); //whatever link you fancy for the first tab
	$("a.tab:eq(0)").addClass("on");
	$("#home-tabs").find("a.tab").each( function(i){
		$(this).click(function(){
			moveTab(i,true);
		})
	});
	startTabs();
});
var interval, num;
num = 1;
function startTabs(){
	interval = setInterval("moveTab(num, false)", 5000); //alter time (ms) between each tab change
}
function moveTab(tabNum, cleared) {
	$("a.tab").removeClass("selected");
	$("a.tab:eq("+tabNum+")").addClass("selected");
	$(".tabCont").stop().animate({
		"opacity": "0"
	},600,function(){$(".tabCont").css({"zIndex":"1"})});//change this value to make the fade out transition longer or shorter
	$(".tabCont:eq("+tabNum+")").stop().animate({
		"opacity": "1"
	},600,function(){$(".tabCont:eq("+tabNum+")").css({"zIndex":"2"})});//change this value to make the fade in transition longer or shorter
	if(cleared){clearInterval(interval)};
	num+=1;
	if(num>2)(num=0);
}
