//打开指定的窗口 且最大化
var RemindWindowhx
function OpenWindowFullReal(name,url) {
if(! RemindWindowhx || RemindWindowhx.closed){
RemindWindowhx = window.open( "", name,"toolbar=no,top=0,left=0,width=0,height=0,location=no,directories=no,resizable=yes,status=no,menubar=no,scrollbars=yes" );
if (document.all){
RemindWindowhx.moveTo(0,0)
RemindWindowhx.resizeTo(screen.availWidth,screen.availHeight)
}

RemindWindowhx.location.href = url;}
else
{ RemindWindowhx.focus()
if (document.all){
RemindWindowhx.moveTo(0,0)
RemindWindowhx.resizeTo(screen.availWidth,screen.availHeight)
}
RemindWindowhx.location.href = url;
}}


function OpenWindowCenter(name,url,myWidth,myHeight) {
if(! RemindWindowhx || RemindWindowhx.closed){
var left=0,top=0;
if(screen.width > "800")
{
	left = (parseInt(screen.availWidth)-800)/2;
}
if(screen.height > "600")
{
	top = (parseInt(screen.availHeight)-600)/2;
}
RemindWindowhx = window.open( "", "_blank","toolbar=no,top="+ top +",left="+ left +",width="+ myWidth +",height="+ myHeight +",location=no,directories=no,resizable=yes,status=no,menubar=no,scrollbars=no" );


RemindWindowhx.location.href = url;
}
}
//打开指定的窗口
var RemindWindowh
function OpenWindow(name,url,top,left,width,height) {
if(! RemindWindowh || RemindWindowh.closed){
var myleft=0,mytop=0;
if(screen.width > "800")
{
	myleft = (parseInt(screen.availWidth)-800)/2;
}
if(screen.height > "600")
{
	mytop = (parseInt(screen.availHeight)-600)/4;
}
RemindWindowh = window.open( "", name,"toolbar=no,top="+ mytop +",left="+ myleft +",width="+ width +",height="+ height +",location=no,directories=no,resizable=yes,status=no,menubar=no,scrollbars=no" );

//RemindWindowh = window.open( "", name,"toolbar=no,top="+ top +",left="+ left +",width=800,height=600,location=no,directories=no,resizable=yes,status=no,menubar=no,scrollbars=yes" );
RemindWindowh.location.href = url;}
else
{ RemindWindowh.focus();
RemindWindowh.location.href = url;
}}

//打开指定的窗口
var RemindWindow
function OpenWindowMenu(name,url,top,left,width,height) {
if(! RemindWindow || RemindWindow.closed){
RemindWindow = window.open( "", name,"toolbar=no,top="+ top +",left="+ left +",width="+ width +",height="+ height +",location=no,directories=no,resizable=yes,status=no,menubar=yes,scrollbars=yes" );
RemindWindow.location.href = url;}
else
{ RemindWindow.focus()
RemindWindow.location.href = url;
}}

//根据分辨率调用指定的css文件		柯文杰 于 2003-4-16
function getCssByScreen(cssFileName)
{

	/*if(screen .width >800)
	{
		window.cssLinkId.href =cssFileName;
	}*/
}
//将一个选择框所选的内容添加至另外一个选择框
function AddItems(selectField,targetField)
{
	for(var i=0;i<selectField.options.length;i++)
	{	
		
		if(selectField.options[i].selected==true)
		{
			
			targetField.options[targetField.options.length]=new Option(selectField.options[i].text);
			targetField.options[targetField.options.length-1].value=selectField.options[i].value;
		
		}
	}
}
//从指定的选择框内删除所有选项
function RemoveAllItems(targetField)
{

	targetField.options.length=0;

}
//从指定的选择框内删除选中的选项
function RemoveItem(targetField)
{
	for(var i=0;i<targetField.options.length;i++)
	{	
		
		if(targetField.options[i].selected==true)
		{
			targetField.options[i]=null;
			
		}
	}
}

//设置title 和status   luym 2003/07/25
function titleAndStatus(){
	window.defaultStatus =self.document.title;
    top.document.title =self.document.title;
    }
 
//打印设置
function printOrder(orderType,orderId){
	OpenWindowMenu('print','../Print/DeCodePrint.aspx?orderType='+orderType+'&orderId='+orderId,'50','50','500','450');
}

//全部选中列表框
function SelectListAll(ListBoxID)
{
	var ObjListBox=document.all(ListBoxID);
	for(var i=0;i<ObjListBox.options.length;i++)
	{
		ObjListBox.options[i].selected=true;
	}
}

//全部选中多选框

function SelectAll(CheckBoxID)
{
	var ObjSelect=document.all(CheckBoxID);
	if(ObjSelect.length==null)
	{
		ObjSelect.checked=true;
	}
	else
	{
		for(var i=0;i<ObjSelect.length;i++)
		{
			ObjSelect[i].checked=true;
		}
	}
}


//数值(Numeric)类型校验函数
function CheckNumberInput(objText)
{
	if(objText.value!="")
	{
		if(isNaN(objText.value))
		{
			objText.value="";
			objText.focus();
			return false;
		}
	}
	return true;
}

//数字(int)类型校验函数
function CheckIntNumberInput(objText)
{
	if(objText.value!="")
	{
		for(var i=0;i<objText.value.length;i++)
		{
			var intTempNumber = objText.value.charAt(i);
			if(intTempNumber<"0" || intTempNumber>"9")
			{
				objText.value="";
				objText.focus();
				return false;
			}
		}
	}
	return true;
}

