
function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr;
    for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) {
        x.src = x.oSrc;
    }
}
function MM_preloadImages() { //v3.0
    var d = document;
    if (d.images) {
        if (!d.MM_p) {
            d.MM_p = new Array();
        }
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments;
        for (i = 0; i < a.length; i++) {
            if (a[i].indexOf("#") != 0) {
                d.MM_p[j] = new Image;
                d.MM_p[j++].src = a[i];
            }
        }
    }
}
function MM_findObj(n, d) { //v4.0
    var p, i, x;
    if (!d) {
        d = document;
    }
    if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document;
        n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) {
        x = d.all[n];
    }
    for (i = 0; !x && i < d.forms.length; i++) {
        x = d.forms[i][n];
    }
    for (i = 0; !x && d.layers && i < d.layers.length; i++) {
        x = MM_findObj(n, d.layers[i].document);
    }
    if (!x && document.getElementById) {
        x = document.getElementById(n);
    }
    return x;
}
function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments;
    document.MM_sr = new Array;
    for (i = 0; i < (a.length - 2); i += 3) {
        if ((x = MM_findObj(a[i])) != null) {
            document.MM_sr[j++] = x;
            if (!x.oSrc) {
                x.oSrc = x.src;
            }
            x.src = a[i + 2];
        }
    }
}
function setParticipant(vParticipants, globalParticipants) {
    var ap = vParticipant.split(",");
    var av = global_participant.split(",");
    for (var i = 0; i < ap.length; i++) {
        subAp = ap[i];
        if (av[i] == null || isBlank(av[i])) {
            return false;
        } else {
            document.forms[0].elements[subAp].value = av[i];
        }
    }
    return true;
}
function mySubmitWithArgs(vParticipants, globalParticipants) {
    if (!setParticipant(vParticipants, globalParticipants)) {
        return false;
    }
    if (!verify()) {
        return false;
    }
    document.forms[0].submit();
    return true;
}
function mySubmit() {
    if (!verify()) {
        return false;
    }
    setParticipantVar();
    document.forms[0].submit();
    return true;
}
function myReset() {
    document.forms[0].reset();
    return true;
}
function isBlank(s) {
    for (var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != "") && (c != " ") && (c != "\n") && (c != "\t")) {
            return false;
        }
    }
    return true;
}
function verify2() {
    var f = document.forms[0];
    var msg;
    var empty_fields = "";
    var errors = "";
	//遍历所有的表单元素,查找所定义了mustFill属性的text以及textarea元素,检查是否为空,
	//另外,如果元素定义了numeric属性,则检查其是否为数字,如果定义了min以及max属性,则检查其是否
	//在范围中,最后把有错误的字段的错误信息集中在一起提示
	//另外也检查日期时间的有效性
    for (var i = 0; i < f.length; i++) {
        var e = f.elements[i];
        if (((e.type == "text") || (e.type == "textarea"))) {
            var len = 0;
            var str = "";
            if (e.value != null) {
                str = e.value;
            }
            for (var j = 0; j < str.length; j++) {
                len = len + ((str.charCodeAt(j) < 255) ? 1 : 2);
            }

            if (len > e.maxLength) {
                if (e.promptName == null) {
                    errors = "\n" + errors + e.value + "\u8d85\u51fa\u957f\u5ea6\u9650\u5236\uff0c\u5305\u542b\u6c49\u5b57\u7684\u5b57\u7b26\u53ea\u80fd\u4e3a" + parseInt(e.maxLength/2) + "\u4f4d!";
                } else {
                    errors = "\n" + errors + e.promptName + "\u8d85\u51fa\u957f\u5ea6\u9650\u5236\uff0c\u5305\u542b\u6c49\u5b57\u7684\u5b57\u7b26\u53ea\u80fd\u4e3a" + parseInt(e.maxLength/2) + "\u4f4d!";
                }
            }
            if (e.mustFill) {
                if ((e.value == null) || (e.value == "") || isBlank(e.value)) {
                    if (e.promptName) {
                        empty_fields = empty_fields + "\n" + e.promptName + "\u4e0d\u5141\u8bb8\u4e3a\u7a7a!";
                    } else {
                        empty_fields = empty_fields + "\n" + e.name + "\u4e0d\u5141\u8bb8\u4e3a\u7a7a!";
                    }
                }
            }
            if (e.numeric && (e.min != null) && (e.max != null)) {
                if (!isBlank(e.value)) {
                    var v = parseFloat(e.value);

					//if(isNaN(v)){
                    if (!_IsFloat(e.value)) {
                        errors = "\n" + errors + e.promptName + "\u5e94\u8be5\u662f\u6570\u5b57!";
                    } else {
                        if ((e.min != null) && (v < e.min)) {
                            errors += "\n" + e.promptName + "\u5e94\u8be5\u4e0d\u5c0f\u4e8e" + e.min;
                        } else {
                            if ((e.max != null) && (v > e.max)) {
                                errors += "\n" + e.promptName + "\u5e94\u8be5\u4e0d\u5927\u4e8e" + e.max;
                            }
                        }
                    }
                }
            }
            if (e.isDate) {
                if (!isBlank(e.value)) {
                    var v = e.value;
                    var vResult = dateverify(v, "");
                    if (vResult == "") {
                        errors += "\n" + e.promptName + "\u65e5\u671f\u4e0d\u5408\u6cd5\uff01";
                    } else {
                        e.value = vResult;
                    }
                }
            }
            if (e.isDateTime) {
                if (!isBlank(e.value)) {
                    var v = e.value;
                    var vResult = dateverify(v, "yyyy-mm-dd hh:nn");
                    if (vResult == "") {
                        errors += "\n" + e.promptName + "\u65e5\u671f\u4e0d\u5408\u6cd5\uff01";
                    } else {
                        e.value = vResult;
                    }
                }
            }
        }
    }
    if (!empty_fields && !errors) {
        return true;
    }
    msg = "";
    if (empty_fields) {
        msg += empty_fields + "\n";
    }
    if (errors) {
        msg += errors;
    }
    alert(msg);
    return false;
}


function verify(frm) {
    var f = document.forms[0];
	if(frm!=null){
		f = frm;
	}
    var msg;
    var empty_fields = "";
    var errors = "";
	//遍历所有的表单元素,查找所定义了mustFill属性的text以及textarea元素,检查是否为空,
	//另外,如果元素定义了numeric属性,则检查其是否为数字,如果定义了min以及max属性,则检查其是否
	//在范围中,最后把有错误的字段的错误信息集中在一起提示
	//另外也检查日期时间的有效性

    for (var i = 0; i < f.length; i++) {
        var e = f.elements[i];
        if (((e.type == "text") || (e.type == "textarea")||(e.type=="select-one"))) {
            var len = 0;
            var str = "";

            if (e.value != null) {
                str = Trim(e.value);
            }
			/*
            for (var j = 0; j < str.length; j++) {
                len = len + ((str.charCodeAt(j) < 255) ? 1 : 2);
            }
			*/
			/*
            if (len > e.maxLength) {
                if (e.promptName == null) {
                    errors = "\n" + errors + e.name + "\u8d85\u51fa\u957f\u5ea6\u9650\u5236\uff0c\u5305\u542b\u6c49\u5b57\u7684\u5b57\u7b26\u53ea\u80fd\u4e3a" + parseInt(e.maxLength/2) + "\u4f4d!";
                } else {
                    errors = "\n" + errors + e.promptName + "\u8d85\u51fa\u957f\u5ea6\u9650\u5236\uff0c\u5305\u542b\u6c49\u5b57\u7684\u5b57\u7b26\u53ea\u80fd\u4e3a" + parseInt(e.maxLength/2) + "\u4f4d!";
                }
            }
			*/
            if (e.mustFill) {
                if ((e.value == null) || (e.value == "") || isBlank(e.value)) {
                    if (e.promptName) {
                        empty_fields = empty_fields + "\n" + e.promptName + "\u4e0d\u5141\u8bb8\u4e3a\u7a7a!";
                    } else {
                        empty_fields = empty_fields + "\n" + e.name + "\u4e0d\u5141\u8bb8\u4e3a\u7a7a!";
                    }
                    //break;
                }
            }
			/*
            if (e.numeric && (e.min != null) && (e.max != null)) {
                if (!isBlank(e.value)) {
                    var v = parseFloat(e.value);

					//if(isNaN(v)){
                    if (!_IsFloat(e.value)) {
                        errors = "\n" + errors + e.promptName + "\u5e94\u8be5\u662f\u6570\u5b57!";
                    } else {
                        if ((e.min != null) && (v < e.min)) {
                            errors += "\n" + e.promptName + "\u5e94\u8be5\u4e0d\u5c0f\u4e8e" + e.min;
                        } else {
                            if ((e.max != null) && (v > e.max)) {
                                errors += "\n" + e.promptName + "\u5e94\u8be5\u4e0d\u5927\u4e8e" + e.max;
                            }
                        }
                    }
                }
            }
            if (e.isDate) {
                if (!isBlank(e.value)) {
                    var v = e.value;
                    var vResult = dateverify(v, "");
                    if (vResult == "") {
                        errors += "\n" + e.promptName + "\u65e5\u671f\u4e0d\u5408\u6cd5\uff01";
                    } else {
                        e.value = vResult;
                    }
                }
            }
            if (e.isDateTime) {
                if (!isBlank(e.value)) {
                    var v = e.value;
                    var vResult = dateverify(v, "yyyy-mm-dd hh:nn:ss");
                    if (vResult == "") {
                        errors += "\n" + e.promptName + "\u65e5\u671f\u4e0d\u5408\u6cd5\uff01";
                    } else {
                        e.value = vResult;
                    }
                }
            }
			*/

        }
    }

    if (!empty_fields && !errors) {
        return true;
    }
    msg = "";
    if (empty_fields) {
        msg += empty_fields + "\n";
    }
    if (errors) {
        msg += errors;
    }

    alert(msg);
    return false;
}

