﻿// 此文件中放与具体的业务逻辑无关的javascript代码

/*
 * 全局变量
 */
var jzwin = window == window.top ? window : window.top.frames["frmMain"];

/*
 * 判断当前浏览器
 */
function JudgeBrowser()
{    
    var win_ie_ver = 0;    //IE版本信息        
    if (navigator.userAgent.indexOf('Mac') >= 0)  // Mac
    {
        win_ie_ver = -1;         
    }
    else if (navigator.userAgent.indexOf('Windows CE') >= 0) // Windows CE
    {
        win_ie_ver = -1;         
    }
    else if (navigator.userAgent.indexOf('Opera') >= 0)  // Opera
    {
        win_ie_ver = -1;         
    } 
    else if (navigator.userAgent.indexOf('Firefox') >= 0)  // Firefox
    {
        win_ie_ver = -1;
    } 
    else if(navigator.userAgent.indexOf('MSIE') < 0)  // 非IE
    {
        win_ie_ver = -2;
    } 
    else  // IE
    {
        win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);    // IE版本信息
    }
    return win_ie_ver;
}
/*
 * 功能：将货币数字（阿拉伯数字）(小写)转化成中文(大写）
 * 参数：num为字符型, 小数点之后保留两位, 例：Arabia_to_Chinese("1234.06")
 * 说明：不支持负数
 */
function Num2Chinese(num)
{
    for(i = num.length - 1; i >= 0; i -- )
    {
        num = num.replace(",", "")// 替换tomoney()中的“, ”
        num = num.replace(" ", "")// 替换tomoney()中的空格
    }

    num = num.replace("￥", "")// 替换掉可能出现的￥字符
    if(isNaN(num))  // 验证输入的字符是否为数字
    {
        alert("请检查小写金额是否正确");
        return;
    }
    // --- 字符处理完毕，开始转换，转换采用前后两部分分别转换 --- //
    part = String(num).split(".");
    rank = 0;
    var trans = new Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖");
    var unit = new Array("拾", "佰", "仟", "万", "拾", "佰", "仟", "亿");
    var digit = new Array("角", "分");
    str = trans[parseInt(part[0].charAt(part[0].length - 1), 10)] + "元";
    index = 0;
    // 小数点前进行转化
    for(i = part[0].length - 2; i >= 0; i -- )
    {
        str = trans[parseInt(part[0].charAt(i), 10)] + unit[index % 8] + str;
        index = index + 1;
    }

    if(part.length == 2 && part[1].substring(0, 2) != "00")
    {
        str = str + trans[parseInt(part[1].charAt(0))] + digit[0];
        if(part[1].length >= 2)
        {
            str = str + trans[parseInt(part[1].charAt(1))] + digit[1];
        }
    }

    // 替换所有无用汉字
    while(str.search("零仟") != - 1)
    {
        str = str.replace("零仟", "零");
    }
    while(str.search("零佰") != - 1)
    {
        str = str.replace("零佰", "零");
    }
    while(str.search("零拾") != - 1)
    {
        str = str.replace("零拾", "零");
    }
    str = str.replace("零角", "零");
    while(str.search("零零") != - 1)
    {
        str = str.replace("零零", "零");
    }
    str = str.replace("零亿", "亿");
    str = str.replace("亿万", "亿");
    str = str.replace("零万", "万");
    str = str.replace("零仟", "零");
    str = str.replace("零佰", "零");
    str = str.replace("零拾", "零");
    str = str.replace("零元", "元");
    str = str.replace("零角", "零");
    str = str.replace("零分", "");

    if(str.charAt(str.length - 1) == "元" || str.charAt(str.length - 1) == "角")
    {
        str = str + "整";
    }
    if(str.charAt(0) == "元")
    {
        str = "零" + str;
    }
    return str;
}
/*
 * 功能：将阿拉伯数字(小写)转化成中文(大写）
 * 参数：num为字符型, 小数点之后保留两位, 例：Arabia_to_Chinese("1234.06")
 * 说明：不支持负数
 */
function Num2Traditional(num)
{
    for(i = num.length - 1; i >= 0; i -- )
    {
        num = num.replace(",", "")// 替换tomoney()中的“, ”
        num = num.replace(" ", "")// 替换tomoney()中的空格
    }

    if(isNaN(num))  // 验证输入的字符是否为数字
    {
        alert("请检查数字是否正确！");
        return;
    }
    // --- 字符处理完毕，开始转换，转换采用前后两部分分别转换 --- //
    part = String(num).split(".");
    rank = 0;
    var trans = new Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖");
    var unit = new Array("拾", "佰", "仟", "万", "拾", "佰", "仟", "亿");
    var digit = new Array("", "");
    str = trans[parseInt(part[0].charAt(part[0].length - 1), 10)] + "点";
    index = 0;
    // 小数点前进行转化
    for(i = part[0].length - 2; i >= 0; i -- )
    {
        str = trans[parseInt(part[0].charAt(i), 10)] + unit[index % 8] + str;
        index = index + 1;
    }

    if(part.length == 2 && part[1].substring(0, 2) != "00")
    {
        str = str + trans[parseInt(part[1].charAt(0))] + digit[0];
        if(part[1].length >= 2)
        {
            str = str + trans[parseInt(part[1].charAt(1))] + digit[1];
        }
    }

    // 替换所有无用汉字
    while(str.search("零仟") != - 1)
    {
        str = str.replace("零仟", "零");
    }
    while(str.search("零佰") != - 1)
    {
        str = str.replace("零佰", "零");
    }
    while(str.search("零拾") != - 1)
    {
        str = str.replace("零拾", "零");
    }
    while(str.search("零零") != - 1)
    {
        str = str.replace("零零", "零");
    }
    str = str.replace("零亿", "亿");
    str = str.replace("亿万", "亿");
    str = str.replace("零万", "万");
    str = str.replace("零仟", "零");
    str = str.replace("零佰", "零");
    str = str.replace("零拾", "零");
    str = str.replace("零点", "点");

    if(str.charAt(str.length - 1) == "点")
    {
        str = str.substring(0, str.length);
    }
    return str;
}

/* 关闭打开的窗口
 *
 */
function CloseWindow()
{
    window.opener = null;
    window.returnValue = false;
    window.close();
}

/* 替换掉str中的xml escape字符
 *
 */
function EscapeXmlChars(str)
{
    if(str != undefined)
    {
        str = str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, '&quot;').replace(/ /g, "&nbsp;");
    }
    return str;
}

/* 还原str中的xml escape字符
 *
 */
function DescapeXmlChars(str)
{
    if(str != undefined)
    {
        str = str.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&nbsp;/g, " ");
    }
    return str;
}

/******************************************************************************
 * arguments有两个属性 : Value和IsValid
 * source是指触发check事件对象, 因校验对象都编译成span, 故source为span对象
 ******************************************************************************/
 
/*
 * 检测是否为时间格式
 */
function CheckTime( source, arguments )
{
   var reg =  /^\d{2}\:\d{2}$/;
   var h = arguments.Value.split( ':' )[0];
   var m = arguments.Value.split( ':' )[1];
   if( ! reg.test( arguments.Value ) )
   {
      arguments.IsValid = false;
      source.errormessage = "时间格式错误，应为 HH:mm ";
   }
   else
   {
      if( parseInt( h, 10 ) > 24 || parseInt( m, 10 ) > 59 )
      {
         arguments.IsValid = false;
         source.errormessage = "时间超出范围!";
      }
   }
}

/* 
 * 检测是否为整数
 */
function CheckInteger(source, arguments)
{
    if(source.className.length > 0)
    {
        eval(source.className + "(source, arguments)");
    }

    var regu = /^[-]{0,1}[0-9]{1,}$/;
    if(!regu.test(arguments.Value))
    {
        arguments.IsValid = false;
    }
}

/*
 * 检测是否为有效日期 (CustomValidator)
 */
