 function killErrors(){
                    return true;
            }
window.onerror = killErrors;
//==========================================================================
//
//  代码描述：控制文本框的输入
//  
//  传入参数：control - 需要验证的文本框
//            txtColor - 需要改变颜色的文本
//            ImgPlay - 显示的图片
//            txt - 提示文本 
//  返回参数：无
//
//  修改记录：姓名              日期                 内容
//           wxf            2003/06/24             创建
//
//==========================================================================
function Authentication(control,txtColor,ImgPlay)
    {
        var tmp_str = control.value.replace(/(^\s*)|(\s*$)/g, "");
        var pattern = /[^0-9A-Z_a-z\_\u4E00-\u9FA5]/g;
        if(tmp_str!="")
        {
            if(4<tmp_str.length<10)
            {
                if(pattern.test(tmp_str))
                {
                    document.getElementById(txtColor).style.color="red";
                    document.getElementById(ImgPlay).style.display="block";
                    document.getElementById(ImgPlay).src="/Gen/Commom/Image/image/cancel_48.jpg";
                }
                else
                {
                    document.getElementById(ImgPlay).style.display="block";
                    document.getElementById(ImgPlay).src="/Gen/Commom/Image/image/accepted_48.jpg";
                }
            }
            else
            {
                document.getElementById(ImgPlay).style.display="block";
                document.getElementById(ImgPlay).src="/Gen/Commom/Image/image/accepted_48.jpg";
            }
            
        }
    }
