$(document).ready(function() {
	var count = $("#news_wrapper div").attr('class');
	if (count == '' || count == undefined) {
		count = 0;
	} else if (count == 5) {
		count = 0;
	}
	var data = "id=" + count;
	
	$.ajax({
		url: 'http://www.mtaoptima.com.au/mta/news.inc.php',
		cache: false,	
		data: data,
		type: 'GET',
		success: function(html) {
			$('#news_wrapper').html(html);
		}
	});
	
	setTimeout('roll_news()', 10000);

});

function roll_news() {
	var count = $("#news_wrapper div").attr('class');
	if (count == '' || count == undefined) {
		count = 0;
	} else if (count == 4) {
		count = 0;
	}
	var data = "id=" + count;
	
	$('#news_wrapper').fadeOut(2000, 
			function() {
				$.ajax({
					url: 'http://www.mtaoptima.com.au/mta/news.inc.php',
					cache: false,	
					data: data,
					type: 'GET',
					success: function(html) {
						$('#news_wrapper').html(html);
					}
				});
			});
	
	$('#news_wrapper').append('<script type="text/javascript">setTimeout(\'roll_news()\', 10000)</script>');
	$('#news_wrapper').fadeIn(2000);
}