function CheckDate(source, arguments)
{
    if(source.className.length > 0)
    {
        eval(source.className + "(source, arguments)");
    }

    tmp = arguments.Value;
    if(tmp == "" || tmp == " ")
    {
        return;
    }
    var strs = tmp.split("-");
    if(strs.length == "undefined" || strs.length != 3)
    {
        strs = tmp.split("/");
        if(strs.length == "undefined" || strs.length != 3)
        {
            arguments.IsValid = false;
        }
        else
        {
            m = parseInt(strs[0], 10);
            d = parseInt(strs[1], 10);
            y = parseInt(strs[2], 10);
            if((m < 1 || m > 12) || (d < 1 || d > 31) || (y < 1)
            || isNaN(strs[0]) || isNaN(strs[1]) || isNaN(strs[2]))
            {
                arguments.IsValid = false;
            }
        }
    }
    else
    {
        y = parseInt(strs[0], 10);
        m = parseInt(strs[1], 10);
        d = parseInt(strs[2], 10);
        if((m < 1 || m > 12) || (d < 1 || d > 31) || (y < 1)
        || isNaN(strs[0]) || isNaN(strs[1]) || isNaN(strs[2]))
        {
            arguments.IsValid = false;
        }
    }
}

/*
 * 验证身份证
 */
