﻿/*
 (1)
 * 显示ToolTip 样式名:ToolTipOuter(边框背景)和ToolTip(定位position:absolute;)
 * @param {Object} msg 要显示的消息
 * @param {Object} e 即调用的控件this
 function ToolTip(msg,e)
 (2)
 * 弹出窗口(屏幕中央) 样式:ThickBox为box样式,title为标题框样式,ThickBoxContent为内容样式
 * @param {Object} msg 显示的内容
 * @param {Object} isConver 是否屏蔽背景
 * @param {Object} isWindwoMode 是否为窗口模式(带半闭按钮)
 function ThickBox(msg,isConver,isWindwoMode,msgTitle)
 下面三个参数手动设置
 //正在执行的提示图片
 var Bzh_ThickBox_LoadingImg;
 //覆盖背景的颜色
 var Bzh_ConvertBody_BackgroundColor;
 //关闭按钮链接
 var Bzh_ThickBox_CloseBtnImg;
 (3)Post编码
 function parameStr(value)
 (4)
 * 获得网址参数
 * @param {Object} name
 function getParameter(name)
 */
var WebSitePath = "http://www.eic.org.cn:8080";//站路径
//正在执行的提示图片
var Bzh_ThickBox_LoadingImg = WebSitePath + "/webimg/loading3.gif";
//覆盖背景的颜色
var Bzh_ConvertBody_BackgroundColor = "#252d35";
//关闭按钮链接
var Bzh_ThickBox_CloseBtnImg = WebSitePath + "/webimg/close.gif";

/*分页图片*/
var PagePreImg = WebSitePath + "/webimg/page/pre.gif";
var PageNextImg = WebSitePath + "/webimg/page/next.gif";
var PageFirstImg = WebSitePath + "/webimg/page/first.gif";
var PageLastImg = WebSitePath + "/webimg/page/last.gif";



/*下面判断网页的DocType*/
var HTMLDocType = "HTML";
if (document.documentElement.clientHeight > 0) {
    HTMLDocType = "XHTML"
}


/*****************************ToopLip****************************************/
/**
 * 显示ToolTip 样式名:ToolTipOuter(边框背景)和ToolTip(定位position:absolute;)
 * @param {Object} msg 要显示的消息
 */
function ToolTip(msg, e){
    var t = new ToolTipClass();
    t.initMouseMove(msg);
    e.onmouseout = ToolTipClost;
}

/**
 * 关闭ToolTip
 */
function ToolTipClost(){
    var t = new ToolTipClass();
    t.initMouseOut();
}

function ToolTipClass(){

    if (_this != null) {
        _this = null;
    }
    var _this = this;
    this.msg_;
    
    this.initMouseMove = function(msg){
        _this.msg_ = msg;
        document.onmousemove = _this.mouseMove;
    }
    this.initMouseOut = function(){
        this.objects = new Array();
        document.onmousemove = null;
        DeleteToolTipDiv();
    }
    
    this.mouseMove = function(evt){
        var tmpScroolLeft = 0;
        var tmpScroolTop = 0;
        if (HTMLDocType == "XHTML") {
            tmpScroolLeft = document.documentElement.scrollLeft;
            tmpScroolTop = document.documentElement.scrollTop;
        }
        else {
            tmpScroolLeft = document.body.scrollLeft;
            tmpScroolTop = document.body.scrollTop;
        }
        
        var x, y;
        if (!document.all) {
            evt = evt || window.event;
            x = tmpScroolLeft + evt.clientX;
            y = tmpScroolTop + evt.clientY;
        }
        else {
            x = tmpScroolLeft + event.clientX;
            y = tmpScroolTop + event.clientY;
        }
        CreateToolTipDiv(_this.msg_);
        var divE = $get("Bzh_ToolTipDiv");
        divE.style.top = parseInt(y) + "px";
        divE.style.left = (parseInt(x) + 20) + "px";
        
    }
    this.objects = new Array();
}

/**
 * 构造ToolTip控件并显示
 * @param {Object} msg 显示的消息
 * @param {Object} x left坐标值
 * @param {Object} y top坐标值
 */
