$(document).ready(function() {
	

	setList();
});

	function setList(){
		var httpRequest = null;
		if (window.XMLHttpRequest) {
		  // If IE7, Mozilla, Safari, and so on: Use native object.
		  httpRequest = new XMLHttpRequest();
		}	else	{
		  if (window.ActiveXObject) {
		     // ...otherwise, use the ActiveX control for IE5.x and IE6.
		     httpRequest = new ActiveXObject('MSXML2.XMLHTTP.3.0');
		  }
		}
		var now = new Date();
		var year = now.getFullYear()%100;
		var mm = now.getMonth() + 1; // 月
		if(mm < 10) { mm = "0" + mm; }
		var day = now.getDate(); // 日
		if(day < 10) { day = "0" + day; }
		var fileName = "realtime-" + String(year) + String(mm) + String(day) + ".xml";

	    httpRequest.open("GET", fileName ,true) 
	    httpRequest.send(null) 

	    httpRequest.onreadystatechange = function() { 

	        if ((httpRequest.readyState == 4) && (httpRequest.status == 200)) { 

				var hour = now.getHours(); // 時
				var min = now.getMinutes(); // 分
				if(hour < 10) { hour = "0" + hour; }
				if(min < 10) { min = "0" + min; }
				var hm = String(hour) + String(min);
				var num = 0;
	            var resultStr = '<div class="body">'; 
		            resultStr += '<ul>'
	            var xmlData = httpRequest.responseXML; 

	            var userData = xmlData.getElementsByTagName('item'); 
	            var idData = xmlData.getElementsByTagName('id'); 
	            var timeData = xmlData.getElementsByTagName('time'); 
	            var nameData = xmlData.getElementsByTagName('text'); 
	            for (var i = 0 ;i<userData.length ;i++) { 

					if(idData[i].childNodes[0].nodeValue <= hm){
						num++;


		                resultStr += '<li><span class="rt_time">' + timeData[i].childNodes[0].nodeValue + '</span>'
		                resultStr += nameData[i].childNodes[0].nodeValue + '</li>'



						if(num == 10){
							break;
						}
					}

					/*if(idData[i].childNodes[0].nodeValue == hm){
						document.getElementById("realtime").innerHTML = "AAAA"; 
					}else{
						document.getElementById("realtime").innerHTML = "BBB"; 
					}*/

	            }
		        resultStr += '</ul>'
	            resultStr += '</div>'; 
	            document.getElementById("resultDiv").innerHTML = resultStr;

	        } 
	    }
	setTimeout("setList()", 30000);
	}


