
function InitNewsJs(){
	//rotation speed_rss and timer
	var speed_rss = 5000;
	var run = setInterval('rotate()', speed_rss);	
	
	//grab the width and calculate left value
	var item_width = $('#slides li').outerWidth(); 
	var left_value = item_width * (-1); 
        
    //move the last item before first item, just in case user click prev button
	$('#slides li:first').before($('#slides li:last'));
	
	//set the default item to the correct position 
	$('#slides ul').css({'left' : left_value});

    //if user clicked on prev button
	$('#prev').click(function() {
		var left_indent = parseInt($('#slides ul').css('left')) + item_width;
		$('#slides ul:not(:animated)').animate({'left' : left_indent}, 200,function(){    
			$('#slides li:first').before($('#slides li:last'));           
			$('#slides ul').css({'left' : left_value});
		});
		
		clearInterval(run);
		run = setInterval('rotate()', speed_rss);

		
		//cancel the link behavior            
		return false;
	});

 
    //if user clicked on next button
	$('#next').click(function() {
		var left_indent = parseInt($('#slides ul').css('left')) - item_width;
		$('#slides ul:not(:animated)').animate({'left' : left_indent}, 200, function () {
			$('#slides li:last').after($('#slides li:first'));                 	
			$('#slides ul').css({'left' : left_value});
		});
		
		clearInterval(run);
		run = setInterval('rotate()', speed_rss);
		         
		//cancel the link behavior
		return false;		
	});        
	
	//if mouse hover, pause the auto rotation, otherwise rotate it
	$('#slides').hover(function() {
		clearInterval(run);
	},function(){
		run = setInterval('rotate()', speed_rss);	
	}); 
}

function rotate() {
	$('#next').click();
}