function CreateToolTipDiv(msg){
    if (!document.getElementById("Bzh_ToolTipDiv")) {
        //插入一个前置层
        var msg2 = "";
        msg2 = "<div class='ToolTipOuter'>";
        msg2 += msg;
        msg2 += "</div>";
        var ToolTipElement = document.createElement("div");
        ToolTipElement.id = "Bzh_ToolTipDiv";//为了不重复，起个特别的名字
        ToolTipElement.innerHTML = msg2;
        ToolTipElement.style.position = "absolute";
        ToolTipElement.className = "ToolTip";
        //ToolTipElement.style.zIndex = 999;
        document.body.appendChild(ToolTipElement);
        //加载覆盖层
        var msgE = $get("Bzh_ToolTipDiv");
        var newFrame = document.createElement("iframe");
        newFrame.id = "Bzh_ToolTipConver";
        newFrame.name = "Bzh_ToolTipConver";
        newFrame.src = "about:blank";
        newFrame.style.position = "absolute";
        newFrame.border = 0;
        newFrame.frameBorder = 0;
        newFrame.scrolling = "no";
        newFrame.style.width = (msgE.offsetWidth - 2) + "px";
        newFrame.style.height = (msgE.offsetHeight - 2) + "px";
        
        newFrame.cellSpacing = 1;
        newFrame.cellPadding = 1;
        newFrame.style.backgroundColor = "#fff";
        newFrame.style.top = 0;
        newFrame.style.left = 0;
        newFrame.style.zIndex = -1;
        msgE.appendChild(newFrame);
    }
}

/**
 * 删除ToolTip控件
 */
function DeleteToolTipDiv(){
    try {
        if (document.getElementById("Bzh_ToolTipDiv")) {
            document.body.removeChild(document.getElementById("Bzh_ToolTipDiv"));
        }
    } 
    catch (Error_) {
        alert(Error_)
    }
}

/***************************ThickBox*****************************************/
/**
 * 弹出窗口(屏幕中央) 样式:ThickBox为box样式,title为标题框样式,ThickBoxContent为内容样式
 * @param {Object} msg 显示的内容
 * @param {Object} isConver 是否屏蔽背景
 * @param {Object} isWindwoMode 是否为窗口模式(带半闭按钮)
 */
var IsThickBoxShow = false;
function ThickBox(msg, isConver, isWindwoMode, msgTitle){
	IsThickBoxShow = true;
	try {
        if (document.getElementById("Bzh_ThickBoxDiv")) {
            document.body.removeChild(document.getElementById("Bzh_ThickBoxDiv"));
        }
    } 
    catch (Error_) {
        alert(Error_)
    }
    try {
        if (document.getElementById("Bzh_ThickBoxConverBody")) {
            document.body.removeChild(document.getElementById("Bzh_ThickBoxConverBody"));
        }
    } 
    catch (Error_) {
        alert(Error_)
    }
    //覆盖整页
    if (isConver == true) {
        ConverBody();
    }
    
    var tmpScroolLeft = 0;
    var tmpScroolTop = 0;
    
    /*判断doctype*/
    //alert(document.all[0].nodeValue);
    
    
    if (HTMLDocType == "XHTML") {
        tmpScroolLeft = document.documentElement.scrollLeft;
        tmpScroolTop = document.documentElement.scrollTop;
    }
    else {
        tmpScroolLeft = document.body.scrollLeft;
        tmpScroolTop = document.body.scrollTop;
    }
    
    var top_ = 0;
    var left_ = 0;
    
    if (HTMLDocType == "XHTML") {
        top_ = tmpScroolTop + (document.documentElement.clientHeight / 2);
        left_ = tmpScroolLeft + (document.documentElement.clientWidth / 2);
    }
    else {
        top_ = tmpScroolTop + ((document.body.clientHeight) / 2);
        left_ = tmpScroolLeft + ((document.body.clientWidth) / 2);
    }
    
    top_ = parseInt(top_);
    
    
    CreateThickBoxDiv(msg, isConver, isWindwoMode, msgTitle);
    var msgE = $get("Bzh_ThickBoxDiv");
    
    top_ = top_ - (msgE.offsetHeight / 2);
    left_ = left_ - (msgE.offsetWidth / 2);
    msgE.style.top = top_ + "px";
    msgE.style.left = left_ + "px";
    
    //加载覆盖层
    var newFrame = document.createElement("iframe");
    newFrame.id = "Bzh_ThickBoxConver";
    newFrame.name = "Bzh_ThickBoxConver";
    newFrame.src = "about:blank";
    newFrame.style.position = "absolute";
    newFrame.border = 0;
    newFrame.frameBorder = 0;
    newFrame.scrolling = "no";
    if (document.all) {
        newFrame.style.width = (msgE.offsetWidth - 2) + "px";
        newFrame.style.height = (msgE.offsetHeight - 2) + "px";
        newFrame.style.top = "0px";
        newFrame.style.left = "0px";
    }
    else {
        newFrame.style.width = msgE.offsetWidth + "px";
        newFrame.style.height = msgE.offsetHeight + "px";
        newFrame.style.top = "0px";
        newFrame.style.left = "0px";
    }
    newFrame.cellSpacing = 1;
    newFrame.cellPadding = 1;
    newFrame.style.backgroundColor = "#f1f1f1";
    newFrame.style.zIndex = -1;
    msgE.appendChild(newFrame);
}

/**
 * 覆盖页面
 */
