var Request = new Object();
Request.send = function(url, method, callback, data) {
	var req;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	req.onreadystatechange = function() {
		if (req.readyState == 4) {
			if (req.status < 400) {
				(method=="POST") ? callback(req) : callback(req,data);
			}
		}
	}

	if (method=="POST") {
		req.open("POST", url, true);
		req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		req.send(data);
	} else {		
		req.open("GET", url, true);
		req.send(null);
	}
	return req;
}

Request.sendPOST = function(url, data, callback) {
	Request.send(url, "POST", callback, data);
}
Request.sendGET = function(url, callback, args) {	
	return Request.send(url, "GET", callback, args);
}
function webinitcallcack(response,data){
	document.getElementById('pet_get'+data).innerHTML = response.responseText;
}
function initallform(){
	Request.sendGET("pet_get1.php?nocache="+Math.random(), webinitcallcack,'1');
	Request.sendGET("pet_get2.php?nocache="+Math.random(), webinitcallcack,'2');
	Request.sendGET("pet_get3.php?nocache="+Math.random(), webinitcallcack,'3');
	Request.sendGET("pet_get4.php?nocache="+Math.random(), webinitcallcack,'4');
}
function pk1calback(response,data){
	if(response.responseText.length>0)
	{	try{
			eval(response.responseText);
		}
		catch(e){}
	}
}
function pk1(theEle){
	var data = document.getElementById('pktu');
	if(data.value.length==0) {
		alert('请输入你要挑战的玩家的名字。');
		return;
	}
	data = 'pktu='+data.value;
	Request.sendGET("pet_get5.php?nocache="+Math.random()+'&'+data, pk1calback,'5');
}
function onliedata(){
	Request.sendGET("pet_get6.php?nocache="+Math.random(), pk1calback,'6');
}
function openpk(opt){
	Request.sendGET("pet_get6.php?nocache="+Math.random()+"&data="+opt, pk1calback,'6');
}
function mediconlie(){
	Request.sendGET("pet_get3.php?nocache="+Math.random(), webinitcallcack,'3');
}

initallform();
setInterval(onliedata, Math.round(15*1000*Math.random()));
onliedata();
setInterval('Request.sendGET("pet_get4.php?nocache="+Math.random(), webinitcallcack,"4");', Math.round(60*1000*Math.random()));

