var $A=jQuery.noConflict();
//array to store IDs of our anntabs
var anntabs = [];
//index for array
var ind = 0;
//store setInterval reference
var inter;

//change anntab and highlight current anntab title
function change(stringref){
	//hide the other anntabs
	$A('.anntab:not(#' + stringref + ')').hide();
	//show proper anntab, catch IE6 bug
	if ($A.browser.msie && $A.browser.version.substr(0,3) == "6.0")
		$A('.anntab#' + stringref).show();
	else 
		$A('.anntab#' + stringref).fadeIn();
	//clear highlight from previous anntab title
	$A('.hanntabs a:not(#' + stringref + 't)').removeClass('select');
	//highlight currentanntab title
	$A('.hanntabs a[href=#' + stringref + ']').addClass('select');
}
function next(){
	//call change to display next anntab
	change(anntabs[ind++]);
	//if it's the last anntab, clear the index
	if(ind >= anntabs.length)
		ind = 0;
}
$A(document).ready(function(){
	//store all anntabs in array
	$A(".anntab").map(function(){
		anntabs[ind++] = $A(this).attr("id");
    })
	//set index to next element to fade
	ind = 1;
	//initialize anntabs, display the current anntab
	$A(".anntab:not(:first)").hide();
	$A(".anntab:first").show();
	//highlight the current anntab title
	$A('#' + anntabs[0] + 't').addClass('select');
	//handler for clicking on anntabs
	$A(".hanntabs a").click(function(){
		
		//if anntab is clicked, stop rotating 
		clearInterval(inter);
		//store reference to clicked anntab
		stringref = $A(this).attr("href").split('#')[1];
		//display referenced anntab
		change(stringref);
		return false;
	});
	//start rotating anntabs
	inter = setInterval("next()", 8000);
	$A('.anntabs').hover(function() {
        clearInterval(inter);
    }, function() {
        inter = setInterval("next()", 8000);
    });
});
