//added by zqg on 2004/07/23
var xml;
var sMsg = "无法连接服务器...    请稍候...";
//信息提示窗口 调用popmsg(msgstr) added on 20051028 by zhongqg
var oPopup = window.createPopup();
var popTop = 50;
var popTime = 332;

//是否为空
function isEmpty(xValue) {
    if (xValue == null || xValue == "null" || xValue == "undefined" || xValue == "NaN" || xValue == "")
        return true;
    return false;
}

//检查邮件的合法性
function chkEMail(sValue) {
    if (!isEmpty(sValue) && sValue.indexOf("@") < 0)
        return false;
    return true;
}
function isPositiveInteger2(sValue){
	var vLength=sValue.length;
	for(i=0;i<vLength;i++){
	if((sValue.charAt(i)<"0" || sValue.charAt(i)>"9")&&sValue.charAt(i)!="."){
			return false;
		}
	}
	return true;
}

//检查网址的合法性
function ChkWWW(sValue) {
    if (!isEmpty(sValue) && sValue.indexOf(".") < 0)
        return false;
    return true;
}

//检查是否输入的是正整数
function isPositiveInteger(sValue) {
    var vLength = sValue.length;
    for (i = 0; i < vLength; i++) {
        if (sValue.charAt(i) < "0" || sValue.charAt(i) > "9") {
            return false;
        }
    }
    return true;
}
//检查是否输入的是资金
function isMoney(sValue) {
    var vLength = sValue.length;
	var num = 0;
	/*if(sValue.charAt(0)==".")
		return false;
	if(sValue.charAt(vLength-1)==".")
		return false;*/
    for (i = 0; i < vLength; i++) {
        if (!(sValue.charAt(i) >= "0" && sValue.charAt(i) <= "9" || sValue.charAt(i) == ".")) {
                return false;
		}
		if(sValue.charAt(i)==".")
		num++;
    }
	if(num>=2){
		return false;
		}
    return true;
}

//检查是否输入的是A-Z的英文字母
function isCharAZ(sValue) {
    var vLength = sValue.length;
    for (i = 0; i < vLength; i++) {
        if (sValue.charAt(i) < "A" || sValue.charAt(i) > "Z") {
            return false;
        }
    }
    return true;
}
//电话号码
function isPhone(sValue) {
    var vLength = sValue.length;
    if (vLength != 0) {
        for (i = 0; i < vLength; i++) {
            if (!(sValue.charAt(i) >= "0" && sValue.charAt(i) <= "9" || sValue.charAt(i) == "-"))
                return false;
        }
    }
    return true;
}
function ischinamobile(sValue) {
    var vLength = sValue.length;
    if (vLength < 11) {
        return false;
    }
    if (vLength != 0) {
        if (!(sValue.charAt(2) >= "4" && sValue.charAt(2) <= "9" && sValue.charAt(0) == "1" && sValue.charAt(1) == "3")) {
            return false;
        }
    }
    return true;
}


function isFloat(sValue) {
    var vLength = sValue.length;
    for (i = 0; i < vLength; i++) {
        if (!(sValue.charAt(i) >= "0" && sValue.charAt(i) <= "9" || sValue.charAt(i) == ".")) {
            return false;
        }
    }

    return true;
}

