  //当使用附件时，名字不可以修改，已经写进类里面
  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);
         document.getElementById("fileUploadAlert" + vIndex).innerHTML = vFileExt ;

    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 + ")";
      document.getElementById("fileUploadAlert" + vIndex).innerHTML = "&nbsp;<input type='button' class='fileClassButton' value='清除' onClick='javascript:FileClear(" + vIndex + ")'>(不能超过" + 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";
      //2014-06-14修改，onPropertyChange修改为onChange，支持chrome;并且增加id
      vHtml = "<input type='file' name='file" + vCount + "' id='file" + vCount + "' class='fileClass2' onChange=\"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;
  }   
  
  //2016-02-27增加，清楚已选的附件
  function FileClear(fileId) {
    var obj = document.getElementById("file" + fileId); 
    if (obj.outerHTML) {
      obj.outerHTML = obj.outerHTML;
    } else {
       obj.value = "";
    }
  }

  //2016-04-15
  function annexNotNull() {
    //判断附件       
    var vCount = 0;
    var vHasAnnex = false;
    var oFileCount = document.getElementById("fileCount");
    if (oFileCount != null) {
      var vCount = parseInt(oFileCount.value);
      for (var v = 1; v<=vCount; v++) {
    	var oFile = document.getElementById("file" + v);
    	if (oFile.value == "") {
        } else {
	  vHasAnnex = true;
	  break;
	}
      }
    }
    
    if (!vHasAnnex) {
      var vAnnexCount = 0;
      var vLen = 0;
      //var oChk = formUpdate.ANNEX_FJID;
      var oChk = document.getElementsByName("ANNEX_FJID");
      if (oChk == null) {
      } else {
    	  if (oChk.checked == true) {
      	  vHasAnnex = false;
      	} else if (oChk.checked == false) {
      	  vHasAnnex = true;      	  
    	  } else {
      	  vLen = oChk.length;
      	  for (var i=0; i<vLen; i++) {
       	    if (oChk[i].checked == false) {
        	vHasAnnex = true;
        	break;  	  
      	    } 
    	  }//for	
    	}    	
      }//else 
    }//if
		    
    if (!vHasAnnex) {
    	alert("请至少选择一个附件");
	return false;
    }
    return true;
  } //function annexNotNull();