//校验电话号码
function CheckTelNumberInput(objText)
{
	if(objText.value!="")
	{
		for(var i=0;i<objText.value.length;i++)
		{
			var intTempNumber = objText.value.charAt(i);
			if(intTempNumber == "-" || intTempNumber == " ")
			{
				continue;
			}
			if(intTempNumber<"0" || intTempNumber>"9")
			{
				alert("请输入正确的电话号码！");
				objText.value="";
				objText.focus();
				return false;
			}
		}
	}
	return true;
}

//比较日期型时间大小
function CompareDate(SmallDate,BigDate)
{
	var intSmallYearLen = SmallDate.indexOf('-');
	var intBigYearLen = BigDate.indexOf('-');
	
	if(intSmallYearLen==-1 || intBigYearLen==-1)
	{
		return true;
	}
	
	var strSmallYear = parseInt(SmallDate.substring(0,intSmallYearLen));
	var strBigYear = parseInt(BigDate.substring(0,intBigYearLen));
	if(strSmallYear > strBigYear)
	{
		return false;
	}
	else if(strSmallYear < strBigYear)
	{
		return true;
	}
	else if(strSmallYear == strBigYear)
	{
		var intSmallMonthLen = SmallDate.indexOf('-',5);
		var intBigMonthLen = BigDate.indexOf('-',5);
		var strSmallMonth = parseInt(SmallDate.substring(intSmallYearLen+1,intSmallMonthLen));
		var strBigMonth = parseInt(BigDate.substring(intBigYearLen+1,intBigMonthLen));
		if(strSmallMonth > strBigMonth)
		{
			return false;
		}
		else if(strSmallMonth < strBigMonth)
		{
			return true;
		}
		else if(strSmallMonth == strBigMonth)
		{
			if(SmallDate.indexOf(':')>0)
			{
				SmallDate = SmallDate.substring(0,SmallDate.length-8);
			}
			if(BigDate.indexOf(':')>0)
			{
				BigDate = BigDate.substring(0,BigDate.length-8);
			}
			var intSmallDay = SmallDate.lastIndexOf('-')+1;
			var intBigDay = BigDate.lastIndexOf('-')+1;
			var strSmallDay = parseInt(SmallDate.substring(intSmallDay,SmallDate.length));
			var strBigDay = parseInt(BigDate.substring(intBigDay,BigDate.length));
			if(strSmallDay > strBigDay)
			{
				return false;
			}
			else
			{
				return true;
			}
		}
	}
	
}



//限制子表数量不能为0
function checkZero(tableID,colID)
{
	for(var y=1;y<document.all(tableID).rows.length;y++)
	{
		if(document.all(tableID).rows[y].cells[colID].innerText=="0")
		{
			return false;
		}
	}
}

//Create By zhangjiang 2003-3-29
//创建标题行覆盖DATAGRID的标题行
//要求：不支持样式的互相COPY，注意DATAGRID和页面的table保持样式要一致
function AdjustTitleMenu(tableId,dataGridId)
{
	var objTable = document.all(dataGridId);
	var cellCount = objTable.rows[0].cells.length;
	var oRow;

	if(document.all(tableId).rows[0] != null)
	{
		document.all(tableId).deleteRow(0);
	}
	
	oRow = document.all(tableId).insertRow();		//插入行
	

	//循环插入单元格
	for(var i=0;i<cellCount;i++)
	{
		oCell = oRow.insertCell();
	
		oCell.innerHTML = objTable.rows[0].cells[i].innerHTML;			//写单元格内容
		oCell.style.cssText = objTable.rows[0].cells[i].style.cssText;
		oCell.style.display = objTable.rows[0].cells[i].style.display;
		oCell.style.width = objTable.rows[0].cells[i].offsetWidth;		//设单元格宽度
		oCell.align = "center";											//字体居中
		oCell.vAlign = "middle";										//字体偏下
		
		oCell.borderColor = "white";									//设置边框颜色

		oCell.style.borderTopWidth = "0";			//上边界
		oCell.style.borderBottomWidth = "0";		//下边界
		oCell.style.borderRightWidth = "0";			//右边界
		if(i==0)
			oCell.style.borderLeftWidth = "0";			//左边界

	}
	
	oRow.style.height = objTable.rows[0].offsetHeight;								//行高
	oRow.style.color = objTable.rows[0].style.color;								//字体颜色
	oRow.style.backgroundColor = objTable.rows[0].style.backgroundColor;			//DataGrid背景色
	oRow.bgColor = objTable.rows[0].bgColor;										//Table背景色

//	document.all(tableId).style.cssText = objTable.style.cssText;
	
	document.all(tableId).style.top = getDataGridOffsetTop(objTable.rows[0],0);
	document.all(tableId).style.left = getDataGridOffsetLeft(objTable.rows[0],0);
	
	document.all(tableId).style.zIndex = 100;										//定层位置
	document.all(tableId).style.tableLayout = "fixed";								//table布局
	document.all(tableId).style.position = "absolute";								//绝对位置
	//document.all(tableId).style.borderCollapse = objTable.style.borderCollapse;		//边框样式
	document.all(tableId).cellPadding = objTable.cellPadding;						//单元格内距
	document.all(tableId).cellSpacing = objTable.cellSpacing;						//行间距
	//设置边框
	if(objTable.border != null && parseInt(objTable.border) != 0)
	{
		document.all(tableId).border = objTable.border;
		
	}
	else
	{
		document.all(tableId).border = "1";
	}
	
	//设置表格外边框的宽度和颜色
	document.all(tableId).style.borderColor = "black";

}
//寻找表头的上边界（TOP）
function getDataGridOffsetTop(e,intTopNum)
{
	if(e.tagName == "BODY")
	{
		intTopNum = intTopNum + e.offsetTop;
		return intTopNum;
	}
	else if((e.tagName.toUpperCase() == "TR" && e.parentElement.tagName.toUpperCase() == "TBODY") || (e.tagName.toUpperCase() == "TBODY" && e.parentElement.tagName.toUpperCase() == "TABLE"))
	{
		return getDataGridOffsetTop(e.parentElement,intTopNum);
	}
	else
	{
		intTopNum = intTopNum + e.offsetTop;
//		alert("TOP:" + e.offsetTop + "\n" + e.tagName + "-" + e.parentElement.tagName + "\n" + e.outerHTML);
		return getDataGridOffsetTop(e.parentElement,intTopNum);
	}
	
}
//寻找表头的左边界（LEFT）
function getDataGridOffsetLeft(e,intLeftNum)
{
	if(e.tagName == "BODY")
	{
		intLeftNum = intLeftNum + e.offsetLeft;
		
		return intLeftNum;
	}
	else if((e.tagName.toUpperCase() == "TR" && e.parentElement.tagName.toUpperCase() == "TBODY") || (e.tagName.toUpperCase() == "TBODY" && e.parentElement.tagName.toUpperCase() == "TABLE"))
	{
		return getDataGridOffsetLeft(e.parentElement,intLeftNum);
	}
	else
	{
		intLeftNum = intLeftNum + e.offsetLeft;
//		alert("LEFT:" + e.offsetLeft + "\n" + e.tagName + "-" + e.parentElement.tagName + "\n" + e.outerHTML);
		return getDataGridOffsetLeft(e.parentElement,intLeftNum);
	}
	
}
/***完成标题覆盖***/
/*********************************/


