//打开弹出的模式窗口，并返回所选择的值
//设计：吴舒涛 创建：2003-04-12
function OpenModalWin(Module,Width,Height)
{
	var sOpen = Module;
	var sStyle = "dialogHeight: "+ Height +"px; dialogWidth: "+ Width +"px; center: Yes; help: No; resizable: no; status: No;unadorned: Yes;scroll:No";
	//模式窗口
	var oReturn = window.showModalDialog( sOpen,window,sStyle);
	return oReturn;
}

//打开弹出的模式窗口，不返回值
//设计：吴舒涛 创建：2005-04-19
function OpenModalWin_NO(Module,Width,Height)
{
	var sOpen = Module;
	var sStyle = "dialogHeight: "+ Height +"px; dialogWidth: "+ Width +"px; center: Yes; help: No; resizable: no; status: No;unadorned: Yes;scroll:auto";
	//模式窗口
	window.showModalDialog( sOpen,window,sStyle);
}


//打开弹出的模式窗口，并返回所选择的值
//设计：吴舒涛 创建：2003-04-12
function OpenModalWin1(Module,WinName,Width,Height)
{
	var sOpen = Module;
	var sStyle = "dialogHeight: "+ Height +"px; dialogWidth: "+ Width +"px; center: Yes; help: No; resizable: no; status: No;unadorned: Yes;scroll:No";
	//模式窗口
	var oReturn = window.showModalDialog( sOpen,WinName,sStyle);
	return oReturn;
}

//打开弹出的非模式窗口，并返回所选择的值
//设计：吴舒涛 创建：2003-04-12
function OpenModelessWin(Module,WinName,Height,Width)
{
	var sOpen = Module;
	var sStyle = "dialogHeight: "+ Height +"px; dialogWidth: "+ Width +"px; edge: raised; center: Yes; help: No; resizable: no; status: No;unadorned: Yes;scroll:No";
	//模式窗口
	var oReturn = window.showModelessDialog( sOpen,WinName,sStyle);
	return oReturn;
}


//打开打印窗口
//设计：吴舒涛   日期：2004-08-09
function OpenPrintWin(Module,Width,Height)
{
	var sOpen = Module;
	var sStyle = "top=0 left=0 height="+Height+",width="+Width+",toolbar=no,status=no,direction=yes,scrollbars=no,resizable=yes, fullscreen = no";
	window.open( sOpen,"_blank",sStyle);
}

function SelectEmployee(oObj, oDe, sSelectMode)
{
	//var oReturn = window.OpenModalWin("SelectMan_Department.aspx", "522", "475");
	var oReturn = window.OpenModalWin("../Sys/SelectEmployee.aspx?SelectMode="+sSelectMode, "605", "475");
	if(oReturn != undefined)
	{
		document.all[oObj].value = oReturn.ID;
		document.all[oDe].value = oReturn.Name;
	}
}

//选择人员信息(临时增加给公共List模块使用，目前无法解决不同目录文件调用SelectEmployee方法时，相对于SelectEmployee.aspx文件的目录问题)
//oObj为用户的ID号(工号)，oDe为用户的描述(姓名)，sSelectMode：选择模式 Single单选；Multi多选
//设计：吴舒涛    日期：2004-10-31
function SelectEmployeeRoot(oObj, oDe, sSelectMode)
{
	//var oReturn = window.OpenModalWin("SelectMan_Department.aspx", "522", "475");
	var oReturn = window.OpenModalWin("Sys/SelectEmployee.aspx?SelectMode="+sSelectMode, "605", "475");
	if(oReturn != undefined)
	{
		document.all[oObj].value = oReturn.ID;
		document.all[oDe].value = oReturn.Name;
	}
}

//选择部门信息
//oObj为部门的ID号(编号号)，oDe为部门的描述(名称)，sSelectMode：选择模式 Single单选；Multi多选
//设计：吴舒涛    日期：2008-01-01
function SelectDepartment(oObj, oDe, sSelectMode)
{
	var oReturn = window.OpenModalWin("../Sys/SelectDepartment.aspx?SelectMode="+sSelectMode, "605", "475");
	if(oReturn != undefined)
	{
		document.all[oObj].value = oReturn.ID;
		document.all[oDe].value = oReturn.Name;
	}
}

