//$(document).ready(function() {
//	show_incidents( 'MRCC' );
//});
// This is needed because pubsys isn't working IE and pubsys dynamic pages arent' working 100% of the time 
/*setTimeout("show_incidents( 'MRCC' )", 6000);*/

function show_incidents ( myDispatchID ) {
	var findStr = "Dispatch[@ID=\"" + myDispatchID + "\"]>Log:lt(5)";
	$.get('/static/includes/traffic/sa.xml', function(data) {
		$('#incidents').empty();
		var html = '<div>';
		var size = $(data).find(findStr).size();
		//If no incident reports are in the XML file for the dispatchID passed
		if (size == 0) {
			html += '<h4> No traffic incidents filed <h4>';
		} 
		//ELSE print out the first 5 incidents
		else {
			$(data).find(findStr).each(function() {
				var item = $(this);
							
				var logType = item.find( 'LogType' ).text();
				var logTime = item.find( 'LogTime' ).text();
				var logLocation = item.find( 'Location' ).text();
				var logArea = item.find( 'Area' ).text();
				
				//Need to strip out the quotes
				html +='<div class="incident">';
				html += '<h4>' + logType.replace(/"/g,'') + '</h4>';
				html += '<ul> <li>' + logTime.replace(/"/g,''); + '</li>';
				html += ' <li>' + logLocation.replace(/"/g,''); + '</li>';
				html += '<li>' + logArea.replace(/"/g,''); + '</li> </ul>';
				html += '</div>';
			});
		}
		html += '</div>';
		$('#incidents').append($(html));
	});
}
