/*--
  - Author: konami
  - Date: 20060711
  - Description: 通用Javascript定义。
  - Copyright Notice: Beijing Jingyun Wanfeng Information Technology Co. Ltd.
--*/

var rowhlcolor = "#D2EDFF";
var msg;
var showing = false;
var canSaveFlag = true;
var waitArray = new Array(); // 等待执行的JS代码

// tab的状态，index：序号；disabled：true，禁用；false，启用
function setTabStatus(index, disabled) {
  var td = document.getElementById("tabTag" + index);
  if (td != null) {
    var obj = td.firstChild;
    if (obj != null && obj.tagName == "A") {
      if (obj.disabled || obj.disabled == "true") {
        if (disabled) {
          return;
        }
        if (obj.oldOnclick != null) {
          if (typeof(obj.oldOnclick) == "function") {
            obj.onclick = obj.oldOnclick;
          } else {
            obj.onclick = new Function(obj.oldOnclick);
          }
          obj.removeAttribute("oldOnclick");
        } else if (obj.oldHref != null) {
          obj.href = obj.oldHref;
          obj.removeAttribute("oldHref");
        }
        obj.disabled = false;
      } else {
        if (!disabled) {
          return;
        }
        if (obj.onclick != null) {
          obj.oldOnclick = obj.onclick;
          obj.onclick = function() { return false; };
        } else {
          obj.oldHref = obj.href;
          obj.href = "javascript:return false;";
        }
        obj.disabled = true;
      }
    }
  }
}
function disableButtons() {
  try {
    canSaveFlag = false;
    var objs = document.forms[0].elements;
    var length = objs.length;
    for (var i = 0; i < length; i++) {
      if (objs[i].type == "button") {
        if(objs[i].disabled == false) {
           objs[i].temporaryDisabled = "true";
           objs[i].disabled = true;
        }        
      }
    }
    if (window.disableExtraButtons != null) {
      disableExtraButtons();
    }
  } catch (e) {
  }
}
function enableButtons() {
  try {
    var objs = document.forms[0].elements;
    var length = objs.length;
    for (var i = 0; i < length; i++) {
      if (objs[i].type == "button") {
        if(objs[i].temporaryDisabled != null) {
           objs[i].disabled = false;
           objs[i].style.color = "#000000";
        }        
      }
    }
    if (window.enableExtraButtons != null) {
      enableExtraButtons();
    }
    if (waitArray.length > 0) {
      eval(waitArray.pop());
    }
    canSaveFlag = true;
  } catch (e) {
  }
}
function showProcess(noTime, noDisable) {
  showing = true;
  try {
    if (!noDisable) {
      disableButtons();
    }
	  var div = document.getElementById("divBlind");
	  if (div != null) {
	    div.style.display = "inline";
	    var ifr = document.getElementById("dsaving");
	    if(ifr != null){
			  window.frames["dsaving"].init(noTime);
	    	ifr.style.display = "inline";
	    }
	  }
	  showing = false;
  } catch (e) {
    setTimeout(function() { showProcess(noTime, noDisable); }, 50);
  }
}
function showProcessNew(noTime, noDisable) {
  showing = true;
  try {
    if (!noDisable) {
      disableButtons();
    }
	  var div = document.getElementById("divBlind");
	  if (div == null) {
	    div = document.createElement("<div id='divBlind' class='dblind'></div>");
	    document.body.appendChild(div);
	  }
	  var ifr = document.getElementById("dsaving");
	  if (ifr == null) {
	    ifr = document.createElement("<iframe id='dsaving' src='" + ROOT_PATH
	      + "jsp/process.jsp' frameborder='0' class='dsaving'></iframe>");
	    document.body.appendChild(ifr);
	  }
	  window.frames["dsaving"].init(noTime);
   	ifr.style.display = "inline";
   	div.style.display = "inline";
   	showing = false;
  } catch (e) {
    setTimeout(function() { showProcess(noTime, noDisable); }, 50);
  }
}
function hideProcess() {
  if (showing) {
    setTimeout(hideProcess, 50);
    return;
  }
  try {
	  enableButtons();
	  var div = document.getElementById("divBlind");
	  if (div != null) {
	    div.style.display = "none";
	    var ifr = document.getElementById("dsaving");
	    if(ifr != null){
	         ifr.style.display = "none";
	    	   window.frames["dsaving"].destroy();
	    }
	  }
  } catch(e) {
  }
}
function closeWin() {
  opener = null;
	try {
	  parent.parent.open("", "_self");
		parent.parent.close();
	}catch (e){
		try{
			parent.close();
		}catch(e){
			window.close();
		}
	}
}