/***传递分页的值***/
//Create By zhangjiang 2004-4-16
//<param>页面名称</param>

//第一页
function FirstPage(searchKey,transferPage)
{
	var Url = transferPage + "?linkPageNum=1&searchKey="+searchKey;
	location.href=Url;
}

//上一页
function PrePage(searchKey,linkPageNum,transferPage)
{
	var Url = transferPage + "?linkPageNum="+linkPageNum+"&searchKey="+searchKey;
	location.href=Url;
}
//下一页
function NextPage(searchKey,linkPageNum,transferPage)
{
	var Url = transferPage + "?linkPageNum="+linkPageNum+"&searchKey="+searchKey;
	location.href=Url;
}

function LastPage(searchKey,linkPageNum,transferPage)
{
	var Url = transferPage + "?linkPageNum="+linkPageNum+"&searchKey="+searchKey;
	location.href=Url;
}

/***完成传递分页的值***/

/****返回父页面值***/
// cellIDText 要返回到父窗体的表的某列Text
// cellIDValue 要返回到父窗体的表的某列ID
function modifyValue(e,cellIDText,cellIDValue){
	var rowObj = findRow(e);
	var cellObj = findCell(e);

	if (cellIDText!="" && cellIDValue!="" && cellIDValue!="undefind")
	{
				 var parentRowObj = top.opener.isCalledRowByChild; //获取父窗口的行对象
				

										parentRowObj.cells[cellIDText].innerText = rowObj.cells[2].innerText;
										
										parentRowObj.cells[cellIDValue].innerText = rowObj.cells[1].innerText;	
		
						modifyTableRow();
	}
	else
	{
	for(i=0;i<rowObj.cells.length;i++){
		if(rowObj.cells[i].childNodes[0])
		{
			if(rowObj.cells[i].childNodes[0].nodeName=="#text")
			{
				if(rowObj.cells[i].oObject){
					if(top.opener.document.all(rowObj.cells[i].oObject)!=null)
						top.opener.document.all(rowObj.cells[i].oObject).value = rowObj.cells[i].innerText;
				}
			}
			else
			{
				if(rowObj.cells[i].oObject){
					if(top.opener.document.all(rowObj.cells[i].oObject)!=null)
						top.opener.document.all(rowObj.cells[i].oObject).value = rowObj.cells[i].childNodes[0].value;	
				}
			}
		}
	   }
	}
	top.window.close();
}
function findRow(e) {
	if (e.tagName == "TR") {
			return e;
	} else if (e.tagName == "BODY") {
		return null;
	} else {
		return findRow(e.parentElement);
	}
}
function findCell(e) {
	if (e.tagName == "TD") {
		return e;
	} else if (e.tagName == "BODY") {
		return null;
	} else {
		return findCell(e.parentElement);
	}
}
/*******************/
var RemindWindowGoogle

function OpenWindowExit (name,url,top,left)

{
	if(! RemindWindowGoogle || RemindWindowGoogle.closed)
	{
		RemindWindowGoogle = window.open( "", "monitor","toolbar=no,top="+ top +",left="+ left +",location=no,directories=no,resizable=yes,status=no,menubar=no,scrollbars=yes" );

		if (document.all)
		{
		//RemindWindowhx.moveTo(0,0)
		RemindWindowGoogle.resizeTo(screen.width,screen.height)
		}
		RemindWindowGoogle.location.href = url;
	}
	else
	{
		 RemindWindowGoogle.focus()
		if (document.all)
		{
			//RemindWindowhx.moveTo(0,0)
			RemindWindowGoogle.resizeTo(screen.width,screen.height)
		}
			RemindWindowGoogle.location.href = url;
	}
}

