﻿/*  Jsamer JavaScript framework, version 1.0.0
 *  (c) 2010 Sam Ren
/*--------------------------------------------------------------------------*/

var Jsamer = {
  Version: '1.0.0'
  
}


function $(){
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);
    if (arguments.length == 1) 
      return element;
    elements.push(element);
  }
  return elements;
}
function $P(obj,str,idp)
{
   var elements=new Array();
   var objs= obj.getElementsByTagName(str);
   for(var i=0;i<objs.length;i++)
   {
       if(objs[i].id.StartsWith(idp))
           elements.push(objs[i]);
   }
   return elements;
}
function $A()
{
    var args=new Array();
    for(var i=0;i<arguments.length;i++)
    {
        args.push(arguments[i]);
    }
    return args;
}
function $e(obj)
{
    return document.createElement(obj);
}
function $$(obj,str)
{
    return obj.getElementsByTagName(str);
}
function $v(objstr)
{
     return document.getElementById(objstr).value;
}
function $sv()
{
  var elements="";  
  for (var i=0;i<arguments.length;i++){
	  var element=arguments[i];
	  if(typeof element=='string'){
	     elements+=element+"="+document.getElementById(element).value+"&";
	  }
  }
  elements=elements.substring(1,elements.length);
  return elements;
}
var Class = {
  create: function() {
    return function() {
      this.initialize.apply(this, arguments);
    }
  }
}
Object.prototype.extend = function(source) {
  for (property in source) {
    this[property] = source[property];
  }
  return this;
}
var Try = {
  these: function() {
    var returnValue;
    for (var i = 0; i < arguments.length; i++) {
      var lambda = arguments[i];
      try {
        returnValue = lambda();
        break;
      } catch (e) {}
    }
    return returnValue;
  }
}

var position={
	delatX:function(obj,eX){
	       var left=obj.style.left;
		   return eX-parseInt(left.replace("px",""))/1;
	},
	delatY:function(obj,eY){
	       var top=obj.style.top;
		   return eY-parseInt(top.replace("px",""))/1;
	},
	OffsetLeft:function(el){
        return (el.offsetParent != null) ? el.offsetLeft + position.OffsetLeft(el.offsetParent) : el.offsetLeft;
	 },
	OffsetTop:function(el) {
	    return (el.offsetParent != null) ? el.offsetTop + position.OffsetTop(el.offsetParent) : el.offsetTop;
	}
}

var RegxPatterns=
{
    tag:'<.+?>',
    htmltag:'<html .+?>([\\w\\W]*?)</html>',
    titletag:'<title>([\\w\\W]*?)</title>',
    scripttag:'(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
    bodytag:'<boyd .+?>([\\w\\W]*?)</body>',
    tabletag:['<table .+?>','<table .+?>([\w\W]*)</table>','<table .+?>([\w\W]*?)</table>'],
    strformattag:'\{([0-9]{1})\}'
}

String.prototype.trim=function(){return this.replace(/(^\s*)|(\s*$)/g,"");}
String.prototype.escapeHtml=function(){this.replace(/\</ig,"&lt");return this.replace(/\>/ig,"&gt");}
String.prototype.unescapeHtml=function(){this.replace(/&lt/ig,"<");return this.replace(/&gt/ig,">");}
String.prototype.Left=function(elementsnum){if(!isNaN(elementsnum)){if(this.length>=elementsnum){return this.substring(0,elementsnum);}
                      else{return this;}}else{return this;}}
String.prototype.Right=function(elementsnum){if(!isNaN(elementsnum)){if(this.length>=elementsnum){return this.substring(this.length-elementsnum);}
	                   else{return this;}}else{return this;}}
String.prototype.scriptHtml=function(){return this.replace(/<[^>.]*>/ig,"");}
String.prototype.isEmpty=function(){if(this.length>0){return true;}else{return false;}}
String.prototype.isDateTime=function(){var date=new Date(this);if(date.getDate()=='NaN'){return false;}else{return true;}}
String.prototype.highlight=function(color){return "<font color=\""+color+"\">"+this+"</font>";}
String.prototype.strong=function(){return "<strong>"+this+"</strong>";}
String.prototype.Format=function(p){var str=this;var regx=new RegExp(RegxPatterns.strformattag,'img');var count=str.match(regx)==null?0:str.match(regx).length;
                        for(var i=0;i<count;i++){regx=new RegExp('\{['+i+']{1}\}','img');str=str.replace(regx,p[i]);}return str;}