//IsFloat函数判断一个字符串是否由数字(int or long or float)组成
function _IsFloat(str) {
    flag_Dec = 0;
    for (ilen = 0; ilen < str.length; ilen++) {
        if (str.charAt(ilen) == ".") {
            flag_Dec++;
            if (flag_Dec > 1) {
                return false;
            } else {
                continue;
            }
        }
        if (str.charAt(ilen) < "0" || str.charAt(ilen) > "9") {
            return false;
        }
    }
    return true;
}
function montharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11) {
    this[0] = m0;
    this[1] = m1;
    this[2] = m2;
    this[3] = m3;
    this[4] = m4;
    this[5] = m5;
    this[6] = m6;
    this[7] = m7;
    this[8] = m8;
    this[9] = m9;
    this[10] = m10;
    this[11] = m11;
}
//日期的合法性判断，如果日期合法，返回经过处理的日期（yyyy-mm-dd或者yyyy-MM-dd hh:mm:ss）如果不合法，则返回空串
function dateverify(date, format) {
    var format, dateString;
    var tmpString;
    var interString;
    var formatString = "ymdhns";
    interString = "";
    if (format == null || format == "") {
        format = "yyyy-mm-dd";
    }
    for (i0 = 0; i0 < format.length; i0++) {
        if (formatString.indexOf(format.charAt(i0)) == -1) {
            interString = interString + format.charAt(i0);
        }
    }
    interString = interString + interString.charAt(0);
    format = format + interString.charAt(0);
    date = date + interString.charAt(0);
    year = 0;
    month = 0;
    day = 0;
    hour = 1;
    min = 1;
    sec = 1;
    dateString = "";
    oldIndex = 0;
    oldIndex0 = 0;
    newIndex = 0;
    for (i0 = 0; i0 < interString.length; i0++) {
        tmpString0 = "";
        tmpString = "";
        newIndex = date.indexOf(interString.charAt(i0), oldIndex);
        if (newIndex != -1) {
            tmpString = date.substring(oldIndex, newIndex);
            oldIndex = newIndex + 1;
            newIndex = format.indexOf(interString.charAt(i0), oldIndex0);
            for (j = 0; j < newIndex - oldIndex0 - tmpString.length; j++) {
                tmpString0 = tmpString0 + "0";
            }
            if (tmpString.length < (newIndex - oldIndex0)) {
                tmpString = tmpString0 + tmpString;
            }
            if (tmpString.length > (newIndex - oldIndex0)) {
                tmpString = "0";
            }
            dateString = dateString + tmpString;
            if (i0 < interString.length - 1) {
                dateString = dateString + interString.charAt(i0);
            }
            if (format.charAt(newIndex - 1) == "y") {
                year = parseInt(tmpString, 10);
            }
            if (format.charAt(newIndex - 1) == "m") {
                month = parseInt(tmpString, 10);
            }
            if (format.charAt(newIndex - 1) == "d") {
                day = parseInt(tmpString, 10);
            }
            if (format.charAt(newIndex - 1) == "h") {
                hour = parseInt(tmpString, 10);
            }
            if (format.charAt(newIndex - 1) == "n") {
                min = parseInt(tmpString, 10);
            }
            if (format.charAt(newIndex - 1) == "s") {
                sec = parseInt(tmpString, 10);
            }
            oldIndex0 = newIndex + 1;
        } else {
            year = 0;
        }
    }
    var monthDays = new montharr(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
        monthDays[1] = 29;
    }
    if (month < 1 || month > 12) {
        dateString = "";
    } else {
        if (day < 1 || day > monthDays[month - 1]) {
            dateString = "";
        } else {
            if (year < 1) {
                dateString = "";
            } else {
                if (hour < 0 || hour > 23) {
                    dateString = "";
                } else {
                    if (min < 0 || min > 59) {
                        dateString = "";
                    } else {
                        if (sec < 0 || sec > 59) {
                            dateString = "";
                        }
                    }
                }
            }
        }
    }
    return dateString;
}

//设置是否选参与者的变量
function setParticipantVar() {
    if (document.forms[0].mustSelectParticipant == null) {
        return;
    }
    if (document.forms[0].activity_goto_where == null) {
        return;
    }
    if (document.forms[0].activitySelect == null) {
        return;
    }
    if (document.forms[0].mustSelectParticipant == null) {
        return;
    }
    var i = document.forms[0].activity_goto_where.selectedIndex;
    var a = document.forms[0].activity_goto_where.options[i].value;
    var b = document.forms[0].activitySelect.value;
    if (b.indexOf(a) >= 0) {
        document.forms[0].mustSelectParticipant.value = "true";
    } else {
        document.forms[0].mustSelectParticipant.value = "false";
    }
//	alert(document.forms[0].mustSelectParticipant.value);
}
function verifytxt(e) {
    var msg;
    var empty_fields = "";
    var errors = "";
    if (((e.type == "text") || (e.type == "textarea"))) {
        if (e.mustFill == true) {
            if ((e.value == null) || (e.value == "") || isBlank(e.value)) {
                if (e.promptName) {
                    empty_fields = empty_fields + "\n" + e.promptName + "\u4e0d\u5141\u8bb8\u4e3a\u7a7a!";
                } else {
                    empty_fields = empty_fields + "\n" + e.name + "\u4e0d\u5141\u8bb8\u4e3a\u7a7a!";
                }
            }
        }
        if (e.numeric == true && (e.min != null) && (e.max != null)) {
            if (!isBlank(e.value)) {
                var v = parseFloat(e.value);
                if (isNaN(v)) {
                    errors = "\n" + errors + e.promptName + "\u5e94\u8be5\u662f\u6570\u5b57!";
                } else {
                    if ((e.min != null) && (v < e.min)) {
                        errors += "\n" + e.promptName + "\u5e94\u8be5\u4e0d\u5c0f\u4e8e" + e.min;
                    } else {
                        if ((e.max != null) && (v > e.max)) {
                            errors += "\n" + e.promptName + "\u5e94\u8be5\u4e0d\u5927\u4e8e" + e.max;
                        }
                    }
                }
            }
        }
        if (e.isDate == true) {
            if (!isBlank(e.value)) {
                var v = e.value;
                var vResult = dateverify(v, "");
                if (vResult == "") {
                    errors += "\n" + e.promptName + "\u65e5\u671f\u4e0d\u5408\u6cd5\uff01";
                } else {
                    e.value = vResult;
                }
            }
        }
        if (e.isDateTime == true) {
            if (!isBlank(e.value)) {
                var v = e.value;
                var vResult = dateverify(v, "yyyy-mm-dd hh:nn:ss");
                if (vResult == "") {
                    errors += "\n" + e.promptName + "\u65e5\u671f\u4e0d\u5408\u6cd51\uff01";
                } else {
                    e.value = vResult;
                }
            }
        }
    }
    if (!empty_fields && !errors) {
        return true;
    }
    msg = "";
    if (empty_fields) {
        msg += empty_fields + "\n";
    }
    if (errors) {
        msg += errors;
    }
    alert(msg);
    return false;
}
function get_time_spent() {
    var time_start = new Date();
    var clock_start = time_start.getTime();
    var time_now = new Date();
    return ((time_now.getTime() - clock_start) / 1000);
}
function show_secs() {
    var i_total_secs = Math.round(get_time_spent());
    var i_secs_spent = i_total_secs % 60;
    var i_mins_spent = Math.round((i_total_secs - 30) / 60);
    var s_secs_spent = "" + ((i_secs_spent > 9) ? i_secs_spent : "0" + i_secs_spent);
    var s_mins_spent = "" + ((i_mins_spent > 9) ? i_mins_spent : "0" + i_mins_spent);
    document.srctecstaytime.time_spent.value = s_mins_spent + ":" + s_secs_spent;
    window.setTimeout("show_secs()", 1000);
}
function xzry(cdz) {
    var pvalue = cdz.value;
    var tag = (cdz.name.indexOf("xm") != -1) ? "0" : "2";
    var str = this.showModalDialog("../ggmk/ggmk_rylbjk.jsp?value=" + pvalue + "&tag=" + tag + "&rec=1", "", "help:0;status:0;scroll:1;center:1;edge:sunken");
    var strArr = str.split(",");
    if (strArr.length > 1) {
        if (tag == "0") {
            document.forms[0]._ryxh.value = strArr[0];
            cdz.value = strArr[1];
        } else {
            cdz.value = strArr[0];
            for (var i = 0; i < document.forms[0].elements.length; i++) {
                var xmk = document.forms[0].elements[i];
                if (xmk.name.toLowerCase().indexOf("xm") != -1) {
                    xmk.value = strArr[1];
                    break;
                }
            }
        }
    }
    return false;
}
function selectperson(cdz) {
    var code = window.event.keyCode;
    if ((code == 13) || (code == 32)) {
        window.event.keyCode = 0;
        xzry(cdz);
    }
}

//-------------------------------------------add files------------------------------------------------------------------
var currFocus;
var ExistAttaInfo = new Array();
var oldDelAttas = new Array();
var attaIdx = 0;
var IsIE;
function fInitMSIE() {
    if (navigator.userAgent.indexOf("MSIE") != -1) {
        IsIE = true;
    } else {
        IsIE = false;
    }
}
fInitMSIE();