function ConverBody(){
    var height_ = 0;
    var width_ = 0;
    if (HTMLDocType == "XHTML") {
        height_ = document.body.clientHeight;
        width_ = document.body.clientWidth;
    }
    else {
        height_ = document.body.scrollHeight;
        width_ = document.body.scrollWidth;
    }
    //$get("text2").value = "body height:" +  document.body.scrollHeight + "\nsco top:" +  tmpScroolTop;
    
    var newFrame = document.createElement("iframe");
    newFrame.id = "Bzh_ThickBoxConverBody";
    newFrame.name = "Bzh_ThickBoxConverBody";
    newFrame.src = "about:blank";
    newFrame.style.position = "absolute";
    newFrame.border = 0;
    newFrame.frameBorder = 0;
    newFrame.scrolling = "no";
    newFrame.style.width = (width_ + 1) + "px";
    newFrame.style.height = (height_ + 1) + "px";
    newFrame.cellSpacing = 1;
    newFrame.cellPadding = 1;
    newFrame.style.backgroundColor = Bzh_ConvertBody_BackgroundColor;
    newFrame.style.top = "-1px";
    newFrame.style.left = "-1px";
    newFrame.style.filter = "Alpha(Opacity=65)";
    newFrame.style.MozOpacity = 0.65;
    newFrame.style.zIndex = 11111110;
    document.body.appendChild(newFrame);
    $get("Bzh_ThickBoxConverBody").contentWindow.document.write("<style type='text/css'>body{margin:0}</style><div style='width:100%;height:" + (height_ + 1).toString() + ";background-color:" + Bzh_ConvertBody_BackgroundColor + ";'>&nbsp;</div>");
}

function UnThickBox(){
    DeleteThickBoxDiv();
}

/**
 * 构造ThickBox控件并显示
 * @param {Object} msg 显示的消息
 * @param {Object} x left坐标值
 * @param {Object} y top坐标值
 */
function CreateThickBoxDiv(msg, isConver, isWindwoMode, msgTitle){
    if (!document.getElementById("Bzh_ThickBoxDiv")) {
        //插入一个前置层
        var msg2 = "";
        msg2 = "<div class='ThickBox'>";
        if (isWindwoMode == true) {
            msg = GetThickBoxOuterMsg(msg, msgTitle);
        }
        else {
            //提示层,多用于Ajax的操作提示
            msg = "<table cellpadding='3' cellspacing='0'><tr><td><img src='" + Bzh_ThickBox_LoadingImg + "' /></td><td>" + msg + "</td></tr></table>";
        }
        msg2 += msg;
        msg2 += "</div>";
        var ToolTipElement = document.createElement("div");
        ToolTipElement.id = "Bzh_ThickBoxDiv";//为了不重复，起个特别的名字
        ToolTipElement.innerHTML = msg2;
        ToolTipElement.style.position = "absolute";
        //ToolTipElement.className = "ThickBox";
        ToolTipElement.style.zIndex = 11111111;
		ToolTipElement.style.filter = "alpha(opacity=100)";
		ToolTipElement.style.MozOpacity = "1";
        document.body.appendChild(ToolTipElement);
        //设置标题的宽度
        if (document.getElementById("Bzh_ThickBoxTitle")) {
            $get("Bzh_ThickBoxTitle").style.width = ($get("Bzh_ThickBoxDiv").offsetWidth - 5) + "px";
        }
    }
}

/**
 * 删除ThickBox控件
 */
function DeleteThickBoxDiv(){
    try {
        if (document.getElementById("Bzh_ThickBoxConverBody")) {
            document.body.removeChild(document.getElementById("Bzh_ThickBoxConverBody"));
        }
    } 
    catch (Error_) {
        alert(Error_)
    }
	IsThickBoxShow = false;
	HideDiv("Bzh_ThickBoxDiv",true);
}

/*下面是公有渐进删除层的方法*/
function HideDiv(divID,isDel){
	if (IsThickBoxShow==true)
		return;
	if (document.getElementById(divID)==null)
		return;
	var img = $get(divID);
	var step = 30;
	if (document.all)
		step = 20;
	if (window.navigator.userAgent.indexOf("Firefox")==-1) {
		var ieValue = parseInt(img.style.filter.substring(img.style.filter.toLowerCase().indexOf("opacity=") + 8));
		if (ieValue > 10) {
			img.style.filter = "Alpha(Opacity=" + (ieValue - 10).toString() + ")";
			window.setTimeout("HideDiv('"+ divID +"'," + isDel + ")", step);
		}
		else {
			DelDiv(divID,isDel);
		}
	}
	else {
		var moValue = parseFloat(img.style.MozOpacity);
		if (moValue > 0.1) {
			img.style.MozOpacity = (moValue - 0.1).toString();
			window.setTimeout("HideDiv('"+ divID +"'," + isDel + ")", step);
		}
		else {
			DelDiv(divID,isDel);
		}
	}
}
function DelDiv(divID,isDel){
	if (isDel == true) {
		try {
			if (document.getElementById(divID)) {
				document.body.removeChild(document.getElementById(divID));
			}
		} 
		catch (Error_) {
			alert(Error_)
		}
	}
	else
	$get(divID).style.display = "disabled";
}
function ShowDiv(divID){
	var e = $get(divID);
	e.style.filter = "alpha(opacity=100)";
	e.style.MozOpacity = "1";
	e.style.display = "";
}

