$(document).ready(function()
{
	$('.js-hide').hide();
	$('.new-window').click(function(){return !window.open($(this).attr('href'));});
	$('a[rel="lightbox"]').lightBox();
	theRotator('s1',4000);
	theRotator('s2',5500);
	theRotator('s3',7500);
	theRotator('s4',5000);
	theRotator('s5',6500);

	$('#home-box .box-img').hover(function(){$(this).stop().animate({bottom:'112px'},{queue:false,duration:160});},function(){$(this).stop().animate({bottom:'0px'},{queue:false,duration:160});});

	$('#subnav ul').hide();
	$('#subnav .hi ul').show();
	$('#subnav a.trigger').click(function()
	{
		$('#subnav ul:visible').slideUp('fast');
		$('ul:hidden', $(this).parent()).slideDown('fast');
		return false;
	});

	$('.toggle').click(function()
	{
		$('.toggle-box:visible').slideUp('fast');
		$('.bg-title-on').removeClass('bg-title-on');

		if ($('#toggle-'+$(this).attr('id')).is(':hidden'))
		{
			$(this).addClass('bg-title-on');
			$('#toggle-'+$(this).attr('id')).slideDown('fast');
		}
	});
});

function theRotator($id,$timer)
{
	//$timer = Math.floor(Math.random()*19000);
	$('ul#'+$id+' li').css({opacity:0.0});
	$('ul#'+$id+' li:first').css({opacity:1.0});
	setInterval('rotate("'+$id+'")',$timer);
}

function rotate($id)
{
	var current = ((typeof $('ul#'+$id+' li.show').attr('class') != 'undefined')?  $('ul#'+$id+' li.show') : $('ul#'+$id+' li:first'));
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('ul#'+$id+' li:first') :current.next()) : $('ul#'+$id+' li:first'));
	next.css({opacity:0.0}).addClass('show').animate({opacity:1.0},2500);
	current.animate({opacity:0.0},2500).removeClass('show');
};