String.prototype.StartsWith=function(v){var ph=v.length;if(this.substring(0,ph)==v){return true;}else{return false;}}
String.prototype.EndsWith=function(v){var ph=v.length;if(this.Right(ph)==v){return true;}else{return false;}}
String.prototype.Cutting=function(l,b)
{
var d = this.trim();
if(d.length<=l)return this;
d=this.Left(l);
d=b?d+'...':d;
return d;
}


var Arrays=
{
}

var dom=
{
    create:function(domNew,domFather,id)
    {
       var dom;
	   dom=$e(domNew);
	   dom.id=id;
	   domFather.appendChild(dom);
       return dom;
    },
    remove:function(domFather,domChild)
    {
        domFather.removeChild(domChild);
    },
    clone:function(source,target)
    {
        for(var p in source)
            target[p]=source[p];
    },
    left:function(el)
    {
        var le=parseInt(el.style.left.replace('px',''));
        return isNaN(le)?0:le;
    },
    top:function(el)
    {
        var le=parseInt(el.style.top.replace('px',''));
        return isNaN(le)?0:le;
    },
    width:function(el)
    {
        var le=parseInt(el.style.width.replace('px',''));
        return isNaN(le)?0:le;
    },
    height:function(el)
    {
        var le=parseInt(el.style.height.replace('px',''));
        return isNaN(le)?0:le;
    },
    readonly:function(id)
    {
        $(id).onkeypress=function(){return false;}
    }
}
dom.element=
{
    reposit:function(sou,tar)
    {
        var tarLeft=dom.left(tar);var tarTop=dom.top(tar);
        tar.style.left=sou.style.left;tar.style.top=sou.style.top;
        sou.style.left=tarLeft+'px';sou.style.top=tarTop+'px';
    },
    zoom:function(obj,w,h)
    {
        obj.style.width=w;obj.style.height=h;
    },
    opacity:function(obj,v)
    {
        obj.style.filter='alpha(opacity='+v+')';obj.style.opacity=v/100;
    },
    drag:function(hand,obj)
    {
        var _x,_y,_ex,_ey,_x1,_y1,_delatx,_delaty;
        var ismove=false;
        var _event=new Event();
        var applyfun=arguments.length>2?arguments[2]:null;
        _event.add('onmousedown',hand,down);
        function down(e)
        {
            var evt=e||window.event;            
            if(browser.isMSIE){hand.setCapture();}
	        _x=evt.clientX;_y=evt.clientY;
		    _x1=evt.clientX;_y1=evt.clientY;
		    _ex=dom.left(obj);_ey=dom.top(obj);
		    ismove=true;
		    if(!browser.isMSIE){_event.add('onmousemove',document,move);_event.add('onmouseup',document,up);}
                    else{_event.add('onmousemove',hand,move);_event.add('onmouseup',hand,up);}
		    if(!browser.isMSIE)evt.preventDefault();
        }
        function move(e)
        {
            var evt=e||window.event;
            if(!ismove)return;
            _x=evt.clientX;_y=evt.clientY;
		    obj.style.top=_ey+_y-_y1+'px';obj.style.left=_ex+_x-_x1+'px';
            if(applyfun!=null)applyfun.apply(obj);
        }
        function up(e)
        {
            if(browser.isMSIE) hand.releaseCapture();
            ismove=false;
            if(browser.isMSIE)
              _event.remove('onmousedown',hand,down);
            else
	          _event.remove('onmousemove',document,move); _event.remove('onmouseup',document,up);
        }
    },
    blot:function(id)
    {
        var o=arguments.length>1?arguments[1]:0;
        var z=arguments.length>2?arguments[2]:1;
        var b=arguments.length>3?arguments[3]:'#ffffff';
        dom.create('div',document.body,id);
        $(id).style.cssText='background:'
                           +b
                           +';z-index:'
                           +z
                           +';position:absolute;left:0px;top:0px;filter:alpha(opacity='
                           +o
                           +');opacity:'
                           +(o/100)
                           +';width:100%;height:'+document.documentElement.clientHeight+'px;display:block'; 
        var iframe=new dom.element.html();
        iframe.inneriframe($(id),{scroll:'no',width:'100%',height:document.documentElement.clientHeight+'px',opacity:o});
    },
    clearblot:function(id)
    {
        dom.remove(document.body,$(id));
    }   
}
dom.element.html=Class.create();
dom.element.html.prototype={
  initialize:function(){},
  inneriframe:function(obj,options)
  {
      obj.innerHTML='<iframe src="javascript:false;" frameborder="0" scrolling="'
                  +options.scroll
                  +'" width="'
                  +options.width
                  +'" height="'
                  +options.height
                  +'" style="filter:alpha(opacity='
                  +options.opacity
                  +');opacity:'
                  +(options.opacity/100)
                  +';"></iframe>';
  }
}