//输入日期合法性检查 added on 2004/08/10 by zqg
//合法的输入格式20040809或200489
//输出:2004-08-09
function validate(Obj) {

    var sValue;
    if (Obj.value == "") {
        return true;
    }

    if (Obj.value.indexOf("-") > -1) {
        var ilength = Obj.value.length;
        sValue = Obj.value.replace(new RegExp("-", "g"), "");
        //if((ilength==10||ilength==9)&& (5<sValue.length<9)){
        //	return true;
        //}
    } else {
        sValue = Obj.value;
    }
    Obj.value = sValue;

    var ilen = Obj.value.length;
    if (!isPositiveInteger(sValue)) {
        //alert("日期输入有误!");
        //Obj.focus();
        alert("注意:日期的合法输入格式是YYYYMMDD,请按照格式直接输入和日期对应的数字,如:2004年1月1号则输入20040101!");
        Obj.select();
        return false;
    }

    if (sValue.substring(0, 1) == "0") {
        alert("日期不能以0开头!");
        Obj.focus();
        return false;
    }
    if (ilen != 8 && ilen != 6) {
        alert("注意:日期的合法输入格式是YYYYMMDD,请按照格式直接输入和日期对应的数字,如:2004年1月1号则输入20040101!");
        Obj.select();
        return false;
    }

    var m;
    var d;
    if (ilen == 8) {
        m = (sValue.substring(4, 6)) * 1;
        //月
        d = (sValue.substring(6)) * 1;
        //日
    } else {
        m = (sValue.substring(4, 5)) * 1;
        d = (sValue.substring(5)) * 1
    }
    if (m < 1) {
        alert("日期输入格式错误,月份不能小于1!");
        Obj.focus();
        return false;
    }
    if (m > 12) {
        alert("日期输入格式错误,月份不能大于12!");
        Obj.focus();
        return false;
    }
    if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
        if (d > 31) {
            alert("天数不能大于31!");
            Obj.focus();
            return false;
        }
    }

    if (m == 4 || m == 6 || m == 9 || m == 11) {
        if (d > 30) {
            alert("天数不能大于30!");
            Obj.focus();
            return false;
        }
    }

    if (m == 2) {//二月
        if (isLeapYear(sValue.substring(0, 4))) {//闰年
            if (d > 29) {
                alert(sValue.substring(0, 4) + "年是闰年，二月天数不能大于29!");
                Obj.focus();
                return false;
            }
        } else {
            if (d > 28) {
                alert(sValue.substring(0, 4) + "年是平年，二月天数不能大于28!");
                Obj.focus();
                return false;
            }
        }
    }
    if (ilen == 8) {
        Obj.value = sValue.substring(0, 4) + "-" + sValue.substring(4, 6) + "-" + sValue.substring(6);
    } else {
        Obj.value = sValue.substring(0, 4) + "-" + "0" + sValue.substring(4, 5) + "-" + "0" + sValue.substring(5);
    }
    return  true;
}

//added by zqg
function detect()
{
    if (window.XMLHttpRequest) {
        // branch for native XMLHttpRequest object
        xml = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        // branch for IE/Windows ActiveX version
        xml = new ActiveXObject("Microsoft.XMLHTTP");
    }
    var post = " ";
    xml.open("POST", "http://zh.zsedu.net/getOnlineCount", false);
    xml.setrequestheader("content-length", post.length);
    xml.setrequestheader("content-type", "application/x-www-form-urlencoded");
    xml.send(post);
    var res = xml.responseText;
    var status = xml.status;
    if (status == 200) {//成功获得
        onlinecount.innerText = res;
    } else {
        onlinecount.innerText = sMsg;
    }
    setTimeout("detect()", 5000);
}

/**
* added by zqg on 2006-03-01
* 获取短信息
*/
/*
function getSMS(){
	var strIp = document.all.serverIp.value;
    if (window.XMLHttpRequest) {
        // branch for native XMLHttpRequest object
        xml = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        // branch for IE/Windows ActiveX version
        xml = new ActiveXObject("Microsoft.XMLHTTP");
    }
    var post = " ";
    xml.open("POST", strIp+"?actiontype=getsms", false);//同步步方式
    xml.setrequestheader("content-length", post.length);
    xml.setrequestheader("content-type", "application/x-www-form-urlencoded");
    xml.send(post);
    var res = xml.responseText;
    var status = xml.status;
    if (status == 200) {//成功获得
	var pos = res.indexOf("|");
	if(pos > -1){		
	var strContent=res.substring(0,pos);
	var strId = res.substring(pos+1);
	//var oPopup = window.createPopup();
	popTop = 50;
    popTime = 332
	popmsg(strContent,strId,99);
	}
    } else {
		//alert(sMsg);
    }
	//每30秒取一次
    //setTimeout("getSMS();",30000);
}
*/

function getSMS(){
	var strIp = document.all.serverIp.value;
    if (window.XMLHttpRequest) {
        // branch for native XMLHttpRequest object
        xml = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        // branch for IE/Windows ActiveX version
        xml = new ActiveXObject("Microsoft.XMLHTTP");
    }
    var post = " ";
	try{
    xml.open("post", strIp+"?actiontype=getsms", true);//异步方式
	xml.setrequestheader("content-length", post.length);
    xml.setrequestheader("content-type", "application/x-www-form-urlencoded");
    xml.send(post);
	xml.onreadystatechange = function(){
	if(xml.readyState == 4) {
		var res = xml.responseText;
		var pos = res.indexOf("|");
		if(pos > -1){		
			var strContent=res.substring(0,pos);
			var strId = res.substring(pos+1);
			popTop = 50;
			popTime = 332
			popmsg(strContent,strId,99);
		}
	}
	}
	}catch(e){
	}
}