/*
Create By zhangjiang 2004-5-20
	计算子表的数量和单价的和
	适用子表只有一个单价字段的页面
参数
	tableId				表名
	amountIndex			数量单元格索引
	priceIndex			单价单元格索引
	moneyIndex			金额单元格索引
	amountTotalId		数量合计的文本框ID
	moneyTotalId		金额合计的文本框ID
*/
function computeColumn(tableId,amountIndex,priceIndex,moneyIndex,amountTotalId,moneyTotalId)
{
	var objTable = document.getElementById(tableId);
	if(objTable.rows.length>1)
	{
		var amountTotal = 0;			//定义列的总数量
		var moneyTotal = 0;				//定义列的总金额
		
		for(var i=1;i<objTable.rows.length;i++)
		{
			var currRow = objTable.rows[i];	//当前行
			
		/******** 横向计算 ********/
			var amountValue = 0;			//给数量初值
			var priceValue = 0;				//给价格初值
			/* 提取amount的值 */
			if(currRow.cells[amountIndex].childNodes[0].nodeName == "#text")
			{
				amountValue = currRow.cells[amountIndex].innerText;
			}
			else
			{
				amountValue = currRow.cells[amountIndex].childNodes[0].value;
			}
			/*** amount完毕 ***/
			/* 提取price的值 */
			if(currRow.cells[priceIndex].childNodes[0].nodeName == "#text")
			{
				priceValue = currRow.cells[priceIndex].innerText;
			}
			else
			{
				priceValue = currRow.cells[priceIndex].childNodes[0].value;
			}
			/*** price完毕 ***/

			/* 将计算结果附给moneyIndex单元格变量 */
			if(currRow.cells[moneyIndex].childNodes[0].nodeName == "#text")
			{
			
				currRow.cells[moneyIndex].innerText = parseFloat(amountValue)*parseFloat(priceValue);
			}
			else
			{
				
				currRow.cells[moneyIndex].childNodes[0].value = parseFloat(amountValue)*parseFloat(priceValue);
			}
			/*** moneyIndex完毕 ***/
		/******** 横向计算完毕 ********/
		
		/******** 纵向计算 ********/
			/*** 计算总数量 ***/
			if(currRow.cells[amountIndex].childNodes[0].nodeName == "#text")
			{
				amountTotal += parseFloat(currRow.cells[amountIndex].innerText);
			}
			else
			{
				amountTotal += parseFloat(currRow.cells[amountIndex].childNodes[0].value);
			}
			/*** 计算总数量完毕 ***/
			/*** 计算总金额 ***/
			//if(currRow.cells[priceIndex].childNodes[0].nodeName == "#text")
			//{
			//	moneyTotal += parseFloat(amountValue)*parseFloat(priceValue);
			//}
			//else
			//{
				moneyTotal += parseFloat(amountValue)*parseFloat(priceValue);
			//}
			/*** 计算总金额完毕 ***/
		
		/******** 纵向计算完毕 ********/
		

		}
		/*** 回送值 ***/
		if(document.getElementById(amountTotalId)!=null)
			document.getElementById(amountTotalId).value = amountTotal;
		if(document.getElementById(moneyTotalId) != null)
			document.getElementById(moneyTotalId).value = moneyTotal;
		/*** 回送值完毕 ***/
	}
}


/*	Create By zhangjiang 2004-5-21 
	判断子表不能为空，数量不能为0，数量单价只能填数字 
参数
	tableId				子表ID
	amoutCellIndex		子表数量的单元格索引
	priceCellTwoIndex	子表单价的单元格索引
	priceCellThreeIndex	子表现价的单元格索引
*/
function checkChildTable(tableId,amoutCellIndex,priceCellTwoIndex,priceCellThreeIndex)
{
	if(document.getElementById(tableId).rows.length<2)
	{
		alert("请先添加子商品");
		return false;
	}
	else
	{
		
		for(var i=1;i<document.getElementById(tableId).rows.length;i++)
		{
			if(amoutCellIndex!=null)
			{
				var strCell5 = document.getElementById(tableId).rows[i].cells[amoutCellIndex].childNodes[0].value;
				
				if(parseFloat(strCell5) == 0)
				{
					alert("子商品数量不能为0            ");
					return false;
				}
				if(isNaN(strCell5)==true)
				{
					alert("子商品数量只能填数字            ");
					return false;
				}
			}
			
			if(priceCellTwoIndex!=null)
			{
				var strCell7 = document.getElementById(tableId).rows[i].cells[priceCellTwoIndex].childNodes[0].value;
				if(isNaN(strCell7)==true)
				{
					alert("子商品单价只能填数字            ");
					return false;
				}
			}
			
			if(priceCellThreeIndex!=null)
			{
				var strCell8 = document.getElementById(tableId).rows[i].cells[priceCellThreeIndex].childNodes[0].value;
				if(isNaN(strCell8)==true)
				{
					alert("子商品现价只能填数字            ");
					return false;
				}
			}
			
		}
	}
	return true;
}