/**
 * 获取提示框(窗口式)内容
 * @param {Object} msg
 */
function GetThickBoxOuterMsg(msg, msgTitle){
    if (msgTitle == "" || msgTitle == undefined) {
        msgTitle = "&nbsp;";
    }
    var h = "";
    h += "<div class='title' id='ThickBoxTitle' onMousedown='Bzh_StartDrag(this,event)' onMouseup='Bzh_StopDrag(this,event)' onMousemove='Bzh_Drag(this,event)'><table id='Bzh_ThickBoxTitle'><tr><td>" + msgTitle + "</td><td style='text-align:right;'>";
    h += "<a href='#' onclick='DeleteThickBoxDiv();return false;'><img src='" + Bzh_ThickBox_CloseBtnImg + "' alt='Close' border='0' /></a>";
    h += "</td></tr></table></div>";
    h += "<div class='ThickBoxContent'>" + msg + "</div>";
    return h;
}

var BzhIsMove = false;
var BzhMoveDivX_ = 0;
var BzhMoveDivY_ = 0;
function Bzh_StartDrag(obj, evt){
    var tmpScroolLeft = 0;
    var tmpScroolTop = 0;
    if (HTMLDocType == "XHTML") {
        tmpScroolLeft = document.documentElement.scrollLeft;
        tmpScroolTop = document.documentElement.scrollTop;
    }
    else {
        tmpScroolLeft = document.body.scrollLeft;
        tmpScroolTop = document.body.scrollTop;
    }
    if (evt.button == 1 || evt.button == 0) {
        obj.style.cursor = "move";
        
        BzhMoveDivX_ = evt.clientX - (obj.parentNode.parentNode.offsetLeft - tmpScroolLeft);
        BzhMoveDivY_ = evt.clientY - (obj.parentNode.parentNode.offsetTop - tmpScroolTop);
        
        if (document.all) 
            obj.setCapture();
        
        //obj.style.background = "#999";
        BzhIsMove = true;
    }
}

function Bzh_Drag(obj, evt){
    if (BzhIsMove) {
    
        var oldwin = obj.parentNode.parentNode;
        
        var tmpScroolLeft = 0;
        var tmpScroolTop = 0;
        if (HTMLDocType == "XHTML") {
            tmpScroolLeft = document.documentElement.scrollLeft;
            tmpScroolTop = document.documentElement.scrollTop;
        }
        else {
            tmpScroolLeft = document.body.scrollLeft;
            tmpScroolTop = document.body.scrollTop;
        }
        
        var x, y;
        if (!document.all) {
            evt = evt || window.event;
            x = tmpScroolLeft + evt.clientX;
            y = tmpScroolTop + evt.clientY;
        }
        else {
            x = tmpScroolLeft + event.clientX;
            y = tmpScroolTop + event.clientY;
        }
        
        oldwin.style.top = (y - BzhMoveDivY_) + "px";
        oldwin.style.left = (x - BzhMoveDivX_) + "px";
        //$get("text2").value = "top:" + BzhMoveDivY_ + "\nleft:" + BzhMoveDivX_ + "\nMouseTop:" + evt.clientY 
        //+ "\nDivTop:" + oldwin.offsetTop + "\nparentNode:" + oldwin.id + "\neHeight:" + obj.offsetHeight;
    }
}

function Bzh_StopDrag(obj){
    //obj.style.background = "#cccccc";
    if (document.all) 
        obj.releaseCapture();
    BzhIsMove = false;
}

/*****************CallBack脚本******************************/
/**
 * 客户回调程序，需要xmlhttp支持
 * 闭至海
 * @param {Object} url post的地址
 * @param {Object} postValue 参数值，以post形式描述(假如为带特殊字符的符串则用parameStr(value)获取编码后的值，服务器端要进行解码)
 * @param {Object} resultFunction 处理完成后返回的外理函数
 * @param {Object} failedCallback 出错时的函数
 * @return 直接返回Array,值只支持五种类型：string,integer,boolean,float,datetime
 */
