function trim(str) {
  return str.replace(/(^\s*)|(\s*$)/g,'');
}

function CheckChange(readId,writeExt,writeFileName) {
  var _value  = document.getElementById(readId).value;
  var _indexB = _value.lastIndexOf('.');
  var _indexE = _value.length;
  var _tCvalue= _value.substring(_indexB+1, _indexE);
  document.getElementById(writeExt).value = _tCvalue;
  
  var _IndexB1 = _value.lastIndexOf('\\');
  var _IndexE1 = _value.lastIndexOf('.');
  var _TCvalue1 = _value.substring(_IndexB1+1, _IndexE1);
  document.getElementById(writeFileName).value = _TCvalue1;
}

function CheckChangeExt(readId,writeId) {
  var _value  = document.getElementById(readId).value;
  var _indexB = _value.lastIndexOf('.');
  var _indexE = _value.length;
  var _tCvalue= _value.substring(_indexB+1, _indexE);
  document.getElementById(writeId).value = _tCvalue;
}
   
function SelectionData(sCode, sName) {
  this.code = sCode;
  this.name = sName;
  this.selection1 = null;
}

function SelectionArgument() {
  this.multi = "false";
  this.initialData = null;
}

function dataDeleteConfirm(sUrl) {
  var decision = showDataDeleteConfirm();
  if (decision != "0"){
    window.location = sUrl;
  }
}

function showDataDeleteConfirm() {
  return confirm("您确实要删除数据吗?");
}

function dataArchiveDeleteConfirm(sUrl) {
  var decision = showDataArchiveDeleteConfirm();
  if (decision != "0"){
    window.location = sUrl;
  }
}

function showDataDelete3Confirm(sUrl) {
  var decision =  confirm("您确实要删除刊号吗?");
 if (decision != "0"){
    window.location = sUrl;
  }
}

function showDataArchiveDeleteConfirm() {
  return confirm("您确实要删除附件吗?");
}

function dataRevertConfirm(sUrl) {
  var decision = showDataRevertConfirm();
  if (decision != "0"){
    window.location = sUrl;
  }
}

function showDataRevertConfirm() {
  return confirm("您确实要还原数据吗?");
}

function dataCancelConfirm(sUrl) {
  var decision = confirm("您确实要作废数据吗?");
  if (decision != "0"){
    window.location = sUrl;
  }
}

function dataGatherConfirm(sUrl) {
  var decision = confirm("您确实要汇总当期数据吗?");
  if (decision != "0"){
    window.location = sUrl;
  }
}

function dataGather1Confirm(sUrl,txts) {
  var decision = confirm("您确实要根据'"+txts+"'进行汇总当期数据吗?");
  if (decision != "0"){
    window.location = sUrl;
  }
}

function dataFileNoConfirm(sUrl) {
  var decision = confirm("您确实要删除与相关文件的链接吗?");
  if (decision != "0"){
    window.location = sUrl;
  }
}

function dataFileCancelConfirm(sUrl) {
  var decision = confirm("您确实取消公示此内容吗?");
  if (decision != "0"){
    window.document.getElementById("div1").style.display = "";
    window.location = sUrl;
  }
}

function dataMonitorConfirm(sUrl,msg,dateInfo) {
  var decision = confirm("您确实要作废 '"+dateInfo+"'日 '"+msg+"' 的数据吗?");
  if (decision != "0"){
    window.document.getElementById("div1").style.display = "";
    window.location = sUrl;
  }
}

function dataIssueConfirm(sUrl) {
  var decision = confirm("您确定要公示所有数据吗?");
  if (decision != "0"){
    window.location = sUrl;
  }
}

function dataIssue1Confirm(sUrl) {
  var decision = confirm("您确定要公示此文件吗?");
  if (decision != "0"){
    window.document.getElementById("div1").style.display = "";
    window.location = sUrl;
  }
}

function dataMonitorImpConfirm1(sUrl) {
  var decision = confirm("您确定要发布数据吗?");
  if (decision != "0"){
    window.document.getElementById("div1").style.display = "";
    window.location = sUrl;
  }
}
function init(){
			var obj=document.getElementById("exportFlag");
			if(obj.value=="yes") {
			alert("数据公示成功!");
			obj.value="no";
			}

}

//是否为IE
   function isIEBrowser() {
      if (navigator.userAgent.indexOf("MSIE") != -1) {
         return true;
      } else {
         return false;
      }
   }

   function deleteRowById(tabId, rowId) {
      var workTable = document.getElementById(tabId);
      var rowNum = document.getElementById(rowId).rowIndex;
      workTable.deleteRow(rowNum);
   }
   
