/*
* Latest News
*/

var ln_index = 0;
var ln_size = 0;
var ln_height = 0;
var ln_stop = false;

$(document).ready(function(){
	
	$('#latestNewsAnimation').hover(
		
		function(){
			ln_stop = true;		
		},
		
		function(){
			ln_stop = false;		
		}
		
	);
	
});

function latestNews(size,height){
	
	ln_size = size;
	
	ln_height = height;
	
	latestNewsAnimate(true);
	
}

function latestNewsAnimate(firsttime){
	if(!ln_stop && !firsttime){
		ln_animate();
	}
	
	$('#ln_info_'+(ln_index+1)).addClass('active');
	window.setTimeout('latestNewsAnimate('+false+')',4000);	
}

function ln_animate(){
	
	ln_index++;
	
	if(ln_index == ln_size){
		ln_index = 0;
	}
	$('.info').removeClass('active');
	$('#ln_info_'+(ln_index+1)).addClass('active');
	
	$('.latestNewsViewer ul').animate({marginTop : (-1*(ln_height*ln_index))},500);	
	
}

function viewLatestNews(n){
	
	ln_index = n-2;
	
	ln_animate();
	
}
