
$(function(){
		
// sidenav hover in ie6
	if($('#nav').length > 0 && jQuery.browser.msie) {
		$('#nav li')
			.mouseenter(function(){$(this).addClass('sfhover')})
			.mouseleave(function(){$(this).removeClass('sfhover')});
	}
//mid top area
	$('.home').height($(window).height()+10)
	// auto rotate
	transitionTime = 0;
	waitTime = 8000;
	
	current = 0;
	items = $('.home .subnav a').length;
	$('.home .subnav').oneTime(waitTime, Date(), rotate)
	
	// manual rotate
	$('.home .subnav a')
		.mouseover(function() {
			if($(this).parent().hasClass('on')) {
				return;
			}
			ind = $('.subnav a').index($(this));
			$('.home .subnav').stopTime();
			showItem(ind)
			return false;
		})
		.mouseout(function(){
			$('.home .subnav').oneTime(waitTime, Date(), rotate)
		});
	
// text size
	$('#text_size a.sml').click(function(){
		$('body').css({fontSize: '1em'});
		if($('.subnav').length > -1) {
			fixBannerHeight();
		}
		return false;
	})
	$('#text_size a.med').click(function(){
		$('body').css({fontSize: '1.15em'});
		if($('.subnav').length > -1) {
			fixBannerHeight();
		}
		return false;
	})
	$('#text_size a.big').click(function(){
		$('body').css({fontSize: '1.3em'});
		if($('.subnav').length > -1) {
			fixBannerHeight();
		}
		return false;
	})
	
	});

function fixBannerHeight() {
	ind = $('.subnav li').index($('.subnav .on'));
	newHeight = $('.item:eq('+ind+')').height();
	$('.top_left_col').animate({height: newHeight+'px'});
}


function rotate() {
	current++;
	current = current%items;
	
	showItem(current)
	$('.home .subnav').oneTime(waitTime, Date(), rotate)
}
function showItem(ind) {
	$('.subnav li').removeClass('on');
	$('.subnav li:eq('+ind+')').addClass('on');
	$('.item.on').css({zIndex: '5'}).stop(true,true).fadeOut(transitionTime);
	$('.item:eq('+ind+')').css({zIndex: '10'}).stop(true,true).fadeIn(transitionTime, function(){
			$('.item.on').removeClass('on').css({display: 'none'});
			$(this).addClass('on');
	});
	newHeight = $('.item:eq('+ind+')').height();
	$('.top_left_col').stop(true,true).animate({height: newHeight+'px'});
}