/*
Create By zhangjiang 2004-5-23
	计算子表的数量和单价的和
	适用子表有2个单价（原价，现价）和2个金额计算（原，现）字段的页面
参数
	tableId				表名
	amountIndex			数量单元格索引
	oldPriceIndex		原价单元格索引
	newPriceIndex		现价单元格索引
	oldMoneyIndex		愿金额单元格索引
	newMoneyIndex		现金额单元格索引
	oldAmountTotalId	数量合计的文本框ID
	oldMoneyTotalId		愿金额合计的文本框ID
	newMoneyTotalId		现金额合计的文本框ID
*/
function computeMulitColumn(tableId,amountIndex,oldPriceIndex,newPriceIndex,oldMoneyIndex,newMoneyIndex,oldAmountTotalId,oldMoneyTotalId,newMoneyTotalId)
{
	var objTable = document.getElementById(tableId);
	if(objTable.rows.length>1)
	{
		var amountTotal = 0;			//定义列的总数量
		var oldMoneyTotal = 0;			//定义列的原价总金额
		var newMoneyTotal = 0;			//定义列的现价总金额
		
		for(var i=1;i<objTable.rows.length;i++)
		{
			var currRow = objTable.rows[i];	//当前行
			
		/******** 横向计算 ********/
			var amountValue = 0;			//给数量初值
			var oldPriceValue = 0;			//给价格初值
			var newPriceValue = 0;			//给价格初值
			
			/* 提取amount的值 */
			if(currRow.cells[amountIndex].childNodes[0].nodeName == "#text")
			{
				amountValue = currRow.cells[amountIndex].innerText;
			}
			else
			{
				amountValue = currRow.cells[amountIndex].childNodes[0].value;
			}
			/*** amount完毕 ***/
			
			/* 提取oldPrice的值 */
			if(currRow.cells[oldPriceIndex].childNodes[0].nodeName == "#text")
			{
				oldPriceValue = currRow.cells[oldPriceIndex].innerText;
			}
			else
			{
				oldPriceValue = currRow.cells[oldPriceIndex].childNodes[0].value;
			}
			/*** oldPrice完毕 ***/
			
			/* 提取newPriceValue的值 */
			if(currRow.cells[newPriceIndex].childNodes[0].nodeName == "#text")
			{
				newPriceValue = currRow.cells[newPriceIndex].innerText;
			}
			else
			{
				newPriceValue = currRow.cells[newPriceIndex].childNodes[0].value;
			}
			/*** oldPrice完毕 ***/

			/* 将计算结果附给oldMoneyIndex单元格变量 */
			if(currRow.cells[oldMoneyIndex].childNodes[0].nodeName == "#text")
			{
			
				currRow.cells[oldMoneyIndex].innerText = parseFloat(amountValue)*parseFloat(oldPriceValue);
			}
			else
			{
				
				currRow.cells[oldMoneyIndex].childNodes[0].value = parseFloat(amountValue)*parseFloat(oldPriceValue);
			}
			/*** oldMoneyIndex完毕 ***/
	
			/* 将计算结果附给newMoneyIndex单元格变量 */
			if(currRow.cells[newMoneyIndex].childNodes[0].nodeName == "#text")
			{
			
				currRow.cells[newMoneyIndex].innerText = parseFloat(amountValue)*parseFloat(newPriceValue);
			}
			else
			{
				
				currRow.cells[newMoneyIndex].childNodes[0].value = parseFloat(amountValue)*parseFloat(newPriceIndex);
			}
			/*** oldMoneyIndex完毕 ***/
		/******** 横向计算完毕 ********/
		
		/******** 纵向计算 ********/
			/*** 计算总数量 ***/
			if(currRow.cells[amountIndex].childNodes[0].nodeName == "#text")
			{
				amountTotal += parseFloat(currRow.cells[amountIndex].innerText);
			}
			else
			{
				amountTotal += parseFloat(currRow.cells[amountIndex].childNodes[0].value);
			}
			/*** 计算总数量完毕 ***/
			/*** 计算总金额 ***/

			oldMoneyTotal += parseFloat(amountValue)*parseFloat(oldPriceValue);
			newMoneyTotal += parseFloat(amountValue)*parseFloat(newPriceValue);

			/*** 计算总金额完毕 ***/
		
		/******** 纵向计算完毕 ********/
		

		}
		/*** 回送值 ***/
		if(document.getElementById(oldAmountTotalId)!=null)
			document.getElementById(oldAmountTotalId).value = amountTotal;
		if(document.getElementById(oldMoneyTotalId) != null)
			document.getElementById(oldMoneyTotalId).value = oldMoneyTotal;
		if(document.getElementById(newMoneyTotalId) != null)
			document.getElementById(newMoneyTotalId).value = newMoneyTotal;
		/*** 回送值完毕 ***/
	}
}

/* Create By zhangjiang 2004-5-25 */
/* 专为采购结算和销售结算编写 */
function ComputeForDownFiniancingCounteract(tableId,amountIndex,priceIndex,moneyIndex,effacementIndex,totalCellId1,totalCellId2,totalCellId3,totalCellId4)
{
	var objTable = document.getElementById(tableId);
	if(objTable.rows.length>1)
	{
		var amountTotal = 0;			//第一列合计
		var priceTotal = 0;				//第二列合计
		var moneyTotal = 0;				//第三列合计
		var effacementTotal = 0;		//第四列合计
		
		for(var i=1;i<objTable.rows.length;i++)
		{
			var currRow = objTable.rows[i];	//当前行
			
		/******** 纵向计算 ********/
			if(amountIndex!=null)
			{
				if(currRow.cells[amountIndex].childNodes[0].nodeName == "#text")
				{
					amountTotal += parseFloat(currRow.cells[amountIndex].innerText);
				}
				else
				{
					amountTotal += parseFloat(currRow.cells[amountIndex].childNodes[0].value);
				}
			}
			if(priceIndex!=null)
			{
				if(currRow.cells[priceIndex].childNodes[0].nodeName == "#text")
				{
					priceTotal += parseFloat(currRow.cells[priceIndex].innerText);
				}
				else
				{
					priceTotal += parseFloat(currRow.cells[priceIndex].childNodes[0].value);
				}
			}
			if(moneyIndex!=null)
			{
				if(currRow.cells[moneyIndex].childNodes[0].nodeName == "#text")
				{
					moneyTotal += parseFloat(currRow.cells[moneyIndex].innerText);
				}
				else
				{
					moneyTotal += parseFloat(currRow.cells[moneyIndex].childNodes[0].value);
				}
			}
			if(effacementIndex!=null)
			{
				if(currRow.cells[effacementIndex].childNodes[0].nodeName == "#text")
				{
					effacementTotal += parseFloat(currRow.cells[effacementIndex].innerText);
				}
				else
				{
					effacementTotal += parseFloat(currRow.cells[effacementIndex].childNodes[0].value);
				}
			}
			
			/*** 计算总金额完毕 ***/
		
		/******** 纵向计算完毕 ********/
		

		}
		/*** 回送值 ***/
		if(totalCellId1 !=null && document.getElementById(totalCellId1)!=null)
			document.getElementById(totalCellId1).value = amountTotal;
		if(totalCellId2 !=null && document.getElementById(totalCellId2) != null)
			document.getElementById(totalCellId2).value = priceTotal;
		if(totalCellId3 !=null && document.getElementById(totalCellId3) != null)
			document.getElementById(totalCellId3).value = moneyTotal;
		if(totalCellId4 !=null && document.getElementById(totalCellId4) != null)
			document.getElementById(totalCellId4).value = effacementTotal;
		/*** 回送值完毕 ***/
	}
}
/* 完成 */


