/****************************************************************
* File name : ajax.php
* Title : 用户调用Ajax
* author : 杨伟明
* Created on 2009-11-24
***************************************************************/
//XMLHttpRequest 
	function getOs() {
		var OsObject = "";
		if (navigator.userAgent.indexOf("Firefox") > 0) {
			return "Firefox";
		}
		if (navigator.userAgent.indexOf("MSIE") > 0) {
			return "MSIE";
		}
		return OsObject;
	}
	function getBrowersType() {
		var OsObject = "";
		if (navigator.userAgent.indexOf("Firefox") > 0) {
			return "Firefox";
		}
		if (navigator.userAgent.indexOf("MSIE") > 0) {
			return "MSIE";
		}
		return OsObject;
	}
	function FirefoxXMLHttpRequest(){
		var xmlhttp = false;
		xmlhttp = new XMLHttpRequest();
		return xmlhttp;
	}
	function IEXMLHttpRequest(){
		var xmlhttp = false;
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e1) {
				try {
					xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.4.0");
				} catch (e2) {
					xmlhttp = false;
				}
			}
		}
		if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
			xmlhttp = new XMLHttpRequest();
		}
		return xmlhttp;
	}
	function GetXMLHttpRequest(){
		if (getBrowersType() == "Firefox") {
			return FirefoxXMLHttpRequest();
		}else{
			return IEXMLHttpRequest();
		}
	}
	//alert(xmlhttp);
	
	// 用法，Ajax(url, tag)
	// url是调用的地址加参数，例如ck.php?op=1
	// tag是结果的显示目的，处理的结果返回到tag变量里面
	function Ajax(url, tag, fun){
		xmlhttp=GetXMLHttpRequest();
	    document.getElementById(tag).innerHTML = "正在处理数据......";//显示状态
		xmlhttp.onreadystatechange=function(){
			if (4==xmlhttp.readyState){
				if (200==xmlhttp.status){
					if (fun != null){
						fun(xmlhttp.responseText);
					}else{
						document.getElementById(tag).innerHTML = xmlhttp.responseText;
					}
				}
			}
		}
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	}

