/******************************************************************************************************************/
// TICKER FUNCTIONS
/******************************************************************************************************************/

function TickerRun(delay){
	h = $('.ticker UL').height();
	endm = '-'+ h +'px';
	
	$('.ticker UL').animate({ marginTop: endm }, delay, 'linear', function(){
		$('.ticker UL').css({ marginTop: '80px' });
		delay = $('.ticker LI').size() * 2000;
		TickerRun(delay);
	});
}

function TickerInit(){
	tnum = $('.ticker LI').size(); 
		
	if (tnum > 1) {
		$('.ticker UL').css({ position: 'absolute', marginTop: '80px' });
		delay = tnum * 2000;
		
		TickerRun(delay);
		
		$('.ticker LI').hover(function(){
			index = $('.ticker LI').index(this);
			$('.ticker UL').stop(true);
		}, function(){
			delay = (tnum - index) * 2000;
			TickerRun(delay);
		});
	}
}

/******************************************************************************************************************/
// SLIDE FUNCTIONS
/******************************************************************************************************************/

function SlideRun(i){
	$('.slide LI').show();
	if (i == 0) {
		$('.slide LI:eq('+ i +')').animate({marginLeft: '50px', opacity: 0}, 1000, function(){
			$('.slide LI').css('marginLeft','0px');
			$('.slide LI').animate({opacity: 1}, 500);
		});
	}
	else $('.slide LI:eq('+ i +')').animate({marginLeft: '50px', opacity: 0}, 1000);
		
	i--;
	if (i < 0) { i = $('.slide LI').size() - 1 };
	SlideTimerId = window.setTimeout('SlideRun('+ i +')', 6000);
}

function SlideInit(){
	snum = $('.slide LI').size();
	$('.slide LI').hide();
	if (snum > 1) SlideTimerId = window.setTimeout('SlideRun('+ (snum - 1) +')', 6000);
}

/******************************************************************************************************************/
// NAVMAP FUNCTION
/******************************************************************************************************************/

function handleNavmap(){
	$('.navmap2 .points STRONG').css('opacity', 0.9);
	$('.navmap2 .points STRONG').hide();
	
	$('.navmap2 .points LI').hover(function(){
		$(this).find('STRONG').show();
	}, function(){
		$(this).find('STRONG').hide();
	});
}


/******************************************************************************************************************/
// on document load...
/******************************************************************************************************************/

$(function(){
	// menu opacity
	$('#menu LI UL').css('opacity', 0.9);
	
	// intro slideshow
	SlideInit();
	
	// news ticker
	TickerInit();
	
	// navmap
	handleNavmap();
});