//选择部门信息(临时增加给公共List模块使用，目前无法解决不同目录文件调用SelectDepartment方法时，相对于SelectDepartment.aspx文件的目录问题)
//oObj为部门的ID号(编号号)，oDe为部门的描述(名称)，sSelectMode：选择模式 Single单选；Multi多选
//设计：吴舒涛    日期：2008-01-01
function SelectDepartmentRoot(oObj, oDe, sSelectMode)
{
	var oReturn = window.OpenModalWin("Sys/SelectDepartment.aspx?SelectMode="+sSelectMode, "605", "475");
	if(oReturn != undefined)
	{
		document.all[oObj].value = oReturn.ID;
		document.all[oDe].value = oReturn.Name;
	}
}

//选择人员信息
//oObj为用户的ID号(工号)，oDe为用户的描述(姓名)
//设计：吴舒涛    日期：2004-08-20
function SelectManID(oObj,oDe)
{
	//var oReturn = window.OpenModalWin("SelectMan_Department.aspx", "522", "475");
	var oReturn = window.OpenModalWin("SelectMan.aspx", "405", "475");
	if(oReturn != undefined)
	{
		document.all[oObj].value = oReturn.ID;
		document.all[oDe].value = oReturn.Name;
	}
}

//选择人员信息
//oObj为用户的ID号(工号)，oDe为用户的描述(姓名)
//设计：吴志力    日期：2007-08-20
function SelectUser(oObj,oDe)
{
	//var oReturn = window.OpenModalWin("SelectMan_Department.aspx", "522", "475");
	var oReturn = window.OpenModalWin("SelectUser.aspx", "405", "475");
	if(oReturn != undefined)
	{
		document.all[oObj].value = oReturn.ID;
		document.all[oDe].value = oReturn.Name;
	}
}

//选择设备信息
//oObj为设备的ID号，oDe为设备的名称
//设计：吴舒涛    日期：2004-08-20
function SelectEquipmentID(oObj,oDe)
{
	var oReturn = window.OpenModalWin("EQ_MA_Tree.aspx", "405", "420");
	if(oReturn != undefined)
	{
		document.all[oObj].value = oReturn.ID;
		document.all[oDe].value = oReturn.Name;
	}
}

//选择日期时间信息
//oObj为返回的对象
//设计：吴舒涛    日期：2004-09-17
function SelectDateTime(oObj)
{
	var oReturn = window.OpenModalWin("SelectDateTime.htm", "190", "90");
	if(oReturn != undefined) document.all[oObj].value = oReturn;
}

// 检查输入的控件中的值是否为空
// 设计：吴舒涛
// 日期：2004-08-27
function CheckControlValue(oObj)
{
	var bRet = true;
	var oValue = document.all[oObj].value;
	if(oValue == "")
	{
		bRet = false;
	}
	return bRet;
}

// 检查输入的控件中的数值是否有效、是否为空
// 设计：吴舒涛
// 日期：2004-08-30
function CheckControlNumber(oObj)
{
	var bRet = true;
	var oValue = document.all[oObj].value;
	if(oValue == "")
	{
		bRet = false;
	}
	if( isNaN(oValue))
	{
		bRet = false;
	}
	return bRet;
}

// 展开/折叠下拉式菜单
// 设计：吴舒涛
// 日期：2005-03-31
function ExpandAndCollapse(sid)
{
	whichEl = eval("document.getElementById('DTL" + sid+"')");
	imgmenu = eval("document.getElementById('imgDTL" + sid+"')");
	if (whichEl.style.display == "none")
	{
		if (whichEl.style.display=='none')
		{
			whichEl.style.display='';
		}
		else
		{
			whichEl.style.display = 'none';
		}
		imgmenu.background="../images/menuup.gif";
	}
	else
	{
		if (whichEl.style.display=='none')
		{
			whichEl.style.display='';
		}
		else
		{
			whichEl.style.display = 'none';
		}
		imgmenu.background="../images/menudown.gif";
	}
}

