﻿
function ReNotNum(Obj)
{
  Obj.value=Obj.value.replace(/[^\d]/g,'');
}
function ReNotMoney(Obj)
{
  Obj.value=Obj.value.replace(/[^\d\.]/g,'');
}
function ReNotPhone(Obj)
{
  Obj.value=Obj.value.replace(/[^\d-+]/g,'');
}
function ReNotNAL(Obj)
{
  Obj.value=Obj.value.replace(/[^a-zA-Z0-9]/g,'');
}
function ReNoHz(Obj)
{
  Obj.value=Obj.value.replace(/[^a-zA-Z0-9-_]/g,'');
}
function handleEnter(event)
{
  event=event?event:(window.event?window.event:null);
  if (event.keyCode == 13)
    return true;
  else
    return false;
}
function handleF5(event)
{
  event=event?event:(window.event?window.event:null);
  if (event.keyCode == 116)
    return true;
  else
    return false;
}
function handleEnterToTab(event)
{
  event=event?event:(window.event?window.event:null);
  if(event.keyCode==13){ 
    event.keyCode=9;    
    return false;
  }
}


//回调类，主参数
function CallBackParameter()
{
    this.Names=new Array();
    this.Values=new Array();
    this.LoadXml=CallBackLoadXml;
    this.AddItem=CallBackAddItem;
    this.ResultText=CallBackResultText;
}


String.prototype.ReplaceAll = stringReplaceAll; 
function  stringReplaceAll(AFindText,ARepText){ 
  raRegExp = new RegExp(AFindText,"g"); 
  return this.replace(raRegExp,ARepText) 
} 



//回调类辅助函数
function CallBackLoadXml(XmlStr)
{
    if (XmlStr.substring(0,6)!="<root>")
    {
        alert("LoadXml函数的参数必须以<root>开头！");
    }
    if (XmlStr.substring(XmlStr.length-7,XmlStr.length)!="</root>")
    {
        alert("LoadXml函数的参数必须以</root>结尾！");
    }
    XmlStr=XmlStr.substring(6,XmlStr.length-7);
    this.Names.length=0;
    this.Values.length=0;
    while (XmlStr!="")
    {
        var array=new RegExp('<(\\S*?)[^>]*>.*?</\\1>|<.*? />', '').exec(XmlStr);
        if (array==null) break;
        var aName=array[1];
        var aValue=array[0];
        aValue=aValue.replace("<"+aName+">","").replace("</"+aName+">","");
        aValue=aValue.ReplaceAll("&lt;","<");
        aValue=aValue.ReplaceAll("&gt;",">")
        aValue=aValue.ReplaceAll("&amp;","&")
        aValue=aValue.ReplaceAll("&apos;","'")
        aValue=aValue.ReplaceAll("&quot;","\"")
        this.AddItem(aName,aValue);
        XmlStr=XmlStr.substring(array[0].length,XmlStr.length);
    }
}
//回调类辅助函数
function CallBackAddItem(Name,Value)
{
    this.Names.length=this.Names.length+1;
    this.Names[this.Names.length-1]=Name;
    this.Values.length=this.Values.length+1;
    this.Values[this.Values.length-1]=Value;
    
}
//回调类辅助函数
function CallBackResultText()
{
    var tempstr="";
    for(var idx=0;idx<this.Names.length;idx++)
    {
        tempstr=tempstr+"<"+this.Names[idx]+">"+this.Values[idx]+"</"+this.Names[idx]+">";
    }
    tempstr="<root>"+tempstr+"</root>";
    return tempstr;
}
function IsGetGoods(Obj)
{
  if(confirm("确定已经收到货品？"))
  window.location.href="orderquery.jhtml?action=" + Obj.id;
}