function checkIdcard(obj)
{
    var msg = true;
    var Errors = new Array("验证通过!", "身份证号码位数不对!", "身份证号码出生日期超出范围或含有非法字符!", "身份证号码校验错误!", "身份证地区非法!");
    var area = 
    {
        11: "北京",
        12: "天津",
        13: "河北",
        14: "山西",
        15: "内蒙古",
        21: "辽宁",
        22: "吉林",
        23: "黑龙江",
        31: "上海",
        32: "江苏",
        33: "浙江",
        34: "安徽",
        35: "福建",
        36: "江西",
        37: "山东",
        41: "河南",
        42: "湖北",
        43: "湖南",
        44: "广东",
        45: "广西",
        46: "海南",
        50: "重庆",
        51: "四川",
        52: "贵州",
        53: "云南",
        54: "西藏",
        61: "陕西",
        62: "甘肃",
        63: "青海",
        64: "宁夏",
        65: "新疆",
        71: "台湾",
        81: "香港",
        82: "澳门",
        91: "国外"
    }
    var idcard, Y, JYM;
    var S, M;
    var idcard = document.getElementById(obj).value;
    var idcard_array = new Array();
    idcard_array = idcard.split("");
    //地区检验
    if (area[parseInt(idcard.substr(0, 2))] == null) 
    {
        msg = "身份证地区非法!";
        return msg;
    }
    //身份号码位数及格式检验
    switch (idcard.length)
    {
        case 15:
            if ((parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0 || ((parseInt(idcard.substr(6, 2)) + 1900) % 100 == 0 && (parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0)) 
            {
                ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;//测试出生日期的合法性
            }
            else 
            {
                ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;//测试出生日期的合法性
            }
            if (ereg.test(idcard)) 
                return true;
            else 
            {
                msg = "身份证号码出生日期超出范围或含有非法字符!";
                return msg;
            }
            break;
        case 18:
            //18位身份号码检测
            //出生日期的合法性检查
            //闰年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))
            //平年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))
            if (parseInt(idcard.substr(6, 4)) % 4 == 0 || (parseInt(idcard.substr(6, 4)) % 100 == 0 && parseInt(idcard.substr(6, 4)) % 4 == 0)) 
            {
                ereg = /^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/;//闰年出生日期的合法性正则表达式
            }
            else 
            {
                ereg = /^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/;//平年出生日期的合法性正则表达式
            }
            if (ereg.test(idcard)) 
            {   //测试出生日期的合法性
                //计算校验位
                S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7 +
                    (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9 +
                    (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10 +
                    (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5 +
                    (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8 +
                    (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4 +
                    (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2 +
                    parseInt(idcard_array[7]) * 1 +
                    parseInt(idcard_array[8]) * 6 +
                    parseInt(idcard_array[9]) * 3;
                Y = S % 11;
                M = "F";
                JYM = "10X98765432";
                M = JYM.substr(Y, 1);//判断校验位
                if (M == idcard_array[17]) 
                    return true; //检测ID的校验位
                else 
                {
                    msg = "身份证号码校验错误!";
                    return msg;
                }
            }
            else 
            {
                msg = "身份证号码出生日期超出范围或含有非法字符!";
                return msg;
            }
            break;
        default:
                        {
                msg = "身份证号码位数不对!";
                return msg;
            }
            break;
    }
    return msg;
}

/*
 * 检测身份证号码是否有效
 */
function CheckCard(source, arguments)
{
    var msg = checkIdcard(source.controltovalidate);
    if(msg != true)
    {
        arguments.IsValid = false;
        source.errormessage = msg;
    }
    msg = null;
}

/*
 * 用隐藏域的值判断记录是否被修改
 */
function md5( hidId, divId)
{
    old = document.getElementById( hidId ).value;
    cur = calcMD5( document.getElementById(divId).innerHTML );
    if( old == cur )
    {
        document.getElementById( hidId ).value = "false";
    }
    else
    {
        document.getElementById( hidId ).value = "true";
    }
}

/*******************************************************************************************
 ******        url相关处理函数(Begin Script)          ********
 *******************************************************************************************/
function RemoveFromUrl(url, name)
{
    i = url.indexOf("?");
    if(i > 0)
    {
        var str = url.substr(i + 1);
        url = url.substr(0, i + 1);
        var names = str.split("&");
        for(k = 0; k < names.length; k ++ )
        {
            if(names[k].split("=")[0] != name)
            {
                url = url + names[k] + "&";
            }
        }
        if(url.charAt(url.length - 1) == "&")
        {
            url = url.substring(0, url.length - 1);
        }
    }
    return url;
}

function AddToUrl(url, name, value)
{
    var url = RemoveFromUrl(url, name);
    var tag = "&";
    i = url.indexOf("?");
    if(i < 0)
    {
        tag = "?";
    }
    url = url + tag + name + "=" + value;
    return url;
}
/*******************************************************************************************
 ******        url相关处理函数(End Script)          ********
 *******************************************************************************************/


/*******************************************************************************************
 * XmlHttp(Begin Script)
 * 为了解决XMLHTTP缓冲的问题, url会被自动加上dt参数, 因此传值时
 * 避免使用dt参数
 *******************************************************************************************/
function GetXmlHttpResult(url)
{
    var dt = new Date();
    if(url.indexOf("?") > 0)
    {
        url = url + "&dt" + dt.getMilliseconds();
    }
    else
    {
        url = url + "?dt" + dt.getMilliseconds();
    }
    var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.open("GET", url, false);
    var str = "";
    try
    {
        xmlhttp.send();
        str = xmlhttp.responseText;
        xmlhttp = null;
        return str;
    }
    catch(e)
    {
        return "";
    }
}
/*******************************************************************************************
 * XmlHttp(End Script)
 *******************************************************************************************/


/*******************************************************************************************
 ******        出错后回填相关处理函数(Begin Script)          ********
 *******************************************************************************************/
/*
 * 收集页面中控件的值
 *
 */
function CollectDocument()
{
    if(window == window.top || document.parentWindow.name != "frmMain")
    {
        return;
    }
    var objHid = window.top.frmTop.frameElement.contentWindow.document.getElementById("hidValue");
    window.top.frmTop.frameElement.contentWindow.document.getElementById("hidUrl").value = location.href;
    objHid.value = "";
    var array = new Array();
    var objs = document.all;
    var i = 0;
    var obj;
    for (i = 0; i < objs.length; i = i + 1) 
    {
        obj = objs[i];
        if (obj.id == "" || obj.id == undefined || obj.id == "__VIEWSTATE" || obj.id.indexOf("__EVENT") == 0 ) 
        {
            continue;
        }
        switch (obj.tagName.toLowerCase())
        {
            case "input":
            {
                switch (obj.type)
                {
                    case "text":
                    {
                        if (obj.value && obj.value != "") 
                        {
                            array.push(obj.id);
                            array.push(EscapeXmlChars(obj.value));
                        }
                        break;
                    }
                    case "radio":
                    {
                        array.push(obj.id);
                        array.push(obj.checked);
                        break;
                    }
                    case "checkbox":
                    {
                        array.push(obj.id);
                        array.push(obj.checked);
                        break;
                    }
                    case "hidden":
                    {
                        if (obj.value && obj.value != "") 
                        {
                            array.push(obj.id);
                            array.push(EscapeXmlChars(obj.value));
                        }
                        break;
                    }
                }
                break;
            }
            case "select":
            {
                array.push(obj.id);
                array.push(obj.selectedIndex);
                break;
            }
            case "textarea":
            {
                if (obj.value && obj.value != "") 
                {
                    array.push(obj.id);
                    array.push(EscapeXmlChars(obj.value));
                }
                break;
            }
            case "img":
            {
                if (obj.url && obj.url != "") 
                {
                    array.push(obj.id);
                    array.push(EscapeXmlChars(obj.url));
                }
                break;
            }
        }
    }
    objHid.value = array.join(' ');
}

/*
 * 将收集到的值, 回填给控件
 *
 */
function FillDocument()
{
    if (! window.top.frmTop )
    {
        return ;
    }
    var topDoc = window.top.frmTop.frameElement.contentWindow.document;
    var url = topDoc.getElementById("hidUrl").value;
    if(window == window.top || document.parentWindow.name != "frmMain")
    {
        topDoc = null;
        return;
    }
    else if(url != location.href)
    {
        topDoc.getElementById("hidValue").value = "";
        topDoc.getElementById("hidUrl").value = "";
    }

    var fillValue = topDoc.getElementById("hidValue").value.split(' ');
    topDoc = null;
    if (fillValue.length < 2) 
    {
        return;
    }
    var i = 0;
    var ctrl = fillValue.length / 2;
    var obj;
    for (i = 0; i < ctrl; i = i + 1) 
    {
        obj = document.getElementById(fillValue[i * 2]);
        if (!obj) 
        {
            continue;
        }
        switch (obj.tagName.toLowerCase())
        {
            case "input":
            {
                switch (obj.type)
                {
                    case "text":
                    {
                        obj.value = DescapeXmlChars(fillValue[i * 2 + 1]);
                        break;
                    }
                    case "radio":
                    {
                        obj.checked = fillValue[i * 2 + 1] == "true";
                        break;
                    }
                    case "checkbox":
                    {
                        obj.checked = fillValue[i * 2 + 1] == "true";
                        break;
                    }
                    case "hidden":
                    {
                        obj.value = DescapeXmlChars(fillValue[i * 2 + 1]);
                        break;
                    }
                }
                break;
            }
            case "select":
            {
                obj.selectedIndex = fillValue[i * 2 + 1];
                break;
            }
            case "textarea":
            {
                obj.value = DescapeXmlChars(fillValue[i * 2 + 1]);
                break;
            }
            case "img":
            {
                obj.url = DescapeXmlChars(fillValue[i * 2 + 1]);
                break;
            }
        }
    }
}
/*******************************************************************************************
 ******        出错后回填相关处理函数(End Script)          ********
 *******************************************************************************************/


/*******************************************************************************************
 * MD5相关函数(Begin Script)
 *******************************************************************************************/

/*
 * 此函数为外部调用函数, 其它均为内部计算时使用
 */
function calcMD5( s )
{
   return rstr2hex( rstr_md5( str2rstr_utf8( s ) ) );
}

//  ---------------------------------------

function b64_md5( s )
{
   return rstr2b64( rstr_md5( str2rstr_utf8( s ) ) );
}

//  ---------------------------------------

function any_md5( s, e )
{
   return rstr2any( rstr_md5( str2rstr_utf8( s ) ), e );
}

//  ---------------------------------------

function hex_hmac_md5( k, d )
{
   return rstr2hex( rstr_hmac_md5( str2rstr_utf8( k ), str2rstr_utf8( d ) ) );
}

//  ---------------------------------------

function b64_hmac_md5( k, d )
{
   return rstr2b64( rstr_hmac_md5( str2rstr_utf8( k ), str2rstr_utf8( d ) ) );
}

//  ---------------------------------------

function any_hmac_md5( k, d, e )
{
   return rstr2any( rstr_hmac_md5( str2rstr_utf8( k ), str2rstr_utf8( d ) ), e );
}

//  ---------------------------------------

function md5_vm_test()
{
   return hex_md5( "abc" ) == "900150983cd24fb0d6963f7d28e17f72";
}

//  ---------------------------------------

function rstr_md5( s )
{
   return binl2rstr( binl_md5( rstr2binl( s ), s.length * 8 ) );
}

//  ---------------------------------------

function rstr_hmac_md5( key, data )
{
   var bkey = rstr2binl( key );
   if( bkey.length > 16 )
   {
      bkey = binl_md5( bkey, key.length * 8 );
   }
   var ipad = Array( 16 ), opad = Array( 16 );
   for( var i = 0; i < 16; i ++ )
   {
      ipad[i] = bkey[i] ^ 909522486;
      opad[i] = bkey[i] ^ 1549556828;
   }
   var hash = binl_md5( ipad.concat( rstr2binl( data ) ), 512 + data.length * 8 );
   return binl2rstr( binl_md5( opad.concat( hash ), 512 + 128 ) );
}

//  ---------------------------------------

function rstr2hex( _e5d )
{
   var hexcase = 0;
   var _e5e = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
   var _e5f = "";
   var x;
   for( var i = 0; i < _e5d.length; i ++ )
   {
      x = _e5d.charCodeAt( i );
      _e5f += _e5e.charAt( ( x >>> 4 ) & 15 ) + _e5e.charAt( x & 15 );
   }
   return _e5f;
}

//  ---------------------------------------

function rstr2b64( _e62 )
{
   var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
   var _e64 = "";
   var b64pad = "";
   var len = _e62.length;
   for( var i = 0; i < len; i += 3 )
   {
      var _e67 = ( _e62.charCodeAt( i ) << 16 ) | ( i + 1 < len ? _e62.charCodeAt( i + 1 ) << 8 : 0 ) | ( i + 2 < len ? _e62.charCodeAt( i + 2 ) : 0 );
      for( var j = 0; j < 4; j ++ )
      {
         if( i * 8 + j * 6 > _e62.length * 8 )
         {
            _e64 += b64pad;
         }
         else
         {
            _e64 += tab.charAt( ( _e67 >>> 6 * ( 3 - j ) ) & 63 );
         }
      }
   }
   return _e64;
}

//  ---------------------------------------

function rstr2any( _e69, _e6a )
{
   var _e6b = _e6a.length;
   var i, j, q, x, quotient;
   var _e6d = Array( Math.ceil( _e69.length / 2 ) );
   for( i = 0; i < _e6d.length; i ++ )
   {
      _e6d[i] = ( _e69.charCodeAt( i * 2 ) << 8 ) | _e69.charCodeAt( i * 2 + 1 );
   }
   var _e6e = Math.ceil( _e69.length * 8 / ( Math.log( _e6a.length ) / Math.log( 2 ) ) );
   var _e6f = Array( _e6e );
   for( j = 0; j < _e6e; j ++ )
   {
      quotient = Array();
      x = 0;
      for( i = 0; i < _e6d.length; i ++ )
      {
         x = ( x << 16 ) + _e6d[i];
         q = Math.floor( x / _e6b );
         x -= q * _e6b;
         if( quotient.length > 0 || q > 0 )
         {
            quotient[quotient.length] = q;
         }
      }
      _e6f[j] = x;
      _e6d = quotient;
   }
   var _e70 = "";
   for( i = _e6f.length - 1; i >= 0; i -- )
   {
      _e70 += _e6a.charAt( _e6f[i] );
   }
   return _e70;
}

//  ---------------------------------------

function str2rstr_utf8( _e71 )
{
   var _e72 = "";
   var i = - 1;
   var x, y;
   while( ++ i < _e71.length )
   {
      x = _e71.charCodeAt( i );
      y = i + 1 < _e71.length ? _e71.charCodeAt( i + 1 ) : 0;
      if( 55296 <= x && x <= 56319 && 56320 <= y && y <= 57343 )
      {
         x = 65536 + ( ( x & 1023 ) << 10 ) + ( y & 1023 );
         i ++ ;
      }
      if( x <= 127 )
      {
         _e72 += String.fromCharCode( x );
      }
      else
      {
         if( x <= 2047 )
         {
            _e72 += String.fromCharCode( 192 | ( ( x >>> 6 ) & 31 ), 128 | ( x & 63 ) );
         }
         else
         {
            if( x <= 65535 )
            {
               _e72 += String.fromCharCode( 224 | ( ( x >>> 12 ) & 15 ), 128 | ( ( x >>> 6 ) & 63 ), 128 | ( x & 63 ) );
            }
            else
            {
               if( x <= 2097151 )
               {
                  _e72 += String.fromCharCode( 240 | ( ( x >>> 18 ) & 7 ), 128 | ( ( x >>> 12 ) & 63 ), 128 | ( ( x >>> 6 ) & 63 ), 128 | ( x & 63 ) );
               }
            }
         }
      }
   }
   return _e72;
}

//  ---------------------------------------

function str2rstr_utf16le( _e75 )
{
   var _e76 = "";
   for( var i = 0; i < _e75.length; i ++ )
   {
      _e76 += String.fromCharCode( _e75.charCodeAt( i ) & 255, ( _e75.charCodeAt( i ) >>> 8 ) & 255 );
   }
   return _e76;
}

//  ---------------------------------------

function str2rstr_utf16be( _e78 )
{
   var _e79 = "";
   for( var i = 0; i < _e78.length; i ++ )
   {
      _e79 += String.fromCharCode( ( _e78.charCodeAt( i ) >>> 8 ) & 255, _e78.charCodeAt( i ) & 255 );
   }
   return _e79;
}

//  ---------------------------------------

function rstr2binl( _e7b )
{
   var _e7c = Array( _e7b.length >> 2 );
   for( var i = 0; i < _e7c.length; i ++ )
   {
      _e7c[i] = 0;
   }
   for( var i = 0; i < _e7b.length * 8; i += 8 )
   {
      _e7c[i >> 5] |= ( _e7b.charCodeAt( i / 8 ) & 255 ) << ( i % 32 );
   }
   return _e7c;
}

//  ---------------------------------------

function binl2rstr( _e7e )
{
   var _e7f = "";
   for( var i = 0; i < _e7e.length * 32; i += 8 )
   {
      _e7f += String.fromCharCode( ( _e7e[i >> 5] >>> ( i % 32 ) ) & 255 );
   }
   return _e7f;
}

//  ---------------------------------------

function binl_md5( x, len )
{
   x[len >> 5] |= 128 << ( ( len ) % 32 );
   x[( ( ( len + 64 ) >>> 9 ) << 4 ) + 14] = len;
   var a = 1732584193;
   var b = - 271733879;
   var c = - 1732584194;
   var d = 271733878;
   for( var i = 0; i < x.length; i += 16 )
   {
      var olda = a;
      var oldb = b;
      var oldc = c;
      var oldd = d;
      a = md5_ff( a, b, c, d, x[i + 0], 7, - 680876936 );
      d = md5_ff( d, a, b, c, x[i + 1], 12, - 389564586 );
      c = md5_ff( c, d, a, b, x[i + 2], 17, 606105819 );
      b = md5_ff( b, c, d, a, x[i + 3], 22, - 1044525330 );
      a = md5_ff( a, b, c, d, x[i + 4], 7, - 176418897 );
      d = md5_ff( d, a, b, c, x[i + 5], 12, 1200080426 );
      c = md5_ff( c, d, a, b, x[i + 6], 17, - 1473231341 );
      b = md5_ff( b, c, d, a, x[i + 7], 22, - 45705983 );
      a = md5_ff( a, b, c, d, x[i + 8], 7, 1770035416 );
      d = md5_ff( d, a, b, c, x[i + 9], 12, - 1958414417 );
      c = md5_ff( c, d, a, b, x[i + 10], 17, - 42063 );
      b = md5_ff( b, c, d, a, x[i + 11], 22, - 1990404162 );
      a = md5_ff( a, b, c, d, x[i + 12], 7, 1804603682 );
      d = md5_ff( d, a, b, c, x[i + 13], 12, - 40341101 );
      c = md5_ff( c, d, a, b, x[i + 14], 17, - 1502002290 );
      b = md5_ff( b, c, d, a, x[i + 15], 22, 1236535329 );
      a = md5_gg( a, b, c, d, x[i + 1], 5, - 165796510 );
      d = md5_gg( d, a, b, c, x[i + 6], 9, - 1069501632 );
      c = md5_gg( c, d, a, b, x[i + 11], 14, 643717713 );
      b = md5_gg( b, c, d, a, x[i + 0], 20, - 373897302 );
      a = md5_gg( a, b, c, d, x[i + 5], 5, - 701558691 );
      d = md5_gg( d, a, b, c, x[i + 10], 9, 38016083 );
      c = md5_gg( c, d, a, b, x[i + 15], 14, - 660478335 );
      b = md5_gg( b, c, d, a, x[i + 4], 20, - 405537848 );
      a = md5_gg( a, b, c, d, x[i + 9], 5, 568446438 );
      d = md5_gg( d, a, b, c, x[i + 14], 9, - 1019803690 );
      c = md5_gg( c, d, a, b, x[i + 3], 14, - 187363961 );
      b = md5_gg( b, c, d, a, x[i + 8], 20, 1163531501 );
      a = md5_gg( a, b, c, d, x[i + 13], 5, - 1444681467 );
      d = md5_gg( d, a, b, c, x[i + 2], 9, - 51403784 );
      c = md5_gg( c, d, a, b, x[i + 7], 14, 1735328473 );
      b = md5_gg( b, c, d, a, x[i + 12], 20, - 1926607734 );
      a = md5_hh( a, b, c, d, x[i + 5], 4, - 378558 );
      d = md5_hh( d, a, b, c, x[i + 8], 11, - 2022574463 );
      c = md5_hh( c, d, a, b, x[i + 11], 16, 1839030562 );
      b = md5_hh( b, c, d, a, x[i + 14], 23, - 35309556 );
      a = md5_hh( a, b, c, d, x[i + 1], 4, - 1530992060 );
      d = md5_hh( d, a, b, c, x[i + 4], 11, 1272893353 );
      c = md5_hh( c, d, a, b, x[i + 7], 16, - 155497632 );
      b = md5_hh( b, c, d, a, x[i + 10], 23, - 1094730640 );
      a = md5_hh( a, b, c, d, x[i + 13], 4, 681279174 );
      d = md5_hh( d, a, b, c, x[i + 0], 11, - 358537222 );
      c = md5_hh( c, d, a, b, x[i + 3], 16, - 722521979 );
      b = md5_hh( b, c, d, a, x[i + 6], 23, 76029189 );
      a = md5_hh( a, b, c, d, x[i + 9], 4, - 640364487 );
      d = md5_hh( d, a, b, c, x[i + 12], 11, - 421815835 );
      c = md5_hh( c, d, a, b, x[i + 15], 16, 530742520 );
      b = md5_hh( b, c, d, a, x[i + 2], 23, - 995338651 );
      a = md5_ii( a, b, c, d, x[i + 0], 6, - 198630844 );
      d = md5_ii( d, a, b, c, x[i + 7], 10, 1126891415 );
      c = md5_ii( c, d, a, b, x[i + 14], 15, - 1416354905 );
      b = md5_ii( b, c, d, a, x[i + 5], 21, - 57434055 );
      a = md5_ii( a, b, c, d, x[i + 12], 6, 1700485571 );
      d = md5_ii( d, a, b, c, x[i + 3], 10, - 1894986606 );
      c = md5_ii( c, d, a, b, x[i + 10], 15, - 1051523 );
      b = md5_ii( b, c, d, a, x[i + 1], 21, - 2054922799 );
      a = md5_ii( a, b, c, d, x[i + 8], 6, 1873313359 );
      d = md5_ii( d, a, b, c, x[i + 15], 10, - 30611744 );
      c = md5_ii( c, d, a, b, x[i + 6], 15, - 1560198380 );
      b = md5_ii( b, c, d, a, x[i + 13], 21, 1309151649 );
      a = md5_ii( a, b, c, d, x[i + 4], 6, - 145523070 );
      d = md5_ii( d, a, b, c, x[i + 11], 10, - 1120210379 );
      c = md5_ii( c, d, a, b, x[i + 2], 15, 718787259 );
      b = md5_ii( b, c, d, a, x[i + 9], 21, - 343485551 );
      a = safe_add( a, olda );
      b = safe_add( b, oldb );
      c = safe_add( c, oldc );
      d = safe_add( d, oldd );
   }
   return Array( a, b, c, d );
}

//  ---------------------------------------

function md5_cmn( q, a, b, x, s, t )
{
   return safe_add( bit_rol( safe_add( safe_add( a, q ), safe_add( x, t ) ), s ), b );
}

//  ---------------------------------------

function md5_ff( a, b, c, d, x, s, t )
{
   return md5_cmn( ( b & c ) | ( ( ~ b ) & d ), a, b, x, s, t );
}

//  ---------------------------------------

function md5_gg( a, b, c, d, x, s, t )
{
   return md5_cmn( ( b & d ) | ( c & ( ~ d ) ), a, b, x, s, t );
}

//  ---------------------------------------

function md5_hh( a, b, c, d, x, s, t )
{
   return md5_cmn( b ^ c ^ d, a, b, x, s, t );
}

//  ---------------------------------------

function md5_ii( a, b, c, d, x, s, t )
{
   return md5_cmn( c ^ ( b | ( ~ d ) ), a, b, x, s, t );
}

//  ---------------------------------------

function safe_add( x, y )
{
   var lsw = ( x & 65535 ) + ( y & 65535 );
   var msw = ( x >> 16 ) + ( y >> 16 ) + ( lsw >> 16 );
   return ( msw << 16 ) | ( lsw & 65535 );
}

//  ---------------------------------------

function bit_rol( num, cnt )
{
   return ( num << cnt ) | ( num >>> ( 32 - cnt ) );
}

/*******************************************************************************************
 * MD5相关函数(End Script)
 *******************************************************************************************/


/*********************************************************************************************************************
 * 显示信息(Begin region)
 *********************************************************************************************************************/
//  ---------------------------------------
function ShowText( url, keyvalue, divid, hidId )
{
    var div = document.createElement( "DIV" );
    var frmShow = document.createElement( "<iframe frameborder=0 marginheight=0 width=100% marginwidth=0 scrolling=\"no\"></iframe>" );
    frmShow.id = frmShow.uniqueID + Math.random();
    frmShow.name = frmShow.id;
    div.appendChild( frmShow );
    div.style.display = "none";
    div.id = "div" + frmShow.uniqueID;
    document.body.appendChild( div );

    value = GetXmlHttpResult( url + keyvalue);
    value = value.substring(value.indexOf("<!--displayinfo-->") + 18);
    value = value.substring(0, value.indexOf("<!--displayinfo-->"));
    value = value.replace(/frametype=&quot;auto&quot;/igm, "");
    value = value.replace(/src/igm, "url");
    window.frames[frmShow.id].document.write( value );

    //ShowText( frmShow.id, divid, hidId );

    var doc = window.frames[frmShow.id].document;
    var divObj = document.getElementById( divid );
    var val = "";
    var obj = null;
    var objSrc = null;
    // 记录处理过的Jzinner
    var strJzinner = " ";
    for( i = 0; i < divObj.all.length; i = i + 1 )
    {
        obj = divObj.all.item( i );
        if( obj.tagName.toLowerCase() == "input" )
        {
            if(obj.id == "")
            {
                continue;
            }
            objSrc = doc.getElementById( obj.id );
            if(objSrc == null)
            {
                continue;
            }
            if( obj.type == "text" )
            {
                obj.value = objSrc.value;
            }
            else if( obj.type == "radio" )
            {
                obj.value = objSrc.value;
                obj.checked = objSrc.checked;
            }
            else if( obj.type == "checkbox" )
            {
                obj.value = objSrc.value;
                obj.checked = objSrc.checked;
            }
            else if( obj.type == "hidden" )
            {
                obj.value = objSrc.value;
            }
        }
        else if( obj.tagName.toLowerCase() == "select" )
        {
            if(obj.id == "")
            {
                continue;
            }
            objSrc = doc.getElementById( obj.id );
            if(objSrc == null)
            {
                continue;
            }
            for( j = 0; j < objSrc.options.length; j = j + 1 )
            {
                oOption = document.createElement( "OPTION" );
                obj.options.add( oOption );
                oOption.innerText = objSrc.options( j ).innerText;
                oOption.value = objSrc.options( j ).value;
            }
            obj.selectedIndex = objSrc.selectedIndex;
        }
        else if( obj.tagName.toLowerCase() == "img" )
        {
            if(obj.id == "")
            {
                continue;
            }
            objSrc = doc.getElementById( obj.id );
            if(objSrc == null)
            {
                continue;
            }
            obj.src = objSrc.url;
        }
        else if( obj.tagName.toLowerCase() == "textarea" )
        {
            if(obj.id == "")
            {
                continue;
            }
            objSrc = doc.getElementById( obj.id );
            if(objSrc == null)
            {
                continue;
            }
            obj.value = objSrc.value;
        }
        else if( obj.tagName.toLowerCase() == "span" )
        {
            if(obj.xml == undefined) // upload file
            {
                continue;
            }
            objSrc = doc.getElementById( obj.id );
            if(objSrc == null)
            {
                continue;
            }
            obj.innerHTML = objSrc.innerHTML;
        }
        else if(obj.tagName.toLowerCase() == "iframe")
        {
            tdDst = obj.parentElement;
            tdSrc = window.frames[frmShow.id].document.getElementById(obj.id);
            if(tdSrc == null) // 存在新加入iframe的情况
            {
                continue;
            }
            tdSrc = tdSrc.parentNode;
            if(strJzinner.indexOf(" " + tdSrc.id + " ") < 0)
            {
                strJzinner = strJzinner + tdSrc.id + " ";
            }
            else
            {
                continue;
            }
            
            var ifmLen = tdDst.children.length > tdSrc.children.length ? tdSrc.children.length : tdDst.children.length;
            for(kw1 = 0; kw1 < ifmLen; kw1 = kw1 + 1)
            {
                RemoveValidator(tdDst.children[kw1].count);
                tdDst.children[kw1].src = tdSrc.children[kw1].url;
            }
            
            if(tdDst.children.length < tdSrc.children.length) // 新的jzinner多些
            {
                for(kw1 = ifmLen; kw1 < tdSrc.children.length; kw1 = kw1 + 1)
                {
                    AddRecord(tdDst.id, tdSrc.children[kw1].url);
                }
            }
            else // 新的jzinner少些
            {                
                for(kw1 = ifmLen; kw1 < tdDst.children.length; kw1 = kw1 + 1)
                {
                    RemoveRecord(tdDst.id, tdDst.children[kw1].id);
                }
            }
            tdSrc = null;
            tdDst = null;
            // RemoveValidator(window.frames[obj.id].frameElement.count);
            // window.frames[obj.id].frameElement.src = window.frames[frmShow.id].frames[obj.id].frameElement.src;
        }
    }
    divObj.style.display = "block";
    document.getElementById( hidId ).value = calcMD5( divObj.innerHTML );

    document.body.removeChild(div);
    div = null;
    frmShow = null;
}

function RemoveValidator(count)
{
    if(count == undefined)
    {
        return;
    }
    var str = count.split(",");
    jzwin.Page_Validators.splice(parseInt(str[0], 10), parseInt(str[1], 10));
    index = parseInt(str[0], 10);
    // 删除记录的验证控件在数组Page_Validators中的起始位置
    num = parseInt(str[1], 10);
    // 删除记录的验证控件个数
    var fms = document.getElementsByTagName("IFRAME");
    for(k = 0; fms != null && k < fms.length; k = k + 1)
    {
        if(fms[k].frametype == "auto" && fms[k].count != undefined)
        {
            str = null;
            str = fms[k].count.split(",");
            if(index < parseInt(str[0], 10))
            {
                fms[k].count = (parseInt(str[0], 10) - num) + "," + str[1];
            }
        }
    }
}
/*
 * 对于Jzinner型控件, 需要ajax的效果. copy iframe时使用
 */
function AddRecord(id, url)
{
    var s = document.body.innerHTML;
    s = s.substring(s.indexOf("<!--" + id), s.length + 1);
    s = s.substring(id.length + 4, s.indexOf(id + "-->"));
    s = s.substring(s.indexOf("<iframe"), s.length + 1);
    s = s.substring(0, s.indexOf("</iframe>") + 9);
    var fm = document.createElement(s);
    fm.id = "ifm" + Math.random();
    fm.name = fm.id;
    var td = document.getElementById(id);
    if(td.children.length == 0)
    {
        fm.src = RemoveFromUrl(url, "isshow") + "&isshow=true";
    }
    else
    {
        fm.src = url;
    }
    td.appendChild(fm);
    s = null;
    fm = null;
    td = null;
}

/*
 * 对于Jzinner, 切换时, 删除掉多余的Jzinner
 */
function RemoveRecord(id, fmid)
{
    var td = document.getElementById(id);
    var fm = document.getElementById(fmid);
    RemoveValidator(fm.count);
    td.removeChild(fm);
    td = null;
    fm = null;
}

/********************************************************************************************************************
 * 显示信息(End region)
 ********************************************************************************************************************/


/********************************************************************************************************************
 * list显示页面相关的函数(Begin Script)
 ********************************************************************************************************************/
function CreateNew(objURL)
{
    document.location.href = objURL.value;
}
function MouseDoubleClick(objSel, objURL)
{
    return ShowDetail(objSel, objURL);
    //alert(obj.innerText);
}
function ShowDetail(objSel, objURL)
{
    if(objSel.value != "")
    {
        url = objURL.value;
        if(url.indexOf("?") > 0)
        {
            url = url + "&id=" + objSel.value;
        }
        else
        {
            url = url + "?id=" + objSel.value;
        }
        document.location.href = url;
    }
    else
    {
        alert("请选择一行!");
        return false;
    }
}
function ShowUpdate(objSel, objURL)
{
    return ShowDetail(objSel, objURL);
}
function Go2NextPage(obj, obj2)
{
    if(parseInt(obj.value) < parseInt(obj2.innerText))
    {
        obj.value = parseInt(obj.value) + 1;
        obj.onchange();
    }
}
function Go2PreviousPage(obj)
{
    if(1 < parseInt(obj.value))
    {
        obj.value = parseInt(obj.value) - 1;
        obj.onchange();
    }
}
function Go2FrontPage(obj)
{
    if(parseInt(obj.value) != 1)
    {
        obj.value = 1;
        obj.onchange();
    }
}
function Go2LastPage(obj, obj2)
{
    if(parseInt(obj.value) < parseInt(obj2.innerText))
    {
        obj.value = obj2.innerText;
        obj.onchange();
    }
}
function SetOrder(obj, obj2)
{
    tmp = event.srcElement.className.split(" ")[1];
    if(tmp != null && tmp.length > 0)
    {
        if(obj.value != null && obj.value.length > 0)
        {
            tmps = obj.value.split(" ");
            if(tmp == tmps[0])
            {
                if(tmps[1].toLowerCase() == "asc")
                {
                   obj.value = tmp + " Desc";
                }
                else
                {
                   obj.value = tmp + " Asc";
                }
            }
            else
            {
                obj.value = tmp + " Asc";
            }
        }
        else         
        {
            obj.value = tmp + " Asc";
        }
        obj2.onchange();
    }
}

function MouseEnter()
{
    obj = event.srcElement; //.parentElement;
    //alert(obj.style.backgroundColor);
    obj.style.backgroundColor = "#BADC0C";
    //obj.style.fontStyle = "italic";
    //obj.style.fontWeight ="bold";
    //alert(obj.bgColor);
}

function MouseLeave(objSel)
{
    obj = event.srcElement;
    if(obj.id.length > 0 && objSel.value == obj.id.substring(1) && objSel.value != "")
        return;
    obj.style.backgroundColor = "";
    //obj.style.fontStyle = "normal";
    //obj.style.fontWeight ="";
      
}

function MouseClick(objSel)
{
    obj = event.srcElement.parentElement;
    if(obj.previousSibling == null)
    {
        return;
    }
    if(obj.id.length > 0 && objSel.value != obj.id.substring(1))
    {
        var chk = obj.cells[0].all.tags( "input" );
        if ( chk.length > 0 && chk[0].type == "checkbox" )
        {
             chk[0].checked = true;
        }
        if(objSel.curObj != undefined)
        {
            chk = objSel.curObj.cells[0].all.tags( "input" );
            if ( chk.length > 0 && chk[0].type == "checkbox" )
            {
                 chk[0].checked = false;
            }
            objSel.curObj.style.backgroundColor = "";
        }
        objSel.value = obj.id.substring(1);
        objSel.curObj = obj;
    }
}

function CheckSelect(objSel)
{
    if(objSel.value == "")
    {
        alert("请选择一行!");
        return false;
    }
    return true;
}

function DeleteFromList(objSel)
{
    if(!CheckSelect(objSel))
    {
        return false;
    }
    if(window.confirm("确定删除当前选中行么?") == true)
    {
        str = window.location.href;
        if(str.indexOf("?") > 0)
        {
            strs = str.substring(str.indexOf("?")+1).split("&");
            if(strs.length != "undefined")
            {
                str = str.substring(0, str.indexOf("?")+1);
                for(i=0; i<strs.length; i++)
                {
                   if(strs[i] == "delete=true" || strs[i].indexOf("id=") == 0)
                       continue;
                   str = str + strs[i] + "&";
                }
            }
            str = str + "delete=true&id=" + objSel.value;
        }
        else
        {
            str = str + "?delete=true&id=" + objSel.value;
        }
        window.location.href = str;
    }
}

function DeleteFromSonList(objSel)
{
    if(!CheckSelect(objSel))
    {
        return false;
    }

    return window.confirm("确定删除当前选中行么?");
}

function Update(objSel)
{
    if(!CheckSelect(objSel))
    {
        return false;
    }
    else
    {
        return true;
    }
}

function Detail(objSel)
{
    return Update(objSel);
}

/* 定位到list页面，去删除数据
 *
 */
function Delete(url)
{
    if(window.confirm("确定删除当前记录么?") == true)
    {
        window.location.href = url;
        return true;
    }
    else
    {
        return false;
    }
} 
/********************************************************************************************************************
 * list显示页面相关的函数(End Script)
 ********************************************************************************************************************/


/********************************************************************************************************************
 * jz-status显示页面相关的函数(Begin Script)
 ********************************************************************************************************************/

function Confirm(s)
{
    var str = "确定" + s + "?";
    if(confirm(str))
    {
       return true;
    }
    else
    {
        return false;
    }
}

/********************************************************************************************************************
 * jz-status显示页面相关的函数(End Script)
 ********************************************************************************************************************/


/********************************************************************************************************************
 * 选择显示列左右、上下调整列时用到的函数(Begin Script)
 ********************************************************************************************************************/
function MoveRight(objl, objr)
{
    var sel1 = document.getElementById(objl);
    var sel2 = document.getElementById(objr);
    var i, j;
    var selIndex = sel1.selectedIndex;
    if (selIndex < 0) 
    {
        alert("请从左面选择一个选项!");
        return;
    }
    sel2.options[sel2.length] = new Option(sel1.options[sel1.selectedIndex].innerHTML, sel1.options[sel1.selectedIndex].value);
    
    for (i = selIndex; i < sel1.length - 1; i++) 
    {
        sel1.options[i].value = sel1.options[i + 1].value;
        sel1.options[i].innerHTML = sel1.options[i + 1].innerHTML;
    }
    sel1.length--;
}

//  ---------------------------------------

function MoveRightAll(objl, objr)
{
    var sel1 = document.getElementById(objl);
    var sel2 = document.getElementById(objr);
    var i, j;
    i = sel1.length;
    if (i == 0) 
    {
        alert("数据为空,不能移动!");
        return;
    }
    for (j = i - 1; j >= 0; j = j - 1) 
    {
        sel2.options.add(new Option(sel1.options[j].innerHTML, sel1.options[j].value), 0);
        sel1.length--;
    }
}

//  ---------------------------------------

function MoveLeft(objl, objr)
{
    var sel1 = document.getElementById(objl);
    var sel2 = document.getElementById(objr);
    var i, j;
    var selIndex = sel2.selectedIndex;
    if (selIndex < 0) 
    {
        alert("请从右面选择一个选项!");
        return;
    }
    sel1.options[sel1.length] = new Option(sel2.options[sel2.selectedIndex].innerHTML, sel2.options[sel2.selectedIndex].value);
    
    for (i = selIndex; i < sel2.length - 1; i = i + 1) 
    {
        sel2.options[i].value = sel2.options[i + 1].value;
        sel2.options[i].innerHTML = sel2.options[i + 1].innerHTML;
    }
    sel2.length--;
}

//  ---------------------------------------

function MoveLeftAll(objl, objr)
{
    var sel1 = document.getElementById(objl);
    var sel2 = document.getElementById(objr);
    var i, j;
    i = sel2.length;
    if (i == 0) 
    {
        alert("数据为空,不能移动!");
        return;
    }
    for (j = i - 1; j >= 0; j = j - 1) 
    {
        sel1.options.add(new Option(sel2.options[j].innerHTML, sel2.options[j].value), 0);
        sel2.length--;
    }
}

//  ---------------------------------------

function Up(objr)
{
    var sel = document.getElementById(objr);
    var i, j;
    var i = sel.selectedIndex;
    if (i < 0) 
    {
        alert("请选择要移动的项!");
        return;
    }
    if (i == 0) 
    {
        sel.selectedIndex = 0;
    }
    j = i - 1;
    if (i > 0) 
    {
        tmptext = sel.options[j].text;
        tmpvalue = sel.options[j].value;
        
        sel.options[j].text = sel.options[i].text;
        sel.options[j].value = sel.options[i].value;
        
        sel.options[i].text = tmptext;
        sel.options[i].value = tmpvalue;
        
        sel.selectedIndex = j;
    }
}

//  ---------------------------------------

function Down(objr)
{
    var i, j;
    var sel = document.getElementById(objr);
    i = sel.selectedIndex;
    
    if (i < 0) 
    {
        alert("请选择要移动的项!");
        return;
    }
    if (i != sel.length - 1) 
    {
        j = i + 1;
        if (i < sel.length) 
        {
            tmptext = sel.options[j].text;
            tmpvalue = sel.options[j].value;
            
            sel.options[j].text = sel.options[i].text;
            sel.options[j].value = sel.options[i].value;
            
            sel.options[i].text = tmptext;
            sel.options[i].value = tmpvalue;
            
            sel.selectedIndex = j;
        }
    }
    else 
    {
        sel.selectedIndex = sel.length - 1;
    }
}
//  ---------------------------------------
var curOption = new Option();
function swapOption( obj )
{
   if( curOption != null && curOption != obj.options[getIndex( obj )] && getIndex( obj ) > - 1 && getIndex( obj ) < obj.size )
      {
          curOption.swapNode( obj.options[getIndex( obj )] );
      }
}

//  ---------------------------------------


function getIndex( obj )
{
   var theIndex = Math.floor( ( event.offsetY + 2 ) / ( obj.offsetHeight / obj.size ) );
   if( theIndex < 0 ) theIndex = 0;
   else if( theIndex > obj.options.length ) theIndex = obj.options.length;
   return   theIndex;
}

//  ---------------------------------------

function showresult(objl, objr, hidobj)
{
    var i, j;
    var s = "";
    var inv = document.getElementById(objl);
    var vis = document.getElementById(objr);
    i = vis.length;
    if (i <= 0) 
    {
        alert("显示列为空,不能提交!");
        return false;
    }
    for (j = 0; j < i; j = j + 1) 
    {
        s = s + vis.options[j].value;
        s = s + " ";
    }
    s = s + ";";
    for (j = 0; j < inv.length; j = j + 1) 
    {
        s = s + inv.options[j].value;
        s = s + " ";
    }
    document.getElementById(hidobj).value = s;
//    window.opener = null;
//    window.close();
}
/********************************************************************************************************************
 * 选择显示列左右、上下调整列时用到的函数(End Script)
 ********************************************************************************************************************/


/********************************************************************************************************************
 * 显示农历(Begin Script)
 ********************************************************************************************************************/
function CalConv()
{
    FIRSTYEAR = 1998;
    LASTYEAR = 5000;
    
    today = new Date();
    SolarYear = today.getFullYear();
    SolarMonth = today.getMonth() + 1;
    SolarDate = today.getDate();
    Weekday = today.getDay();
    LunarCal = [new tagLunarCal(27, 5, 3, 43, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1), new tagLunarCal(46, 0, 4, 48, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1), /* 88 */ new tagLunarCal(35, 0, 5, 53, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1), /* 89 */ new tagLunarCal(23, 4, 0, 59, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1), new tagLunarCal(42, 0, 1, 4, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1), new tagLunarCal(31, 0, 2, 9, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0), new tagLunarCal(21, 2, 3, 14, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1), /* 93 */ new tagLunarCal(39, 0, 5, 20, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1), new tagLunarCal(28, 7, 6, 25, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1), new tagLunarCal(48, 0, 0, 30, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1), new tagLunarCal(37, 0, 1, 35, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1), /* 97 */ new tagLunarCal(25, 5, 3, 41, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1), new tagLunarCal(44, 0, 4, 46, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1), new tagLunarCal(33, 0, 5, 51, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1), new tagLunarCal(22, 4, 6, 56, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0), /* 101 */ new tagLunarCal(40, 0, 1, 2, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0), new tagLunarCal(30, 9, 2, 7, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1), new tagLunarCal(49, 0, 3, 12, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1), new tagLunarCal(38, 0, 4, 17, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0), /* 105 */ new tagLunarCal(27, 6, 6, 23, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1), new tagLunarCal(46, 0, 0, 28, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0), new tagLunarCal(35, 0, 1, 33, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0), new tagLunarCal(24, 4, 2, 38, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1), /* 109 */ new tagLunarCal(42, 0, 4, 44, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1), new tagLunarCal(31, 0, 5, 49, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0), new tagLunarCal(21, 2, 6, 54, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1), new tagLunarCal(40, 0, 0, 59, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1), /* 113 */ new tagLunarCal(28, 6, 2, 5, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0), new tagLunarCal(47, 0, 3, 10, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1), new tagLunarCal(36, 0, 4, 15, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1), new tagLunarCal(25, 5, 5, 20, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0), /* 117 */ new tagLunarCal(43, 0, 0, 26, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1), new tagLunarCal(32, 0, 1, 31, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0), new tagLunarCal(22, 3, 2, 36, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0)];
    /* 民國年每月之日數 all by www.qpsh.com */
    SolarCal = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    
    /* 民國年每月之累積日數, 平年與閏年 */
    SolarDays = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 396, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366, 397];
    
    if (SolarYear <= FIRSTYEAR || SolarYear > LASTYEAR) 
        return 1;
    sm = SolarMonth - 1;
    if (sm < 0 || sm > 11) 
        return 2;
    leap = GetLeap(SolarYear);
    if (sm == 1) 
        d = leap + 28;
    else 
        d = SolarCal[sm];
    if (SolarDate < 1 || SolarDate > d) 
        return 3;
    y = SolarYear - FIRSTYEAR;
    acc = SolarDays[leap * 14 + sm] + SolarDate;
    kc = acc + LunarCal[y].BaseKanChih;
    Kan = kc % 10;
    Chih = kc % 12;
    
    Age = kc % 60;
    if (Age < 22) 
        Age = 22 - Age;
    else 
        Age = 82 - Age;
    
    if (acc <= LunarCal[y].BaseDays) 
    {
        y--;
        LunarYear = SolarYear - 1;
        leap = GetLeap(LunarYear);
        sm += 12;
        acc = SolarDays[leap * 14 + sm] + SolarDate;
    }
    else 
        LunarYear = SolarYear;
    l1 = LunarCal[y].BaseDays;
    for (i = 0; i < 13; i++) 
    {
        l2 = l1 + LunarCal[y].MonthDays[i] + 29;
        if (acc <= l2) 
            break;
        l1 = l2;
    }
    LunarMonth = i + 1;
    LunarDate = acc - l1;
    im = LunarCal[y].Intercalation;
    if (im != 0 && LunarMonth > im) 
    {
        LunarMonth--;
        if (LunarMonth == im) 
            LunarMonth = -im;
    }
    if (LunarMonth > 12) 
        LunarMonth -= 12;
    var today = new Date();
    function initArray()
    {
        this.length = initArray.arguments.length
        for (var i = 0; i < this.length; i++) 
            this[i + 1] = initArray.arguments[i]
    }
    var d = new initArray("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
    // document.write("", today.getYear(), "年", today.getMonth() + 1, "月", today.getDate(), "日&nbsp;", d[today.getDay() + 1], "");
    
    months = ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"];
    
    days = ["初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十"];
    
    var showmsg = "今天是 " + today.getYear() + "年";
    if (today.getMonth() < 10) 
    {
        showmsg = showmsg ;//showmsg = showmsg+ "0" ;原代码
    }
    showmsg = showmsg + (today.getMonth() + 1) + "月";
    if (today.getDate() < 10) 
    {
        showmsg = showmsg + "0";
    }
    showmsg = showmsg + today.getDate() + "号" + " " + d[today.getDay() + 1] + " " + "农历" + months[LunarMonth - 1] + "月" + days[LunarDate - 1] + "   ";
    if (today.getHours() < 10) 
    {
        showmsg = showmsg + "0";
    }
    showmsg = showmsg + today.getHours() + "时";
    if (today.getMinutes() < 10) 
    {
        showmsg = showmsg + "0";
    }
    showmsg = showmsg + today.getMinutes() + "分";
    if (today.getSeconds() < 10) 
    {
        showmsg = showmsg + "0";
    }
    showmsg = showmsg + today.getSeconds() + "秒";
    document.getElementById("clock").innerHTML = showmsg;
    setTimeout("CalConv()", 1000);
    return 0;
}

/* 求此民國年是否為閏年, 返回 0 為平年, 1 為閏年 */
function GetLeap(year)
{
    if (year % 400 == 0) 
        return 1;
    else 
        if (year % 100 == 0) 
            return 0;
        else 
            if (year % 4 == 0) 
                return 1;
            else 
                return 0;
}

function tagLunarCal(d, i, w, k, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13)
{
    this.BaseDays = d;
    /* 到民国 1 月 1 日到农历正月初一的累积日数 */
    this.Intercalation = i;
    /* 闰月月份. 0 == 此年沒有闰月 */
    this.BaseWeekday = w;
    /* 此年民国1 月1 日为星期几再减 1 */
    this.BaseKanChih = k;
    /* 此年民国1 月1 日之干支序号减 1 */
    this.MonthDays = [m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13];
    /* 此農曆年每月之大小, 0 == 小月(29日), 1 == 大月(30日) */
}

/********************************************************************************************************************
 * 显示农历(Begin Script)
 ********************************************************************************************************************/
//List列表中的全选和全不选
function gvUnSelectAll( tableId )
{
  tmp = event.srcElement.className.toLowerCase();
  if ( tmp == "gridheadselect" )
  {
     var chks = document.getElementById(tableId).all.tags("input");
     var j = 0;
     if (event.srcElement.innerHTML == "全选")
     {
         event.srcElement.innerHTML = "不选";
         for(j = 0; j < chks.length; j = j + 1)
          {
             if (chks[j])
             {
                chks[j].checked = true;
              }
           }
     }
     else
     {
          event.srcElement.innerHTML = "全选";
          for(j = 0; j < chks.length; j = j + 1)
          {
             if (chks[j])
             {
                chks[j].checked = false;
              }
           }
      }
  }
}
//List列表中选中的记录ID
function CollSelectIds( tableId )
{
   var ids = "";
   var chks = document.getElementById(tableId).all.tags("input");
   var j = 0;
     for(j = 0; j < chks.length; j = j + 1)
     {
        if (chks[j] && chks[j].checked)
        {
            ids = ids + ";";
            ids = ids + chks[j].id.substring( chks[j].id.lastIndexOf( "k" ) + 1, chks[j].id.length + 1 )
        }
      }
    return ids.substring(1);
}

function DeleteSelFromList(tableId, url)
{
    var ids = CollSelectIds(tableId);
    if (ids == "") 
    {
        alert('请至少选择一行!');
        return false;
    }
    if (window.confirm("确定删除选中的" + ids.split(';').length + "行记录么?") == true) 
    {
        var b = true;
        msg = GetXmlHttpResult(url + ids);
        if(msg != "")
        {
            b = confirm(msg);
        }
        if (b) 
        {
            str = window.location.href;
            if (str.indexOf("?") > 0) 
            {
                strs = str.substring(str.indexOf("?") + 1).split("&");
                if (strs.length != "undefined") 
                {
                    str = str.substring(0, str.indexOf("?") + 1);
                    for (i = 0; i < strs.length; i++) 
                    {
                        if (strs[i] == "delete=true" || strs[i].indexOf("id=") == 0) 
                            continue;
                        str = str + strs[i] + "&";
                    }
                }
                str = str + "delete=true&id=" + ids;
            }
            else 
            {
                str = str + "?delete=true&id=" + ids;
            }
            window.location.href = str;
        }
    }
}
/********************************************************************************************************************************************************
 ***********************************************新增的代码放在此线之上***********************************************************************************
 ********************************************************************************************************************************************************/



/************************************************************************************************
 * Iframe 自适应
 ************************************************************************************************/
function iframeAutoFit()
{
    if(jzwin == null)
    {
        return;
    }

    if(window != parent)
    {
        var a = parent.document.getElementsByTagName("IFRAME");
        for(var i = 0; i < a.length; i ++ ) // author : meizz
        {
            if(a[i].contentWindow == window)
            {
                var h1 = 0, h2 = 0, d = document, dd = d.documentElement;
                if(a[i].frametype == "auto")
                {
                    a[i].parentNode.style.height = a[i].offsetHeight + "px";
                    a[i].style.height = "0px";
                }

                if(dd && dd.scrollHeight)
                {
                    h1 = dd.scrollHeight;
                }

                if(d.body)
                {
                    h2 = d.body.scrollHeight;
                }

                var h = Math.max(h1, h2);

                if(a[i].frametype == "auto")
                {
                    a[i].style.height = a[i].parentNode.style.height = h + "px";

                    if(a[i].contentWindow["Page_Validators"] != null)
                    {
                        for(m = 0; m < a[i].contentWindow.Page_Validators.length;
                        m = m + 1)
                        {
                            if(jzwin.Page_Validators == undefined)
                            {
                                jzwin.Page_Validators = new Array();
                            }
                            jzwin.Page_Validators.push(a[i].contentWindow.Page_Validators[m]);
                        }
                        // count : 记录需验证的控件个数
                        window.frameElement.count = (jzwin.Page_Validators.length - m) + "," + m;
                    }
                }
            }
        }
    }
}

/************************************************************************
 * 释放javascript内存(Begin region)
 ************************************************************************/
function Release()
{
    jzwin = null;
    CollectGarbage();
}
/************************************************************************
 * 释放javascript内存(End region)
 ************************************************************************/

if(window.attachEvent)
{
    window.attachEvent("onload",  iframeAutoFit);
    window.attachEvent("onunload",  Release);
    // window.attachEvent("onresize",  iframeAutoFit);
}
else if(window.addEventListener)
{
    window.addEventListener('load',  iframeAutoFit,  false);
    window.addEventListener('unload',  Release,  false);
    // window.addEventListener('resize',  iframeAutoFit,  false);
}

/*
 * 输入框中敲回车, 自动跳到下一个可输入框
 */
function KeyDown()
{
    var tag = event.srcElement.tagName;
    var tp = event.srcElement.type;
    var key = event.keyCode;
    if (tag.localeCompare("input") == 1) 
    {
        if (event.altKey) 
        {
            if (key == 13) 
            {
                switch (tp)
                {
                    //-----button、submit、reset时按住ALT+ENTER则实现单击
                    case "button":
                    case "submit":
                    case "reset":
                        event.srcElement.click();
                        break;
                    default:
                }
            }
        }
        switch (key)
        {
            case 13:
                switch (tp)
                {
                    case "text":
                        if (event.srcElement.onkeyup != null) 
                        {
                            event.srcElement.onkeyup();
                        }
                    case "password":
                    case "checkbox":
                    case "radio":
                    case "button":
                    case "select-one":
                    case "select-multiple":
                    case "submit":
                    case "reset":
                        event.keyCode = 9;
                        break;
                    //--------以上为回车键跳到下一个控件   
                    default:
                }
                break;
            default:
        }
    }
    if(tag.localeCompare("textarea") == 1) 
    {
        if(key == 13)
        {
            //----------textarea按住Shift + enter 换行
            if(event.srcElement.jump == "no")
            {
                event.keyCode = 13;
                event.returnValue = false;
            }
            else if(!event.shiftKey)
            {
                event.keyCode = 9;
            }
        }
    }
    
    if(key == 13) 
    {
        JzwHideSelectDiv();
        window["enter"] = event.srcElement;
    }
}

/*****************************************************************************************************
 * 登录相关的函数(Begin Script)
 *****************************************************************************************************/
function LoginOpen(val)
{
    var result = val.split(" ");
    // alert(result);
    if((result.length == 1 && result[0] == "true") || result[1] == "true")
    {
        if(result.length == 2)
        {
            alert(result[0]);
            // 即将过期提醒
        }
        var obj = window.open("HomePage.aspx", "_blank", "toolbar=no,menubar=no,location=no,resizable=no,status=yes,scroll=no,", false);
        //var obj = null;
        if(obj != null)
        {
            obj.document.onreadystatechange = function()
            {
                window.opener = null;
                window.close();
                obj.document.onreadystatechange = null;
                obj = null;
            }
        }
        else
        {
            return;
        }
    }
    else
    {
        if(result.length == 1)
        {
            alert("用户名或密码错误, 请重新登录!");
        }
        else if(result.length == 2 && result[1] == "false")
        {
            alert(result[0]);
            // 密码过期
        }
        else
        {
            alert("内部错误, 请关闭网页重新登陆！");
        }
    }
}

function KeyD(obj)               //// 登录时按下回车键
{
    var name = "jztxtName";
    var pwd = "jztxtPwd";
    var login = "imgbLogin"
    if (event.keyCode == 13)
    {
        if (document.getElementById(obj).name == name)
        {
            document.getElementById(pwd).focus();
        }
        if (document.getElementById(obj).name == pwd)
        {
            document.getElementById(login).click();
        }
    }
}
/*****************************************************************************************************
 * 登录相关的函数(End Script)
 *****************************************************************************************************/