function maximize() {
    window.moveTo(-4, -4);
    window.resizeTo(screen.availWidth + 8, screen.availHeight + 8);
}

function resetPage() {
  var pageNum = document.getElementById("pageNum");
  if (pageNum != null) {
    pageNum.value = 0;
  }
}

function gotoPage() {
  processBeforePage();
  var n = parseInt(document.all("findPage").value, 10);
  if (isNaN(n)) {
    n = 1;
  }
  n--;
  var count = parseInt(document.all("pageCount").value, 10);
  if (n < 0) {
    n = 0;
  } else if (n >= count) {
    n = count - 1;
  }
  document.all("pageNum").value = n;
  //andy20090121汇总结果查看跳转错误
  //submitRefresh();
  //document.forms[0].submit();
  if (window.submitRefresh != null) {
    submitRefresh();
  } else {
    showProcess();
    document.forms[0].submit();
  }
  //end20090121
}

function toFirstPage(){
  processBeforePage();
  document.all("pageNum").value = 0;
  if (window.submitRefresh != null) {
    submitRefresh();
  } else {
    showProcess();
    document.forms[0].submit();
  }
}

function toPreviousPage(){
  processBeforePage();
  var pageNum = document.all("pageNum");
  var v = parseInt(pageNum.value, 10) - 1;
  if (v < 0) {
    v = 0;
  }
  pageNum.value = v;
  if (window.submitRefresh != null) {
    submitRefresh();
  } else {
    showProcess();
    document.forms[0].submit();
  }
}

function toNextPage(){
  processBeforePage();
  var pageNum = document.all("pageNum");
  var v = parseInt(pageNum.value, 10) + 1;
  var count = parseInt(document.all("pageCount").value, 10);
  if (v >= count) {
    v = count - 1;
  }
  pageNum.value = v;
  if (window.submitRefresh != null) {
    submitRefresh();
  } else {
    showProcess();
    document.forms[0].submit();
  }
}

function toLastPage(){
  processBeforePage();
  document.all("pageNum").value = parseInt(document.all("pageCount").value, 10) - 1;
  if (window.submitRefresh != null) {
    submitRefresh();
  } else {
    showProcess();
    document.forms[0].submit();
  }
}

function processBeforePage() {
  if (window.pageProcess != null) {
    pageProcess();
  }
}

function mover(obj) {
  obj.oldcolor = obj.style.backgroundColor;
  obj.style.backgroundColor = rowhlcolor;
}

function mout(obj) {
  if (obj.oldcolor != null) {
    obj.style.backgroundColor = obj.oldcolor;
    obj.removeAttribute("oldcolor");
  }
}

function getRelativePath() {
  var rtn;
  var base = document.getElementsByTagName("BASE");
  if (base != null) {
    base = base[0].href;
    rtn = base.substring(0, base.lastIndexOf("/") + 1);
  }
  return rtn;
}
function getParentByTagName(obj, tagName) {
	while (obj != null && obj.tagName != tagName) {
		obj = obj.parentNode;
	}
	return obj;
}
//////add by javaseed/////////////////////

// 名称:全截取函数
// 功能:把指定的文本中左边和右边的空格全部截取
// 返回:已经截取的文本
// 参数:text 指定的文本
function trimAll(text){
    //先右截取，再左截取，返回
 	return leftTrim(rightTrim(text));
}


// 名称:左截取函数
// 功能:把指定的文本中左边的空格全部截取
// 返回:已经截取的文本
// 参数:text 指定的文本
function leftTrim(text){
   //如果text无内容，返回text
   if(text==null || text=="") return text;

   //定义最左非空格字符的索引下标(空格字符数)
   var leftIndex=0;

   //直至找到最左的非空格的字符，要么进行
   while(text.substring(leftIndex,leftIndex+1)==" ")
           leftIndex++;//最右非空格字符的索引下标后移
   return text.substring(leftIndex,text.length);//返回
}


