// JavaScript Document
function refreshVisitorCount()
	{
		/*
		
			function xmlhttpPost(strURL) {
				var xmlHttpReq = false;
				var self = this;
				// Mozilla/Safari
				if (window.XMLHttpRequest) {
					self.xmlHttpReq = new XMLHttpRequest();
				}
				// IE
				else if (window.ActiveXObject) {
					self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
				}
				self.xmlHttpReq.open('POST', strURL, true);
				self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				self.xmlHttpReq.onreadystatechange = function() {
					if (self.xmlHttpReq.readyState == 4) {
						updatepage(self.xmlHttpReq.responseText);
					}
				}
				self.xmlHttpReq.send(getquerystring());
			}
			
			function getquerystring() {
				var form     = document.forms['f1'];
				var word = form.word.value;
				qstr = 'w=' + escape(word);  // NOTE: no '?' before querystring
				return qstr;
			}
			
			function updatepage(str){
				document.getElementById("result").innerHTML = str;
			}
		
		*/
		
		var xmlHttpReq = false;
		var self = this;
		
		
		
		
		// Mozilla/Safari
		if (window.XMLHttpRequest) {
			self.xmlHttpReq = new XMLHttpRequest();
		}
		// IE
		else if (window.ActiveXObject) {
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		self.xmlHttpReq.onreadystatechange=function()
		{
		  	if (self.xmlHttpReq.readyState == 4)
			{
				document.getElementById("visitor-count-span").innerHTML = addComma(self.xmlHttpReq.responseText);
			}
		}
		
		self.xmlHttpReq.open("GET","logs/index.txt",true);
		self.xmlHttpReq.send();
	}

function addComma(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function showVisitorCount()
{	
	refreshVisitorCount();
	setInterval("refreshVisitorCount()", 1000);	
}