//num ,每次打印的多少
function PrintIt(num) {
    var NS = (navigator.appName == "Netscape");
    if (NS) {
        window.print();
    } else {
        var WebBrowser = '<OBJECT ID="Web" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
        document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
        print2Page(num)
        Web.outerHTML = "";
    }
}


function print2Page(num) {
    var i = 0;
    for (i = 0; i <= num; i++) {
        Web.execwb(6, 6);
    }
    window.close();
}
function printsetup() {
    // 打印页面设置
    var WebBrowser = '<OBJECT ID="Web" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
    document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    Web.execwb(8, 1);
    Web.outerHTML = "";
}

function printpreview() {
    // 打印页面预览
    Web.execwb(7, 1);
}

//判断是平年还是闰年,闰年二月29天,平年二月28天
//sYear是年的字符串形式
function isLeapYear(sYear) {
    isleap = false;
    if (isEmpty(sYear)) {
        alert("传入年份不能为空");
        return;
    }
    var iYear = sYear * 1;
    if ((iYear % 400 == 0) || ((iYear % 4 == 0) && (iYear % 100 != 0))) {//是闰年
        isleap = true;
    } else {//平年
        isleap = false;
    }
    return isleap;
}

//设定当前年度
function getCurrntYear()
{
    var today = new Date();
    var year;
    if (today.getMonth() > 7 || today.getMonth() < 3)
        year = today.getYear() + '-' + (today.getYear() + 1);
    else
        year = (today.getYear() - 1) + '-' + today.getYear();
    return year;
}
//判断学年度的合法性
function isYear(sValue)
{
    var vLength = sValue.length;
    if (vLength != 9)
        return false;
    else {
        if (sValue.indexOf('-') != 4)
            return false;
        for (i = 0; i < vLength; i++) {
            if (!(sValue.charAt(i) >= "0" && sValue.charAt(i) <= "9" || sValue.charAt(i) == "-")) {
                return false;
            }
        }
    }
    return true;
}
function isDate(sValue)
{
    var vLength = sValue.length;
    var second,spacecount = 0;
    var year,month,day;
    if (vLength > 10 || vLength < 8)
        return false;
    if (sValue.charAt(4) != "-")

        return false;
    for (i = 0; i < vLength; i++) {
        if (!(sValue.charAt(i) >= "0" && sValue.charAt(i) <= "9" || sValue.charAt(i) == "-")) {
            return false;
        }
        if (sValue.charAt(i) == "-")
        {
            spacecount++;
            if (spacecount > 2)
                return false;
            if (spacecount == 2)
                second = i;
        }
    }
    //遍历结束
    if (!(second == 6 || second == 7)) {
        return false;
    }
    year = sValue.substring(0, 4) * 1;
    month = sValue.substring(5, second) * 1;
    day = sValue.substring(second + 1, vLength) * 1;
    if (month < 1 || month > 12 || day > 31 || day < 1)  return false;
    if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
    {
        if (day > 31)
            return false;
    }
    else if (month == 4 || month == 6 || month == 9 || month == 10)
    {
        if (day > 30)
            return false;
    }
    else if (month == 2)
    {
        if (isLeapYear(year)) {
            if (day > 29) return false;
        } else if (day > 28) return false;
    }
    return true;
}

function chkAll(chkName) {
    var obj;
    var vValue = 0;
    for (iLoop = 0; iLoop < form1.length; iLoop++) {
        obj = form1.elements[iLoop];
        if (obj.name == chkName) {
            if (obj.checked == true) {
                vValue++;
            }
        }
    }
    return vValue;
}
/**提交前的检查 added by zqg on 2005/01/23
*sMsg:提示消息类型
*chkName:checkbox 名
*sActionType:动作类型:add新增，edit修改,del删除
*/
function chkOnSubmit(sMsg, chkName, sActionType) {
    var i_sel = 0;
    i_sel = CheckAll();
    if (i_sel == 0) {
        alert(sMsg);
        return false;
    }
    if ((sActionType == "edit") && (i_sel > 1)) {
        alert("每次只允许修改一条记录!");
        return false;
    }
    return true;
}