// 名称:右截取函数
// 功能:把指定的文本中右边的空格全部截取
// 返回:已经截取的文本
// 参数:text 指定的文本
function rightTrim(text){
   //如果text无内容，返回text
   if(text==null || text=="") return text;

   //定义最右非空格字符的索引下标
   var rightIndex=text.length;

   //直至找到最右的非空格的字符，要么进行
   while(text.substring(rightIndex-1,rightIndex)==" ")
           rightIndex--;//最右非空格字符的索引下标前移
   return text.substring(0,rightIndex);//返回
}
//////////////////////////////////////////

function moveSelected(select1, select2) {
	var labels = new Array();
	var values = new Array();
	var num = 0;
	for (var i = 0; i < select1.length; i++) {
		if (select1.options[i].selected) {
			labels[num] = select1.options[i].text;
			values[num] = select1.options[i].value+"@_@"+select1.options[i].text;
			num++;
			select1.options[i] = null;
			i--;
		}
	}
	var length = select2.options.length;
	for (var i = 0; i < labels.length; i++)	{
		select2.options[length] = new Option(labels[i], values[i]);
		length++;
	}
}

function removeSelected(select1, select2)
{
	var selectedArray = new Array();
	var setNumber = 0;
	for (var i=0; i<select2.options.length; i++)
	{
		if (select2.options[i].selected)
		{
			selectedArray[setNumber] = select2.options[i];
			setNumber++;
		}
	}
	for (var j=0; j<setNumber; j++)
	{
		selectedArray[j].removeNode(true);
	}
}

function SelectAllOptions(selectObj) {
	for (var i = 0; i < selectObj.options.length; i++) {
		selectObj.options[i].selected = true;
	}
}

function clearSelected(selectObj) {
	for (var i = 0; i < selectObj.options.length; i++) {
		selectObj.options[i].selected = false;
	}
}

function clearAllOptions(selectObj) {
    SelectAllOptions(selectObj);
	var selectedArray = new Array();
	var setNumber = 0;
	for (var i=0; i<selectObj.options.length; i++)
	{
		if (selectObj.options[i].selected)
		{
			selectedArray[setNumber] = selectObj.options[i];
			setNumber++;
		}
	}
	for (var j=0; j<setNumber; j++)
	{
		selectObj.options.remove(selectedArray[j]);
	}
}
/////////////////////////////////////////////////


function defaultInit() {
  if (msg != null && msg != "") {
    alert(msg);
  }
}

function confirmOpt(msg) {
  var m = msg;
  if (m == null) {
    m = "确定删除吗?";
  }
  return window.confirm(m);
}

function openWindow(url,title,width,height, scroll, resizable, status){
  var screenWidth=screen.availWidth;
  var screenHeight=screen.availHeight;
  var top,left;

  top=(screenHeight-height)/2;
  left=(screenWidth-width)/2;
  var strscroll
  if (scroll) {
    strscroll = ",scrollbars=1";
  }
  return window.open(url,title,"status=" + (status ? "1" : "0") + ", resizable=" + (resizable ? "1" : "0") + ", width="
                        +width+", height="+height
                        +", top="+top+", left="+left+strscroll);
}

function executeXhr(callback, url) {
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
    req.onreadystatechange = callback;
    req.open("GET", url, true);
    req.send(null);
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    if (req) {
      req.onreadystatechange = callback;
      req.open("GET", url, true);
      req.send();
    }
  }
}
function callbackDefault() {
  if (req.readyState == 4) {
   	if (req.status == 200) {
    	eval(req.responseText);
    	req.abort();
		  req = null;
   	}
	}
}