// 增加附件函数 ()，增加到 idfilespan,基数为 attaIdx 。
function add() {
    addfile("idfilespan", attaIdx);
    attaIdx++;
    return false;
}
function addfile(spanId, index) {
    var strIndex = "" + index;
    var fileId = "attachfile" + strIndex;
    var brId = "idAttachBr" + strIndex;
    addInputFile(spanId, fileId);
    adddel(spanId, index);
    addbr(spanId, brId);
	   //document.getElementById( "attachfile"+ strIndex).click();
    return;
}
function addInputFile(spanId, fileId) {
    var span = document.getElementById(spanId);
    if (span != null) {
        if (!IsIE) {
            var fileObj = document.createElement("input");
            if (fileObj != null) {
                fileObj.type = "\"file\"";
                fileObj.name = fileId;
                fileObj.id = fileId;
                fileObj.size = "50";
                var clickEvent = "exist('" + fileId + "')";
                fileObj.setAttribute("onclick", clickEvent, 0);
                span.appendChild(fileObj);
            }//if fileObj
        }// !IsIE
        if (IsIE) {
            var fileTag = "<input type=\"file\" id ='" + fileId + "' name='" + fileId + "' size=50 onchange=exist('" + fileId + "')>";
            var fileObj = document.createElement(fileTag);
            span.appendChild(fileObj);
        }//IsIE if
    }//if span
}
function addbr(spanId, brId) {
    var span = document.getElementById(spanId);
    if (span != null) {
        var brObj = document.createElement("br");
        if (brObj != null) {
            brObj.name = brId;
            brObj.id = brId;
            span.appendChild(brObj);
        }//if
    }//if
    return;
}
function adddel(spanId, index) {
    var strIndex = "" + index;
    var delId = "idAttachOper" + strIndex;
    var span = document.getElementById(spanId);
    if (span != null) {
        var oTextNode = document.createElement("SPAN");
        oTextNode.style.width = "5px";
        span.appendChild(oTextNode);
        if (IsIE) {
            var tag = "<input type='button' id='" + delId + "' onclick=delfile('" + spanId + "'," + strIndex + ")></input>";
            var delObj = document.createElement(tag);
            if (delObj != null) {
                span.appendChild(delObj);
            }//if
        }// Is IE
        if (!IsIE) {
            var delObj = document.createElement("input");
            if (delObj != null) {
                delObj.name = delId;
                delObj.id = delId;
                delObj.type = "button";
                var clickEvent = "return delfile('" + spanId + "'," + strIndex + ");";
                delObj.setAttribute("onclick", clickEvent);
                span.appendChild(delObj);
            }//if
        }// !IsIE if
        if (delObj != null) {
            delObj.value = "\u5220\u9664";
        }
    }//main if
    return;
}
function delfile(spanId, index) {
    var strIndex = "" + index;
    var fileId = "attachfile" + strIndex;
    var brId = "idAttachBr" + strIndex;
    var delId = "idAttachOper" + strIndex;
	   //first,get the element
    var span = document.getElementById(spanId);
	   //alert(  "del span: " + span  );
    if (span == null) {
        return false;
    }
    var fileObj = document.getElementById(fileId);
    if (fileObj == null) {
        return false;
    }
    var brObj = document.getElementById(brId);
    if (brObj == null) {
        return false;
    }
    var delObj = document.getElementById(delId);
	   //alert(  "del delId: " + delObj  );
    if (delObj == null) {
        return false;
    }

       //second,create the replace element
    var temp = document.createElement("SPAN");
	   //third,replace it
    span.replaceChild(temp, fileObj);
    span.replaceChild(temp, brObj);
		// Added by Harry, Repair Remove attached bug 2005/04/04
    span.removeChild(delObj.previousSibling);
    var attach = document.getElementById("attach");
    if (span.getElementsByTagName("INPUT").length == 1) {
        attach.childNodes[0].nodeValue = "\u6dfb\u52a0\u9644\u4ef6";
    }
		// End
    span.replaceChild(temp, delObj);
    return false;
}
//---------------------------------------------add files-----------------------------------------------
//--------------------------------------------date control-------------------------------------------
var g_bIsIE = (navigator.appVersion.indexOf("MSIE") > -1) ? true : false;
var g_wndSub;
var g_nCtrlCount = 0;
var g_ctrlSelected;
var dtDefault;
var dtNow = new Date();
dtDefault = dtNow.getFullYear() + "-" + ((dtNow.getMonth() + 1) >= 10 ? (dtNow.getMonth() + 1) : "0" + (dtNow.getMonth() + 1)) + "-" + (dtNow.getDate() >= 10 ? dtNow.getDate() : "0" + dtNow.getDate());
function DateInput_onclick(formEmbeded, strFieldName) {
    alert("test b");
    eval("g_ctrlSelected=formEmbeded." + strFieldName + ";");
    var strFeatures = "toolbar=no,menubar=no,scrollbar=no,resizable=no,location=no" + (g_bIsIE ? ",width=200,height=200" : ",width=220,height=200");
    g_wndSub = window.open("../js/Calendar2.htm", "Calendar", strFeatures, false);
    g_wndSub.focus();
}
function DateInputInner_onclick(formEmbeded, strFieldName) {
    eval("g_ctrlSelected=formEmbeded." + strFieldName + ";");
    DivCalendar.style.left = document.body.scrollLeft + (document.body.clientWidth - 201) / 2;
    DivCalendar.style.top = document.body.scrollTop + (document.body.clientHeight - 70) / 2;
    DivCalendar.style.visibility = "visible";
    TabCalendar.style.visibility = "visible";
    IFCalendar.opener = this;
    IFCalendar.initDate();
}
function clearvalue() {
    g_ctrlSelected.value = "";
    hideInnerCalendar();
}
function setDateFieldValue(NewValue) {
    g_ctrlSelected.value = NewValue;
}
function getDateFieldValue() {
    return g_ctrlSelected.value;
}
var g_bInnerCalenderCreated = false;
function insertDateInputCtrlImpl(sType, strLabel, strName, strDefault, bShowButton, sWidth) {
	//this
    if (strLabel == null) {
        strLabel = "\u65e5\u671f";
    }
    if (strName == null) {
        strName = "DateInputCtrlName" + g_nCtrlCount++;
    }
    if (strDefault == null) {
        var dtNow = new Date();
        strDefault = dtDefault;
    }
    if (bShowButton == null) {
        bShowButton = true;
    }
    var strProcessor;
    if (sType == "simple") {
        strProcessor = "DateSimpleInput_onclick";
    } else {
        if (sType == "complex") {
            strProcessor = "DateInput_onclick";
        } else {
            if (sType == "inner") {
                strProcessor = "DateInputInner_onclick";
                if (g_bInnerCalenderCreated == false) {
                    g_bInnerCalenderCreated = true;
                    document.writeln("<div id=DivCalendar style='POSITION: absolute;VISIBILITY: hidden'>\n" + "<table id=TabCalendar border=1 bgcolor='lightblue' style='VISIBILITY: hidden'>\n" + "<TR><TH width='88%' bgcolor='darkblue' style='COLOR: white ' align=left>\u65e5\u5386</TH>\n" + "<TH align=right width='12%'><img src='/mlnoa/img/refuse.gif' onclick='return hideInnerCalendar();' alt='\u5173\u95ed' style='cursor:hand;'></TH></TR>\n" + "<tr align=center><TH colspan=2><IFRAME id=IFCalendar align=center src='/mlnoa/pages/common/calendar.htm' frameborder=1 width=200 height=212></IFRAME></TH></tr></table></div>");
                }
            }
        }
    }
    if (sWidth == null) {
        document.writeln(strLabel + "<INPUT onfocus='return " + strProcessor + "( this.form,\"" + strName + "\")' ID='" + strName + "' NAME='" + strName + "' VALUE='" + strDefault + "'  class='text'>");
    } else {
        document.writeln(strLabel + "<INPUT style='width:" + sWidth + ";' onfocus='return DateInputInner_onclick( this.form,\"" + strName + "\")' ID='" + strName + "' NAME='" + strName + "' VALUE='" + strDefault + "'  class='text'>");
    }
    if (bShowButton == true) {
        document.writeln("<INPUT ID='InteleInput' NAME='InteleInput' type='button'" + " VALUE='\u667a\u80fd\u8f93\u5165' LANGUAGE='javascript' onclick='return " + strProcessor + "( this.form,\"" + strName + "\")'  class='text' >");
    }
}
function insertDateInputCtrl(strLabel, strName, strDefault, bShowButton, sWidth) {
    insertDateInputCtrlImpl("complex", strLabel, strName, strDefault, bShowButton, sWidth);
}
function insertInnerDateInputCtrl2(strLabel, strName, strDefault, bShowButton, sWidth) {
    insertDateInputCtrlImpl("inner", strLabel, strName, strDefault, bShowButton, sWidth);
}
//simple date control
function DateSimpleInput_onclick(formEmbeded, strFieldName) {
	//get date field control
    eval("g_ctrlSelected=formEmbeded." + strFieldName + ";");
	//prepare parameters.
    var varParas = new Array();
    varParas[0] = "InputDate";//function type show be invoked.
    varParas[1] = getDateFieldValue();//current value in control
    setDateFieldValue(window.showModalDialog("InputDateDialog.htm", varParas, "dialogHeight:80px;dialogWidth:370px"));
}
function insertSimpleDateInputCtrl2(strLabel, strName, strDefault, bShowButton, sWidth) {
    insertDateInputCtrlImpl("simple", strLabel, strName, bShowButton, sWidth);
}
var g_ctrlCode = null;
var g_ctrDesc = null;
function CodeInput_onclick(formEmbeded, strName, lClientID, lCodeType, nFields, lLanguageID, nProjectID) {
    eval("g_ctrlCode=formEmbeded." + strName + ";");
    eval("g_ctrlDesc=formEmbeded.txt_" + strName + ";");
    alert("test a");
    var strURL = "CodeXDesc.jsp" + "?lClientID=" + lClientID + "&lCodeType=" + lCodeType + "&nFields=" + nFields + "&lLanguage=" + lLanguageID + "&nProjectID=" + nProjectID;
    var strFeatures = "toolbar=no,menubar=no,scrollbar=no,resizable=no,location=no" + (g_bIsIE ? ",width=246,height=200" : ",width=260,height=200");
    g_wndSub = window.open(strURL, "CodeXDesc", strFeatures, false);
    g_wndSub.focus();
}
function insertCodeExchangeCtrl(strLabel, strName, strButtonText, lCodeType, nFields, lLanguageID, lDefault, lClientID, strDefault, nProjectID) {
    if (strLabel == null) {
        strLabel = "";
    }
    if (strName == null) {
        strName = "CodeInputCtrlName" + g_nCtrlCount++;
    }
    if (strButtonText == null) {
        strButtonText = "\u667a\u80fd\u8f93\u5165";
    }
    if (lCodeType == null) {
        lCodeType = 1;
    }
    if (nFields == null) {
        nFields = 0;
    }
    if (lLanguageID == null) {
        lLanguageID = 0;
    }
    if (lDefault == null) {
        lDefault = 0;
    }
    if (lClientID == null) {
        lClientID = 0;
    }
    if (strDefault == null) {
        strDefault = "----";
    }
    if (nProjectID == null) {
        nProjectID = 1;
    }
    document.writeln(strLabel + "<INPUT TYPE='HIDDEN' VALUE='" + lDefault + "' ID='" + strName + "' NAME='" + strName + "'>" + "<INPUT onfocus='this.blur()' ID='txt_" + strName + "' NAME='txt_" + strName + "' VALUE='" + strDefault + "'>" + "<INPUT ID='InteleInput' NAME='InteleInput' TYPE='button' LANGUAGE='javascript' " + "onclick='return CodeInput_onclick(this.form,\"" + strName + "\"," + lClientID + "," + lCodeType + "," + nFields + "," + lLanguageID + "," + nProjectID + ")' " + "VALUE='" + strButtonText + "'>");
}
function setIDandDesc(nID, nLanguageID, sName) {
    g_ctrlCode.value = nID;
    g_ctrlDesc.value = sName;
}
function hideInnerCalendar() {
    DivCalendar.style.visibility = "hidden";
    TabCalendar.style.visibility = "hidden";
}
//-------------------------------------------date control-------------------------------------------