// 展开当前选择的菜单，折叠其它所有的菜单
// (根据ExpandAndCollapse方法修改)
// 设计：吴舒涛
// 日期：2007-10-19
function ExpandAndCollapseOther(sid, SubNumber)
{
	whichEl = eval("document.getElementById('DTL" + sid+"')");
	imgmenu = eval("document.getElementById('imgDTL" + sid+"')");
	var tEL, imgEL;
	if (whichEl.style.display == "none")
	{
			whichEl.style.display='';
		  imgmenu.background="../images/menuup.gif";
		for(var nTemp = 0; nTemp <SubNumber; nTemp++)
		{
		  if(nTemp == sid)
		  {
		    continue;
		  }
		  else
		  {
		    tEL = eval("document.getElementById('DTL" + nTemp+"')");
		    imgEL = eval("document.getElementById('imgDTL" + nTemp+"')");
		    tEL.style.display = 'none';
		    imgEL.background="../images/menudown.gif";
		  }
		}
	}
}


// 加载相对于浏览器固定位置的DIV
// 设计：吴舒涛
// 日期：2005-03-31
function KB_keepItInIE(obj,theWantTop,theWantLeft) {
	var div = document.getElementById(obj);
	theRealTop=parseInt(document.body.scrollTop);
	theTrueTop=theWantTop+theRealTop;
	div.style.top=theTrueTop;
	theRealLeft=parseInt(document.body.scrollLeft);
	theTrueLeft=theWantLeft+theRealLeft;
	div.style.left=theTrueLeft;
}

function KB_keepItInNN(theName,theWantX,theWantY) {
	theRealLay=document.layers[theName];
	theBadX=self.pageYOffset;
	theBadY=self.pageXOffset;
	theRealX=theBadX+theWantX;
	theRealY=theBadY+theWantY;
	theRealLay.moveTo(theRealY,theRealX);
}


// ************** 其它功能 ******************
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.01
  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 && d.getElementById) x=d.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 Delete()
		{
			var value;
			value='';
			
			var count=1;
			var obj =document.getElementsByName("chk");			
			if(!obj)
			{
			alert("没有数据");
				return false;
			}
			
			if (obj.length)
			{
				for(var i=0;i<obj.length;i++)
				{
					if(obj[i].checked)
					{
					    if(count==1)
					    {
							value = obj[i].value;
							count++;
					    }
					    else
					    {    
							value=value + ","+ obj[i].value;
							count++;								
						}
					}							
				}
			}
			else
			{
				if (obj.checked)
				{
					count++;
				    value=obj.value; 
				}		
			} 
			if(count==1)
			{	
				alert('请选择要删除的数据！');
				return false;
			}
			else
			{
			    if (window.confirm('删除后不可恢复。确定要删除吗？'))
				{
					document.all.txtDel.value=value;
					return true;
					
					
				}
			}	
		}
		
		function Update()
		{
			var value;
			value='';
			var count=1;
			
			var obj =document.getElementsByName("chk");			
			if(!obj)
			{
			alert("没有数据");
				return false;
			}
			if(obj.length)
			{
				for(var i=0;i<obj.length;i++)
				{
					if(obj[i].checked)
					{
					    if(count==1)
					    {
							value = obj[i].value;
							count++;
					    }
					    else
					    {    
							value=value + "^"+ obj[i].value;
							count++;								
						}
					}							
				}
			}
			else
			{
				if (obj.checked)
				{
					count++;
				    value=obj.value; 
				}		
			}
			if(count==1)
			{
				alert('请选择数据！');
				return false;
			}
			else if(count>2)
			{
				alert('请选择一条记录进行修改！');
				return false;
			}
			else
			{
				
				document.all.txtDel.value=value;
				return true;
				//value=aspx+'?mainkey='+value;
				//DialogOut(value);
			}	
				
		}
		
		function IsAudit()
		{		   
			var obj=document.all.chk;
			var count=1;
			var isCanUpdate;
			
			if(obj==undefined)
			{
				return 0;
			}
			if(obj.length)
			{
				for(var i=0;i<obj.length;i++)
				{
					if(obj[i].checked)
					{
					    if(count==1)
					    {							
							isCanUpdate=obj[i].data;
							count++;
					    }
					    else
					    {
							count++;								
						}
					}							
				}
			}
			else
			{
				if (obj.checked)
				{
					count++;				  
				    isCanUpdate=obj.data;
				}		
			}
			if(count==1)
			{				
				return false;
			}
			else if(count>2)
			{				
				return false;
			}
			else
			{
			    if (isCanUpdate == '0' || isCanUpdate == '')
			    {
				   return true
				}
				else
				{
				   alert('已经审核不能被修改！');
				   return false;
				}
			}		  
		}
		