/*
	为了无框架的单页面点击一行记录，将数据拼成XML，放在隐藏文本框中	
参数
	clickButtonId		要点击触发底层事件的按钮的ID
*/
function getXmlSetInHiddenText(clickButtonId)
{
	var e = event.srcElement;
	var currRow = findRow(e);
	var currCell = findCell(e);
	var strXml = "<NewDataSet><table>";
	
	for(var i=0;i<currRow.cells.length;i++)
	{
		if(currRow.cells[i].oColName)
		{
			
			if(currRow.cells[i].childNodes[0].nodeName == "#text")
			{
				strXml += "<" + currRow.cells[i].oColName + ">" + currRow.cells[i].innerText + "</" + currRow.cells[i].oColName + ">"
			}
			else
			{
				strXml += "<" + currRow.cells[i].oColName + ">" + currRow.cells[i].childNodes[0].value + "</" + currRow.cells[i].oColName + ">"
			}
		}
	}
	
	strXml += "</table></NewDataSet>";

	document.getElementById("hidXml").value = strXml;	//回送XML
	
	if(clickButtonId != null)
	{
		document.getElementById(clickButtonId).click();
	}
//	self.close();
}


//Create By zhangjiang 2003-3-29
//创建标题行覆盖DATAGRID的标题行
//要求：不支持样式的互相COPY，注意DATAGRID和页面的table保持样式要一致
function AdjustTitleMenuForDataGride(tableId,dataGridId)
{
	var objTable = document.all(dataGridId);
	var cellCount = objTable.rows[0].cells.length;
	var oRow;
	
	if(document.all(tableId).rows[0] != null)
	{
		document.all(tableId).deleteRow(0);
	}
	
	oRow = document.all(tableId).insertRow();		//插入行
	

	//循环插入单元格
	for(var i=0;i<cellCount;i++)
	{
		oCell = oRow.insertCell();
	
		oCell.innerHTML = objTable.rows[0].cells[i].innerHTML;			//写单元格内容
		oCell.style.cssText = objTable.rows[0].cells[i].style.cssText;
		oCell.style.display = objTable.rows[0].cells[i].style.display;
		oCell.style.width = objTable.rows[0].cells[i].offsetWidth;		//设单元格宽度
		oCell.align = "center";											//字体居中
		oCell.vAlign = "bottom";										//字体偏下
		
		oCell.borderColor = "white";									//设置边框颜色
		//由于2个单元格边框叠加在一起，去掉偶数单元格边框
		if(i%2==0)
		{
			oCell.style.borderLeftWidth = "0";
			oCell.style.borderRightWidth = "0";
		}
		
	}
	
	oRow.style.height = objTable.rows[0].offsetHeight;								//行高
	oRow.style.color = objTable.rows[0].style.color;								//字体颜色
	oRow.style.backgroundColor = objTable.rows[0].style.backgroundColor;			//DataGrid背景色
	oRow.bgColor = objTable.rows[0].bgColor;										//Table背景色

	
	
	//定位top和left
//	document.all(tableId).style.cssText = objTable.style.cssText;
//	alert(objTable.style.cssText);
	
	document.all(tableId).style.top = getDataGridOffsetTop(objTable,0);
	document.all(tableId).style.left = getDataGridOffsetLeft(objTable,0);
	
	document.all(tableId).style.zIndex = 100;										//定层位置
	document.all(tableId).style.tableLayout = "fixed";								//table布局
	document.all(tableId).style.position = "absolute";								//绝对位置
	document.all(tableId).style.borderCollapse = objTable.style.borderCollapse;		//边框样式
	document.all(tableId).cellPadding = objTable.cellPadding;						//单元格内距
	document.all(tableId).cellSpacing = objTable.cellSpacing;						//行间距
	//设置边框
	if(objTable.border != null)
	{
		document.all(tableId).border = objTable.border;
		
	}
	else
	{
		document.all(tableId).border = "1";
	}
	//设置表格外边框的宽度和颜色
	//document.all(tableId).borderWidth = "0px";
	document.all(tableId).borderColor = "black";

}
//寻找表头的上边界（TOP）
function getDataGridOffsetTop(e,intTopNum)
{
	if(e.tagName == "BODY")
	{
		intTopNum = intTopNum + e.offsetTop;
		return intTopNum;
	}
	else if(e.tagName == "TD" || (e.tagName.toUpperCase() == "TBODY" && e.parentElement.tagName.toUpperCase() == "TABLE"))
	{
		return getDataGridOffsetTop(e.parentElement,intTopNum);
	}
	else
	{
		intTopNum = intTopNum + e.offsetTop;
//		alert("TOP:" + e.offsetTop + "\n" + e.tagName + "-" + e.parentElement.tagName + "\n" + e.outerHTML);
		return getDataGridOffsetTop(e.parentElement,intTopNum);
	}
	
}
//寻找表头的左边界（LEFT）
function getDataGridOffsetLeft(e,intLeftNum)
{
	if(e.tagName == "BODY")
	{
		intLeftNum = intLeftNum + e.offsetLeft;
		return intLeftNum;
	}
	else if((e.tagName.toUpperCase() == "TR" && e.parentElement.tagName.toUpperCase() == "TBODY") || (e.tagName.toUpperCase() == "TBODY" && e.parentElement.tagName.toUpperCase() == "TABLE"))
	{
		return getDataGridOffsetLeft(e.parentElement,intLeftNum);
	}
	else
	{
		intLeftNum = intLeftNum + e.offsetLeft;
//		alert("LEFT:" + e.offsetLeft + "\n" + e.tagName + "-" + e.parentElement.tagName + "\n" + e.outerHTML);
		return getDataGridOffsetLeft(e.parentElement,intLeftNum);
	}
	
}
/***完成标题覆盖***/
/*********************************/