function SelectAll() {
    var obj;
    for (iLoop = 0; iLoop < form1.length; iLoop++) {
        obj = form1.elements[iLoop];
        if (obj.name != 'SelAll') {
            obj.checked = form1.SelAll.checked;
        }
    }
}
function CheckAll() {
    var obj;
    var vValue = 0;
    for (iLoop = 0; iLoop < form1.length; iLoop++) {
        obj = form1.elements[iLoop];
        if (obj.name == 'checkbox') {
            if (obj.checked == true) {
                vValue++;
            }
        }
    }
    return vValue;
}
function EditCheck(sServletMap, sAction) {
    var i_sel = 0;
    i_sel = CheckAll();
    if (i_sel == 0) {
        alert('请选择要修改的记录！');
    } else if (i_sel == 1) {
        form1.action = sServletMap + "?action=" + sAction;
        form1.submit();
    } else {
        alert('每次只能修改一条记录！');
    }
}
function DelCheck(sServletMap, sAction) {
    var i_del = 0;
    i_del = CheckAll();
    if (i_del == 0) {
        alert('请选择要删除的记录！');
        return false;
    }
    if (confirm('确定要删除选中的记录？') == true) {
        form1.action = sServletMap + "?action=" + sAction;
        form1.submit();
    } else {
        return false;
    }
}

//比较两个日期的大小日期格式是:2004-01-01 或 2004-1-11 或2004-11-1或2004-11-01
//用方法前必须保证两个日期非空
//oDate1 开始日期，oDate2 结束日期 isSameYear 是否要求年度相同,true是false否
//Msg1,Msg2需要提示的信息
function compDate(oDate1, oDate2, isSameYear, Msg1, Msg2) {
    var y1,y2;
    var m1,m2;
    var d1,d2;
    var sTemp;
    var pos1,pos2;

    if (isEmpty(Msg1)) {
        Msg1 = "开始日期";
    }
    if (isEmpty(Msg2)) {
        Msg2 = "结束日期";
    }

    pos1 = oDate1.value.indexOf('-');
    y1 = oDate1.value.substring(0, pos1) * 1;
    sTemp = oDate1.value.substring(pos1 + 1);
    pos2 = sTemp.indexOf('-');
    m1 = sTemp.substring(0, pos2) * 1;
    d1 = sTemp.substring(pos2 + 1) * 1;

    pos1 = oDate2.value.indexOf('-');
    y2 = oDate2.value.substring(0, pos1) * 1;
    sTemp = oDate2.value.substring(pos1 + 1);
    pos2 = sTemp.indexOf('-');
    m2 = sTemp.substring(0, pos2) * 1;
    d2 = sTemp.substring(pos2 + 1) * 1;

    if (isSameYear) {//要求年度相同
        if (y1 != y2) {
            alert(Msg1 + "和" + Msg2 + "年度不同,请重新输入!");
            return false;
        }
    }
    if (y2 < y1) {
        alert(Msg2 + "不能小于" + Msg1 + ",请重新输入!");
        return false;
    } else if (y2 > y1) {
        return true;
    }

    if (m2 < m1) {
        alert(Msg2 + "不能小于" + Msg1 + ",请重新输入!");
        return false;
    } else if (m2 > m1) {
        return true;
    }

    if (d2 < d1) {
        alert(Msg2 + "不能小于" + Msg1 + ",请重新输入!");
        return false;
    }
    return true;
}

function getOptionName(oOption, oObj) {
    var _iSelIndex = oOption.selectedIndex;
    if (_iSelIndex < 0)
        return "";

    var _sName = new String(oOption.options[_iSelIndex].text);

    if (!isEmpty(oObj)) {
        oObj.value = _sName;
    }
    return _sName;
}
//取系统的当前日期
function getCurrentDate() {
    var today = new Date();
    var sDate = today.getYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
    return sDate;
}

function over(obj) {
    //  obj.style.backgroundColor="A5C8E8";
    obj.style.backgroundColor = "FFFFFF";
}
function out(obj) {
    obj.style.backgroundColor = "FFFFFF";
}
//去单引号
function trimadd(obj){
	var sTemp = obj.value;
    var sResult = "";
    var pos = -1;
    pos = sTemp.indexOf("'");
    while (pos > -1) {
        sResult += sTemp.substring(0, pos);
        sTemp = sTemp.substring(pos + 1);
        pos = sTemp.indexOf("'");
    }
    sResult += sTemp;
	obj.value=sResult;
	}

//去除空白,豆点,单引号,双引号,%


