CurrentBannerLocation = 0;
CurrentNewsLocation = 0;
BANNER_IMG_LENGTH = 934;


moveBanner = function(to){
	$('#myslide .cover').animate({left:-BANNER_IMG_LENGTH*(parseInt(to)-1)})  /*----- Width of div mystuff (here 160) ------ */
	CurrentBannerLocation = to;
	$('#button a').each(function(){
		if($(this).attr('rel') == to){ 
			$(this).addClass('active')
		} else {
			$(this).removeClass('active');
		}
	})
}

moveNews = function(to){
	var list = $('#newsBar ul').children('li');
	var height = 12;

	for(var i = 0; i < to - 1; i++){
		height -= $(list[i]).outerHeight(true);
	}

	$('#newsBar ul').animate({top:height});
	$('#newsBar').animate({height:$(list[to - 1]).outerHeight(true)});
	CurrentNewsLocation = to;
}



$(document).ready(function (){

	$('#button a').click(function(){
		moveBanner($(this).attr('rel'));
		clearInterval(interval);
	});
	
	imageCount = $('.cover').children('.mystuff').length
	$('#splash #myslide .cover').css('width', BANNER_IMG_LENGTH * imageCount);
	interval = setInterval(function(){moveBanner(CurrentBannerLocation%imageCount + 1)}, 4500);
	
//	console.log($('#newsBar li').outerHeight

	newsCount = ($('#newsBar ul').children('li')).length;
	moveNews(1);
	newsInterval = setInterval(function(){moveNews(CurrentNewsLocation%newsCount + 1)}, 7000);
	
	
});
