function createXMLHttp(){ 
	var A=null; 
	try { 
		A=new ActiveXObject('Msxml2.XMLHTTP') 
	} catch(e) { 
		try{
			A=new ActiveXObject('Microsoft.XMLHTTP') 
		} catch(oc) { 
			A=null 
		} 
	} 
	if ( !A && typeof XMLHttpRequest != 'undefined' ) {
		 A=new XMLHttpRequest() 
	 } 
	return A 
}

function viewWin(P_str){
	switch (P_str) {
		case "alert":
			if (arguments[1]!="") alert(arguments[1]);
			break;
		case "status":
			if (arguments[1]!="") window.status=arguments[1];
			break;
		case "time":
			var d, s = "UPDATE: ";
			var Hours,Minutes,Seconds;
			var c = ":";
			d = new Date();
			//
			if (d.getHours().toString().length<2){
				Hours="0"+d.getHours();
			}else{
				Hours=d.getHours();
			}
			//
			if (d.getMinutes().toString().length<2){
				Minutes="0"+d.getMinutes();
			}else{
				Minutes=d.getMinutes();
			}
			//
			if (d.getSeconds().toString().length<2){
				Seconds="0"+d.getSeconds();
			}else{
				Seconds=d.getSeconds();
			}
			
			s += Hours + c;
			s += Minutes + c;
			s += Seconds + c;
			s += d.getMilliseconds();
			window.status=s;
			break;
		default :
			break; 
	}
}

function viewLost(P_str){
	switch (P_str) {
		case "alert":
		   alert(xmlhttp.responseText);
			break;
		case "status":
			if (arguments[1]!="") window.status=arguments[1];
			break;
		case "open":
			var strHTML=window.open();
			strHTML.document.write(xmlhttp.responseText);
			break;
		default :
			break; 
	}
} 

//返回本域的URL完整路径
function localURL(P_url){
	var F_url;
	//相对路径
	if (P_url.substring(0,1)!="/"){
		F_url=document.location.href
		var s = F_url.lastIndexOf('/')+1;
		var F_str=F_url.substring(0,s);
		return F_str+P_url;
	}else{
	//绝对路径
		F_url=document.location.host;
		return "http://"+F_url+P_url;
	}
}
var xmlhttp=createXMLHttp();

function GETURL(P_URL,P_method,P_POSTdata,P_async){
	G_debug=(typeof G_debug=="undefined")?false:G_debug;
	
	P_URL=localURL(P_URL);
	
	P_method=(typeof P_method=="undefined")?"POST":P_method;
	P_method=(P_method=="")?"POST":P_method;
	P_method=P_method.toUpperCase();

	P_POSTdata=(typeof P_POSTdata=="undefined")? null:P_POSTdata;
	P_POSTdata=(P_POSTdata=="")? null:P_POSTdata;

	P_async=(typeof P_async=="undefined")? false:P_async;
	P_async=(P_async=="")? false:P_async;

	xmlhttp.open(P_method,P_URL,P_async);
	if (P_method=="POST"){
		xmlhttp.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
	}
	xmlhttp.send(P_POSTdata);
	window.status="Requesting "+P_URL+"...";
	//viewWin("time");
	if (G_debug){
		var strHTML=window.open();
		strHTML.document.write("URL=="+P_URL+"<HR/>");
		strHTML.document.write("POST=="+P_POSTdata+"<HR/>");
		strHTML.document.write("Header=="+xmlhttp.getAllResponseHeaders()+"<HR/>");
		strHTML.document.write(xmlhttp.responseText);
	}
}

function GETobjURL(P_xmlhttp,P_URL,P_method,P_POSTdata,P_async){
	G_debug=(typeof G_debug=="undefined")?false:G_debug;
	
	if (typeof P_xmlhttp!="object"){
		window.status="P_xmlhttp Object is error...";
		if (G_debug){
			alert("P_xmlhttp of GETobjURL is no Object.");
		}
		return;
	}
	P_URL=localURL(P_URL);
	
	P_method=(typeof P_method=="undefined")?"POST":P_method;
	P_method=(P_method=="")?"POST":P_method;
	P_method=P_method.toUpperCase();

	P_POSTdata=(typeof P_POSTdata=="undefined")? null:P_POSTdata;
	P_POSTdata=(P_POSTdata=="")? null:P_POSTdata;

	P_async=(typeof P_async=="undefined")? false:P_async;
	P_async=(P_async=="")? false:P_async;

	P_xmlhttp.open(P_method,P_URL,P_async);
	if (P_method=="POST"){
		P_xmlhttp.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
	}
	P_xmlhttp.send(P_POSTdata);
	window.status="Requesting "+P_URL+"...";
	/**/
	if (G_debug){
		var strHTML=window.open();
		strHTML.document.write("URL=="+P_URL+"<HR/>");
		strHTML.document.write("POST=="+P_POSTdata+"<HR/>");
		strHTML.document.write("Header=="+P_xmlhttp.getAllResponseHeaders()+"<HR/>");
		strHTML.document.write(P_xmlhttp.responseText);
		strHTML.document.write("<HR/>");
		strHTML.document.write(P_xmlhttp.responseBody);
	}
	
}


/*
//Math.round(Math.random()*100)避开缓存
xmlhttp.open("GET",localURL("seekResult.asp?t="+Math.round(Math.random()*100)), false);
xmlhttp.send(null);

try{
xmlhttp.onreadystatechange=stateAction;
}catch(e){}

function stateAction(){
	if (xmlhttp.status==200 && xmlhttp.readyState==4 ){
		alert("win..");
	}else{
		alert("lost..");
	}
}
/////////////////////////////////////////////////
function delres(P_id,P_obj){
	var url=document.location.href
	var s = url.lastIndexOf('/')+1;
	var F_str=url.substring(0,s);
	url=F_str+'delannex.asp?id='+P_id;
	
	xmlhttp.open('POST',url, false);
	//POST方法必须指定头文件类型
	xmlhttp.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
	xmlhttp.send(null);
	if (xmlhttp.readyState==4 && xmlhttp.responseText==""){
		viewWin("status","Action win!");
	}else{
		viewLost("open");
	}
} 
*/