function trim(obj) {
    if (isEmpty(obj.value)) {
        obj.value = "";
    }
    //去除空白
    var sTemp = "1" + obj.value;
    var sResult = "";
    var pos = -1;
    pos = sTemp.indexOf(" ");
    while (pos > -1) {
        sResult += sTemp.substring(0, pos);
        sTemp = sTemp.substring(pos + 1);
        pos = sTemp.indexOf(" ");
    }
    sResult += sTemp;
    //去除豆点
    sTemp = sResult;
    var sResult1 = "";
    pos = sTemp.indexOf(",");
    while (pos > -1) {
        sResult1 += sTemp.substring(0, pos);
        sTemp = sTemp.substring(pos + 1);
        pos = sTemp.indexOf(",");
    }
    sResult1 += sTemp;
    if (!isEmpty(sResult1)) {
        sResult = sResult1;
    }
    //去除单引号
    sTemp = sResult;
    var sResult2 = "";
    pos = sTemp.indexOf("'");
    while (pos > -1) {
        sResult2 += sTemp.substring(0, pos);
        sTemp = sTemp.substring(pos + 1);
        pos = sTemp.indexOf("'");
    }
    sResult2 += sTemp;
    if (!isEmpty(sResult2)) {
        sResult = sResult2;
    }
    //去除双引号
    sTemp = sResult;
    pos = sTemp.indexOf('"');
    var sResult3 = "";
    while (pos > -1) {
        sResult3 += sTemp.substring(0, pos);
        sTemp = sTemp.substring(pos + 1);
        pos = sTemp.indexOf('"');
    }
    sResult3 += sTemp;
    if (!isEmpty(sResult3)) {
        sResult = sResult3;
    }
    //去除%
    sTemp = sResult;
    pos = sTemp.indexOf("%");
    var sResult4 = "";
    while (pos > -1) {
        sResult4 += sTemp.substring(0, pos);
        sTemp = sTemp.substring(pos + 1);
        pos = sTemp.indexOf("%");
    }
    sResult4 += sTemp;
    if (!isEmpty(sResult4)) {
        sResult = sResult4;
    }

    //去除* added on 2005-04-13
    sTemp = sResult;
    pos = sTemp.indexOf("*");
    var sResult5 = "";
    while (pos > -1) {
        sResult5 += sTemp.substring(0, pos);
        sTemp = sTemp.substring(pos + 1);
        pos = sTemp.indexOf("*");
    }
    sResult5 += sTemp;
    if (!isEmpty(sResult5)) {
        sResult = sResult5;
    }
    //去除\ added on 2005-04-13
    sTemp = sResult;
    pos = sTemp.indexOf("\\");
    var sResult6 = "";
    while (pos > -1) {
        sResult6 += sTemp.substring(0, pos);
        sTemp = sTemp.substring(pos + 1);
        pos = sTemp.indexOf("\\");
    }
    sResult6 += sTemp;
    if (!isEmpty(sResult6)) {
        sResult = sResult6;
    }
    //去除\ added on 2005-04-13
    sTemp = sResult;
    pos = sTemp.indexOf("/");
    var sResult7 = "";
    while (pos > -1) {
        sResult7 += sTemp.substring(0, pos);
        sTemp = sTemp.substring(pos + 1);
        pos = sTemp.indexOf("/");
    }
    sResult7 += sTemp;
    if (!isEmpty(sResult7)) {
        sResult = sResult7;
    }
    //去除: added on 2005-04-13
    sTemp = sResult;
    pos = sTemp.indexOf(":");
    var sResult8 = "";
    while (pos > -1) {
        sResult8 += sTemp.substring(0, pos);
        sTemp = sTemp.substring(pos + 1);
        pos = sTemp.indexOf(":");
    }
    sResult8 += sTemp;
    if (!isEmpty(sResult8)) {
        sResult = sResult8;
    }
    //去除? added on 2005-04-13
    sTemp = sResult;
    pos = sTemp.indexOf("?");
    var sResult9 = "";
    while (pos > -1) {
        sResult9 += sTemp.substring(0, pos);
        sTemp = sTemp.substring(pos + 1);
        pos = sTemp.indexOf("?");
    }
    sResult9 += sTemp;
    if (!isEmpty(sResult9)) {
        sResult = sResult9;
    }
    //去除"" added on 2005-04-13
    sTemp = sResult;
    pos = sTemp.indexOf("\"");
    var sResult10 = "";
    while (pos > -1) {
        sResult10 += sTemp.substring(0, pos);
        sTemp = sTemp.substring(pos + 1);
        pos = sTemp.indexOf("\"");
    }
    sResult10 += sTemp;
    if (!isEmpty(sResult10)) {
        sResult = sResult10;
    }
    //去除< added on 2005-04-13
    sTemp = sResult;
    pos = sTemp.indexOf("<");
    var sResult11 = "";
    while (pos > -1) {
        sResult11 += sTemp.substring(0, pos);
        sTemp = sTemp.substring(pos + 1);
        pos = sTemp.indexOf("<");
    }
    sResult11 += sTemp;
    if (!isEmpty(sResult11)) {
        sResult = sResult11;
    }
    //去除> added on 2005-04-13
    sTemp = sResult;
    pos = sTemp.indexOf(">");
    var sResult12 = "";
    while (pos > -1) {
        sResult12 += sTemp.substring(0, pos);
        sTemp = sTemp.substring(pos + 1);
        pos = sTemp.indexOf(">");
    }
    sResult12 += sTemp;
    if (!isEmpty(sResult12)) {
        sResult = sResult12;
    }
    //去除| added on 2005-04-13
    sTemp = sResult;
    pos = sTemp.indexOf("|");
    var sResult13 = "";
    while (pos > -1) {
        sResult13 += sTemp.substring(0, pos);
        sTemp = sTemp.substring(pos + 1);
        pos = sTemp.indexOf("|");
    }
    sResult13 += sTemp;
    if (!isEmpty(sResult13)) {
        sResult = sResult13;
    }


    /*if(!isEmpty(sResult)&&!isEmpty(obj.value)&&(sResult.length<obj.value.length)){
         alert("您所输入的不合法字符将会被自动删除!");
     }*/
    if ((sResult.length == 1) && (sResult.value == "1")) {
        obj.value = "";
        return;
    } else {
        sResult = sResult.substring(1);
    }
    if (sResult == " " || sResult == "'" || sResult == "," || sResult == '"' || sResult == "%" || sResult == "*" || sResult == "\\" || sResult == "/" || sResult == ":" || sResult == "\"" || sResult == "?" || sResult == "<" || sResult == ">" || sResult == "|") {
        obj.value = "";
    } else {
        obj.value = sResult;
    }

}

