  /////这里列出了常用的JS函数，要求每个页面都包含这个js文件
  //常用函数
   function trim(v) {
    var v = v.replace(/(^\s*)|(\s*$)/g, ""); 
    return v; 
   } 

   function replaceAll(vStr, vSource, vTarget) {    
    return vStr.replace(new RegExp(vSource,"gm"),vTarget); 
   }


  
  //检查是不是在vBegin,vEnd范围内
  function notBeteen(oFormObj, sObjName, vBegin, vEnd) {
     var v = oFormObj.value;
     if (v < vBegin || v > vEnd || v.length < vBegin.length || v.length > vEnd.length) {
      //oFormObj.focus();
      alert(sObjName + "不能超过" + vBegin + "--" + vEnd + "的范围");
      return false;
    }
    return true;
  }

  //主要是把<br>转成\n
  function toJavaStr(v) {
    v = v.replace(/(<br>)/g, "\n"); 
    return v;
  }

  //主要是把&nbsp;转成" "
  function toJsStr(v) {
    v = v.replace(/(&nbsp;)/g, " "); 
    return v;
  }

  //当前date:yyyy-MM-dd
  function getCurrentDate() {
    var today  = new Date();
    var vYear  = today.getYear();
    var vMonth = today.getMonth() + 1;
    var vDate  = today.getDate();
    var v = vYear + "-";
    if (vMonth < 10) {
      v += "0" + vMonth + "-";
    } else {
      v += vMonth + "-";
    }
    if (vDate < 10) {
      v += "0" + vDate;
    } else {
      v += vDate;
    }
    return v;
  }

  //当前time:yyyy-MM-dd hh:mm
  function getCurrentTime() {
    //测试日期
    var today  = new Date();
    var vYear  = today.getYear();
    var vMonth = today.getMonth() + 1;
    var vDate  = today.getDate();
    var v = vYear + "-";
    if (vMonth < 10) {
      v += "0" + vMonth + "-";
    } else {
      v += vMonth + "-";
    }
    if (vDate < 10) {
      v += "0" + vDate;
    } else {
      v += vDate;
    }

    var vHour = today.getHours();
    var vMinute = today.getMinutes();
    if (vHour < 10) {
      v += " " + "0" + vHour;
    } else {
      v += " " + vHour;
    }

    if (vMinute < 10) {
      v += ":" + "0" + vMinute;
    } else {
      v += ":" + vMinute;
    }
    return v;
  }


  //不能
  function isZero(str) {
    if (str == "0") {
      return true;
    }
    return false;
  }

  //判断是否全部为空格
  function isSpace(str) {
      var len = str.length;

      for(var i=0; i< len; i++) {
          temp = str.substring(i,i+1);
          if (temp != " ") {
		return false;
          }
      }
      return true;
  }

  function isLetterOrNum(str) {
      var len = 0;
      len = str.length;
      var i = 0;
      for( i=0; i< len; i++) {
          temp = str.substring(i,i+1);
          if ((temp >="a" && temp<="z") || (temp >="A" && temp<="Z") || (temp >="0" && temp<="9")) {
              continue;
          }
          else {
              return false;
          }
      }
      return true;
  }

  function isLetterOrNumOrLine(str) {
      var len = 0;
      len = str.length;
      var i = 0;
      for( i=0; i< len; i++) {
          temp = str.substring(i,i+1);
          if ((temp >="a" && temp<="z") || (temp >="A" && temp<="Z") || (temp >="0" && temp<="9") || temp == "_") {
              continue;
          }
          else {
              return false;
          }
      }
      return true;
  }

  //检查是否全部是字母
  function isLetter(str) {
      var len = 0;
      len = str.length;
      var i = 0;
      for( i=0; i< len; i++) {
          temp = str.substring(i,i+1);
          if ((temp >="a" && temp<="z") || (temp >="A" && temp<="Z")) {
              continue;
          }
          else {
              return false;
          }
      }
      return true;
  }

  //检查是否全部为数字
  function isNum(str) {
      var len = 0;
      len = str.length;
      var i = 0;
      for( i=0; i< len; i++) {
          temp = str.substring(i,i+1);
          if (temp >="0" && temp<="9") {
              continue;
          }
          else {
              return false;
          }
      }
      return true;
  }

  //检查是不是"数字.数字"的格式
  function isPrice(str) {
      var len = 0;
      len = str.length;
      var i = 0;
      var count = 0;

      for( i=0; i< len; i++) {
          temp = str.substring(i,i+1);
          if (temp == "." && count<1) {
              count++;
              continue;
          } 
          else if (temp == "-" && i == 0) {
	      continue;
          }
          else if (temp >="0" && temp<="9") {
              continue;
          }
          else {
              return false;
          }
      }
      return true;
  }

  //判断是否为0，为0则提示不能为空
  function notZero(oFormObj, sObjName) {
    if (isZero(oFormObj.value)) {
      //oFormObj.focus();
      alert(sObjName + "不能为空");
      return false;
    }
    return true;
  }

  //判断是否全部为空格
  function notSpace(oFormObj, sObjName) {
    if (isSpace(oFormObj.value)) {
      //oFormObj.focus();
      alert(sObjName + "不能为空");
      return false;
    }
    return true;
  }

  //检查是否全部为数字
  function notNum(oFormObj, sObjName) {
    if (!isNum(oFormObj.value)) {
      //oFormObj.focus();
      alert(sObjName + "只能填写数字");
      return false;
    }
    return true;
  }
  //检查是不是"数字.数字"的格式
  function notPrice(oFormObj, sObjName) {
    if (!isPrice(oFormObj.value)) {
      //oFormObj.focus();
      alert(sObjName + "只能填写数字.数字");
      return false;
    }
    return true;
  }


  //第一个表示对象，form。按照form的默认地址提交
  function FormSubmitDefault(oFormName) {
    oFormName.submit();
  }

  //第一个表示对象，form，第二个表示字符串
  function FormSubmit(oFormName, vUrl) {
    oFormName.action = vUrl;
    //oFormName.target = "_self";
    oFormName.submit();
  }

  //第一个表示对象，form，第二个表示字符串
  function FormSubmitConfirm(oFormName, vUrl, vMessage) {
    if (confirm(vMessage)) {
      oFormName.action = vUrl;
      //oFormName.target = "_self";
      oFormName.submit();
    }
  }

  //第一个表示对象，form，第二个表示字符串
  //form里必须有两个txtSortField,txtSortOrder
  function ReSort(oFormName, vSortField) {
    var vSortOrder = oFormName.txtSortOrder.value;
    if (vSortOrder == 1) {
      vSortOrder = 0;
    } else {
      vSortOrder = 1;
    }
    oFormName.txtSortOrder.value = vSortOrder;
    oFormName.txtSortField.value = vSortField;
    oFormName.target = "_self";
    oFormName.submit();
  }

  //连接到指定的页面
  function GoUrl(vUrl) {
    document.location.href = vUrl;
  }

  //连接到指定的页面
  function GoUrlConfirm(vUrl, vMessage, divLine) {
    if (confirm(vMessage)) {
      if (divLine != null && divLine != "") {
	document.getElementById(divLine).style.display = "block";
      }
      document.location.href = vUrl;
    }
  }

  //javascript参数的调用：
  //checkAll(formList,chkCheckAll,'chkId')
  //第一个表示对象，第二个表示对象，第三个表示字符串
  function CheckAll(oFormList, oChkCheckAll, vChkId) {
    var e;
    for (var i=0; i<oFormList.elements.length; i++) {
      e = oFormList.elements[i];
      if (e.name == vChkId) {
        e.checked = oChkCheckAll.checked;
      }
    }
  }

  //javascript函数：NumberOfCheck(oChk)
  //参数为一个check对象，一般是form.chk
  //返回同名的checkbox选中的个数。0表示没有一个选中。
  function NumberOfCheck(oChk) {
    var vCheck = 0;
    var vLen = 0;
    if (oChk == null) {
	return vCheck;
    }
    if (oChk.checked == true) {
      vCheck = 1;
    } else {
      vLen = oChk.length;
    }
    for (var i=0; i<vLen; i++) {
      if (oChk[i].checked == true) {
        vCheck = vCheck + 1;
      }
    }
    return vCheck;
  }

  function ValueOfCheck(oChk) {
    var v = "";
    var vCheck = 0;
    var vLen = 0;
    if (oChk == null) {
      return "";
    }
    if (oChk.checked == true) {
      v = oChk.value;
    } else {
      vLen = oChk.length;
    }
    for (var i=0; i<vLen; i++) {
      if (oChk[i].checked == true) {
        v += "," + oChk[i].value;
      }
    }
    return v;
  }

  function ValueOfSelect(oSelect, tag) {
    var iLen = oSelect.length;
    var v = "";
    for (var i=0; i<iLen; i++){
        v += tag + oSelect.options[i].value;
    }
    return v;
  }

  //2013-12-10增加，对check,radio的disable
  function DisabledCheck(idChk, flag) {
    var oChk = document.getElementsByName(idChk);
    var vLen = 0;
    if (oChk == null) {
      return "";
    }
    vLen = oChk.length;
    for (var i=0; i<vLen; i++) {
      oChk[i].disabled = flag;
    }
  }

  //javascript函数：ValueOfRadio(oChk)
  //参数为一个radio对象，一般是form.chk
  //返回同名的radio选中的值
  function ValueOfRadio(oChk) {
    var vCheckValue = "";
    var vLen = 0;
    //2008-01-19,增加判断是否为空，不判断的话可能出现undefine的情况。
    if(oChk == null) {
       return "";
    }
    if (oChk.checked == true) {
      vCheckValue = oChk.value;
    } else {
      vLen = oChk.length;
    }

    for (var i=0; i<vLen; i++) {
      if (oChk[i].checked == true) {
        vCheckValue = oChk[i].value;
        break;
      }
    }

    return vCheckValue;
  }

  //2011-11-04增加：支持ff
  function ValueOfRadio2(idChk) {
    var oChk = document.getElementsByName(idChk);
    var vCheckValue = "";

    var vLen = 0;
    //2008-01-19,增加判断是否为空，不判断的话可能出现undefine的情况。
    if(oChk == null) {
       return "";
    }
    if (oChk.checked == true) {
      vCheckValue = oChk.value;
    } else {
      vLen = oChk.length;
    }

    for (var i=0; i<vLen; i++) {
      if (oChk[i].checked == true) {
        vCheckValue = oChk[i].value;
        break;
      }
    }

    return vCheckValue;
  }

  function CheckRadio(oChk, vValue) {

    var vLen = 0;
    //2008-01-19,增加判断是否为空，不判断的话可能出现undefine的情况。
    if(oChk == null) {
       return "";
    }
    vLen = oChk.length;
    if (vLen == null) {
      if (oChk.value == vValue) {
        oChk.checked = true;
      }
      return;
    }

    for (var i=0; i<vLen; i++) {
      if (oChk[i].value == vValue) {
        oChk[i].checked = true;
        break;
      } //if ends
    } //for ends

  } //function CheckRadio ends

  function CheckCheckBox(oChk, vValue) {

    var vLen = 0;
    //2008-01-19,增加判断是否为空，不判断的话可能出现undefine的情况。
    if(oChk == null) {
       return "";
    }
    vLen = oChk.length;
    if (vLen == null) {
      if (oChk.value == vValue) {
        oChk.checked = true;
      } else {
        oChk.checked = false;
      }
      return;
    }

    //把vValue分割
    vValueArray = new Array();
    if (vValue.indexOf(";") >=0 ) {
      vValueArray = vValue.split(";");
    } else if (vValue.indexOf(",") >=0 ) {
      vValueArray = vValue.split(",");
    } else if (vValue != "" ) {
      //2010-09-13增加判断，当只有一个值的时候。	
      vValueArray = new Array(vValue);
    } 

    if (vValueArray == null) {
      return;
    }
    var vLenValue = vValueArray.length;

    //初始化
    for (var i=0; i<vLen; i++) {
      oChk[i].checked = false;
    }

    for (var i=0; i<vLen; i++) {
      for (var j=0; j<vLenValue; j++) {
        if (oChk[i].value == vValueArray[j]) {
            oChk[i].checked = true;
        }//if else
      } //for (var j =0) ends
    } //for ends

  } //function CheckRadio ends

  function DepartUserWin(objId, objName, objDesc, objDescName) {
    //type=all没有限制，same同一部门，tree树下的子部门
    var type = "all";
    var url = "../../share/organize/user_win.jsp";
    url = url + "?objId=" + objId + "&objName=" + objName
        + "&objDesc=" + objDesc + "&objDescName=" + objDescName
        + "&type=" + type;
    window.showModalDialog(url,window,"status=no;dialogWidth=680px;dialogHeight=450px");
  }

  //员工单选
  function OpenWin12(objId, objName) {
    var type = "all";
    var url = "../../share/organize/user_win.jsp";
    url = url + "?objId=" + objId + "&objName=" + objName + "&type=" + type;
    window.showModalDialog(url,window,"status=no;dialogWidth=680px;dialogHeight=450px");
  }

  //以下为多部门，多员工的选
  function OpenWin14(objId, objName) {
    var type = "all";
    var url = "../../share/organize/user_win2.jsp";
    url = url + "?objId=" + objId + "&objName=" + objName + "&type=" + type;
    window.showModalDialog(url,window,"status=no;dialogWidth=680px;dialogHeight=450px");
  }


  //以下为多部门，多员工的选
  function OpenWin34(vLevel, objId, objName) {
    var type = "all";
    var url = vLevel + "share/organize/user_win2.jsp";
    url = url + "?objId=" + objId + "&objName=" + objName + "&type=" + type;
    window.showModalDialog(url,window,"status=no;dialogWidth=680px;dialogHeight=450px");
  }

  //部门单选
  function OpenWin22(objDesc, objDescName) {
    //type=all没有限制，same同一部门，tree树下的子部门
    var type = "all";
    var url = "../../share/organize/user_win.jsp";
    url = url + "?objDesc=" + objDesc + "&objDescName=" + objDescName
        + "&type=" + type;
    window.showModalDialog(url,window,"status=no;dialogWidth=680px;dialogHeight=450px");
  }

  function OpenManageDepart(objDesc, objDescName) {
    //type=all没有限制，same同一部门，tree树下的子部门
    var type = "manage";
    var url = "../../share/organize/user_win.jsp";
    url = url + "?objDesc=" + objDesc + "&objDescName=" + objDescName
        + "&type=" + type;
    window.showModalDialog(url,window,"status=no;dialogWidth=680px;dialogHeight=450px");
  }

  //员工单选
  function OpenManageUser(objId, objName) {
    var type = "manage";
    var url = "../../share/organize/user_win.jsp";
    url = url + "?objId=" + objId + "&objName=" + objName + "&type=" + type;
    window.showModalDialog(url,window,"status=no;dialogWidth=680px;dialogHeight=450px");
  }

  //部门多选
  function OpenWin24(objDesc, objDescName) {
    //type=all没有限制，same同一部门，tree树下的子部门
    var type = "all";
    var url = "../../share/organize/depart_win2.jsp";
    url = url + "?objDesc=" + objDesc + "&objDescName=" + objDescName
        + "&type=" + type;
    window.showModalDialog(url,window,"status=no;dialogWidth=380px;dialogHeight=450px");
  }

  function OpenWin3(vLevel, objId, objName, objDesc, objDescName, objPostId, objPostName) {
    var type = "all";
    var url = vLevel + "share/organize/user_win3.jsp";

    url = url + "?objId=" + objId + "&objName=" + objName;
    url = url + "&objDesc=" + objDesc + "&objDescName=" + objDescName;
    url = url + "&objPostId=" + objPostId + "&objPostName=" + objPostName;
    
    window.showModalDialog(url,window,"status=no;dialogWidth=800px;dialogHeight=450px");
  }

  function OpenWin32(vLevel, objId, objName) {
    var type = "all";
    var url = vLevel + "share/organize/user_win.jsp";
    url = url + "?objId=" + objId + "&objName=" + objName + "&type=" + type;
    window.showModalDialog(url,window,"status=no;dialogWidth=680px;dialogHeight=450px");
  }

  //当使用附件时，名字不可以修改，已经写进类里面
  function FileChange(vIndex) {
    var vCount = parseInt(formUpdate.fileCount.value);
    var oFile = eval("formUpdate.file" + vIndex);
    var vHtml = "";

    //增加判断

    if (oFile.value != "" && vCount == vIndex) {
      vCount = vCount + 1;
      formUpdate.fileCount.value = vCount;
      //增加一行
      var row = tableAnnex.insertRow(tableAnnex.rows.length);
      var cell;
      cell = row.insertCell();
      cell.colSpan = "3";
      vHtml = "<input type='file' name='file" + vCount + "' class='fileClass2' onPropertyChange='javascript:FileChange(" + vCount + ");'>";
      cell.innerHTML = vHtml;
    }
  }

  //2012-05-31增加
  function FileChangeNew(vIndex, fileSize, allowFileExt) {
    var vCount = parseInt(formUpdate.fileCount.value);
    var oFile = eval("formUpdate.file" + vIndex);
    var vHtml = "";

    var iM = parseInt(fileSize);
    var sM = "";    
    if (iM > 1000 * 1000) {
	sM = (iM/1000/1000) + "M";
    } else if (iM >  1000) {
	sM = (iM/1000) + "K";
    } else {
	sM = (fileSize) + "B";
    }
    //增加判断
    //alert(getFileSize("file" + vIndex));
    //var vFileSize = getFileSize("file" + vIndex);
    var vFileSize = 0;
    var vFileExt = getFileExt("file" + vIndex);

    if (vFileExt == "" || ("," + allowFileExt + ",").indexOf("," + vFileExt + ",") == -1 ) {
      //不在允许范围内
      document.getElementById("fileUploadAlert" + vIndex).innerHTML =  "<font color='#F02C56'>" + vFileExt +"附件不在允许范围内</font>";
    } else if (vFileSize > fileSize) {
      document.getElementById("fileUploadAlert" + vIndex).innerHTML =  "<font color='#F02C56'>附件超过允许的大小" + (sM) + "</font>";
    } else {
      document.getElementById("fileUploadAlert" + vIndex).innerHTML = "(大小不能超过" + sM + ")";
    }

    if (oFile.value != "" && vCount == vIndex) {
      vCount = vCount + 1;
      formUpdate.fileCount.value = vCount;
      //增加一行
      var row = tableAnnex.insertRow(tableAnnex.rows.length);
      var cell;
      cell = row.insertCell();
      cell.colSpan = "3";
      vHtml = "<input type='file' name='file" + vCount + "' class='fileClass2' onPropertyChange=\"javascript:FileChangeNew(" + vCount + ",'" + fileSize + "','" + allowFileExt + "');\">";
      vHtml += "<span id='fileUploadAlert" + vCount + "'></span>"
      cell.innerHTML = vHtml;
    }

  }

  function getFileExt(fileId) { 
     var vFileExt = "";

     var obj = document.getElementById(fileId);

     if (obj != null) {
	vFileExt = obj.value;
     }

     var iLastIndex = vFileExt.lastIndexOf(".");

     if (iLastIndex > 0) {
	vFileExt = vFileExt.substring(iLastIndex + 1, vFileExt.length);
     }

     return vFileExt;
  }

  //2012-05-31增加:可以获得文件大小，但是总是会提示activex不安全，不建议使用。
  function getFileSize(fileId) {  
    var obj = document.getElementById(fileId); 
    var  Sys = {};   
    if(navigator.userAgent.indexOf("MSIE")>0) {   
      Sys.ie=true;   
    }   
    if(isFirefox=navigator.userAgent.indexOf("Firefox")>0) {   
      Sys.firefox=true;   
    }
    var filesize = 0;   
       
    if(Sys.firefox) {   
        filesize = obj.files[0].fileSize;   
    } else if(Sys.ie) {   
        var fileobject = new ActiveXObject ("Scripting.FileSystemObject");//获取上传文件的对象   
        var file = fileobject.GetFile(obj.value);//获取上传的文件   
        var filesize = file.Size;//文件大小   
    }   
    return filesize;
  }   



  //弹出窗口
  function OpenIdSingleWin(vTableName, objId, objName) {
    var type= "";
    var url = "../../share/page/id_single_win.jsp";
    url = url + "?objId=" + objId + "&objName=" + objName + "&tableName=" + vTableName;
    window.showModalDialog(url,window,"status=no;dialogWidth=580px;dialogHeight=350px");
  }

  //弹出窗口
  function OpenFormIdSingleWin(vTableName, objId, objName) {
    var type= "";
    var url = "../../share/page/formId_single_win.jsp";
    url = url + "?objId=" + objId + "&objName=" + objName + "&tableName=" + vTableName;
    window.showModalDialog(url,window,"status=no;dialogWidth=580px;dialogHeight=350px");
  }

  function OpenIdSingleWinSubmit(vTableName, objId, objName, vFormName) {
    var type= "";
    var url = "../../share/page/id_single_win.jsp";
    url = url + "?objId=" + objId + "&objName=" + objName + "&tableName=" + vTableName + "&formName=" + vFormName;
    window.showModalDialog(url,window,"status=no;dialogWidth=580px;dialogHeight=350px");
  }

  //弹出窗口
  function OpenIdMultWin(vTableName, objId, objName) {
    var type= "";
    var url = "../../share/page/id_mult_win.jsp";
    url = url + "?objId=" + objId + "&objName=" + objName + "&tableName=" + vTableName;
    window.showModalDialog(url,window,"status=no;dialogWidth=580px;dialogHeight=350px");
  }

  //弹出窗口:只列出自己的
  function OpenIdMultWinSelf(vTableName, objId, objName) {

    var type= "";
    var url = "../share/page/id_mult_win_self.jsp";
    url = url + "?objId=" + objId + "&objName=" + objName + "&tableName=" + vTableName;
    window.showModalDialog(url,window,"status=no;dialogWidth=580px;dialogHeight=350px");
  }


  //弹出窗口
  function OpenIdMultWin2(vTableName, objId, objName) {
    var type= "";
    var url = "../share/page/id_mult_win.jsp";
    url = url + "?objId=" + objId + "&objName=" + objName + "&tableName=" + vTableName;
    window.showModalDialog(url,window,"status=no;dialogWidth=580px;dialogHeight=350px");
  }

  //弹出窗口
  function OpenSelectWin(vTableName) {
    var type= "";
    var url = "../../share/formEngine2/select_win.jsp";
    url = url + "?tableName=" + vTableName + "&index=-1";
    window.showModalDialog(url,window,"status=no;dialogWidth=580px;dialogHeight=350px");
  }

  //弹出窗口
  function OpenSelectWinJs(vTableName, vFunc) {
    var type= "";
    var url = "../../share/formEngine2/select_win.jsp";
    url = url + "?tableName=" + vTableName + "&index=-1" + "&func=" + vFunc;
    window.showModalDialog(url,window,"status=no;dialogWidth=580px;dialogHeight=350px");
  }

  //弹出窗口
  function OpenDetailSelectWin(vTableName) {
    //取得点的是哪一行
    var oTr = event.srcElement.parentElement.parentElement;
    var vIndex = -1;
    if (oTr.nodeName == "TR" || oTr.nodeName == "tr") {
        vIndex = oTr.rowIndex -1;
    }
    var url = "../../share/formEngine2/select_win.jsp";
    url = url + "?tableName=" + vTableName + "&index=" +vIndex;
    window.showModalDialog(url,window,"status=no;dialogWidth=580px;dialogHeight=350px");

  } 

  function AddDetailRow3(oTable, vCount, vReadonly, vDetailCount) {

    if (oTable == null) {
      return;
    }
    var oDiv = document.getElementById("div" + oTable.id);
    if (oDiv == null) {
      return;
    }
    //获得第二行
    var oRow = oTable.rows[1];
    if (oRow == null) {
      return;
    }
    var oCell = null;
    var vCellLen = oRow.cells.length;
    //默认增加5行
    var oRowTemp = null;
    var oCellTemp = null;
    var iLen = 0;

    var i = 0;
    var j = 0;
    var k = 0;


    //2010-06-12第一行增加判断函数
    if (vReadonly == "false") {
      for (i=0; i<vCellLen; i++) {
      	oCellTemp = oRow.cells[i];
          if (oCellTemp.childNodes != null) {
            iLen = oCellTemp.childNodes.length;
            for (k=0; k<iLen; k++) {
              if (oCellTemp.childNodes[k] != null && oCellTemp.childNodes[k] != "") {
		//oCellTemp.childNodes[k].attachEvent("onblur", new Function("FormCheckDetail(formUpdate)"));
		//上行注释，当该单元格没有控件时出错。
		if (typeof(oCellTemp.childNodes[k].id) != "undefined") {
		  oCellTemp.childNodes[k].attachEvent("onblur", new Function("FormCheckDetail(formUpdate)"));
		}
              }
            } //for (k=0; k<iLen; k++) {
          }
      } //for (i=0; i<vCellLen; i++) {   
    } //if (vReadonly == "false") {

    for (j=0; j<vCount; j++) {
      oRowTemp = oTable.insertRow(oTable.rows.length);

      for (i=0; i<vCellLen; i++) {
        oCellTemp = oRowTemp.insertCell(i);

        if (i == 0) {
          oCellTemp.innerHTML = oDiv.innerHTML;
          if (oCellTemp.childNodes != null) {
            iLen = oCellTemp.childNodes.length;
            for (k=0; k<iLen; k++) {
              if (oCellTemp.childNodes[k] != null && oCellTemp.childNodes[k] != "") {
                oCellTemp.childNodes[k].style.display = "none";
                //oCellTemp.childNodes[k].attachEvent("onblur", new Function("FormCheckDetail(formUpdate)"));
              }
            }
          }
        }
        oCellTemp.innerHTML += oRow.cells[i].innerHTML;

        if (oCellTemp.childNodes != null) {

          iLen = oCellTemp.childNodes.length;

          for (k=0; k<iLen; k++) {
            //当列数不够的时候，这里有异常，要增加判断
            if (oCellTemp.childNodes[k] != null && oCellTemp.childNodes[k] != ""
                && oCellTemp.childNodes[k].nodeName == "INPUT" ) {
	      ////判断是否选择的按纽
	      if (oCellTemp.childNodes[k].type == "button" && oCellTemp.childNodes[k].name=="btnSelect") {

     	      } else {
              	  oCellTemp.childNodes[k].value = "";
                  oCellTemp.childNodes[k].attachEvent("onblur", new Function("FormCheckDetail(formUpdate)"));
	      	  if (vReadonly == "true") {
              	      oCellTemp.childNodes[k].readOnly = true;
              	      oCellTemp.childNodes[k].style.background = "#EAF2F3";
	          } else if (vReadonly == "false") {
              	      oCellTemp.childNodes[k].readOnly = false;
	          }
	      }
            }
          } // for ends
        } //if ends


      } // for (var i=0)
    } // for (var j=0)
    //formUpdate.detailCount.value = oTable.rows.length - 1;
    eval("formUpdate." + vDetailCount + ".value= oTable.rows.length - 1;");

  }//function AddDetailRow ends;

  function AddDetailRow2(oTable, vCount, vReadonly) {
    AddDetailRow3(oTable, vCount, vReadonly, "detailCount");
  }

  function AddDetailRow(oTable, vCount) {
    AddDetailRow2(oTable, vCount, "false");
  }

  function AddTotalRow(oTable) {

    if (oTable == null) {
      return;
    }
    var oDiv = document.getElementById("div" + oTable.id);
    if (oDiv == null) {
      return;
    }
    //获得Total table
    var oTableTotal = document.getElementById(oTable.id + "Total");   
    if (oTableTotal == null) {
      return;
    }

    //获得第二行
    var oRow = oTable.rows[1];
    if (oRow == null) {
      return;
    }
    var vCellLen = oRow.cells.length;
    //默认增加5行
    var oRowTemp = null;
    var oCellTemp = null;

    var i = 0;

    /////增加一行，用来统计数量, vCount
    var vCount = 1;

    oRowTemp = oTableTotal.insertRow(oTableTotal.rows.length);
    oRowTemp.className = "trClassTitle";

    for (i=0; i<vCellLen; i++) {
        oCellTemp = oRowTemp.insertCell(i);
        oCellTemp.innerHTML = "&nbsp;";
    } // for (var i=0)

  }//function AddDetailRow ends;

  function RenameObject(oTable) {
    RenameObject3(oTable, "detailCount");
  }

  function RenameObject3(oTable, vDetailCount) {

    if (oTable == null) {
      return;
    }  
    var vCount = oTable.rows.length;
    var oRow = null;
    //获得第二行
    var oRow = oTable.rows[1];
    if (oRow == null) {
      return;
    }
    var oCell = null;
    var vCellLen = oRow.cells.length;
    
    var oRowTemp = null;
    var oCellTemp = null;
    var iLen = 0;
    var oObject = null;
    var i = 0;
    var j = 0;
    var k = 0;

    for (j=1; j<vCount; j++) {
      //取得行
      oRowTemp = oTable.rows[j];
      if (j == 1) {
	//如果是第一行，有一部分数据在div里面
        oCellTemp = document.getElementById("div" + oTable.id);
	if (oCellTemp != null && oCellTemp.childNodes != null) {
          iLen = oCellTemp.childNodes.length;
          for (k=0; k<iLen; k++) {
            if (oCellTemp.childNodes[k] != null && oCellTemp.childNodes[k] != ""
                && oCellTemp.childNodes[k].nodeName == "INPUT" ) {
              //oCellTemp.childNodes[k].value = "";
              oObject = oCellTemp.childNodes[k];
      	      oObject.id = oObject.id + "_" + j;
      	      oObject.name = oObject.name + "_" + j;
      	      //oObject.value = oObject.id;
            }//if
          } //for k
        }
      }
      //取得行下面的列
      for (i=0; i<vCellLen; i++) {
        oCellTemp = oRowTemp.cells[i];
        if (oCellTemp.childNodes != null) {
          iLen = oCellTemp.childNodes.length;
          for (k=0; k<iLen; k++) {
            if (oCellTemp.childNodes[k] != null && oCellTemp.childNodes[k] != ""
                && oCellTemp.childNodes[k].nodeName == "INPUT" ) {
	 
              //oCellTemp.childNodes[k].value = "";
              oObject = oCellTemp.childNodes[k];
      	      oObject.id = oObject.id + "_" + j;
      	      oObject.name = oObject.name + "_" + j;

      	      //oObject.value = oObject.id;
            }//if
          } //for k
        }	//if (oCellTemp.childNodes != null) 
      } // for (var i=0)
    } // for (var j=0)
    //formUpdate.detailCount.value = vCount -1;

    eval("formUpdate." + vDetailCount + ".value= vCount -1;");
  }//function RenameObject ends;

  function copyValue(objTarget, objSource) {
	objTarget.value = objSource.value;
  }

  //2009-12-26增加
  function disableOther() {
    var obj = document.all;
    var vType = null;
    if (obj != null) {
      if (obj.length == null) {
    	obj.disabled = true;
      } else {
        var vLen = obj.length;
        for (var i=0; i<vLen; i++) {
	  vType = obj[i].getAttribute("type");

          if (vType == "radio" || vType == "checkbox") {
  	     obj[i].disabled = true;
	  } else if ( vType == "select-one") {
  	     obj[i].disabled = true;
	  }	
	}
      }
    }
  }

  function disableAll(obj) {
    if (obj != null) {
      if (obj.length == null) {
    	obj.disabled = true;
      } else {
        var vLen = obj.length;
        for (var i=0; i<vLen; i++) {
  	  obj[i].disabled = true;
	}
      }
    }
  }
  //2009-12-26增加
  function hideAll(obj) {
    if (obj != null) {
      if (obj.length == null) {
    	obj.disabled = true;
        obj.style.display = "none"
      } else {
        var vLen = obj.length;
        for (var i=0; i<vLen; i++) {
          obj[i].style.display = "none"
	}
      }
    }
  }

  //2010-01-23
  function DepartUserWin2(objId, objName, objDesc, objDescName) {
    //type=all没有限制，same同一部门，tree树下的子部门
    var type = "all";
    var url = "../../share/organize/user_win2.jsp";
    url = url + "?objId=" + objId + "&objName=" + objName
        + "&objDesc=" + objDesc + "&objDescName=" + objDescName
        + "&type=" + type;
    window.showModalDialog(url,window,"status=no;dialogWidth=680px;dialogHeight=450px");
  }

  function DepartAndUserName(objName) {
    //type=all没有限制，same同一部门，tree树下的子部门
    var type = "all";
    var url = "../../share/organize/user_win4.jsp";
    url = url + "?objName=" + objName + "&type=" + type;
    window.showModalDialog(url,window,"status=no;dialogWidth=680px;dialogHeight=450px");
  }
  
  //2010-07-01增加AJAX执行函数
  function AJAX(vUrl, vMessage, bFresh)  {
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.open("POST", vUrl, false);
	xmlhttp.send(null);

	if (xmlhttp.readyState == 4) { 
	  if (vMessage != "") {
	    alert(vMessage);
	  }
	  if (bFresh == true) {
	     document.location.reload();
	  }
	}
	xmlhttp.abort();
	xmlhttp = null;
  }

  //2012-01-11增加
  var vBeforeFrameHtmlUnload = true;
  function beforeFrameHtmlUnload() {
	if (vBeforeFrameHtmlUnload == true) {
	  return "------------------------------\n\n离开或关闭本页面，未保存的数据可能丢失，是否继续\n\n-----------------------------";	
	} else {

	}
  }