//==========================================================================
//
//  代码描述：打开一个新的有状态栏、工具栏、菜单栏、定位栏，
//            可以改变大小，且位置居中的新窗口
//  
//  传入参数：pageURL - 传递链接
//            innerWidth - 传递需要打开新窗口的宽度
//            innerHeight - 传递需要打开新窗口的高度
//  
//  返回参数：无
//
//  修改记录：姓名              日期                 内容
//           wxf            2003/06/24             创建
//
//==========================================================================
function g_OpenSizeWindow(pageURL, innerWidth, innerHeight)
{	
	var ScreenWidth = screen.availWidth
	var ScreenHeight = screen.availHeight
	var StartX = (ScreenWidth - innerWidth) / 2
	var StartY = (ScreenHeight - innerHeight) / 2
	window.open(pageURL, '', 'left='+ StartX + ', top='+ StartY + ', Width=' + innerWidth +', height=' + innerHeight + ', resizable=yes, scrollbars=yes, status=yes, toolbar=yes, menubar=yes, location=no')
}
//==========================================================================================
//调用方法
//onKeyDown="textCounter(this.form.控件名,最大长度);" 
//onKeyUp="textCounter(this.form.控件名,最大长度);" 
//==========================================================================================
function textCounter(field,  maxlimit) 
{//控制文本输入的长度
    try{
        if (field.value.length > maxlimit) // if too long...trim it!
    
        {
            field.value = field.value.substring(0, maxlimit);
        
            var showMessage = '输入文本的长度大于'+maxlimit+'，多余的文字已被截取！';
            alert(showMessage);
        }
    }catch(e){}
   
}
//==========================================================================
//
//  代码描述：打开一个新的没有状态栏、工具栏、菜单栏、定位栏，
//            可以改变大小，且位置居中的新窗口
//  
//  传入参数：pageURL - 传递链接
//            innerWidth - 传递需要打开新窗口的宽度
//            innerHeight - 传递需要打开新窗口的高度
//  
//  返回参数：无
//
//  修改记录：姓名              日期                 内容
//           wxf           2003/06/24             创建
//
//==========================================================================
function g_OpenWindow(pageURL, innerWidth, innerHeight)
{	
	var ScreenWidth = screen.availWidth
	var ScreenHeight = screen.availHeight
	var StartX = (ScreenWidth - innerWidth) / 2
	var StartY = (ScreenHeight - innerHeight) / 2
	window.open(pageURL, '', 'left='+ StartX + ', top='+ StartY + ', Width=' + innerWidth +', height=' + innerHeight + ', resizable=yes, scrollbars=yes, status=no, toolbar=no, menubar=no, location=no')
}
//控制文本框只能输入数字
function IsNum(oInput)
{//js不支持直接重载，所以用变通的方法实现重载
    var len= arguments.length;
    if(0 == len)
    {
    IsNum0();

    }
    else
    {
    IsNum1(oInput);

    }
}
function IsNum0()//控制文本框只能输入数字
{
//debugger
    if(event.keyCode<48 || event.keyCode>57)
    {
         event.keyCode=0;
    }
}
function IsNum1(oInput)//控制文本框只能输入数字为两位小数/^[+-]?[0-9]+(\.[0-9])？$/
{
//debugger

      //if((event.keyCode<48 || event.keyCode>57) && event.keyCode!=46 || /(\.){0,1}\d\d$/.test(value))event.returnValue=false
    if('' != oInput.value.replace(/\d{1,}\.{0,1}\d{0,2}/,''))
    {
        oInput.value = oInput.value.match(/\d{1,}\.{0,1}\d{0,2}/) == null ? '' :oInput.value.match(/\d{1,}\.{0,1}\d{0,2}/);
    }
}
function killErrors() 
{ 
	return true; 
} 
function IsNum3(oInput)//控制文本框只能输入数字为0位小数/^[+-]?[0-9]+(\.[0-9])？$/
{
//debugger

      //if((event.keyCode<48 || event.keyCode>57) && event.keyCode!=46 || /(\.){0,1}\d\d$/.test(value))event.returnValue=false
    if('' != oInput.value.replace(/\d{1,}/,''))
    {
        oInput.value = oInput.value.match(/\d{1,}/) == null ? '' :oInput.value.match(/\d{1,}/);
    }
}
//==========================================================================
//
//  代码描述：打开一个新的没有状态栏、工具栏、菜单栏、定位栏，
//            不能改变大小，且位置居中的新窗口
//       
//  
//  传入参数：pageURL - 传递链接
//            innerWidth - 传递需要打开新窗口的宽度
//            innerHeight - 传递需要打开新窗口的高度
//  
//  返回参数：返回的数值
//
//  修改记录：姓名              日期                 内容
//            wxf            2003/06/24             创建
//
//==========================================================================
function g_OpenReturnWindow(pageURL, innerWidth, innerHeight)
{	
	var ScreenWidth = screen.availWidth
	var ScreenHeight = screen.availHeight
	var StartX = (ScreenWidth - innerWidth) / 2
	var StartY = (ScreenHeight - innerHeight) / 2
	window.open(pageURL, '', 'left='+ StartX + ', top='+ StartY + ', Width=' + innerWidth +', height=' + innerHeight + ', resizable=yes, scrollbars=yes, status=no, toolbar=no, menubar=no, location=no')
	return false;
}
// 060421 h
function g_ShowModelDialog(pageURL, ifCenter, ifStatus)
{
	var sFeatures = '' ;
	if( ifCenter == true )
		sFeatures += 'center:yes;' ;
	else
		sFeatures += 'center:no;' ;
	if( ifStatus == true )
		sFeatures += 'status:yes;' ;
	else
		sFeatures += 'status:no;' ;
	window.showModalDialog(pageURL,null,sFeatures) ;
	return false;
}
// 060430 h
function g_ShowModelessDialog(pageURL, ifCenter, ifStatus)
{
	var sFeatures = 'help:no;' ;
	if( ifCenter == true )
		sFeatures += 'center:yes;' ;
	else
		sFeatures += 'center:no;' ;
	if( ifStatus == true )
		sFeatures += 'status:yes;' ;
	else
		sFeatures += 'status:no;' ;
	window.showModelessDialog(pageURL,null,sFeatures) ;
	return false;
}
// 060430
function g_ShowModelessDialog2(pageURL, ifCenter, ifStatus,varHeigh,varWidth)
{
	var sFeatures = 'help:no;dialogWidth:'+varWidth+';dialogHeight:'+varHeigh+';' ;
	if( ifCenter == true )
		sFeatures += 'center:yes;' ;
	else
		sFeatures += 'center:no;' ;
	if( ifStatus == true )
		sFeatures += 'status:yes;' ;
	else
		sFeatures += 'status:no;' ;
	window.showModelessDialog(pageURL,null,sFeatures) ;
	return false;
}
// 060430 h
function g_ShowModelessDialogMax(pageURL, ifCenter, ifStatus)
{
	var sFeatures = 'help:no;dialogWidth:1024px;dialogHeight:768px;' ;
	if( ifCenter == true )
		sFeatures += 'center:yes;' ;
	else
		sFeatures += 'center:no;' ;
	if( ifStatus == true )
		sFeatures += 'status:yes;' ;
	else
		sFeatures += 'status:no;' ;
	window.showModelessDialog(pageURL,null,sFeatures) ;
	return false;
}
// 060523 h
function g_ShowModelessDialogDetail(pageURL, ifCenter, ifStatus)
{
	var sFeatures = 'help:no;dialogWidth:800px;dialogHeight:600px;' ;
	if( ifCenter == true )
		sFeatures += 'center:yes;' ;
	else
		sFeatures += 'center:no;' ;
	if( ifStatus == true )
		sFeatures += 'status:yes;' ;
	else
		sFeatures += 'status:no;' ;
	window.showModelessDialog(pageURL,null,sFeatures) ;
	return false;
}
// 060921 yucca
function g_ShowModelDialogPosistion(pageURL, ifCenter, ifStatus,varHeigh,varWidth)
{
	var sFeatures = 'dialogWidth:'+varWidth+';dialogHeight:'+varHeigh+';' ;
	if( ifCenter == true )
		sFeatures += 'center:yes;' ;
	else
		sFeatures += 'center:no;' ;
	if( ifStatus == true )
		sFeatures += 'status:yes;' ;
	else
		sFeatures += 'status:no;' ;
	window.showModalDialog(pageURL,null,sFeatures) ;
	return false;
}
// 060421 h
function g_ShowModelDialog2(pageURL, ifCenter, ifStatus,varHeigh,varWidth)
{
	var sFeatures = 'dialogWidth:'+varWidth+';dialogHeight:'+varHeigh+';' ;
	if( ifCenter == true )
		sFeatures += 'center:yes;' ;
	else
		sFeatures += 'center:no;' ;
	if( ifStatus == true )
		sFeatures += 'status:yes;' ;
	else
		sFeatures += 'status:no;' ;
	window.showModalDialog(pageURL,null,sFeatures) ;
	return false;
}
function g_OpenReturnWindowNoScrollbars(pageURL, innerWidth, innerHeight)
{	
	var ScreenWidth = screen.availWidth
	var ScreenHeight = screen.availHeight
	var StartX = (ScreenWidth - innerWidth) / 2
	var StartY = (ScreenHeight - innerHeight) / 2
	window.open(pageURL, '', 'left='+ StartX + ', top='
		+ StartY + ', Width=' + innerWidth +', height=' + innerHeight + ', resizable=no, scrollbars=no, status=no, toolbar=no, menubar=no, location=no')
	//return false
}