//added on 2004/11/17

function IsCloseIt()
{
    var clickclose = 0;
    //判断是否点击IE窗口的关闭按钮
    //窗口右上角的关闭按钮
    if (event.screenX >= (screen.availWidth - 50))
    {
        if (event.screenY < 30)
        {
            clickclose = 1;
            logOut();
            //清除该用户的信息
        }
    }

    //任务栏中的关闭
    if (event.screenY > (screen.availHeight - 25))
    {
        clickclose = 1;
        logOut();
        //清除该用户的信息
    }

    if (clickclose == 1)
    {
        //  event.returnValue = "===========================注意=======================     \n"+"      建议您在日后的操作中点击页面右上角的[注销]按钮来退出本系统,谢谢!!\n"+"=====================================================     ";

        //clickclose=0;

    }

}

//身份证号码判断,允许输入中文字母
function isCertification(sValue) {
    var vLength = sValue.length;
    if (vLength != 0) {
        for (i = 0; i < vLength; i++) {
            if (!(sValue.charAt(i) >= "0" && sValue.charAt(i) <= "9" || sValue.charAt(i) >= "a" && sValue.charAt(i) <= "z" || sValue.charAt(i) >= "A" && sValue.charAt(i) <= "Z"))
                return false;
        }
    }
    return true;
}

//added on 2005-04-19
// empty Topics select list content
function clearSelectList(id) {
    var select = document.getElementById(id);
    while (select.length > 0) {
        select.remove(0);
    }
}

// add item to select element the less
// elegant, but compatible way.
function appendToSelect(select, value, content) {
    var opt;
    opt = document.createElement("option");
    opt.value = value;
    opt.appendChild(content);
    select.appendChild(opt);
}

function resize(obj) {
    for (i = 0; i < 123 && (obj.width > 100 || obj.height > 100); i++) {
        obj.width -= obj.width / 10
    }
}

function bbimg(o) {
    var zoom = parseInt(o.style.zoom, 10) || 100;
    zoom += event.wheelDelta / 12;
    if (zoom > 0) o.style.zoom = zoom + '%';
    return false;
}

//显示最新通知详细信息
//	function showContent(url){
//window.open("sysmanage?action=showissuecontent&id="+url,'信息显示','top=150,left=150,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no');
//}