//----------------------------------------------select users ----------------------------------------

// Definition of class Folder
// *****************************************************************
function Folder(folderDescription, hreference) {
  //constant data
    this.desc = "<input type='checkbox' name='user_id'>" + folderDescription;
    this.hreference = hreference;
    this.id = -1;
    this.navObj = 0;
    this.iconImg = 0;
    this.nodeImg = 0;
    this.isLastNode = 0;
    this.iconSrc = ICONPATH + "ftv2folderopen.gif";
    this.iconSrcClosed = ICONPATH + "ftv2folderclosed.gif";
    this.children = new Array;
    this.nChildren = 0;
    this.level = 0;
    this.leftSideCoded = "";
    this.isLastNode = false;
    this.parentObj = null;
    this.maySelect = true;
    this.prependHTML = "";

  //dynamic data
    this.isOpen = false;
    this.isLastOpenedFolder = false;
    this.isRendered = 0;

  //methods
    this.initialize = initializeFolder;
    this.setState = setStateFolder;
    this.addChild = addChild;
    this.addChildren = addChildren;
    this.createIndex = createEntryIndex;
    this.escondeBlock = escondeBlock;
    this.esconde = escondeFolder;
    this.folderMstr = folderMstr;
    this.renderOb = drawFolder;
    this.totalHeight = totalHeight;
    this.subEntries = folderSubEntries;
    this.linkHTML = linkFolderHTML;
    this.blockStartHTML = blockStartHTML;
    this.blockEndHTML = blockEndHTML;
    this.nodeImageSrc = nodeImageSrc;
    this.iconImageSrc = iconImageSrc;
    this.getID = getID;
    this.forceOpeningOfAncestorFolders = forceOpeningOfAncestorFolders;
}
function initializeFolder(level, lastNode, leftSide) {
    var j = 0;
    var i = 0;
    nc = this.nChildren;
    this.createIndex();
    this.level = level;
    this.leftSideCoded = leftSide;
    if (browserVersion == 0 || STARTALLOPEN == 1) {
        this.isOpen = true;
    }
    if (level > 0) {
        if (lastNode) {
            leftSide = leftSide + "0";
        } else {
            leftSide = leftSide + "1";
        }
    }
    this.isLastNode = lastNode;
    if (nc > 0) {
        level = level + 1;
        for (i = 0; i < this.nChildren; i++) {
            if (typeof this.children[i].initialize == "undefined") { //document node was specified using the addChildren function
            }
            if (typeof this.children[i][0] == "undefined" || typeof this.children[i] == "string") {
                this.children[i] = ["item incorrectly defined", ""];
            }

        //Basic initialization of the Item object
        //These members or methods are needed even before the Item is rendered
            this.children[i].initialize = initializeItem;
            this.children[i].createIndex = createEntryIndex;
            if (typeof this.children[i].maySelect == "undefined") {
                this.children[i].maySelect = true;
            }
            this.children[i].forceOpeningOfAncestorFolders = forceOpeningOfAncestorFolders;
            if (i == this.nChildren - 1) {
                this.children[i].initialize(level, 1, leftSide);
            } else {
                this.children[i].initialize(level, 0, leftSide);
            }
        }
    }
}
function drawFolder(insertAtObj) {
    var nodeName = "";
    var auxEv = "";
    var docW = "";
    var i = 0;
    finalizeCreationOfChildDocs(this);
    var leftSide = leftSideHTML(this.leftSideCoded);
    if (browserVersion > 0) {
        auxEv = "<a href='javascript:clickOnNode(\"" + this.getID() + "\")'>";
    } else {
        auxEv = "<a>";
    }
    nodeName = this.nodeImageSrc();
    if (this.level > 0) {
        if (this.isLastNode) {
            leftSide = leftSide + "<td valign=top>" + auxEv + "<img name='nodeIcon" + this.id + "' id='nodeIcon" + this.id + "' src='" + nodeName + "' width=16 height=22 border=0></a></td>";
        } else {
            leftSide = leftSide + "<td valign=top background=" + ICONPATH + "ftv2vertline.gif>" + auxEv + "<img name='nodeIcon" + this.id + "' id='nodeIcon" + this.id + "' src='" + nodeName + "' width=16 height=22 border=0></a></td>";
        }
    }
    this.isRendered = 1;
    if (browserVersion == 2) {
        if (!doc.yPos) {
            doc.yPos = 20;
        }
    }
    docW = this.blockStartHTML("folder");
    docW = docW + "<tr>" + leftSide + "<td valign=top>";
    if (USEICONS) {
        docW = docW + this.linkHTML(false);
        docW = docW + "<img id='folderIcon" + this.id + "' name='folderIcon" + this.id + "' src='" + this.iconImageSrc() + "' border=0></a>";
    } else {
        if (this.prependHTML == "") {
            docW = docW + "<img src=" + ICONPATH + "ftv2blank.gif height=2 width=2>";
        }
    }
    if (WRAPTEXT) {
        docW = docW + "</td>" + this.prependHTML + "<td valign=middle width=100%>";
    } else {
        docW = docW + "</td>" + this.prependHTML + "<td valign=middle nowrap width=100%>";
    }
    if (USETEXTLINKS) {
        docW = docW + this.linkHTML(true);
        docW = docW + this.desc + "</a>";
    } else {
        docW = docW + this.desc;
    }
    docW = docW + "</td>";
    docW = docW + this.blockEndHTML();
    if (insertAtObj == null) {
        if (supportsDeferral) {
            doc.write("<div id=domRoot></div>");
            insertAtObj = getElById("domRoot");
            insertAtObj.insertAdjacentHTML("beforeEnd", docW);
        } else {
            doc.write(docW);
        }
    } else {
        insertAtObj.insertAdjacentHTML("afterEnd", docW);
    }
    if (browserVersion == 2) {
        this.navObj = doc.layers["folder" + this.id];
        if (USEICONS) {
            this.iconImg = this.navObj.document.images["folderIcon" + this.id];
        }
        this.nodeImg = this.navObj.document.images["nodeIcon" + this.id];
        doc.yPos = doc.yPos + this.navObj.clip.height;
    } else {
        if (browserVersion != 0) {
            this.navObj = getElById("folder" + this.id);
            if (USEICONS) {
                this.iconImg = getElById("folderIcon" + this.id);
            }
            this.nodeImg = getElById("nodeIcon" + this.id);
        }
    }
}
function setStateFolder(isOpen) {
    var subEntries;
    var totalHeight;
    var fIt = 0;
    var i = 0;
    var currentOpen;
    if (isOpen == this.isOpen) {
        return;
    }
    if (browserVersion == 2) {
        totalHeight = 0;
        for (i = 0; i < this.nChildren; i++) {
            totalHeight = totalHeight + this.children[i].navObj.clip.height;
        }
        subEntries = this.subEntries();
        if (this.isOpen) {
            totalHeight = 0 - totalHeight;
        }
        for (fIt = this.id + subEntries + 1; fIt < nEntries; fIt++) {
            indexOfEntries[fIt].navObj.moveBy(0, totalHeight);
        }
    }
    this.isOpen = isOpen;
    if (this.getID() != foldersTree.getID() && PRESERVESTATE && !this.isOpen) { //closing
    }
    currentOpen = GetCookie("clickedFolder");
    if (currentOpen != null) {
        currentOpen = currentOpen.replace(this.getID() + cookieCutter, "");
        SetCookie("clickedFolder", currentOpen);
    }
    if (!this.isOpen && this.isLastOpenedfolder) {
        lastOpenedFolder = null;
        this.isLastOpenedfolder = false;
    }
    propagateChangesInState(this);
}
function propagateChangesInState(folder) {
    var i = 0;

  //Change icon
    if (folder.nChildren > 0 && folder.level > 0) {  //otherwise the one given at render stays
    }
    folder.nodeImg.src = folder.nodeImageSrc();

  //Change node
    if (USEICONS) {
        folder.iconImg.src = folder.iconImageSrc();
    }

  //Propagate changes
    for (i = folder.nChildren - 1; i >= 0; i--) {
        if (folder.isOpen) {
            folder.children[i].folderMstr(folder.navObj);
        } else {
            folder.children[i].esconde();
        }
    }
}
function escondeFolder() {
    this.escondeBlock();
    this.setState(0);
}
function linkFolderHTML(isTextLink) {
    var docW = "";
    if (this.hreference) {
        if (USEFRAMES) {
            docW = docW + "<a href='" + this.hreference + "' TARGET=\"basefrm\" ";
        } else {
            docW = docW + "<a href='" + this.hreference + "' TARGET=_top ";
        }
        if (isTextLink) {
            docW += "id=\"itemTextLink" + this.id + "\" ";
        }
        if (browserVersion > 0) {
            docW = docW + "onClick='javascript:clickOnFolder(\"" + this.getID() + "\")'";
        }
        docW = docW + ">";
    } else {
        docW = docW + "<a>";
    }
    return docW;
}
function addChild(childNode) {
    this.children[this.nChildren] = childNode;
    childNode.parentObj = this;
    this.nChildren++;
    return childNode;
}

//The list can contain either a Folder object or a sub list with the arguments for Item
function addChildren(listOfChildren) {
    this.children = listOfChildren;
    this.nChildren = listOfChildren.length;
    for (i = 0; i < this.nChildren; i++) {
        this.children[i].parentObj = this;
    }
}
function folderSubEntries() {
    var i = 0;
    var se = this.nChildren;
    for (i = 0; i < this.nChildren; i++) {
        if (this.children[i].children) { //is a folder
        }
        se = se + this.children[i].subEntries();
    }
    return se;
}
function nodeImageSrc() {
    var srcStr = "";
    if (this.isLastNode) {
        if (this.nChildren == 0) {
            srcStr = ICONPATH + "ftv2lastnode.gif";
        } else {
            if (this.isOpen) {
                srcStr = ICONPATH + "ftv2mlastnode.gif";
            } else {
                srcStr = ICONPATH + "ftv2plastnode.gif";
            }
        }
    } else {
        if (this.nChildren == 0) {
            srcStr = ICONPATH + "ftv2node.gif";
        } else {
            if (this.isOpen) {
                srcStr = ICONPATH + "ftv2mnode.gif";
            } else {
                srcStr = ICONPATH + "ftv2pnode.gif";
            }
        }
    }
    return srcStr;
}
function iconImageSrc() {
    if (this.isOpen) {
        return (this.iconSrc);
    } else {
        return (this.iconSrcClosed);
    }
}