function CallBack(url,parames,succeedFunction,Failfunction){
	var loadValue = "?";
	for (var i=0;i<parames.length;i++){
		loadValue += "&" + parames[i]["name"] + "=" + parameStr(parames[i]["value"]);
	}
	var callback_ ;
	if (Failfunction)
		callback_ = new CallBackXMLArray(url, loadValue, succeedFunction,Failfunction);
	else
		callback_ = new CallBackXMLArray(url, loadValue, succeedFunction);
	callback_.getCallBack();
}
function CallBackXMLArray(url, postValue, succeededCallback, failedCallback){
    if (_this != null) {
        _this = null;
    }
    var _this = this;
    
    this.url = url;
    this.postValue = postValue;
    this.succeededCallback = succeededCallback;
    this.failedCallback = failedCallback;
    this._xmlHttpRequest = null;
    this._xmlHttpRequest = getXMLHttpRequest_();
    
    this.getCallBack = function(){
        //deal url and post	
        //alert(_this.url + "?" + _this.postValue);
        _this._xmlHttpRequest.open("POST", _this.url, true);
        _this._xmlHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
        _this._xmlHttpRequest.onreadystatechange = _this.returnXmlResult;
        try {
            _this._xmlHttpRequest.send(_this.postValue);
        } 
        catch (e) {
            alert("执行参数或网址出错！");
            _this.failedCallback();
        }
    }
    this.returnXmlResult = function(){
        if (_this._xmlHttpRequest.readyState === 4) {
            if (_this._xmlHttpRequest.status === 200) {
                //alert(_this._xmlHttpRequest.responseXML.xml);
                /*新的回调*/
                var xml;
                try {
                    xml = _this._xmlHttpRequest.responseXML;
                    if (!xml || !xml.documentElement) {
                    
                        xml = new XMLDOM(_this._xmlHttpRequest.responseText);
                        
                        if (!xml || !xml.documentElement) 
                            _this.succeededCallback(null);
                    }
                    else 
                        if (navigator.userAgent.indexOf('MSIE') !== -1) {
                            xml.setProperty('SelectionLanguage', 'XPath');
                        }
                    
                    if (xml.documentElement.namespaceURI === "http://www.mozilla.org/newlayout/xml/parsererror.xml" &&
                    xml.documentElement.tagName === "parsererror") {
                        _this.succeededCallback(null);
                    }
                    
                    if (xml.documentElement.firstChild && xml.documentElement.firstChild.tagName === "parsererror") {
                        _this.succeededCallback(null);
                    }
                } 
                catch (eeee__) {
                    alert("错误的XML格式。");
                }
                var result;
                if (xml) {
                    result = Foreach_(xml);
                }
                _this.succeededCallback(result);
                /*新的回调end*/
            }
            else 
                if (_this._xmlHttpRequest.status === 404) {
                    alert("非法的服务器请求，HTTP 错误 404 没有找到网络路径。");
                    if (_this.failedCallback()) 
                        _this.failedCallback();
                }
                else 
                    if (_this._xmlHttpRequest.status === 403) {
                        alert("非法的服务器请求，HTTP 错误 403 - 禁止访问。");
                        if (_this.failedCallback()) 
                            _this.failedCallback();
                    }
                    else {
                        alert("服务器请求错误，HTTP 状态 " + _this._xmlHttpRequest.status + " \n" + _this._xmlHttpRequest.statusText);
                        if (_this.failedCallback()) 
                            _this.failedCallback();
                    }
        }
    }
}

function getXMLHttpRequest_(){
    var xmlHttpRequest_ = null;
    if (window.ActiveXObject) {
        try {
            xmlHttpRequest_ = new ActiveXObject('Msxml2.XMLHTTP');
        } 
        catch (e) {
            try {
                xmlHttpRequest_ = new ActiveXObject('Microsoft.XMLHTTP');
            } 
            catch (ee) {
                alert("您的浏览器不支持XMLHTTP服务器访问，请安装Internet Explorer6.0以上版本。\n您可以访问微软公司的网站下载此支持软件");
                throw ee;
            }
            throw e;
        }
    }
    else 
        if (window.XMLHttpRequest) {
            try {
                xmlHttpRequest_ = new XMLHttpRequest();
            } 
            catch (e) {
                alert("您的浏览器不支持XMLHTTP服务器访问，请安装Internet Explorer6.0以上版本。\n您可以访问微软公司的网站下载此支持软件");
                throw e;
            }
        }
    return xmlHttpRequest_;
}

/**
 * 分析XMLHTTP返回的.responseXML，并把结果存入Array里
 * 从根节点历遍xml
 */
