function jikoku() {
	d = new Date()
	millenium = new Date(d.getYear(),d.getMonth()+1,d.getDate(),24,00,00)
	
	today = new Date()
	myMsec= millenium.getTime()-today.getTime();
	time0 = Math.floor(myMsec/(1000*60*60*24));
	myMsec -= (time0*(1000*60*60*24)); 
	time1 = Math.floor(myMsec/(1000*60*60));
	myMsec -= (time1*(1000*60*60)); 
	time2 = Math.floor(myMsec/(1000*60)); 
	myMsec -= (time2*(1000*60));
	time3 = Math.floor(myMsec/1000);
	
	for(i=0;i<2;i++){ time1 = '' + '0' + time1; }
	for(i=0;i<2;i++){ time2 = '' + '0' + time2; }
	for(i=0;i<2;i++){ time3 = '' + '0' + time3; }
	time1 = time1.substring(time1.length - 2,time1.length);
	time2 = time2.substring(time2.length - 2,time2.length);
	time3 = time3.substring(time3.length - 2,time3.length);

        
        ntime="<div id=\"count_down\"><span class=\"time\">"+time1+"</span><span class=\"min\">"+time2+"</span><span class=\"sec\">"+time3+"</span></div>";

		document.getElementById("countdown").innerHTML= ntime;
		setTimeout("jikoku()",1000);
		setTimeout("loadDataFile('csv/counter.csv')",1000);
}

function loadDataFile(fName)
{
httpObj = createXMLHttpRequest(displayData);
if (httpObj)
{
httpObj.open("GET",fName,true);
httpObj.send(null);
}
}
function displayData()
{
if ((httpObj.readyState == 4) && (httpObj.status == 200))
{
$("lastday").innerHTML = parseTabText(httpObj.responseText);
}else{

}
}

function parseTabText(tabText)
{

var dt1 = new Date();     
Hhour = dt1.getHours();
Hmin  = dt1.getMinutes();
Hsec  = dt1.getSeconds();
for(i=0;i<2;i++){ HhourA = '' + '0' + Hhour; }
for(i=0;i<2;i++){ HminA = '' + '0' + Hmin; }
for(i=0;i<2;i++){ HsecA = '' + '0' + Hsec; }
HhourA = HhourA.substring(HhourA.length - 2,HhourA.length);
HminA  = HminA.substring(HminA.length - 2,HminA.length);
HsecA  = HsecA.substring(HsecA.length - 2,HsecA.length);

hikaku = "1"+HhourA+HminA+HsecA;

var lastdayText = "<div id=\"clock\"><span class=\"hour\">"+HhourA+"</span><span class=\"min\">"+HminA+"</span></div>";
var LF = String.fromCharCode(10); 
var CR = String.fromCharCode(13); 

tabText = tabText.replace( CR, "");
lineData = tabText.split(LF);
for (var i=0; i<lineData.length; i++)
{
wCount = lineData[i].split(",");
gg     = wCount[0].split(":");
if(parseInt(gg[0])<10){
wCount[0] = "0"+wCount[0];
}
moto   = "1"+wCount[0].replace(":","");
moto   = moto.replace(":","");

if(parseInt(moto)>parseInt(hikaku)){
wCount = lineData[i-1].split(",");
tData = wCount[1]; 
if(tData<10){
tData = "0"+tData;
}
lastdayText += "<div id=\"last_people\">"+tData+"</div>";
break;
}
}
return lastdayText;
}

