function InitAjax(){
	var http_request = false;
	if(window.XMLHttpRequest){
		http_request = new XMLHttpRequest();
		if(http_request.overrideMimeType){
			http_request.overrideMimeType("text/xml");
		}
	}else if(window.ActiveXObject){
		try{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){}
		}
	}
	if(!http_request){
		window.alert("不能创建XMLHttpRequest对象实例.");
	}
	return http_request;
}

function GetAjax(url,width,height,afterFunction){
	var AjaxRequestObj = InitAjax();
	if (AjaxRequestObj)
	{
		AjaxRequestObj.onreadystatechange = function (){
			if(AjaxRequestObj.readyState == 4){
				if(AjaxRequestObj.status == 200){
					DialogShow(AjaxRequestObj.responseText,width,height,width,height,"#DDD");
					if(afterFunction != ""){
						eval(afterFunction);
					}
				}else{
					alert("您所请求的页面有异常。");
				}
			}
		}
		AjaxRequestObj.open("GET",url,true);
		AjaxRequestObj.send(null);
	}
}

function InformGetAjax(url,width,height){
	var AjaxRequestObj = InitAjax();
	if (AjaxRequestObj)
	{
		AjaxRequestObj.onreadystatechange = function (){
			if(AjaxRequestObj.readyState == 4){
				if(AjaxRequestObj.status == 200){
					if(AjaxRequestObj.responseText!=""){
						DialogWindow(AjaxRequestObj.responseText,0,0,width,height,"#FFFFFF");
					}
				}else{
					alert("您所请求的页面有异常。");
				}
			}
		}
		AjaxRequestObj.open("GET",url,true);
		AjaxRequestObj.send(null);
	}
}

function GetFillAjax(url,pageName,afterFunction){
	var AjaxRequestObj = InitAjax();
	if (AjaxRequestObj)
	{
		AjaxRequestObj.onreadystatechange = function (){
			if(AjaxRequestObj.readyState == 4){
				if(AjaxRequestObj.status == 200){
					fillPage(pageName,AjaxRequestObj.responseText);
					if(afterFunction != ""){
						eval(afterFunction);
					}
				}else{
					alert("您所请求的页面有异常。");
				}
			}
		}
		AjaxRequestObj.open("GET",url,true);
		AjaxRequestObj.send(null);
	}
}

function PostAjax(url,poststr,afterFunction,width,height){
	//alert(poststr);
	var AjaxRequestObj = InitAjax();
	if(AjaxRequestObj){
		AjaxRequestObj.onreadystatechange = function(){
			if(AjaxRequestObj.readyState == 4){
				if(AjaxRequestObj.status == 200){
					re = /<html>/i;
					if(AjaxRequestObj.responseText!=""){
						if(AjaxRequestObj.responseText.search(re)!=-1){
							DialogShow(AjaxRequestObj.responseText,width,height,width,height,"#FFFFFF");
						}else{
							DialogShow(AjaxRequestObj.responseText,400,50,400,50,"#FFFFFF");
						}
					}
					if(afterFunction != ""){
						eval(afterFunction);
					}
				}else{
					alert("您所请求的页面有异常。");
				}
			}
		}
		AjaxRequestObj.open("POST",url,true);
		AjaxRequestObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		//alert(poststr);
		AjaxRequestObj.send(poststr);
		
	}
}

function PostFillAjax(url,poststr,pageName,afterFunction){
	var AjaxRequestObj = InitAjax();
	if(AjaxRequestObj){
		AjaxRequestObj.onreadystatechange = function(){
			if(AjaxRequestObj.readyState == 4){
				if(AjaxRequestObj.status == 200){
					fillPage(pageName,AjaxRequestObj.responseText);
					if(afterFunction != ""){
						eval(afterFunction);
					}
				}else{
					alert("您所请求的页面有异常。");
				}
			}
		}
		AjaxRequestObj.open("POST",url,true);
		AjaxRequestObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		AjaxRequestObj.send(poststr);
	}
}

function DialogShow(showdata,ow,oh,w,h,bg)
{
	var objDialog = document.getElementById("DialogMove");
	if (!objDialog) objDialog = document.createElement("div");
	t_DiglogW = ow;
	t_DiglogH = oh;
	DialogLocation();
	objDialog.id = "DialogMove";
	objDialog.style.display = "block";
	objDialog.style.top = t_DiglogY + "px";
	objDialog.style.left = t_DiglogX + "px";
	objDialog.style.margin = "0px";
	objDialog.style.padding = "1px";
	objDialog.style.width = w + "px";
	objDialog.style.height = h + "px";
	//objDialog.style.lineHeight = h + "px";
	objDialog.style.position = "absolute";
	objDialog.style.zIndex = "5";
	objDialog.align = "center";
	objDialog.style.background = bg;
	objDialog.style.border = "solid #369 1px";
	objDialog.innerHTML = showdata;
	//objDialog.style.overflow= "auto";
	document.body.appendChild(objDialog);
}