function Foreach_(dom){
    var root = dom.getElementsByTagName('items').item(0);//根目录
    if (!root) {
        if (document.all) {
            root = dom.childNodes[1];//IE
        }
        else {
            root = dom.childNodes[0];//Firfox
        }
    }
    var value;
	if (root.childNodes.length == 1 && root.getAttribute("type")!=null) {
		//只有一个值时,只支持五种类型：string,integer,boolean,float,datetime
		var thisType = "";
		var tmpValue;
		try {
			thisType = root.getAttribute("type");
			tmpValue = root.childNodes[0].nodeValue;
		} 
		catch (Ex) {
			//假如取不到的处理
		}
		if (thisType == "string") {
			value = tmpValue;
		}
		else 
			if (thisType == "boolean") {
				if (tmpValue.toLowerCase() == "true") {
					value = true;
				}
				else {
					value = false;
				}
			}
			else 
				if (thisType == "integer") {
					tmpValue = parseInt(tmpValue);
					if (isNaN(tmpValue)) {
						value = 0;
					}
					else {
						value = tmpValue;
					}
				}
				else 
					if (thisType == "float") {
						tmpValue = parseFloat(tmpValue);
						if (isNaN(tmpValue)) {
							value = 0;
						}
						else {
							value = tmpValue;
						}
					}
					else 
						if (thisType == "datetime") {
							var dateValue = new Date(tmpValue);
							value = dateValue;
						}
	}
	else {
		value = GetValueFromNode(root);
	}
    return value;
}

function GetValueFromNode(node){
    var ValueFromXmlArray = new Array();
    for (var i = 0; i < node.childNodes.length; i++) {
        if (node.childNodes[i].childNodes.length == 1) {
			//只有一个值时,只支持五种类型：string,integer,boolean,float,datetime
			var thisType = "";
			var tmpValue;
			try {
				thisType = node.childNodes[i].getAttribute("type");
				tmpValue = node.childNodes[i].lastChild.nodeValue;
			} 
			catch (Ex) {
			//假如取不到的处理
			
			}
			if (thisType == "string") {
				ValueFromXmlArray[ValueFromXmlArray.length] = tmpValue;
			}
			else 
				if (thisType == "boolean") {
					if (tmpValue.toLowerCase() == "true") {
						ValueFromXmlArray[ValueFromXmlArray.length] = true;
					}
					else {
						ValueFromXmlArray[ValueFromXmlArray.length] = false;
					}
				}
				else 
					if (thisType == "integer") {
						tmpValue = parseInt(tmpValue);
						if (isNaN(tmpValue)) {
							ValueFromXmlArray[ValueFromXmlArray.length] = 0;
						}
						else {
							ValueFromXmlArray[ValueFromXmlArray.length] = tmpValue;
						}
					}
					else 
						if (thisType == "float") {
							tmpValue = parseFloat(tmpValue);
							if (isNaN(tmpValue)) {
								ValueFromXmlArray[ValueFromXmlArray.length] = 0;
							}
							else {
								ValueFromXmlArray[ValueFromXmlArray.length] = tmpValue;
							}
						}
						else 
							if (thisType == "datetime") {
								var dateValue = new Date(tmpValue);
								ValueFromXmlArray[ValueFromXmlArray.length] = dateValue;
							}
							else {
								//ValueFromXmlArray[ValueFromXmlArray.length] = tmpValue;
								//还有子节点
								ValueFromXmlArray[ValueFromXmlArray.length] = GetValueFromNode(node.childNodes[i]);
							}
		}
		else {
			ValueFromXmlArray[ValueFromXmlArray.length] = GetValueFromNode(node.childNodes[i]);
		}
    }
    return ValueFromXmlArray;
}

/**
 * 把数据绑定到表格
 * @param {Object} table 表格
 * @param {Object} Items 数据集
 */
function TableBindding(table, Items, MouseOverClass){
    var tableRowsCount = table.rows.length;
    for (var i = 3; i < tableRowsCount; i++) {
        table.deleteRow(3);
    }
    for (var i = 0; i < Items.length; i++) {
        var r = table.insertRow(-1);
        if ((i % 2) == 0) {
            r.className = table.rows[1].className;
            r.attachEvent("onmouseout", BinddingTrMouseOut(r, table.rows[1].className));
            for (var j = 0; j < table.rows[1].cells.length; j++) {
                r.insertCell(j).innerHTML = table.rows[1].cells[j].innerHTML;
            }
        }
        else {
            r.className = table.rows[2].className;
            r.attachEvent("onmouseout", BinddingTrMouseOut(r, table.rows[2].className));
            for (var j = 0; j < table.rows[2].cells.length; j++) {
                r.insertCell(j).innerHTML = table.rows[2].cells[j].innerHTML;
            }
        }
        
        r.id = table.id + "_tr_" + i.toString();
        if (MouseOverClass) 
            r.attachEvent("onmouseover", BinddingTrHover(r, MouseOverClass));
        
        var Attribs = r.getElementsByTagName("span");
        for (var j = 0; j < Attribs.length; j++) {
            eval("Attribs[" + j + "].innerHTML = Items[" + i + "]." + Attribs[j].getAttribute("field"));
        }
    }
}

var BinddingTrHover = function(e, className){
    return function(){
        doBinddingTrHover(e, className);
    }
}
var BinddingTrMouseOut = function(e, className){
    return function(){
        doBinddingTrMouseOut(e, className);
    }
}
function doBinddingTrHover(e, className){
    e.className = className;
}