function refreshDiv(DataGridID)
{
	try
	{
		oTitle.rows(0).style.width=document.all(""+DataGridID+"").rows(0).offsetWidth;
		if (countR==0){
		oTitle.rows(0).style.height=document.all(""+DataGridID+"").rows(0).offsetHeight+5;
		}
		var k=document.all(""+DataGridID+"").rows(0).cells.length
		for (i=0;i<k;i++)
		{
			oTitle.rows(0).cells(i).style.width=document.all(""+DataGridID+"").rows(0).cells(i).offsetWidth;
		}
		divspan.style.height=oTitle.rows(0).style.height
		document.all(""+DataGridID+"").rows(0).style.height=1;
	countR=1;
window.setTimeout("refreshDiv('"+DataGridID+"')",500);
	}
	catch(e)
	{
	
	}
		
}


/* 
	Create By zhangjiang 2004-5-30
	比较子表中两个值的大小
参数
	tableId			子表的ID
	oneCellIndex	第一个值作在表中的单元格索引
	twoCellIndex	第二个值作在表中的单元格索引
返回值
	如果第一个大于第二个，返回true，否则false
*/
function CompareTwoCellValue(tableId,oneCellIndex,twoCellIndex)
{
	var objTable = document.getElementById(tableId);
	if(objTable.rows.length>1)
	{
		var oneValue,twoValue;
		for(var i=1;i<objTable.rows.length;i++)
		{
			if(objTable.rows[i].cells[oneCellIndex].childNodes[0].nodeName == "#text")
				oneValue = Math.abs(objTable.rows[i].cells[oneCellIndex].innerText);
			else
				oneValue = Math.abs(objTable.rows[i].cells[oneCellIndex].childNodes[0].value);
			
			if(objTable.rows[i].cells[twoCellIndex].childNodes[0].nodeName == "#text")
				twoValue = Math.abs(objTable.rows[i].cells[twoCellIndex].innerText);
			else
				twoValue = Math.abs(objTable.rows[i].cells[twoCellIndex].childNodes[0].value);

			if(oneValue <= twoValue)
			{
				return false;
			}
		}
	}
	return true;
}


/*
	判断输入的值str只能在strRange范围里面，否则报错
	ControlId	输入控件的Id
	strRange	允许输入的字符串范围
*/

function IsInRange(ControlId,strRange,ErrorMessage)
{
	var objControl = document.getElementById(ControlId);

	for(var i=0;i<objControl.value.length;i++)
	{
		if(strRange.indexOf(objControl.value.charAt(i))==-1)
		{
			alert(ErrorMessage+"            ");
			objControl.focus();
			return false;
		}
	}
	return true;
}


//打开指定的窗口 且最大化
var RemindWindowhx
function OpenWindowFullRealNoScroll(name,url) {
if(! RemindWindowhx || RemindWindowhx.closed){
RemindWindowhx = window.open( "", "_blank","toolbar=no,location=no,directories=no,resizable=yes,status=no,menubar=no,scrollbars=no" );
if (document.all){
RemindWindowhx.moveTo(0,0)
RemindWindowhx.resizeTo(screen.availWidth,screen.availHeight)
}

RemindWindowhx.location.href = url;}
else
{ RemindWindowhx.focus()
if (document.all){
RemindWindowhx.moveTo(0,0)
RemindWindowhx.resizeTo(screen.availWidth,screen.availHeight)
}
RemindWindowhx.location.href = url;
}}

//显示开单页面的帐户信息
//现在目前用于付款结算单
//Songhh Added in 2005-06-24
function disPlayAcc(id)
{
	if (document.all("ScriptDiv"))
  	{
		for(var i=0;i<id.options.length;i++)
		{
			if(id.options[i].selected == true)
			{
				var strValue = id.options[i].text;
				break;
			}
		}
		var pX = event.x + document.body.scrollLeft;
		var pY = event.y + document.body.scrollTop - 35;
		var shtml="<div class='BlackDiv' title='"+ strValue +"' style='position:absolute;left:"+pX+";top:"+pY+"; background-color: #FFFFDD; layer-background-color: #FFFF99;'>"+strValue+"</div>" ;
		ScriptDiv.innerHTML = shtml;
  	}
}
//Songhh Added in 2006-4-25
//采购订单的商品选择界面和开单界面
function disPlayForOrder()
{ 	
    /*
  	    for(var e=1;e<document.all("allProductsTable").rows.length;e++)
  	    {
  	        var strValue = document.all("allProductsTable").rows[e].cells[11].childNodes[0].value;
  	    }
  	 */ 
    var e = event.srcElement;
	var rowSource=findRow(e);	
    if (document.all("ScriptDiv"))
  	{
  	    var strValue = rowSource.cells[11].childNodes[0].value;
  	    if(strValue != "")
  	    {		
		    var pX = event.x + document.body.scrollLeft + 10;
		    var pY = event.y + document.body.scrollTop;
		    var shtml="<div class='BlackDiv' title='"+ strValue +"' style='position:absolute;left:"+pX+";top:"+pY+"; background-color: #FFFFDD; layer-background-color: #FFFF99;'>"+strValue+"</div>" ;
		    ScriptDiv.innerHTML = shtml;
		}
		
  	}
}
//显示品名等列"title" 
function disPlay(e)
{ 
	if (document.all("ScriptDiv"))
  	{
		var strValue = e.value;
		var pX = event.x + document.body.scrollLeft + 10;
		var pY = event.y + document.body.scrollTop;
		var shtml="<div class='BlackDiv' title='"+ strValue +"' style='position:absolute;left:"+pX+";top:"+pY+"; background-color: #FFFFDD; layer-background-color: #FFFF99;'>"+strValue+"</div>" ;
		ScriptDiv.innerHTML = shtml;
  	}
}
function unDisPlay()
{
	
	if (document.all("ScriptDiv"))
    {
		ScriptDiv.innerHTML = "";
    }	
}