//信息提示窗口 调用popmsg(msgstr) added on 20051028 by zhongqg
//var oPopup = window.createPopup();
//var popTop = 50;
//var popTime = 332;
//pop窗口显示时间
//msgstr要显示的内容，issueid信息id,flag标志：1表示最新通知，2表示最新短信 99表示其它
function popmsg(msgstr, issueid, flag) {
    var winstr = "";
    winstr = "<table style=\"border: 1 solid  #FFA6CA\"  width=\"241\" height=\"172\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"  background=\"/images/bg_1.gif\" >";
    winstr += "<tr><td align=\"center\"><table width=\"90%\" height=\"110\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
    winstr += "<tr><td valign=\"top\" style=\"font-size:12px; color: red; face: Tahoma\">" + msgstr + "</td></tr></table></td></tr></table>";
    if (flag == 1) {//最新通知
        winstr = winstr.replace(/<a ([^>]*)>/g, "<a onclick='parent.open(this.href,\"信息显示\",\"top=150,left=150,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no\");return false' $1>");
    } else if (flag == 2) {//最新短信
        winstr = winstr.replace(/<a ([^>]*)>/g, "<a onclick='parent.open(this.href,\"信息显示\",\"top=150,left=150,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no\");return false' $1>");
        //加入最新短信处理


    } else {//其它
        winstr = winstr.replace(/<a ([^>]*)>/g, "<a onclick='parent.open(this.href,\"信息显示\",\"top=150,left=150,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no\");return false' $1>");
    }
    oPopup.document.body.innerHTML = winstr;
    popshow();
}

function popshow() {
    window.status = popTop;
    if (popTop > popTime) {
        clearTimeout(mytime);
        oPopup.hide();
        return;
    } else if (popTop <= 180) {
        oPopup.show(screen.width - 250, screen.height, 241, popTop);
    } else if (popTop <= 220) {
        oPopup.show(screen.width - 250, screen.height - popTop, 241, 172);
    } else if (popTop > 1500 && popTop <= 1540) {
        oPopup.show(screen.width - 250, screen.height + (popTop - 1720), 241, 172);
    } else if (popTop > 1540 && popTop <= 1720) {
        oPopup.show(screen.width - 250, screen.height, 241, 1720 - popTop);
    } else {
        oPopup.show(screen.width - 250, screen.height - 220, 241, 172);
    }
    popTop += 1;
    var mytime = setTimeout("popshow();", 20);
}


function turnit(ss)
{
    if (ss.style.display == "none")
    {//菜单显示
        ss.style.display = "";
    }
    else
    {//隐藏菜单
        ss.style.display = "none";
    }
}

function showIssue() {
    window.parent.window.dataframe.window.location = 'body';
}

function turnits(ss) ////隐藏菜单
{
    if (ss.style.display == "")
    {
        ss.style.display = "none";
    }
}

//显示所有菜单
function expandAll() {
    if (a1.style.display == "none")
    {
        a1.style.display = "";
    }
    if (a2.style.display == "none")
    {
        a2.style.display = "";
    }

    if (a3.style.display == "none")
    {
        a3.style.display = "";
    }
    if (a4.style.display == "none")
    {
        a4.style.display = "";
    }
    if (a5.style.display == "none")
    {
        a5.style.display = "";
    }
    if (a6.style.display == "none")
    {
        a6.style.display = "";
    }
    if (a7.style.display == "none")
    {
        a7.style.display = "";
    }
    if (a8.style.display == "none")
    {
        a8.style.display = "";
    }
    if (a9.style.display == "none")
    {
        a9.style.display = "";
    }
    if (b1.style.display == "none")
    {
        b1.style.display = "";
    }
    if (b2.style.display == "none")
    {
        b2.style.display = "";
    }
    if (b3.style.display == "none")
    {
        b3.style.display = "";
    }
    if (c1.style.display == "none")
    {
        c1.style.display = "";
    }
    if (c2.style.display == "none")
    {
        c2.style.display = "";
    }
    if (c3.style.display == "none")
    {
        c3.style.display = "";
    }
    if (c4.style.display == "none")
    {
        c4.style.display = "";
    }
    if (c5.style.display == "none")
    {
        c5.style.display = "";
    }
    if (c6.style.display == "none")
    {
        c6.style.display = "";
    }
    if (c7.style.display == "none")
    {
        c7.style.display = "";
    }
}

//隐藏所有菜单
function hiddenAll() {
    if (a1.style.display == "")
    {
        a1.style.display = "none";
    }
    if (a2.style.display == "")
    {
        a2.style.display = "none";
    }

    if (a3.style.display == "")
    {
        a3.style.display = "none";
    }
    if (a4.style.display == "")
    {
        a4.style.display = "none";
    }
    if (a5.style.display == "")
    {
        a5.style.display = "none";
    }
    if (a6.style.display == "")
    {
        a6.style.display = "none";
    }
    if (a7.style.display == "")
    {
        a7.style.display = "none";
    }
    if (a8.style.display == "")
    {
        a8.style.display = "none";
    }
    if (a9.style.display == "")
    {
        a9.style.display = "none";
    }
    if (b1.style.display == "")
    {
        b1.style.display = "none";
    }
    if (b2.style.display == "")
    {
        b2.style.display = "none";
    }
    if (b3.style.display == "")
    {
        b3.style.display = "none";
    }
    if (c1.style.display == "")
    {
        c1.style.display = "none";
    }
    if (c2.style.display == "")
    {
        c2.style.display = "none";
    }
    if (c3.style.display == "")
    {
        c3.style.display = "none";
    }
    if (c4.style.display == "")
    {
        c4.style.display = "none";
    }
    if (c5.style.display == "")
    {
        c5.style.display = "none";
    }
    if (c6.style.display == "")
    {
        c6.style.display = "none";
    }
    if (c7.style.display == "")
    {
        c7.style.display = "none";
    }
}

