var xmlHttp=false;
Ajax = function () {
	//this.xmlHttp = false;
};
Ajax.prototype.createXmlHttp = function () {
	if(window.XMLHttpRequest){ //Mozilla
		xmlHttp=new XMLHttpRequest();
	}else if(window.ActiveXObject){
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){}
		}
	}
};
Ajax.prototype.post = function (url, fun) {
	this.createXmlHttp();
	
	
		xmlHttp.open("POST", url, true);
		var self = this;
	
		xmlHttp.onreadystatechange = showAll;
		
		xmlHttp.send(null);
	
	
};
Ajax.prototype.get = function (url, fun) {
	this.createXmlHttp();
	if (this.xmlHttp) {
		this.xmlHttp.open("POST", url, true);
		var self = this;
		this.xmlHttp.onreadystatechange = fun;
		this.xmlHttp.send();
	} else {
		alert("\xc4\xe3\xb5\xc4\xe4\xaf\xc0\xc0\xc6\xf7\xb0\xe6\xb1\xbe\xb9\xfd\xb5\xcd!");
	}
};
//show all counts
function showAll() {
	var d = document.getElementById("showAll");
	d.innerHTML = "";
	if (xmlHttp.readyState == 4) {
		
		if (xmlHttp.status == 200) {
			
			var doc = xmlHttp.responseXML;
		
			var bean = doc.getElementsByTagName("counts");
			if (bean.length != 0 && bean != null) {
				for (var i = 0; i < bean.length; i++) {
					var content = bean[i];
					//var day_counts = content.getElementsByTagName("day_counts")[0].firstChild.data;
					var week_counts = content.getElementsByTagName("week_counts")[0].firstChild.data;
					//d.innerHTML += "<span id=\"day_counts\">day_counts:"+day_counts+"</span>";
					d.innerHTML += week_counts;
				}
			}
		}
	} else {
		d.innerHTML = "<img src=\"img/loading.gif\"/>";
	}
}