/*
Javascript Implementation for ESOE v0.2.1, M1:kernel.
Version 0.3
by forxm@21cn.com, http://www.viviasoft.com
2006-7
License: esoe-license.txt
*/
if(window.$esoe)throw "error: $esoe reloaded or keyword conflict!";window.$esoe=new Object;$esoe._modulemax=5;$esoe.HasModule=function(m){if(m==1)return true;return(this._module.indexOf(","+m+",")>=0)?true:false;};$esoe.LoadModule=function(m){document.write("<script src='"+this._path+"esoe"+m+".js'></script>");};$esoe.LoadParamM1=function(){this._param=document.getElementById("_ESOE_ENGINE_");if(!this._param){var scripts=document.getElementsByTagName("SCRIPT");this._param=scripts[scripts.length-1];scripts=null;};with(this._param){var i,s;s=getAttribute("src")+"";i=s.lastIndexOf("/");if(i>=0)this._path=s.substring(0,i+1);else this._path="./";s=getAttribute("module");if(s){this._module=","+s+",";}else this._module="";this._nokey=getAttribute("nokey");if(this._nokey){if(this._nokey!="*")this._nokey=","+this._nokey+",";}else this._nokey="";s=getAttribute("debug");this._debug=(s>=1)?(s-0):0;s=null;}};$esoe.LoadParamM1();$esoe._nextid=1;$esoe.PrepareM1=function(_global){this._id=this._nextid;$esoe._nextid++;this.ns=new Object;this._lib=new Object;this._global=_global;};$esoe.PrepareM1(window);$esoe._track=new Array;$esoe.Track=function(obj){var ti=this._track[this._id];if(!ti){ti=new Array;ti[0]=this;this._track[this._id]=ti;};if(this.PrepareM4&&obj&&obj!==ti[ti.length-1]){ti[ti.length]=obj;};ti=null;obj=null;};$esoe._trace=new Array;$esoe.TRACE=function(s){if(!this._debug)return;this._trace[this._trace.length]="["+this._id+"] "+s;};$esoe.ALERT=function(s){if(!this._debug)return;this.TRACE("ALERT: "+s);alert("["+this._id+"] "+s);if(this._debug>8)this._stop_();};$esoe.ClearTrace=function(){if(!this._debug)return;var i;for(i in this._trace){delete this._trace[i];};this._trace.length=0;};$esoe.OnNsConflict=function(ns,objOld,objNew){this.ALERT("name space conflict: "+ns);return false;};$esoe.GetNs=function(ns,root){try{return eval("root."+ns);}catch(e){return null;}};$esoe._ns=function(ns,root,obj){var _this=this.$esoe?this.$esoe:this;if((typeof root)=='undefined')root=_this.ns;var nsi=_this.GetNs(ns,root);if(nsi){if(obj&&obj!==nsi){if(!_this.OnNsConflict(ns+", when call _ns()",nsi,obj)){return nsi;}else{return eval("root."+ns+"=obj");}}else{return nsi;}};if((typeof obj)=='undefined')obj=new Object;var i=ns.lastIndexOf(".");if(i>=0)_this._ns(ns.substring(0,i),root);return eval("root."+ns+"=obj");};$esoe._package=$esoe._ns;$esoe.SplitNs=function(ns,root){var i=ns.lastIndexOf(".");if(i>=0){var nsi=ns.substring(i+1,ns.length);return [ this._ns(ns.substring(0,i),root),nsi ];}else{return [ root,ns ];}};$esoe._normalize=function(ns,func,bNonEsoe,bObject,bConflict){var _this=this.$esoe?this.$esoe:this;if(arguments.length==1)func=eval("_this.ns."+ns);if(!func)return null;var aRet=_this.SplitNs(ns,_this.ns);var pkg=aRet[0];var nsi=aRet[1];if(eval("pkg."+nsi)){nsi=eval("pkg."+nsi);if(func!==nsi){if(!_this.OnNsConflict(ns+", when call _normalize()",nsi,func)){return nsi;}else{return eval("_this.ns."+ns+"=func");}};if(bObject){if(_this.IsNormalized(nsi))return nsi;}else{if(! nsi.prototype){_this.ALERT("normalize non-function object: "+ns);return null;};if(_this.IsNormalized(nsi))return nsi;}}else{nsi=eval("pkg."+nsi+"=func");};if(!bObject){if(! nsi.prototype){_this.ALERT("_normalize non-function object: "+ns);return null;};nsi.prototype._esoe=new Object;nsi.prototype._esoe._type=1;with(nsi.prototype){_esoe._pkg=pkg;if(bNonEsoe)_esoe._nonesoe=1;else{nsi.prototype.constructor=nsi;};if(bConflict)_esoe._conflict=1;else{nsi.prototype._pkg=pkg;}}}else{nsi._esoe=new Object;nsi._esoe._type=2;nsi._esoe._pkg=pkg;if(bNonEsoe)nsi._esoe._nonesoe=1;if(bConflict)nsi._esoe._conflict=1;else{nsi._pkg=pkg;}};return nsi;};$esoe.IsNormalized=function(obj){if(!obj)return false;if(obj.prototype){if(obj.prototype._esoe&&obj.prototype._esoe._type==1)return true;}else{if(obj._esoe&&obj._esoe._type==2)return true;};return false;};$esoe.Clone=function(obj,objsrc,bReplace){var i;for(i in objsrc){if((typeof obj[i])=="undefined"||bReplace)obj[i]=objsrc[i];}};$esoe.RemoveProperties=function(obj){var i;for(i in obj){if(!obj[i])continue;obj[i]=null;}};$esoe._derive=function(ns,func,nsBase){var _this=this.$esoe?this.$esoe:this;if(arguments.length==2){nsBase=func;func=eval("_this.ns."+ns);};var nso={};if(!_this._import(nsBase,"base",nso))return null;if(! func.prototype){_this.ALERT("derive non-function object: "+ns);return null;}else if(_this.IsNormalized(func)){if(_this.GetNs(ns+".$run",_this._lib))return func;_this.ALERT("derive normalized function: "+ns);return null;};var prototype0=null;var i;for(i in func.prototype){prototype0=func.prototype;break;};func.prototype=new nso.base;func.prototype._esoe=null;if(prototype0){_this.Clone(func.prototype,prototype0,1);_this.RemoveProperties(prototype0);prototype0=null;};if(!_this._normalize(ns,func)){throw "error when deriving "+ns+" from "+nsBase;};with(func.prototype){_esoe._base=nso.base.prototype;if(! _esoe._conflict)func.prototype._base=_esoe._base;};return func;};$esoe._derivex=function(ns,nsBase1){var _this=this.$esoe?this.$esoe:this;var nsi=eval("_this.ns."+ns);var base;var i;var imax=arguments.length;for(i=1;i<imax;i++){base=eval("_this.ns."+arguments[i]+".prototype");_this.Clone(nsi.prototype,base);}};$esoe.LoadConstructor=function(ns){return this.GetNs(ns);};$esoe.OnImport=function(ns,map,root,bSuccess){this._ns(ns,this._lib).$run--;return bSuccess;};$esoe.MapTo=function(func,ns,map,root){if(map===null)return true;var aRet=this.SplitNs(map,root);var pkg=aRet[0];var nsi=aRet[1];if(eval("pkg."+nsi)){var nsii=eval("pkg."+nsi);if(nsii!==func){if(!this.OnNsConflict(ns+"=>"+map+"("+nsi+")",nsii,func)){return false;}}else{return true;}};eval("pkg."+nsi+"=func");return true;};$esoe.PrepareImport=function(ns,map,root){if((typeof root)=="undefined"){if(map!==null){root=this._global;if(!map)map=ns.substring(ns.lastIndexOf(".")+1,ns.length);}}else{if(!map)map=ns.substring(ns.lastIndexOf(".")+1,ns.length);};return [ map,root ];};$esoe._import=function(ns,map,root){var _this=this.$esoe?this.$esoe:this;var nsi=_this._ns(ns,_this._lib);if(nsi.$run)nsi.$run++;else nsi.$run=1;var aRet=_this.PrepareImport(ns,map,root);map=aRet[0];root=aRet[1];nsi=_this.GetNs(ns,_this.ns);if(!nsi){nsi=_this.LoadConstructor(ns);if(!nsi){return _this.OnImport(ns,map,root,false);}};if(nsi.prototype){if(!_this.IsNormalized(nsi)){if(!nsi()){return _this.OnImport(ns,map,root,false);}}}else{if(!_this.IsNormalized(nsi)){return false;}};return _this.OnImport(ns,map,root,_this.MapTo(nsi,ns,map,root));};$esoe.GetGlobal=function(id){return this._global;};$esoe.EventFunc=function(_global,nsVar,sFunc,sParam,sParam2){return "function("+(sParam?sParam:"")+"){return $esoe.GetGlobal("+_global.$esoe._id+")."+nsVar+"."+sFunc+"("+(sParam?sParam:"")+(sParam2?((sParam?",":"")+sParam2):"")+");}";};$esoe._update=$esoe.Share=$esoe._setpath=$esoe._getpath=$esoe.Destroy=function(){};$esoe.CallBaseShare=function(){return true;};$esoe.KeyConflict=function(keyname){if(! this._nokey)return false;return(this._nokey.indexOf(","+keyname+",")>=0)?true:false;};$esoe.LoadKeywords=function(keylist){if(this._nokey=="*")return;var i;for(i=0;i<keylist.length;i++){if(!this.KeyConflict(keylist[i]))eval("this._global."+keylist[i]+"= this."+keylist[i]);}};$esoe.RemoveKeywords=function(keylist){if(this._nokey=="*")return;if(!this._global)return;var i;for(i=0;i<keylist.length;i++){if(!this.KeyConflict(keylist[i]))eval("if(this._global)this._global."+keylist[i]+"= null");}};$esoe._keylistM1=new Array("_ns","_package","_normalize","_import","_derive","_derivex","_setpath","_getpath","_loadcss","_update");$esoe.LoadKeywords($esoe._keylistM1);if($esoe.HasModule(2)||$esoe.HasModule(3))$esoe.LoadModule(2);if($esoe.HasModule(3))$esoe.LoadModule(3);if($esoe.HasModule(4))$esoe.LoadModule(4);if($esoe.HasModule(5))$esoe.LoadModule(5);