function doBinddingTrMouseOut(e, className){
    e.className = className;
}

//返回分页信息
function getPageInfo(pageNum, pageCount, iCount, reloadWithPage, reLoad, isShowPageTo, isShowInfo){
    //分页
	var showCount = 0;
    var h = "<div class='page_info'>";
    if (pageCount > 0) {
        h += "<table><tr>";
		if (isShowInfo) {
			h += "<td>";
			h += "共" + iCount.toString() + " 条记录　 页码：" + pageNum.toString() + "/" + pageCount + " <a href='#' onclick='" + reLoad + "();return false;' class='link-c'>刷新</a>"
			h += "</td>";
		}
		if (pageCount > 1) {
			h += "<td><ul class='page_ul'>";
			if (pageNum > 1)//首页
			{
				h += "<li><a href='#' onclick='" + reloadWithPage + "(" + (pageNum - 1).toString() + ");return false;'>上一页</a></li>";
			}
			else {
				h += "<li><a href='#' onclick='return false;' disabled='disabled'>上一页</a></li>";
			}
			//{页码
			var pages = [];
			var step = 0;
			for (var i = pageNum - 4; i < pageNum + 5; i++) {
				if (i > 0 && i <= pageCount) {
					pages.add(i);
				}
				if (i <= 0) 
					step = -1;
				if (i > pageCount) 
					step = 1;
			}
			if (step < 0) {
				//后增补
				for (var i = pages[pages.length - 1] + 1; i < pages[pages.length - 1] + (10 - pages.length); i++) {
					if (i <= pageCount) 
						pages.add(i);
				}
			}
			if (step > 0) {
				//前增补
				for (var i = pages[0] - 1; i > pages[0] - (10 - pages.length); i--) {
					if (i > 0) 
						pages.splice(0, 0, i);
				}
			}
			//前置页
			if (pages[0] > 4) {
				pages.splice(0, 0, 1, 2, 0);
			}
			else {
				var tmp = pages[0];
				for (var i = tmp - 1; i >= 1; i--) {
					pages.splice(0, 0, i);
				}
			}
			//if (pages.length>9)
			//	pages.del(9,pages.length-9);
			//后置页
			if (pages[pages.length - 1] < pageCount - 3) {
				pages.splice(pages.length, 0, 0, pageCount - 1, pageCount);
			}
			else {
				for (var i = pages[pages.length - 1] + 1; i <= pageCount; i++) {
					pages.add(i);
				}
			}
			//生成页码
			
			for (var i = 0; i < pages.length; i++) {
				if (pages[i] == pageNum) 
					h += "<li><a href='#' class='selected' onclick='" + reloadWithPage + "(" + pageNum.toString() + ");return false;'>" + pageNum.toString() + "</a></li>";
				else 
					if (pages[i] == 0) 
						h += "<li>..</li>";
					else 
						h += "<li><a href='#' onclick='" + reloadWithPage + "(" + pages[i] + ");return false;'>" + pages[i] + "</a></li>";
			}
			//页码}
			if (pageNum < pageCount)//尾页
			{
				h += "<li><a href='#' onclick='" + reloadWithPage + "(" + (pageNum + 1).toString() + ");return false;'>下一页</a></li>";
			}
			else {
				h += "<li><a href='#' onclick='return false;' disabled='disabled'>下一页</a></li>";
			}
			h += "</ul></td>";
		}
		else{
			//只有一页时的显示
		}
		h += "<td>";
        if (isShowPageTo && isShowPageTo == true && pageCount>1) {
            h += "<div onkeypress=\"DoBtn(event,'pageinto_bt');\"><input type='text' style='width:25px;' id='pageinto' name='pageinto' value='" + pageNum.toString() + "' /><input type='button' id='pageinto_bt' onclick=\"fun_pageto(" + reloadWithPage + ");\" value='go' />";
        }
        h += "</td>";
		h += "</tr></table>";
    }
    
    h += "</div>";
    return h;
}

function fun_pageto(fun){
    var pageN = 1;
    try {
        pageN = parseInt(document.getElementById("pageinto").value);
        if (pageN == 0) {
            pageN = 1;
        }
    } 
    catch (ee) {
        pageN = 1;
    }
    fun(pageN);
}

///////////////其它描述类////////////////////////////
/**
 * 错误类
 */
function ValidataError(){
    this.Field;
    this.FieldName;
    this.ErrorMsg;
    this.setDataFromArray = function(array){
        this.Field = array[0];
        this.FieldName = array[1];
        this.ErrorMsg = array[2];
    }
}

/*其它必要小工具*/
function $get(id_){
    var e = document.getElementById(id_);
    if (e == null) {
        e = document.getElementsByName(id_);
    }
    return e;
}

function $set(e, value){
    if (e) {
        if (e.type == "text" || e.type == "textarea" || e.type == "hidden") {
            e.value = value;
        }
        else {
            e.innerHTML = value;
        }
    }
}