// Definition of class Item (a document or link inside a Folder)
// *************************************************************
function Item(itemDescription) {
  // constant data
    this.desc = itemDescription;
    this.level = 0;
    this.isLastNode = false;
    this.leftSideCoded = "";
    this.parentObj = null;
    this.maySelect = true;
    this.initialize = initializeItem;
    this.createIndex = createEntryIndex;
    this.forceOpeningOfAncestorFolders = forceOpeningOfAncestorFolders;
    finalizeCreationOfItem(this);
}

//Assignments that can be delayed when the item is created with folder.addChildren
//The assignments that cannot be delayed are done in addChildren and in initializeFolder
//Additionaly, some assignments are also done in finalizeCreationOfChildDocs itself
function finalizeCreationOfItem(itemArray) {
    itemArray.navObj = 0;
    itemArray.iconImg = 0;
    itemArray.iconSrc = ICONPATH + "ftv2doc.gif";
    itemArray.isRendered = 0;
    itemArray.nChildren = 0;
    itemArray.prependHTML = "";

  // methods
    itemArray.escondeBlock = escondeBlock;
    itemArray.esconde = escondeBlock;
    itemArray.folderMstr = folderMstr;
    itemArray.renderOb = drawItem;
    itemArray.totalHeight = totalHeight;
    itemArray.blockStartHTML = blockStartHTML;
    itemArray.blockEndHTML = blockEndHTML;
    itemArray.getID = getID;
}
function initializeItem(level, lastNode, leftSide) {
    this.createIndex();
    this.level = level;
    this.leftSideCoded = leftSide;
    this.isLastNode = lastNode;
}
function drawItem(insertAtObj) {
    var leftSide = leftSideHTML(this.leftSideCoded);
    var docW = "";
    var fullLink = "href=\"" + this.link + "\" target=\"" + this.target + "\" onClick=\"clickOnLink('" + this.getID() + "', '" + this.link + "','" + this.target + "');return false;\"";
    this.isRendered = 1;
    if (this.level > 0) {
        if (this.isLastNode) {
            leftSide = leftSide + "<td valign=top><img src='" + ICONPATH + "ftv2lastnode.gif' width=16 height=22></td>";
        } else {
            leftSide = leftSide + "<td valign=top background=" + ICONPATH + "ftv2vertline.gif><img src='" + ICONPATH + "ftv2node.gif' width=16 height=22></td>";
        }
    }
    docW = docW + this.blockStartHTML("item");
    docW = docW + "<tr>" + leftSide + "<td valign=top>";
    if (USEICONS) {
        docW = docW + "<input type='checkbox' name='user_id' value='" + this.id + "'><img id='itemIcon" + this.id + "' " + "src='" + this.iconSrc + "' border=0>";
    } else {
        if (this.prependHTML == "") {
            docW = docW + "<img src=" + ICONPATH + "ftv2blank.gif height=2 width=3>";
        }
    }
    if (WRAPTEXT) {
        docW = docW + "</td>" + this.prependHTML + "<td valign=middle width=100%>";
    } else {
        docW = docW + "</td>" + this.prependHTML + "<td valign=middle nowrap width=100%>";
    }
    if (USETEXTLINKS) {
        docW = docW + this.desc;
    } else {
        docW = docW + this.desc;
    }
    docW = docW + "</td>";
    docW = docW + this.blockEndHTML();
    if (insertAtObj == null) {
        doc.write(docW);
    } else {
        insertAtObj.insertAdjacentHTML("afterEnd", docW);
    }
    if (browserVersion == 2) {
        this.navObj = doc.layers["item" + this.id];
        if (USEICONS) {
            this.iconImg = this.navObj.document.images["itemIcon" + this.id];
        }
        doc.yPos = doc.yPos + this.navObj.clip.height;
    } else {
        if (browserVersion != 0) {
            this.navObj = getElById("item" + this.id);
            if (USEICONS) {
                this.iconImg = getElById("itemIcon" + this.id);
            }
        }
    }
}


// Methods common to both objects (pseudo-inheritance)
// ********************************************************
function forceOpeningOfAncestorFolders() {
    if (this.parentObj == null || this.parentObj.isOpen) {
        return;
    } else {
        this.parentObj.forceOpeningOfAncestorFolders();
        clickOnNodeObj(this.parentObj);
    }
}
function escondeBlock() {
    if (browserVersion == 1 || browserVersion == 3) {
        if (this.navObj.style.display == "none") {
            return;
        }
        this.navObj.style.display = "none";
    } else {
        if (this.navObj.visibility == "hidden") {
            return;
        }
        this.navObj.visibility = "hidden";
    }
}
function folderMstr(domObj) {
    if (browserVersion == 1 || browserVersion == 3) {
        if (t == -1) {
            return;
        }
        var str = new String(doc.links[t]);
        if (str.slice(14, 16) != "em") {
            return;
        }
    }
    if (!this.isRendered) {
        this.renderOb(domObj);
    } else {
        if (browserVersion == 1 || browserVersion == 3) {
            this.navObj.style.display = "block";
        } else {
            this.navObj.visibility = "show";
        }
    }
}
function blockStartHTML(idprefix) {
    var idParam = "id='" + idprefix + this.id + "'";
    var docW = "";
    if (browserVersion == 2) {
        docW = "<layer " + idParam + " top=" + doc.yPos + " visibility=show>";
    } else {
        if (browserVersion != 0) {
            docW = "<div " + idParam + " style='display:block; position:block;'>";
        }
    }
    docW = docW + "<table border=0 cellspacing=0 cellpadding=0 width=100% >";
    return docW;
}
function blockEndHTML() {
    var docW = "";
    docW = "</table>";
    if (browserVersion == 2) {
        docW = docW + "</layer>";
    } else {
        if (browserVersion != 0) {
            docW = docW + "</div>";
        }
    }
    return docW;
}
function createEntryIndex() {
    this.id = nEntries;
    indexOfEntries[nEntries] = this;
    nEntries++;
}

// total height of subEntries open
function totalHeight() {
    var h = this.navObj.clip.height;
    var i = 0;
    if (this.isOpen) { //is a folder and _is_ open
    }
    for (i = 0; i < this.nChildren; i++) {
        h = h + this.children[i].totalHeight();
    }
    return h;
}
function leftSideHTML(leftSideCoded) {
    var i;
    var retStr = "";
    for (i = 0; i < leftSideCoded.length; i++) {
        if (leftSideCoded.charAt(i) == "1") {
            retStr = retStr + "<td valign=top background=" + ICONPATH + "ftv2vertline.gif><img src='" + ICONPATH + "ftv2vertline.gif' width=16 height=22></td>";
        }
        if (leftSideCoded.charAt(i) == "0") {
            retStr = retStr + "<td valign=top><img src='" + ICONPATH + "ftv2blank.gif' width=16 height=22></td>";
        }
    }
    return retStr;
}
function getID() {
  //define a .xID in all nodes (folders and items) if you want to PERVESTATE that
  //work when the tree changes. The value eXternal value must be unique for each
  //node and must node change when other nodes are added or removed
  //The value may be numeric or string, but cannot have the same char used in cookieCutter
    if (typeof this.xID != "undefined") {
        return this.xID;
    } else {
        return this.id;
    }
}


// Events
// *********************************************************
function clickOnFolder(folderId) {
    var clicked = findObj(folderId);
    if (typeof clicked == "undefined" || clicked == null) {
        alert("Treeview was not able to find the node object corresponding to ID=" + folderId + ". If the configuration file sets a.xID values, it must set them for ALL nodes, including the foldersTree root.");
        return;
    }
    if (!clicked.isOpen) {
        clickOnNodeObj(clicked);
    }
    if (lastOpenedFolder != null && lastOpenedFolder != folderId) {
        clickOnNode(lastOpenedFolder);
    } //sets lastOpenedFolder to null
    if (clicked.nChildren == 0) {
        lastOpenedFolder = folderId;
        clicked.isLastOpenedfolder = true;
    }
    if (isLinked(clicked.hreference)) {
        highlightObjLink(clicked);
    }
}
function clickOnNode(folderId) {
    fOb = findObj(folderId);
    if (typeof fOb == "undefined" || fOb == null) {
        alert("Treeview was not able to find the node object corresponding to ID=" + folderId + ". If the configuration file sets a.xID, it must set foldersTree.xID as well.");
        return;
    }
    clickOnNodeObj(fOb);
}
function clickOnNodeObj(folderObj) {
    var state = 0;
    var currentOpen;
    state = folderObj.isOpen;
    folderObj.setState(!state);
    if (folderObj.id != foldersTree.id && PRESERVESTATE) {
        currentOpen = GetCookie("clickedFolder");
        if (currentOpen == null) {
            currentOpen = "";
        }
        if (!folderObj.isOpen) {
            currentOpen = currentOpen.replace(folderObj.getID() + cookieCutter, "");
            SetCookie("clickedFolder", currentOpen);
        } else {
            SetCookie("clickedFolder", currentOpen + folderObj.getID() + cookieCutter);
        }
    }
}
function clickOnLink(clickedId, target, windowName) {
    highlightObjLink(findObj(clickedId));
    if (isLinked(target)) {
        window.open(target, windowName);
    }
}
function ld() {
    return document.links.length - 1;
}


// Auxiliary Functions
// *******************
function finalizeCreationOfChildDocs(folderObj) {
    for (i = 0; i < folderObj.nChildren; i++) {
        child = folderObj.children[i];
        if (typeof child[0] != "undefined") {
      // Amazingly, arrays can have members, so   a = ["a", "b"]; a.desc="asdas"   works
      // If a doc was inserted as an array, we can transform it into an itemObj by adding
      // the missing members and functions
            child.desc = child[0];
            setItemLink(child, GLOBALTARGET, child[1]);
            finalizeCreationOfItem(child);
        }
    }
}
function findObj(id) {
    var i = 0;
    var nodeObj;
    if (typeof foldersTree.xID != "undefined") {
        nodeObj = indexOfEntries[i];
        for (i = 0; i < nEntries && indexOfEntries[i].xID != id; i++) { //may need optimization
        }
        id = i;
    }
    if (id >= nEntries) {
        return null;
    } else {
        return indexOfEntries[id];
    }
}
function isLinked(hrefText) {
    var result = true;
    result = (result && hrefText != null);
    result = (result && hrefText != "");
    result = (result && hrefText.indexOf("undefined") < 0);
    result = (result && hrefText.indexOf("parent.op") < 0);
    return result;
}