function Affirm()
{
	var value = '';
	var count=1;
	var obj =document.getElementsByName("chk");			
	if(!obj)
	{
	alert("没有数据");
		return false;
	}
	if (obj.length)
	{
		for(var i=0;i<obj.length;i++)
		{
			if(obj[i].checked)
			{
					if(count==1)
					{
					value = obj[i].value;
					count++;
					}
					else
					{    
					value=value + ","+ obj[i].value;
					count++;								
				}
			}							
		}
	}
	else
	{
		if (obj.checked)
		{
			count++;
				value=obj.value; 
		}		
	} 
	if(count==1)
	{	
		alert('请选择数据！');
		return false;
	}
	else
	{
		document.all.txtDel.value=value;
		return true;
	}	
}
		
function UpdateDialog(url)
{
	DialogOut(url);
	__doPostBack('txtre','')
}

function UpdateDialogMin(url)
{
	DialogOutMin(url);
	__doPostBack('txtre','')
}
		
function Msg(msg)
{
	alert(msg);
}

function win_close()
{
	parent.close();
}
		
function openWinMin(url)
{
	var newwin=window.open(url,"_blank","top=150,left=200,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=643,height=400");
	return false;
}
		
function openWin(url)
{
	window.open(url,"_blank","top=50,left=100,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=600");
	return false;
}	
	
function openWinLi(url)
{
	window.open(url,"_blank","fullscreen=0,toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes");
	return false;
}

function DialogOut(str)
{
  return window.showModalDialog('../Sys/ShowModal.aspx?url=' + str ,'','dialogWidth:800px;dialogHeight:600px');
}
  
function DialogOutMin(str)
{
  var ReturnName = window.showModalDialog('../common/ShowModal.aspx?url=' + str ,'','dialogWidth:600px;dialogHeight:400px');
	if (ReturnName != null)
	{
		return ReturnName;
	}
	else
	{
		return "";
	}
}

function Txt_onkeypress() 
{
	if((window.event.keyCode<48 || window.event.keyCode>57)&&(window.event.keyCode!=8))
	{
		event.keyCode=0;
	}
}

function Txt_InputMoney(textValue) 
{	
  if((window.event.keyCode<48 || window.event.keyCode>57)&&(window.event.keyCode!=8)&&(window.event.keyCode!=46))
	{
		event.keyCode=0
	}
  else if (window.event.keyCode==46)  //判断小数点的个数.
	{
		var pos = textValue.indexOf(".",0);
		if (pos!=-1)
		{
			event.keyCode= 0 ;
		}
	}
}	

function CodeSelect(tableName,textName)
{
	var str='../Sys/CodeSelect.aspx?tableName='+tableName;
	if (tableName.split("^")!=-1)
	{
		var a=tableName.split("^");
		tableName=a[0];
	}
	var CS=window.showModalDialog('../Sys/ShowModal.aspx?url='+str,'','dialogWidth:600px;dialogHeight:400px'); 
  if (CS!=null) 
  { 
		var aAyy=CS.split("^"); 
		var Key=aAyy[0]; 
		var KeyId=aAyy[1]; 
		var ChinaName=aAyy[2];
		var EnName=aAyy[3];
    if (tableName=="Contract")
    { 
      document.all.txtContractKey.value=Key;
      document.all.txtContractNo.value=KeyId;
    }                  
    return true;     
	}
  else
  {
		return false;
  }
}    
     
function BaseCodeSelect(tableName,textName)
{
	var str='../common/BaseCodeSelect.aspx?tableName='+tableName;
	var CS=window.showModalDialog('../common/ShowModal.aspx?url='+str,'','dialogWidth:600px;dialogHeight:400px'); 
  if (CS!=null) 
  { 
		var aAyy=CS.split("^"); 
		var Key=aAyy[0]; 
		var KeyId=aAyy[1]; 
    var ChinaName=aAyy[2];
    var EnName=aAyy[3];
    if (tableName=="PCCode")
    { 
			document.all.txtMaterial.value=ChinaName;
      document.all.txtItemNumber.value=KeyId;
      //document.all.txtMaterialName.value=ChinaName;
    }
  } 
}
     
function AlertWindow(value,mode)
{
	var h1 = 200;
  var w1 = 443;
  var sfeature="height="+h1+",width="+w1+",toolbar=no, menubar=no,scrollbars=yes, resizable=yes, location=no, status=no";    
	if (mode ==1)
  {
    //window.open('../common/Info.aspx?Msg='+ value,'home',sfeature); 
    var str='../common/Info.aspx?Msg='+ value;
    window.showModalDialog('../common/ShowModal.aspx?url='+str,'',sfeature); 
  }
}
// ********** 其它功能结束 *************