/**
 * 取得上经编码后回传的字符串参数
 */
function parameStr(value){
    return value.toString().PostEncode();
}

/**
 * 获得网址参数
 * @param {Object} name
 */
function getParameter(name){
    var paramStr = location.search;
    if (paramStr.length == 0) 
        return null;
    if (paramStr.charAt(0) != '?') 
        return null;
    paramStr = unescape(paramStr);
    paramStr = paramStr.substring(1);
    if (paramStr.length == 0) 
        return null;
    var params = paramStr.split('&');
    for (var i = 0; i < params.length; i++) {
        var parts = params[i].split('=', 2);
        if (parts[0] == name) {
            if (parts.length < 2 || typeof(parts[1]) == "undefined" || parts[1] == "undefined" || parts[1] == "null") 
                return "";
            return parts[1];
        }
    }
    return null;
}

function getUrlParame(name){
    return getParameter(name);
}

//正则验证
function RegExpCheck(value, expression){
    var thisChecked = true;
    var thisExp = new RegExp(expression);
    //var m=value.match(thisExp);
    if (!thisExp.test(value)) {
        thisChecked = false;
    }
    return thisChecked;
}

/*按值设置选定项*/
function setSelectedIndexWithValue(e, value){
    try {
        for (var i = 0; i < e.options.length; i++) {
            if (e.options[i].value == value) {
                e.selectedIndex = i;
                break;
            }
        }
    } 
    catch (Exe) {
        alert(Exe);
    }
}


/**
 * 表单默认按钮
 */
function DoBtn(evt, btnID){
    var _event = evt || window.event;
    if (_event.keyCode == 13 && !(_event.srcElement && (_event.srcElement.tagName.toLowerCase() == "textarea"))) {
        var e = $get(btnID);
	    if (document.all)
	    {
		    e.click();
	    }
	    else
	    {
		    var evt = document.createEvent("MouseEvents");  
		    evt.initEvent("click",true,true);  
		    e.dispatchEvent(evt);
	    }
    }
}

/**
 * 增加系统函数
 */
String.prototype.trim = function(){
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.replaceAll = function(replacement, target){
	text = this;
	if (text == null || text == "") {
		return text;
	}
	if (replacement == null || replacement == "") {
		return text;
	}
	if (target == null) {
		target = "";
	}
	var returnString = "";
	var index = text.indexOf(replacement);
	while (index != -1) {
		if (index != 0) {
			returnString += text.substring(0, index) + target;
		}
		text = text.substring(index + replacement.length);
		index = text.indexOf(replacement);
	}
	if (text !== "") {
		returnString += text;
	}
	return returnString;
}
String.prototype.PostEncode = function(){
    return escape(encodeURIComponent(this));
}
Array.prototype.add = function(item, i){
    if (i) 
        this.splice(i, 0, item);
    else 
        this[this.length] = item;
}
Array.prototype.del = function(i, num){
    if (num) 
        this.splice(i, num);
    else 
        this.splice(i, 1);
}
Object.prototype.attachEvent = function(method, func){
    if (!this[method]) 
        this[method] = func;
    else 
        this[method] = this[method].attach(func);
}
Function.prototype.attach = function(func){
    var f = this;
    return function(){
        f();
        func();
    }
}

Date.prototype.toFormat = function(format){
	//"ddd,dd MMM yyyy,HH':'mm':'ss '"
	format = format.replace("year", this.getFullYear());
	format = format.replace("month", (this.getMonth()+1).toString());
	format = format.replace("date",this.getDate());
	format = format.replace("hour",this.getHours());
	format = format.replace("minute",this.getMinutes());
	format = format.replace("second",this.getSeconds());
	//format = format.replace("ddd",this.getDay());
	if (format.indexOf("day")>-1){
		switch (this.getDay()){
			case 1:
			format = format.replace("day","Mon");
			break;
			case 2:
			format = format.replace("day","Tue");
			break;
			case 3:
			format = format.replace("day","Wed");
			break;
			case 4:
			format = format.replace("day","Thu");
			break;
			case 5:
			format = format.replace("day","Fri");
			break;
			case 6:
			format = format.replace("day","Sat");
			break;
			case 0:
			format = format.replace("day","Sun");
			break;
		}
	}
	if (format.indexOf("星期")>-1){
		switch (this.getDay()){
			case 1:
			format = format.replace("星期","星期一");
			break;
			case 2:
			format = format.replace("星期","星期二");
			break;
			case 3:
			format = format.replace("星期","星期三");
			break;
			case 4:
			format = format.replace("星期","星期四");
			break;
			case 5:
			format = format.replace("星期","星期五");
			break;
			case 6:
			format = format.replace("星期","星期六");
			break;
			case 0:
			format = format.replace("星期","星期日");
			break;
		}
	}
	return format;
}