//动态新增关联文档  typeName 是指要选择的栏目名称;
function addItem(tableID,Number,typeName){
      var isIE = isIEBrowser();
      var workHandle = document.getElementById(tableID);
      var maxField = document.getElementById(Number);
      var maxNum = parseInt(maxField.value) + 1;
      var DeleteX;
      var SelectX;
      maxField.value = maxNum;

      TitleX = document.createElement("input");
      TitleX.type = "text";
      TitleX.name = "filename"+tableID+maxNum;
      TitleX.id = "filename"+tableID+maxNum;
      TitleX.size = "30";
      TitleX.readOnly = false;

      if(isIE){
        HiddenX = document.createElement("<input type='hidden' name ='filenameId"+tableID+maxNum+"' id='filenameId"+tableID+maxNum+"'>");
        DeleteX = document.createElement("<input type='button' class='button1' value = '删除' onclick=deleteRowById('" + tableID + "','" + tableID + "Row" + maxNum + "')>");
        SelectX = document.createElement("<input type='button' class='button1' value = '选择' onclick=addDocFrame('"+typeName+"','"+HiddenX.name+"','"+TitleX.name+"')>");
      }
      else{
        HiddenX = document.createElement("input");
        HiddenX.type = "hidden";
        HiddenX.name = "filenameId"+tableID+maxNum;
        HiddenX.id   = "filenameId"+tableID+maxNum;
       
        DeleteX = document.createElement("input");
        DeleteX.type = "button";
        DeleteX.value = "删除";
        DeleteX.cssclass= "button1";
        DeleteX.setAttribute("onclick","deleteRowById('"+tableID+"','"+HiddenX.name+"','"+TitleX.name+"')");
  
        SelectX = document.createElement("input");
        SelectX.type = "button";
        SelectX.value = "选择";
        SelectX.cssclass= "button1";
        SelectX.setAttribute("onclick","addDocFrame('"+typeName+"',"+tableID+"Row"+maxNum+"')");
      }
      var uRow = workHandle.insertRow(workHandle.rows.length);
      uRow.id = tableID + "Row" + maxNum;

      uCell = uRow.insertCell(-1);
      uCell.align = "center";
      uCell.appendChild(DeleteX);
      uCell = uRow.insertCell(-1);
      uCell.align = "left";
      uCell.appendChild(TitleX);
      uCell.appendChild(HiddenX);
      uCell.appendChild(SelectX);
   }
   
   function addDocFrame(typeName,docId,docName)
   {
     var _docId   = document.getElementById(docId);
     var _docName = document.getElementById(docName);
     var obj   = new Object();
     var Selected = new Object();
     var Selected = window.showModalDialog("./docLinkQuery.do?name="+typeName,obj,"dialogWidth=550px");
     if(Selected == null) return;
     if(Selected.id == null || Selected.name == null) return;
     _docId.value   = Selected.id;
     _docName.value = Selected.name;
   }
   
function showDeviceSelectDialog(sUrl) {
  return window.showModalDialog(sUrl, null, "dialogHeight=480px;dialogWidth=660px");
}


function selectChange(id,name){
	var chk = document.getElementById(id);
	var chks = document.getElementsByName(name);
	
	if (chk.checked){
		for (i = 0; i < chks.length; i++)
			chks[i].checked = true;
	}else if (!chk.checked){
		for (i = 0; i < chks.length; i++)
			chks[i].checked = false;
	}
}

function classifyInfo(chkName,dept,pdlx){
	var chks = document.getElementsByName('checkInfo');
	var deptId = document.getElementById(dept);
	var pdlxId = document.getElementById(pdlx); 
	var toClassify = document.getElementById('toClassify');
	var infoIdArray = '';
	
	for (i = 0; i < chks.length; i++){
		if (chks[i].checked){
			infoIdArray = infoIdArray + chks[i].value;
			if (i < chks.length - 1)
				infoIdArray = infoIdArray + ',';
		}
	}
	
	var url = toClassify.getAttribute('href'); 
	toClassify.setAttribute('href',url + '&ids=' + infoIdArray + '&deptId=' + deptId.value + '&pdlxId=' + pdlxId.value);
	
}


function tbs(o,a,b,c,d){
 var t=document.getElementById(o).getElementsByTagName("tr");
 for(var i=0;i<t.length;i++){
  t[i].style.backgroundColor=(t[i].sectionRowIndex%2==0)?a:b;
  t[i].onclick=function(){
   if(this.x!="1"){
    this.x="1";
    this.style.backgroundColor=d;
   }else{
    this.x="0";
    this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;
   }
  }
  t[i].onmouseover=function(){
   if(this.x!="1")this.style.backgroundColor=c;
  }
  t[i].onmouseout=function(){
   if(this.x!="1")this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;
  }
 }
}

//用JS得到URL的相关参数
function getResponseValue(paramName)
{
  var strHref= window.document.location.href;
  var intPos = strHref.indexOf("?");
  var strRight = strHref.substr(intPos+1);
  var arrTmp   = strRight.split("&");
  for(var i = 0;i<arrTmp.length;i++)
  {
    var arrTemp = arrTmp[i].split("=");
    if(arrTemp[0].toUpperCase() == paramName.toUpperCase())
    {
      return arrTemp[1];
    }
   }
   return null;
  
}