﻿ /*Version:1.0.0*/
 /*Author:FJ*/
 var syslogID=0;
 function Offset(left,top,height,width)
{
this.Left=left;
this.Top=top;
this.Height=height;
this.Width=width;
}
function Hashtable()
{
    this._hash        = new Object();
    this.add        = function(key,value){
                        if(typeof(key)!="undefined"){
                                this._hash[key]=typeof(value)=="undefined"?null:value;
                                return true;
                        } else {
                            return false;
                        }
                    }
    this.remove        = function(key){delete this._hash[key];}
    this.count        = function(){var i=0;for(var k in this._hash){i++;} return i;}
    this.items        = function(key){return this._hash[key];}
    this.contains    = function(key){ return typeof(this._hash[key])!="undefined";}
    this.clear        = function(){for(var k in this._hash){delete this._hash[k];}}
    this.toJson = function()
    { 
    
    }
}
function Hash(key,value)
{
   this.key = key;
   this.value = value;
}
var SortMode = {

    Asc:"asc",
    Desc:"desc",
    Normal:"normal"

}
/*Base*/ 
 var Browser = {

    IE:     !!(window.attachEvent && !window.opera),
    Opera:  !!window.opera,
    WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
    Gecko:  navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1,
    MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
  }
  var BrowserUtility = {
    GetOffset:function(o){
    var result=new Offset();
    var nLt=0;
    var nTp=0;
     var offsetParent = o;
     while (offsetParent!=null) {
     // && offsetParent!=document.body
     nLt+=offsetParent.offsetLeft;
     nTp+=offsetParent.offsetTop;
     if(Browser.IE){
     parseInt(offsetParent.currentStyle.borderLeftWidth)>0?nLt+=parseInt(offsetParent.currentStyle.borderLeftWidth):"";
     parseInt(offsetParent.currentStyle.borderTopWidth)>0?nTp+=parseInt(offsetParent.currentStyle.borderTopWidth):"";
     }
     offsetParent=offsetParent.offsetParent;
     }
    result.Left=nLt;
    result.Top=nTp;
    result.Width=o.offsetWidth;
    result.Height=o.offsetHeight;
    return result;
    },
    FrameId:'Page_LoadingFrame',
    SetLoading:function()
    {
         if(!$(BrowserUtility.FrameId)){
         document.body.appendChild(BrowserUtility.FrameObj);
         showLoadingTip();
         }
    },
    ClearLoading:function()
    {
    if($(BrowserUtility.FrameId)){
         document.body.removeChild($(BrowserUtility.FrameId));
         clearLoadingTip();
    }
    },
    InitFrame:function()
    {
         var _iframeTmp = document.createElement("iframe");
         _iframeTmp.id = BrowserUtility.FrameId;
         _iframeTmp.style.position = "absolute";  
         _iframeTmp.style.filter = "alpha(opacity=0)";
         _iframeTmp.style.border="0px";
         _iframeTmp.style.zIndex = 999;
         _iframeTmp.style.width=document.documentElement.scrollWidth+"px";
        _iframeTmp.style.height=document.documentElement.scrollHeight+document.documentElement.scrollTop+"px";
        if(document.documentElement.scrollHeight+document.documentElement.scrollTop<window.screen.availHeight)
        _iframeTmp.style.height=window.screen.availHeight+"px"; 
	    _iframeTmp.style.top="0px";
	    _iframeTmp.style.left="0px";
	    BrowserUtility.FrameObj=_iframeTmp;
    },
    FrameObj:null
}
BrowserUtility.InitFrame();
var Cookie = {
    GetCookieVal:function(offset)//获得Cookie解码后的值
   {
//    var endstr = document.cookie.indexOf (";", offset);
//    alert(document.cookie);
//    if (endstr == -1)
//    endstr = document.cookie.length;
//    var ret=unescape(document.cookie.substring(offset, endstr));
//    if(ret.split('=').length>1)
//    return ret.split('=')[1];
//    else
//    return "";
//
var ret=document.cookie.split(';');
for(var i=0;i<ret.length;i++)
{
var item=ret[i].split('=');
if(item.length>1)
{if(item[0].Trim()==offset)return unescape(item[1]);}
}  
return "";  
}
    ,
    SetCookie:function(name, value,b)//设定Cookie值
    {
    var Days = 30;
    var exp = new Date(); 
    if(b)
    {
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();

    }
    else
    document.cookie = name + "="+ escape (value);
    }
    ,
    DelCookie:function (name)//删除Cookie
    {
    var exp = new Date();
    exp.setTime (exp.getTime() - 1);
    var cval = GetCookie (name);
    document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
    }
    ,
    GetCookie:function(Name)//获得Cookie的原始值
    {
//    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
//    if(document.cookie.match(reg)) 
//    {
//    arr=document.cookie.match(reg);
//    return unescape(arr[2]);
//    }else 
//    return null;
var search = Name + "="; 
var returnvalue = ""; 
if (document.cookie.length > 0) 
{ 
offset = document.cookie.indexOf(search); 
if (offset != -1) 
{ 
offset += search.length; 
if(document.cookie.indexOf("&",offset )!= -1)
{
    end = document.cookie.indexOf("&", offset); 
}
else
{
    end = document.cookie.indexOf(";", offset); 
}
if (end == -1) 
end = document.cookie.length; 
returnvalue=unescape(document.cookie.substring(offset,end)); 
} 
} 
return returnvalue; 
    }
}
var ElementBuilder = {
Create: function(tag)
{
return document.createElement(tag);
},

Append:function(father,child)
{
father.appendChild(child);
},
Insert:function(father,current,before)
{
father.insertBefore(current, before);
},
Remove:function(father,child)
{
father.removeChild(child);
}

}
 function $(id)
{
if(document.getElementById(id)&&typeof(document.getElementById(id))!="undefined")
return document.getElementById(id);
else
return null;
}
function getEvent(){ 
if(document.all) return window.event; 
func=getEvent.caller; 
while(func!=null){ 
var arg0=func.arguments[0]; 
if(arg0){ 
if((arg0.constructor==Event&&arg0.constructor ==MouseEvent)||(typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){ 
return arg0; 
} 
} 
func=func.caller; 
} 
return null; 
}
/*向select加载option*/
var AddOption2=function(id,value,text)
{
    var slt=$(id);
    var objOption=ElementBuilder.Create("OPTION");
   objOption.value=value;
   objOption.text=text;
 
   if(objOption!=null)
   {
         if(Browser.IE)
     slt.add(objOption);
     else
     slt.insertBefore(objOption, slt.options[slt.length]);
   }
}

var AddOption=function(id,value,text,select)
{
var slt=$(id);
var door =false;
for(var i=0;i<slt.options.length;i++){
if(slt.options[i].value.Trim() == value.Trim())
{
   door = true;
   if(select)
   slt.options[i].selected="selected";
   break;
   }
}
if(!door)
{var objOption=ElementBuilder.Create("OPTION");
   objOption.value=value;
   objOption.text=text;
   if(select)
   objOption.selected="selected";
   if(objOption!=null)
   {
     if(Browser.IE)
     slt.add(objOption);
     else
     slt.insertBefore(objOption, slt.options[slt.length]);
   }
  }
}
var RemoveOption=function(id,index) 
{ $(id).remove(index); } 

var Select = {
 DataBind:function (id,data,selected)
{
  if(selected&&!data.contain(selected))
  {
  AddOption(id,selected,selected,false);
  }
  for(var i=0;i<data.length;i++)
  {
      if(selected==data[i])
      AddOption(id,data[i],data[i],true)
      else
      AddOption(id,data[i],data[i],false)
      
  }
},
 DataBind2:function (id,data,selected)
{
  for(var i=0;i<data.length;i++)
  {
      if(selected==data[i].value)
      AddOption(id,data[i].value,data[i].text,true)
      else
      AddOption(id,data[i].value,data[i].text,false)
      
  }
}
}
String.prototype.Trim = function()
{
  return this.replace(/(^\s*)|(\s*$)/g, "");
}

Date.prototype.ToString = function(mode)
{
  if(this.getYear()==0)
  return "";
  var result = "";
  if(mode!="S"){
  result += this.getYear()<10?"0"+this.getYear():this.getYear();
  result +="-";
  result+=parseInt(this.getMonth()+1)<10?"0"+parseInt(this.getMonth()+1):parseInt(this.getMonth()+1);
  result +="-";
  result +=this.getDate()<10?"0"+this.getDate():this.getDate();
  if(mode!="C")
  result += " "+this.toLocaleTimeString();}
  else
  {
  result += this.getYear()<10?"0"+this.getYear():this.getYear();
  result+=parseInt(this.getMonth()+1)<10?"0"+parseInt(this.getMonth()+1):parseInt(this.getMonth()+1);
  result +=this.getDate()<10?"0"+this.getDate():this.getDate();
  }
  return result;
}


Array.prototype.ToString = function()
{
  
  
  var result = "";
  for(var i=0;i<this.length;i++)
  {
  
  result += this[i];
  if(i!=this.length-1)
  result+=',';
  }
  return result;
}
Number.prototype.IsNum = function()
{
 if((this<=57&&this>=48)||(this<=105&&this>=96)||this==190||this==9||this==8||this==13||this==110||this==46||this==38||this==40||this==37||this==39)
 return true;
 else 
 return false;
}
Number.prototype.IsInt = function()
{
 if((this<=57&&this>=48)||(this<=105&&this>=96)||this==9||this==8||this==13||this==46||this==38||this==40||this==37||this==39||this==189)
 return true;
 else 
 return false;
}
Number.prototype.IsFInt = function()
{
 if((this<=57&&this>=48)||(this<=105&&this>=96)||this==9||this==8||this==13||this==46||this==38||this==40||this==189||this==109||this==37||this==39)
 return true;
 else 
 return false;
}
Number.prototype.IsIntFZero = function()
{
if((this<=57&&this>=48)||(this<=105&&this>=96)||this==190||this==9||this==8||this==13||this==110||this==46||this==38||this==40||this==189||this==109||this==37||this==39)
 return true;
 else 
 return false;
}
var checkIsType=function(id,type)
{
    var obj=$(id);
    switch(type)
    {
    case "User":
    if(obj.value.IsUser())
    {obj.IsError=false;return true;}
    else
    {obj.ErrorMsg='格式错误！\r\n名称为1-12位英文字母或数字或下划线或汉字！';break;}
    case "Password":
    if(obj.value.IsPassword())
    {obj.IsError=false;return true;}
    else
    {obj.ErrorMsg='格式错误！\r\n密码为0-20位英文字母或数字或下划线！';break;}
    case "Num":
    if(obj.value.IsNum())
    {obj.IsError=false;return true;}
    else
    {obj.ErrorMsg='格式错误！\r\n格式为整数或小数！';break;}
    case "FZero":
    if(parseInt(obj.value)>0||parseInt(obj.value)<0)
    {obj.IsError=false;return true;}
    else
    {obj.ErrorMsg='格式错误！\r\n格式为非零整数或小数！';break;}
    default:
    return true;
    }
    obj.IsError=true;alert(obj.ErrorMsg);return false;
}
String.prototype.IsNum = function()
{
  var reg = /^\-{0,1}\d+(\.{0,1}\d+){0,1}$/;
  return reg.test(this); 
}

String.prototype.IsPassword = function()
{
  var reg = /^(\w){0,20}$/;
  return reg.test(this);
}
String.prototype.IsUser = function()
{
  if(String.GetLength(this)>12)
  return false;
  else
  {var reg = /^[a-zA-Z0-9_\u4e00-\u9fa5]+$/;
  return reg.test(this);}
}

String.GetLength = function(str) {
   var totallength=0;   
   for (var i=0;i<str.length;i++)
   {
    var intCode=str.charCodeAt(i);    
    if (intCode>=0&&intCode<=128) {
     totallength=totallength+1; 
    }
    else {
     totallength=totallength+2; 
    }
   }   
   return totallength;
 }
   
String.FormatByArgs = function() {
 
 if(arguments.length == 0)
  return "";
 
 if(arguments.length == 1)
  return arguments[0];
 
 var reg = /{(\d+)?}/g;
 var args = arguments;
 var result = arguments[0].replace(
  reg,
  function($0, $1) {
   return  args[parseInt($1)+1];
  }
 )

 return result;
}

String.prototype.Format = function(type)
{
  var result = "";
  switch(type.toLowerCase( ))
  {
    case "date":
    if(this.length <= 0)
    return "1900-01-01";
    else if(this.substring(4,5) == "-")
    return this;
    else
    {
        result= this.substring(0,4)+"-"+this.substring(4,6)+"-"+this.substring(6,8);
        return result;
    }
    
  
  }

}
String.prototype.replaceAll  = function(rstr,rs)
{    
//return this.replace(new RegExp(s1,"gm"),s2);
var tempStr = this;
str='';
  while(tempStr.indexOf(rstr)!=-1) 
  {
   
   k=tempStr.indexOf(rstr);
   tempStr=tempStr.replace(rstr,rs);
   str+=tempStr.substr(0,k+rs.length);
   tempStr=tempStr.substr(k+rs.length);
   
  }
  str+=tempStr;
 return str;    
} 
/*否决的*/
var Validate = function(formObj)
{
  var result = true ;
  if(formObj){
  var elementsObj=formObj.elements;
  var obj;
   if(elementsObj){
    for(var i=0; i<elementsObj.length;i+=1){
     obj=elementsObj[i];
     if(obj.name!=undefined&&obj.name!=""){
     {
     if(obj.IsError!=undefined&&obj.IsError)
     {alert(obj.ErrorMsg);obj.focus(); result = false;break;}
     }
     }
    }
  }
  else
  result = false;
  }
  else
  result = false;
  return result;   
}

var FormHelper = {
EnterArray:[],
UpdownArray:[],
Pre:"",
Submit:null,
InitForm:function(form,enterArray,updownArray,pre,submit)
{
    FormHelper.Form = form;
    FormHelper.EnterArray=enterArray;
    FormHelper.UpdownArray=updownArray;
    FormHelper.Pre = pre;
    FormHelper.Submit = submit;
    if(enterArray.length==0)
    enterArray = updownArray;
    for(var i=0;i<enterArray.length;i++)
    {
        var _item = $(pre+enterArray[i].key);
        if(_item)
        {   
            _item.setAttribute("maxlength",enterArray[i].value,0);
            
            if(_item.tagName=='INPUT' && _item.type!="radio" && _item.name=="")
            {_item.name = _item.id;}
            if(_item.checkType=='num'){
            _item.onkeydown=function(){if(!FormHelper.NumDown('num')){return false;}};
            _item.value='0';_item.style.textAlign='right';_item.style.imeMode='disabled'; 
            }
            else if(_item.checkType=='int'){
            _item.onkeydown=function(){if(!FormHelper.NumDown('int')){return false;}};
            _item.value='0';_item.style.textAlign='right';_item.style.imeMode='disabled';
            }
            else if(_item.checkType=='fint')
            {
             _item.onkeydown=function(){if(!FormHelper.NumDown('fint')){return false;}};
            _item.value='0';_item.style.textAlign='right';_item.style.imeMode='disabled';
            }
            else if(_item.checkType=='fzero')
            {
             _item.onkeydown=function(){if(!FormHelper.NumDown('fzero')){return false;}};
            _item.value='0';_item.style.textAlign='right';_item.style.imeMode='disabled';
            }
            else
            _item.onkeydown=FormHelper.KeyDown;
            
            if(_item.onfocus==null&&(_item.tagName=='INPUT'||_item.tagName=='TEXTAREA'))_item.onfocus=FormHelper.Focus;
            
            
         }
    }

},
NumDown:function(type)
{
    var code; var shift;
    var e = getEvent();
    var obj=e.srcElement ? e.srcElement : e.target;
    var b=false;
    if(!Browser.IE)
    {code=getEvent().which; shift=getEvent().shiftKey;}
    else
    {code= event.keyCode;shift=event.shiftKey;}
        switch(type)
    {
       case 'int':
       b =code.IsInt();
       break;
       case 'fint':
       b =code.IsFInt();
       break;
       case 'num':
       b =code.IsNum();
      if(code==110||code==190)
     { var temp="";
       for(var i=0;i<obj.value.length;i++)
       {temp=obj.value.charAt(i);
        if(temp==".")return false;}
       if(obj.value.length==0)
         return false;
     }
       break;
       case 'fzero':
       b=code.IsIntFZero();
      if(code==110||code==190)
     { var temp="";
       for(var i=0;i<obj.value.length;i++)
       {temp=obj.value.charAt(i);
        if(temp==".")return false;}
       if(obj.value.length==0)
         return false;
     }
       break;
    }
    if(b&&!shift)
      { if(code==13||code==38||code==40)
      {FormHelper.KeyDown();}
       return true;}
      else
      {return false;}
},

KeyDown:function()
{
    var e = getEvent();
    var input =e.srcElement ? e.srcElement : e.target;
    var code;
    if(!Browser.IE)
    {
      code=e.which;
    }
    else
    code= event.keyCode;
                 switch (code)
                 {  
                    case 13:
                    if($('select_option')&&$('select_option').style.display!='none')
                    {if(_selectActiveOption){
                    $('select_option').style.display='none';
                    if(selectInput.id=="NewGh"){input.value=_selectActiveOption.gh;
                    chNo=_selectActiveOption.ch;}
                    else if(selectInput.id=="NewGno"){input.value=_selectActiveOption.innerHTML.Trim();selectInput.focus();getRelationSelect(selectInput,"GNO");}
                    else if(selectInput.id=="NewGname"){input.value=_selectActiveOption.innerHTML.Trim();selectInput.focus();getRelationSelect(selectInput,"GNAME");}
                    else if(selectInput.id=="txtXLCODE"){selectInput.value=_selectActiveOption.innerHTML.substring(0,_selectActiveOption.innerHTML.indexOf("--"));}
                    else input.value=_selectActiveOption.innerHTML.Trim();
                    _selectActiveOption = null;removeFrame();}}
                    else if(FormHelper.EnterArray.length>0){
                    if(input.id==FormHelper.Pre+FormHelper.EnterArray[FormHelper.EnterArray.length-1].key)
                        {
                        if(input.onchange)input.onchange.call();
                        if(FormHelper.Submit.onclick)FormHelper.Submit.onclick.call();
                        else return false;
 }
                        else
                        for(var i=0;i<FormHelper.EnterArray.length-1;i++)
                            if(input.id==FormHelper.Pre+FormHelper.EnterArray[i].key)
                            {   
                                $(FormHelper.Pre+FormHelper.EnterArray[i].key).blur();
                                $(FormHelper.Pre+FormHelper.EnterArray[i+1].key).focus();
                                break;
                            }
                            }
                        else  {FormHelper.Submit.onclick.call();}
                        event.keyCode=0;event.returnValue=false;
                        break;
                    case 38:
                            if($('select_option')&&$('select_option').style.display!='none')
                            {moveSelectOption("up");break;}
                            else
                        {for(var i=FormHelper.UpdownArray.length-1;i>0;i--)
                        if(input.id==FormHelper.Pre+FormHelper.UpdownArray[i].key)
                        {   
                            $(FormHelper.Pre+FormHelper.UpdownArray[i].key).blur();
                            $(FormHelper.Pre+FormHelper.UpdownArray[i-1].key).focus();
                            if($(FormHelper.Pre+FormHelper.UpdownArray[i-1].key).tagName=='INPUT')
                            return false;
                            else
                            break;
                        }
                         }
                    case 40:
                           if($('select_option')&&$('select_option').style.display!='none')
                            {moveSelectOption();break;}
                            else{
                        for(var i=0;i<FormHelper.UpdownArray.length-1;i++)
                            if(input.id==FormHelper.Pre+FormHelper.UpdownArray[i].key)
                            {   
                                $(FormHelper.Pre+FormHelper.UpdownArray[i].key).blur();
                                $(FormHelper.Pre+FormHelper.UpdownArray[i+1].key).focus();
                                if($(FormHelper.Pre+FormHelper.UpdownArray[i+1].key).tagName=='INPUT')
                            return false;
                            else
                            break;
                            }
                    }
                    default:
                    break;
             }

},
Focus:function()
{
    var e = getEvent();
    var element =e.srcElement ? e.srcElement : e.target;
    element.select();
},
Validate:function()
{
  var result = true ;
  if(FormHelper.Form){
  var elementsObj=FormHelper.Form.elements;
  var obj;
   if(elementsObj){
    for(var i=0; i<elementsObj.length;i+=1){
     obj=elementsObj[i];
     if(obj.name!=undefined&&obj.name!=""){
     {
     if(String.GetLength(obj.value) > obj.getAttribute("maxlength"))
     {alert("超出长度!");obj.focus(); result = false;
       break;}
     if(obj.IsError!=undefined&&obj.IsError)
     {
       alert(obj.ErrorMsg);obj.focus(); result = false;
       break;}
     }
     }
    }
  }
  else
  result = false;
  }
  else
  result = false;
  return result;  
}
}
function formToObject(formObj){

   var all={};
if(formObj){
   var elementsObj=formObj.elements;
   var obj;
   if(elementsObj){
    for(var i=0; i<elementsObj.length;i+=1){
     obj=elementsObj[i];
     if(obj.name!=undefined&&obj.name!=""){
     {
     all[obj.name]=encodeURIComponent(obj.value);
     }
     }
    }
   }else{
    alert("没有elements对象!");
    return ;
   }
}else{
   alert("form不存在!");
   return ;
}
return all;
}


function Timer(spam)
{
  this.Spam = 0;
  this.Elapsed = null;
  this.AutoReset = true;
  this.Enabled = true;
  if(typeof(spam)=="number")
  this.Spam = spam;
  var timer = null;
  this.Run = function()
  {
    timer = setInterval(this.Elapsed,this.Spam);
  }
  this.Close = function()
  {
     clearInterval(timer);
  }
}
if (!Array.prototype.push) {

	Array.prototype.push = function array_push() {

		for(var i=0;i<arguments.length;i++)

			this[this.length]=arguments[i];

		return this.length;

	}

};
if (!Array.prototype.pop) {

	Array.prototype.pop = function array_pop() {

		lastElement = this[this.length-1];

		this.length = Math.max(this.length-1,0);

		return lastElement;

	}
};
Array.prototype.remove = function(item)
{
    for(var i=0;i<this.length;i++)
    {
        if(item==this[i])
        {this.splice(i,1);break;}
    }
};
Array.prototype.removeAtLast = function()
{
   if(this.length>0)
   this.splice(this.length-1,1);
};
Array.prototype.add = function(item)
{
    for(var i=0;i<this.length;i++)
    {
        if(item==this[i])
        return;
    }
    this.push(item);
};
Array.prototype.contain = function(item)
{
    for(var i=0;i<this.length;i++)
    {
        if(item==this[i])
        return true;
    }
    return false;
};
Array.prototype.containAttribute = function(item,atr)
{
    for(var i=0;i<this.length;i++)
    {
        if(item==this[i].getAttribute(atr))
        return true;
    }
    return false;
};
Array.prototype.baoremove = function(dx)
{
    if(isNaN(dx)||dx>this.length){return false;}
    this.splice(dx,1);
}

var KeyControl = {
    KeyAccessArray:[],
    KeyCode:null,
    DoAccessAction:function()
    {
        var _code=KeyControl.GetCode();
        var _activeObj=document.activeElement;
        if(_activeObj.tagName=='INPUT'&&_activeObj.getAttribute('readonly')&&_code==8)
        {event.keyCode=0;event.returnValue=false;return;}
        for(var i=0;i<KeyControl.KeyAccessArray.length;i++)
        if(String.fromCharCode(_code)==KeyControl.KeyAccessArray[i].key&&KeyControl.IsDubKey("alt"))
        {if(!AutoPanel.varConfig.isOpen&&!$(BrowserUtility.FrameId)){if(KeyControl.KeyAccessArray[i].value.onclick!=null)KeyControl.KeyAccessArray[i].value.onclick.call();event.keyCode=0;event.returnValue=false;break;}}
    },
    GetCode:function()
    {
        var code;
        if(!Browser.IE)
          code=e.which;
        else
        code= event.keyCode;
        return code;
    },
    
    IsDubKey:function(key)
    {
        var res=false;
        if(!Browser.IE)
        eval("res=getEvent()."+key+"Key;");
        else
        eval("res=event."+key+"Key;");
        return res;
    },
    AccessKeyInit:function(keyArray)
    {    
        for(var i=0;i<keyArray.length;i++)
        {
           keyArray[i].value.innerHTML+=" (<u>"+keyArray[i].key.toUpperCase()+"</u>)";
           KeyControl.KeyAccessArray.push(new Hash(keyArray[i].key.toUpperCase(),keyArray[i].value))
        }
        if(!Browser.IE)
        document.addEventListener("keydown",KeyControl.DoAccessAction,false);
        else
        document.attachEvent("onkeydown",KeyControl.DoAccessAction);
        try
       {document.body.focus();}
       catch(e){}
    }
}
String.prototype.UnDefault=function()
{
switch(this.toLowerCase())
{
case '#000000':
return false;
case '#000':
return false;
case 'black':
return false;
default:return true;
}
} 
String.prototype.isMobile = function() {  
  return (/^(?:13\d|15[89])-?\d{5}(\d{3}|\*{3})$/.test(this.Trim()));  
} 
String.prototype.isTel = function()
{
    return (/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/.test(this.Trim()));
}
var GetParentCS=function(name)
{
if(window.parent&& window.parent.GetCS)
   try{
   return window.parent.GetCS(name);
   }
   catch(e)
   {
   return false;
   }
 else if(window.parent.parent&& window.parent.parent.GetCS)
 try{
   return window.parent.parent.GetCS(name);
   }
   catch(e)
   {
   return false;
   }
   else
 return false;
}
var showLoadingTip=function()
{
          var tip = document.createElement("div");
         tip.id = "loading_tip";
         tip.style.position = "absolute";  
         tip.style.backgroundColor="#eee";
         tip.style.border="1px";
         tip.style.borderStyle="ridge";
         tip.style.fontSize="12px";
         tip.style.zIndex = 1000;
         tip.style.left=document.documentElement.offsetWidth-130+"px";
         tip.style.top="0px";
	     tip.style.width="110px";
	     tip.style.height="20px";
	     tip.style.color="#666";
	     tip.innerHTML="正在加载,请稍候..."
	    if($(BrowserUtility.FrameId))
        document.body.appendChild(tip);
}
var clearLoadingTip=function()
{
        if($("loading_tip"))
        document.body.removeChild($("loading_tip"));
}
function StringBuilder( value )
{
    this._Strings = new Array( value || '' ) ;
}
StringBuilder.prototype.Append = function( value )
{
    if ( value )
        this._Strings.push( value ) ;
}
StringBuilder.prototype.ToString = function()
{
    return this._Strings.join( '' ) ;
}
if(window.navigator.userAgent.indexOf('MSIE 8') != -1)
{}
//var Version={
//TY:"车型",
//Color:"颜色",
//FA:"产地",
//FLM:"分类码",
//ProductName:"零件",
//QP:"汽配",
//QPQX:"汽配汽修"
//}
var replaceAllFun = function(initStr,rstr,rs)
{ 
 str='';
  while(initStr.indexOf(rstr)!=-1) 
  {
   
   k=initStr.indexOf(rstr);
   initStr=initStr.replace(rstr,rs);
   str+=initStr.substr(0,k+rs.length);
   initStr=initStr.substr(k+rs.length);
   
  }
  str+=initStr;
 return str;
}

//var V9_Domain="http://192.168.0.107/v9web";
var V9_Domain="http://v9.longsky.com";