// noHide: true,不自动隐藏等待窗口；false，自动隐藏
// 如果callback设为null，使用同步ajax方式，return req.responseText
function executeXhrNew(callback, url, noHide, catchException) {
  var req;
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
    if (callback == null) {
      req.open("GET", url, false);
      req.send(null);
      return processSynch(req, noHide);
    } else {
      req.onreadystatechange = function () { callback(req, noHide, catchException); };
      req.open("GET", url, true);
      req.send(null);
    }
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    if (req) {
      if (callback == null) {
        req.open("GET", url, false);
        req.send();
        return processSynch(req, noHide);
      } else {
        req.onreadystatechange = function () { callback(req, noHide, catchException);};
        req.open("GET", url, true);
        req.send();
      }
    }
  }
  return req;
}
function processSynch(req, noHide) {
  var rtn = req.responseText;
  req.abort();
  req = null;
  if (!noHide) {
 	  if (window.hideWait != null) {
 	    hideWait();
 	  } else {
 	    hideProcess();
 	  }
	}
	return rtn;
}
function executeXhrPost(callback, url, param, noHide) {
  var req;
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req) {
    req.onreadystatechange = function () { callback(req, noHide); };
    req.open("POST", url, true);
    req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    param = encodeURI(param);
    param = encodeURI(param);
    param = param.replace(/\+/g, "%2b");
    req.send(param);
  }
}
// parray为参数二维数组，parray[i][0]为name，parray[i][1]为value
// 如果callback设为null，使用同步ajax方式，return req.responseText
function executeXhrPostNew(callback, url, parray, extraParams, noHide, catchException) {
  var req;
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req) {
    if (callback == null) {
      req.open("POST", url, false);
    } else {
      req.onreadystatechange = function () { callback(req, noHide, catchException); };
      req.open("POST", url, true);
    }
    req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    var length = parray.length;
    var array = new Array(length);
    for (var i = 0; i < length; i++) {
      array[i] = "&" + parray[i][0] + "=" + encodeURI(encodeURI(parray[i][1])).replace(/&/g, "%26").replace(/\+/g, "%2b");
    }
    var param = array.join("");
    if (param != "") {
      param = param.substring(1);
      if (extraParams != null) {
	      param += "&" + extraParams;
	    }
    } else {
      if (extraParams != null) {
        param = extraParams;
      }
    }
    req.send(param);
    if (callback == null) {
      return processSynch(req, noHide);
    } else {
      return req;
    }
  }
}
function callbackDefaultNew(req, noHide, catchException) {
  if (req.readyState == 4) {
   	if (req.status == 200) {
   	  if (catchException) {
   	    try {
      	  eval(req.responseText);
      	} catch (e) {
      	  if(req.responseText.indexOf("登录超时") != -1){
  	  	    alert("您的登录已超时，请重新登录");
        	} else {
        		alert(req.responseText);
        	}
      	}
   	  } else {
    	  eval(req.responseText);
    	}
    	req.abort();
		  req = null;
		  if (!noHide) {
	    	if (window.hideWait != null) {
	    	  hideWait();
	    	} else {
	    	  hideProcess();
	    	}
    	}
   	}
	}
}
function callbackAjax(req) {
  if (req.readyState == 4) {
   	if (req.status == 200) {
    	eval(req.responseText);
    	req.abort();
		  req = null;
   	}
	}
}
function isNumber(str) {
    if (!isCharsInBag(str, "0123456789")) {
        return false;
    }
    return true;
}
function isCharsInBag (str, bag) {
    for (i = 0; i < str.length; i++) {
        var c = str.charAt(i);
        if (bag.indexOf(c) == -1) return false;
    }
    return true;
}
function getByteLength(str) {
	var count = 0;
	for (var i = 0; i < str.length; i++){
	  var c = str.charAt(i);
	  if (/^[\u0000-\u00ff]$/.test(c)) {
	    count += 1;
	  }	else {
	    count += 2;
	  }
	}
	return count;
}
function substringByte(str, n) {
	var count = 0;
	var s = "";
	for (var i = 0; count < n && i < str.length; i++){
	  var c = str.charAt(i);
	  if (/^[\u0000-\u00ff]$/.test(c)) {
	    count += 1;
	  }	else {
	    count += 2;
	  }
	  s += c;
	}
	if (count > n) {
	  s = s.substring(0, s.length - 1);
	}
	return s;
}
function offsetLeft(obj) {
  var x = obj.offsetLeft;
  for (var objParent = obj.offsetParent; objParent; objParent = objParent.offsetParent) {
    x += objParent.offsetLeft;
    if (objParent.className == "tdiv") {
      x -= objParent.scrollLeft;
    }
  }
  return x;
}
function offsetTop(obj) {
  var y = obj.offsetTop;
  for (var objParent = obj.offsetParent; objParent; objParent = objParent.offsetParent) {
    y += objParent.offsetTop;
    if (objParent.className == "tdiv") {
      y -= objParent.scrollTop;
    }
  }
  return y;
}
function showBlindDiv(blindObjId) {
  var obj = document.getElementById(blindObjId);
  var div = document.createElement("DIV");
  div.id = "blindDiv";
  div.className = "dblindOnly";
  div.style.width = obj.clientWidth;
  div.style.height = obj.clientHeight;
  div.style.left = offsetLeft(obj);
  div.style.top = offsetTop(obj);
  document.body.appendChild(div);
}
function hideBlindDiv() {
  var obj = document.getElementById("blindDiv");
  if (obj != null) {
    obj.removeNode(true);
  }
}
function initPeriods(typeSelectName, periodSelectName, tableId, cellNum, callback, allTrs) { // allTrs: 用于table嵌套
  var tbl = document.getElementById(tableId);
  if (tbl != null) {
    var periodType = document.getElementById(typeSelectName);
    var obj;
    if (event != null) {
      obj = event.srcElement;
    }
    if (obj != null && obj.name == periodSelectName) { // 报告期选择
      var url = ROOT_PATH + "query/queryperiods.do";
      url += "?change=true&period=" + document.getElementById(periodSelectName).value;
      eval(executeXhrNew(null, url));
      if (callback != null) {
        eval(callback + "();");
      }
    } else { // 期别类型选择或body onload
      if (periodType.selectedIndex != -1) {
        showProcessNew(false, true);
        var url = ROOT_PATH + "query/queryperiods.do";
        var params = getPeriodsParams();
        params.push(new Array("selectName", periodSelectName));
        params.push(new Array("timeFreq", periodType.value));
        params.push(new Array("type", "periodType"));
        params.push(new Array("typeSelectName", typeSelectName));
        params.push(new Array("tblId", tableId));
        params.push(new Array("cellNum", cellNum));
        if (callback != null) {
          params.push(new Array("callback", callback));
        }
        if (allTrs) {
          params.push(new Array("allTrs", allTrs));
        }
		    if (obj != null && obj.name == typeSelectName) {
		      params.push(new Array("change", "true"));
		    }
		    var length = periodType.options.length;
		    for (var i = 0; i < length; i++) {
		      params.push(new Array("periodTypeValue", periodType.options[i].value));
		    }
		    executeXhrPostNew(callbackDefaultNew, url, params);
	    }
    }
  }
}
function callbackPeriodType(typeSelectName, timeFreq, allTrs, tableId, cellNum, callback) {
  var tbl = document.getElementById(tableId);
  if (tbl != null) {
	  var periodType = selectOption(typeSelectName, timeFreq);
	  var periodLabel = periodType.options[periodType.selectedIndex].innerText;
	  var flag = true;
	  var objs;
	  if (allTrs) {
	    objs = tbl.getElementsByTagName("TR");
	  } else {
	    objs = tbl.rows;
	  }
	  for (var i = 0; i < objs.length; i++) {
	    flag = setPeriodTr(objs[i], cellNum, periodLabel, flag);
	  }
	  if (callback != null) {
	    eval(callback + "();");
	  }
  }
}
function setPeriodTr(tr, cellNum, periodLabel, flag) {
  try {
	  var objs = tr.getElementsByTagName("A");
	  var objs2 = tr.getElementsByTagName("INPUT");
	  if (trimAll(tr.cells[cellNum].innerText) == periodLabel) {
	    tr.row_disabled = false;
	    tr.style.display = "inline";
	    if (flag) {
	      tr.className = "tab-bgbg";
	    } else {
	      tr.className = "tab-bgbg1";
	    }
	    flag = !flag;
	    for (var j = 0; j < objs.length; j++) {
	      objs[j].disabled = false;
	      if (objs[j].old_onclick != null) {
	        objs[j].onclick = objs[j].old_onclick;
	      }
	    }
	    for (var j = 0; j < objs2.length; j++) {
	      objs2[j].disabled = false;
	    }
	  } else {
	    tr.row_disabled = true;
	    tr.style.display = "none";
	    for (var j = 0; j < objs.length; j++) {
	      objs[j].disabled = true;
	      if (objs[j].onclick != null&&objs[j].old_onclick==null) {        
	        objs[j].old_onclick = objs[j].onclick;
	        objs[j].onclick = function() { return false; };
	      }
	    }
	    for (var j = 0; j < objs2.length; j++) {
	      objs2[j].disabled = true;
	      objs2[j].checked = false;
	    }
	  }
  } catch (e) {
    flag = true;
  }
  return flag;
}
function clearOptions(selectName) {
  var obj = document.getElementById(selectName);
  if (obj != null) {
    for (var i = 0; obj.options.length > 0; ) {
      obj.options[i].removeNode(true);
    }
  }
}
function addOptions(selectName, value, label, isSelected) {
  var obj = document.getElementById(selectName);
  if (obj != null) {
    var option = document.createElement("OPTION");
    option.value = value;
    option.innerText = label;
    option.selected = isSelected;
    obj.appendChild(option);
  }
}
function selectOption(selectName, value) {
  var obj = document.getElementById(selectName);
  if (obj != null) {
    var length = obj.options.length;
    for (var i = 0; i < length; i++) {
      if (obj.options[i].value == value) {
        obj.options[i].selected = true;
        break;
      }
    }
  }
  return obj;
}