// ******** 多选窗体 *********
function ShowModDialog(Url,Height,Width)
{
	var sOpen = Url;
	var sStyle = "dialogHeight: "+ Height +"px; dialogWidth: "+ Width +"px; center: Yes; help: No; resizable: no; status: No;unadorned: Yes;scroll:No";

	return window.showModalDialog( sOpen,window,sStyle);
}

function MultiSelect(oText,Sign,Param)
{
	var oReturn = ShowModDialog("../MultiSelect.aspx" + "?sign=" + Sign + "&param=" + Param, "300", "400");
	var tbSel = document.getElementById(oText);
	if(oReturn != undefined)
	{
		tbSel.value = oReturn.Text;
	}
} 

function oReturn()
{
	var oRet = new Object();
	var sText = document.all["hText"].value;
	oRet.Text = sText;

	window.returnValue = oRet;
	window.close();
}
// ******** 多选窗体结束 *********

// 从左ListBox对象中选中的项目移到右边的ListBox
// 设计：吴舒涛
// 日期：2006-02-22
function oLeftClick(obj_Name,strLeft,strRight,strHidden)
{
	var left,right,option,hidden, obj;
	var i,isChanged=false;
	var strValue="";
	obj=document.getElementById(obj_Name);
	left=document.getElementById(strLeft);
	right=document.getElementById(strRight);
	hidden=document.getElementById(strHidden);
	for(i=0;i<right.options.length;i++)
	{
		if(right.options[i].selected)
		{
			option=right.removeChild(right.options[i--]);
			left.appendChild(option);
			isChanged=true;
		}
	}
	
	if(isChanged)
	{
		if(obj.id=="btnDelSingle" || obj.id=="imgRoleRight")
		{
			left=right;
		}
		
		for(i=0;i<left.options.length;i++)
		{
			strValue += left.options[i].value+",";
		}
		if(strValue.length>0) strValue=strValue.substr(0,strValue.length-1);
		hidden.value=strValue;
	}
	else
	{
		alert("请选定要移动的用户或角色!");
	}
}

// 从右ListBox对象中选中的项目移到左边的ListBox
// 设计：吴舒涛
// 日期：2006-02-22
function oRightClick(obj,strLeft,strRight,strHidden)
{
	oLeftClick(obj,strRight,strLeft,strHidden);
}


// 将页面上的Table对象数据拷贝到Excel中，实现数据的导出功能
// 设计：刘敏
// 日期：2006-02-24
function ExportExcel(tableObj)
{
	try{
		/*var out =document.getElementById("hr_man_schema")
		window.clipboardData.setData("Text", out.outerHTML);
		var oXL = new ActiveXObject("Excel.Application");
			// Get a new workbook.
				oXL.Visible = true;
				var oWB = oXL.Workbooks.Add();
				var oSheet = oWB.ActiveSheet;
		oSheet.Paste;*/
	 
		//拷贝
		var elTable = document.getElementById(tableObj);
		var oRangeRef = document.body.createTextRange();
		var sMsg = "导出失败！请尝试做如下操作：打开IE浏览器—工具—Ieternet选项——安全—本地Intranet—自定义级别—AxtiveX控件和插件，将“对没有标记为安全的AxtiveX进行初始化和脚本运行”一项设为“启用”状态";
		if (oRangeRef==null){alert(sMsg);return;}

		oRangeRef.moveToElementText( elTable );
		oRangeRef.execCommand( "Copy" );

		//粘贴
		var appExcel = new ActiveXObject( "Excel.Application" );
		if (appExcel==null){alert(sMsg);return;}
		appExcel.Visible = true;
		appExcel.Workbooks.Add().Worksheets.Item(1).Paste();
		appExcel = null;
	}
	catch(e){alert("Excel对象初始化失败："+e)}
}