//detect client browse version
function testNavigator() {
    var message = "系统检测到您的浏览器的版本比较低,建议您使用IE5.5以上的浏览器,否则有的功能可能不能正常使用.您可以到http://www.microsoft.com/china/免费获得IE的最新版本!";
    var ua = navigator.userAgent;
    var ie = false;
    if (navigator.appName == "Microsoft Internet Explorer")
    {
        ie = true;
    }
    if (!ie) {
        alert(message);
        return;
    }
    var IEversion = parseFloat(ua.substring(ua.indexOf("MSIE ") + 5, ua.indexOf(";", ua.indexOf("MSIE "))));
    if (IEversion < 5.5) {
        alert(message);
        return;
    }
}

/*
 * Returns a new XMLHttpRequest object, or false if this browser
 * doesn't support it
 */

function newXMLHttpRequest() {

  var xmlreq = false;

  if (window.XMLHttpRequest) {

    // Create XMLHttpRequest object in non-Microsoft browsers
    xmlreq = new XMLHttpRequest();

  } else if (window.ActiveXObject) {

    // Create XMLHttpRequest via MS ActiveX
    try {
      // Try to create XMLHttpRequest in later versions
      // of Internet Explorer

      xmlreq = new ActiveXObject("Msxml2.XMLHTTP");

    } catch (e1) {

      // Failed to create required ActiveXObject

      try {
        // Try version supported by older versions
        // of Internet Explorer

        xmlreq = new ActiveXObject("Microsoft.XMLHTTP");

      } catch (e2) {

        // Unable to create an XMLHttpRequest with ActiveX
      }
    }
  }

  return xmlreq;
}

/**
*
*/
function OptionCopy(oSurOption, oTarOption) {
  oTarOption.length=0; 
  var _iSurLength = oSurOption.length;
  var _oOption;
  for (var i=0; i<_iSurLength; i++) {
    _oOption = document.createElement("OPTION");
    _oOption.value = oSurOption.options[i].value;
    _oOption.text  = oSurOption.options[i].text;
    oTarOption.add(_oOption);
  }
  return true;
}

/**
 * description:键盘事件处理
 *	author:zhongqiongge
 * date: 2006-07-27 
 */

function editOnKeyDown(aObj) {
  if (isEmpty(aObj)) {
    aObj = [ document.all.btnSave, document.all.btnCancel ];
  }

  var _iKeyCode = window.event.keyCode;
  if (_iKeyCode==9 && (window.event.srcElement.type!="button" || window.event.srcElement.type != "img")) {
    window.event.keyCode = 9;
    return true;
  }
  else if (_iKeyCode==13 || _iKeyCode == 121) {       // enter,F10
    if (typeof(aObj[0])!="undefined")
      aObj[0].onclick();
  }
  else if (_iKeyCode==27) {//esc
    if (typeof(aObj[1])!="undefined")
      aObj[1].onclick();
    return keyReturn();
  }
  return false;
} // qryOnKeyDown()

function keyReturn() {
  window.event.returnValue = false;
  return true;
}

function chkPassword(psw){
   //密码中字母的个数,数字的个数
   var Flag1=0,Flag2=0;
   for(i=0;i<psw.length;i++){
      var temp=psw.charAt(i);
      if(temp>='0'&&temp<='9')
         Flag2++;
      if(temp>='A'&&temp<='z')
         Flag1++;
   }
  if(Flag1==psw.length||Flag2==psw.length){
   return false;
  }
  else{
   return true;
  }
 }
 
 function isValidUser_ID(checkStr)
{
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
	var allValid = true;
	if (checkStr.length<6 || checkStr.length>20)
	allValid=false
	for (i=0;i<checkStr.length;i++)
	{
	  ch=checkStr.charAt(i);
	  for(j=0;j<checkOK.length;j++)
	  if(ch==checkOK.charAt(j))
	    break;
	  if(j==checkOK.length)
	   {
	    allValid = false;
	    break;
	   }
	}
	return allValid;
}