// JavaScript Document

var headerSwitchInterval = 8000;

$(document).ready(function(){
	setTimeout(rotateImage,headerSwitchInterval);
	$('input.inactive').bind('focus',inputFocus).bind('blur',inputBlur);
	$('a[href^=http]').attr({'target':'_blank'});
	$('#fluSeason li').click(switchTab);
	$('#fluSeason li:last').addClass('last');
	$('#fluSeason li:first').addClass('first').click();
	$('.footnote').click(clickFootnote);
	$('.roundBox .toggleUL').click(toggleLI);
	if($('.tabbedTable.top').size()){
		var num = $('.tabbedTable.top>ul>li').size();
		$('.tabbedTable.top>ul>li').css({width:(100/num)+'%'});
	}
});

function switchTab(){
	$(this).siblings().removeClass('selected').end().addClass('selected');
	$(this).parent().next().find('#'+$(this).attr('id')).addClass('selected').siblings().removeClass('selected');
}

function inputFocus(){
	if($(this).val()=='Search'){
		$(this).removeClass('inactive').val('');
	}
}

function inputBlur(){
	if($(this).val()==''){
		$(this).addClass('inactive').val('Search');
	}
}

function rotateImage(){
	var current = $('#banners a:visible');
	if(current.next().size()){
		current.next().fadeIn(1000);
	}else{
		$('#banners a:first').fadeIn(1000);
	}
	current.fadeOut(1000);
	setTimeout(rotateImage, headerSwitchInterval);
}

function clickFootnote(){
	$(document).scrollTo($(this).attr('goto'),500,{offset:-10});
	$($(this).attr('goto')).parent().effect('pulsate',500).effect('highlight',2500);
}

function toggleLI(){
	if($(this).next().find('li:visible').size()){
		$(this).parent().animate({'background-color':'#fff'},'normal');
	}else{
		$(this).parent().animate({'background-color':'#e3e3e3'},'normal');
	}
	$(this).toggleClass('on').next().find('li').toggle('normal');
}

if($.browser.opera){
	$('head').append('<link rel="stylesheet" type="text/css" href="/includes/css/styles_opera.css" />');
}

if($.browser.mozilla){
	$('head').append('<link rel="stylesheet" type="text/css" href="/includes/css/styles_ff.css" />');
}


