$(document).ready(function() {
	$("a[title]").tooltip();
	$jScroller.add("#Scroller","#Scroll","left",4,true);
	$jScroller.start();
});

function RegionReport(_RegionID) {
	$.getJSON("json.php", { RegionID: _RegionID }, 
			function(data){
				if (data.length) {
					var LastCat = '';
					var html = '';
					$.each(data,
							function(i,item) {
								if (LastCat != item.OrgCat) {
									LastCat = item.OrgCat;
									html += '<span class="TickerCategory">' + LastCat + ':</span>';
								}
								html += '<span class="TickerName">'+item.OrgName+ '</span>';
								html += '<span class="TickerMessage"> - ' + item.Message + '</span><span class="TickerPosted"> - Posted: ' + item.Posted + '</span>'
								html += '<span class="TickerDots">...</span>';
								
							}
						);
				}
				else {
					// nothing to report
					html = '<span>There are no emergency messages to display currently for this region.</span>';
				}
				
				var scroller = $('div#Scroller');
				
				scroller.empty();
				scroller.append('<div id="Scroll">'+html + '</scroll>');
				$jScroller.add("#Scroller","#Scroll","left",4,true);
				$jScroller.start();
	});	
	setTimeout("RegionReport("+_RegionID+");", 20 * 60 * 1000);
}