//==========================================================================
//
//  代码描述：打开一个新的没有状态栏、工具栏、菜单栏、定位栏，
//            不能改变大小，且位置居中的新窗口
//  
//  传入参数：pageURL - 传递链接
//  
//  返回参数：无
//
//  修改记录：姓名              日期                 内容
//            wxf            2003/11/14           创建
//
//==========================================================================
function g_OpenReturnWindowPrint(pageURL)
{	
	var ScreenWidth = screen.availWidth
	var ScreenHeight = screen.availHeight
	//var StartX = (ScreenWidth - innerWidth) / 2
	//var StartY = (ScreenHeight - innerHeight) / 2
	var Win = window.open(pageURL, '','Width=' + ScreenWidth +', height=' + ScreenHeight + ', resizable=no, scrollbars=no, status=no, toolbar=no, menubar=no, location=no, left=0, top=0')
	Win.moveTo(99999,99999)	
	return false
}



//==========================================================================================
//
// 代码描述：打开模式窗口函数，打开一个模式窗口不包含菜单、状态条、工具条、定位栏
//
// 传入参数：pageURL - 传递链接
//            innerWidth - 传递需要打开新窗口的宽度
//            innerHeight - 传递需要打开新窗口的高度
// 返回参数：无
//
// 修改记录：姓名                日期                 内容
//           wxf             2003/06/25              创建
//
//==========================================================================================
function g_OpenModalWindow(pageURL, innerWidth, innerHeight)
{
	window.showModalDialog(pageURL, null, 'dialogWidth:' + innerWidth + 'px;dialogHeight:' + innerHeight + 'px;help:no;unadorned:no;resizable:no;status:no')
}

