﻿jQuery(document).ready(function(){

 var thisId = this;
 var tabIdnum = 1;
 var intervalId = 0;

function autotab(){
	 thisId = ".vtabs a#tab"+tabIdnum;
 	 bannerchange();
	 $('.vtabs a').removeClass('currentbanner');
	 $('#tab'+tabIdnum).addClass('currentbanner');
	 tabIdnum++;
	 if (tabIdnum > 4){
	 	tabIdnum = 1;
	 }
 }
 autotab();
 intervalId = setInterval ( autotab, 8000 );

 
 //if this is not the first tab, hide it
 jQuery(".tab:not(:first)").hide();
 
 //to fix u know who
 jQuery(".tab:first").show();
 
 //when we click one of the tabs
 jQuery(".vtabs a").click(function(){
	thisId = this;
 	bannerchange();
 	clearInterval(intervalId);
 	$('.vtabs a').removeClass('currentbanner');
 	$(thisId).addClass('currentbanner');
 	return false;
 });
 
 function bannerchange(){
 	//get the ID of the element we need to show
 	stringref = jQuery(thisId).attr("href").split('#')[1];
 	//hide the tabs that doesn't match the ID
 	jQuery('.tab:not(#'+stringref+')').hide();

 	//fix
 	if (jQuery.browser.msie && jQuery.browser.version.substr(0,3) == "6.0") {
 	jQuery('.tab#' + stringref).show();
 	}
 	else
 	//display our tab fading it in
 	jQuery('.tab#' + stringref).slideDown();
 	//stay with me
 }

});


