//array to store IDs of our tabs
var tabs = [];
//index for array
var ind = 0;
//store setInterval reference
var inter;

//change tab and highlight current tab title
function change(stringref){
	//hide the other tabs
	jQuery('.tab:not(#' + stringref + ')').hide();
	//show proper tab, catch IE6 bug
	if (jQuery.browser.msie && jQuery.browser.version.substr(0,3) == "6.0")
		jQuery('.tab#' + stringref).show();
	else 
		jQuery('.tab#' + stringref).fadeIn();
	//clear highlight from previous tab title
	jQuery('.htabs div:not(#' + stringref + 't)').css('background-image', 'url(images/2010-images/inactive-box-bg.png)');
	jQuery('.htabs div:not(#' + stringref + 't)').css('background-color', '#edece7');
	jQuery('.htabs div:not(#' + stringref + 't) a').css('color', '#7c6b5a');
	//highlight currenttab title
	jQuery('.htabs #' + stringref + 't').css({'background-image': 'url(images/2010-images/active-box-bg.png)','background-repeat': 'repeat-x', 'color' : '#ffffff', 'background-color' : '330000'});
	jQuery('.htabs #' + stringref + 't a').css('color', '#ffffff');
}
/*
function next(){
	//call change to display next tab
	change(tabs[ind++]);
	//if it's the last tab, clear the index
	if(ind >= tabs.length)
		ind = 0;
}
*/
jQuery(document).ready(function(){
	//store all tabs in array
	jQuery(".tab").map(function(){
		tabs[ind++] = jQuery(this).attr("id");
    })
	//set index to next element to fade
	ind = 1;
	//initialize tabs, display the current tab
	jQuery(".tab:not(:first)").hide();
	jQuery(".tab:first").show();
	//highlight the current tab title
	jQuery('#' + tabs[0] + 't').css('background-image', 'url(images/2010-images/active-box-bg.png)');
	jQuery('#' + tabs[0] + 't').css('background-color', '7c6b5a');
	jQuery('#' + tabs[0] + 't a').css('color', '#ffffff');

	//handler for clicking on tabs
	jQuery(".htabs a").click(function(){
		
		//if tab is clicked, stop rotating 
		//clearInterval(inter);
		//store reference to clicked tab
		stringref = jQuery(this).attr("href").split('#')[1];
		//display referenced tab
		change(stringref);
		return false;
	});
	//start rotating tabs
	//inter = setInterval("next()", 1000);
});