function Event()
{
}
Event.prototype.add=function (evt,el,handler)
{   
   if(el.addEventListener){
   el.addEventListener(evt.substring(2), handler, false);}
   else if(el.attachEvent){el.attachEvent(evt, function(){return handler.call(el, window.event);});}
   else{el[evt] = handler;}
}
Event.prototype.remove=function(evt,el,handler)
{
    if(window.addEventListener){
　　el.removeEventListener(evt, handler, false);}
　　else{el.detachEvent(evt, handler);}
}

var browser=
{
    isMSIE:navigator.userAgent.indexOf("MSIE")>0?true:false,
    isFirefox:navigator.userAgent.indexOf("Firefox")>0?true:false,
    isSafari:navigator.userAgent.indexOf("Safari")>0?true:false,
    isCamino:navigator.userAgent.indexOf("Camino")>0?true:false,
    isMozilla:navigator.userAgent.indexOf("Gecko")>0?true:false
}


var Ajax = new Object();
 Ajax.Request = function(options,readychange,onerror) {
     this.request = null;
     this.url=options.url;
     this.method=options.method;
     this.params=options.params;
     this.transport=options.transport;
     this.onreadyStateComplete = readychange.oncomplete;
     this.onreadyStateLoad=readychange.onload;
     this.onerror = (onerror) ? onerror : this.onError;     
     this.sendRequest();
 };
 Ajax.Request.prototype.SetPostHeader=function()
 {
     if(this.method.toUpperCase()=='POST')
     {
         
         this.request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
     }
 };
 Ajax.Request.prototype.getTransport=function()
 {
     return Try.these(
       function() {return new ActiveXObject('Msxml2.XMLHTTP')},
       function() {return new ActiveXObject('Microsoft.XMLHTTP')},
       function() {return new XMLHttpRequest()}
      ) || false;
 };
 Ajax.Request.prototype.sendRequest = function() {
    if (!this.method)this.method = "GET";
    this.request=this.getTransport();
    
    if (this.request) {
        try {
            var _requestEvent = this;            
            this.request.onreadystatechange = function() {
                Ajax.Request.onReadyState.call(_requestEvent);
            };
            this.request.open(this.method, this.method = "GET"?this.url+'?'+this.params:this.url, this.transport);
            this.SetPostHeader();
            this.request.send(this.params==''?null:this.params);
            
        } catch (err) {
           this.onerror.call(this);
        }
    }
};

Ajax.Request.onReadyState = function() {
    var req = this.request;
    var ready = req.readyState;
    if (ready == 4) {
        if (req.status == 200) {
            this.onreadyStateComplete.call(this);
        }else{
            this.onerror.call(this);
        }
    }else
    {
        this.onreadyStateLoad.call(this);
    }
};

Ajax.Request.prototype.onError = function() {
    alert("Error fetching data!"
            + "\n\nreadyState:" + this.request.readyState
            + "\nstatus: " + this.request.status
            + "\nheaders: " + this.request.getAllResponseHeaders());
};