// 将页面上的Table对象数据逐行逐列地写入到Excel文件中，实现数据的导出功能
// 设计：赵修勇
// 日期：2006-10-11
function ToExcel(TableObject)
{
	var o = document.getElementById(TableObject);
  window.oldOnError = window.onerror;
  window.onerror = function (err)
  {
  if (err.indexOf('utomation') != -1)
  {
      alert('用户禁止了 WScript.Shell 的使用！'); 
      return true;
  }
  else return false;
  };
  var xls    = new ActiveXObject ( "Excel.Application" );  
	var i,j; 
	var oWB = xls.Workbooks.Add(); 
	var oSheet = oWB.ActiveSheet;
	for(i=0;i< o.rows.length;i++) //从第一行开始
	{
		for(j=1;j< o.rows(i).cells.length;j++)//从第二列开始 
		{
			if(i>0) 
			{	
				oSheet.Cells(i+1,j).Font.Size = 10;
			}
			else 
			{				
				//oSheet.Cells(i+1,j).Interior.ColorIndex = 15;
				oSheet.Cells(i+1,j).VerticalAlignment = -4108;
				oSheet.Cells(i+1,j).HorizontalAlignment = -4108;
			}
			
			oSheet.Cells(i+1,j).Value = o.rows(i).cells(j).innerText; 	
			oSheet.Cells(i+1,j).Borders.Weight=2;	
		}
	}
	oSheet.Rows(1).RowHeight = 30;
	oSheet.Columns.AutoFit;
	xls.Visible = true; 
	xls.UserControl = true; 	
} 

// 将选中的对象值加入到某个控件(如：隐藏控件)的value中
// 设计：吴舒涛
// 日期：2004-10-25
function AddToString(oObj, oString)
{
	document.all[oObj].value += oString + ";";
}

// 将选中的对象值从指定控件(如：隐藏控件)的value中删除
// 设计：吴舒涛
// 日期：2004-10-25
function RemoveFromString(oObj, oString)
{
	var str = document.all[oObj].value;
	var re = new RegExp(oString+";","g");
	var r = str.replace(re, "");
	document.all[oObj].value = r;
}

function doapp(appID)
{
    var dr = OpenModalWin("../sys/approve.aspx?ID="+appID,650,490);
}

//确定用户的选择是单选还是多选
// sType：Single 为单选；Multi：为多选；gvGridView：DataGrid或GridView对象名；tbhSelected：选中后关键字内容存放的控件
// 设计：吴舒涛
// 日期：2006-04-04
// 修改:
// 1. 吴舒涛 2007-10-13 ASP.NET 2.0 中对象的编号少一个"_"符号同时序号也由最少一位改为二位（1改为01），即：原"gvClassRank__ctl1_chkSelect"，现改为："gvClassRank_ctl01_chkSelect"
function GridViewSelectMode(sType, nCurrentRow, gvGridView, tbhSelected)
{
	var dg = document.getElementById(gvGridView);
	var check;
	if(sType == "Single") //单选时，将选中的记录顺序号存入到隐藏控件中
	{
		for(var i=2; i<=dg.rows.length; i++)
		{
		  var sTmp ="0";
	    if (i<10) 
		  {
		      sTmp = sTmp.concat(i);
		  }
		  else
		  {
		      sTmp = i;
		  }
			check=document.getElementById(gvGridView+"_ctl"+sTmp+"_chkSelected");
			if(i == nCurrentRow)
			{
			  if(check!=null && check.checked)
			  {
				  AddToString(tbhSelected,dg.rows[i-1].cells[1].innerText);
				}
				else
				{
					RemoveFromString(tbhSelected,dg.rows[i-1].cells[1].innerText);
				}
				continue;
			}
			if(check!=null && check.checked)
			{
				RemoveFromString(tbhSelected,dg.rows[i-1].cells[1].innerText);
				check.checked = false;
			}
		}
	}
	else //多选时，将记录编号用“;”分开保存到隐藏控件中
	{
	  var sTmp ="0";
    if (nCurrentRow<10) 
	  {
	      sTmp = sTmp.concat(nCurrentRow);
	  }
	  else
	  {
	      sTmp = nCurrentRow;
	  }
		check=document.getElementById(gvGridView+"_ctl"+sTmp+"_chkSelected");
		if(check!=null && check.checked)
		{
			//AddToString(tbhSelected,nCurrentRow-2);
			AddToString(tbhSelected,dg.rows[nCurrentRow-1].cells[1].innerText);
		}
		else
		{
			//RemoveFromString(tbhSelected,nCurrentRow-2);
			RemoveFromString(tbhSelected,dg.rows[nCurrentRow-1].cells[1].innerText);
		}
	}
}