/**
 * added by cris,进入打印预览的界面
 * @param tableId 	报表Id
 * @param soId		调查对象Id
 * @param orgId		数据处理地Id
 * @param period	期别
 * @param showEmptyLine	是否显示空行
 * @param loopTblCatIdx 循环表当前目录Id
 * @param qryTitle		灵活查询结果名称
 * @param qryRowInfo	综合表灵活查询主栏分组信息
 * @param qryData		灵活查询结果的数据部分
 * @param multiTableIds 多表打印时的报表Id序列，使用_连接
**/
function printPreview(tableId,soId,orgId,period,showEmptyLine,loopTblCatIdx,qryTitle,qryRowInfo,qryData,multiTableIds)
{
	//modified by cris 4 YB-4384
	if (typeof multiTableIds != undefined && multiTableIds != null)
	{
		tableId = multiTableIds.substring(0,25);
	}
	
	//使用前缀来统一相对路径和绝对路径
	var prefix = (window.ROOT_PATH != null)?window.ROOT_PATH:"../";
	var loc = prefix
	+"print/printpreview.do?tableId="+tableId
	+"&soId="+soId
	+"&orgId="+orgId
	+"&period="+period;

	if (showEmptyLine != null)
	{
		loc += "&showEmptyLine=" + showEmptyLine;
	}

	//modified by cris 4 YB-2797
//	if (loopTblCatIdx != null)
//	{
//		loc += "&loopTblCatIdx=" + loopTblCatIdx;
//	}

	var options = new Object();
	//考虑到如果以外网身份访问时,IE会强制性显示状态栏,因此需要预留出10px的状态栏高度
	var result = window.showModalDialog('../print/printoption.do?tableId=' + tableId,options
	,'dialogHeight:290px; dialogWidth:300px; status:yes; help:no; scroll:no');

	if (result == undefined || result == null || result == false)
	{
		//打印取消
		return false;
	}

	//根据设置的选项来补充URL
	loc += "&pageSize=" + options.pagesize;
	loc += "&landScape=" + options.landScape;
	loc += "&showFooter=" + options.showFooter;
	loc += "&autoFitText=" + options.autoFitText;
	loc += "&fixedColsLocked=" + options.fixedColsLocked;
	loc += "&forcedPaging=" + options.forcedPaging;
	loc += "&emptyLineCount=" + options.emptyLineCount;

	if (typeof qryTitle != undefined && qryTitle != null)
	{
		//要采用POST提交的方式将比较大的数据部分传送到打印处理服务
		var printForm = new DynamicForm("printForm",loc);
		printForm.addProperty("title",qryTitle);
		printForm.addProperty("rowInfo",qryRowInfo);
		printForm.addProperty("gridData",qryData);
		printForm.submit();		
	}
	else
	{
		//modified by cris 4 YB-4384
		if (typeof multiTableIds != undefined && multiTableIds != null)
		{
			//要采用POST提交的方式将比较大的数据部分传送到打印处理服务
			var printForm = new DynamicForm("printForm",loc);
			printForm.addProperty("multiTableIds",multiTableIds);
			printForm.submit();		
		}
		else
		{
			//modified by cris 4 YB-2797
			if (loopTblCatIdx != null)
			{
				if (loopTblCatIdx.length < 10)
				{
					loc += "&loopTblCatIdx=" + loopTblCatIdx;
					window.location = loc;
				}
				else
				{
					//要采用POST提交的方式将比较大的数据部分传送到打印处理服务
					var printForm = new DynamicForm("printForm",loc);
					printForm.addProperty("loopTblCatIdx",loopTblCatIdx);
					printForm.submit();		
				}
			}
			else
			{
				window.location = loc;
			}
		}
	}
	return true;
}

