var counter = 1;
var timer;
var now = new Date();
var before = new Date();
var focus = true;

function slideShow()
	{

		var $active = $('div#header-index li.ss-active');
		if ($active.length == 0)
		{

			$active = $('div#header-index li:last');
		}
		var $next = $active.next().length ? $active.next() : $('div#header-index li:first');
		$active.addClass('ss-last-active');
		
		$next.css({opacity: 0.0})
			.addClass('ss-active')
			.animate({opacity: 1.0 }, 1000, function() 
				{
					$active.removeClass('ss-active ss-last-active');
			});
		window.counter++;
		//timer = setTimeout("slideShow()", 5000);
	}

$(function() {

	// INDEX NAVIGATION
	$('ul#nav li').hover(
	function()
	{ 
		var margin = 0;
		
		margin = 400 - $(this).children('ul').height();
		
		//alert(margin);
		$(this).children('ul').css('margin-top', margin);
	
	},
	function()
	{}
	);
	
	
	
	// INDEX SLIDESHOW
	
	 timer = setInterval("slideShow()", 5000);
	 window.addEventListener('blur', function() {
		focus = false;
		clearInterval(timer);
	 },false);
	 
	 window.addEventListener('focus',function() {
		if (!focus)
			timer = setInterval("slideShow()", 5000);
		focus = true;
	 },false);
	 
	 //timer = setTimeout("slideShow()",5000);
	//slideShow();

	
});

	