//==========================================================================================
//
// 代码描述：打开模式窗口函数，打开一个模式窗口不包含菜单、状态条、工具条、定位栏 ,并且返回值
//
// 传入参数：pageURL - 传递链接
//            innerWidth - 传递需要打开新窗口的宽度
//            innerHeight - 传递需要打开新窗口的高度
// 返回参数：模式窗体返回的returnValue
//
// 修改记录：姓名                日期                 内容
//           wxf             2003/06/25              创建
//
//==========================================================================================
function g_OpenreturnWindow(pageURL, innerWidth, innerHeight)
{
	var returnv;
	returnv=window.showModalDialog(pageURL, null, 'dialogWidth:' + innerWidth + 'px;dialogHeight:' + innerHeight + 'px;help:no;unadorned:no;resizable:yes;status:no')
	return returnv;
}

//==========================================================================================
//
// 代码描述：打开模式窗口函数，打开一个模式窗口不包含菜单、状态条、工具条、定位栏
//
// 传入参数：pageURL - 传递链接
//            innerWidth - 传递需要打开新窗口的宽度
//            innerHeight - 传递需要打开新窗口的高度
// 返回参数：无
//
// 修改记录：姓名                日期                 内容
//           wxf             2003/06/25              创建
//
//==========================================================================================
function g_OpenReturnModalWindow(pageURL, innerWidth, innerHeight)
{
	window.showModalDialog(pageURL, null, 'dialogWidth:' + innerWidth + 'px;dialogHeight:' + innerHeight + 'px;help:no;unadorned:no;resizable:no;status:no');
	return false;
}










//==========================================================================================
//
// 代码描述：关闭窗口
//
// 传入参数：无
//
// 返回参数：无
//
// 修改记录：姓名                      日期                       内容
//           wxf                    2003/06/24                   创建
//
//==========================================================================================
function g_CloseWindow()
{
	window.close()
	return false
}

var row_marked = Array();
var row_over_color;
var row_marked_color;

function onRowClicked(row, rowNo, evt)
{
whichIt = document.all?evt.srcElement:evt.target;
	while (whichIt.tagName != "A") 
	{
		whichIt = document.all?whichIt.parentElement:whichIt.parentNode;
		if (whichIt == null)
		{
			// no link clicked, passed
			break;
		}
	}
	if (whichIt != null)
	{
	return;
	}

	if(row_marked[rowNo]==null||!row_marked[rowNo])
	{
	row_marked[rowNo]=true;
	row.style.backgroundColor = row_marked_color!=null?row_marked_color:'#FFCC99';
	}
	else
	{
	row_marked[rowNo]=false;
	row.style.backgroundColor = row_over_color!=null?row_over_color:'#FEF6E1';
	}
}
function onRowOver(row, rowNo)
{
	if(row_marked[rowNo]==null||!row_marked[rowNo])
	{
		// use row.bgColor save ori color since it has no effect if has style backgroundColor
		row.bgColor=row.style.backgroundColor;
		row.style.backgroundColor=row_over_color!=null?row_over_color:'#FEF6E1';
	}
}
function onRowOut(row, rowNo)
{
	if(row_marked[rowNo]==null||!row_marked[rowNo])
	{
		row.style.backgroundColor=row.bgColor;
		row.bgColor='';
	}
}