/**
 * 根据全选核选框的状态全选（或者全部取消）所有指定名称的复选框选中状态
 * @author Cris YANG
 * @param selAllCheckId 全选按钮的Id
 * @param checkName 复选框的名称
 */
function selectAllCheckBox(selAllCheckId,checkName)
{
	var selAll = document.getElementById(selAllCheckId);
	var checks = document.getElementsByName(checkName);
	if (selAll != null && checks != null && checks.length > 0)
	{
		for (var i=0;i<checks.length;i++)
		{
			checks[i].checked = selAll.checked;
		}
	}
}

/**
 *检查所有指定名称的复选框的选中状态，根据综合状态确定最终的全选核选框的显示状况
 * @author Cris YANG
 * @param selAllCheckId 全选按钮的Id
 * @param checkName 复选框的名称
 */
function checkAllCheckBoxStatus(selAllCheckId,checkName)
{
	var selAll = document.getElementById(selAllCheckId);
	var checks = document.getElementsByName(checkName);
	if (selAll != null && checks != null && checks.length > 0)
	{
		for (var i=0;i<checks.length;i++)
		{
			if (!checks[i].checked)
			{
				selAll.checked = false;
				return;
			}
		}
		selAll.checked = true;
	}
}

/**
 * 提交选中的所有报表，检查是否为全部未选状态
 * @author Cris YANG
 * @param type	提交类型，如果不是all，则需要检查选中状态
 * @param checkName 需要检查的复选框名称
 */
