$(function(){
	
	// newsfilter toggle
	$('#toggle-newsfilter').toggle(
	function(){
		$(this).html('Hide filter<span></span>').addClass('open').next('div.inner').slideDown(300);
	},
	function(){
		$(this).html('Show filter<span></span>').removeClass('open').next('div.inner').slideUp(300);
	})
	
	
	// homepage news ticker
	var $item  = $("li.news-item"),
		item_count = $item.size(),
		item_interval,
		current_item = 0,
		old_item = 0;
	
	$item.css({'position':'absolute','top':'35px'});
	$item.eq(current_item).css('top',0);
	
	//start the function
	item_interval = setInterval(item_move,3000);
	
	// stop scrolling on hover
	$('#latest-news').hover(
	function(){
		clearInterval(item_interval);
	},
	function(){
	 	item_interval = setInterval(item_move,3000);
		
	});
	
	// the scrolling function
	function item_move() {
		current_item = (old_item + 1) % item_count;
		$item.eq(old_item).animate({top: -40},"slow", function(){
		   $(this).css('top', 40);
		 });
		$item.eq(current_item).animate({top: 0},"slow"); 
			old_item = current_item;
	}

})