dom.element.form=Class.create();
dom.element.form.prototype=
{
    initialize:function(winname)
    {
        this.Window=document.createElement('div');
        this.Cover=document.createElement('div');
        this.Window.id=winname;
        
        this.zIndex=5;
        this.left='';
        this.top='';
        this.scanlLeft='';
        this.scanlTop='';
        this.width='500px';
        this.height='400px';
        this.scanlWidth=this.width;
        this.scanlHeight=this.height;
        this.background='#ffffff';
        this.border='1px solid #006699';
        this.position='absolute';
        this.titlecolor='#000000';
        this.titlebackground='#E1F4FE';
        this.WindowStyle='';
        this.TitleStyle='';
        this.MinBox=true;
        this.MaxBox=true;
        this.ContentSrc='';
        this.Max=false;
        this.Min=false;
        this.titleValue='';
        this.contentValue='';
        this.WindowMove=true;
        this.WindowMode=0;
        this.CoverOpacity=0.3;
        this.CoverBackground='#ffffff';
        this.binder=document.body;
        this.fixFormCenter=true;
    },
    UserDefined:function(fun,args){fun.apply(this,args);},
    Show:function(title,content)
    {        
        if(this.WindowMode==0)this.createTitle(title);        
        this.createContent(content);        
        this.createWindow();
        if(this.ContentSrc!='')$('content_'+this.Window.id).src=this.ContentSrc;
    },
    createWindow:function()
    {        
        this.left=this.scanlLeft=this.left==''?parseInt((document.documentElement.clientWidth-parseInt(this.width.replace('px','')))/2)+'px':this.left;
        this.top=this.scanlTop=this.top==''?parseInt((document.documentElement.clientHeight-parseInt(this.height.replace('px','')))/2)+'px':this.top;        
        if(this.WindowStyle=='')
        this.WindowStyle='position:'+this.position+';'
                        +'z-index:'+this.zIndex+';'
                        +'left:'+this.left+';'
                        +'top:'+this.top+';'
                        +'width:'+this.width+';'
                        +'height:'+this.height+';'
                        +'background:'+this.background+';'
                        +'border:'+this.border+';'
                        +'display:block;'
                        +'overflow:hidden;'
                        ;
        this.Window.style.cssText=this.WindowStyle;
        this.binder.appendChild(this.Window);
        var WindowHandler=this;
        window.onscroll=function()
        {
            if(WindowHandler.fixFormCenter)
            {
            WindowHandler.Window.style.top=(parseInt(WindowHandler.scanlTop.replace('px',''))
                                          +document.documentElement.scrollTop)+'px';        
            WindowHandler.Window.style.left=(parseInt(WindowHandler.scanlLeft.replace('px',''))
                                           +document.documentElement.scrollLeft)+'px';   
            }     
        }
    },
    createTitle:function(title)
    {
        this.titleValue=title==''?this.titleValue:title;
        
        this.TitleStyle='overflow:hidden;'
                       
                       
                       +';height:35px;display:block;line-height:35px;margin-left:1px;margin-top:1px;'
                       +'color:'
                       +this.titlecolor
                       +';background:'
                       +this.titlebackground+';';
        var Title=document.createElement('div');Title.style.cssText=this.TitleStyle;
        
        var Titleleft=document.createElement('div');
        Titleleft.style.cssText='width:69%;float:left;font-weight:bold;font-size:12px;text-indent:10px;';
        Titleleft.innerHTML=this.titleValue==''?'From Jsamer':this.titleValue;            
        var Titleright=document.createElement('div');
        Titleright.style.cssText='width:29%;float:left;font-size:12px;text-align:right;';   
         
        var TitlerightMin=document.createElement('span');
        TitlerightMin.style.cssText='cursor:pointer;'; TitlerightMin.innerHTML='_ ';
        var TitlerightMax=document.createElement('span');
        TitlerightMax.style.cssText='cursor:pointer;'; TitlerightMax.innerHTML='□ ';
        var TitlerightCls=document.createElement('span');
        TitlerightCls.style.cssText='cursor:pointer;'; TitlerightCls.innerHTML='× ';
        var TitlerightEvent=this;
        
        TitlerightMin.onclick=function(){TitlerightEvent.MinWindow();}
        TitlerightMax.onclick=function(){TitlerightEvent.MaxWindow();}
        TitlerightCls.onclick=function(){TitlerightEvent.close();}
        
        if(this.MinBox)Titleright.appendChild(TitlerightMin);
        if(this.MaxBox)Titleright.appendChild(TitlerightMax);    
        Titleright.appendChild(TitlerightCls);Title.appendChild(Titleleft);Title.appendChild(Titleright);this.Window.appendChild(Title);
        if(this.WindowMove)dom.element.drag(Title,this.Window);
    },
    createContent:function(content)
    {
        this.scanlWidth=this.width;
        this.scanlHeight=this.height;
        this.contentValue=content==''?this.contentValue:content;
        
        var Content=document.createElement('div');
        var ConMistake=this.WindowMode==0?30:0;
        Content.style.cssText='width:99%;height:'
                             +(parseInt(this.scanlHeight.replace('px',''))-ConMistake)
                             +'px;margin-left:1px;margin-top:1px;font-size:12px;overflow-y:auto;overflow-x:hidden;';
        var ContextText='<iframe id="content_'+this.Window.id+'" frameborder="0" src="'
                       +this.ContentSrc+'" scrolling="auto" width="100%" height="'
                       +(parseInt(this.scanlHeight.replace('px',''))-ConMistake)+'" ></iframe>';
        Content.innerHTML=this.ContentSrc==''?this.contentValue:ContextText;
        this.Window.appendChild(Content);        
    },
    close:function()
    {
        this.binder.removeChild(this.Window);
        this.Window=null;
    },
    MinWindow:function()
    {
        var Widthmsie=(document.documentElement.clientWidth-parseInt(this.width.replace('px',''))-20)+'px';
        var Heightmsie=(document.documentElement.clientHeight-35)+'px';
        this.Window.style.width=this.Min?this.width:'150px';this.Window.style.height=this.Min?this.height:'30px';
        this.scanlHeight=this.Min?this.height:'30px';
        this.Window.style.left=this.Min?this.left:Widthmsie;this.Window.style.top=this.Min?this.top:Heightmsie;
        this.scanlLeft=this.Min?this.left:Widthmsie;this.scanlTop=this.Min?this.top:Heightmsie;
        this.Window.innerHTML='';
        this.createTitle('');this.createContent('');
        this.Min=this.Min?false:true;
    },
    MaxWindow:function()
    {    
        var Heightmsie=document.documentElement.clientHeight-20+'px';
        var Widthmsie=document.documentElement.clientWidth-20+'px';
        this.Window.style.width=this.Max?this.width:Widthmsie;this.Window.style.height=this.Max?this.height:Heightmsie;
        this.Window.style.left=this.Max?this.left:'0px';this.Window.style.top=this.Max?this.top:'0px';
        this.scanlWidth=this.Max?this.width:Widthmsie;this.scanlHeight=this.Max?this.height:Heightmsie;
        this.scanlLeft=this.Max?this.left:'0px';this.scanlTop=this.Max?this.top:'0px';
        this.Window.innerHTML='';
        this.createTitle('');this.createContent('');
        this.Max=this.Max?false:true;
    }
}