function submitCheckedTables(type,checkName,submitUrl)
{
	var selAtLeastOne = false;
	if ("all" != type)
	{
		//检查是否至少有一个选中项
		var checks = document.getElementsByName(checkName);
		for (var i=0;i<checks.length;i++)
		{
			if (checks[i].checked)
			{
				selAtLeastOne = true;
				break;
			}
		}
		if (!selAtLeastOne)
		{
			alert ("请至少选择一张报表！");
			return;
		}
	}
	
	var seperator = (submitUrl.indexOf("?") != -1)?"&":"?";
	submitUrl += seperator + "type=" + type;
	
	var form = document.forms[0];
	var oldAction = form.action;
	form.action = submitUrl;
	var oldTarget = form.target;
	form.target = "_blank";
	form.submit();
	
	form.action = oldAction;
	form.target = oldTarget;
}


/**
 * 创建一个Grid+Report 打印预览对象,大小为100%占用当前窗口,Id为ReportViewer
 */
function createPrintPreviewObj()
{
	document.write('<OBJECT classid="CLSID:9E4CCA44-17FC-402b-822C-BFA6CBA77C0C" codebase="/griectl.cab#Version=5,0,9,920" width="100%" height="100%" id="ReportViewer" VIEWASTEXT>');
	document.write('<param name="SerialNo" value="RLNB9X8Q54VLDP5L21B9BRA93VF0G829HL8ZB5Y8XD6T571W18W01492A3T9GRTG8PH7R56ZPK9">');
	document.write('<param name="UserName" value="北京京云万峰信息技术有限公司">');
	document.write('</OBJECT>');
}

/**
 * 从打印预览页面中去除不需要的按钮
 */
function removeNeedlessPrintButtons()
{
	ReportViewer.removeToolbarControl(5);//导出菜单
	ReportViewer.removeToolbarControl(6);//邮件发送按钮
	ReportViewer.removeToolbarControl(22);//显示书签按钮
	ReportViewer.removeToolbarControl(60);//导出Excel按钮
	ReportViewer.removeToolbarControl(61);//导出PDF按钮
	
    //最后更新显示
    ReportViewer.UpdateToolbar();      	
}