/*
* 列表页面 按钮相应事件
* Herdsman 060425
* @para 
* @para 
*/
function listBtnOnclick(varRid,varCmd,varInserter)
{
	Form1.InputCmdName.value=varCmd;
	Form1.InputRid.value = varRid;
	Form1.InputInserter.value = varInserter ;
	
	Form1.iBtnSummary.click() ;
}
/*
* 列表页面 按钮相应事件
* Herdsman 060425
* @para 
* @para 
*/
function window_hide(oPopup)
{
//	if( oPopup != null && !oPopup.isOpen )
//	{
//		oPopup.hide();
//		alert('hide') ;
//	}
}
/*
*  对话框 顾客选择
*  2006-4-30
*  H
*/
function PopCustomerSel(paras)
{
	//alert('Poped');//ShowFrameCustomer.aspx//PopCustomerSel.aspx
	//CustomerID:hiddenCustomerID,CustomerName:tbCustomerName,CustomerLocalCode:hiddenCustomerAreaID,CustomerLocal:tbCustomerArea,CustomerAddress:tbCustomerAddress,CustomerTel:tbCustomerTel
	var returnValue = window.showModalDialog('/Gen/Commom/ComPages/PopUpForm/ShowFrameCustomer.aspx?paras='+paras,null,'dialogHeight:400px; dialogWidth:600px;') ;
	//var returnValue = window.showModalDialog('/Gen/Commom/ComPages/PopUpForm/ShowFrameCustomer.aspx?paras=CustomerID:hiddenCustomerID,CustomerName:tbCustomerName,CustomerLocalCode:hiddenCustomerAreaID,CustomerLocal:tbCustomerArea,CustomerAddress:tbCustomerAddress,CustomerTel:tbCustomerTel',null,'dialogHeight:400px; dialogWidth:600px;') ;
	if( returnValue == '' )
		return ;
	var fs = returnValue.split('##') ;
	if( fs == null )
		return ;
	//aPopCustomerSel.href = '/Gen/Commom/ComPages/PopUpForm/PopCustomerSel.aspx?paras=CustomerID:hiddenCustomerID,CustomerName:tbCustomerName,CustomerLocalCode:hiddenCustomerAreaID,CustomerLocal:tbCustomerArea,CustomerAddress;tbCustomerAddress,CustomerTel:tbCustomerTel' ;
	//aPopCustomerSel.click() ;
	for(var i = 0 ; i < fs.length ; i ++)
	{
		var control = fs[i].split(':=')[0] ;
		if( control != '' && window.document.all(control) != null )
		{
			window.document.all(control).value = fs[i].split(':=')[1] ;
		}
	}
}


function flipImage(url)
{
    if (window.event.srcElement.tagName == "IMG" )
	{
        window.event.srcElement.src = url;
    }
}




// 选择所有的 CheckBox
// 060526 h
function ChooseAllCheckBox(vCheckBox,vControlPrefix)
{
	var vtemp = '';
	var checked = window.document.all(vCheckBox).checked ;
	for(var i = 0 ; i < window.document.all.length ; i ++)
	{
		var vControl = window.document.all(i);
		if( vControl.tagName == 'INPUT' && vControl.id.indexOf(vControlPrefix) == 0 )
		{
			vControl.checked = checked ;
			
		}
	}
}
function GetJSParams(jsFileName,paramName,defaultValue)
{
	//debugger
	var rtnValue = defaultValue;
	var jsFileName = jsFileName;
	var rName = new RegExp(jsFileName+"(\\?(.*))?$")
	var jss=document.getElementsByTagName('script');
	var find=false;
	if(jss.length>0)
	{
		for (var i = 0;i < jss.length; i++)
		{
		  if(find==false)
		  {
			  var j = jss[i];
			  if (j.src&&j.src.match(rName))
			  {
				var oo = j.src.match(rName)[2];
				if (oo&&(t = oo.match(/([^&=]+)=([^=&]+)/g)))
				{
					for (var l = 0; l < t.length; l++)
					{
						r = t[l];
						var tt = r.match(/([^&=]+)=([^=&]+)/);
						if (tt)
						{
							//document.write('参数：' + tt[1] + '，参数值：' + tt[2] + '<br />');
							if(paramName==tt[1])
							{
								rtnValue = tt[2];
								find=true;//查找标志位
								break;
							}
						}
					}
				}
			  }
		  }
		  else
		  {
			break;
		  }
		}
	}
	return rtnValue;
}