function Timer()
{
    this.Interval=1000;
    this.Tick=null;
    this.Args=[];
    this.State=false;
}
Timer.prototype.Start=function()
{
    this.Tick=arguments.length>0?arguments[0]:this.Tick;
    this.Args=arguments.length>1?arguments[1]:this.Args;
    if(this.Tick==null)return false;
    this.Tick.apply(this,this.Args);
    var evt=this;
    if(!this.State)
       setTimeout(function(){evt.Start(evt.Tick,evt.Args)},evt.Interval);
}
Timer.prototype.Stop=function()
{
    this.State=true;
}


var progressBar=Class.create(); 
progressBar.prototype=
{    
    initialize:function(name)
    {
        this.Bar=null;
        this.FatherNode=document.body;
        
        this.Name=name;
        this.Maximum = 10;
        this.Minimum = 1;
        this.Step = 1;
        this.Value = 1;
        this.Width=0;
    },
    Create:function(style)
    {
        this.Bar=dom.create('div',this.FatherNode,this.Name);
        this.Bar.style.cssText=style;
        this.Step=dom.width(this.Bar)/this.Maximum;
        this.Bar.style.width=this.Width+'px';
    },
    PerformStep:function()
    {
        this.Width+=this.Step;
        this.Bar.style.width=this.Width+'px';
    }
}
var popMenu=Class.create();
popMenu.prototype=
{
    initialize:function(id)
    {
        this.id=id;
        this.popobj=null;
        this.items_name=[];
        this.items_style=[];
        this.items_over_style=[];
        this.items_bind=[];
        this.style='';
        this.item_height=22;
    },
    plugin:function(fun,args)
    {
        fun.apply(this,args);
    },
    create:function()
    {
        if(this.popobj==null)
        {
            this.popobj=dom.create('div',document.body,this.id); 
            if(this.style.indexOf(':')!=-1){
                this.popobj.style.cssText=this.style;
            }else{
                this.popobj.className=this.style;
            }            
        }
        this.popobj.style.display='none'; 
        this.popobj.style.height=(this.items_name.length*this.item_height)+'px';
        this.binditem();
        
    },
    close:function()
    {
        var popcall=this;
        this.popobj.onmouseout=function(e)
        {
            var evt=e||window.event;
            document.onmouseup=function(e)
            {
                var evt=e||window.event;
                popcall.popobj.style.display='none';                
            }
        }
    },
    pop:function(e)
    {
        var evt=e||window.event;
        this.popobj.style.zIndex='9999';
        this.popobj.style.position='absolute';
        this.popobj.style.top=(evt.clientY-5)+'px'; 
        this.popobj.style.left=(evt.clientX-5)+'px';
        this.popobj.style.display='none'; 
        this.popobj.style.display='block';
        return false;
    },
    binditem:function()
    {
        var evt=new Event();
        if(this.popobj!=null)
        {
            for(var i=0;i<this.items_name.length;i++)
            {
                var li=dom.create('li',this.popobj,this.id+'_item_'+i);
                if(this.items_style[i].indexOf(':')!=-1){
                   li.style.cssText=this.items_style[i];
                }else{
                   li.className=this.items_style[i];
                }
                li.innerHTML=this.items_name[i];
                evt.add('onmouseover',li,itemover); 
                evt.add('onmouseout',li,itemout); 
                evt.add('onmouseup',li,this.items_bind[i]); 
            }
        }
        var itemcall=this;
        function itemover(e)
        {
             var evt=e||window.event;
             var obj=evt.target||evt.srcElement;
             var index=0;
             index=parseInt(obj.id.split('_')[2]);
             if(itemcall.items_over_style[index].indexOf(':')!=-1)obj.style.cssText=itemcall.items_over_style[index];else obj.className=itemcall.items_over_style[index];
		}
        function itemout(e)
        {
            var evt=e||window.event;
            var obj=evt.target||evt.srcElement;
            var index=0;
             index=parseInt(obj.id.split('_')[2]);
            if(itemcall.items_style[index].indexOf(':')!=-1)obj.style.cssText=itemcall.items_style[index];else obj.className=itemcall.items_style[index];
        }
    }
}