//打开指定的窗口 且最大化Login.aspx专用
var RemindWindowhL
function OpenWindowFullRealForLogin(name,url) {
if(! RemindWindowhL || RemindWindowhL.closed){
RemindWindowhL = window.open( "", "_blank","toolbar=no,location=no,directories=no,resizable=yes,status=no,menubar=no,scrollbars=yes" );
if (document.all){
RemindWindowhL.moveTo(0,0)
RemindWindowhL.resizeTo(screen.availWidth,screen.availHeight)
}

RemindWindowhL.location.href = url;}
else
{ RemindWindowhL.focus()
if (document.all){
RemindWindowhL.moveTo(0,0)
RemindWindowhL.resizeTo(screen.availWidth,screen.availHeight)
}
RemindWindowhL.location.href = url;
}}


var RemindWindowGoogle

function OpenWindowExitClose (name,url,top,left)

{
	if(! RemindWindowGoogle || RemindWindowGoogle.closed)
	{
		RemindWindowGoogle = window.open( "", "monitor","toolbar=no,top="+ top +",left="+ left +",location=no,directories=no,resizable=yes,status=no,menubar=no,scrollbars=yes" );

		if (document.all)
		{
		//RemindWindowhx.moveTo(0,0)
		//RemindWindowGoogle.resizeTo(screen.width,screen.height)
		}
		RemindWindowGoogle.close();
	}
	else
	{
		 RemindWindowGoogle.focus()
		if (document.all)
		{
			//RemindWindowhx.moveTo(0,0)
			RemindWindowGoogle.resizeTo(screen.width,screen.height)
		}
		RemindWindowGoogle.close();
	}
}


//取对话框的审核意见值
//用于各个开单界面添加审核意见 Liug 2004/08/30
function getAuditionMind(SessionAuditionId,objInput){
	//var str = objInput.value;
	var vReturnValue = showModalDialog("../Pop/PopAuditionMind.aspx","","dialogWidth:396px;dialogHeight:203px;status:no;center:true");

	var s = "";  
	var d = new Date(); 
	s += d.getYear() +"-";
	s += (d.getMonth() + 1) + "-";  
	s += d.getDate() + "  ";
	s += d.getHours() + ":";
	s += d.getMinutes() + ":";
	s += d.getSeconds();
	
	if (vReturnValue!="" && vReturnValue!=null)
	{	
		if (vReturnValue == "CancelAuditing")
		{
			objInput.value = vReturnValue
		}
		else
		{
			objInput.value += "\n"+SessionAuditionId+s+" 评审："+vReturnValue;
		}
	}
}
function showMessage(messageStr)
{
	alert(messageStr);
}

//按钮单击后变灰
function hasClick(id)
{
	id.disabled = true;
}

//Open
function OpenModalDialog(Url)
{
	window.showModalDialog(Url,null,'dialogTop:0;dialogLeft:0;dialogWidth:'+screen.availWidth+';dialogHeight:'+screen.availHeight+'');
}


//去掉字符串两边的空格，Add by DuH
function TrimString(s)
{
	if (s == null)
		return s;
	var i;
	var beginIndex = 0;
	var endIndex = s.length-1;
	
	for (i = 0;i < s.length;i++)
	{
		if (s.charAt(i) == ' '||s.charAt(i) == ' ')
			beginIndex++;
		else
			break;
	}
	for (i = s.length-1;i >= 0;i--)
	{
		if (s.charAt(i) == ' '||s.charAt(i) == ' ')
			endIndex--;
		else
			break;
	}
	if (endIndex < beginIndex)
		return "";
	return s.substring(beginIndex,endIndex+1);
}


//用于费用单显示附件
function OpenFile (e)
{
	var table = document.all("oTable");
	var FeesOrderID;
	var customer;
	var objRow = findRow(e);
	
	FeesOrderID = document.all("FeesOrderID").value;
	customer = document.all("customName").value;
	var address = objRow.cells[6].innerText;
	
	if (FeesOrderID != "自动生成" || customer != "")
	{
		OpenWindow('File','accessories.aspx?address='+address+'&FeesOrderID='+FeesOrderID+'&customer='+customer,'20','20','600','500');
	}
	else
	{
		OpenWindow('File','accessories.aspx?address='+address,'20','20','600','500');
	}
	
	
}

//用于费用单的附件上传功能
function ChooseAddress (e)
{
	var table = document.all("oTable");
	//先将所有的复选框置为非选中状态
	for (i=1; i<table.rows.length; i++)
	{
		table.rows[i].cells[5].childNodes[0].checked = false;
	
	}
	//再将刚刚点击的那一行的复选框置为选中状态
	var objRow = findRow(e);
	objRow.cells[5].childNodes[0].checked = true;
	
	var FileAddress = document.all("btn_hid");
	FileAddress.click();
	
}