// Do highlighting by changing background and foreg. colors of folder or doc text
function highlightObjLink(nodeObj) {
    if (!HIGHLIGHT || nodeObj == null || nodeObj.maySelect == false) {//node deleted in DB
        return;
    }
    if (browserVersion == 1 || browserVersion == 3) {
        var clickedDOMObj = getElById("itemTextLink" + nodeObj.id);
        if (clickedDOMObj != null) {
            if (lastClicked != null) {
                var prevClickedDOMObj = getElById("itemTextLink" + lastClicked.id);
                prevClickedDOMObj.style.color = lastClickedColor;
                prevClickedDOMObj.style.backgroundColor = lastClickedBgColor;
            }
            lastClickedColor = clickedDOMObj.style.color;
            lastClickedBgColor = clickedDOMObj.style.backgroundColor;
            clickedDOMObj.style.color = HIGHLIGHT_COLOR;
            clickedDOMObj.style.backgroundColor = HIGHLIGHT_BG;
        }
    }
    lastClicked = nodeObj;
    if (PRESERVESTATE) {
        SetCookie("highlightedTreeviewLink", nodeObj.getID());
    }
}
function insFld(parentFolder, childFolder) {
    return parentFolder.addChild(childFolder);
}
function insDoc(parentFolder, document) {
    return parentFolder.addChild(document);
}
function gFld(description, hreference) {
    folder = new Folder(description, hreference);
    return folder;
}
function gLnk(optionFlags, description, linkData) {
    if (optionFlags >= 0) { //is numeric (old style) or empty (error)
    //Target changed from numeric to string in Aug 2002, and support for numeric style was entirely dropped in Mar 2004
        alert("Change your Treeview configuration file to use the new style of target argument in gLnk");
        return;
    }
    newItem = new Item(description);
    setItemLink(newItem, optionFlags, linkData);
    return newItem;
}
function setItemLink(item, optionFlags, linkData) {
    var targetFlag = "";
    var target = "";
    var protocolFlag = "";
    var protocol = "";
    targetFlag = optionFlags.charAt(0);
    if (targetFlag == "B") {
        target = "_blank";
    }
    if (targetFlag == "P") {
        target = "_parent";
    }
    if (targetFlag == "R") {
        target = "basefrm";
    }
    if (targetFlag == "S") {
        target = "_self";
    }
    if (targetFlag == "T") {
        target = "_top";
    }
    if (optionFlags.length > 1) {
        protocolFlag = optionFlags.charAt(1);
        if (protocolFlag == "h") {
            protocol = "http://";
        }
        if (protocolFlag == "s") {
            protocol = "https://";
        }
        if (protocolFlag == "f") {
            protocol = "ftp://";
        }
        if (protocolFlag == "m") {
            protocol = "mailto:";
        }
    }
    item.link = protocol + linkData;
    item.target = target;
}

//Function created  for backwards compatibility purposes
//Function contents voided in March 2004
function oldGLnk(target, description, linkData) {
}
function preLoadIcons() {
    var auxImg;
    auxImg = new Image();
    auxImg.src = ICONPATH + "ftv2vertline.gif";
    auxImg.src = ICONPATH + "ftv2mlastnode.gif";
    auxImg.src = ICONPATH + "ftv2mnode.gif";
    auxImg.src = ICONPATH + "ftv2plastnode.gif";
    auxImg.src = ICONPATH + "ftv2pnode.gif";
    auxImg.src = ICONPATH + "ftv2blank.gif";
    auxImg.src = ICONPATH + "ftv2lastnode.gif";
    auxImg.src = ICONPATH + "ftv2node.gif";
    auxImg.src = ICONPATH + "ftv2folderclosed.gif";
    auxImg.src = ICONPATH + "ftv2folderopen.gif";
    auxImg.src = ICONPATH + "ftv2doc.gif";
}

//Open some folders for initial layout, if necessary
function setInitialLayout() {
    if (browserVersion > 0 && !STARTALLOPEN) {
        clickOnNodeObj(foldersTree);
    }
    if (!STARTALLOPEN && (browserVersion > 0) && PRESERVESTATE) {
        PersistentFolderOpening();
    }
}

//Used with NS4 and STARTALLOPEN
function renderAllTree(nodeObj, parent) {
    var i = 0;
    nodeObj.renderOb(parent);
    if (supportsDeferral) {
        for (i = nodeObj.nChildren - 1; i >= 0; i--) {
            renderAllTree(nodeObj.children[i], nodeObj.navObj);
        }
    } else {
        for (i = 0; i < nodeObj.nChildren; i++) {
            renderAllTree(nodeObj.children[i], null);
        }
    }
}
function hideWholeTree(nodeObj, hideThisOne, nodeObjMove) {
    var i = 0;
    var heightContained = 0;
    var childrenMove = nodeObjMove;
    if (hideThisOne) {
        nodeObj.escondeBlock();
    }
    if (browserVersion == 2) {
        nodeObj.navObj.moveBy(0, 0 - nodeObjMove);
    }
    for (i = 0; i < nodeObj.nChildren; i++) {
        heightContainedInChild = hideWholeTree(nodeObj.children[i], true, childrenMove);
        if (browserVersion == 2) {
            heightContained = heightContained + heightContainedInChild + nodeObj.children[i].navObj.clip.height;
            childrenMove = childrenMove + heightContainedInChild;
        }
    }
    return heightContained;
}


// Simulating inserAdjacentHTML on NS6
// Code by thor@jscript.dk
// ******************************************
if (typeof HTMLElement != "undefined" && !HTMLElement.prototype.insertAdjacentElement) {
    HTMLElement.prototype.insertAdjacentElement = function (where, parsedNode) {
        switch (where) {
          case "beforeBegin":
            this.parentNode.insertBefore(parsedNode, this);
            break;
          case "afterBegin":
            this.insertBefore(parsedNode, this.firstChild);
            break;
          case "beforeEnd":
            this.appendChild(parsedNode);
            break;
          case "afterEnd":
            if (this.nextSibling) {
                this.parentNode.insertBefore(parsedNode, this.nextSibling);
            } else {
                this.parentNode.appendChild(parsedNode);
            }
            break;
        }
    };
    HTMLElement.prototype.insertAdjacentHTML = function (where, htmlStr) {
        var r = this.ownerDocument.createRange();
        r.setStartBefore(this);
        var parsedHTML = r.createContextualFragment(htmlStr);
        this.insertAdjacentElement(where, parsedHTML);
    };
}
function getElById(idVal) {
    if (document.getElementById != null) {
        return document.getElementById(idVal);
    }
    if (document.all != null) {
        return document.all[idVal];
    }
    alert("Problem getting element by id");
    return null;
}