var Suggest=Class.create();
Suggest.prototype=
{
    initialize:function(_id,_box,_event)
    {
        this.suggest=null;
        this.id=_id;
        this.bindevent=_event;
        this.binder=document.body;
        this.box=_box;
        this.left=0;
        this.top=0;
        this.Style='';
        this.ListStyle='';
        this.ListOverStyle='';
        this.ListOutStyle='';
        this.requestdata=[];
        this.dataobjarray=new Array();
        this.dataindex=-1;
        this.isList=true;
    },
    bind:function(fun)
    {
        var evt=new Event();
        evt.add(this.bindevent,this.box,showcontainer);
        var sugevt=this;
        function showcontainer()
        {
            sugevt.requestdata=fun.apply(sugevt);
            if(sugevt.suggest==null){
                sugevt.suggest=dom.create('div',sugevt.binder,sugevt.id);
                sugevt.dataindex=-1;
            }else
            {
                sugevt.suggest.style.display='block';
                sugevt.suggest.innerHTML='';
            }            
            if(sugevt.Style.indexOf(':')!=-1){
                sugevt.suggest.style.cssText=sugevt.Style;
            }else{
                sugevt.suggest.className=sugevt.Style;
            }
            sugevt.dataobjarray.length=0;sugevt.dataindex=-1;
            sugevt.suggest.style.left=sugevt.left==0?position.OffsetLeft(sugevt.box)+'px':sugevt.suggest.style.left;            
            sugevt.suggest.style.top=sugevt.top==0?position.OffsetTop(sugevt.box)+20+'px':sugevt.suggest.style.top;
            sugevt.isList=true;
            evt.add('onkeydown',document,listkeydown);
            evt.add('onmouseup',document,documentup);
            showlist();
        }
        function showlist()
        {
             var ul=dom.create('ul',sugevt.suggest,'sugul'+i);
                 ul.style.padding='0px';ul.style.margin='0px';
             for(var i=0;i<sugevt.requestdata.length;i++)
             {
                 var _data=dom.create('li',ul,'sugli'+i);
                 if(sugevt.ListStyle.indexOf(':')!=-1){
                    _data.style.cssText=sugevt.ListStyle;
                 }else{
                    _data.className=sugevt.ListStyle;
                 }
                 _data.innerHTML=sugevt.requestdata[i];_data.title=sugevt.requestdata[i];
                 sugevt.dataobjarray.push(_data);
                 evt.add('onmouseover',_data,listover);
                 evt.add('onmouseout',_data,listout);
                 evt.add('onclick',_data,listclick);
             }
        }
        function documentup()
        {
             if(sugevt.suggest!=null)sugevt.suggest.style.display='none';
             sugevt.isList=false;
        }
        function listover(e)
        {
            var evt=e||window.event;
            var obj=evt.target||evt.srcElement;
            sugevt.onover(obj,sugevt);
        }
        function listout(e)
        {
            var evt=e||window.event;
            var obj=evt.target||evt.srcElement;
            sugevt.onout(obj,sugevt);
        }
        function listclick(e)
        {
            var evt=e||window.event;
            var obj=evt.target||evt.srcElement;
            sugevt.onclick(obj,sugevt);
        }
        function listkeydown(e)
        {
            if(!sugevt.isList)return true;
            if(sugevt.dataobjarray.length<=0)return true;
            var evt=e||window.event;
            var obj=evt.target||evt.srcElement;
            if(evt.keyCode==38)
            {
                sugevt.dataindex--;
                sugevt.dataindex=sugevt.dataindex<0?sugevt.dataobjarray.length-1:sugevt.dataindex;
            }
            else if(evt.keyCode==40)
            {
                sugevt.dataindex++;
                sugevt.dataindex=sugevt.dataindex>sugevt.dataobjarray.length-1?0:sugevt.dataindex;    
            }else
            {
                return true;
            }
            for(var i=0;i<sugevt.dataobjarray.length;i++)
                sugevt.onout(sugevt.dataobjarray[i],sugevt);
            sugevt.onover(sugevt.dataobjarray[sugevt.dataindex],sugevt);
            sugevt.box.value=sugevt.dataobjarray[sugevt.dataindex].innerHTML;
            try{CollectGarbage();}catch(e){}
        }
    },
    onover:function(obj,sugevt)
    {
        if(this.ListOverStyle.indexOf(':')!=-1){
           obj.style.cssText=this.ListOverStyle;
        }else{
           obj.className=this.ListOverStyle;
        }
    },
    onout:function(obj,sugevt)
    {
        if(this.ListOutStyle.indexOf(':')!=-1){
           obj.style.cssText=this.ListOutStyle;
        }else{
           obj.className=this.ListOutStyle;
        }
    },
    onclick:function(obj,sugevt)
    {
        sugevt.box.value=obj.innerHTML;
        dom.remove(sugevt.binder,sugevt.suggest);
        document.onkeydown = "";
        document.onmoueup = "";
        sugevt.isList=false;
        sugevt.suggest=null;
        try{CollectGarbage();}catch(e){}
    }    
}
