// JavaScript Document
var news_json = false;
function news_ticker(){
	if(news_json===false){
		$.getJSON('/json/latest_news', function(data,textStatus){
			if(data.queryResponse){
				news_json = data.queryResponse;
				news_json.current = 0;
				news_ticker();
			}
		});
		return false;
	}else{
		if(news_json.current >= news_json.items.length){
			news_json.current = 0;
		}
		var tmp = news_json.items[news_json.current];
		var html = '<div class="news_title"><a href="' + tmp.LINK + '" target="_blank">' + tmp.TITLE + '</a></div><div class="news_description">' + tmp.DESCRIPTION + '</div>';
		$('#news_ticker_news').html(html);
		news_json.current = news_json.current + 1;
		setTimeout(news_ticker, 10000);
	}
	
}

$(function(){
	news_ticker();
});