// Functions for cookies
// Note: THESE FUNCTIONS ARE OPTIONAL. No cookies are used unless
// the PRESERVESTATE variable is set to 1 (default 0)
// The separator currently in use is ^ (chr 94)
// ***********************************************************
function PersistentFolderOpening() {
    var stateInCookie;
    var fldStr = "";
    var fldArr;
    var fldPos = 0;
    var id;
    var nodeObj;
    stateInCookie = GetCookie("clickedFolder");
    SetCookie("clickedFolder", "");
    if (stateInCookie != null) {
        fldArr = stateInCookie.split(cookieCutter);
        for (fldPos = 0; fldPos < fldArr.length; fldPos++) {
            fldStr = fldArr[fldPos];
            if (fldStr != "") {
                nodeObj = findObj(fldStr);
                if (nodeObj != null) { //may have been deleted
                }
                if (nodeObj.setState) {
                    nodeObj.forceOpeningOfAncestorFolders();
                    clickOnNodeObj(nodeObj);
                } else {
                    alert("Internal id is not pointing to a folder anymore.\nConsider giving an ID to the tree and external IDs to the individual nodes.");
                }
            }
        }
    }
}
function storeAllNodesInClickCookie(treeNodeObj) {
    var currentOpen;
    var i = 0;
    if (typeof treeNodeObj.setState != "undefined") { //is folder
    }
    currentOpen = GetCookie("clickedFolder");
    if (currentOpen == null) {
        currentOpen = "";
    }
    if (treeNodeObj.getID() != foldersTree.getID()) {
        SetCookie("clickedFolder", currentOpen + treeNodeObj.getID() + cookieCutter);
    }
    for (i = 0; i < treeNodeObj.nChildren; i++) {
        storeAllNodesInClickCookie(treeNodeObj.children[i]);
    }
}
function CookieBranding(name) {
    if (typeof foldersTree.treeID != "undefined") {
        return name + foldersTree.treeID;
    } else {
        return name;
    }
}
function GetCookie(name) {
    name = CookieBranding(name);
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) {
            return getCookieVal(j);
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) {
            break;
        }
    }
    return null;
}
function getCookieVal(offset) {
    var endstr = document.cookie.indexOf(";", offset);
    if (endstr == -1) {
        endstr = document.cookie.length;
    }
    return unescape(document.cookie.substring(offset, endstr));
}
function SetCookie(name, value) {
    var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
	//var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    var path = "/"; //allows the tree to remain open across pages with diff names & paths
    name = CookieBranding(name);
    document.cookie = name + "=" + escape(value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
}
function ExpireCookie(name) {
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval = GetCookie(name);
    name = CookieBranding(name);
    document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}


//To customize the tree, overwrite these variables in the configuration file (demoFramesetNode.js, etc.)
var USETEXTLINKS = 0;
var STARTALLOPEN = 0;
var USEFRAMES = 1;
var USEICONS = 1;
var WRAPTEXT = 0;
var PERSERVESTATE = 0; //backward compatibility
var PRESERVESTATE = 0;
var ICONPATH = "/mlnoa/img/";
var HIGHLIGHT = 0;
var HIGHLIGHT_COLOR = "white";
var HIGHLIGHT_BG = "blue";
var BUILDALL = 0;
var GLOBALTARGET = "R"; // variable only applicable for addChildren uses


//Other variables
var lastClicked = null;
var lastClickedColor;
var lastClickedBgColor;
var indexOfEntries = new Array;
var nEntries = 0;
var browserVersion = 0;
var selectedFolder = 0;
var lastOpenedFolder = null;
var t = 5;
var doc = document;
var supportsDeferral = false;
var cookieCutter = "^";
doc.yPos = 0;

// Main function
// *************

// This function uses an object (navigator) defined in
// ua.js, imported in the main html page (left frame).
function initializeDocument() {
    preLoadIcons();
    switch (navigator.family) {
      case "ie4":
        browserVersion = 1;
        break;
      case "opera":
        browserVersion = (navigator.version > 6 ? 1 : 0);
        break;
      case "nn4":
        browserVersion = 2;
        break;
      case "gecko":
        browserVersion = 3;
        break;
      case "safari":
        browserVersion = 1;
        break;
      default:
        browserVersion = 0;
        break;
    }

  // backward compatibility
    if (PERSERVESTATE) {
        PRESERVESTATE = 1;
    }
    supportsDeferral = ((navigator.family == "ie4" && navigator.version >= 5 && navigator.OS != "mac") || browserVersion == 3);
    supportsDeferral = supportsDeferral & (!BUILDALL);
    if (!USEFRAMES && browserVersion == 2) {
        browserVersion = 0;
    }
    eval(String.fromCharCode(116, 61, 108, 100, 40, 41));

  //If PRESERVESTATE is on, STARTALLOPEN can only be effective the first time the page
  //loads during the session. For subsequent (re)loads the PRESERVESTATE data stored
  //in cookies takes over the control of the initial expand/collapse
    if (PRESERVESTATE && GetCookie("clickedFolder") != null) {
        STARTALLOPEN = 0;
    }

  //foldersTree (with the site's data) is created in an external .js (demoFramesetNode.js, for example)
    foldersTree.initialize(0, true, "");
    if (supportsDeferral && !STARTALLOPEN) {
        foldersTree.renderOb(null);
    } else {
        renderAllTree(foldersTree, null);
        if (PRESERVESTATE && STARTALLOPEN) {
            storeAllNodesInClickCookie(foldersTree);
        }

    //To force the scrollable area to be big enough
        if (browserVersion == 2) {
            doc.write("<layer top=" + indexOfEntries[nEntries - 1].navObj.top + ">&nbsp;</layer>");
        }
        if (browserVersion != 0 && !STARTALLOPEN) {
            hideWholeTree(foldersTree, false, 0);
        }
    }
    setInitialLayout();
    if (PRESERVESTATE && GetCookie("highlightedTreeviewLink") != null && GetCookie("highlightedTreeviewLink") != "") {
        var nodeObj = findObj(GetCookie("highlightedTreeviewLink"));
        if (nodeObj != null) {
            nodeObj.forceOpeningOfAncestorFolders();
            highlightObjLink(nodeObj);
        } else {
            SetCookie("highlightedTreeviewLink", "");
        }
    }
}
function xbDetectBrowser() {
    var oldOnError = window.onerror;
    var element = null;
    window.onerror = null;

  // work around bug in xpcdom Mozilla 0.9.1
    window.saveNavigator = window.navigator;
    navigator.OS = "";
    navigator.version = parseFloat(navigator.appVersion);
    navigator.org = "";
    navigator.family = "";
    var platform;
    if (typeof (window.navigator.platform) != "undefined") {
        platform = window.navigator.platform.toLowerCase();
        if (platform.indexOf("win") != -1) {
            navigator.OS = "win";
        } else {
            if (platform.indexOf("mac") != -1) {
                navigator.OS = "mac";
            } else {
                if (platform.indexOf("unix") != -1 || platform.indexOf("linux") != -1 || platform.indexOf("sun") != -1) {
                    navigator.OS = "nix";
                }
            }
        }
    }
    var i = 0;
    var ua = window.navigator.userAgent.toLowerCase();
    if (ua.indexOf("safari") != -1) {
        i = ua.indexOf("safari");
        navigator.family = "safari";
        navigator.org = "safari";
        navigator.version = parseFloat("0" + ua.substr(i + 7), 10);
    } else {
        if (ua.indexOf("opera") != -1) {
            i = ua.indexOf("opera");
            navigator.family = "opera";
            navigator.org = "opera";
            navigator.version = parseFloat("0" + ua.substr(i + 6), 10);
        } else {
            if ((i = ua.indexOf("msie")) != -1) {
                navigator.org = "microsoft";
                navigator.version = parseFloat("0" + ua.substr(i + 5), 10);
                if (navigator.version < 4) {
                    navigator.family = "ie3";
                } else {
                    navigator.family = "ie4";
                }
            } else {
                if (ua.indexOf("gecko") != -1) {
                    navigator.family = "gecko";
                    var rvStart = ua.indexOf("rv:");
                    var rvEnd = ua.indexOf(")", rvStart);
                    var rv = ua.substring(rvStart + 3, rvEnd);
                    var rvParts = rv.split(".");
                    var rvValue = 0;
                    var exp = 1;
                    for (var i = 0; i < rvParts.length; i++) {
                        var val = parseInt(rvParts[i]);
                        rvValue += val / exp;
                        exp *= 100;
                    }
                    navigator.version = rvValue;
                    if (ua.indexOf("netscape") != -1) {
                        navigator.org = "netscape";
                    } else {
                        if (ua.indexOf("compuserve") != -1) {
                            navigator.org = "compuserve";
                        } else {
                            navigator.org = "mozilla";
                        }
                    }
                } else {
                    if ((ua.indexOf("mozilla") != -1) && (ua.indexOf("spoofer") == -1) && (ua.indexOf("compatible") == -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1) && (ua.indexOf("hotjava") == -1)) {
                        var is_major = parseFloat(navigator.appVersion);
                        if (is_major < 4) {
                            navigator.version = is_major;
                        } else {
                            i = ua.lastIndexOf("/");
                            navigator.version = parseFloat("0" + ua.substr(i + 1), 10);
                        }
                        navigator.org = "netscape";
                        navigator.family = "nn" + parseInt(navigator.appVersion);
                    } else {
                        if ((i = ua.indexOf("aol")) != -1) {
    // aol
                            navigator.family = "aol";
                            navigator.org = "aol";
                            navigator.version = parseFloat("0" + ua.substr(i + 4), 10);
                        } else {
                            if ((i = ua.indexOf("hotjava")) != -1) {
    // hotjava
                                navigator.family = "hotjava";
                                navigator.org = "sun";
                                navigator.version = parseFloat(navigator.appVersion);
                            }
                        }
                    }
                }
            }
        }
    }
    window.onerror = oldOnError;
}
xbDetectBrowser();
function select_users() {
    var ulist;
    var urlOpen = "/mlnoa/pages/common/user_list.jsp";
    var win_dimensions = "height=480,width=430,top=50,left=150,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no";
    var returnData = showModalDialog(urlOpen, "_blank", win_dimensions);
    return returnData;
	//returnData[0]：人员id 例如：1;2
	//returnData[1]：人员名称 例如：张三;李四
	//returnData[2]：部门id 例如：3;4
	//returnData[3]：部门名称 例如：综合部;合同部
	//returnData[4]：角色id 例如：5;6
	//returnData[5]：角色名称 例如：总经理;合同部主任
}

 //日期选择窗口
function calendarDlg(ctrlobj) {
    showx = event.screenX - event.offsetX + 4; // + deltaX;
    showy = event.screenY - event.offsetY + 18; // + deltaY;
    newWINwidth = 210 + 4 + 18;
    retval = window.showModalDialog("/mlnoa/js/date.htm", "", "dialogWidth:197px; dialogHeight:210px; dialogLeft:" + showx + "px; dialogTop:" + showy + "px; status:no; directories:yes;scrollbars:no;Resizable=no; ");
    if (retval != null) {
        ctrlobj.value = retval;
    }
}
function calendartimeDlg(ctrlobj) {
    showx = event.screenX - event.offsetX + 4; // + deltaX;
    showy = event.screenY - event.offsetY + 18; // + deltaY;
    newWINwidth = 210 + 4 + 18;
    retval = window.showModalDialog("/mlnoa/pages/mlnpr/js/datetime.htm", "", "dialogWidth:197px; dialogHeight:240px; dialogLeft:" + showx + "px; dialogTop:" + showy + "px; status:no; directories:yes;scrollbars:no;Resizable=no; ");
    if (retval != null) {
        ctrlobj.value = retval;
    }
}
function insertInnerDateInputCtrl(strLabel, strName, strDefault, bMustFill, sWidth) {
    if(bMustFill){
		document.writeln("<input type=\"text\" name=\"" + strName + "\" value=\"" + strDefault + "\" size=\"10\" maxlength=\"10\" class=\"text\" onclick=\"calendarDlg(this)\" readonly mustFill=true promptName=\"'"+strLabel+"'\">");
	}
	else{
		document.writeln("<input type=\"text\" name=\"" + strName + "\" value=\"" + strDefault + "\" size=\"10\" maxlength=\"10\" class=\"text\" onclick=\"calendarDlg(this)\" readonly promptName=\"'"+strLabel+"'\">");
	}
}
function insertDateCtrl(strName, strDefault, mustFill, promptName) {
	if(mustFill){
		document.writeln("<input type=\"text\" name=\"" + strName + "\" value=\"" + strDefault + "\" size=\"10\" maxlength=\"10\" class=\"text\" onclick=\"calendarDlg(this)\" readonly mustFill=" + mustFill + " promptName=\"" + promptName + "\">");
	}
	else{
		document.writeln("<input type=\"text\" name=\"" + strName + "\" value=\"" + strDefault + "\" size=\"10\" maxlength=\"10\" class=\"text\" onclick=\"calendarDlg(this)\" readonly promptName=\"" + promptName + "\">");
	}
}
function insertInnerDateTimeInputCtrl(strLabel, strName, strDefault, bMustFill, sWidth) {
	if(bMustFill){
	    document.writeln("<input type=\"text\" name=\"" + strName + "\" value=\"" + strDefault + "\" size=\"16\" maxlength=\"16\" class=\"text\" onclick=\"calendartimeDlg(this)\" readonly mustFill=true promptName=\"'"+strLabel+"'\">");
	}
	else{
		document.writeln("<input type=\"text\" name=\"" + strName + "\" value=\"" + strDefault + "\" size=\"16\" maxlength=\"16\" class=\"text\" onclick=\"calendartimeDlg(this)\" readonly promptName=\"'"+strLabel+"'\">");
	}
}

function insertDateTimeCtrl(strName,strDefault,mustFill,promptName){
	if(mustFill){
		document.writeln("<input type=\"text\" name=\"" + strName + "\" value=\"" + strDefault + "\" size=\"16\" maxlength=\"16\" class=\"text\" onclick=\"calendartimeDlg(this)\" readonly mustFill=true promptName=\"'"+promptName+"'\">");
	}
	else
	{
		document.writeln("<input type=\"text\" name=\"" + strName + "\" value=\"" + strDefault + "\" size=\"16\" maxlength=\"16\" class=\"text\" onclick=\"calendartimeDlg(this)\" readonly promptName=\"'"+promptName+"'\">");
	}
}
//---------------------------------------------select users --------------------------------------------
/**
  * userIds 发送对象 msg 短信内容
  */
function _sendNote(userIds, msg) {
    window.open("/mlnoa/pages/sendnote.jsp?userIds=" + userIds + "&message=" + msg, "", "toolbar=0,status=0,scrollbars=0,top=0,left=0,width=500,height=300");
}
function Trim(TRIM_VALUE) {
    if (TRIM_VALUE.length < 1) {
        return "";
    }
    TRIM_VALUE = RTrim(TRIM_VALUE);
    TRIM_VALUE = LTrim(TRIM_VALUE);
    if (TRIM_VALUE == "") {
        return "";
    } else {
        return TRIM_VALUE;
    }
} //End Function
function RTrim(VALUE) {
    var w_space = String.fromCharCode(32);
    var v_length = VALUE.length;
    var strTemp = "";
    if (v_length < 0) {
        return "";
    }
    var iTemp = v_length - 1;
    while (iTemp > -1) {
        if (VALUE.charAt(iTemp) == w_space) {
        } else {
            strTemp = VALUE.substring(0, iTemp + 1);
            break;
        }
        iTemp = iTemp - 1;
    } //End While
    return strTemp;
} //End Function
function LTrim(VALUE) {
    var w_space = String.fromCharCode(32);
    if (v_length < 1) {
        return "";
    }
    var v_length = VALUE.length;
    var strTemp = "";
    var iTemp = 0;
    while (iTemp < v_length) {
        if (VALUE.charAt(iTemp) == w_space) {
        } else {
            strTemp = VALUE.substring(iTemp, v_length);
            break;
        }
        iTemp = iTemp + 1;
    } //End While
    return strTemp;
} //End







//格式化数字显示方式，也可以用于对数字重定精度。
/*
使用方法
formatNumber(0,'');
formatNumber(12432.21,'#,###');
formatNumber(12432.21,'#,###.000#');
formatNumber(12432,'#,###.00');
formatNumber('12432.415','#,###.0#');
*/
function formatNumber(number, pattern) {
    var str = number.toString();
    var strInt;
    var strFloat;
    var formatInt;
    var formatFloat;
    if (/\./g.test(pattern)) {
        formatInt = pattern.split(".")[0];
        formatFloat = pattern.split(".")[1];
    } else {
        formatInt = pattern;
        formatFloat = null;
    }
    if (/\./g.test(str)) {
        if (formatFloat != null) {
            var tempFloat = Math.round(parseFloat("0." + str.split(".")[1]) * Math.pow(10, formatFloat.length)) / Math.pow(10, formatFloat.length);
            strInt = (Math.floor(number) + Math.floor(tempFloat)).toString();
            strFloat = /\./g.test(tempFloat.toString()) ? tempFloat.toString().split(".")[1] : "0";
        } else {
            strInt = Math.round(number).toString();
            strFloat = "0";
        }
    } else {
        strInt = str;
        strFloat = "0";
    }
    if (formatInt != null) {
        var outputInt = "";
        var zero = formatInt.match(/0*$/)[0].length;
        var comma = null;
        if (/,/g.test(formatInt)) {
            comma = formatInt.match(/,[^,]*/)[0].length - 1;
        }
        var newReg = new RegExp("(\\d{" + comma + "})", "g");
        if (strInt.length < zero) {
            outputInt = new Array(zero + 1).join("0") + strInt;
            outputInt = outputInt.substr(outputInt.length - zero, zero);
        } else {
            outputInt = strInt;
        }
        var outputInt = outputInt.substr(0, outputInt.length % comma) + outputInt.substring(outputInt.length % comma).replace(newReg, (comma != null ? "," : "") + "$1");
        outputInt = outputInt.replace(/^,/, "");
        strInt = outputInt;
    }
    if (formatFloat != null) {
        var outputFloat = "";
        var zero = formatFloat.match(/^0*/)[0].length;
        if (strFloat.length < zero) {
            outputFloat = strFloat + new Array(zero + 1).join("0");
            //outputFloat        = outputFloat.substring(0,formatFloat.length);
            var outputFloat1 = outputFloat.substring(0, zero);
            var outputFloat2 = outputFloat.substring(zero, formatFloat.length);
            outputFloat = outputFloat1 + outputFloat2.replace(/0*$/, "");
        } else {
            outputFloat = strFloat.substring(0, formatFloat.length);
        }
        strFloat = outputFloat;
    } else {
        if (pattern != "" || (pattern == "" && strFloat == "0")) {
            strFloat = "";
        }
    }
    return strInt + (strFloat == "" ? "" : "." + strFloat);
}

/*
	在弹出的窗体中选择用户（多选或单选）
	objId：放置userId的text
	objName：放置usreName的text
*/
function selectAttendUser(objId,objName,t){
	var stype = "0";
	if(t!=null){
		stype = t;  //0:多选,1:单选
	}
	var par = "/mlnoa/pages/mlnpr/public/user_list.jsp?stype="+stype;

	if(objId!=null){
		if(objId.value!=null && objId.value!=""){
			par += "&users="+objId.value;
		}
	}
	else{
		if(objName.value!=null && objName.value != ""){
			par += "&unames="+objName.value;
		}
	}
	var data=window.showModalDialog( par,"人员信息","center: Yes; help: No; resizable: No; status: No;width=500,height=100");
	if(data!=null && data[0]!=null){
		if(objId!=null){
			objId.value =data[0];
		}
		objName.value =data[1];
	}
}

/*
	在弹出的窗体中选择水工建筑物（多选或单选）
	objId：放置Id的text
	objName：放置Name的text
*/
function selectBuilding(objId,objName,t){
	var stype = "0";
	if(t!=null){
		stype = t;  //0:多选,1:单选
	}
	var par = "/mlnoa/pages/mlnpr/public/building_list.jsp?stype="+stype;

	if(objId!=null){
		if(objId.value!=null && objId.value!=""){
			par += "&bid="+objId.value;
		}
	}
	else{
		if(objName.value!=null && objName.value != ""){
			par += "&bnames="+objName.value;
		}
	}
	var data=window.showModalDialog( par,"","status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=500,height=100");
	if(data!=null && data[0]!=null){
		if(objId!=null){
			objId.value =data[0];
		}
		objName.value =data[1];
	}
}



/*
上传附件
tableName:表名
keyName:主键名
keyValue:主键值
*/
function affix(tableName,keyName,keyValue){
	var url="/mlnoa/pages/mlnpr/public/file.jsp?tablename="+tableName+"&funcostname="+keyName+"&funcost="+keyValue;
	var showx = event.screenX - event.offsetX/3; // + deltaX;
	var showy = "300"; // + deltaY;
	window.open ( url,"","status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,width=650,height=400,left=500,top=300");
}

/*
	在弹出的窗体中选择水工建筑物（多选或单选）
	objId：放置Id的text
	objName：放置Name的text
*/

function selectfixing(objId,objName,t){
	var stype = "0";
	if(t!=null){
		stype = 0;  //0:多选,1:单选
	}
	var par = "/mlnoa/pages/mlnpr/public/fixing_select.jsp?stype="+stype;

	if(objId!=null){
		if(objId.value!=null && objId.value!=""){
			par += "&bid="+objId.value;
		}
	}
	else{
		if(objName.value!=null && objName.value != ""){
			par += "&bnames="+objName.value;
		}
	}
	var data=window.showModalDialog( par,"","status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=500,height=100");
	if(data!=null && data[0]!=null){
		if(objId!=null){
			objId.value =data[0];
		}
		objName.value =data[1];
	}
}


function _Print(objName)
{
	window.open("/mlnoa/pages/mlnpr/public/print.jsp?p="+objName,"","status=yes,toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes,width=1024,height=768");
}


/**
返回签名组件
objId: id文本框的name
userId: 签名人ID
disabled：是否可用
*/
function insertSignCtrl(objId,userId,curUserId,disabled,timeCtrl){
	var s="";
	//alert(userId);
	s +="<img name=\"img"+objId+"\" src=\"/mlnoa/pages/mlnpr/images/sign/"+userId+".gif\" style=\"display:"+((userId==null||Trim(userId)=="")?"none":"inline")+"\">";
	s +="<input type=\"hidden\" name=\""+objId+"\" value=\""+userId+"\">";
	s +="<img src=\"/mlnoa/pages/mlnpr/images/edit.bmp\" style=\"cursor:hand;display:"+((disabled)?"inline":"none")+"\" alt=\"本人签名\" onclick=\"Sign(document.all('"+objId+"'),document.all('img"+objId+"'),'"+curUserId+"','"+timeCtrl+"')\">";
	//alert(s);
	document.writeln(s);
}

function insertSignWithTimeCtrl(objId,userId,curUserId,disabled,timeCtrl){

}

function Sign(objId,objImg,userId,timeCtrl){
	//alert(timeCtrl);
	objImg.src = "/mlnoa/pages/mlnpr/images/sign/"+userId+".gif";
	var curDateTime = "";
	var d = new Date();
	curDateTime = d.getYear()+"-"+((d.getMonth()<10)?"0"+d.getMonth():d.getMonth())+"-"+((d.getDay()<10)?"0"+d.getDay():d.getDay());
	curDateTime += " " + ((d.getHours()<10)?"0"+d.getHours():d.getHours())+":"+((d.getMinutes()<10)?"0"+d.getMinutes():d.getMinutes());

	if(Trim(objId.value)=="" || objId.value==null){
		objImg.style.display = "inline";
		objId.value = userId;
		if(timeCtrl!=null || timeCtrl!=""){
			document.all(timeCtrl).value = curDateTime;
		}
	}
	else{
		objImg.style.display = "none";
		objId.value = "";
		document.all(timeCtrl).value = "";
	}

}