function DialogWindow(showdata,ow,oh,w,h,bg)
{
	var objDialog = document.getElementById("DialogMove");
	if (!objDialog) objDialog = document.createElement("div");
	t_DiglogW = ow;
	t_DiglogH = oh;
	objDialog.id = "DialogMove";
	objDialog.style.display = "block";
	objDialog.style.top = oh + "px";
	objDialog.style.right = ow + "px";
	objDialog.style.margin = "0px";
	objDialog.style.padding = "0px";
	objDialog.style.width = w + "px";
	objDialog.style.height = h + "px";
	objDialog.style.position = "absolute";
	objDialog.style.zIndex = "5";
	objDialog.align = "center";
	objDialog.style.background = bg;
	objDialog.style.border = "solid #000 1px";
	objDialog.innerHTML = showdata;
	document.body.appendChild(objDialog);
}

function DialogHide()
{
	var objDialog = document.getElementById("DialogMove");
	if (objDialog) objDialog.style.display = "none";
}

/*
 * 描述：跨浏览器的设置 innerHTML 方法缺点：脚本中不能有document.write;
 *       允许插入的 HTML 代码中包含 script 和 style
 * 作者：kenxu <kenxu at ajaxwing dot com>
 * 日期：2006-03-23
 * 参数：
 *    el: 合法的 DOM 树中的节点
 *    htmlCode: 合法的 HTML 代码
 * 经测试的浏览器：ie5+, firefox1.5+, opera8.5+
 */
var setInnerHTML = function (el, htmlCode) {
    var ua = navigator.userAgent.toLowerCase();
    if (ua.indexOf('msie') >= 0 && ua.indexOf('opera') < 0) {
        htmlCode = '<div style="display:none">for IE</div>' + htmlCode;
        htmlCode = htmlCode.replace(/<script([^>]*)>/gi,
                                    '<script$1 defer>');
		el.innerHTML = '';
        el.innerHTML = htmlCode;
        el.removeChild(el.firstChild);
    } else {
        var el_next = el.nextSibling;
        var el_parent = el.parentNode;
        el_parent.removeChild(el);
        el.innerHTML = htmlCode;
        if (el_next) {
            el_parent.insertBefore(el, el_next)
        } else {
            el_parent.appendChild(el);
        }
    }
}

function fillPage(pageName,fillData){		
	//document.all(pageName).innerHTML = fillData;
	//document.getElementById(pageName).innerHTML = fillData;
	setInnerHTML(document.getElementById(pageName),fillData);
}

function ScreenConvert()
{
	var browser = new Browser();
	var objScreen = document.getElementById("ScreenOver");
	if (!objScreen) var objScreen = document.createElement("div");
	objScreen.id = "ScreenOver";
	objScreen.style.display = "block";
	objScreen.style.top = objScreen.style.left = objScreen.style.margin = objScreen.style.padding = "0px";
	if (document.body.clientHeight)
	{
		var wh = document.body.clientHeight + "px";
		var ww = document.body.clientWidth + "px";
	}
	else if (window.innerHeight)
	{
		var wh = window.innerHeight + "px";
		var ww = window.innerWidth + "px";
	}
	else
	{
		var wh = "100%";
		var ww = "100%";
	}
    if(document.body.clientHeight < window.screen.height ) var wh=window.screen.height + "px";
	if(document.body.clientHeight < window.innerHeight) var wh=document.body.clientHeight+window.innerHeight + "px";
	objScreen.style.width = ww;
	objScreen.style.height = wh;
	objScreen.style.position = "absolute";
	objScreen.style.zIndex = "3";
	if ((!browser.isSF) && (!browser.isOP))
	{
		objScreen.style.background = "#181818";	
	}
	else
	{
		objScreen.style.background = "#F0F0F0";
	}
	objScreen.style.filter = "alpha(opacity=40)";
	objScreen.style.opacity = 40/100;
	objScreen.style.MozOpacity = 40/100;
	document.body.appendChild(objScreen);
	var allselect = gname("select");
	for (var i=0; i<allselect.length; i++) allselect[i].style.visibility = "hidden";
}

function ScreenClean()
{
	var objScreen = document.getElementById("ScreenOver");
	if (objScreen) objScreen.style.display = "none";
	var allselect = gname("select");
	for (var i=0; i<allselect.length; i++) allselect[i].style.visibility = "visible";
}