// Livesite (c) Livesite Networks, LLC 2006-2010.  SHA1 Algorithms (c) Paul Johnston 2000-2002.  ContentLoaded by Diego Perini based on code by Dean Edwards and John Resig.

var ECMAScript={Name:"Livesite ECMAScript",Version:.014,Copyright:"Livesite (c) Livesite Networks, LLC 2006-2010.  SHA1 Algorithms (c) Paul Johnston 2000-2002.  ContentLoaded by Diego Perini based on code by Dean Edwards and John Resig.",About:function(){var names={};for(var i=0;i<ECMAScript.Packages.length;i++){var def=ECMAScript.Packages[i];var ns=def.namespace;var idx=ns.indexOf('.');var name=idx>0?ns.substr(0,idx):ns;names[name]=true;}
var pkgs=[];for(var ns in names){pkgs.push(ns);}
return[this.Name,this.Version,pkgs.sort().join(',')].join(';');},Packages:[],Instances:[],Extend:function(ns,func){ns=ns.toLowerCase();for(var n in ECMAScript.Class.prototype){if(ns==n)throw'illegal name-space name: '+ns;}
var def={'namespace':ns,'constructor':func};ECMAScript.Packages.push(def);for(var i=0;i<ECMAScript.Instances.length;i++){ECMAScript.Instances[i].extend(ns,func);}},Class:function(win,doc){this.window=win;this.document=doc;this.id='ecma'+Math.floor(Math.random()*100000);for(var i=0;i<ECMAScript.Packages.length;i++){var def=ECMAScript.Packages[i];this.extend(def.namespace,def.constructor);}
ECMAScript.Instances.push(this);}};ECMAScript.Class.prototype={window:null,document:null,extend:function(ns,func){var nses=ns.split('.');var name=nses.pop();var inst=this;for(var i=0,seg;seg=nses[i];i++){if(!inst[seg])inst[seg]={};inst=inst[seg];}
if(inst[name]){func.apply(inst[name],[this]);}else{inst[name]=new func(this);}}};ECMAScript.Extend('lang',function(ecma){this.createAbstractFunction=function(){return function(){throw'Abstract function not implemented';};};this.createMethods=function(func){if(arguments.length>1){var proto=null;var bases=null;for(var i=0;i<arguments.length;i++){func=arguments[i];if(typeof(func)!='function')
throw'Argument '+i+' is not a constructor';var Class=function(){};Class.prototype=func.prototype;var stub=new Class();if(!bases)bases=stub.__bases__?stub.__bases__:[];delete stub.__bases__;bases.push(stub);if(proto){ecma.util.overlay(proto,stub);}else{proto=new Class();}}
proto.__bases__=bases;return proto;}else{function Class(){};if(func&&typeof(func)!='function')
throw'single argument is not a constructor';if(func)Class.prototype=func.prototype;return new Class();}};this.createObject=function(klass,args){var ctor=function(){};ctor.prototype=ecma.lang.createMethods(klass);var obj=new ctor();klass.apply(obj,args||[]);return obj;};this.createCallback=function(){var cbarr=ecma.lang.createCallbackArray.apply(null,arguments);var func=cbarr[0];var scope=cbarr[1];var args=cbarr[2];return function(){var argx=ecma.util.args(arguments);return func.apply(scope||this,argx.concat(args));}};this.createCallbackArray=function(func,scope,args){if(!args)args=[];if(!func)throw'Missing callback function (or array)';if(typeof(func)!='function'&&func.length){if(func[2])args=args.concat(func[2]);scope=func[1];func=func[0];}
return[func,scope,args];}
this.callback=function(func,scope,args){var cbarr=ecma.lang.createCallbackArray(func,scope,args);return cbarr[0].apply(cbarr[1],cbarr[2]);};this.assert=function(expression,msg){if(expression)return;if(!msg)msg='Assertion failed';if(ecma.window&&ecma.window.console&&ecma.window.console.trace)ecma.window.console.trace(msg);throw new ecma.error.Assertion(msg);};});ECMAScript.Extend('lang',function(ecma){this.Constructor=function(){return ecma.lang.createConstructor.apply(this,arguments);};this.Methods=function(){return ecma.lang.createMethods.apply(this,arguments);};this.Callback=function(){return ecma.lang.createCallback.apply(this,arguments);};this.createConstructor=function(){return function(){if(this.construct)this.construct.apply(this,arguments);};};});ECMAScript.Extend('util',function(ecma){this.defined=function(unk){return unk===null?false:typeof(unk)=='undefined'?false:true;};this.isa=function(unk,klass){if(!klass)return false;if(unk instanceof klass)return true;if(unk&&unk.__bases__){for(var i=0;i<unk.__bases__.length;i++){if(ecma.util.isa(unk.__bases__[i],klass))return true;}}
return false;};this.isObject=function(unk){return unk&&unk.constructor&&typeof(unk)=='object';};this.isArray=function(unk){if(!ecma.util.isObject(unk))return false;return typeof(unk.constructor.prototype.push)=='function';};this.isAssociative=function(unk){if(!ecma.util.isObject(unk))return false;if(unk.__bases__){for(var i=0,base;base=unk.__bases__[i];i++){if(!ecma.util.isArray(base))return true;}}else{return!ecma.util.isArray(unk);}
return false;};this.args=function(args){if(!args)return[];var len=args.length||0;var result=new Array(len);while(len--)result[len]=args[len];return result;};this.use=function(){var args=this.args(arguments);var scope=args.shift();for(var i=0;i<args.length;i++){var ns=args[i];for(var name in ns){if(ecma.util.defined(scope[name])){throw"'"+name+"' is already defined in this scope: "+scope;}
scope[name]=ns[name];}}};this.evar=function(unk,scope){if(!unk||typeof(unk)!='string')throw'Provide a String';if(!unk.match(/[A-Za-z_\$][A-Za-z_\$\.0-9]+/))throw'Illegal object address';var result=undefined;try{if(scope){var func=function(){return eval(unk);}
result=func.apply(scope,[]);}else{result=eval(unk);}}catch(ex){return null;}
return result;};this.asInt=function(unk,gez){var i=unk;if(typeof(unk)=='string'){i=parseInt(unk.replace("\w",""));}else{i=parseInt(unk);}
return isNaN(i)?0:gez&&i<0?0:i;};this.randomId=function(prefix,multiplier){if(!multiplier)multiplier=100000;var w=new String(multiplier).length;var n=ecma.util.pad(Math.floor(Math.random()*multiplier),w);return prefix?prefix+n:n;};var _incrementalIdMap=new Object();this.incrementalId=function(prefix,width){var idx=_incrementalIdMap[prefix];idx=_incrementalIdMap[prefix]=idx==null?1:idx+1;return width?prefix+ecma.util.pad(idx,width):prefix+idx;};this.pad=function(src,width,chr,rtl){if(!chr)chr='0';if(!rtl)rtl=false;if(width>100)throw new ecma.error.IllegalArg('width');if(width<1)throw new ecma.error.IllegalArg('width');if(chr.length!=1)throw new ecma.error.IllegalArg('chr');var len=new String(src).length;if(len>width)return src;var result=rtl?''+src:'';for(var i=len;i<width;i++){result+=chr;}
return rtl?result:result+src;};this.grep=function(target,a){if(!a||!ecma.util.defined(a.length))return null;var result=[];var func=target instanceof Function?target:function(a){return a==target;};for(var i=0;i<a.length;i++){if(func(a[i]))result.push(a[i]);}
return result.length>0?result:null;};this.overlay=function(){var args=ecma.util.args(arguments);var dest=args.shift();if(typeof(dest)!='object')throw'invalid argument';for(var i=0;i<args.length;i++){var src=args[i];if(!ecma.util.defined(src))continue;if(typeof(dest)!=typeof(src))throw'type mismatch';if(dest===src)continue;for(var k in src){if(typeof(dest[k])=='function'){dest[k]=src[k];}else if(typeof(dest[k])=='object'){this.overlay(dest[k],src[k]);}else{dest[k]=src[k];}}}
return dest;};this.clone=function(arg1){var args=ecma.util.args(arguments);if(typeof(arg1)!='object')throw'invalid argument';var obj=ecma.util.isAssociative(arg1)?{}:[];args.unshift(obj);return ecma.util.overlay.apply(this,args);};this.keys=function(obj){if(!(obj instanceof Object))return null;var result=[];for(var k in obj){result.push(k);}
return result;};this.values=function(obj){if(!(obj instanceof Object))return null;var result=[];for(var k in obj){result.push(obj[k]);}
return result;};this.step=function(arr,func,scope,args){if(!ecma.util.isArray(arr))throw new ecma.error.IllegalArg('arr');if(typeof(func)!='function')throw new ecma.error.IllegalArg('func');if(!args)args=[];if(typeof(args.shift)!='function')args=ecma.util.args(args);if(!ecma.util.isArray(args))throw new ecma.error.IllegalArg('args');var errors=[];for(var i=0;i<arr.length;i++){try{args.unshift(arr[i]);func.apply(scope,args);}catch(ex){errors.push([ex,i]);}finally{args.shift();continue;}}
if(errors.length){var exceptions=[];for(var i=0;i<errors.length;i++){var err=errors[i];var ex=err[0];exceptions.push(ex);}
throw exceptions.length>1?new js.error.Multiple(exceptions):exceptions[0];}};this.associateArrays=function(values,names){var result=new Object();if(!(values&&names))return result;for(var i=0;i<names.length&&i<values.length;i++){result[names[i]]=values[i];}
return result;};});ECMAScript.Extend('units',function(ecma){this.ONE_KiB=Math.pow(2,10);this.ONE_MiB=Math.pow(2,20);this.ONE_GiB=Math.pow(2,30);this.ONE_TiB=Math.pow(2,40);this.ONE_PiB=Math.pow(2,50);this.ONE_EiB=Math.pow(2,60);this.ONE_ZiB=Math.pow(2,70);this.ONE_YiB=Math.pow(2,80);var _units=[[this.ONE_KiB,'K'],[this.ONE_MiB,'M'],[this.ONE_GiB,'G'],[this.ONE_TiB,'T'],[this.ONE_PiB,'P'],[this.ONE_EiB,'E'],[this.ONE_ZiB,'Z'],[this.ONE_YiB,'Y']];this.bytesize=function(bytes,digits,min){bytes=ecma.util.asInt(bytes);var denominator=1;var sym='B';var unit;for(var i=0;unit=_units[i];i++){if((!min||unit[0]>=min)&&bytes<unit[0])break;denominator=unit[0];sym=unit[1];}
var num=bytes/denominator;return(num.toFixed(digits)+sym);}});ECMAScript.Extend('date',function(ecma){var token=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,timezone=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,timezoneClip=/[^-+\dA-Z]/g,pad=function(val,len){val=String(val);len=len||2;while(val.length<len)val="0"+val;return val;};var dateFormat=new Object();dateFormat.masks={"default":"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"};dateFormat.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"]};this.format=function(date,mask,utc){var dF=dateFormat;if(arguments.length==1&&Object.prototype.toString.call(date)=="[object String]"&&!/\d/.test(date)){mask=date;date=undefined;}
date=date?new Date(date):new Date;if(isNaN(date))
throw SyntaxError("invalid date");mask=String(dF.masks[mask]||mask||dF.masks["default"]);if(mask.slice(0,4)=="UTC:"){mask=mask.slice(4);utc=true;}
var _=utc?"getUTC":"get",d=date[_+"Date"](),D=date[_+"Day"](),m=date[_+"Month"](),y=date[_+"FullYear"](),H=date[_+"Hours"](),M=date[_+"Minutes"](),s=date[_+"Seconds"](),L=date[_+"Milliseconds"](),o=utc?0:date.getTimezoneOffset(),flags={d:d,dd:pad(d),ddd:dF.i18n.dayNames[D],dddd:dF.i18n.dayNames[D+7],m:m+1,mm:pad(m+1),mmm:dF.i18n.monthNames[m],mmmm:dF.i18n.monthNames[m+12],yy:String(y).slice(2),yyyy:y,h:H%12||12,hh:pad(H%12||12),H:H,HH:pad(H),M:M,MM:pad(M),s:s,ss:pad(s),l:pad(L,3),L:pad(L>99?Math.round(L/10):L),t:H<12?"a":"p",tt:H<12?"am":"pm",T:H<12?"A":"P",TT:H<12?"AM":"PM",Z:utc?"UTC":(String(date).match(timezone)||[""]).pop().replace(timezoneClip,""),o:(o>0?"-":"+")+pad(Math.floor(Math.abs(o)/60)*100+Math.abs(o)%60,4),S:["th","st","nd","rd"][d%10>3?0:(d%100-d%10!=10)*d%10]};return mask.replace(token,function($0){return $0 in flags?flags[$0]:$0.slice(1,$0.length-1);});};});ECMAScript.Extend('error',function(ecma){this.Assertion=function(){Error.apply(this,arguments);};this.Assertion.prototype=ecma.lang.createMethods(Error);this.MissingArg=function(name){var message='Missing argument: '+name;Error.apply(this,[message]);};this.MissingArg.prototype=ecma.lang.createMethods(Error);this.IllegalArg=function(name){var message='Illegal argument: '+name;Error.apply(this,[message]);};this.IllegalArg.prototype=ecma.lang.createMethods(Error);this.Multiple=function(errors){this.errors=errors;this.message='Multiple exceptions';Error.apply(this,[this.message]);};this.Multiple.prototype=ecma.lang.createMethods(Error);this.Multiple.prototype.toString=function(){var result=this.message+"\n";for(var i=0,ex;ex=this.errors[i];i++){result+='  Exception #'+i+': '+ex.toString()+"\n";}
return result;};});ECMAScript.Extend('error',function(ecma){function _errprintf(str,args){var result=new String(str);for(var i=0;i<args.length;i++){var param=new RegExp('\\$'+(i+1));result=result.replace(param,args[i]);}
result=result.replace(/\$@/,args.join(';'));return result;}
function _errstr(str){return function(){return _errprintf(str,ecma.util.args(arguments));}}
this.assertion=_errstr('Assertion failed');this.abstract=_errstr('Abstract function not implemented');this.illegalArgument=_errstr('Illegal argument: $1');this.missingArgument=_errstr('Missing argument: $1');this.multiple=_errstr('Multiple exceptions: $@');});ECMAScript.Extend('thread',function(ecma){this.spawn=function(func,scope,args,excb){var cb=ecma.lang.createCallbackArray(func,scope,args);ecma.dom.setTimeout(cb[0],0,cb[1],cb[2],excb);}});ECMAScript.Extend('impl',function(ecma){this.Parameters=function(){this.parameters=new Object();};var Parameters=this.Parameters.prototype=ecma.lang.createMethods();Parameters.getParameter=function(key){return this.parameters[key];};Parameters.setParameter=function(key,value){return this.parameters[key]=value;};Parameters.getParameters=function(){return this.parameters;};Parameters.setParameters=function(parameters){return this.parameters=parameters;};Parameters.overlayParameters=function(parameters){ecma.util.overlay(this.parameters,parameters);return this.parameters;};});ECMAScript.Extend('crypt',function(ecma){var hexcase=0;var b64pad="";var chrsz=8;this.hex_sha1=function(s){return binb2hex(core_sha1(str2binb(s),s.length*chrsz));}
this.b64_sha1=function(s){return binb2b64(core_sha1(str2binb(s),s.length*chrsz));}
this.str_sha1=function(s){return binb2str(core_sha1(str2binb(s),s.length*chrsz));}
this.hex_hmac_sha1=function(key,data){return binb2hex(core_hmac_sha1(key,data));}
this.b64_hmac_sha1=function(key,data){return binb2b64(core_hmac_sha1(key,data));}
this.str_hmac_sha1=function(key,data){return binb2str(core_hmac_sha1(key,data));}
function sha1_vm_test()
{return hex_sha1("abc")=="a9993e364706816aba3e25717850c26c9cd0d89d";}
function core_sha1(x,len)
{x[len>>5]|=0x80<<(24-len%32);x[((len+64>>9)<<4)+15]=len;var w=Array(80);var a=1732584193;var b=-271733879;var c=-1732584194;var d=271733878;var e=-1009589776;for(var i=0;i<x.length;i+=16)
{var olda=a;var oldb=b;var oldc=c;var oldd=d;var olde=e;for(var j=0;j<80;j++)
{if(j<16)w[j]=x[i+j];else w[j]=rol(w[j-3]^w[j-8]^w[j-14]^w[j-16],1);var t=safe_add(safe_add(rol(a,5),sha1_ft(j,b,c,d)),safe_add(safe_add(e,w[j]),sha1_kt(j)));e=d;d=c;c=rol(b,30);b=a;a=t;}
a=safe_add(a,olda);b=safe_add(b,oldb);c=safe_add(c,oldc);d=safe_add(d,oldd);e=safe_add(e,olde);}
return Array(a,b,c,d,e);}
function sha1_ft(t,b,c,d)
{if(t<20)return(b&c)|((~b)&d);if(t<40)return b^c^d;if(t<60)return(b&c)|(b&d)|(c&d);return b^c^d;}
function sha1_kt(t)
{return(t<20)?1518500249:(t<40)?1859775393:(t<60)?-1894007588:-899497514;}
function core_hmac_sha1(key,data)
{var bkey=str2binb(key);if(bkey.length>16)bkey=core_sha1(bkey,key.length*chrsz);var ipad=Array(16),opad=Array(16);for(var i=0;i<16;i++)
{ipad[i]=bkey[i]^0x36363636;opad[i]=bkey[i]^0x5C5C5C5C;}
var hash=core_sha1(ipad.concat(str2binb(data)),512+data.length*chrsz);return core_sha1(opad.concat(hash),512+160);}
function safe_add(x,y)
{var lsw=(x&0xFFFF)+(y&0xFFFF);var msw=(x>>16)+(y>>16)+(lsw>>16);return(msw<<16)|(lsw&0xFFFF);}
function rol(num,cnt)
{return(num<<cnt)|(num>>>(32-cnt));}
function str2binb(str)
{var bin=Array();var mask=(1<<chrsz)-1;for(var i=0;i<str.length*chrsz;i+=chrsz)
bin[i>>5]|=(str.charCodeAt(i/chrsz)&mask)<<(32-chrsz-i%32);return bin;}
function binb2str(bin)
{var str="";var mask=(1<<chrsz)-1;for(var i=0;i<bin.length*32;i+=chrsz)
str+=String.fromCharCode((bin[i>>5]>>>(32-chrsz-i%32))&mask);return str;}
function binb2hex(binarray)
{var hex_tab=hexcase?"0123456789ABCDEF":"0123456789abcdef";var str="";for(var i=0;i<binarray.length*4;i++)
{str+=hex_tab.charAt((binarray[i>>2]>>((3-i%4)*8+4))&0xF)+
hex_tab.charAt((binarray[i>>2]>>((3-i%4)*8))&0xF);}
return str;}
function binb2b64(binarray)
{var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var str="";for(var i=0;i<binarray.length*4;i+=3)
{var triplet=(((binarray[i>>2]>>8*(3-i%4))&0xFF)<<16)|(((binarray[i+1>>2]>>8*(3-(i+1)%4))&0xFF)<<8)|((binarray[i+2>>2]>>8*(3-(i+2)%4))&0xFF);for(var j=0;j<4;j++)
{if(i*8+j*6>binarray.length*32)str+=b64pad;else str+=tab.charAt((triplet>>6*(3-j))&0x3F);}}
return str;}});ECMAScript.Extend('console',function(ecma){var _consoles=[];var _history=[];var _lastFlushed=0;function _formatLine(line,text){return text;}
this.tee=function(console){if(!console)throw'Missing argument';_consoles.push(console);for(var i=_lastFlushed;i<_history.length;i++){var text=_history[i];console.log(_formatLine(i+1,text));}};this.log=function(){var args=ecma.util.args(arguments);var text=args.join(' ');_history.push(text);for(var i=0,c;c=_consoles[i];i++){c.log(_formatLine(_history.length,text));}};this.trace=function(){for(var i=0,c;c=_consoles[i];i++){if(typeof(c.trace)=='function')c.trace();}};this.dir=function(){for(var i=0,c;c=_consoles[i];i++){try{c.dir.apply(c,arguments);}catch(ex){}}};this.flush=function(){for(var i=_lastFlushed;i<_history.length;i++){_lastFlushed++;var text=_history[i];for(var j=0,c;c=_consoles[j];j++){c.log(_formatLine(i,text));}}};this.history=function(){return _history;};});ECMAScript.Extend('data',function(ecma){_inspect=function(unk,name,ctrl){var result='';if(typeof(unk)=='function'){unk='(function)';}else if(ecma.util.isObject(unk)){if(!ecma.util.grep(function(i){return i===unk},ctrl)){ctrl.push(unk);var pName=ecma.util.defined(name)&&name!=''?name+'/':'';for(var k in unk){var v=unk[k];result+=_inspect(v,pName+k,ctrl);}
return result;}}
result+=name+': '+unk+"\n";return result;};this.inspect=function(unk,name){return _inspect(unk,name||'',[]);};});ECMAScript.Extend('data.utf8',function(ecma){this.encode=function(str){if(typeof(str)!='string'){str=new String(str);}
str=str.replace(/\r\n/g,"\n");var utftext="";for(var n=0;n<str.length;n++){var c=str.charCodeAt(n);if(c<128){utftext+=String.fromCharCode(c);}
else if((c>127)&&(c<2048)){utftext+=String.fromCharCode((c>>6)|192);utftext+=String.fromCharCode((c&63)|128);}
else{utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128);}}
return utftext;};this.decode=function(utftext){var str="";var i=0;var c=c2=c3=0;while(i<utftext.length){c=utftext.charCodeAt(i);if(c<128){str+=String.fromCharCode(c);i++;}
else if((c>191)&&(c<224)){c2=utftext.charCodeAt(i+1);str+=String.fromCharCode(((c&31)<<6)|(c2&63));i+=2;}
else{c2=utftext.charCodeAt(i+1);c3=utftext.charCodeAt(i+2);str+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));i+=3;}}
return str;};});ECMAScript.Extend('data.md5',function(ecma){function RotateLeft(lValue,iShiftBits){return(lValue<<iShiftBits)|(lValue>>>(32-iShiftBits));}
function AddUnsigned(lX,lY){var lX4,lY4,lX8,lY8,lResult;lX8=(lX&0x80000000);lY8=(lY&0x80000000);lX4=(lX&0x40000000);lY4=(lY&0x40000000);lResult=(lX&0x3FFFFFFF)+(lY&0x3FFFFFFF);if(lX4&lY4){return(lResult^0x80000000^lX8^lY8);}
if(lX4|lY4){if(lResult&0x40000000){return(lResult^0xC0000000^lX8^lY8);}else{return(lResult^0x40000000^lX8^lY8);}}else{return(lResult^lX8^lY8);}}
function F(x,y,z){return(x&y)|((~x)&z);}
function G(x,y,z){return(x&z)|(y&(~z));}
function H(x,y,z){return(x^y^z);}
function I(x,y,z){return(y^(x|(~z)));}
function FF(a,b,c,d,x,s,ac){a=AddUnsigned(a,AddUnsigned(AddUnsigned(F(b,c,d),x),ac));return AddUnsigned(RotateLeft(a,s),b);};function GG(a,b,c,d,x,s,ac){a=AddUnsigned(a,AddUnsigned(AddUnsigned(G(b,c,d),x),ac));return AddUnsigned(RotateLeft(a,s),b);};function HH(a,b,c,d,x,s,ac){a=AddUnsigned(a,AddUnsigned(AddUnsigned(H(b,c,d),x),ac));return AddUnsigned(RotateLeft(a,s),b);};function II(a,b,c,d,x,s,ac){a=AddUnsigned(a,AddUnsigned(AddUnsigned(I(b,c,d),x),ac));return AddUnsigned(RotateLeft(a,s),b);};function ConvertToWordArray(string){var lWordCount;var lMessageLength=string.length;var lNumberOfWords_temp1=lMessageLength+8;var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1%64))/64;var lNumberOfWords=(lNumberOfWords_temp2+1)*16;var lWordArray=Array(lNumberOfWords-1);var lBytePosition=0;var lByteCount=0;while(lByteCount<lMessageLength){lWordCount=(lByteCount-(lByteCount%4))/4;lBytePosition=(lByteCount%4)*8;lWordArray[lWordCount]=(lWordArray[lWordCount]|(string.charCodeAt(lByteCount)<<lBytePosition));lByteCount++;}
lWordCount=(lByteCount-(lByteCount%4))/4;lBytePosition=(lByteCount%4)*8;lWordArray[lWordCount]=lWordArray[lWordCount]|(0x80<<lBytePosition);lWordArray[lNumberOfWords-2]=lMessageLength<<3;lWordArray[lNumberOfWords-1]=lMessageLength>>>29;return lWordArray;};function WordToHex(lValue){var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;for(lCount=0;lCount<=3;lCount++){lByte=(lValue>>>(lCount*8))&255;WordToHexValue_temp="0"+lByte.toString(16);WordToHexValue=WordToHexValue+WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);}
return WordToHexValue;};this.sum=function(string){var x=Array();var k,AA,BB,CC,DD,a,b,c,d;var S11=7,S12=12,S13=17,S14=22;var S21=5,S22=9,S23=14,S24=20;var S31=4,S32=11,S33=16,S34=23;var S41=6,S42=10,S43=15,S44=21;string=ecma.data.utf8.encode(string);x=ConvertToWordArray(string);a=0x67452301;b=0xEFCDAB89;c=0x98BADCFE;d=0x10325476;for(k=0;k<x.length;k+=16){AA=a;BB=b;CC=c;DD=d;a=FF(a,b,c,d,x[k+0],S11,0xD76AA478);d=FF(d,a,b,c,x[k+1],S12,0xE8C7B756);c=FF(c,d,a,b,x[k+2],S13,0x242070DB);b=FF(b,c,d,a,x[k+3],S14,0xC1BDCEEE);a=FF(a,b,c,d,x[k+4],S11,0xF57C0FAF);d=FF(d,a,b,c,x[k+5],S12,0x4787C62A);c=FF(c,d,a,b,x[k+6],S13,0xA8304613);b=FF(b,c,d,a,x[k+7],S14,0xFD469501);a=FF(a,b,c,d,x[k+8],S11,0x698098D8);d=FF(d,a,b,c,x[k+9],S12,0x8B44F7AF);c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);a=FF(a,b,c,d,x[k+12],S11,0x6B901122);d=FF(d,a,b,c,x[k+13],S12,0xFD987193);c=FF(c,d,a,b,x[k+14],S13,0xA679438E);b=FF(b,c,d,a,x[k+15],S14,0x49B40821);a=GG(a,b,c,d,x[k+1],S21,0xF61E2562);d=GG(d,a,b,c,x[k+6],S22,0xC040B340);c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);b=GG(b,c,d,a,x[k+0],S24,0xE9B6C7AA);a=GG(a,b,c,d,x[k+5],S21,0xD62F105D);d=GG(d,a,b,c,x[k+10],S22,0x2441453);c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);b=GG(b,c,d,a,x[k+4],S24,0xE7D3FBC8);a=GG(a,b,c,d,x[k+9],S21,0x21E1CDE6);d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);c=GG(c,d,a,b,x[k+3],S23,0xF4D50D87);b=GG(b,c,d,a,x[k+8],S24,0x455A14ED);a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);d=GG(d,a,b,c,x[k+2],S22,0xFCEFA3F8);c=GG(c,d,a,b,x[k+7],S23,0x676F02D9);b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);a=HH(a,b,c,d,x[k+5],S31,0xFFFA3942);d=HH(d,a,b,c,x[k+8],S32,0x8771F681);c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);a=HH(a,b,c,d,x[k+1],S31,0xA4BEEA44);d=HH(d,a,b,c,x[k+4],S32,0x4BDECFA9);c=HH(c,d,a,b,x[k+7],S33,0xF6BB4B60);b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);d=HH(d,a,b,c,x[k+0],S32,0xEAA127FA);c=HH(c,d,a,b,x[k+3],S33,0xD4EF3085);b=HH(b,c,d,a,x[k+6],S34,0x4881D05);a=HH(a,b,c,d,x[k+9],S31,0xD9D4D039);d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);b=HH(b,c,d,a,x[k+2],S34,0xC4AC5665);a=II(a,b,c,d,x[k+0],S41,0xF4292244);d=II(d,a,b,c,x[k+7],S42,0x432AFF97);c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);b=II(b,c,d,a,x[k+5],S44,0xFC93A039);a=II(a,b,c,d,x[k+12],S41,0x655B59C3);d=II(d,a,b,c,x[k+3],S42,0x8F0CCC92);c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);b=II(b,c,d,a,x[k+1],S44,0x85845DD1);a=II(a,b,c,d,x[k+8],S41,0x6FA87E4F);d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);c=II(c,d,a,b,x[k+6],S43,0xA3014314);b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);a=II(a,b,c,d,x[k+4],S41,0xF7537E82);d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);c=II(c,d,a,b,x[k+2],S43,0x2AD7D2BB);b=II(b,c,d,a,x[k+9],S44,0xEB86D391);a=AddUnsigned(a,AA);b=AddUnsigned(b,BB);c=AddUnsigned(c,CC);d=AddUnsigned(d,DD);}
var temp=WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);return temp.toLowerCase();};});ECMAScript.Extend('data.base64',function(ecma){var _keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";this.encode=function(input){var output="";var chr1,chr2,chr3,enc1,enc2,enc3,enc4;var i=0;input=ecma.data.utf8.encode(input);while(i<input.length){chr1=input.charCodeAt(i++);chr2=input.charCodeAt(i++);chr3=input.charCodeAt(i++);enc1=chr1>>2;enc2=((chr1&3)<<4)|(chr2>>4);enc3=((chr2&15)<<2)|(chr3>>6);enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64;}else if(isNaN(chr3)){enc4=64;}
output=output+
_keyStr.charAt(enc1)+_keyStr.charAt(enc2)+
_keyStr.charAt(enc3)+_keyStr.charAt(enc4);}
return output;};this.decode=function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(i<input.length){enc1=_keyStr.indexOf(input.charAt(i++));enc2=_keyStr.indexOf(input.charAt(i++));enc3=_keyStr.indexOf(input.charAt(i++));enc4=_keyStr.indexOf(input.charAt(i++));chr1=(enc1<<2)|(enc2>>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2);}
if(enc4!=64){output=output+String.fromCharCode(chr3);}}
output=ecma.data.utf8.decode(output);return output;};});ECMAScript.Extend('data.entities',function(ecma){function _isAllowed(cc){if(cc>=0&&cc<=8)return false;if(cc>=11&&cc<=12)return false;if(cc>=14&&cc<=31)return false;if(cc==127)return false;if(cc>=128&&cc<=159)return false;if(cc>=55296&&cc<=57343)return false;return true;}
function _isMarkup(cc){return cc==34||cc==38||cc==60||cc==62;}
function _isLower(cc){return cc<32&&cc!=9&&cc!=10&&cc!=13;}
function _isUpper(cc){return cc>=127;}
var charCodeToNamedMap={};charCodeToNamedMap[34]='quot';charCodeToNamedMap[38]='amp';charCodeToNamedMap[60]='lt';charCodeToNamedMap[62]='gt';charCodeToNamedMap[160]='nbsp';charCodeToNamedMap[161]='iexcl';charCodeToNamedMap[162]='cent';charCodeToNamedMap[163]='pound';charCodeToNamedMap[164]='curren';charCodeToNamedMap[165]='yen';charCodeToNamedMap[166]='brvbar';charCodeToNamedMap[167]='sect';charCodeToNamedMap[168]='uml';charCodeToNamedMap[169]='copy';charCodeToNamedMap[170]='ordf';charCodeToNamedMap[171]='laquo';charCodeToNamedMap[172]='not';charCodeToNamedMap[173]='shy';charCodeToNamedMap[174]='reg';charCodeToNamedMap[175]='macr';charCodeToNamedMap[176]='deg';charCodeToNamedMap[177]='plusmn';charCodeToNamedMap[178]='sup2';charCodeToNamedMap[179]='sup3';charCodeToNamedMap[180]='acute';charCodeToNamedMap[181]='micro';charCodeToNamedMap[182]='para';charCodeToNamedMap[183]='middot';charCodeToNamedMap[184]='cedil';charCodeToNamedMap[185]='sup1';charCodeToNamedMap[186]='ordm';charCodeToNamedMap[187]='raquo';charCodeToNamedMap[188]='frac14';charCodeToNamedMap[189]='frac12';charCodeToNamedMap[190]='frac34';charCodeToNamedMap[191]='iquest';charCodeToNamedMap[192]='Agrave';charCodeToNamedMap[193]='Aacute';charCodeToNamedMap[194]='Acirc';charCodeToNamedMap[195]='Atilde';charCodeToNamedMap[196]='Auml';charCodeToNamedMap[197]='Aring';charCodeToNamedMap[198]='AElig';charCodeToNamedMap[199]='Ccedil';charCodeToNamedMap[200]='Egrave';charCodeToNamedMap[201]='Eacute';charCodeToNamedMap[202]='Ecirc';charCodeToNamedMap[203]='Euml';charCodeToNamedMap[204]='Igrave';charCodeToNamedMap[205]='Iacute';charCodeToNamedMap[206]='Icirc';charCodeToNamedMap[207]='Iuml';charCodeToNamedMap[208]='ETH';charCodeToNamedMap[209]='Ntilde';charCodeToNamedMap[210]='Ograve';charCodeToNamedMap[211]='Oacute';charCodeToNamedMap[212]='Ocirc';charCodeToNamedMap[213]='Otilde';charCodeToNamedMap[214]='Ouml';charCodeToNamedMap[215]='times';charCodeToNamedMap[216]='Oslash';charCodeToNamedMap[217]='Ugrave';charCodeToNamedMap[218]='Uacute';charCodeToNamedMap[219]='Ucirc';charCodeToNamedMap[220]='Uuml';charCodeToNamedMap[221]='Yacute';charCodeToNamedMap[222]='THORN';charCodeToNamedMap[223]='szlig';charCodeToNamedMap[224]='agrave';charCodeToNamedMap[225]='aacute';charCodeToNamedMap[226]='acirc';charCodeToNamedMap[227]='atilde';charCodeToNamedMap[228]='auml';charCodeToNamedMap[229]='aring';charCodeToNamedMap[230]='aelig';charCodeToNamedMap[231]='ccedil';charCodeToNamedMap[232]='egrave';charCodeToNamedMap[233]='eacute';charCodeToNamedMap[234]='ecirc';charCodeToNamedMap[235]='euml';charCodeToNamedMap[236]='igrave';charCodeToNamedMap[237]='iacute';charCodeToNamedMap[238]='icirc';charCodeToNamedMap[239]='iuml';charCodeToNamedMap[240]='eth';charCodeToNamedMap[241]='ntilde';charCodeToNamedMap[242]='ograve';charCodeToNamedMap[243]='oacute';charCodeToNamedMap[244]='ocirc';charCodeToNamedMap[245]='otilde';charCodeToNamedMap[246]='ouml';charCodeToNamedMap[247]='divide';charCodeToNamedMap[248]='oslash';charCodeToNamedMap[249]='ugrave';charCodeToNamedMap[250]='uacute';charCodeToNamedMap[251]='ucirc';charCodeToNamedMap[252]='uuml';charCodeToNamedMap[253]='yacute';charCodeToNamedMap[254]='thorn';charCodeToNamedMap[255]='yuml';charCodeToNamedMap[338]='OElig';charCodeToNamedMap[339]='oelig';charCodeToNamedMap[352]='Scaron';charCodeToNamedMap[353]='scaron';charCodeToNamedMap[376]='Yuml';charCodeToNamedMap[402]='fnof';charCodeToNamedMap[710]='circ';charCodeToNamedMap[732]='tilde';charCodeToNamedMap[913]='Alpha';charCodeToNamedMap[914]='Beta';charCodeToNamedMap[915]='Gamma';charCodeToNamedMap[916]='Delta';charCodeToNamedMap[917]='Epsilon';charCodeToNamedMap[918]='Zeta';charCodeToNamedMap[919]='Eta';charCodeToNamedMap[920]='Theta';charCodeToNamedMap[921]='Iota';charCodeToNamedMap[922]='Kappa';charCodeToNamedMap[923]='Lambda';charCodeToNamedMap[924]='Mu';charCodeToNamedMap[925]='Nu';charCodeToNamedMap[926]='Xi';charCodeToNamedMap[927]='Omicron';charCodeToNamedMap[928]='Pi';charCodeToNamedMap[929]='Rho';charCodeToNamedMap[931]='Sigma';charCodeToNamedMap[932]='Tau';charCodeToNamedMap[933]='Upsilon';charCodeToNamedMap[934]='Phi';charCodeToNamedMap[935]='Chi';charCodeToNamedMap[936]='Psi';charCodeToNamedMap[937]='Omega';charCodeToNamedMap[945]='alpha';charCodeToNamedMap[946]='beta';charCodeToNamedMap[947]='gamma';charCodeToNamedMap[948]='delta';charCodeToNamedMap[949]='epsilon';charCodeToNamedMap[950]='zeta';charCodeToNamedMap[951]='eta';charCodeToNamedMap[952]='theta';charCodeToNamedMap[953]='iota';charCodeToNamedMap[954]='kappa';charCodeToNamedMap[955]='lambda';charCodeToNamedMap[956]='mu';charCodeToNamedMap[957]='nu';charCodeToNamedMap[958]='xi';charCodeToNamedMap[959]='omicron';charCodeToNamedMap[960]='pi';charCodeToNamedMap[961]='rho';charCodeToNamedMap[962]='sigmaf';charCodeToNamedMap[963]='sigma';charCodeToNamedMap[964]='tau';charCodeToNamedMap[965]='upsilon';charCodeToNamedMap[966]='phi';charCodeToNamedMap[967]='chi';charCodeToNamedMap[968]='psi';charCodeToNamedMap[969]='omega';charCodeToNamedMap[977]='thetasym';charCodeToNamedMap[978]='upsih';charCodeToNamedMap[982]='piv';charCodeToNamedMap[8194]='ensp';charCodeToNamedMap[8195]='emsp';charCodeToNamedMap[8201]='thinsp';charCodeToNamedMap[8204]='zwnj';charCodeToNamedMap[8205]='zwj';charCodeToNamedMap[8206]='lrm';charCodeToNamedMap[8207]='rlm';charCodeToNamedMap[8211]='ndash';charCodeToNamedMap[8212]='mdash';charCodeToNamedMap[8216]='lsquo';charCodeToNamedMap[8217]='rsquo';charCodeToNamedMap[8218]='sbquo';charCodeToNamedMap[8220]='ldquo';charCodeToNamedMap[8221]='rdquo';charCodeToNamedMap[8222]='bdquo';charCodeToNamedMap[8224]='dagger';charCodeToNamedMap[8225]='Dagger';charCodeToNamedMap[8226]='bull';charCodeToNamedMap[8230]='hellip';charCodeToNamedMap[8240]='permil';charCodeToNamedMap[8242]='prime';charCodeToNamedMap[8243]='Prime';charCodeToNamedMap[8249]='lsaquo';charCodeToNamedMap[8250]='rsaquo';charCodeToNamedMap[8254]='oline';charCodeToNamedMap[8260]='frasl';charCodeToNamedMap[8364]='euro';charCodeToNamedMap[8465]='image';charCodeToNamedMap[8472]='weierp';charCodeToNamedMap[8476]='real';charCodeToNamedMap[8482]='trade';charCodeToNamedMap[8501]='alefsym';charCodeToNamedMap[8592]='larr';charCodeToNamedMap[8593]='uarr';charCodeToNamedMap[8594]='rarr';charCodeToNamedMap[8595]='darr';charCodeToNamedMap[8596]='harr';charCodeToNamedMap[8629]='crarr';charCodeToNamedMap[8656]='lArr';charCodeToNamedMap[8657]='uArr';charCodeToNamedMap[8658]='rArr';charCodeToNamedMap[8659]='dArr';charCodeToNamedMap[8660]='hArr';charCodeToNamedMap[8704]='forall';charCodeToNamedMap[8706]='part';charCodeToNamedMap[8707]='exist';charCodeToNamedMap[8709]='empty';charCodeToNamedMap[8711]='nabla';charCodeToNamedMap[8712]='isin';charCodeToNamedMap[8713]='notin';charCodeToNamedMap[8715]='ni';charCodeToNamedMap[8719]='prod';charCodeToNamedMap[8721]='sum';charCodeToNamedMap[8722]='minus';charCodeToNamedMap[8727]='lowast';charCodeToNamedMap[8730]='radic';charCodeToNamedMap[8733]='prop';charCodeToNamedMap[8734]='infin';charCodeToNamedMap[8736]='ang';charCodeToNamedMap[8743]='and';charCodeToNamedMap[8744]='or';charCodeToNamedMap[8745]='cap';charCodeToNamedMap[8746]='cup';charCodeToNamedMap[8747]='int';charCodeToNamedMap[8756]='there4';charCodeToNamedMap[8764]='sim';charCodeToNamedMap[8773]='cong';charCodeToNamedMap[8776]='asymp';charCodeToNamedMap[8800]='ne';charCodeToNamedMap[8801]='equiv';charCodeToNamedMap[8804]='le';charCodeToNamedMap[8805]='ge';charCodeToNamedMap[8834]='sub';charCodeToNamedMap[8835]='sup';charCodeToNamedMap[8836]='nsub';charCodeToNamedMap[8838]='sube';charCodeToNamedMap[8839]='supe';charCodeToNamedMap[8853]='oplus';charCodeToNamedMap[8855]='otimes';charCodeToNamedMap[8869]='perp';charCodeToNamedMap[8901]='sdot';charCodeToNamedMap[8968]='lceil';charCodeToNamedMap[8969]='rceil';charCodeToNamedMap[8970]='lfloor';charCodeToNamedMap[8971]='rfloor';charCodeToNamedMap[9001]='lang';charCodeToNamedMap[9002]='rang';charCodeToNamedMap[9674]='loz';charCodeToNamedMap[9824]='spades';charCodeToNamedMap[9827]='clubs';charCodeToNamedMap[9829]='hearts';charCodeToNamedMap[9830]='diams';var namedToCharCodeMap={};namedToCharCodeMap['quot']=34;namedToCharCodeMap['amp']=38;namedToCharCodeMap['lt']=60;namedToCharCodeMap['gt']=62;namedToCharCodeMap['nbsp']=160;namedToCharCodeMap['iexcl']=161;namedToCharCodeMap['cent']=162;namedToCharCodeMap['pound']=163;namedToCharCodeMap['curren']=164;namedToCharCodeMap['yen']=165;namedToCharCodeMap['brvbar']=166;namedToCharCodeMap['sect']=167;namedToCharCodeMap['uml']=168;namedToCharCodeMap['copy']=169;namedToCharCodeMap['ordf']=170;namedToCharCodeMap['laquo']=171;namedToCharCodeMap['not']=172;namedToCharCodeMap['shy']=173;namedToCharCodeMap['reg']=174;namedToCharCodeMap['macr']=175;namedToCharCodeMap['deg']=176;namedToCharCodeMap['plusmn']=177;namedToCharCodeMap['sup2']=178;namedToCharCodeMap['sup3']=179;namedToCharCodeMap['acute']=180;namedToCharCodeMap['micro']=181;namedToCharCodeMap['para']=182;namedToCharCodeMap['middot']=183;namedToCharCodeMap['cedil']=184;namedToCharCodeMap['sup1']=185;namedToCharCodeMap['ordm']=186;namedToCharCodeMap['raquo']=187;namedToCharCodeMap['frac14']=188;namedToCharCodeMap['frac12']=189;namedToCharCodeMap['frac34']=190;namedToCharCodeMap['iquest']=191;namedToCharCodeMap['Agrave']=192;namedToCharCodeMap['Aacute']=193;namedToCharCodeMap['Acirc']=194;namedToCharCodeMap['Atilde']=195;namedToCharCodeMap['Auml']=196;namedToCharCodeMap['Aring']=197;namedToCharCodeMap['AElig']=198;namedToCharCodeMap['Ccedil']=199;namedToCharCodeMap['Egrave']=200;namedToCharCodeMap['Eacute']=201;namedToCharCodeMap['Ecirc']=202;namedToCharCodeMap['Euml']=203;namedToCharCodeMap['Igrave']=204;namedToCharCodeMap['Iacute']=205;namedToCharCodeMap['Icirc']=206;namedToCharCodeMap['Iuml']=207;namedToCharCodeMap['ETH']=208;namedToCharCodeMap['Ntilde']=209;namedToCharCodeMap['Ograve']=210;namedToCharCodeMap['Oacute']=211;namedToCharCodeMap['Ocirc']=212;namedToCharCodeMap['Otilde']=213;namedToCharCodeMap['Ouml']=214;namedToCharCodeMap['times']=215;namedToCharCodeMap['Oslash']=216;namedToCharCodeMap['Ugrave']=217;namedToCharCodeMap['Uacute']=218;namedToCharCodeMap['Ucirc']=219;namedToCharCodeMap['Uuml']=220;namedToCharCodeMap['Yacute']=221;namedToCharCodeMap['THORN']=222;namedToCharCodeMap['szlig']=223;namedToCharCodeMap['agrave']=224;namedToCharCodeMap['aacute']=225;namedToCharCodeMap['acirc']=226;namedToCharCodeMap['atilde']=227;namedToCharCodeMap['auml']=228;namedToCharCodeMap['aring']=229;namedToCharCodeMap['aelig']=230;namedToCharCodeMap['ccedil']=231;namedToCharCodeMap['egrave']=232;namedToCharCodeMap['eacute']=233;namedToCharCodeMap['ecirc']=234;namedToCharCodeMap['euml']=235;namedToCharCodeMap['igrave']=236;namedToCharCodeMap['iacute']=237;namedToCharCodeMap['icirc']=238;namedToCharCodeMap['iuml']=239;namedToCharCodeMap['eth']=240;namedToCharCodeMap['ntilde']=241;namedToCharCodeMap['ograve']=242;namedToCharCodeMap['oacute']=243;namedToCharCodeMap['ocirc']=244;namedToCharCodeMap['otilde']=245;namedToCharCodeMap['ouml']=246;namedToCharCodeMap['divide']=247;namedToCharCodeMap['oslash']=248;namedToCharCodeMap['ugrave']=249;namedToCharCodeMap['uacute']=250;namedToCharCodeMap['ucirc']=251;namedToCharCodeMap['uuml']=252;namedToCharCodeMap['yacute']=253;namedToCharCodeMap['thorn']=254;namedToCharCodeMap['yuml']=255;namedToCharCodeMap['OElig']=338;namedToCharCodeMap['oelig']=339;namedToCharCodeMap['Scaron']=352;namedToCharCodeMap['scaron']=353;namedToCharCodeMap['Yuml']=376;namedToCharCodeMap['fnof']=402;namedToCharCodeMap['circ']=710;namedToCharCodeMap['tilde']=732;namedToCharCodeMap['Alpha']=913;namedToCharCodeMap['Beta']=914;namedToCharCodeMap['Gamma']=915;namedToCharCodeMap['Delta']=916;namedToCharCodeMap['Epsilon']=917;namedToCharCodeMap['Zeta']=918;namedToCharCodeMap['Eta']=919;namedToCharCodeMap['Theta']=920;namedToCharCodeMap['Iota']=921;namedToCharCodeMap['Kappa']=922;namedToCharCodeMap['Lambda']=923;namedToCharCodeMap['Mu']=924;namedToCharCodeMap['Nu']=925;namedToCharCodeMap['Xi']=926;namedToCharCodeMap['Omicron']=927;namedToCharCodeMap['Pi']=928;namedToCharCodeMap['Rho']=929;namedToCharCodeMap['Sigma']=931;namedToCharCodeMap['Tau']=932;namedToCharCodeMap['Upsilon']=933;namedToCharCodeMap['Phi']=934;namedToCharCodeMap['Chi']=935;namedToCharCodeMap['Psi']=936;namedToCharCodeMap['Omega']=937;namedToCharCodeMap['alpha']=945;namedToCharCodeMap['beta']=946;namedToCharCodeMap['gamma']=947;namedToCharCodeMap['delta']=948;namedToCharCodeMap['epsilon']=949;namedToCharCodeMap['zeta']=950;namedToCharCodeMap['eta']=951;namedToCharCodeMap['theta']=952;namedToCharCodeMap['iota']=953;namedToCharCodeMap['kappa']=954;namedToCharCodeMap['lambda']=955;namedToCharCodeMap['mu']=956;namedToCharCodeMap['nu']=957;namedToCharCodeMap['xi']=958;namedToCharCodeMap['omicron']=959;namedToCharCodeMap['pi']=960;namedToCharCodeMap['rho']=961;namedToCharCodeMap['sigmaf']=962;namedToCharCodeMap['sigma']=963;namedToCharCodeMap['tau']=964;namedToCharCodeMap['upsilon']=965;namedToCharCodeMap['phi']=966;namedToCharCodeMap['chi']=967;namedToCharCodeMap['psi']=968;namedToCharCodeMap['omega']=969;namedToCharCodeMap['thetasym']=977;namedToCharCodeMap['upsih']=978;namedToCharCodeMap['piv']=982;namedToCharCodeMap['ensp']=8194;namedToCharCodeMap['emsp']=8195;namedToCharCodeMap['thinsp']=8201;namedToCharCodeMap['zwnj']=8204;namedToCharCodeMap['zwj']=8205;namedToCharCodeMap['lrm']=8206;namedToCharCodeMap['rlm']=8207;namedToCharCodeMap['ndash']=8211;namedToCharCodeMap['mdash']=8212;namedToCharCodeMap['lsquo']=8216;namedToCharCodeMap['rsquo']=8217;namedToCharCodeMap['sbquo']=8218;namedToCharCodeMap['ldquo']=8220;namedToCharCodeMap['rdquo']=8221;namedToCharCodeMap['bdquo']=8222;namedToCharCodeMap['dagger']=8224;namedToCharCodeMap['Dagger']=8225;namedToCharCodeMap['bull']=8226;namedToCharCodeMap['hellip']=8230;namedToCharCodeMap['permil']=8240;namedToCharCodeMap['prime']=8242;namedToCharCodeMap['Prime']=8243;namedToCharCodeMap['lsaquo']=8249;namedToCharCodeMap['rsaquo']=8250;namedToCharCodeMap['oline']=8254;namedToCharCodeMap['frasl']=8260;namedToCharCodeMap['euro']=8364;namedToCharCodeMap['image']=8465;namedToCharCodeMap['weierp']=8472;namedToCharCodeMap['real']=8476;namedToCharCodeMap['trade']=8482;namedToCharCodeMap['alefsym']=8501;namedToCharCodeMap['larr']=8592;namedToCharCodeMap['uarr']=8593;namedToCharCodeMap['rarr']=8594;namedToCharCodeMap['darr']=8595;namedToCharCodeMap['harr']=8596;namedToCharCodeMap['crarr']=8629;namedToCharCodeMap['lArr']=8656;namedToCharCodeMap['uArr']=8657;namedToCharCodeMap['rArr']=8658;namedToCharCodeMap['dArr']=8659;namedToCharCodeMap['hArr']=8660;namedToCharCodeMap['forall']=8704;namedToCharCodeMap['part']=8706;namedToCharCodeMap['exist']=8707;namedToCharCodeMap['empty']=8709;namedToCharCodeMap['nabla']=8711;namedToCharCodeMap['isin']=8712;namedToCharCodeMap['notin']=8713;namedToCharCodeMap['ni']=8715;namedToCharCodeMap['prod']=8719;namedToCharCodeMap['sum']=8721;namedToCharCodeMap['minus']=8722;namedToCharCodeMap['lowast']=8727;namedToCharCodeMap['radic']=8730;namedToCharCodeMap['prop']=8733;namedToCharCodeMap['infin']=8734;namedToCharCodeMap['ang']=8736;namedToCharCodeMap['and']=8743;namedToCharCodeMap['or']=8744;namedToCharCodeMap['cap']=8745;namedToCharCodeMap['cup']=8746;namedToCharCodeMap['int']=8747;namedToCharCodeMap['there4']=8756;namedToCharCodeMap['sim']=8764;namedToCharCodeMap['cong']=8773;namedToCharCodeMap['asymp']=8776;namedToCharCodeMap['ne']=8800;namedToCharCodeMap['equiv']=8801;namedToCharCodeMap['le']=8804;namedToCharCodeMap['ge']=8805;namedToCharCodeMap['sub']=8834;namedToCharCodeMap['sup']=8835;namedToCharCodeMap['nsub']=8836;namedToCharCodeMap['sube']=8838;namedToCharCodeMap['supe']=8839;namedToCharCodeMap['oplus']=8853;namedToCharCodeMap['otimes']=8855;namedToCharCodeMap['perp']=8869;namedToCharCodeMap['sdot']=8901;namedToCharCodeMap['lceil']=8968;namedToCharCodeMap['rceil']=8969;namedToCharCodeMap['lfloor']=8970;namedToCharCodeMap['rfloor']=8971;namedToCharCodeMap['lang']=9001;namedToCharCodeMap['rang']=9002;namedToCharCodeMap['loz']=9674;namedToCharCodeMap['spades']=9824;namedToCharCodeMap['clubs']=9827;namedToCharCodeMap['hearts']=9829;namedToCharCodeMap['diams']=9830;this.decode=function(s,bHtml){var result='';for(var i=0;i<s.length;i++){var cc=s.charCodeAt(i);if(!_isAllowed(cc))continue;if(_isLower(cc)||_isUpper(cc)||(bHtml&&_isMarkup(cc))){var named=charCodeToNamedMap[cc];if(named){result+='&'+named+';';}else{result+='&#'+cc+';';}}else{result+=s.charAt(i);}}
return result;};function _encodeEntity(entity,name,offset,str){var cc=namedToCharCodeMap[name];return cc?_encodeNumeric(entity,cc,offset,str):entity;}
function _encodeNumeric(entity,cc,offset,str){return _isAllowed(cc)?String.fromCharCode(cc):entity;}
function _encodeHex(entity,hexVal,offset,str){var cc=parseInt(hexVal,16);return _isAllowed(cc)?String.fromCharCode(cc):entity;}
this.encode=function(str){str=str.replace(/&([a-z]+);/ig,_encodeEntity);str=str.replace(/&#([0-9]+);/g,_encodeNumeric);str=str.replace(/&#x([0-9A-F]+);/gi,_encodeHex);return str;}});ECMAScript.Extend('data',function(ecma){function _crossCheck(node){if(!ecma.util.isa(node,ecma.data.Node)){throw'child is not a data node';}
if(node.parentNode!==this){throw'child belongs to another parent';}}
function _setChildMembers(){this.firstChild=this.childNodes[0];this.lastChild=this.childNodes[this.childNodes.length-1];}
function _relink(index){for(var i=index-1;i<=index+1;i++){if(i<0)continue;if(i>=this.childNodes.length)break;var prevNode=i<1?null:this.childNodes[i-1];var currNode=i<this.childNodes.length?this.childNodes[i]:null;var nextNode=i<=this.childNodes.length?this.childNodes[i+1]:null;if(prevNode)prevNode.nextSibling=currNode;if(currNode)currNode.previousSibling=prevNode;if(currNode)currNode.nextSibling=nextNode;if(nextNode)nextNode.previousSibling=currNode;}}
function _unlink(node,bSilent){return node.parentNode?node.parentNode.removeChild(node,bSilent):node;}
function _vivify(node){return ecma.util.isa(node,ecma.data.Node)?node:this.createNode.apply(this,arguments);}
this.Node=function(data){this.id=this.generateId(),this.data=data;this.childNodes=[];this.rootNode=null;this.parentNode=null;this.previousSibling=null;this.nextSibling=null;this.firstChild=null;this.lastChild=null;this.index=null;};this.Node.prototype={generateId:function(){return js.util.randomId('n',100000);},createNode:function(data){return new ecma.data.Node(data);},appendChild:function(node){node=_vivify.apply(this,arguments);var isChild=node.parentNode===this;_unlink.call(this,node,isChild);node.previousSibling=this.lastChild;node.nextSibling=null;if(this.lastChild)this.lastChild.nextSibling=node;this.childNodes.push(node);node.index=this.childNodes.length-1;node.parentNode=this;node.rootNode=this.rootNode||this;_setChildMembers.call(this);if(!isChild)this.onAdopt(node);return node;},insertBefore:function(node,child,args){_crossCheck.call(this,child);if(args){args.unshift(node)}else{args=[node];}
node=_vivify.apply(this,args);var isChild=node.parentNode===this;_unlink.call(this,node,isChild);var index=child.index;this.childNodes.splice(index,0,node);result=node;for(var i=index;i<this.childNodes.length;i++){this.childNodes[i].index=i;}
_relink.call(this,index);node.parentNode=this;node.rootNode=this.rootNode||this;_setChildMembers.call(this);if(!isChild)this.onAdopt(node);return node;},insertAfter:function(node,child){_crossCheck.call(this,child);return child.nextSibling?this.insertBefore(node,child.nextSibling):this.appendChild(node);},removeChild:function(node,bSilent){_crossCheck.call(this,node);var result=null;var index=0;for(;index<this.childNodes.length;index++){if(this.childNodes[index]===node){result=node;this.childNodes.splice(index,1);break;}}
if(!result){throw'programatic error, known child not found';}
for(var i=index;i<this.childNodes.length;i++){this.childNodes[i].index--;}
_relink.call(this,index);_setChildMembers.call(this);result.previousSibling=null;result.nextSibling=null;result.parentNode=null;result.rootNode=null;result.index=null;if(!bSilent)this.onOrphan(result);return result;},removeAllChildren:function(){for(var i=0;i<this.childNodes.length;i++){var child=this.childNodes[i];child.previousSibling=null;child.nextSibling=null;child.parentNode=null;child.rootNode=null;child.index=null;this.onOrphan(child);}
this.childNodes=[];this.firstChild=null;this.lastChild=null;return this;},replaceChild:function(node,child,args){_crossCheck.call(this,child);if(args){args.unshift(node)}else{args=[node];}
node=_vivify.apply(this,args);var isChild=node.parentNode===this;_unlink.call(this,node,isChild);node.previousSibling=child.previousSibling;node.nextSibling=child.nextSibling;node.index=child.index;var result=this.childNodes[child.index];this.childNodes[child.index]=node;node.parentNode=this;node.rootNode=this.rootNode||this;_setChildMembers.call(this);_unlink.call(this,child);if(!isChild)this.onAdopt(node);return result;},walk:function(callback,scope){var node=this.firstChild;while(node){try{callback.call(scope||this,node);}catch(ex){if(ex=='break'){break;}else if(ex!='continue'){throw ex;}}
if(node.hasChildNodes())node.walk(callback,scope);node=node.nextSibling;}},getDepth:function(){var node=this;var depth=0;while(node=node.parentNode){depth++;}
return depth;},hasChildNodes:function(){return this.childNodes.length>0;},onAdopt:function(childNode){},onOrphan:function(childNode){},toString:function(){return this.id;}};});ECMAScript.Extend('data',function(ecma){this.addr_split=function(addr){if(!ecma.util.defined(addr)||addr===""||addr=='/')return[];if(addr instanceof Array)return addr;if(typeof(addr)!='string')return[addr];return addr.replace(/^\//,'').split('/');};this.addr_normalize=function(addr){if(!ecma.util.defined(addr)||addr==="")return'';if(typeof(addr)=='string'){addr=addr.replace(/\/{2,}/g,'/');if(addr=='/')return addr;addr=addr.replace(/\/$/,'');return addr;}};this.addr_ext=function(addr){var lastKey=this.addr_split(addr).pop();if(!lastKey)return;if(typeof(lastKey)!='string')return;if(lastKey.indexOf('.')<=0)return;return lastKey.split('.').pop();};this.addr_parent=function(addr){var parts=this.addr_split(addr);parts.pop();var result=parts.length?parts.join('/'):'';return addr.indexOf('/')==0?'/'+result:result;};this.addr_name=function(addr){var parts=this.addr_split(addr);return parts.pop();};this.addr_join=function(){var args=ecma.util.args(arguments);var addr=args.shift();if(!addr)throw'Missing Argument: addr';var list=addr instanceof Array?addr:[addr];list=list.concat(args);return ecma.data.addr_normalize(list.join('/').replace(/^\/\//,'/'));};});ECMAScript.Extend('data',function(ecma){this.Container=function(){};this.Container.prototype.get=ecma.lang.createAbstractFunction();this.Container.prototype.get=function(addr){var parts=ecma.data.addr_split(addr);var c=this;for(var i=0;i<parts.length;i++){if(typeof(c)=='undefined'||!c.getValue)return;c=c.getValue(parts[i]);}
return c;};this.Container.prototype.set=function(addr,value){var parts=ecma.data.addr_split(addr);var lastKey=parts.pop();if(ecma.util.defined(lastKey)){var ptr=this;for(var i=0;i<parts.length;i++){var key=parts[i];var node=ptr.getValue(key);if(!ecma.util.defined(node)){node=ptr.setValue(key,new ecma.data.HashList());}
ptr=node;}
return ptr.setValue(lastKey,value);}else if(ecma.util.isa(value,ecma.data.Container)){this.clear();value.iterate(function(k,v){this.set(k,v);},this);}};this.Container.prototype.remove=function(addr){var parts=ecma.data.addr_split(addr);var lastKey=parts.pop();if(!ecma.util.defined(lastKey))return;var parent=this.get(parts);if(ecma.util.isa(parent,ecma.data.Container))parent.removeValue(lastKey);};this.Container.prototype.walk=function(callback,scope,prefix,depth){if(!depth)depth=0;this.iterate(function(k,v){var addr=ecma.util.defined(prefix)?prefix+'/'+k:k;callback.apply(scope,[k,v,depth,addr,this]);if(ecma.util.isa(v,ecma.data.Container)){v.walk(callback,scope,addr,(depth+1));}},this);};this.Container.prototype.toObject=function(){var result=ecma.util.isa(this,ecma.data.Array)?[]:{};this.iterate(function(k,v){result[k]=typeof(v.toObject)=='function'?v.toObject():v;},this);return result;};this.Container.prototype.toXFR=function(){var result='';this.iterate(function(k,v){result+=ecma.data.xfr.encodeComponent(k);result+=v.toXFR?v.toXFR():'${'+ecma.data.xfr.encodeComponent(v)+'}';},this);return result;};this.Container.prototype.getObject=function(addr){if(!ecma.util.defined(addr))return this.toObject();var v=this.get(addr);return ecma.util.defined(v)?v.toObject():v;};this.Container.prototype.getString=function(addr){if(!ecma.util.defined(addr))return this.toString();var v=this.get(addr);return ecma.util.defined(v)?v.toString():v;};});ECMAScript.Extend('data',function(ecma){this.Array=function(){this.clear();var args=ecma.util.args(arguments);if(args){this.data=args;this.length=this.data.length;}};this.Array.prototype=ecma.lang.Methods(ecma.data.Container);this.Array.prototype.clear=function(){this.data=[];this.length=0;};this.Array.prototype.getValue=function(key){return this.data[key];};this.Array.prototype.setValue=function(key,value){if(typeof(key)!='number')key=ecma.util.asInt(key);var result=this.data[key]=value;this.length=this.data.length;return result;};this.Array.prototype.indexOfValue=function(value){for(var i=0;i<this.data.length;i++){if(this.data[i]===value)return i;}
return null;};this.Array.prototype.push=function(value){return this.setValue(this.data.length,value);};this.Array.prototype.removeValue=function(key){if(typeof(key)!='number')key=ecma.util.asInt(key);var result=this.data.splice(key,1);this.length=this.data.length;return result;};this.Array.prototype.keys=function(){var result=[];for(var i=0;i<this.data.length;i++){result.push(i);}
return result;};this.Array.prototype.values=function(){return this.data;};this.Array.prototype.iterate=function(cb,scope){for(var i=0;i<this.data.length;i++){ecma.lang.callback(cb,scope,[i,this.data[i]]);}};this.Array.prototype.toXFR=function(){var result='';this.iterate(function(k,v){result+=v.toXFR?v.toXFR():'${'+ecma.data.xfr.encodeComponent(v)+'}';},this);return'@{'+result+'}';};});ECMAScript.Extend('data',function(ecma){this.HashList=function(){this.clear();for(var i=0;arguments&&i<arguments.length;i+=2){var k=arguments[i];var v=arguments[i+1];this.indicies.push(k);this.data[k]=v;}
this.length=this.indicies.length;};this.HashList.prototype=ecma.lang.Methods(ecma.data.Container);this.HashList.prototype.clear=function(){this.indicies=[];this.data={};this.length=0;};this.HashList.prototype.getValue=function(key){return this.data[key];};this.HashList.prototype.setValue=function(key,value,index){var currentIndex=this.indexOfKey(key);if(ecma.util.defined(index)&&currentIndex!=index){if(index<0||index>this.indicies.length)
throw new ecma.error.IllegalArgument('index');if(currentIndex!=null){this.indicies.splice(currentIndex,1);if(currentIndex<index)index--;}
this.indicies.splice(index,0,key);}else{if(currentIndex==null)this.indicies.push(key);}
this.length=this.indicies.length;return this.data[key]=value;};this.HashList.prototype.indexOfKey=function(key){for(var i=0;i<this.indicies.length;i++){if(this.indicies[i]==key)return i;}
return null;};this.HashList.prototype.indexOfValue=function(value){for(var i=0;i<this.indicies.length;i++){if(this.data[this.indicies[i]]===value)return i;}
return null;};this.HashList.prototype.removeValue=function(key){for(var i=0;i<this.indicies.length;i++){if(this.indicies[i]==key){this.indicies.splice(i,1);break;}}
this.length=this.indicies.length;var result=this.data[key];delete this.data[key];return result;};this.HashList.prototype.keys=function(){return this.indicies;};this.HashList.prototype.values=function(){var result=[];for(var i=0;i<this.indicies.length;i++){result.push(this.data[this.indicies[i]])}
return result;};this.HashList.prototype.iterate=function(cb,scope){for(var i=0;i<this.indicies.length;i++){var key=this.indicies[i];ecma.lang.callback(cb,scope,[key,this.data[key]]);}};this.HashList.prototype.toXFR=function(){return'%{'+ecma.data.Container.prototype.toXFR.apply(this,arguments)+'}';};this.OrderedHash=this.HashList;});ECMAScript.Extend('data',function(ecma){var _proto={};var _symbolToClassMap={'%':ecma.data.HashList,'@':ecma.data.Array,'$':ecma.window.String};var _typeToSymbolMap={'string':'$'};this.XFR=function(encoding){this.encoding=encoding;};this.XFR.prototype=_proto;_proto.symbolToClass=function(symbol){var klass=_symbolToClassMap[symbol];return klass;};_proto.classToSymbol=function(obj){var type=typeof(obj);var symbol=_typeToSymbolMap[type];if(symbol)return symbol;for(symbol in _symbolToClassMap){if(obj instanceof _symbolToClassMap[symbol])return symbol;}};_proto.createObject=function(symbol){var klass=this.symbolToClass(symbol);return new klass();};_proto.createValue=function(symbol,value){if(value=='true')return true;if(value=='false')return false;var klass=this.symbolToClass(symbol);if(klass===String)return value;return new klass(value);};_proto.encodeComponent=function(str){return this.encoding=='base64'?ecma.data.base64.encode(str):ecma.window.encodeURIComponent(str);};_proto.decodeComponent=function(str){return this.encoding=='base64'?ecma.data.base64.decode(str):ecma.window.decodeURIComponent(str);};_proto.parse=function(str){if(!ecma.util.defined(str))return;var CHash=this.symbolToClass('%');var CArray=this.symbolToClass('@');var CScalar=this.symbolToClass('$');var m=str.match(/^([\%\$\@]){/);if(!m)throw'str must begin with "%{", "@{", or "${"';if(m[1]=='$'){var value=str.substr(2,(str.length-3));return this.decodeComponent(value);}
var root=this.createObject(m[1],null);var pos=2;var node=root;var nodeParent=root;var parents=[];while(true){var open_pos=str.indexOf('{',pos);var close_pos=str.indexOf('}',pos);if(close_pos<open_pos&&close_pos>=0){node=parents.pop()||root;pos=close_pos+1;continue;}
if(open_pos<0)break;var key=str.substr(pos,(open_pos-pos));var len=key.length-1;var type=key.substr(len,1);key=key.substr(0,len);key=this.decodeComponent(key);pos=open_pos+1;if(type=='%'||type=='@'){parents.push(node);nodeParent=node;node=this.createObject(type,nodeParent);if(ecma.util.isa(nodeParent,CHash)){nodeParent.setValue(key,node);}else if(ecma.util.isa(nodeParent,CArray)){nodeParent.push(node);}}else{if(!this.symbolToClass(type))throw'invalid data type: '+type;open_pos=str.indexOf('{',pos);if(open_pos>=0&&open_pos<close_pos)close_pos=open_pos-1;var vstr=str.substr(pos,(close_pos-pos));vstr=this.decodeComponent(vstr);var value=this.createValue(type,vstr);if(ecma.util.isa(node,CHash)){node.setValue(key,value);}else if(ecma.util.isa(node,CArray)){node.push(value);}else if(node&&node.setValue instanceof Function){node.setValue(value);}else{nodeParent+=value;}
pos=close_pos+1;}}
return root;};_proto.format=function(obj){var result='';var symbol=this.classToSymbol('');if(!ecma.util.defined(obj))return symbol+'{}';if(obj.toXFR){return obj.toXFR();}else if(ecma.util.isArray(obj)){var result='@{';for(var i=0;i<obj.length;i++){result+=this.format(obj[i]);}
return result+'}';}else if(ecma.util.isAssociative(obj)){var result=null;if(typeof(obj.toUTCString)=='function'){result='${'+this.encodeComponent(obj.toUTCString())+'}';}else{result='%{';for(var k in obj){var v=obj[k];result+=this.encodeComponent(k)+this.format(v);}
result+='}';}
return result;}else{return'${'+this.encodeComponent(obj)+'}';}};});ECMAScript.Extend('data',function(ecma){this.xfr=new ecma.data.XFR('base64');});ECMAScript.Extend('data.json',function(ecma){var number='(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)';var oneChar='(?:[^\\0-\\x08\\x0a-\\x1f\"\\\\]'
+'|\\\\(?:[\"/\\\\bfnrt]|u[0-9A-Fa-f]{4}))';var string='(?:"'+oneChar+'*?"|\''+oneChar+'*?\')';var jsonToken=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]'
+'|'+number
+'|'+string
+')','g');var escapeSequence=new RegExp('\\\\(?:([^u])|u(.{4}))','g');var escapes={'"':'"','/':'/','\\':'\\','b':'\b','f':'\f','n':'\n','r':'\r','t':'\t'};function unescapeOne(_,ch,hex){return ch?escapes[ch]:String.fromCharCode(parseInt(hex,16));}
var EMPTY_STRING=new String('');var firstTokenCtors={'{':Object,'[':Array};var hop=Object.hasOwnProperty;this.parse=function(json,opt_reviver){var toks=json.match(jsonToken);var result;var tok=toks[0];var topLevelPrimitive=false;if('{'===tok){result={};}else if('['===tok){result=[];}else{result=[];topLevelPrimitive=true;}
var key;var stack=[result];for(var i=1-topLevelPrimitive,n=toks.length;i<n;++i){tok=toks[i];var cont;switch(tok.charCodeAt(0)){default:cont=stack[0];cont[key||cont.length]=+(tok);key=void 0;break;case 0x22:case 0x27:tok=tok.substring(1,tok.length-1);if(tok.indexOf('\\')!==-1){tok=tok.replace(escapeSequence,unescapeOne);}
cont=stack[0];if(!key){if(cont instanceof Array){key=cont.length;}else{key=tok||EMPTY_STRING;break;}}
cont[key]=tok;key=void 0;break;case 0x5b:cont=stack[0];stack.unshift(cont[key||cont.length]=[]);key=void 0;break;case 0x5d:stack.shift();break;case 0x66:cont=stack[0];cont[key||cont.length]=false;key=void 0;break;case 0x6e:cont=stack[0];cont[key||cont.length]=null;key=void 0;break;case 0x74:cont=stack[0];cont[key||cont.length]=true;key=void 0;break;case 0x7b:cont=stack[0];stack.unshift(cont[key||cont.length]={});key=void 0;break;case 0x7d:stack.shift();break;}}
if(topLevelPrimitive){if(stack.length!==1){throw new Error();}
result=result[0];}else{if(stack.length){throw new Error();}}
if(opt_reviver){var walk=function(holder,key){var value=holder[key];if(value&&typeof value==='object'){var toDelete=null;for(var k in value){if(hop.call(value,k)&&value!==holder){var v=walk(value,k);if(v!==void 0){value[k]=v;}else{if(!toDelete){toDelete=[];}
toDelete.push(k);}}}
if(toDelete){for(var i=toDelete.length;--i>=0;){delete value[toDelete[i]];}}}
return opt_reviver.call(holder,key,value);};result=walk({'':result},'');}
return result;};this.format=function(obj){var hasOwnProperty=Object.hasOwnProperty;function _escape(str){return str.replace(/(["])/,'\\$1');}
function _format(obj){if(!ecma.util.defined(obj)){return'null';}else if(ecma.util.isArray(obj)){var items=[];for(var i=0;i<obj.length;i++){items.push(_format(obj[i]));}
return'['+items.join(',')+']';}else if(ecma.util.isAssociative(obj)){if(typeof(obj.toUTCString)=='function'){return'"'+obj.toUTCString()+'"';}else{var items=[];for(var k in obj){if(hasOwnProperty.call(obj,k)){var v=obj[k];items.push('"'+k+'":'+_format(v));}}}
return'{'+items.join(',')+'}';}else{return'"'+obj+'"';}}
return _format(obj);};});ECMAScript.Extend('http',function(ecma){var proto={};this.Location=function(uri){if(uri){if(uri instanceof ecma.http.Location){this.copyLocation(uri);}else{this.parseUri(uri);}}else{this.copyDocumentLocation();}};this.Location.prototype=proto;proto.copyDocumentLocation=function(){this.copyLocation(ecma.document.location);};proto.copyLocation=function(loc){try{this.protocol=loc.protocol;this.hostname=loc.hostname;this.port=loc.port;this.pathname=loc.pathname;this.search=loc.search;this.hash=loc.hash;}catch(ex){this.protocol='';this.hostname='';this.port='';this.pathname='';this.search='';this.hash='';}};proto.getOrigin=function(){var origin=this.protocol+'//'+this.hostname;if(this.port)origin+=':'+this.port;return origin;};proto.isSameOrigin=function(loc){if(!(loc instanceof ecma.http.Location)){loc=new ecma.http.Location(loc);}
return loc.getOrigin()==this.getOrigin();};proto.isSameDocument=function(loc){if(!(loc instanceof ecma.http.Location)){loc=new ecma.http.Location(loc);}
return loc.getDocumentUri()==this.getDocumentUri();};proto.getUri=function(){return this.getOrigin()+this.getAddress()};proto.getHref=proto.getUri;proto.getDocumentUri=function(){return this.getOrigin()+this.pathname;};proto.getHref=function(){return new ecma.http.Location().isSameOrigin(this)?this.getAddress():this.getUri();};proto.getAddress=function(){return this.pathname+this.search+this.hash;};proto.getSearch=function(){return this.search?this.search.replace(/^\?/,''):'';};proto.getHash=function(){return this.hash?this.hash.replace(/^#/,''):'';};proto.addParameter=function(key,value){key=encodeURIComponent(key);value=encodeURIComponent(value);var prefix=this.search?this.search+'&':'?';return this.search=prefix+key+'='+value;};proto.getParameters=function(){var result={};if(!this.search)return result;var str=this.search.replace(/^\?/,'');if(!str)return result;var kvpairs=str.split(/[&;]/);for(var i=0;i<kvpairs.length;i++){var parts=kvpairs[i].split(/=/);var k=decodeURIComponent(parts.shift());var v=decodeURIComponent(parts.join());if(k==""&&v=="")continue;result[k]=result[k]!=undefined?result[k]instanceof Array?result[k].concat(v):[result[k],v]:v;}
return result;};proto.parseUri=function(uri){this.copyDocumentLocation();var href=undefined;if(uri.indexOf('//')==0){href=this.protocol+uri;}else if((uri.indexOf('?')==0)||(uri.indexOf('#')==0)){href=this.getOrigin()+this.pathname+uri;}else if(uri.indexOf('/')==0){href=this.getOrigin()+uri;}else if(uri.indexOf('://')==-1){var base=this.pathname.match(/\/$/)?this.pathname:ecma.data.addr_parent(this.pathname)+'/';href=this.getOrigin()+base+uri;}else{href=uri;}
var m=href.match(/^([^\/]+:)?\/\/([^\/#?:]*):?([0-9]*)([^#?]*)(\??[^#]*)(#?.*)/);if(!m)throw'cannot parse uri';this.protocol=m[1]?m[1].toLowerCase():ecma.document.location.protocol;this.hostname=m[2].toLowerCase();this.port=m[3]||'';this.pathname=m[4]||'';this.search=m[5]||'';this.hash=m[6]||'';};});ECMAScript.Extend('http',function(ecma){var _documentLocation=null
function _getDocumentLocation(){if(!_documentLocation)_documentLocation=new ecma.http.Location();return _documentLocation;}
this.HTTP_STATUS_NAMES={100:'Continue',101:'SwitchingProtocols',200:'Ok',201:'Created',202:'Accepted',203:'NonAuthoritativeInformation',204:'NoContent',205:'ResetContent',206:'PartialContent',300:'MultipleChoices',301:'MovedPermanently',302:'Found',303:'SeeOther',304:'NotModified',305:'UseProxy',306:'Unused',307:'TemporaryRedirect',400:'BadRequest',401:'Unauthorized',402:'PaymentRequired',403:'Forbidden',404:'NotFound',405:'MethodNotAllowed',406:'NotAcceptable',407:'ProxyAuthenticationRequired',408:'RequestTimeout',409:'Conflict',410:'Gone',411:'LengthRequired',412:'PreconditionFailed',413:'RequestEntityTooLarge',414:'RequestURITooLong',415:'UnsupportedMediaType',416:'RequestedRangeNotSatisfiable',417:'ExpectationFailed',500:'InternalServerError',501:'NotImplemented',502:'BadGateway',503:'ServiceUnavailable',504:'GatewayTimeout',505:'HTTPVersionNotSupported'};this.isSameOrigin=function(uri1,uri2){if(!(uri1))return false;var loc1=uri1 instanceof ecma.http.Location?uri1:new ecma.http.Location(uri1);var loc2=uri2||_getDocumentLocation();return loc1.isSameOrigin(loc2);};});ECMAScript.Extend('http',function(ecma){this.XHR_UNINITIALIZED=0;this.XHR_LOADING=1;this.XHR_LOADED=2;this.XHR_INTERACTIVE=3;this.XHR_COMPLETE=4;this.XHR_STATE_NAMES=['Uninitialized','Loading','Loaded','Interactive','Complete'];this.newXHR=function(){try{return new XMLHttpRequest();}catch(ex){try{return new ActiveXObject('Msxml2.XMLHTTP');}catch(ex){return new ActiveXObject('Microsoft.XMLHTTP');}}};this.Request=function(uri,options){this.uri=uri;this.method='GET';this.asynchronous=true;this.body=null;this.headers={'Accept':'*/*','Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'};this.events=[];var props={};for(var k in options){if(k.match(/^on/)){this.addEventListener(k,options[k]);}else{props[k]=options[k];}}
ecma.util.overlay(this,props);};this.Request.prototype.getEventListeners=function(type){var name=type.toLowerCase().replace(/^on/,'');return this.events[name];};this.Request.prototype.setEventListeners=function(type,listeners){var name=type.toLowerCase().replace(/^on/,'');this.events[name]=listeners;};this.Request.prototype.addEventListener=function(type,func,scope,args){var name=type.toLowerCase().replace(/^on/,'');var group=this.events[name];if(!group)group=this.events[name]=[];if(!scope)scope=this;if(!args)args=[];group.push([func,scope,args]);};this.Request.prototype.removeEventListener=function(type,func){var name=type.toLowerCase().replace(/^on/,'');var group=this.events[name];if(!group)return;for(var i=0;i<group.length;i++){var cb=group[i];var cbFunc=ecma.util.isArray(group[i])?group[i][0]:group[i]
if(cbFunc===func){group.splice(i--,1);break;}}};this.Request.prototype.getHeader=function(k,v){return this.headers[k];};this.Request.prototype.setHeader=function(k,v){return this.headers[k]=v;};this.Request.prototype.submit=function(body,cb){this.body=this.parseBody(body);this.cb=cb;return this._submit();};this.Request.prototype._submit=function(){this.xhr=ecma.http.newXHR();this.xhr.open(this.method.toUpperCase(),this.uri,this.asynchronous);this.xhr.onreadystatechange=js.lang.Callback(this.onStateChange,this);for(var k in this.headers){this.xhr.setRequestHeader(k,this.headers[k]);}
this.fireEvent('Create');this.xhr.send(this.body);};this.Request.prototype.resubmit=function(){return this._submit();};this.Request.prototype.parseBody=function(body){if(!body)return null;if(ecma.util.isObject(body)){try{var result='';for(var k in body){var name=encodeURIComponent(k);var value=encodeURIComponent(body[k]);result+=name+'='+value+'&';}
return result;}catch(ex){return body;}}
return body;};this.Request.prototype.parseResponse=function(){};this.Request.prototype.onStateChange=function(){var state=this.xhr.readyState;if(state==ecma.http.XHR_COMPLETE){if(this.canComplete())this.completeRequest();}else{var name=ecma.http.XHR_STATE_NAMES[state];this.fireEvent(name);}};this.Request.prototype.canComplete=function(){return true;};this.Request.prototype.completeRequest=function(){var state=this.xhr.readyState;this.parseResponse();var status=this.xhr.status||500;if(this.cb)this.invokeListener(this.cb);var name=ecma.http.HTTP_STATUS_NAMES[status];this.fireEvent(status);if(name)this.fireEvent(name);if(status>=200&&status<300){this.fireEvent('Success');}else{this.fireEvent('NotSuccess');}
if(status>=500&&status<600){this.fireEvent('Failure');}
var name=ecma.http.XHR_STATE_NAMES[state];this.fireEvent(name);};this.Request.prototype.fireEvent=function(type){if(this['on'+type]){this['on'+type].call(this,this);}
var name=typeof(type)=='number'?type:type.toLowerCase();var group=this.events[name];if(!group)return;ecma.util.step(group,this.invokeListener,this);};this.Request.prototype.invokeListener=function(cb){var func,scope,args;var args=[this];if(ecma.util.isArray(cb)){func=cb[0];scope=cb[1];args=args.concat(cb[2]);}else{func=cb;scope=this;}
func.apply(scope,args);};});ECMAScript.Extend('http',function(ecma){var _proto={};var _xfr=new ecma.data.XFR();this.Cookies=function(){};this.Cookies.prototype=_proto;_proto.encode=function(value){return _xfr.format(value);};_proto.decode=function(str){return _xfr.parse(str);};_proto.setObject=function(name,value,days){value=this.encode(value);return this.set(name,value,days);};_proto.getObject=function(name){value=this.get(name);return value?this.decode(value):null;};_proto.set=function(name,value,days){var expires="";if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));expires="; expires="+date.toGMTString();}
ecma.document.cookie=name+"="+value+expires+"; path=/";};_proto.get=function(name){var prefix=name+"=";var parts=ecma.document.cookie.split(';');for(var i=0;i<parts.length;i++){var c=parts[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(prefix)==0)return c.substring(prefix.length,c.length);}
return null;};_proto.remove=function(name){this.set(name,"",-1);};});ECMAScript.Extend('action',function(ecma){this.addActionListener=function(klass,name,listener,scope,args){if(!klass.prototype.globalActionListeners){klass.prototype.globalActionListeners=[];}
var inst=new klass();var al=inst.createActionListener(name,listener,scope,args);klass.prototype.globalActionListeners.push(al);return al;};this.removeActionListener=function(name,listener,scope){if(!klass.prototype.globalActionListeners)return;var inst=new klass();return inst.removeActionListenerFrom(this.globalActionListeners,arguments);};var proto={};this.ActionDispatcher=function(){this.actionListeners=[];};this.ActionDispatcher.prototype=proto;proto.normalizeActionName=function(name){if(!name)return;if(!name.toLowerCase)return;return name.toLowerCase().replace(/^on/,'');};proto.createActionListener=function(name,listener,scope,args){name=this.normalizeActionName(name);if(!listener)throw'Action listener callback function required';if(typeof(listener)!='function')'Action listener callback must be a function';this.removeActionListener(name,listener,scope);return new ecma.action.ActionListener(this,name,listener,scope,args);};proto.addActionListener=function(name,listener,scope,args){var al=this.createActionListener.apply(this,arguments);this.actionListeners.push(al);return al;};proto.removeActionListener=function(name,listener,scope){return this.removeActionListenerFrom(this.actionListeners,arguments);};proto.removeActionListenerFrom=function(listeners,argv){var args=ecma.util.args(argv);var name=args.shift();var listener=args.shift();var scope=args.shift();if(typeof(name)=='string'){name=this.normalizeActionName(name);}else{al=name;name=al.name;listener=al.listener;scope=al.scope;}
for(var i=0,props;props=listeners[i];i++){if(props.name!==name)continue;if(props.listener!==listener)continue;if(props.scope!==scope)continue;listeners.splice(i--,1);break;}};proto.getActionListenersByName=function(name){var result=[];if(this.globalActionListeners){for(var i=0,props;props=this.globalActionListeners[i];i++){if(props.name==name||props.name==='*')result.push(props);}}
for(var i=0,props;props=this.actionListeners[i];i++){if(props.name==name||props.name==='*')result.push(props);}
return result;}
proto.executeAction=function(){var args=ecma.util.args(arguments);var actionEvent=this.createActionEvent(args.shift());var name=actionEvent.name;var group=this.getActionListenersByName(name);args.unshift(actionEvent);ecma.util.step(group,this.executeActionListener,this,args);};proto.executeActionListener=function(){var argz=ecma.util.args(arguments);var listener=argz.shift();listener.invoke.apply(listener,argz);};proto.dispatchAction=function(name){var args=ecma.util.args(arguments);var actionEvent=this.createActionEvent(args.shift());var name=actionEvent.name;var group=this.getActionListenersByName(name);args.unshift(actionEvent);ecma.util.step(group,this.dispatchActionListener,this,args);};proto.dispatchActionListener=function(){var argz=ecma.util.args(arguments);var listener=argz.shift();listener.spawn.apply(listener,argz);};proto.createActionEvent=function(arg1){if(ecma.util.isa(arg1,ecma.action.ActionEvent)){arg1.setDispatcher(this);return arg1;}
var name=this.normalizeActionName(arg1);return new ecma.action.ActionEvent(name,this);};proto.dispatchClassAction=function(){var args=ecma.util.args(arguments);var funcName=args.shift();var funcEx=undefined;try{if(typeof(this[funcName])=='function'){this[funcName].apply(this,args);}}catch(ex){funcEx=ex;}
this.dispatchAction.apply(this,arguments);if(funcEx){throw funcEx;}};proto.executeClassAction=function(){var args=ecma.util.args(arguments);var funcName=args.shift();var funcEx=undefined;try{if(typeof(this[funcName])=='function'){this[funcName].apply(this,args);}}catch(ex){funcEx=ex;}
this.executeAction.apply(this,arguments);if(funcEx){throw funcEx;}};});ECMAScript.Extend('action',function(ecma){var proto={};this.ActionListener=function(dispatch,name,listener,scope,args){this.dispatch=dispatch;this.name=name;this.listener=listener;this.scope=scope;this.args=args;if(0){this.stack=ecma.error.getStackTrace();}};this.ActionListener.prototype=proto;proto.invoke=function(){var argz=ecma.util.args(arguments);if(this.args)argz=argz.concat(this.args);return this.listener.apply(this.scope||this,argz);};proto.spawn=function(){var argz=ecma.util.args(arguments);if(this.args)argz=argz.concat(this.args);ecma.thread.spawn(this.listener,this.scope||this,argz,[this.onException,this]);};proto.remove=function(name){return this.dispatch.removeActionListener(this);};proto.onException=function(ex){var logMessage=ex.toString()+' (while invoking an action listener)';if(this.stack){logMessage+=' The action listener was added here:'+"\n";for(var i=2;i<this.stack.length;i++){var src=this.stack[i].match(/(@.*?:\d+)$/);if(src)logMessage+='    '+src[1]+"\n";}}
ecma.console.log(logMessage);if(ex.toString().match(/freed script/))return this.remove();throw ex;};});ECMAScript.Extend('action',function(ecma){var proto={};this.ActionEvent=function(name,dispatcher){this.name=null;this.dispatcher=null;this.setName(name);this.setDispatcher(dispatcher);};this.ActionEvent.prototype=proto;proto.getName=function(){return this.name;};proto.setName=function(name){return this.name=name;};proto.getDispatcher=function(){return this.dispatcher;};proto.setDispatcher=function(dispatcher){return this.dispatcher=dispatcher;};});ECMAScript.Extend('platform',function(ecma){var _browsers=null;var _platforms=null;var _info=null;var _pkg=this;this.getInfo=function(){return _info;};this.Info=function(){this.browser=this.searchString(_browsers)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.os=this.searchString(_platforms)||"an unknown OS";},this.Info.prototype=proto={};proto.searchString=function(data){for(var i=0;i<data.length;i++){var dataString=data[i].string;var dataProp=data[i].prop;this.versionSearchString=data[i].versionSearch||data[i].identity;if(dataString){if(dataString.indexOf(data[i].subString)!=-1)
return data[i].identity;}
else if(dataProp)
return data[i].identity;}};proto.searchVersion=function(dataString){var index=dataString.indexOf(this.versionSearchString);if(index==-1)return;return parseFloat(dataString.substring(index+this.versionSearchString.length+1));};_browsers=[{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}];_platforms=[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.userAgent,subString:"iPhone",identity:"iPhone/iPod"},{string:navigator.platform,subString:"Linux",identity:"Linux"}];_info=new _pkg.Info();this.isIE=_info.browser=='Explorer';this.isIE8=_info.browser=='Explorer'&&_info.version==8;});ECMAScript.Extend('dom',function(ecma){this.browser={isIE:!!(ecma.window.attachEvent&&ecma.window.navigator.userAgent.indexOf('Opera')===-1),isOpera:ecma.window.navigator.userAgent.indexOf('Opera')>-1,isWebKit:ecma.window.navigator.userAgent.indexOf('AppleWebKit/')>-1,isGecko:ecma.window.navigator.userAgent.indexOf('Gecko')>-1&&ecma.window.navigator.userAgent.indexOf('KHTML')===-1,isMobileSafari:!!ecma.window.navigator.userAgent.match(/Apple.*Mobile.*Safari/)},this.getEventPointer=function(event){var docElement=ecma.document.documentElement,body=ecma.dom.getRootElement()||{scrollLeft:0,scrollTop:0};return{x:event.pageX||(event.clientX+
(docElement.scrollLeft||body.scrollLeft)-
(docElement.clientLeft||0)),y:event.pageY||(event.clientY+
(docElement.scrollTop||body.scrollTop)-
(docElement.clientTop||0))};};this.getEventTarget=function(event){if(!event.target&&event.srcElement)return event.srcElement;return event.target;};this.addEventListener=function(target,type,listener,scope,args,useCapture){var elem=ecma.dom.getElement(target);if(!elem)throw new Error('No such element');if(!useCapture)useCapture=false;if(typeof(type)=='function')throw new Error('Missing argument: event type');var name=type.toLowerCase().replace(/^on/,'');var func=scope||args?function(){var argz=ecma.util.args(arguments);return listener.apply(scope||elem,argz.concat(args));}:listener;if(target===ecma.document&&name=='load'){ecma.dom.content.addActionListener('load',func);}else if(elem.addEventListener){elem.addEventListener(name,func,useCapture);}else if(elem.attachEvent){elem.attachEvent('on'+name,func);}else{throw new Error('Cannot add event listener');}
return func;};this.removeEventListener=function(target,type,listener,scope,useCapture){var elem=ecma.dom.getElement(target);if(!elem)throw new Error('No such element');if(!useCapture)useCapture=false;var name=type.toLowerCase().replace(/^on/,'');if(elem.removeEventListener){elem.removeEventListener(name,listener,useCapture);}else if(elem.detachEvent){elem.detachEvent('on'+name,listener);}else{throw'Cannot remove event listener';}}
this.stopEvent=function(event){try{event.stopped=true;event.preventDefault();event.stopPropagation();}catch(ex){if(event){event.cancelBubble=true;event.returnValue=false;}}};this.setTimeout=function(func,delay,scope,args,excb){if(typeof(func)!='function')throw'Invalid argument: func';var cb=excb?function(){try{func.apply(scope||this,args||[]);}catch(ex){ecma.lang.callback(excb,scope,[ex]);}}:function(){func.apply(scope||this,args||[]);};return ecma.window.setTimeout(cb,delay);};this.clearTimeout=function(id){return ecma.window.clearTimeout(id);};this.setInterval=function(func,interval,scope,args){var cb=function(){func.apply(scope||this,args||[]);};return ecma.window.setInterval(cb,interval);};this.clearInterval=function(id){return ecma.window.clearInterval(id);};this.waitUntil=function(func,cond,delay,scope,args){if(!ecma.util.defined(delay))delay=10;var decay=2;var cb=function(){if(cond.apply(scope||this,args||[])){func.apply(scope||this,args||[]);return true;}
return false;}
if(cb())return;var waitFunc;waitFunc=function(){if(cb())return;delay*=decay;ecma.dom.setTimeout(waitFunc,delay,scope,args);};ecma.dom.setTimeout(waitFunc,delay,scope,args);};this.getRootElement=function(){return ecma.document.rootElement||ecma.dom.getBody()||ecma.document.documentElement||ecma.document.lastChild||ecma.document;};this.getHead=function(){var heads=ecma.document.getElementsByTagName('head');return heads&&heads.length>0?heads[0]:ecma.dom.getRootElement();};this.getBody=function(){var bodies=ecma.document.getElementsByTagName('body');return bodies&&bodies.length>0?bodies[0]:undefined;};this.getFrame=function(id){if(typeof(id)=='object')return id;return frames[id]||ecma.dom.getElement(id);};this.getContentWindow=function(frameid){var iframe=ecma.dom.getFrame(frameid);if(!iframe)return;return iframe.contentWindow||iframe.window;};this.getContentDocument=function(frameid){var iframe=ecma.dom.getFrame(frameid);if(!iframe)return;return iframe.contentWindow?iframe.contentWindow.document:iframe.contentDocument||iframe.document;};this.getContentJS=function(frameid){try{var frame=ecma.dom.getFrame(frameid);var doc=ecma.dom.getContentDocument(frame);var win=ecma.dom.getContentWindow(frame);if(!ecma.http.isSameOrigin(ecma.document.location.href,doc.location.href)){return null;}
return win.js||new ECMAScript.Class(win,doc);}catch(ex){return null;}};this.getElementsByNodeType=function(elem,type){elem=ecma.dom.getElement(elem);if(!elem)return;var result=[];_getElementsByNodeType(elem,type,result,elem);return result;};function _getElementsByNodeType(elem,type,result,topElem){if(!elem)return;if(elem.nodeType==type&&elem!==topElem){result.push(elem);}
if(elem.childNodes){for(var i=0,node;node=elem.childNodes[i];i++){_getElementsByNodeType(node,type,result,topElem);}}}
this.getElementsByClassName=function(elem,className){elem=ecma.dom.getElement(elem);if(typeof(elem.getElementsByClassName)=='function'){return elem.getElementsByClassName(className);}
var result=[];_getElementsByClassName(elem,className,result);return result;};function _getElementsByClassName(elem,className,result){if(elem.hasChildNodes()){for(var i=0,node;node=elem.childNodes[i];i++){if(ecma.dom.hasClassName(node,className))result.push(node);_getElementsByClassName(node,className,result);}}}
this.getElementsByAttribute=function(elem,name,value){elem=ecma.dom.getElement(elem);if(!elem)return;var result=[];var values=ecma.util.isArray(value)?value:[value];_getElementsByAttribute(elem,name,values,result,elem);return result;};function _getElementsByAttribute(elem,name,values,result,topElem){if(!elem)return;if(elem.nodeType==ecma.dom.constants.ELEMENT_NODE&&elem!==topElem){var attr=ecma.dom.getAttribute(elem,name);if(ecma.util.grep(function(v){return attr===v;},values)){result.push(elem);}}
if(elem.childNodes){for(var i=0,node;node=elem.childNodes[i];i++){_getElementsByAttribute(node,name,values,result,topElem);}}}
this.getElementsByTagName=function(elem,spec){var tagNames=ecma.util.isArray(spec)?spec:[spec];for(var i=0;i<tagNames.length;i++){tagNames[i]=tagNames[i].toUpperCase();}
var result=[];elem=ecma.dom.getElement(elem);_getElementsByAttribute(elem,'tagName',tagNames,result,elem);return result;};this.canvas={getPosition:function(){var pos={windowX:ecma.dom.canvas.windowX(),windowY:ecma.dom.canvas.windowY(),scrollX:ecma.dom.canvas.scrollX(),scrollY:ecma.dom.canvas.scrollY(),pageX:ecma.dom.canvas.pageX(),pageY:ecma.dom.canvas.pageY()};pos.width=pos.windowX<pos.pageX?pos.pageX:pos.windowX;pos.height=pos.windowY<pos.pageY?pos.pageY:pos.windowY;return pos;},windowX:function(){var windowX=ecma.window.innerWidth||(ecma.document.documentElement&&ecma.document.documentElement.clientWidth)||ecma.dom.getRootElement().clientWidth||(ecma.document.documentElement&&ecma.document.documentElement.offsetWidth);return ecma.util.asInt(windowX);},windowY:function(){var windowY=ecma.window.innerHeight||(ecma.document.documentElement&&ecma.document.documentElement.clientHeight)||ecma.dom.getRootElement().clientHeight||(ecma.document.documentElement&&ecma.document.documentElement.offsetHeight);return ecma.util.asInt(windowY);},scrollX:function(){var scrollX=(ecma.document.documentElement&&ecma.document.documentElement.scrollLeft)||ecma.window.pageXOffset||ecma.dom.getRootElement().scrollLeft;return ecma.util.asInt(scrollX);},scrollY:function(){var scrollY=(ecma.document.documentElement&&ecma.document.documentElement.scrollTop)||ecma.window.pageYOffset||ecma.dom.getRootElement().scrollTop;return ecma.util.asInt(scrollY);},pageX:function(){var pageX=Math.max(ecma.util.asInt(ecma.document.documentElement.scrollWidth),ecma.util.asInt(ecma.dom.getRootElement().scrollWidth),ecma.util.asInt(ecma.dom.getRootElement().offsetWidth))
return ecma.util.asInt(pageX);},pageY:function(){var pageY=Math.max(ecma.util.asInt(ecma.document.documentElement.scrollHeight),ecma.util.asInt(ecma.dom.getRootElement().scrollHeight),ecma.util.asInt(ecma.dom.getRootElement().offsetHeight))
return ecma.util.asInt(pageY);}};this.getViewportPosition=function(){var c=ecma.dom.canvas.getPosition();return{'left':c.scrollX,'top':c.scrollY,'width':c.windowX,'height':c.windowY};};this.getElement=function(unk){return typeof(unk)=='object'?unk:unk instanceof Object?unk:ecma.document.getElementById?ecma.document.getElementById(unk):ecma.document.all?ecma.document.all[unk]:ecma.document.layers?ecma.document.layers[unk]:false;};this.getParentElement=function(elem,tagName){elem=ecma.dom.getElement(elem);while(elem&&elem.parentNode){if(elem.parentNode.nodeType==1){if(!tagName||elem.parentNode.tagName==tagName){return elem.parentNode;}}
elem=elem.parentNode;}
return undefined;};this.getDescendantById=function(elem,id){elem=ecma.dom.getElement(elem);var result=null;if(elem.hasChildNodes()){for(var i=0,node;node=elem.childNodes[i];i++){if(node.id==id){result=node;}else{result=ecma.dom.getDescendantById(node,id);}
if(result)break;}}
return result;};this.createElement=function(){var args=ecma.util.args(arguments);var tagName=args.shift();if(!tagName)return;var attrs=args.shift();var children=args.shift();if(ecma.util.isArray(attrs)){children=attrs;attrs=undefined;}
var elem=undefined;if(tagName.nodeType){elem=tagName;}else if(tagName.indexOf('#')==0){var parts=tagName.split('=',2);if(parts.length==2){tagName=parts[0];if(!attrs)attrs={};if(attrs.nodeValue)throw'Multiple nodeValues';attrs.nodeValue=parts[1];}
if(tagName=='#text'){elem=ecma.document.createTextNode(attrs.nodeValue);}else if(tagName=='#comment'){elem=ecma.document.createComment(attrs.nodeValue);}else{throw'Component not available: '+tagName;}
if(children)throw'Cannot append children to a #text node';return elem;}else{var parts=tagName.match(/^([^#\.=]+)(#[^=\.]+)?(\.[^=]+)?(=.*)?/);if(!parts)throw'Invalid tagName specification: '+tagName;if(!attrs)attrs={};tagName=parts[1];if(parts[2]&&!attrs['id']){attrs['id']=parts[2].substr(1);}
if(parts[3]&&!attrs['class']){attrs['class']=parts[3].substr(1).split('.').join(' ');}
if(parts[4]&&!attrs['innerHTML']){attrs['innerHTML']=parts[4].substr(1);}
elem=attrs&&attrs.namespace&&ecma.document.createElementNS?ecma.document.createElementNS(attrs.namespace,tagName.toUpperCase()):ecma.document.createElement(tagName.toUpperCase());}
if(attrs){for(var k in attrs){if(!k)continue;if(k.toLowerCase()=='namespace')continue;var v=attrs[k];if(k.toLowerCase()=='style'&&typeof(v)=='object'){for(var k2 in v){var v2=v[k2];ecma.dom.setStyle(elem,k2,v2);}}else{ecma.dom.setAttribute(elem,k,v);}}}
if(children){ecma.dom.appendChildren(elem,ecma.dom.createElements.apply(ecma.dom,children));}
return elem;};this.createElements=function(){var args=ecma.util.args(arguments);var elems=new Array();while(args&&args.length>0){var attrs=null;var children=null;var childNodes=null;var elem=null;var tag=args.shift();if(!tag)continue;if(typeof(tag)!='string'&&tag.nodeType){elem=tag;}else{if(ecma.util.isAssociative(args[0])&&!args[0].nodeType){attrs=args.shift();}
if(ecma.util.isArray(args[0])){children=args.shift();}
elem=ecma.dom.createElement(tag,attrs,children);}
elems.push(elem);}
return elems;};this.replaceChildren=function(elem,children){ecma.dom.removeChildren(elem);ecma.dom.appendChildren(elem,children);};this.appendChildren=function(arg1,arg2){var elem,children;if(ecma.util.isArray(arg1)){elem=arg2;children=arg1;}else{elem=arg1;children=arg2;}
elem=ecma.dom.getElement(elem);if(!ecma.util.defined(elem))throw'elem not defined';if(!ecma.util.defined(children))throw'missing children';var len=children.length||0;for(var i=0;i<children.length;){var child=children[i];if(!ecma.util.defined(child))throw'undefined child node';if(child instanceof Array){ecma.dom.appendChildren(elem,child);}else{elem.appendChild(children[i]);}
i++;if(children.length!=len){i-=(len-children.length);len=children.length;}}};this.appendChild=function(elem,child){ecma.dom.getElement(elem).appendChild(child);};this.prependChild=function(elem,child){var p=ecma.dom.getElement(elem)
if(p.hasChildNodes()){p.insertBefore(child,p.firstChild);}else{p.appendChild(child);}};this.insertChildrenAfter=function(elem,children){elem=ecma.dom.getElement(elem);if(!ecma.util.defined(elem))throw'elem not defined';if(!ecma.util.defined(children))throw new ecma.window.Error('missing children');for(var i=0;i<children.length;i++){var child=children[i];if(!ecma.util.defined(child))throw'undefined child node';if(child instanceof Array){elem=ecma.dom.insertChildrenAfter(elem,child);}else{elem=ecma.dom.insertAfter(child,elem);}}
return elem;};this.insertChildrenBefore=function(elem,children){elem=ecma.dom.getElement(elem);if(!ecma.util.defined(elem))throw'elem not defined';if(!ecma.util.defined(children))throw new ecma.window.Error('missing children');for(var i=0;i<children.length;i++){var child=children[i];if(!ecma.util.defined(child))throw'undefined child node';if(child instanceof Array){elem=ecma.dom.insertChildrenBefore(elem,child);}else{elem.parentNode.insertBefore(child,elem);}}
return elem;};this.insertBefore=function(elem,target){if(!(ecma.util.defined(target)&&ecma.util.defined(elem)))return;var p=target.parentNode;if(!p)throw'undefined parent node';p.insertBefore(elem,target);};this.insertAfter=function(elem,target){if(!(ecma.util.defined(target)&&ecma.util.defined(elem)))return;var p=target.parentNode;if(!p)throw'undefined parent node';if(p.lastChild===target){p.appendChild(elem);ecma.lang.assert(p.lastChild===elem);}else{p.insertBefore(elem,target.nextSibling);ecma.lang.assert(target.nextSibling===elem);}
return elem;};this.removeChildren=function(elem){elem=ecma.dom.getElement(elem);if(!(elem&&elem.childNodes))return;for(var idx=elem.childNodes.length-1;idx>=0;idx--){elem.removeChild(elem.childNodes[idx]);}};this.removeElement=function(elem){elem=ecma.dom.getElement(elem);if(!elem)return;var pElem=elem.parentNode;if(!pElem)return;return pElem.removeChild(elem);};this.removeElements=function(){var args=ecma.util.args(arguments);while(args&&args.length>0){ecma.dom.removeElement(args.shift());}};this.removeElementOrphanChildren=function(elem){elem=ecma.dom.getElement(elem);if(!elem)return;var pElem=elem.parentNode;if(!pElem)return;while(elem.firstChild){pElem.insertBefore(elem.firstChild,elem);}
return pElem.removeChild(elem);};this.insertElementAdoptChildren=function(elem,parentElem){elem=ecma.dom.getElement(elem);parentElem=ecma.dom.getElement(parentElem);if(!(parentElem&&elem))return;if(parentElem.firstChild){parentElem.insertBefore(elem,parentElem.firstChild);while(elem.nextSibling){elem.appendChild(elem.nextSibling);}}else{parentElem.appendChild(elem);}};this.replaceElement=function(newElem,elem){elem.parentNode.insertBefore(newElem,elem);return elem.parentNode.removeChild(elem);};this.isChildOf=function(elem,parentElem){var y=ecma.dom.getElement(parentElem);var x=ecma.dom.getElement(elem);while(x&&y){if(x===y)return true;if(x===x.parentNode)break;x=x.parentNode;}
return false;};this.makePositioned=function(elem){elem=ecma.dom.getElement(elem);var pos=ecma.dom.getStyle(elem,'position');if(pos=='static'||!pos){elem.style.position='relative';if(ecma.dom.browser.isOpera){ecma.dom.setStyle(elem,'top',0);ecma.dom.setStyle(elem,'left',0);}}
return elem;};this.getStyle=function(elem,propName){elem=ecma.dom.getElement(elem);if(!(elem&&propName&&elem.style))return;propName=ecma.dom.translateStyleName(propName);if(ecma.window.getComputedStyle){var hyphenated=ecma.util.asHyphenatedName(propName);var cs=ecma.document.defaultView.getComputedStyle(elem,undefined)
return cs?cs.getPropertyValue(hyphenated):undefined;}else if(elem.currentStyle){var camelCase=ecma.util.asCamelCaseName(propName);return elem.currentStyle[camelCase];}else{var camelCase=ecma.util.asCamelCaseName(propName);return elem.style[camelCase];}};this.setStyle=function(elem,propName,propValue,importance){var elem=ecma.dom.getElement(elem);if(!elem||!elem.style)return;propName=ecma.dom.translateStyleName(propName);propValue=new String(propValue).toString();try{if(ecma.util.defined(elem.style.setProperty)){elem.style.setProperty(propName,propValue,importance?importance:null);}else{propName=ecma.util.asCamelCaseName(propName);elem.style[propName]=propValue;}}catch(ex){if(ecma.dom.browser.isIE){if(ex instanceof Object){ex.message='Cannot set style "'+propName+'" to "'+propValue+'".';ex.description=ex.message;ecma.console.log(ex.message);}}
throw ex;}};this.translateAttributeName=function(name){if(name=='className'||name=='class'&&ecma.platform.isIE){if(ecma.document.documentMode&&ecma.document.documentMode>7){return'class';}else{return'className';}}
return name;};this.translateStyleName=function(name){if(name=='cssFloat'&&!ecma.dom.browser.isIE)return'float';if(name=='cssFloat'&&ecma.dom.browser.isIE)return'styleFloat';if(name=='float'&&ecma.dom.browser.isIE)return'styleFloat';if(name=='float'&&ecma.dom.browser.isOpera)return'cssFloat';return name;};this.setStyles=function(elem,styles,importance){for(var name in styles){ecma.dom.setStyle(elem,name,styles[name],importance);}};this.removeStyle=function(elem,propName){elem=ecma.dom.getElement(elem);propName=ecma.dom.translateStyleName(propName);if(!elem)throw new ecma.error.MissingArg('elem');if(!propName)throw new ecma.error.MissingArg('propName');if(typeof(elem.style.removeProperty)=='function'){elem.style.removeProperty(propName);}else if(elem.style.removeAttribute){elem.style.removeAttribute(propName);}else{propName=ecma.util.asCamelCaseName(propName);try{elem.style[propName]=null;}catch(ex){if(ex instanceof Object){ex.description='Cannot remove style "'+propName+'".';}
throw ex;}}};this.hasClassName=function(elem,name){var classAttr=ecma.dom.getAttribute(elem,'class');if(!classAttr)return false;var names=classAttr.split(/\s+/);for(var i=0;i<names.length;i++){if(names[i]==name)return true;}
return false;};this.setClassName=function(elem,name){ecma.dom.setAttribute(elem,'class',name);}
this.addClassName=function(elem,name){var classAttr=ecma.dom.getAttribute(elem,'class');var names=ecma.util.defined(classAttr)?classAttr.split(/\s+/):[];for(var i=0;i<names.length;i++){if(names[i]==name)return;}
names.push(name);ecma.dom.setAttribute(elem,'class',names.join(' '));}
this.addClassNames=function(){var args=ecma.util.args(arguments);var elem=args.shift();if(!elem)return;for(var i=0;i<args.length;i++){ecma.dom.addClassName(elem,args[i]);}};this.removeClassName=function(elem,name){var classAttr=ecma.dom.getAttribute(elem,'class');if(!classAttr)return;var names=classAttr.split(/\s+/);for(var i=0;i<names.length;i++){if(names[i]==name)names.splice(i--,1);}
ecma.dom.setAttribute(elem,'class',names.join(' '));}
this.removeClassNames=function(){var args=ecma.util.args(arguments);var elem=args.shift();if(!elem)return;for(var i=0;i<args.length;i++){ecma.dom.removeClassName(elem,args[i]);}};this.getAttribute=function(elem,attrName){var elem=ecma.dom.getElement(elem);if(!elem)return;if(typeof(attrName)!='string')return;if(attrName.indexOf('_')==0){var v1=elem.getAttribute(attrName);var v2=elem[attrName];return v1===null||v1===undefined?v2:v1;}else if(attrName.indexOf('on')==0){attrName=attrName.toLowerCase();return elem[attrName];}else{if(attrName.toLowerCase()=='text'||attrName.toLowerCase()=='tagname'||attrName.indexOf('inner')==0){return elem[attrName];}else if(elem.attributes&&elem.attributes.getNamedItem){var attr=elem.attributes.getNamedItem(attrName);return attr?attr.value:attr;}else if(elem.getAttribute){attrName=ecma.dom.translateAttributeName(attrName);return elem.getAttribute(attrName);}else{return elem[attrName];}}};this.setAttribute=function(elem,attrName,attrValue){var elem=ecma.dom.getElement(elem);if(!elem)return;if(typeof(attrName)!='string')return;if(attrName.indexOf('_')==0){elem[attrName]=attrValue;}else if(attrName.toLowerCase()=='value'){elem.value=attrValue;}else if(attrName.indexOf('on')==0){var eventName=attrName.substr(2).toLowerCase();if(ecma.util.isArray(attrValue)){ecma.dom.addEventListener(elem,eventName,attrValue[0],attrValue[1],attrValue[2]);}else if(typeof(attrValue)=='function'){ecma.dom.addEventListener(elem,eventName,attrValue);}else{attrName=attrName.toLowerCase();elem[attrName]=attrValue;}}else{attrName=ecma.dom.translateAttributeName(attrName);if(!ecma.util.defined(elem.setAttribute)||attrName.toLowerCase()=='text'||attrName.indexOf('inner')==0){elem[attrName]=attrValue;}else{elem.setAttribute(attrName,attrValue);}}};this.removeAttribute=function(elem,attrName){elem=ecma.dom.getElement(elem);if(!elem)return;elem.removeAttribute(attrName);};this.setOpacity=function(elem,opacity){opacity=(Math.round(opacity*10000)/10000);if(ecma.dom.browser.isIE){opacity*=100;ecma.dom.setStyle(elem,'-ms-filter','alpha(opacity='+opacity+')');ecma.dom.setStyle(elem,'filter','alpha(opacity='+opacity+')');}else if(ecma.dom.browser.isGecko){ecma.dom.setStyle(elem,'-moz-opacity',opacity);ecma.dom.setStyle(elem,'opacity',opacity);}else if(ecma.dom.browser.isWebKit){ecma.dom.setStyle(elem,'-khtml-opacity',opacity);ecma.dom.setStyle(elem,'opacity',opacity);}else{ecma.dom.setStyle(elem,'opacity',opacity);}};this.getCenteredPosition=function(elem,contextElem){elem=ecma.dom.getElement(elem);var vp;if(contextElem){vp=ecma.dom.getElementPosition(contextElem);}else{vp=ecma.dom.getViewportPosition();}
var pos=ecma.dom.getElementPosition(elem);var x=vp['left']+(vp['width']/2)-(pos['width']/2);var y=vp['top']+(vp['height']/2)-(pos['height']/2);if(x<vp['left'])x=vp['left'];if(y<vp['top'])y=vp['top'];return{'top':y,'left':x};};this.setPosition=function(elem,props){elem=ecma.dom.getElement(elem);if(!props)props={'position':'top-third'}
var attrVisibility=elem.style.visibility;var attrDisplay=elem.style.display;elem.style.visibility='hidden';elem.style.display='block';var vp=ecma.dom.getViewportPosition();var xy=ecma.dom.getCenteredPosition(elem,props.contextElem);if(props.position=='top-third'){var h=ecma.dom.getHeight(elem);var t=(vp.height-h)/3;if(t<0)t=ecma.util.asInt(ecma.dom.canvas.scrollY());if(t<ecma.dom.canvas.scrollY())t+=ecma.dom.canvas.scrollY();elem.style.left=xy.left+"px";elem.style.top=t+"px";}else if(props.position=='center'){elem.style.left=xy.left+"px";elem.style.top=xy.top+"px";}else if(props.position=='bottom-left'){vp['left']+=ecma.util.asInt(ecma.dom.getStyle(elem,'padding-left'));vp['top']-=ecma.util.asInt(ecma.dom.getStyle(elem,'padding-bottom'));elem.style.left=vp['left']+'px';elem.style.top=(vp['top']+vp['height']-ecma.dom.getHeight(elem))+'px';}else if(props.position=='bottom-right'){elem.style.right='0px';elem.style.bottom='0px';}
elem.style.visibility=attrVisibility;elem.style.display=attrDisplay;};this.getElementPosition=function(elem){elem=ecma.dom.getElement(elem);return{'left':ecma.dom.getLeft(elem),'top':ecma.dom.getTop(elem),'width':ecma.dom.getWidth(elem),'height':ecma.dom.getHeight(elem)};};this.getInnerPosition=function(elem){return{'top':ecma.dom.getInnerTop(elem),'left':ecma.dom.getInnerLeft(elem),'right':ecma.dom.getInnerRight(elem),'bottom':ecma.dom.getInnerBottom(elem),'width':ecma.dom.getInnerWidth(elem),'height':ecma.dom.getInnerHeight(elem)};};this.getTop=function(elem){elem=ecma.dom.getElement(elem);if(!elem)return 0;var result=elem.getBBox?elem.getBBox().y:elem.offsetTop;result+=ecma.dom.getTop(elem.offsetParent);return isNaN(result)?0:result;};this.getBottom=function(elem){return ecma.dom.getTop(elem)+ecma.dom.getHeight(elem);};this.getLeft=function(elem){elem=ecma.dom.getElement(elem);if(!elem)return 0;var result=elem.getBBox?elem.getBBox().x:elem.offsetLeft;result+=ecma.dom.getLeft(elem.offsetParent);return isNaN(result)?0:result;};this.getRight=function(elem){return ecma.dom.getLeft(elem)+ecma.dom.getWidth(elem);};this.getWidth=function(elem){elem=ecma.dom.getElement(elem);var result=elem.getBBox?elem.getBBox().width:elem.offsetWidth;return isNaN(result)?0:result;};this.getHeight=function(elem){elem=ecma.dom.getElement(elem);var result=elem.getBBox?elem.getBBox().height:elem.offsetHeight;return isNaN(result)?0:result;};this.getInnerTop=function(elem){elem=ecma.dom.getElement(elem);if(!elem)return 0;var result=elem.getBBox?elem.getBBox().y:elem.offsetTop+elem.clientTop;result+=ecma.dom.getInnerTop(elem.offsetParent);return isNaN(result)?0:result;};this.getInnerBottom=function(elem){return ecma.dom.getInnerTop(elem)+ecma.dom.getInnerHeight(elem);};this.getInnerLeft=function(elem){elem=ecma.dom.getElement(elem);if(!elem)return 0;var result=elem.getBBox?elem.getBBox().x:elem.offsetLeft+elem.clientLeft;result+=ecma.dom.getInnerLeft(elem.offsetParent);return isNaN(result)?0:result;};this.getInnerRight=function(elem){return ecma.dom.getInnerLeft(elem)+ecma.dom.getInnerWidth(elem);};this.getInnerWidth=function(elem){elem=ecma.dom.getElement(elem);var result=elem.getBBox?elem.getBBox().width:elem.clientWidth;if(!result)result=elem.offsetWidth-elem.clientLeft;return isNaN(result)?0:result;};this.getInnerHeight=function(elem){elem=ecma.dom.getElement(elem);var result=elem.getBBox?elem.getBBox().height:elem.clientHeight;if(!result)result=elem.offsetHeight-elem.clientTop;return isNaN(result)?0:result;};function _getContentWidth(elem,result){while(elem){result=Math.max(result,ecma.dom.getWidth(elem));if(elem.hasChildNodes){result=_getContentWidth(elem.firstChild,result);}
elem=elem.nextSibling;}
return result;}
this.getContentWidth=function(elem){elem=ecma.dom.getElement(elem);return _getContentWidth(elem.firstChild,ecma.dom.getWidth(elem));};function _getContentHeight(elem,result){while(elem){result=Math.max(result,ecma.dom.getHeight(elem));if(elem.hasChildNodes){result=_getContentHeight(elem.firstChild,result);}
elem=elem.nextSibling;}
return result;}
this.getContentHeight=function(elem){elem=ecma.dom.getElement(elem);return _getContentHeight(elem.firstChild,ecma.dom.getHeight(elem));};this.getValues=function(elem,tagNames){elem=ecma.dom.getElement(elem);if(!elem)return;var result={};if(!tagNames)tagNames=['input','textarea','select'];for(var i=0,tagName;tagName=tagNames[i];i++){var nodeList=elem.getElementsByTagName(tagName);for(var j=0,node;node=nodeList[j];j++){var name=ecma.dom.getAttribute(node,'name');if(!name)continue;var value=ecma.dom.getValue(node);if(ecma.util.defined(result[name])){var attrName=node.tagName;var attrType=ecma.dom.getAttribute(node,'type')||'';if(attrName.toUpperCase()=='INPUT'&&attrType.toUpperCase()=='RADIO'){if(result[name]&&!value)continue;result[name]=value;}else{if(!ecma.util.defined(value))continue;if(ecma.util.isArray(result[name])){result[name].push(value);}else{result[name]=[result[name],value];}}}else{result[name]=value;}}}
return result;};this.getValue=function(elem){function resolveValue(value){if(value.match(/^&:/)){return ecma.dom.getValue(value.replace(/^&:/,''));}
return value;}
var elem=ecma.dom.getElement(elem);if(!elem)return;var value=undefined;switch(elem.tagName.toUpperCase()){case'INPUT':switch(elem.type.toUpperCase()){case'HIDDEN':value=resolveValue(elem.value);break;case'CHECKBOX':value=elem.checked?ecma.util.defined(elem.value)?resolveValue(elem.value):true:undefined;break;case'RADIO':if(elem.checked){value=ecma.util.defined(elem.value)?resolveValue(elem.value):true;}else{value=undefined;}
break;case'SUBMIT':case'PASSWORD':case'TEXT':case'FILE':value=elem.value;break;default:throw'Unhandled input type: '+elem.type;}
break;case'BUTTON':value=ecma.dom.getAttribute(elem,'value');break;case'TEXTAREA':case'SELECT':value=elem.value;break;default:if(ecma.util.defined(elem.innerHTML)){value=elem.innerHTML;}else{throw'Unhandled tag: '+elem.tagName;}}
return value;};this.setValue=function(elem,value){var elem=ecma.dom.getElement(elem);if(!elem)return;switch(elem.tagName.toUpperCase()){case'INPUT':switch(elem.type.toUpperCase()){case'HIDDEN':case'PASSWORD':case'TEXT':elem.value=value;break;case'CHECKBOX':case'RADIO':var checked=elem.checked;if(typeof(value)=='boolean'){checked=value;}else{if(value=='on'){checked=true;}else if(value=='off'){checked=false;}else{elem.value=value;}}
elem.checked=checked;break;default:throw'Unhandled input type: '+elem.type;}
break;case'TEXTAREA':case'SELECT':elem.value=value;break;case'PRE':if(ecma.dom.browser.isIE){var div=ecma.dom.createElement('div',{innerHTML:'<pre>'+value+'</pre>'});ecma.dom.replaceChildren(elem,div.childNodes);}else{ecma.dom.setAttribute(elem,'innerHTML',value);}
break;default:if(ecma.util.defined(elem.innerHTML)){ecma.dom.setAttribute(elem,'innerHTML',value);}else if(ecma.util.defined(elem.innerText)){ecma.dom.setAttribute(elem,'innerText',value);}else{throw'Unhandled tag: '+elem.tagName;}}
return value;};this.clearSelection=function(){if(ecma.document.selection&&ecma.document.selection.empty){ecma.document.selection.empty();}else if(ecma.window.getSelection){var sel=ecma.window.getSelection();sel.removeAllRanges();}};});ECMAScript.Extend('util',function(ecma){this.asHyphenatedName=function(name){function upperToHyphenLower(match){return'-'+match.toLowerCase();}
return name.replace(/[A-Z]/g,upperToHyphenLower);};this.asCamelCaseName=function(name){function ucFirstMatch(str,p1,offest,s){return p1.toUpperCase();}
return name.replace(/-([a-z])/g,ucFirstMatch);};});ECMAScript.Extend('dom.constants',function(ecma){this.ELEMENT_NODE=1;this.ATTRIBUTE_NODE=2;this.TEXT_NODE=3;this.CDATA_SECTION_NODE=4;this.ENTITY_REFERENCE_NODE=5;this.ENTITY_NODE=6;this.PROCESSING_INSTRUCTION_NODE=7;this.COMMENT_NODE=8;this.DOCUMENT_NODE=9;this.DOCUMENT_TYPE_NODE=10;this.DOCUMENT_FRAGMENT_NODE=11;this.NOTATION_NODE=12;});ECMAScript.Extend('dom.node',function(ecma){this.isElement=function(node){node=ecma.dom.getElement(node);return node&&node.nodeType&&node.nodeType==ecma.dom.constants.ELEMENT_NODE&&node.tagName!='!';};this.isAttribute=function(node){node=ecma.dom.getElement(node);return node&&node.nodeType&&node.nodeType==ecma.dom.constants.ATTRIBUTE_NODE;};this.isText=function(node){node=ecma.dom.getElement(node);return node&&node.nodeType&&node.nodeType==ecma.dom.constants.TEXT_NODE;};this.isCdataSection=function(node){node=ecma.dom.getElement(node);return node&&node.nodeType&&node.nodeType==ecma.dom.constants.CDATA_SECTION_NODE;};this.isEntityReference=function(node){node=ecma.dom.getElement(node);return node&&node.nodeType&&node.nodeType==ecma.dom.constants.ENTITY_REFERENCE_NODE;};this.isEntity=function(node){node=ecma.dom.getElement(node);return node&&node.nodeType&&node.nodeType==ecma.dom.constants.ENTITY_NODE;};this.isProcessingInstruction=function(node){node=ecma.dom.getElement(node);return node&&node.nodeType&&node.nodeType==ecma.dom.constants.PROCESSING_INSTRUCTION_NODE;};this.isComment=function(node){node=ecma.dom.getElement(node);return node&&node.nodeType&&node.nodeType==ecma.dom.constants.COMMENT_NODE;};this.isDocument=function(node){node=ecma.dom.getElement(node);return node&&node.nodeType&&node.nodeType==ecma.dom.constants.DOCUMENT_NODE;};this.isDocumentType=function(node){node=ecma.dom.getElement(node);return node&&node.nodeType&&node.nodeType==ecma.dom.constants.DOCUMENT_TYPE_NODE;};this.isDocumentFragment=function(node){node=ecma.dom.getElement(node);return node&&node.nodeType&&node.nodeType==ecma.dom.constants.DOCUMENT_FRAGMENT_NODE;};this.isNotation=function(node){node=ecma.dom.getElement(node);return node&&node.nodeType&&node.nodeType==ecma.dom.constants.NOTATION_NODE;};});ECMAScript.Extend('dom',function(ecma){this.getXPath=function(elem){elem=ecma.dom.getElement(elem);var result=[''];while(elem&&ecma.dom.node.isElement(elem)){var i=ecma.dom.getChildIndex(elem);var name=elem.tagName.toLowerCase();if(i>0)name+='['+(i+1)+']';result.unshift(name);elem=elem.parentNode;}
return result.join('/');}
this.getChildIndex=function(elem){var result=0;for(var node=elem.previousSibling;node;node=node.previousSibling){if(ecma.dom.node.isElement(node)&&(node.tagName==elem.tagName)){result++;}}
return result;}});ECMAScript.Extend('console',function(ecma){function _initBrowserConsole(){try{if(ecma.dom.browser.isOpera){ecma.console.tee(new ecma.console.Opera());ecma.console.flush();return;}
var win=ecma.window;while(win){if(win.console){ecma.console.tee(win.console);ecma.console.flush();break;}
if(win.parent===win)break;win=win.parent;}}catch(ex){}}
if(ecma.window.parent!==ecma.window){_initBrowserConsole();}else{_initBrowserConsole();}
this.Opera=function(){};this.Opera.prototype.log=function(){if(!arguments.length)return;var args=ecma.util.args(arguments);ecma.window.opera.postError(args.join(' '));};});ECMAScript.Extend('dom.include',function(ecma){var _loaded={};function _getHead(){var heads=ecma.document.getElementsByTagName('head');if(!(heads&&heads[0])){var doc=ecma.dom.getRootElement();var head=ecma.dom.createElement('head');doc.appendChild(head);return head;}
return heads[0];}
function _setLoaded(event,id,cb){var target=ecma.dom.getEventTarget(event);if(ecma.dom.browser.isIE){if(target.readyState.match(/complete|loaded/))_loaded[id]=true;}else{_loaded[id]=true;}
if(_loaded[id]&&cb){ecma.lang.callback(cb,ecma.window,[target]);}}
this.hasLoaded=function(id){return id&&ecma.util.defined(_loaded[id])?_loaded[id]:false;};this.script=function(attrs,cb){var elem=attrs.id?ecma.dom.getElement(attrs.id):undefined;if(elem){if(cb)ecma.lang.callback(cb,ecma.window,[elem]);return elem;}
if(!attrs.type)attrs.type='text/javascript';if(!attrs.id)attrs.id=ecma.util.randomId('script');var head=_getHead();elem=ecma.dom.createElement('script',attrs);if(attrs.text){head.appendChild(elem);_loaded[attrs.id]=true;if(cb)ecma.lang.callback(cb,ecma.window,[elem]);}else{if(ecma.dom.browser.isIE){ecma.dom.addEventListener(elem,'readystatechange',_setLoaded,this,[attrs.id,cb]);}else{ecma.dom.addEventListener(elem,'load',_setLoaded,this,[attrs.id,cb]);}
_loaded[attrs.id]=false;head.appendChild(elem);}
return elem;};this.style=function(attrs){var elem=attrs.id?ecma.dom.getElement(attrs.id):undefined;if(elem)return elem;if(!attrs.id)attrs.id=ecma.util.randomId('css');if(!attrs.type)attrs.type='text/css';var head=_getHead();if(attrs.href){if(!attrs.rel)attrs.rel='stylesheet';elem=ecma.dom.createElement('link',attrs);}else{var text=attrs.text;delete attrs.text;elem=ecma.dom.createElement('style',attrs);if(ecma.dom.browser.isIE){elem.styleSheet.cssText=text;}else{elem.appendChild(ecma.document.createTextNode(text));}}
head.appendChild(elem);return elem;};});ECMAScript.Extend('dom',function(ecma){this.Canvas=function(){this.doc=ecma.document.documentElement||ecma.document;this.body=ecma.dom.getBody();this.root=ecma.document.rootElement||this.body.parentNode;};var _proto=this.Canvas.prototype=ecma.lang.createMethods();_proto.getPosition=function(){return{'left':this.getLeft(),'top':this.getTop(),'width':this.getWidth(),'height':this.getHeight()};};_proto.getWidth=function(){var winX=this.windowX();var pgX=this.pageX();var w=winX<pgX?pgX:winX;var sbX=0;var rootX=ecma.dom.getWidth(this.root);if(rootX==pgX){if(ecma.document.compatMode=='BackCompat'){sbX=Math.abs(winX-rootX);}else if(ecma.document.compatMode=='CSS1Compat'){sbX=ecma.dom.browser.isIE?0:Math.abs(winX-rootX);}}
return w-sbX;};_proto.getHeight=function(){var winY=this.windowY();var pgY=this.pageY();var h=winY<pgY?pgY:winY;var sbY=0;var rootY=ecma.dom.getHeight(this.root);if(rootY==pgY){if(ecma.document.compatMode=='BackCompat'){sbY=Math.abs(winY-rootY);}else if(ecma.document.compatMode=='CSS1Compat'){sbY=ecma.dom.browser.isIE?0:Math.abs(winY-rootY);}}
return h-sbY;};_proto.getRawWidth=function(){return this.getDimension('Width');};_proto.getRawHeight=function(){return this.getDimension('Height');};_proto.getDimension=function(name){return Math.max(this.doc["client"+name],this.body["scroll"+name],this.doc["scroll"+name],this.body["offset"+name],this.doc["offset"+name]);};_proto.windowX=function(){return ecma.window.innerWidth||this.doc.clientWidth||this.body.clientWidth||this.doc.offsetWidth;};_proto.windowY=function(){return ecma.window.innerHeight||this.doc.clientHeight||this.body.clientHeight||this.doc.offsetHeight;};_proto.getLeft=_proto.scrollX=function(){return this.doc.scrollLeft||ecma.window.pageXOffset||this.body.scrollLeft;};_proto.getTop=_proto.scrollY=function(){return this.doc.scrollTop||ecma.window.pageYOffset||this.body.scrollTop;};_proto.pageX=function(){return Math.max(this.doc.scrollWidth,this.body.scrollWidth,this.body.offsetWidth);};_proto.pageY=function(){return Math.max(this.doc.scrollHeight,this.body.scrollHeight,this.body.offsetHeight);};});ECMAScript.Extend('dom',function(ecma){var _canvas=undefined;this.getCanvasPosition=function(){if(!_canvas)_canvas=new ecma.dom.Canvas();return _canvas.getPosition();};});ECMAScript.Extend('dom',function(ecma){CDispatcher=ecma.action.ActionDispatcher;var proto=ecma.lang.createMethods(CDispatcher);function Content(){CDispatcher.apply(this,arguments);};Content.prototype=proto;this.content=new Content();});ECMAScript.Extend('dom',function(ecma){function ContentLoaded(w,f){var d=w.document,D='DOMContentLoaded',u=w.navigator.userAgent.toLowerCase(),v=parseFloat(u.match(/.+(?:rv|it|ml|ra|ie)[\/: ]([\d.]+)/)[1]);function init(e){if(!document.loaded){document.loaded=true;f((e.type&&e.type==D)?e:{type:D,target:d,eventPhase:0,currentTarget:d,timeStamp:+new Date,eventType:e.type||e});}}
if(/webkit\//.test(u)&&v<525.13){(function(){if(/complete|loaded/.test(d.readyState)){init('khtml-poll');}else{setTimeout(arguments.callee,10);}})();}else if(/msie/.test(u)&&!w.opera){d.attachEvent('onreadystatechange',function(e){if(d.readyState=='complete'){d.detachEvent('on'+e.type,arguments.callee);init(e);}});if(w==top){(function(){try{d.documentElement.doScroll('left');}catch(e){setTimeout(arguments.callee,10);return;}
init('msie-poll');})();}}else if(d.addEventListener&&(/opera\//.test(u)&&v>9)||(/gecko\//.test(u)&&v>=1.8)||(/khtml\//.test(u)&&v>=4.0)||(/webkit\//.test(u)&&v>=525.13)){d.addEventListener(D,function(e){d.removeEventListener(D,arguments.callee,false);init(e);},false);}else{var oldonload=w.onload;w.onload=function(e){init(e||w.event);if(typeof oldonload=='function'){oldonload(e||w.event);}};}}
ContentLoaded(ecma.window,function(event){ecma.dom.content.dispatchAction('load',event);});});ECMAScript.Extend('dom',function(ecma){var _lowerNames=[];_lowerNames[8]='backspace';_lowerNames[9]='tab';_lowerNames[13]='enter';_lowerNames[16]='shift';_lowerNames[17]='ctrl';_lowerNames[18]='alt';_lowerNames[19]='pause';_lowerNames[20]='capslock';_lowerNames[27]='esc';_lowerNames[144]='numlock';var _modifierNames=[];_modifierNames[16]='shift';_modifierNames[17]='ctrl';_modifierNames[18]='alt';_modifierNames[20]='capslock';_modifierNames[144]='numlock';var _commandNames=[];_commandNames[33]='pageup';_commandNames[34]='pagedown';_commandNames[35]='end';_commandNames[36]='home';_commandNames[37]='left';_commandNames[38]='up';_commandNames[39]='right';_commandNames[40]='down';_commandNames[45]='insert';_commandNames[46]='delete';var _symbolNames=[];if(ecma.dom.browser.isIE||ecma.dom.browser.isWebKit){_symbolNames[186]=';';_symbolNames[187]='=';_symbolNames[189]='-';}
if(ecma.dom.browser.isGecko||ecma.dom.browser.isOpera){_symbolNames[109]='-';}
_symbolNames[188]=',';_symbolNames[190]='.';_symbolNames[191]='/';_symbolNames[192]='`';_symbolNames[219]='[';_symbolNames[220]='\\';_symbolNames[221]=']';_symbolNames[222]='\'';var CAction=ecma.action.ActionDispatcher;this.KeyPress=function(){CAction.apply(this);this.handlers={};this.events=[];this.queue=[];return this;};var KeyPress=this.KeyPress.prototype=ecma.lang.createMethods(CAction);KeyPress.setHandler=KeyPress.addHandler=function(){var args=ecma.util.args(arguments);var name=args.shift();var cbList=this.handlers[name];if(!cbList)cbList=this.handlers[name]=[];cbList.push(args);};KeyPress.attach=function(elem){this.events=this.events.concat([new ecma.dom.EventListener(elem,'keydown',this.onKeyDown,this),new ecma.dom.EventListener(elem,'keypress',this.onKeyPress,this),new ecma.dom.EventListener(elem,'keyup',this.onKeyUp,this)]);return this;};KeyPress.detach=function(elem){elem=ecma.dom.getElement(elem);for(var i=0,evt;evt=this.events[i];i++){if(evt.target!==elem)continue;evt.remove();this.events.splice(i--,1);}
return this;};KeyPress.pumpEvent=function(event,chrSeq){var cmdSeq=this.queue.shift();if(!cmdSeq)return;var seq=chrSeq&&chrSeq.isCharacter?chrSeq:cmdSeq;this.doEvent(event,seq);};KeyPress.doEvent=function(event,seq){ecma.lang.assert(seq);if(seq.isModifier&&!seq.downUp)return;var cbList=this.handlers[seq.ascii]
if(cbList){ecma.util.step(cbList,function(cb,event){if(!event||event.stopped)return;ecma.lang.callback(cb,null,[event]);},this,[event]);}
this.dispatchAction('keypress',seq,event);this.lastSeq=seq;};KeyPress.repeatEvent=function(event){this.doEvent(event,this.lastSeq);};KeyPress.onKeyDown=function(event){this.state=1;this.pumpEvent(event);var seq=this.getCommandSequence(event);if(seq.isResolved&&!seq.isModifier){this.doEvent(event,seq);}else{this.queue.push(seq);}};KeyPress.onKeyPress=function(event){if(this.state==2){this.repeatEvent();return;}
this.state=2;var seq=this.getCharacterSequence(event);this.pumpEvent(event,seq);};KeyPress.onKeyUp=function(event){if(this.state==1){var seq=this.queue[0];if(seq)seq.downUp=true;}
this.state=3;this.pumpEvent(event);};KeyPress.getCommandSequence=function(event){var num=event.keyCode;var name=undefined;var isModifier=false;var isResolved=event.ctrlKey||event.altKey||event.metaKey?true:false;if(num<32||num==144){name=_lowerNames[num];isModifier=_modifierNames[num]?true:false;isResolved=true;}else{name=_commandNames[num];if(name){isResolved=true;}else{name=_symbolNames[num];if(name){isResolved=event.shiftKey?false:true;}else{name=String.fromCharCode(num).toLowerCase();}}}
var ascii=[];if(ecma.util.defined(name)){if(event.ctrlKey&&name!='ctrl')ascii.push('ctrl');if(event.altKey&&name!='alt')ascii.push('alt');if(event.shiftKey&&name!='shift')ascii.push('shift');if(event.metaKey&&name!='meta')ascii.push('meta');ascii.push(name);}
var seq={'ascii':ascii.join('+'),'numeric':num,'isModifier':isModifier,'isResolved':isResolved,'isCharacter':false,'keyCode':event.keyCode,'which':event.which,'type':event.type};return seq;};KeyPress.getCharacterSequence=function(event){var num=ecma.util.defined(event.which)?event.which:event.keyCode;var isModifier=false;var omitShift=false;var name=undefined;if(num<32||num==144){name=_lowerNames[num];isModifier=_modifierNames[num]?true:false;}else{name=String.fromCharCode(num);omitShift=true;}
var isCharacter=name&&!event.ctrlKey&&!event.altKey;var ascii=[];if(ecma.util.defined(name)){if(event.ctrlKey&&name!='ctrl')ascii.push('ctrl');if(event.altKey&&name!='alt')ascii.push('alt');if(event.shiftKey&&name!='shift'&&!omitShift)ascii.push('shift');if(event.metaKey&&name!='meta')ascii.push('meta');ascii.push(name);}
var seq={'ascii':ascii.join('+'),'numeric':num,'isModifier':isModifier,'isResolved':true,'isCharacter':isCharacter,'keyCode':event.keyCode,'which':event.which,'type':event.type};return seq;};KeyPress.trace=function(){var out=ecma.util.args(arguments);var seq=out.shift();var flags='';if(seq.isCharacter)flags+='c';if(seq.isModifier)flags+='m';if(seq.isResolved)flags+='r';out.push(ecma.util.pad(seq.type,10,' '));out.push(ecma.util.pad(seq.keyCode,5,' '));out.push(ecma.util.pad(seq.which,5,' '));out.push(ecma.util.pad(seq.numeric,5,' '));out.push(ecma.util.pad(flags,6,' '));out.push(ecma.util.pad(seq.ascii,25,' '));ecma.console.log(out.join('|'));};KeyPress.traceHeader=function(){var out=[];out.push(ecma.util.pad('event',10,' '));out.push(ecma.util.pad('keyCo',5,' '));out.push(ecma.util.pad('which',5,' '));out.push(ecma.util.pad('using',5,' '));out.push(ecma.util.pad('flags',6,' '));out.push(ecma.util.pad('sequence',25,' '));ecma.console.log(out.join('|'));};});ECMAScript.Extend('dom',function(ecma){this.StyleSheet=function(id){this.id=id||ecma.util.randomId('css');this.style=undefined;this.sheet=undefined;this.cssRulesByName=undefined;};this.StyleSheet.prototype={vivify:function(){this.style=ecma.dom.getElement(this.id)||ecma.dom.createElement('style',{id:this.id,type:'text/css',rel:'stylesheet',media:'screen'});ecma.dom.getHead().appendChild(this.style);this.sheet=this.style.sheet||this.style.styleSheet;this.cssRulesByName={};},objToStr:function(obj,opts){var result='';for(var name in obj){if(opts&&ecma.util.defined(opts.exclude)){if(name.match(opts.exclude)){continue;}}
result+=name+':'+this.clarifyValue(name,obj[name])+';';}
return result;},strToObj:function(str){str=str.replace(/\r?\n\r?\s*/g,'');var result={};var items=str.split(';');for(var i=0;i<items.length-1;i++){var key=items[i].split(/:/,1);var value=items[i].substr(key[0].length+1);value=value.replace(/^\s+/,'');var name=key[0];result[name]=value;}
return result;},clarifyValue:function(name,value){return typeof(value)==='number'?name.match(/(width|height|top|right|bottom|left)$/)?value+'px':value+'':value;},createRules:function(name,props){var names=name.split(/,\s*/);var rules=[];for(var i=0;i<names.length;i++){rules.push(this.createRule(names[i],props));}
return rules;},updateRules:function(name,props){var names=name.split(/,\s*/);var rules=[];for(var i=0;i<names.length;i++){rules.push(this.updateRule(names[i],props));}
return rules;},cssNameToJsName:function(name){if(name=='float')return'cssFloat';if(name=='class')return'className';return ecma.util.asCamelCaseName(name);},jsNameToCssName:function(name){if(name=='cssFloat')return'float';if(name=='className')return'class';return ecma.util.asHyphenatedName(name);},createRule:function(name,props){if(!this.style)this.vivify();var str=ecma.util.isAssociative(props)?this.objToStr(props):props;var rule=null;var idx=-1;if(ecma.util.defined(this.sheet.addRule)){idx=this.sheet.rules.length;this.sheet.addRule(name,str);rule=this.sheet.rules[idx];}else if(ecma.util.defined(this.sheet.insertRule)){idx=this.sheet.cssRules.length;this.sheet.insertRule(name+' {'+str+'}',idx);rule=this.sheet.cssRules[idx];}
this.cssRulesByName[name]={'rule':rule,'index':idx};return rule;},updateRule:function(name,props){if(!this.style)this.vivify();var rinfo=this.cssRulesByName[name];var rule=rinfo?rinfo.rule:undefined;if(rule){if(!ecma.util.isAssociative(props))props=this.strToObj(props);for(var propName in props){var value=this.clarifyValue(propName,props[propName]);ecma.dom.setStyle(rule,propName,value);}}else{rule=this.createRule(name,props);}
return rule;},deleteRule:function(rule){if(!this.style)return;for(var name in this.cssRulesByName){var rinfo=this.cssRulesByName[name];if(rinfo.rule===rule){if(ecma.util.defined(this.sheet.removeRule)){this.sheet.removeRule(rinfo.index);}else{this.sheet.deleteRule(rinfo.index);}
return true;}}}};});ECMAScript.Extend('dom',function(ecma){this.EventListener=function(target,type,listener,scope,args,useCapture){this.target=ecma.dom.getElement(target);this.type=type;this.scope=scope;this.useCapture=useCapture;this.func=ecma.dom.addEventListener(this.target,this.type,listener,this.scope,args,this.useCapture);};var proto=this.EventListener.prototype={};proto.remove=function(){ecma.dom.removeEventListener(this.target,this.type,this.func,this.scope,this.useCapture);};});ECMAScript.Extend('dom',function(ecma){var PRESERVE_WS_TAGS=['CODE','PRE','TEXTAREA','TT'];function _wsMatters(node){var pNode=node.parentNode;while(pNode){if(ecma.util.grep(pNode.tagName,PRESERVE_WS_TAGS))return true;if(pNode.parentNode===pNode)break;pNode=pNode.parentNode;}
return false;}
this.condense=function(elem){var node=elem.firstChild;while(node){var next=node.nextSibling;switch(node.nodeType){case ecma.dom.constants.ELEMENT_NODE:ecma.dom.condense(node);break;case ecma.dom.constants.TEXT_NODE:if(node.nodeValue.match(/^\s*$/)&&(node===elem.firstChild||ecma.dom.node.isElement(node.previousSibling))&&(node===elem.lastChild||ecma.dom.node.isElement(node.nextSibling))){ecma.dom.removeElement(node);break;}
if(_wsMatters(node)){break;}
node.nodeValue=node.nodeValue.replace(/\s+/g,' ');if(node.nodeValue){break;}}
node=next;}
return elem;};});ECMAScript.Extend('lsn',function(ecma){var _pendingAuth=[];var _loginDialog=null;var CRequest=ecma.http.Request;var proto=ecma.lang.createMethods(CRequest);function _resubmitPending(){var req=_pendingAuth.shift();while(req){req.resubmit();req=_pendingAuth.shift();}}
function _flushPending(){var req=_pendingAuth.shift();while(req){req.completeRequest();req=_pendingAuth.shift();}}
this.Request=function(uri,userOptions){var options=ecma.util.overlay({method:'POST',loginURI:'/res/login/login.dlg',headers:{'Accept':'text/data-xfr','X-Accept-Content-Encoding':'base64','X-Content-Format':'text/data-xfr','X-Content-Encoding':'base64'}},userOptions);CRequest.apply(this,[uri,options]);};this.Request.prototype=proto;proto.parseBody=function(body){return body?ecma.data.xfr.format(body):null;};proto.parseResponse=function(){var c_type=this.xhr.getResponseHeader('X-Content-Format');var c_enc=this.xhr.getResponseHeader('X-Content-Encoding');if(c_type&&c_type=='text/data-xfr'){var xfr=this.getXFR(c_enc);this.responseHash=xfr.parse(this.xhr.responseText);}};proto.getXFR=function(encoding){return new ecma.data.XFR(encoding);};proto.canComplete=function(){if(this.xhr.status==401||(this.xhr.status==403&&ecma.dom.browser.isOpera)){if(this.uri==this.loginURI)return true;if(!_loginDialog)_loginDialog=this.showLoginDialog();_pendingAuth.push(this);return false;}
return true;};proto.showLoginDialog=function(){var loginDialog=new ecma.lsn.ui.LoginDialog(this.loginURI);loginDialog.dlg.show({onSuccess:ecma.lang.createCallback(function(){_loginDialog=null;_resubmitPending();},this),onCancel:ecma.lang.createCallback(function(){_loginDialog=null;_flushPending();},this)});return loginDialog;};});ECMAScript.Extend('http',function(ecma){var CDispatcher=ecma.action.ActionDispatcher;var _proto=ecma.lang.createMethods(CDispatcher);this.PerlModule=function(moduleUrl){CDispatcher.call(this);this.moduleUrl=moduleUrl;};this.PerlModule.prototype=_proto;_proto.submit=function(sub,params,cb){var req=new ecma.lsn.Request(this.moduleUrl+'/'+sub);req.addEventListener('onComplete',this.doSubmitComplete,this,[cb]);req.submit(params);this.dispatchClassAction('onSend',req);};_proto.doSubmitComplete=function(req,cb){var data=req&&req.responseHash?req.responseHash.get('body'):undefined;if(cb)ecma.lang.callback(cb,this,[data,req]);this.dispatchClassAction('onRecv',req);};});ECMAScript.Extend('http',function(ecma){var CRequest=ecma.lsn.Request;var CAction=ecma.action.ActionDispatcher;this.Stream=function(){CAction.apply(this);CRequest.apply(this,arguments);this.responseParts=[];this.boundary=null;this.pos=0;};var _proto=this.Stream.prototype=ecma.lang.createMethods(CAction,CRequest);_proto.parseResponseHeaders=function(){this.xContentFormat=this.xhr.getResponseHeader('X-Content-Format');this.xContentEncoding=this.xhr.getResponseHeader('X-Content-Encoding');var contentType=this.xhr.getResponseHeader('Content-Type');var match=contentType.match(/boundary=([^\s]+)/);this.boundary=match?match[1]:undefined;};_proto.getXFR=function(){if(this.xfr)return this.xfr;if(this.xContentFormat&&this.xContentFormat=='text/data-xfr'){return this.xfr=new ecma.data.XFR(this.xContentEncoding);}else{throw'Response content is not in XFR format';}};_proto.onInteractive=function(){this.parseResponse();};_proto.submit=function(){this.responseParts=[];this.boundary=null;this.pos=0;CRequest.prototype.submit.apply(this,arguments);};_proto.parseResponse=function(){try{if(!this.xhr.responseText)return;}catch(ex){return;}
if(this.pos==0)this.parseResponseHeaders();if((this.xhr.responseText.length)>this.pos){var parts=this.boundary?this.xhr.responseText.split(this.boundary):[this.responseText,undefined];parts.pop();for(var i=this.responseParts.length,part;part=parts[i];i++){this.responseParts[i]=this.getXFR().parse(part);this.dispatchClassAction('onReceive',this.responseParts[i],i);}
this.pos=this.xhr.responseText.length;}};});ECMAScript.Extend('hub',function(ecma){var _controller=null;this.getInstance=function(){if(!_controller){if(ecma.window!==ecma.window.top){try{_controller=ecma.window.parent.js.hub.getInstance();}catch(ex){}}
if(!_controller){_controller=new ecma.hub.Controller();}}
return _controller;};this.ccd=function(type){return type=='directory'||type.match(/^file-(data|multipart)/)||type.match(/^data-(array|hash)/)?true:false;};var Icons={};Icons['application-wireframe.png']='/res/icons/16x16/nodes/application-wireframe.png';Icons['applications-internet.png']='/res/icons/16x16/nodes/applications-internet.png';Icons['bgleft.png']='/res/icons/16x16/nodes/bgleft.png';Icons['canexp.png']='/res/icons/16x16/nodes/canexp.png';Icons['data-array.png']='/res/icons/16x16/nodes/data-array.png';Icons['data-hash.png']='/res/icons/16x16/nodes/data-hash.png';Icons['data-scalar.png']='/res/icons/16x16/nodes/data-scalar.png';Icons['directories.png']='/res/icons/16x16/nodes/directories.png';Icons['directory.png']='/res/icons/16x16/nodes/directory.png';Icons['file-bmp.png']='/res/icons/16x16/nodes/file-bmp.png';Icons['file-csv.png']='/res/icons/16x16/nodes/file-csv.png';Icons['file-data-array.png']='/res/icons/16x16/nodes/file-data-array.png';Icons['file-data.png']='/res/icons/16x16/nodes/file-data.png';Icons['file-doc.png']='/res/icons/16x16/nodes/file-doc.png';Icons['file-flv.png']='/res/icons/16x16/nodes/file-flv.png';Icons['file-gif.png']='/res/icons/16x16/nodes/file-gif.png';Icons['file-jar.png']='/res/icons/16x16/nodes/file-jar.png';Icons['file-jpeg.png']='/res/icons/16x16/nodes/file-jpeg.png';Icons['file-jpg.png']='/res/icons/16x16/nodes/file-jpg.png';Icons['file-mp3.png']='/res/icons/16x16/nodes/file-mp3.png';Icons['file-multipart-html.png']='/res/icons/16x16/nodes/file-multipart-html.png';Icons['file-multipart.png']='/res/icons/16x16/nodes/file-multipart.png';Icons['file-pdf.png']='/res/icons/16x16/nodes/file-pdf.png';Icons['file-pm.png']='/res/icons/16x16/nodes/file-pm.png';Icons['file-png.png']='/res/icons/16x16/nodes/file-png.png';Icons['file-swf.png']='/res/icons/16x16/nodes/file-swf.png';Icons['file-text-cgi.png']='/res/icons/16x16/nodes/file-text-cgi.png';Icons['file-text-css.png']='/res/icons/16x16/nodes/file-text-css.png';Icons['file-text-ht.png']='/res/icons/16x16/nodes/file-text-ht.png';Icons['file-text-html.png']='/res/icons/16x16/nodes/file-text-html.png';Icons['file-text-js.png']='/res/icons/16x16/nodes/file-text-js.png';Icons['file-text-pl.png']='/res/icons/16x16/nodes/file-text-pl.png';Icons['file-text-pm.png']='/res/icons/16x16/nodes/file-text-pm.png';Icons['file-text.png']='/res/icons/16x16/nodes/file-text.png';Icons['folders.png']='/res/icons/16x16/nodes/folders.png';Icons['isempty.png']='/res/icons/16x16/nodes/isempty.png';Icons['isexp.png']='/res/icons/16x16/nodes/isexp.png';Icons['mpe-bg.png']='/res/icons/16x16/nodes/mpe-bg.png';Icons['mpe-data-array.png']='/res/icons/16x16/nodes/mpe-data-array.png';Icons['mpe-data-hash.png']='/res/icons/16x16/nodes/mpe-data-hash.png';Icons['mpe-data-scalar.png']='/res/icons/16x16/nodes/mpe-data-scalar.png';Icons['mpe-end.png']='/res/icons/16x16/nodes/mpe-end.png';Icons['noexp.png']='/res/icons/16x16/nodes/noexp.png';Icons['unknown.png']='/res/icons/16x16/nodes/unknown.png';Icons['user-home.png']='/res/icons/16x16/nodes/user-home.png';this.getIcon=function(type){var parts=type.split('-');var icon=undefined;while(!icon&&parts.length>0){var name=parts.join('-')+'.png';icon=Icons[name];parts.pop();}
return icon||Icons['unknown.png'];};});ECMAScript.Extend('hub',function(ecma){this.Controller=function(){this.cache=new ecma.hub.Node('/','directory');this.listeners=[];this.fetchq={};};this.Controller.prototype.addListener=function(callback,scope){this.listeners.push([callback,scope]);};this.Controller.prototype.removeListener=function(callback,scope){for(var i=0;i<this.listeners.length;i++){var listener=this.listeners[i];if(callback===listener[0]&&scope===listener[1]){this.listeners.splice(i--,1);}}};this.Controller.prototype.get=function(addr){return this.cache.get(addr);}
this.Controller.prototype.fetch=function(addr,optBranch,onFetch){addr=ecma.data.addr_normalize(addr);if(!addr)return;var qkey=optBranch?addr+'+branch':addr;if(this.fetchq[qkey])return;this.fetchq[qkey]=true;var req=new ecma.hub.Fetch(this,addr,qkey,onFetch);var node=this.get(addr);if(ecma.util.defined(node)&&node.mtime&&node.fetched){var d=new Date((1000*node.mtime));req.setHeader('If-Modified-Since',d.toUTCString());req.setHeader('Cache-Control','max-age=0; must-revalidate');}else{req.setHeader('Cache-Control','no-fetch');}
var params={};if(optBranch)params.branch=true;req.submit(params);};this.Controller.prototype.store=function(addr,value){var xcmd=new ecma.hub.XCommand(this,'store',addr,this.onStore);xcmd.submit({'value':value});};this.Controller.prototype.onStore=function(r){var addr=this._setCache(r);this._sendUpdates('stored',addr,true);};this.Controller.prototype.create=function(addr,name,type){var xcmd=new ecma.hub.XCommand(this,'create',addr,this.onCreate);xcmd.submit({'name':name,'type':type});};this.Controller.prototype.onCreate=function(r){var addr=this._setCache(r);this._sendUpdates('fetched',addr,true);};this.Controller.prototype.remove=function(addr){var xcmd=new ecma.hub.XCommand(this,'remove',addr,this.onRemove);xcmd.submit();};this.Controller.prototype.onRemove=function(r){var addr=r.responseHash.get('head/meta/addr');this.cache.remove(addr);this._sendUpdates('removed',addr,true);};this.Controller.prototype.copy=function(addr,dest){var xcmd=new ecma.hub.XCommand(this,'copy',addr,this.onCopy);xcmd.submit({'dest':dest});};this.Controller.prototype.onCopy=function(r){var dest=this._setCache(r);this._sendUpdates('fetched',dest,true);};this.Controller.prototype.move=function(addr,dest){var xcmd=new ecma.hub.XCommand(this,'move',addr,this.onMove);xcmd.submit({'dest':dest});};this.Controller.prototype.onMove=function(r){var dest=this._setCache(r);this.cache.remove(addr);this._sendUpdates('removed',addr,true);this._sendUpdates('fetched',dest,true);};this.Controller.prototype.reorder=function(addr,value){var xcmd=new ecma.hub.XCommand(this,'reorder',addr,this.onReorder);xcmd.submit({'value':value});};this.Controller.prototype.onReorder=function(r){var addr=this._setCache(r);this._sendUpdates('stored',addr,true);};this.Controller.prototype._setCache=function(r){var rh=r.responseHash;var type=rh.get('head/meta/type');var body=rh.get('body');var addr;if(type=='subset'){body.iterate(function(key,value){addr=this._merge(value);},this);}else{addr=this._merge(rh);}
return addr;};this.Controller.prototype._merge=function(struct){var addr=struct.get('head/meta/addr');var type=struct.get('head/meta/type');var mtime=struct.get('head/meta/mtime');var body=struct.get('body');var text=struct.get('head/meta/content');var node=new ecma.hub.Node(addr,type,mtime,body,text);if('directory'==node.type){node.iterate(function(k,v){var addr2=ecma.data.addr_normalize(node.addr+'/'+k);var child=new ecma.hub.Node(v.get('addr'),v.get('type'),v.get('mtime'));child.fetched=false;node.set(k,child);},this);var value=this.get(node.addr);if(ecma.util.isa(value,ecma.data.Container)){var keys=node.keys();for(var i=0;i<keys.length;i++){var k=keys[i];var v=value.get(k);if(ecma.util.isa(v,ecma.data.Container)){if(v.type==node.get(k).type){if(v.mtime>=node.get(k).mtime)node.set(k,v);}else{this.cache.remove(v.addr);this._sendUpdates('removed',v.addr,true);}}}
value.iterate(function(k,v){if(!ecma.util.defined(node.get(k))){this.cache.remove(v.addr);this._sendUpdates('removed',v.addr,true);}},this);}}else{node.walk(function(k,v,d,a){var addr2=ecma.data.addr_normalize(node.addr+'/'+a);var type=undefined;if(ecma.util.isa(v,ecma.data.Container)){type=v instanceof ecma.data.OrderedHash?'data-hash':v instanceof ecma.data.Array?'data-array':undefined;}else{type='data-scalar';var ext=ecma.data.addr_ext(k);if(ext)type+='-'+ext;}
var child=new ecma.hub.Node(addr2,type,mtime,v);node.set(a,child);},this);}
if(addr=='/'){this.cache.mtime=node.mtime;}
this.cache.set(addr,node);return addr;};this.Controller.prototype._sendUpdates=function(action,addr,modified){var value=action=='removed'?{'addr':addr}:this.get(addr);for(var i=0;i<this.listeners.length;i++){var callback=this.listeners[i][0];var scope=this.listeners[i][1];try{ecma.dom.setTimeout(callback,0,scope,[action,value,modified]);}catch(ex){this.listeners.splice(i--,1);}}};});ECMAScript.Extend('hub',function(ecma){this.XCommand=function(ctrl,cmd,addr,cb){if(!cmd)throw'No command provided';if(!addr)throw'No address provided';if(!cb)throw'No callback provided';var options={method:'POST',headers:{'X-Command':cmd}};ecma.lsn.Request.call(this,addr,options);this.ctrl=ctrl;this.cb=cb;};this.XCommand.prototype=ecma.lang.Methods(ecma.lsn.Request);this.XCommand.prototype.onSuccess=function(xhr){this.cb.call(this.ctrl,xhr);};this.XCommand.prototype.onInternalServerError=function(xhr){throw xhr.statusText+': '+xhr.responseText;};});ECMAScript.Extend('hub',function(ecma){this.Fetch=function(ctrl,addr,qkey,onFetch){var options={method:'POST',headers:{'X-Command':'fetch'}};ecma.lsn.Request.call(this,addr,options);this.addr=addr;this.ctrl=ctrl;this.qkey=qkey;this.onFetch=onFetch;};this.Fetch.prototype=ecma.lang.Methods(ecma.lsn.Request);this.Fetch.prototype.onSuccess=function(xhr){this.addr=this.ctrl._setCache(xhr);this.ctrl._sendUpdates('fetched',this.addr,true);if(this.onFetch)this.onFetch(this.ctrl.get(this.addr));};this.Fetch.prototype.onNotModified=function(xhr){this.ctrl._sendUpdates('fetched',this.addr,false);if(this.onFetch)this.onFetch(this.ctrl.get(this.addr));};this.Fetch.prototype.onNotFound=function(xhr){if(this.ctrl.get(this.addr)){this.ctrl.cache.remove(this.addr);this.ctrl._sendUpdates('removed',this.addr,true);}
if(this.onFetch)this.onFetch();};this.Fetch.prototype.onInternalServerError=function(xhr){if(this.ctrl.get(this.addr)){this.ctrl.cache.remove(this.addr);this.ctrl._sendUpdates('removed',this.addr,true);}
if(this.onFetch)this.onFetch();};this.Fetch.prototype.onComplete=function(xhr){delete this.ctrl.fetchq[this.qkey];};});ECMAScript.Extend('hub',function(ecma){this.Node=function(addr,type,mtime,body,text){ecma.data.OrderedHash.apply(this);if(ecma.util.isa(body,ecma.data.Container)){body.iterate(function(k,v){this.set(k,v);},this);this.content=text;}else{this.content=body;}
this.mtime=mtime;this.addr=addr;this.type=type;this.icon=ecma.hub.getIcon(type);this.ccd=ecma.hub.ccd(type);this.fetched=true;this.dateStr='';this.timeStr='';this.dateObj=mtime?new Date(1000*mtime):undefined;if(this.dateObj){this.dateStr+=this.dateObj.getFullYear();this.dateStr+='-'+this._zero(this.dateObj.getMonth());this.dateStr+='-'+this._zero(this.dateObj.getDate());this.timeStr+=this._zero(this.dateObj.getHours());this.timeStr+=':'+this._zero(this.dateObj.getMinutes());this.timeStr+=':'+this._zero(this.dateObj.getSeconds());}};this.Node.prototype=ecma.lang.Methods(ecma.data.OrderedHash);this.Node.prototype.toXFR=function(){return this.type.match(/^data-scalar/)?ecma.data.xfr.format(this.content):this.type.match(/^data-array/)?ecma.data.xfr.format(this.values()):ecma.data.OrderedHash.prototype.toXFR.apply(this);};this.Node.prototype._zero=function(num){return num<10?'0'+num:num;};});ECMAScript.Extend('hub',function(ecma){this.List=function(e,dm,ra,opts){if(!e instanceof Object)throw'Illegal argument: e';if(!dm instanceof ecma.hub.Controller)throw'Illegal argument: dm';if(!opts instanceof Object)throw'Illegal argument: opts';this.opts={};ecma.util.overlay(this.opts,this.defaults,opts);this.id=ecma.util.randomId('nlist-');this.dm=dm;this.ce=ecma.dom.getElement(e);this.re=undefined;this.ra=undefined;this.sel=undefined;this.lsel=undefined;this.trg=undefined;this.exp=undefined;this.hl=undefined;this.kp=undefined;this.kpe=undefined;ecma.dom.include.style({href:'/res/css/hub_list.css'});this.dm.addListener(this._devt,this);this.chroot(ra);this._initkp();};this.List.prototype={chroot:function(a){var ra=a||'/';if(ra==this.ra)return;this.ra=ra;this.sel=undefined;this.trg=undefined;this.exp=undefined;this.re=this._getbopt('showRoot')?this._new_dl():this._new_dl(this.ra);ecma.dom.replaceChildren(this.ce,[this.re]);},select:function(a,delay){a=this._defa(a);this.sel=a;this.trg=a;this.exp=undefined;var dt=this._e(a,'dt');var n=this.dm.get(a);if(delay&&dt&&n){this._hl(n);setTimeout(ecma.lang.Callback(function(n){if(n.addr==this.sel){this._fetch(a,true);}else{}},this,[n]),delay);}else{this._fetch(a,true);}},expand:function(a,optSel){a=this._defa(a);if(optSel)this.sel=a;this.trg=a;this.exp=a;this._fetch(a,true);},isExpanded:function(n){return this._isexp(n.addr);},getSelected:function(){if(!ecma.util.defined(this.sel))return undefined;return this.dm.get(this.sel);},expandSelected:function(event){if(event)js.dom.stopEvent(event);var n=this.getSelected();if(n)this._expand(n);},collapseSelected:function(event){if(event)js.dom.stopEvent(event);var n=this.getSelected();if(n)this._collapse(n);},selectPrevious:function(event){if(!this.sel)return;if(event)js.dom.stopEvent(event);var ui=this._ui(this.sel)
if(ui.dt.previousSibling){var a=this._etoa(ui.dt.previousSibling);while(this._isexp(a)){var cui=this._ui(a);if(cui.dl.lastChild){a=this._etoa(cui.dl.lastChild);}else{break;}}
this.select(a,250);}else{var pui=this._pui(this.sel);if(pui&&pui.dt){this.select(this._etoa(pui.dt),250);}}},selectNext:function(event){if(!this.sel)return;if(event)js.dom.stopEvent(event);var ui=this._ui(this.sel)
if(this._isexp(this.sel)&&ui.dl.firstChild){this.select(this._etoa(ui.dl.firstChild),250);}else if(ui.dd.nextSibling){this.select(this._etoa(ui.dd.nextSibling),250);}else{var pui=this._pui(this.sel);while(pui&&pui.dt){if(pui.dd.nextSibling){this.select(this._etoa(pui.dd.nextSibling),250);break;}
pui=this._pui(this._etoa(pui.dt));}}},focus:function(a){if(!a)return;var dt=this._e(a,'dt');if(!dt)return;dt.appendChild(this.kpe);this.kpe.focus();},defaults:{showRoot:true,autoExpand:false,canDisplay:true,canExpand:function(n){return n.ccd;},formatName:function(n,str){return str;},formatDetail:function(n){return[];},onClick:function(event,n){},onSelect:function(n){}},destroy:function(){this.dm.removeListener(this._devt,this);},_initkp:function(){var btnStyle={'margin':'0','padding':'0','width':'1px','height':'1px','border':'none','background':'transparent','position':'absolute','left':'0','z-index':'-1'};this.kpe=ecma.dom.getBody().appendChild(ecma.dom.createElement('button',{'class':'nlist','style':btnStyle}));this.kp=new ecma.dom.KeyPress({trace:false}).attach(this.kpe);this.kp.setHandler('up',this.selectPrevious,this);this.kp.setHandler('down',this.selectNext,this);this.kp.setHandler('left',this.collapseSelected,this);this.kp.setHandler('right',this.expandSelected,this);},_fetch:function(a,branch){this.dm.fetch(a,branch);},_devt:function(action,n,modified){if(action=='fetched'||action=='stored'){if(n.addr==this.trg){if(this._e(n.addr,'dt')&&!modified){if(n.addr==this.exp&&!this._isexp(n.addr)){this._populate(n);}}else{this._populate(n);}
this.exp=undefined;this.trg=undefined;var tgl=this._e(n.addr,'tgl');if(n.length>0&&ecma.dom.hasClassName(tgl,'empty')){var cnodes=n.values();for(var i=0;i<cnodes.length;i++){if(this._canDisplay(cnodes[i])){ecma.dom.removeClassNames(tgl,'empty');break;}}}
if(n.addr==this.sel)this._sel(n);}else if(this._e(n.addr,'dt')&&modified&&this._isexp(n.addr)){this._populate(n);}else if(!this._e(n.addr,'dt')&&this._p(n.addr,'dt')&&this._isexp(ecma.data.addr_parent(n.addr))&&this._canDisplay(n)){var pn=this._pn(n.addr);if(pn)this._populate(pn);}}else if(action=='removed'){var ui=this._ui(n.addr);var sel=undefined;if(ecma.util.defined(this.sel)&&this.sel.indexOf(n.addr)==0){if(ui.dt){var e=ui.dt.nextSibling&&ui.dt.nextSibling.nextSibling?ui.dt.nextSibling.nextSibling:ui.dt.previousSibling?ui.dt.previousSibling.previousSibling:ui.dt.parentNode;var sel=this._etoa(e);}else{sel=ecma.data.addr_parent(n.addr);}}
for(var k in ui){if(!(ui[k]&&ui[k].parentNode))continue;ui[k].parentNode.removeChild(ui[k]);}
if(sel)this.select(sel);this.focus(sel);}else{}},_populate:function(n){if(n.addr.indexOf(this.ra)!=0)return;var parts=[this.ra];if(n.addr!=this.ra){var a2=n.addr.substring(this.ra.length);parts=parts.concat(ecma.data.addr_split(a2));}
var segments=new Array();for(var i=0;i<parts.length;i++){segments.push(parts[i]);var seg_a=ecma.data.addr_join(segments);var seg_n=this.dm.get(seg_a);if(this._canDisplay(seg_n)){if(!this._e(seg_n.addr,'dl')){var nextsib=undefined;if((i+1)<parts.length){nextsib=this._e(ecma.data.addr_join(segments.concat(parts[i+1])),'dt');}
this._new(seg_n,nextsib);}else{this._update(seg_n);}}else{continue;}
if(seg_a==n.addr&&n.addr!=this.exp&&!this._isexp(n.addr))break;if(!this._canexp(seg_n))break;var h=0;var cnodes=seg_n.values();for(var j=0;j<cnodes.length;j++){var cn=cnodes[j];if(this._canDisplay(cn)){if(!this._e(cn.addr,'dl')){var nextsib=undefined;if((j+1)<cnodes.length){nextsib=this._e(cnodes[j+1].addr,'dt');}
this._new(cn,nextsib);}else{this._update(cn);}}else{h++;}}
var tgl=this._e(seg_n.addr,'tgl');if(h==seg_n.length){ecma.dom.addClassNames(tgl,'empty');ecma.dom.removeChildren(this._e(seg_n.addr,'dl'));}else{ecma.dom.removeClassNames(tgl,'empty');}}},_collapse:function(n){var ui=this._ui(n.addr);ecma.dom.removeClassNames(ui.tgl,'isexp');ecma.dom.setStyle(ui.dl,'display','none');},_expand:function(n){var ui=this._ui(n.addr);ecma.dom.setStyle(ui.dl,'display','block');this.trg=n.addr;this.exp=n.addr;this._fetch(n.addr);},_sel:function(n){this._hl(n);this.opts.onSelect.apply(this,[n]);this.lsel=this.sel;},_hl:function(n){var dt=this._e(n.addr,'dt');if(dt===this.hl)return;if(this.hl)ecma.dom.removeClassNames(this.hl,'sel');this.hl=dt;if(this.hl){ecma.dom.addClassNames(this.hl,'sel');this._scroll(n);this.focus(n.addr);return true;}
return false;},_scroll:function(n){var dt=this._e(n.addr,'dt');var pt=(this.ce.scrollTop);var ph=ecma.dom.getHeight(this.ce);var tt=ecma.dom.getTop(dt)-ecma.dom.getTop(this.ce);var tb=ecma.dom.getBottom(dt)-ecma.dom.getTop(this.ce);if(tb>(pt+ph)||(tt<pt)){var pm=ecma.util.asInt(pt+(ph/2));var m=ecma.util.asInt(tt-(ph/2));this.ce.scrollTop=m;}},_vis:function(n){var p_tgl=this._p(n.addr,'tgl');if(p_tgl)ecma.dom.addClassNames(p_tgl,'canexp','isexp');},_getbopt:function(name,n){return typeof(this.opts[name])=='function'?this.opts[name].apply(this,[n]):this.opts[name];},_autoExpand:function(n){return this._getbopt('autoExpand',n);},_canDisplay:function(n){return this._getbopt('canDisplay',n);},_formatName:function(n){var name=undefined;if(n.addr==this.ra){name=n.addr;}else{name=ecma.data.addr_name(n.addr);if(!ecma.util.defined(name))name=n.addr;}
return this.opts.formatName.apply(this,[n,name]);},_osel:function(event,n){this.focus(n.addr);this.opts.onClick.apply(this,[event,n]);if(event.stopped)return;this.sel=n.addr;if(this._canexp(n)&&this._autoExpand(n)){this._expand(n);}else{this.sel=n.addr;this.trg=n.addr;this._fetch(n.addr);}
ecma.dom.stopEvent(event);},_omover:function(event,n){ecma.dom.addClassNames(this._e(n.addr,'dt'),'hl');},_omout:function(event,n){ecma.dom.removeClassNames(this._e(n.addr,'dt'),'hl');},_toggle:function(event,n){var tgl=this._e(n.addr,'tgl');if(ecma.dom.hasClassName(tgl,'empty')||!this._canexp(n)){return this._osel(event,n);}
if(this._isexp(n.addr)){this._collapse(n);}else{this._expand(n);}
ecma.dom.stopEvent(event);},_new:function(n,nextsib){var dl=this._new_dl(n.addr);var elems=[this._new_dt(n),this._new_dd(n,dl)];if(nextsib){ecma.dom.insertChildrenBefore(nextsib,elems);}else{var pe=this._p(n.addr,'dl');if(!pe)throw'Cannot obtain parent element';ecma.dom.appendChildren(pe,elems);}
var ui=this._ui(n.addr);if(this._canexp(n)){ecma.dom.addClassNames(ui.tgl,'canexp');}else{ecma.dom.removeClassNames(ui.tgl,'canexp','isexp')}
ecma.dom.setAttribute(ui.lbl,'innerHTML',this._formatName(n));this._update(n,ui);return dl;},_update:function(n,ui){if(!ui)ui=this._ui(n.addr);var dtlItems=this.opts.formatDetail(n);if(dtlItems&&dtlItems.length>0){var list=[];for(var i=dtlItems.length-1;i>=0;i--){list.push(ecma.dom.createElement('li',{'class':'li'+(i+1),innerHTML:dtlItems[i]}));}
ecma.dom.replaceChildren(this._e(n.addr,'dtl'),list);}
this._vis(n);},_new_dt:function(n){var onDblClick=this._autoExpand(n)?undefined:[this._toggle,this,[n]];return ecma.dom.createElements('dt',{id:this._eid(n.addr,'dt'),onClick:[this._osel,this,[n]],onDblClick:onDblClick,onMouseOver:[this._omover,this,[n]],onMouseOut:[this._omout,this,[n]],onSelectStart:function(event){ecma.dom.stopEvent(event);},onMouseDown:function(event){ecma.dom.stopEvent(event);}},['ul',{id:this._eid(n.addr,'dtl')},'div',{id:this._eid(n.addr,'tgl'),onClick:[this._toggle,this,[n]],'class':'tgl'},'img',{id:this._eid(n.addr,'ico'),title:n.addr,onClick:[this._osel,this,[n]],'class':'ico',src:n.icon},'a',{id:this._eid(n.addr,'lbl'),'class':'name',style:{cursor:'default'}}]);},_new_dd:function(n,dl){return ecma.dom.createElements('dd',{id:this._eid(n.addr,'dd')},[dl]);},_new_dl:function(a){if(!ecma.util.defined(a))a='';return ecma.dom.createElement('dl',{id:this._eid(a,'dl'),'class':'nlist'});},_defa:function(a){if(ecma.util.defined(a)){if(a.indexOf(this.ra)!=0)
throw'Address outside of list root: '+a;}else{a=this.ra;}
return a;},_canexp:function(n){return this._getbopt('canExpand',n);},_isexp:function(a){var tgl=this._e(a,'tgl');if(!tgl)return;return ecma.dom.hasClassName(tgl,'isexp')||ecma.dom.hasClassName(tgl,'empty')?true:ecma.dom.hasClassName(tgl,'canexp')?false:true;},_etoa:function(e){if(!e)return;var id=e.id;var a=id.substr(this.id.length);return a.substr(0,a.indexOf('?'));},_eid:function(a,tag){return this.id+a+'?'+tag;},_pid:function(a,tag){if(a==this.ra)return this._eid('',tag);return this._eid(ecma.data.addr_parent(a),tag);},_e:function(a,tag){return ecma.dom.getElement(this._eid(a,tag));},_p:function(a,tag){return ecma.dom.getElement(this._pid(a,tag));},_pn:function(a){var pa=ecma.data.addr_parent(a);if(pa.indexOf(this.ra)!=0)return undefined;if(pa==a)return undefined;return this.dm.get(pa);},_pui:function(a){if(a!=this.ra&&a.indexOf(this.ra)==0){return this._ui(ecma.data.addr_parent(a));}},_ui:function(a){return{dt:this._e(a,'dt'),tgl:this._e(a,'tgl'),ico:this._e(a,'ico'),lbl:this._e(a,'lbl'),dd:this._e(a,'dd'),dl:this._e(a,'dl')};}};});ECMAScript.Extend('lsn',function(ecma){var _globalMask=undefined;var _defaultStyles={'opacity':.75,'background-color':'white'};var _requiredStyles={'position':'absolute','margin':0,'padding':0,'border':0,'overflow':'hidden','top':0,'left':0,'width':0,'height':0};this.Mask=function(optStyle){this.showCount=0;this.style=ecma.util.overlay({},_defaultStyles,optStyle,_requiredStyles);this.ui=ecma.dom.createElement('div');if(ecma.dom.isIE){this.ui.appendChild(ecma.dom.createElement('iframe',{'width':'0','height':'0','frameborder':'0','src':'about:blank','style':{'width':'0','height':'0','visibility':'hidden'}}));}};this.Mask.prototype={show:function(optStyle){this.showCount++;if(this.showCount>1)return;this.initDOM();this.applyStyles(optStyle);this.ce.appendChild(this.ui);this.t=ecma.dom.getTop(this.ui);this.l=ecma.dom.getLeft(this.ui);ecma.dom.setStyle(this.html,'width','100%');ecma.dom.setStyle(this.html,'height','100%');this.resize();this.resizeEvent=new ecma.dom.EventListener(window,'resize',this.resize,this);return this;},initDOM:function(){var body=ecma.dom.getBody();this.ce=ecma.dom.browser.isIE?body:body.parentNode||body;this.html=body.parentNode;this.canvas=new ecma.dom.Canvas();},applyStyles:function(optStyle){var style=ecma.util.overlay(this.style,optStyle);var opacity=undefined;if(style){for(var k in style){if(k=='opacity'){opacity=style[k];continue;}
ecma.dom.setStyle(this.ui,k,style[k]);}}
if(ecma.util.defined(opacity))ecma.dom.setOpacity(this.ui,opacity);},getElement:function(){return this.ui;},hide:function(){this.showCount--;if(this.showCount<0)this.showCount=0;if(this.showCount)return;try{this.ce.removeChild(this.ui);this.resizeEvent.remove();}catch(ex){}
return this;},resize:function(){var w=this.canvas.getWidth()-this.l;var h=this.canvas.getHeight()-this.t;ecma.dom.setStyle(this.ui,'width',w+"px");ecma.dom.setStyle(this.ui,'height',h+"px");}};this.showMask=function(style){if(!_globalMask)_globalMask=new ecma.lsn.Mask();return _globalMask.show(style);};this.hideMask=function(){if(_globalMask)return _globalMask.hide();};});ECMAScript.Extend('lsn',function(ecma){this.setMoveTarget=function(event,elem){return new ecma.lsn.Move(event,elem);},this.Move=function(event,elem){this.elem=ecma.dom.getElement(elem);this.listenOn=ecma.dom.browser.isIE?ecma.document:ecma.window;if(!this.elem)return;this.mmEvent=new ecma.dom.EventListener(this.listenOn,'mousemove',this.onMouseMove,this);this.muEvent=new ecma.dom.EventListener(this.listenOn,'mouseup',this.onMouseUp,this);var vp=ecma.dom.getViewportPosition();ecma.dom.makePositioned(elem);var pointer=ecma.dom.getEventPointer(event);this.min_x=vp['left'];this.min_y=vp['top'];this.abs_x=ecma.dom.getLeft(this.elem);this.abs_y=ecma.dom.getTop(this.elem);this.orig_x=ecma.util.asInt(ecma.dom.getStyle(this.elem,'left'));this.orig_y=ecma.util.asInt(ecma.dom.getStyle(this.elem,'top'));this.orig_z=ecma.dom.getStyle(this.elem,'z-index');this.orig_mx=pointer.x;this.orig_my=pointer.y;this.max_x=vp['left']+vp['width']-ecma.dom.getWidth(this.elem);this.max_y=vp['top']+vp['height']-ecma.dom.getHeight(this.elem);ecma.dom.setStyle(this.elem,'left',this.orig_x.toString(10)+'px');ecma.dom.setStyle(this.elem,'top',this.orig_y.toString(10)+'px');ecma.dom.setStyle(this.elem,'z-index','199');ecma.dom.stopEvent(event);};this.Move.prototype={onMouseUp:function(event){ecma.dom.setStyle(this.elem,'z-index',this.orig_z);this.mmEvent.remove();this.muEvent.remove();},onMouseMove:function(event){var pointer=ecma.dom.getEventPointer(event);var delta_x=pointer.x-this.orig_mx;var delta_y=pointer.y-this.orig_my;var new_x=this.orig_x+delta_x;var new_y=this.orig_y+delta_y;if(this.abs_x+delta_x>=this.max_x)new_x=this.max_x;if(this.abs_y+delta_y>=this.max_y)new_y=this.max_y;if(this.abs_x+delta_x<this.min_x)new_x=this.min_x;if(this.abs_y+delta_y<this.min_y)new_y=this.min_y;if(new_x!=null)
ecma.dom.setStyle(this.elem,'left',(new_x).toString(10)+'px');if(new_y!=null)
ecma.dom.setStyle(this.elem,'top',(new_y).toString(10)+'px');ecma.dom.stopEvent(event);}};});ECMAScript.Extend('lsn',function(ecma){var _css=null;this.initDialogStyles=function(){if(_css)return;_css=new ecma.dom.StyleSheet();_css.createRule('.dlghidden',{'visibility':'hidden','z-index':'-1','position':'absolute','left':'-1000em'});};this.includeHead=function(){ecma.lsn.includeHeadCSS.apply(this,arguments);ecma.lsn.includeHeadJS.apply(this,arguments);};this.includeHeadCSS=function(head,id,caller){if(head){var links=head.get('links/css');if(links){links.iterate(function(k,v){ecma.dom.include.style({'href':v});});}
var text=head.get('css');if(text){ecma.dom.include.style({'text':text});}}};this.includeHeadJS=function(head,id,caller,cb){if(head){var hasLoaded=false;var links=head.get('links/js');if(links){var list=links.values();var includeNext;includeNext=function(){if(list.length){var uri=list.shift();ecma.dom.include.script({'src':uri},includeNext);}else{hasLoaded=true;}}
includeNext();}else{hasLoaded=true;}
var text=head.get('js');if(text){ecma.dom.include.script({'text':text});}
var events=head.get('events/js');if(events){events.iterate(function(target,events){events.iterate(function(idx,kvpair){var js=ecma;var window=ecma.window;var document=ecma.document;var evtFunc=ecma.lang.Callback(function(){eval(kvpair.get('value'));},caller);if(target=='dialog'||target=='widget'){if(caller){caller.includeEvent(kvpair.get('key'),evtFunc);}}else{ecma.dom.addEventListener(eval(target),kvpair.get('key'),evtFunc);}});});}
if(cb){ecma.dom.waitUntil(cb,function(){return hasLoaded;},10,caller);}}else{if(cb)cb.apply(caller);}};this.Widget=function(uri,options){ecma.lsn.initDialogStyles();if(!this.id)this.id=ecma.util.randomId('widget_');this.request=new ecma.lsn.Request(uri,{'onSuccess':ecma.lang.Callback(this._onSuccess,this),'onInternalServerError':ecma.lang.Callback(this._onFailure,this)});this.container=undefined;this.handleKeypress={};this.sticky=false;this.nodeStyles=[];this.refetch=true;this.events={};this.includeEvents={};this.props={};this.jsLoaded=false;this.hidden=false;for(var k in options){this.setOption(k,options[k]);}
this.reset();};this.Widget.prototype={reset:function(){this.nodes=null;this.values={};this.btn_events=[];this.includeEvents={};this._stopEvent={};this._eventName=[];this.hasLoaded=false;},setOption:function(key,value){if(key.match(/^on[A-Z]/)){this.addEvent(key,value);}else{this[key]=value;}},relayEvent:function(event,name){ecma.dom.stopEvent(event);this.doEvent(name);},addEvent:function(name,func){name=name.replace(/^on/,'');name=name.toLowerCase();if(!this.events[name])this.events[name]=new Array();this.events[name].push(func);},includeEvent:function(name,func){name=name.replace(/^on/,'');name=name.toLowerCase();if(!this.includeEvents[name])this.includeEvents[name]=new Array();this.includeEvents[name].push(func);},stopEvent:function(){if(!this._eventName.length)return;var name=this._eventName[this._eventName.length-1];this._stopEvent[name]=true;},_isStopped:function(name){return this._stopEvent[name];},_beginEvent:function(name){this._eventName.push(name);},_endEvent:function(name){delete this._stopEvent[name];this._eventName.pop();},doEvent:function(name){this._beginEvent(name);if(this._isStopped(name))return this._endEvent(name);if(this.includeEvents[name]){for(var i=0;i<this.includeEvents[name].length;i++){this.includeEvents[name][i].apply(this);if(this._isStopped(name))return this._endEvent(name);}}
if(this.events[name]){for(var i=0;i<this.events[name].length;i++){var cb=this.events[name][i];ecma.lang.callback(cb,this,[this]);if(this._isStopped(name))return this._endEvent(name);}}
if(name=='init'){ecma.dom.waitUntil(this._onInit,this._jsLoaded,10,this,['ready']);}
if(name=='ok'||name=='cancel'){this.hide();}
if(name=='hide'){this.onHide();}
if(name=='load'){this.hasLoaded=true;}
this._endEvent(name);},show:function(params){this.params=params?params:{};this.beforeShow();if(this.nodes){if(this.refetch){this.destroy();this.request.submit();}else{this._enableUI();this.doEvent('init');}}else{this.request.submit();}},getElementById:function(id){var elem=null;for(var i=0,node;node=this.nodes[i];i++){elem=ecma.dom.getDescendantById(node,id);if(elem)break;}
return elem;},beforeShow:function(){},_onFailure:function(xhr){this.onHide();},_onSuccess:function(r){this.doc=r.responseHash;var tmpDiv=ecma.dom.createElement('div',{'innerHTML':this.doc.get('body')});this.nodes=ecma.util.args(tmpDiv.childNodes);this.nodes.push(ecma.dom.createElement('noscript',{id:this.id+'_dom_ready'}));this._appendNodes();this._includeRes();this.doEvent('init');},_appendNodes:function(){var ce=ecma.dom.getElement(this.container||ecma.dom.getBody());for(var i=0;i<this.nodes.length;i++){var node=this.nodes[i];if(!node.style){this.nodes.splice(i--,1);continue;}
if(this.zIndex){ecma.dom.setStyle(node,'z-index',this.zIndex);}
ce.appendChild(node);}
if(this.nodes.length==1){throw'No element nodes found';}},_includeRes:function(){ecma.lsn.includeHeadCSS(this.doc.get('head'),this.id,this);ecma.dom.waitUntil(this._includeJS,this._domLoaded,10,this);},_includeJS:function(){this.jsLoaded=false;ecma.lsn.includeHeadJS(this.doc.get('head'),this.id,this,function(){this.jsLoaded=true;});},_domLoaded:function(){return ecma.dom.getElement(this.id+'_dom_ready')?true:false;},_jsLoaded:function(){return this.jsLoaded;},_onInit:function(){if(!this.hasLoaded)this.doEvent('load');this.doEvent('show');this.hidden=false;this.doEvent('ready');},_removeUI:function(){if(this.nodes){for(var i=0;i<this.nodes.length;i++){ecma.dom.removeElement(this.nodes[i]);}}},_disableUI:function(){if(!this.sticky)return this._removeUI();if(this.nodes){for(var i=0;i<this.nodes.length;i++){this.nodeStyles[i]=this._hideElement(this.nodes[i]);}}},_enableUI:function(){if(!this.sticky)return this._appendNodes();if(this.nodes){for(var i=0;i<this.nodes.length;i++){ecma.dom.setStyles(this.nodes[i],this.nodeStyles[i]);}
this.nodeStyles=[];}},_hideElement:function(elem){var bak={'visibility':ecma.dom.getStyle(elem,'visibility'),'z-index':ecma.dom.getStyle(elem,'z-index'),'position':ecma.dom.getStyle(elem,'position'),'left':ecma.dom.getStyle(elem,'left')};ecma.dom.setStyles(elem,{'visibility':'hidden','z-index':'-1','position':'absolute','left':'-1000em'});return bak;},_showElement:function(){},hide:function(){if(this.hidden)return;this.doEvent('hide');this._disableUI();this.hidden=true;},onHide:function(){},destroy:function(){this.hide();this._removeUI();this.doEvent('destroy');this.reset();}};});ECMAScript.Extend('lsn',function(ecma){this.dlg={};var _zIndex=102;var _zCount=0;this.zIndex=function(){return _zIndex+(2*_zCount);}
this.zIndexAlloc=function(){_zCount++;return ecma.lsn.zIndex();}
this.zIndexFree=function(){_zCount--;return ecma.lsn.zIndex();};var baseClass=ecma.lsn.Widget;var proto=ecma.lang.Methods(baseClass);this.Dialog=function(uri,userOpts){this.id=ecma.util.randomId('dlg_');var opts={modal:true,modalOpacity:.50};ecma.util.overlay(opts,userOpts);baseClass.apply(this,[uri,opts]);this.mask=null;};this.Dialog.prototype=proto;proto.beforeShow=function(){this.zIndex=ecma.lsn.zIndexAlloc();if(this.modal){this.mask=new ecma.lsn.Mask();this.mask.show({'opacity':this.modalOpacity,'z-index':this.zIndex-1});}};proto.onHide=function(){if(this.modal){this.mask.hide();this.mask=null;}
ecma.lsn.zIndexFree();};});ECMAScript.Extend('lsn',function(ecma){this.PageLayout=function(opts){ecma.util.overlay(this,opts);ecma.dom.addEventListener(ecma.window,'load',this.load,this);ecma.dom.addEventListener(ecma.window,'resize',this.resize,this);ecma.dom.addEventListener(ecma.window,'unload',this.unload,this);};this.PageLayout.prototype={load:function(event){this.resize(event);},resize:function(event){},unload:function(event){}};});ECMAScript.Extend('lsn',function(ecma){this.DragHandle=function(elem,opts){this.opts={'threshold':0,'onMouseDown':function(event,dh){event.stop()},'onMouseUp':function(event,dh){event.stop()},'onMouseMove':function(event,dh){event.stop()}};ecma.util.overlay(this.opts,opts);this.elem=ecma.dom.getElement(elem);if(!this.elem)return;this.listenOn=ecma.dom.browser.isIE?ecma.document:ecma.window;ecma.dom.addEventListener(this.elem,'mousedown',this.onMouseDown,this);this.reset();this.mmEvent=null;this.muEvent=null;};this.DragHandle.prototype={reset:function(){this.orig_mx=0;this.orig_my=0;this.delta_x=0;this.delta_y=0;this.dragging=false;},onMouseDown:function(event){this.reset();var pointer=ecma.dom.getEventPointer(event);this.orig_mx=pointer.x;this.orig_my=pointer.y;this.mmEvent=new ecma.dom.EventListener(this.listenOn,'mousemove',this.onMouseMove,this);this.muEvent=new ecma.dom.EventListener(this.listenOn,'mouseup',this.onMouseUp,this);ecma.lang.callback(this.opts.onMouseDown,this,[event,this]);},onMouseUp:function(event){this.mmEvent.remove();this.muEvent.remove();this.dragging=false;ecma.lang.callback(this.opts.onMouseUp,this,[event,this]);},onMouseMove:function(event){var pointer=ecma.dom.getEventPointer(event);this.delta_x=pointer.x-this.orig_mx;this.delta_y=pointer.y-this.orig_my;if(!this.dragging&&Math.abs(this.delta_x)<this.opts.threshold&&Math.abs(this.delta_y)<this.opts.threshold){return}
this.dragging=true;ecma.lang.callback(this.opts.onMouseMove,this,[event,this]);}};});ECMAScript.Extend('lsn',function(ecma){_impl={};this.ContentController=function(){this.impl=ecma.dom.browser.isIE?new _impl.IE():ecma.dom.browser.isGecko?new _impl.Gecko():new _impl.Gecko();if(!this.impl)throw'no ContentController implementation for this browser';};this.ContentController.prototype.attach=function(elem){elem=ecma.dom.getElement(elem);return this.impl.attach.apply(this.impl,[elem]);};this.ContentController.prototype.detach=function(){return this.impl.detach.apply(this.impl,[]);};this.ContentController.prototype.insertHTML=function(){return this.impl.insertHTML.apply(this.impl,arguments);};this.ContentController.prototype.getFocusElement=function(){return this.impl.getFocusElement.apply(this.impl,arguments);};this.ContentController.prototype.insertElement=function(){return this.impl.insertElement.apply(this.impl,arguments);};this.ContentController.prototype.selectElement=function(){return this.impl.selectElement.apply(this.impl,arguments);};this.ContentController.prototype.focusBefore=function(){return this.impl.focusBefore.apply(this.impl,arguments);};this.ContentController.prototype.focusAfter=function(){return this.impl.focusAfter.apply(this.impl,arguments);};this.ContentController.prototype.exec=function(){return this.impl.exec.apply(this.impl,arguments);};this.ContentController.prototype.toggle=function(tagName){return this.impl.toggle.apply(this.impl,arguments);};_impl.Gecko=function(){};_impl.Gecko.prototype={attach:function(elem){this.target=elem;this.exec('useCSS',true);},detach:function(){this.target=undefined;},getFocusElement:function(){var sel=this.getSelection();var range=sel.getRangeAt(0);var elem=range.commonAncestorContainer;while(elem&&elem.nodeType!=Node.ELEMENT_NODE){elem=elem.parentNode;}
return elem;},insertElement:function(elem){var sel=this.getSelection();if(false==sel.isCollapsed){sel.deleteFromDocument();sel=this.getSelection();}
if(sel.isCollapsed){var nFocus=sel.focusNode;var focusOffset=sel.focusOffset;switch(nFocus.nodeType){case Node.ELEMENT_NODE:var nCurr=focusOffset>0?nFocus.childNodes[focusOffset-1]:nFocus;if(nCurr===this.target){if(nCurr.childNodes.length>0){nCurr.insertBefore(elem,nCurr.childNodes[0]);}else{nCurr.appendChild(elem);}}else{ecma.dom.insertChildrenAfter(nCurr,[elem]);}
break;case Node.TEXT_NODE:var a=nFocus.nodeValue.substr(0,focusOffset);var b=nFocus.nodeValue.substr(focusOffset);var nA=ecma.dom.createElement('#text',{'nodeValue':a});var nB=ecma.dom.createElement('#text',{'nodeValue':b});ecma.dom.insertChildrenBefore(nFocus,[nA,elem,nB]);nFocus.parentNode.removeChild(nFocus);break;default:throw'no implementation for selected nodeType';}
this.focusAfter(elem);}},selectElement:function(elem){var sel=this.getSelection();sel.removeAllRanges();var range=ecma.document.createRange();range.selectNode(elem);sel.addRange(range);return sel;},focusBefore:function(elem){sel=this.selectElement(elem);sel.collapseToStart();},focusAfter:function(elem){sel=this.selectElement(elem);sel.collapseToEnd();},insertHTML:function(html){this.exec('insertHTML',html);},exec:function(cmd,args){ecma.document.execCommand(cmd,false,args);},toggle:function(tagName){},getSelection:function(){var sel=ecma.window.getSelection();if(!sel.anchorNode)throw'target does not have focus';return sel;},setSelection:function(){}};_impl.IE=function(){};_impl.IE.prototype={attach:function(elem){this.target=elem;},detach:function(){this.target=undefined;},getFocusElement:function(){var sel=this.getSelection();var range=sel.createRange();return sel.type=='Control'?range.item(0):range.parentElement();},insertElement:function(elem){var sel=this.getSelection();var tmp=this._insertTemp();this.replaceElement(tmp,elem);},replaceElement:function(eOld,eNew){eOld.appendChild(eNew);eOld.removeNode();},_insertTemp:function(){var id=ecma.util.randomId();var html="<span id='"+id+"'></span>";this.getRange().pasteHTML(html);var elem=ecma.dom.getElement(id);return elem;},selectElement:function(elem){var range=ecma.dom.getBody().createControlRange();range.addElement(elem);range.select();},focusBefore:function(elem){this.selectElement(elem);},focusAfter:function(elem){this.selectElement(elem);},insertHTML:function(html){this.getRange().pasteHTML(html);},exec:function(cmd,args){ecma.document.execCommand(cmd,args?false:true,args);},toggle:function(tagName){var sel=ecma.document.selection;var ranges=sel.createRangeCollection();for(var i=0;i<ranges.length;i++){var textRange=ranges.item(i);var html=textRange.htmlText;if(html){var re=new RegExp('\\s*<'+tagName+'>');if(html.match(re,'g')){}else{}
textRange.pasteHTML(html);}}},getSelection:function(){var sel=ecma.document.selection;return sel;},getRange:function(){return this.getSelection().createRange();}};});ECMAScript.Extend('lsn',function(ecma){this.ComboBox=function(){this.ctrl=ecma.dom.createElement('input');this.toggle=ecma.dom.createElement('img',{'alt':'[...]','src':'/res/images/dropdown.png','onClick':[this.onToggle,this],'style':{'font-size':'8pt','width':'16px','height':'16px','cursor':'pointer','vertical-align':'text-bottom'}});if(!this.ui)this.ui={box:null};this.mask=new ecma.lsn.Mask();this.vUnmask=new ecma.dom.EventListener(this.mask.getElement(),'click',this.hide,this);};var proto=this.ComboBox.prototype={};proto.destroy=function(){this.vUnmask.remove();};proto.attach=function(elem){var ctrl=ecma.dom.getElement(elem);ecma.dom.insertAfter(this.toggle,ctrl);ecma.dom.addClassName(ctrl,'combo');this.ctrl=ctrl;};proto.setPosition=function(){var box=this.getElement();ecma.dom.setStyle(box,'top',ecma.dom.getBottom(this.ctrl)+'px');ecma.dom.setStyle(box,'left',ecma.dom.getLeft(this.ctrl)+'px');ecma.dom.setStyle(box,'width',(ecma.dom.getWidth(this.ctrl))+'px');};proto.show=function(){this.setPosition();var zIndex=ecma.lsn.zIndexAlloc();ecma.dom.setStyle(this.ui.box,'z-index',zIndex);ecma.dom.setAttribute(this.ctrl,'disabled','disabled');this.mask.show({'opacity':0,'z-index':zIndex-1});ecma.dom.setStyle(this.ui.box,'visibility','visible');ecma.dom.getBody().appendChild(this.ui.box);var boxBottom=ecma.dom.getBottom(this.ui.box);var vpHeight=ecma.dom.getViewportPosition().height;if(boxBottom>vpHeight){this.ui.tmpBottomMargin=ecma.dom.createElement('div',{'style':{'position':'relative','height':((boxBottom-vpHeight)+50)+'px'}});ecma.dom.getBody().appendChild(this.ui.tmpBottomMargin);}
this.isVisible=true;};proto.hide=function(){ecma.dom.removeAttribute(this.ctrl,'disabled','disabled');ecma.dom.setStyle(this.ui.box,'visibility','hidden');ecma.dom.removeElement(this.ui.box);ecma.lsn.zIndexFree();this.mask.hide();this.isVisible=false;if(this.ui.tmpBottomMargin){ecma.dom.removeElement(this.ui.tmpBottomMargin);this.ui.tmpBottomMargin=null;}};proto.onToggle=function(event){ecma.dom.stopEvent(event);if(this.isVisible){this.hide();}else{this.show();}};proto.getElement=ecma.lang.createAbstractFunction();});ECMAScript.Extend('lsn',function(ecma){var CActionDispatcher=ecma.action.ActionDispatcher;var proto=ecma.lang.createMethods(CActionDispatcher);this.InputListener=function(elem){CActionDispatcher.apply(this);this.elem=ecma.dom.getElement(elem);this.setValue();this.kpevt=new ecma.dom.EventListener(elem,'keypress',this.onKeyPress,this);this.checkInterval=75;this.checkTimeout=10*this.checkInterval;this.checkCount=0;};this.InputListener.prototype=proto;proto.setValue=function(){this.currentValue=ecma.dom.getValue(this.elem);};proto.onKeyPress=function(){if(this.intervalId)return;this.intervalId=ecma.dom.setInterval(this.checkValue,this.checkInterval,this);};proto.checkValue=function(){var value=ecma.dom.getValue(this.elem);if(this.currentValue!=value){this.clearInterval();var prevValue=this.currentValue;this.setValue();this.dispatchAction('change',this.currentValue,prevValue);}else{this.checkCount++;if((this.checkInterval*this.checkCount)>this.checkTimeout){this.clearInterval();}}};proto.clearInterval=function(){ecma.dom.clearInterval(this.intervalId);this.intervalId=null;this.checkCount=0;};proto.destroy=function(){this.clearInterval();this.kpevt.remove();};});ECMAScript.Extend('dom',function(ecma){this.toggleDisplay=function(elem){var v1=js.dom.getStyle(elem,'display');var v2=v1=='none'?'block':'none';js.dom.setStyle(elem,'display',v2);return v2=='none'?false:true;};this.toggleClassName=function(elem,name){if(ecma.dom.hasClassName(elem,name)){ecma.dom.removeClassName(elem,name);return false;}else{ecma.dom.addClassName(elem,name);return true;}};this.getAnchorsByRel=function(rootNode,name){var links=ecma.dom.getElementsByTagName(rootNode,'A');var result=[];for(var i=0,node;node=links[i];i++){var rel=ecma.dom.getAttribute(node,'rel');if(rel==name){result.push(node);}}
return result;};this.findNode=function(node,cb){if(!ecma.dom.node.isElement(node))return null;var n=node.firstChild;while(n){if(ecma.lang.callback(cb,null,[n]))return n;var r=ecma.dom.findNode(n,cb);if(r)return r;n=n.nextSibling;}
return null;};});ECMAScript.Extend('dom',function(ecma){var CActionDispatcher=ecma.action.ActionDispatcher;var proto=ecma.lang.createMethods(CActionDispatcher);this.LocationListener=function(){CActionDispatcher.apply(this);this.checkInterval=75;this.setLocation();this.intervalId=ecma.dom.setInterval(this.checkLocation,this.checkInterval,this);};this.LocationListener.prototype=proto;proto.setLocation=function(){this.currentHref=ecma.document.location.href;this.currentLocation=new ecma.http.Location();};proto.checkLocation=function(){var href=ecma.document.location.href;if(this.currentHref!=href){var prevLocation=this.currentLocation;this.setLocation();this.dispatchAction('change',this.currentLocation,prevLocation);}};proto.destroy=function(){ecma.dom.clearInterval(this.intervalId);};});ECMAScript.Extend('dom',function(ecma){var proto={};this.KeyListener=function(elem,key,func,scope,args){this.elem=ecma.dom.getElement(elem);this.key=key;this.cb=ecma.lang.createCallbackArray(func,scope,args);this.kpevt=new ecma.dom.EventListener(elem,'keypress',this.onKeyPress,this);};this.KeyListener.prototype=proto;proto.onKeyPress=function(event){var seq=this.getSequence(event);var match=false;if(typeof(this.key)=='function'){match=ecma.lang.callback(this.key,null,[seq]);}else{match=seq.numeric==this.key||seq.ascii==this.key;}
if(match)ecma.lang.callback(this.cb,null,[event]);};proto.getSequence=function(event){var char_code=this.getCharCode(event);var ascii_code=String.fromCharCode(char_code).toLowerCase();var prefix=event.ctrlKey?"ctrl+":"";if(event.altKey)prefix+="alt+";if(event.shiftKey)prefix+="shift+";var seq={'ascii':prefix,'numeric':prefix+char_code,'ismod':false};var is_special=true;if(ecma.dom.browser.isGecko){is_special=event.keyCode&&!event.charCode;}
if(is_special){switch(char_code){case 8:seq.ascii+='backspace';break;case 9:seq.ascii+='tab';break;case 13:seq.ascii+='enter';break;case 16:seq.ascii='shift';break;case 17:seq.ascii='ctrl';break;case 18:seq.ascii='alt';break;case 27:seq.ascii+='esc';break;case 37:seq.ascii+='left';break;case 38:seq.ascii+='up';break;case 39:seq.ascii+='right';break;case 40:seq.ascii+='down';break;case 46:seq.ascii+='delete';break;case 36:seq.ascii+='home';break;case 35:seq.ascii+='end';break;case 33:seq.ascii+='pageup';break;case 34:seq.ascii+='pagedown';break;case 45:seq.ascii+='insert';break;default:seq.ascii+=ascii_code;}}else{seq.ascii+=ascii_code;}
seq.ismod='shift'==seq.ascii||'ctrl'==seq.ascii||'alt'==seq.ascii;return seq;};proto.getCharCode=function(event){return event.which?event.which:event.keyCode?event.keyCode:event.charCode?event.charCode:0;};proto.remove=function(){this.kpevt.remove();};proto.destroy=function(){this.remove();};});ECMAScript.Extend('dom',function(ecma){var ACCEPT_TAGS=['A','ABBR','ACRONYM','ADDRESS','B','BDO','BIG','BLOCKQUOTE','BR','BUTTON','CAPTION','CENTER','CITE','CODE','COL','COLGROUP','DD','DEL','DFN','DIV','DL','DT','EM','FONT','FORM','H1','H2','H3','H4','H5','H6','HR','I','IMG','INS','KBD','LABEL','LI','OL','OPTGROUP','OPTION','P','PRE','Q','S','SAMP','SMALL','SPAN','STRIKE','STRONG','SUB','SUP','TABLE','TBODY','TD','TFOOT','TH','THEAD','TR','TT','U','UL','VAR'];var EMPTY_TAGS=['BR','IMG','INPUT','TBODY','TD','TFOOT','TH','THEAD','TR',];var REMOVE_TAGS=['FONT','SPAN','LABEL'];var REMAP_TAG_MAP={'STRONG':'B','EM':'I'};var REMAP_TAGS=[];for(var tag in REMAP_TAG_MAP){REMAP_TAGS.push(tag);}
var PRESERVE_WS_TAGS=['CODE','PRE','TEXTAREA','TT'];var DENY_INBREEDING=['A','ABBR','ACRONYM','ADDRESS','B','BDO','BIG','BR','BUTTON','CAPTION','CENTER','CITE','CODE','DEL','DFN','EM','FONT','FORM','H1','H2','H3','H4','H5','H6','HR','I','IMG','INS','KBD','LABEL','OPTION','P','PRE','Q','S','SAMP','SMALL','STRIKE','STRONG','SUB','SUP','TT','U','VAR'];var ACCEPT_STYLES=['color','align','clear'];var DENY_ATTRS=['id','class'];this.Scrubber=function(js){this.js=js;}
var Scrubber=this.Scrubber.prototype=ecma.lang.createMethods();Scrubber.scrub=function(elem){return this.collapse(this.clean(elem));};Scrubber.clean=function(elem){var node=elem.firstChild;while(node){var next=node.nextSibling;switch(node.nodeType){case ecma.dom.constants.ELEMENT_NODE:if(!ecma.util.grep(node.tagName,ACCEPT_TAGS)){elem.removeChild(node);break;}
if(!node.childNodes.length&&!ecma.util.grep(node.tagName,EMPTY_TAGS)){elem.removeChild(node);break;}
if(ecma.util.grep(node.tagName,REMOVE_TAGS)){next=node.firstChild;this.js.dom.removeElementOrphanChildren(node);break;}
if(ecma.util.grep(node.tagName,REMAP_TAGS)){var newTag=REMAP_TAG_MAP[node.tagName];var newNode=this.js.dom.createElement(newTag);this.js.dom.insertAfter(newNode,node);this.js.dom.appendChildren(newNode,node.childNodes);this.js.dom.removeElement(node);node=newNode;}
this.clean(node);for(var i=0,attr;attr=DENY_ATTRS[i];i++){this.js.dom.removeAttribute(node,attr);}
this.scrubStyles(node);break;case ecma.dom.constants.TEXT_NODE:if(node.nodeValue.match(/^\s*$/)&&(node===elem.firstChild||ecma.dom.node.isElement(node.previousSibling))&&(node===elem.lastChild||ecma.dom.node.isElement(node.nextSibling))){this.js.dom.removeElement(node);break;}
if(this.wsMatters(node)){break;}
node.nodeValue=node.nodeValue.replace(/\s+/g,' ');if(node.nodeValue){break;}
default:elem.removeChild(node);}
node=next;}
return elem;};Scrubber.scrubStyles=function(elem){var styles={};for(var i=0,name;name=ACCEPT_STYLES[i];i++){var value=elem.style[name];if(ecma.util.defined(value)){styles[name]=value;}}
var styleAttr=this.js.dom.getAttribute(elem,'style');this.js.dom.removeAttribute(elem,'style');for(var name in styles){this.js.dom.setStyle(elem,name,styles[name]);}
var styleAttr2=this.js.dom.getAttribute(elem,'style');if(styleAttr!=styleAttr2){}};Scrubber.wsMatters=function(node){var pNode=node.parentNode;while(pNode){if(ecma.util.grep(pNode.tagName,PRESERVE_WS_TAGS))return true;if(pNode.parentNode===pNode)break;pNode=pNode.parentNode;}
return false;};Scrubber.collapse=function(elem,stack){if(!stack)stack=new this.NodeStack();stack.push(elem);var node=elem.firstChild;while(node){var next=node.nextSibling;if(ecma.dom.node.isElement(node)){if(stack.isAllowed(node)){this.collapse(node,stack);}else{if(node.firstChild){next=node.firstChild;ecma.dom.removeElementOrphanChildren(node);}else{ecma.dom.removeElement(node);}}}
node=next;}
stack.pop();return elem;};Scrubber.NodeStack=function(){this.stack=[];};var NodeStack=Scrubber.NodeStack.prototype=ecma.lang.createMethods();NodeStack.push=function(elem){return this.stack.push(elem);};NodeStack.pop=function(){return this.stack.pop();};NodeStack.toString=function(){var tagNames=[];for(var i=0,node;node=this.stack[i];i++){switch(node.nodeType){case ecma.dom.constants.ELEMENT_NODE:tagNames.push(node.tagName);break;case ecma.dom.constants.TEXT_NODE:tagNames.push('#TEXT');break;default:tagNames.push('#OTHER');}}
return tagNames.join('>');};NodeStack.isAllowed=function(child){for(var i=0,node;node=this.stack[i];i++){if(!ecma.dom.node.isElement(node))continue;if(this.canContain(node,child))continue;return false;}
return true;};NodeStack.canContain=function(node,child){return node.tagName==child.tagName&&ecma.util.grep(node.tagName,DENY_INBREEDING)?false:true};});ECMAScript.Extend('lsn.auth',function(ecma){var _basic_auth_token=null;this.setAuthToken=function(tk){_basic_auth_token=tk;};this.basic=function(un,pw){var h1=ecma.crypt.hex_sha1(pw);var h2=ecma.crypt.hex_sha1(h1+':'+_basic_auth_token);return{'un':un,'h2':h2};};});ECMAScript.Extend('lsn.ui',function(ecma){var UI_STATE_DEFAULT=1;var UI_STATE_AUTHENTICATING=2;var UI_STATE_AUTHENTICATED=3;var UI_STATE_FAILED=4;var proto={};this.LoginDialog=function(dlgUri,loginUri){this.ui={};this.dlgUri=dlgUri||'/res/login/login.dlg';this.loginUri=loginUri||'/res/login/module.pm/login';this.dlg=new ecma.lsn.Dialog(this.dlgUri,{refetch:false});this.dlg.addEvent('load',[this.onLoad,this]);this.dlg.addEvent('show',[this.onShow,this]);this.dlg.addEvent('ok',[this.onOk,this]);this.dlg.addEvent('cancel',[this.onCancel,this]);this.dlg.addEvent('destroy',[this.onDestroy,this]);this.req=new ecma.lsn.Request(this.loginUri);this.req.addEventListener('success',this.onSuccess,this);this.req.addEventListener('failure',this.onFailure,this);};this.LoginDialog.prototype=proto;proto.show=function(params){this.dlg.show(params);};proto.hide=function(){this.dlg.hide();};proto.onLoad=function(){this.ui.un=this.dlg.getElementById('un');this.ui.pw=this.dlg.getElementById('pw');this.ui.msg=this.dlg.getElementById('msg');this.ui.btnbar=this.dlg.getElementById('btnbar');this.ui.btnOk=this.dlg.getElementById('btn_ok');this.ui.btnCancel=this.dlg.getElementById('btn_cancel');this.ui.kbUnEnter=new ecma.dom.KeyListener(this.ui.un,'enter',this.onEnter,this);this.ui.kbPwEnter=new ecma.dom.KeyListener(this.ui.pw,'enter',this.onEnter,this);};proto.enableButtons=function(){ecma.dom.removeAttribute(this.ui.un,'readonly');ecma.dom.removeAttribute(this.ui.pw,'readonly');ecma.dom.removeAttribute(this.ui.btnOk,'disabled');ecma.dom.removeAttribute(this.ui.btnCancel,'disabled');};proto.disableButtons=function(){ecma.dom.setAttribute(this.ui.un,'readonly','readonly');ecma.dom.setAttribute(this.ui.pw,'readonly','readonly');ecma.dom.setAttribute(this.ui.btnOk,'disabled','disabled');ecma.dom.setAttribute(this.ui.btnCancel,'disabled','disabled');};proto.updateUI=function(state){if(state==UI_STATE_DEFAULT){this.enableButtons();ecma.dom.setValue(this.ui.msg,'');ecma.dom.setClassName(this.ui.msg,'authenticating');if(this.ui.cont){ecma.dom.removeElement(this.ui.cont);delete this.ui.cont;this.ui.btnbar.appendChild(this.ui.btnCancel);this.ui.btnbar.appendChild(this.ui.btnOk);}}else if(state==UI_STATE_AUTHENTICATING){this.disableButtons();ecma.dom.setClassName(this.ui.msg,'authenticating');ecma.dom.setValue(this.ui.msg,'Authenticating...');}else if(state==UI_STATE_FAILED){this.enableButtons();ecma.dom.setValue(this.ui.msg,'Login incorrect');ecma.dom.setClassName(this.ui.msg,'failed');}else if(state==UI_STATE_AUTHENTICATED){ecma.dom.setClassName(this.ui.msg,'authenticated');ecma.dom.setValue(this.ui.msg,'Success');}else{throw'Unknown ui state: '+state;}};proto.onShow=function(){ecma.dom.setValue(this.ui.un,'');ecma.dom.setValue(this.ui.pw,'');ecma.dom.setValue(this.ui.msg,'');this.updateUI(UI_STATE_DEFAULT);this.ui.un.focus();};proto.onEnter=function(event){js.dom.stopEvent(event);this.onOk();};proto.onOk=function(){this.dlg.stopEvent();this.updateUI(UI_STATE_AUTHENTICATING);var un=ecma.dom.getValue(this.ui.un);var pw=ecma.dom.getValue(this.ui.pw);this.req.submit(ecma.lsn.auth.basic(un,pw));};proto.onCancel=function(){this.goNext(this.dlg.params.onCancel,this.dlg.params.onCancelUri);};proto.onDestroy=function(){this.ui.kbUnEnter.destroy();this.ui.kbPwEnter.destroy();};proto.onSuccess=function(){this.updateUI(UI_STATE_AUTHENTICATED);this.goNext(this.dlg.params.onSuccess,this.dlg.params.onSuccessUri);};proto.goNext=function(cb,uri){if(cb){this.hide();ecma.lang.callback(cb,this.dlg);}else if(uri){var loc=new ecma.http.Location(uri);ecma.lang.assert(loc.isSameOrigin());if(false&&ecma.dom.browser.isIE){this.ui.cont=ecma.dom.createElement('a',{'href':loc.getUri(),'innerHTML':'Continue'});ecma.dom.removeElement(this.ui.btnCancel);ecma.dom.removeElement(this.ui.btnOk);this.ui.btnbar.appendChild(this.ui.cont);this.ui.cont.focus();}else{if(ecma.document.location.href==loc.getUri()){ecma.document.location.reload();}else{ecma.document.location.replace(loc.getUri());}}}else{this.hide();}};proto.onFailure=function(req){var resp=req.xhr.responseText;var match=req.xhr.responseText.match(/nonce=([^;]+);/);if(match[1])js.lsn.auth.setAuthToken(match[1]);ecma.dom.setValue(this.ui.pw,'');this.updateUI(UI_STATE_FAILED);};});ECMAScript.Extend('fx',function(ecma){this.createEffect=function(){var args=ecma.util.args(arguments);var name=args.shift().toLowerCase();var klass=null;for(var key in ecma.fx.effects){if(key.toLowerCase()==name){klass=ecma.fx.effects[key];break;}}
if(!klass)throw'No such effect class';return ecma.lang.createObject(klass,args);};this.perform=function(){var args=ecma.util.args(arguments);var effect=ecma.fx.createEffect.apply(null,args.shift());var cb=args.length?[ecma.fx.perform,null,args]:null;effect.start(cb);};});ECMAScript.Extend('fx',function(ecma){var proto={};this.Effect=function(delta,duration){this.fxDelta=delta;this.fxRate=1000;this.fxInterval=25;this.fxDuration=duration;this.fxListeners=null;this.fxAnimator=null;};this.Effect.prototype=proto;proto.getDelta=function(){return this.fxDelta;};proto.getDuration=function(){return this.fxDuration;};proto.setDuration=function(duration){return this.fxDuration=duration;};proto.start=function(cb){if(!this.fxDuration){this.setDuration((this.getDelta()/this.fxRate)*1000);}
this.cb=cb;this.setAnimator(new ecma.fx.Animator(this.fxInterval,this.fxDuration));this.getAnimator().start();return this;};proto.stop=function(){this.removeAnimator();};proto.getAnimator=function(){return this.fxAnimator;};proto.setAnimator=function(ani){if(this.fxListeners)this.removeAnimator();this.fxListeners={};this.fxListeners.onFirst=ani.addActionListener('onFirst',this.onFirst,this);this.fxListeners.onNext=ani.addActionListener('onNext',this.onNext,this);this.fxListeners.onLast=ani.addActionListener('onLast',this.onLast,this);return this.fxAnimator=ani;};proto.removeAnimator=function(){try{this.fxListeners.onFirst.remove();this.fxListeners.onNext.remove();this.fxListeners.onLast.remove();}catch(ex){}finally{this.fxListeners=null;this.fxAnimator=null;}};proto.onFirst=function(action,progress){this.draw(action,progress);};proto.onNext=function(action,progress){this.draw(action,progress);};proto.onLast=function(action,progress){this.draw(action,progress);if(this.cb){var cb=this.cb;this.cb=null;ecma.lang.callback(cb);}};proto.draw=ecma.lang.createAbstractFunction();});ECMAScript.Extend('fx',function(ecma){var CActionDispatcher=ecma.action.ActionDispatcher;var proto=ecma.lang.createMethods(CActionDispatcher);this.Sequencer=function(interval,loop){CActionDispatcher.apply(this);this.seqEvents={};this.seqItems=[];this.seqInterval=interval;this.seqAutoAdvance=null;this.seqBlocking=false;this.seqIndex=-1;};this.Sequencer.prototype=proto;proto.createActionEvent=function(name){return new ecma.fx.SequencerEvent(name,this);};proto.isValid=function(){return this.seqItems.length>0;};proto.isValidIndex=function(idx){return 0<=this.seqIndex&&this.seqIndex<this.seqItems.length;};proto.setInterval=function(ms){return this.seqInterval=ms;};proto.getInterval=function(){return ecma.util.defined(this.seqInterval)?this.seqInterval:0;};proto.getIndex=function(){return this.seqIndex;};proto.addItem=function(item){return this.seqItems.push(item);};proto.getItem=function(idx){return this.seqItems[idx];};proto.removeItem=function(item){var idx=-1;for(var i=0;i<this.seqItems.length;i++){if(this.seqItems[i]===item){idx=i;break;}}
if(idx>=0){return this.seqItems.splice(idx,1);}};proto.start=function(){this.executeAction('start');this.seqAutoAdvance=1;return this.autoAdvance();};proto.prev=function(){if(this.seqAutoAdvance){this.seqAutoAdvance=-1;return this.autoAdvance()}else{this.select(this.seqIndex-1);}};proto.next=function(){if(this.seqAutoAdvance){this.seqAutoAdvance=1;return this.autoAdvance()}else{this.select(this.seqIndex+1);}};proto.autoAdvance=function(){this.select(this.seqIndex+this.seqAutoAdvance);return this;};proto.select=function(idx){if(!this.isValid()||this.seqBlocking)return;if(this.seqIndex==idx)return;ecma.dom.clearTimeout(this.seqEvents.tid);if(idx+0!=idx){throw'Invalid index';}
try{this.seqBlocking=true;if(this.isValidIndex(this.seqIndex)){this.executeAction('deselect',this.getItem(this.seqIndex),this.seqIndex);}}finally{this.seqBlocking=false;}
if(idx<0){return this.loop(this.seqItems.length-1);}else if(idx>=this.seqItems.length){return this.loop(0);}
try{this.seqBlocking=true;this.seqIndex=idx;this.executeAction('select',this.getItem(this.seqIndex),this.seqIndex);}finally{this.seqBlocking=false;}
if(this.seqAutoAdvance){this.seqEvents.tid=ecma.dom.setTimeout(this.autoAdvance,this.getInterval(),this);}
return this;}
proto.loop=function(idx){this.select(idx);};proto.stop=function(){this.seqAutoAdvance=null;this.dispatchAction('stop');return this;};});ECMAScript.Extend('fx',function(ecma){var CActionEvent=ecma.action.ActionEvent;var proto=ecma.lang.createMethods(CActionEvent);this.SequencerEvent=function(name,dispatcher){CActionEvent.apply(this,arguments);};this.SequencerEvent.prototype=proto;});ECMAScript.Extend('fx',function(ecma){var CActionDispatcher=ecma.action.ActionDispatcher;var proto=ecma.lang.createMethods(CActionDispatcher);this.Animator=function(interval,duration){CActionDispatcher.apply(this);this.aniEvents={};this.aniEffects=[];this.aniDuration=duration;this.aniInterval=interval||25;this.aniBlocking=true;this.aniProgress=null;};this.Animator.prototype=proto;function next(){if(!this.isRunning())return;if(this.aniBlocking)return;this.aniBlocking=true;this.aniProgress.update();try{if(this.aniProgress.isComplete()){this.executeAction('last',this.aniProgress);this.stop();}else{this.executeAction('next',this.aniProgress);}}finally{this.aniBlocking=false;}
return this;}
proto.isRunning=function(){return this.aniEvents.iid&&true;};proto.setDuration=function(duration){if(this.isRunning())throw'Cannot update duration while running';this.aniDuration=duration;};proto.addEffect=function(arg1){var effect=ecma.util.isObject(arg1)?arg1:ecma.fx.createEffect.apply(null,arguments);effect.setAnimator(this);this.aniEffects.push(effect)
return effect;};proto.removeEffect=function(effect){var idx=-1;for(var i=0;i<this.aniEffects.length;i++){if(this.aniEffects[i]===effect){idx=i;break;}}
if(idx>=0){var effect=this.aniEffects[idx];effect.removeAnimator();this.aniEffects.splice(idx,1);}};proto.start=function(cb){this.executeAction('start');this.aniProgress=new ecma.fx.AnimatorProgress(this.aniInterval,this.aniDuration);this.aniEvents.iid=ecma.dom.setInterval(next,this.aniInterval,this);this.executeAction('first',this.aniProgress);this.aniBlocking=false;return this;};proto.stop=function(){if(this.aniEvents.iid){this.aniBlocking=true;ecma.dom.clearInterval(this.aniEvents.iid);delete this.aniEvents.iid;this.aniProgress=null;this.dispatchAction('stop');}
return this;};});ECMAScript.Extend('fx',function(ecma){var proto={};this.AnimatorProgress=function(interval,duration){this.interval=interval;this.duration=duration;this.last=this.now=this.begin=new Date();};this.AnimatorProgress.prototype=proto;proto.update=function(){this.last=this.now;this.now=new Date();};proto.isComplete=function(){return this.duration&&(this.getElapsed()>=this.duration);};proto.getLap=function(){return this.now-this.last;};proto.getElapsed=function(){return this.now-this.begin;};proto.getProportion=function(){var p=this.duration?this.getElapsed()/this.duration:-1;return Math.min(p,1);};proto.toString=function(){var result=['proportion='+this.getProportion(),'lap='+this.getLap(),'elapsed='+this.getElapsed(),'isComplete='+this.isComplete()]
return result.join(', ');};});ECMAScript.Extend('fx.effects',function(ecma){var CEffect=ecma.fx.Effect;var proto=ecma.lang.createMethods(CEffect);this.Style=function(elem,attr,p1,p2,units,duration){this.elem=ecma.dom.getElement(elem);this.attr=attr;this.units=units||'';this.end=p2;this.begin=p1;this.dir=this.begin>this.end?-1:1;var delta=Math.abs(this.dir>0?this.end-this.begin:this.end-this.begin);CEffect.apply(this,[delta,duration]);};this.Style.prototype=proto;proto.draw=function(action,progress){var d=this.getDelta()*progress.getProportion();var value=(d*this.dir)+this.begin;ecma.dom.setStyle(this.elem,this.attr,value+this.units);};});ECMAScript.Extend('fx.effects',function(ecma){var CEffect=ecma.fx.Effect;var proto=ecma.lang.createMethods(CEffect);this.Opacify=function(elem,beg,end,duration){this.elem=ecma.dom.getElement(elem);this.begin=beg;this.end=end;var delta=this.getDelta();CEffect.apply(this,[delta,duration]);};this.Opacify.prototype=proto;proto.getDelta=function(){this.dir=this.begin>this.end?-1:1;return Math.abs(this.dir>0?this.end-this.begin:this.end-this.begin);};proto.draw=function(action,progress){var d=this.getDelta()*progress.getProportion();var value=(d*this.dir)+this.begin;ecma.dom.setOpacity(this.elem,value);};});ECMAScript.Extend('fx.effects',function(ecma){var CEffect=ecma.fx.Effect;var proto=ecma.lang.createMethods(CEffect);this.Swap=function(attr,units,duration){this.attr=attr;this.units=units||'';CEffect.apply(this,[0,duration]);};this.Swap.prototype=proto;proto.start=function(elem1,elem2,cb){this.elem1=ecma.dom.getElement(elem1);this.elem2=ecma.dom.getElement(elem2);var p1=ecma.dom.getStyle(elem1,this.attr);var p2=ecma.dom.getStyle(elem2,this.attr);if(this.units){p1=p1.substr(0,p1.length-this.units.length);p2=p2.substr(0,p2.length-this.units.length);}
p1=ecma.util.asInt(p1);p2=ecma.util.asInt(p2);this.sum=p1+p2;this.begin=p1;this.end=p2;this.dir=p1>p2?-1:1;this.fxDelta=Math.abs(this.dir>0?p2-p1:p2-p1);CEffect.prototype.start.call(this,cb);};proto.draw=function(action,progress){var d=this.getDelta()*progress.getProportion();var v1=(d*this.dir)+this.begin;var v2=(d*-this.dir)+this.end;ecma.dom.setStyle(this.elem1,this.attr,v1+this.units);ecma.dom.setStyle(this.elem2,this.attr,v2+this.units);};});ECMAScript.Extend('lsn.ui',function(ecma){this.colors={};this.colors.white='rgb(255,255,255)';this.colors.black='rgb(0,0,0)';this.colors.red1='rgb(164,0,0)';this.colors.red2='rgb(204,0,0)';this.colors.red3='rgb(239,41,41)';this.colors.green1='rgb(78,154,6)';this.colors.green2='rgb(115,210,22)';this.colors.green3='rgb(138,226,52)';this.colors.blue1='rgb(32,74,135)';this.colors.blue2='rgb(52,101,164)';this.colors.blue3='rgb(114,159,207)';this.colors.yellow1='rgb(196,160,0)';this.colors.yellow2='rgb(237,212,0)';this.colors.yellow3='rgb(252,233,79)';this.colors.orange1='rgb(206,92,0)';this.colors.orange2='rgb(245,121,0)';this.colors.orange3='rgb(252,175,62)';this.colors.purple1='rgb(92,53,102)';this.colors.purple2='rgb(117,80,123)';this.colors.purple3='rgb(173,127,168)';this.colors.brown1='rgb(143,89,2)';this.colors.brown2='rgb(193,125,17)';this.colors.brown3='rgb(233,185,110)';this.colors.gray1='rgb(46,52,54)';this.colors.gray2='rgb(186,189,182)';this.colors.gray3='rgb(238,238,236)';this.colors.gray4='rgb(242,242,242)';});ECMAScript.Extend('lsn.ui',function(ecma){var CAction=ecma.action.ActionDispatcher;this.Base=function(){CAction.apply(this);this.zIndex=ecma.lsn.zIndex();};var _proto=this.Base.prototype=ecma.lang.createMethods(CAction);_proto.zIndexAlloc=function(){return this.zIndex=ecma.lsn.zIndexAlloc();};_proto.zIndexFree=function(){return this.zIndex=ecma.lsn.zIndexFree();};});ECMAScript.Extend('lsn.ui',function(ecma){var CDispatcher=ecma.action.ActionDispatcher;var _proto=ecma.lang.createMethods(CDispatcher);this.Page=function(){CDispatcher.call(this);this.pgRefreshRate=250;this.pgBuffer={};this.pgCanvas={width:0,height:0,delta:{width:0,height:0}};this.pgViewport={width:0,height:0,left:0,top:0,delta:{width:0,height:0,top:0,left:0}};this.pgStyleSheet=null;ecma.dom.addEventListener(ecma.document,'load',this.onLoadEvent,this);ecma.dom.addEventListener(ecma.window,'resize',this.onResizeEvent,this);ecma.dom.addEventListener(ecma.window,'scroll',this.onScrollEvent,this);ecma.dom.addEventListener(ecma.window,'unload',this.onUnloadEvent,this);};this.Page.prototype=_proto;_proto.getViewport=function(){return this.pgViewport;};_proto.getCanvas=function(){return this.pgCanvas;};_proto.getStyleSheet=function(){return this.pgStyleSheet;};_proto.onPageLoad=function(event){};_proto.onPageResize=function(event){};_proto.onPageScroll=function(event){};_proto.onPageUnload=function(event){};_proto.onLoadEvent=function(event){this.pgStyleSheet=new ecma.dom.StyleSheet();this.doAction(event,'onPageLoad');};_proto.onResizeEvent=function(event){this.bufferAction(event,'onPageResize');};_proto.onScrollEvent=function(event){this.bufferAction(event,'onPageScroll');};_proto.onUnloadEvent=function(event){this.doAction(event,'onPageUnload');};_proto.bufferAction=function(event,name){if(this.pgBuffer[name])return;this.pgBuffer[name]=ecma.dom.setTimeout(this.doBufferedAction,this.pgRefreshRate,this,[event,name]);};_proto.doBufferedAction=function(event,name){delete this.pgBuffer[name];this.doAction(event,name);};_proto.doAction=function(event,name){this.pgUpdate(name);var func=this[name];if(func){func.call(this,event);}else{throw'No class method defined for action: '+name;}
this.dispatchAction(name,event);};_proto.pgUpdate=function(name){var pos=ecma.dom.canvas.getPosition();var vp=this.pgViewport;var c=this.pgCanvas;c.delta.width=pos.width-c.width;c.delta.height=pos.height-c.height;c.width=pos.width;c.height=pos.height;vp.delta.width=pos.windowX-vp.width;vp.delta.height=pos.windowY-vp.height;vp.width=pos.windowX;vp.height=pos.windowY;vp.delta.left=pos.scrollX-vp.left;vp.delta.top=pos.scrollY-vp.top;vp.top=pos.scrollY;vp.left=pos.scrollX;};});ECMAScript.Extend('lsn.ui',function(ecma){var proto={};this.Element=function(){this.uiElems={root:null};this.uiEvents={};};this.Element.prototype=proto;proto.createElement=function(){var args=ecma.util.args(arguments);var arg1=args.shift();var parts=arg1.split('_');var tag=parts[0];var id=parts[1];var elem=null;if(tag&&id){args.unshift(tag);elem=this.uiElems[arg1]=ecma.dom.createElement.apply(null,args);}else{elem=ecma.dom.createElement.apply(null,arguments);}
return elem;};proto.getRootElement=ecma.lang.createAbstractFunction();proto.getElement=function(id){return this.uiElems[id];};proto.setElement=function(id,elem){return this.uiElems[id]=elem;};proto.removeElement=function(id){var elem=this.getElement(id);if(!elem)return;return delete this.uiElems[id];};function formatEventKey(id,type){return id+'.'+type;};proto.addEventListener=function(id){var elem=this.getElement(id);if(!elem)return;var args=ecma.util.args(arguments);args[0]=elem;var key=formatEventKey(id,args[1]);return this.uiEvents[key]=ecma.lang.createObject(ecma.dom.EventListener,args);}
proto.removeEventListener=function(id,type){var elem=this.getElement(id);if(!elem)return;var key=formatEventKey(id,type);this.uiEvents[key].remove();return delete this.uiEvents[key];}});ECMAScript.Extend('lsn.ui',function(ecma){var CActionDispatcher=ecma.action.ActionDispatcher;var proto=ecma.lang.createMethods(CActionDispatcher);this.View=function(rootElem){CActionDispatcher.apply(this);this.ui=new Object();this.rootElem=rootElem;};this.View.prototype=proto;proto.createUI=function(){return this;};proto.updateUI=function(){return this;};proto.destroyUI=function(){return this;};proto.attachUI=function(elem){if(!elem)elem=this.rootElem;if(!elem)throw'Missing element';var nlist=elem.getElementsByClassName('ui');for(var i=0,node;node=nlist[i];i++){if(!node.id)continue;this.ui[node.id]=node;}
return this;};});ECMAScript.Extend('lsn.ui',function(ecma){var _css=null;function initBannerStyles(){if(_css)return;_css=new ecma.dom.StyleSheet();_css.createRule('.bnrViewport',{'overflow':'hidden','position':'relative'});_css.createRule('.bnrItems',{'position':'absolute','border-collapse':'collapse','border-spacing':'0','margin':'0','padding':'0'});_css.createRule('.bnrCell',{'vertical-align':'center','margin':'0','padding':'0'});};var CElement=ecma.lsn.ui.Element;var CSequencer=ecma.fx.Sequencer;var proto=ecma.lang.createMethods(CElement,CSequencer);this.Banner=function(interval){initBannerStyles();CElement.apply(this);CSequencer.apply(this,[interval||1000]);this.createUI();this.frames=[];this.addActionListener('select',this.onSelect,this);this.addActionListener('deselect',this.onDeselect,this);this.addActionListener('loop',this.onLoop,this);};this.Banner.prototype=proto;proto.attach=function(div,table,row){div=ecma.dom.getElement(div);table=ecma.dom.getElement(table);row=ecma.dom.getElement(row);this.setElement('div_vp',div);this.setElement('table_items',table);this.setElement('tr_items',row);var nodes=row.getElementsByTagName('td');for(var i=0,cell;cell=nodes[i];i++){CSequencer.prototype.addItem.call(this,cell);}};proto.sizeTo=function(elem){elem=ecma.dom.getElement(elem);var vp=this.getElement('div_vp');ecma.dom.setStyle(vp,'width',ecma.dom.getInnerWidth(elem)+'px');ecma.dom.setStyle(vp,'height',ecma.dom.getInnerHeight(elem)+'px');};proto.getRootElement=function(elem){return this.getElement('div_vp');};proto.createUI=function(){this.createElement('div_vp',{'class':'bnrViewport'},[this.createElement('table_items',{'class':'bnrItems'},['tbody',[this.createElement('tr_items')]]),this.getElement('table_items')]);};proto.onClickNext=function(event){this.next();};proto.onClickPrev=function(event){this.prev();};proto.onClickSelect=function(event,idx){this.select(idx);};proto.onClickStart=function(event){this.start();};proto.onClickStop=function(event){this.stop();};proto.addItem=function(item){var td=this.createElement('td',{'class':'bnrCell'},[item]);this.getElement('tr_items').appendChild(td);return CSequencer.prototype.addItem.call(this,td);};proto.getMovement=function(idx){var left=0;for(var i=0;i<idx;i++){var td=this.getItem(i);left+=ecma.dom.getWidth(td);}
left*=-1;var tbl=this.getElement('table_items');var pos=ecma.util.asInt(ecma.dom.getStyle(tbl,'left'));return[pos,left];}
proto.onSelect=function(action,target,idx){var left=this.getMovement(idx);if(left[0]!=left[1]){var tbl=this.getElement('table_items');var ani=new ecma.fx.Animator(25,500);ani.addEffect('style',tbl,'left',left[0],left[1],'px');ani.addEffect('style',target,'opacity',0,1);ani.start();}};proto.onDeselect=function(action,target){};proto.loop=function(idx){var left=this.getMovement(idx);var tbl=this.getElement('table_items');new ecma.fx.effects.Style(tbl,'opacity',1,0,null,250).start([function(){ecma.dom.setStyle(tbl,'left',left[1]+'px');new ecma.fx.effects.Style(tbl,'opacity',0,1,null,250).start([this.select,this,[idx]]);},this]);};});ECMAScript.Extend('lsn.ui',function(ecma){var _defaultBackground='#f2f2f2';var _defaultOpacity=.75;var CBase=ecma.lsn.ui.Base;this.Mask=function(){CBase.apply(this);this.hasLoaded=false;this.createUI();this.fxShow=new ecma.fx.effects.Opacify(this.getRoot(),0,_defaultOpacity,100);this.fxHide=new ecma.fx.effects.Opacify(this.getRoot(),_defaultOpacity,0,100);};var _proto=this.Mask.prototype=ecma.lang.createMethods(CBase);_proto.getRoot=function(){return this.uiRoot;};_proto.setOpacity=function(opacity){this.fxShow.end=opacity;this.fxHide.begin=opacity;return opacity;};_proto.setDuration=function(ms){this.fxShow.setDuration(ms);this.fxHide.setDuration(ms);return ms;};_proto.setBackground=function(cssValue){ecma.dom.setStyle(this.uiRoot,'background',cssValue);return cssValue;};_proto.load=function(){if(this.hasLoaded)return;var body=ecma.dom.getBody();this.uiParent=ecma.dom.browser.isIE?body:body.parentNode||body;this.html=body.parentNode;this.canvas=new ecma.dom.Canvas();this.executeClassAction('onMaskLoad');this.hasLoaded=true;}
_proto.show=function(){this.load();this.executeClassAction('onMaskShow');this.attach();this.appear([function(){this.dispatchClassAction('onMaskReady');},this]);};_proto.hide=function(){this.executeClassAction('onMaskHide');this.disappear([function(){this.detach();},this]);};_proto.attach=function(){ecma.dom.setStyle(this.html,'width','100%');ecma.dom.setStyle(this.html,'height','100%');ecma.dom.setStyle(this.uiRoot,'z-index',this.zIndexAlloc());this.resizeEvent=new ecma.dom.EventListener(ecma.window,'resize',this.resize,this);this.resize();ecma.dom.appendChild(this.uiParent,this.uiRoot);this.executeClassAction('onMaskAttach');};_proto.resize=function(){var w=this.canvas.getWidth();var h=this.canvas.getHeight();ecma.dom.setStyle(this.uiRoot,'width',w+"px");ecma.dom.setStyle(this.uiRoot,'height',h+"px");};_proto.detach=function(){try{ecma.dom.removeElement(this.uiRoot);this.resizeEvent.remove();}catch(ex){}
this.zIndexFree();ecma.dom.setStyle(this.uiRoot,'z-index','-1');this.executeClassAction('onMaskDetach');};_proto.appear=function(cb){this.fxShow.start(cb);};_proto.disappear=function(cb){this.fxHide.start(cb);};_proto.createUI=function(){this.uiRoot=ecma.dom.createElement('div',{'style':{'background':_defaultBackground,'position':'absolute','overflow':'hidden','z-index':'-1','margin':0,'padding':0,'border':0,'top':0,'left':0,'width':0,'height':0}});this.fixupUI();ecma.dom.setOpacity(this.uiRoot,0);return this.uiRoot;};if(ecma.dom.isIE){_proto.fixupUI=function(){this.uiRoot.appendChild(ecma.dom.createElement('iframe',{'width':0,'height':0,'frameborder':0,'src':'about:blank','style':{'width':0,'height':0,'visibility':'hidden'}}));};}else{_proto.fixupUI=function(){};}});ECMAScript.Extend('lsn.ui',function(ecma){var CBase=ecma.lsn.ui.Base;this.Dialog=function(content){CBase.apply(this);this.hasLoaded=false;this.position=null;this.createUI();this.fxShow=new ecma.fx.effects.Opacify(this.getRoot(),0,1,100);this.fxHide=new ecma.fx.effects.Opacify(this.getRoot(),1,0,100);if(content)this.setContent(content);this.addActionListener('onClose',this.hide,this);};var _proto=this.Dialog.prototype=ecma.lang.createMethods(CBase);_proto.getRoot=function(){return this.uiRoot;};_proto.load=function(){};_proto.show=function(){if(!this.hasLoaded){this.load();this.executeClassAction('onDialogLoad');this.hasLoaded=true;}
this.executeClassAction('onDialogShow');this.attach();this.appear([function(){this.dispatchClassAction('onDialogReady');},this]);};_proto.hide=function(){this.executeClassAction('onDialogHide');this.disappear([function(){this.detach();},this]);};_proto.attach=function(parentElem){this.uiParent=parentElem||ecma.dom.getBody();ecma.dom.setStyle(this.uiRoot,'z-index',this.zIndexAlloc());ecma.dom.appendChild(this.uiParent,this.uiRoot);this.executeClassAction('onDialogAttach');this.center();};_proto.center=function(){var vp=ecma.dom.getViewportPosition();var w=ecma.dom.getContentWidth(this.getRoot());var h=ecma.dom.getContentHeight(this.getRoot());var posTop=(vp.height-h)/2;var posLeft=(vp.width-w)/2;var minTop=0;var minLeft=0;if(this.position=='absolute'){posTop+=vp.top;posLeft+=vp.left;minTop=vp.top;minLeft=vp.left;}
posTop=Math.max(posTop,minTop);posLeft=Math.max(posLeft,minLeft);ecma.dom.setStyles(this.getRoot(),{'width':w+'px','height':h+'px','top':posTop+'px','left':posLeft+'px'});};_proto.detach=function(){ecma.dom.removeElement(this.uiRoot);this.zIndexFree();ecma.dom.setStyle(this.uiRoot,'z-index','-1');this.executeClassAction('onDialogDetach');};_proto.appear=function(cb){this.fxShow.start(cb);};_proto.disappear=function(cb){this.fxHide.start(cb);};_proto.createUI=function(){this.position=js.platform.isIE?'absolute':'fixed';this.uiRoot=ecma.dom.createElement('div',{'style':{'position':this.position,'z-index':'-1','top':'0','left':'0','padding':'0','margin':'0'}});ecma.dom.setOpacity(this.uiRoot,0);return this.uiRoot;};_proto.setContent=function(content){this.hook(content);ecma.dom.replaceChildren(this.uiRoot,content.childNodes);return this.uiRoot;};_proto.hook=function(content){var list=[];var links=ecma.dom.getElementsByTagName(content,'A');for(var i=0,node;node=links[i];i++){var rel=ecma.dom.getAttribute(node,'rel');if(rel=='action'){var action=new ecma.http.Location(node.href).getHash();list.push([node,action]);}}
var buttons=ecma.dom.getElementsByTagName(content,'BUTTON');for(var i=0,node;node=buttons[i];i++){var type=ecma.dom.getAttribute(node,'type');if(type=='submit')continue;var name=ecma.dom.getAttribute(node,'name');if(name!='action')continue;var action=ecma.dom.getAttribute(node,'value');list.push([node,action]);}
for(var i=0,item;item=list[i];i++){var elem=item[0];var action=item[1];ecma.dom.addEventListener(elem,'onClick',function(event,action){ecma.dom.stopEvent(event);this.dispatchAction(action);},this,[action]);}};_proto.makeModal=function(){this.mask=new ecma.lsn.ui.Mask();this.addActionListener('onDialogShow',this.mask.show,this.mask);this.addActionListener('onDialogHide',this.mask.hide,this.mask);};_proto.makeMasked=function(){this.mask=new ecma.lsn.ui.Mask();this.addActionListener('onDialogShow',this.mask.show,this.mask);this.addActionListener('onDialogHide',this.mask.hide,this.mask);this.evtMaskClick=new ecma.dom.EventListener(this.mask.getRoot(),'click',this.hide,this);};});ECMAScript.Extend('lsn.ui',function(ecma){var _imgReady='/res/icons/16x16/status/blank.gif';var _imgActive='/res/icons/16x16/status/saving.gif';var _imgComplete='/res/icons/16x16/status/checkmark.gif';var _css={'margin':'0 2px','vertical-align':'middle','border':'none'};this.StatusIcon=function(){this.elem=ecma.dom.createElement('img',{'src':_imgReady,'width':16,'height':16,'border':0,'style':_css});this.fade=new ecma.fx.effects.Opacify(this.elem,1,.25,1000);};var _proto=this.StatusIcon.prototype=ecma.lang.createMethods();_proto.getRootElement=function(){return this.elem;};_proto.showActive=function(){ecma.dom.setOpacity(this.elem,1);ecma.dom.setAttribute(this.elem,'src',_imgActive);};_proto.showComplete=function(){ecma.dom.setOpacity(this.elem,1);ecma.dom.setAttribute(this.elem,'src',_imgComplete);ecma.dom.setTimeout(this.fade.start,1000,this.fade);};_proto.showReady=function(){ecma.dom.setOpacity(this.elem,1);ecma.dom.setAttribute(this.elem,'src',_imgReady);};});ECMAScript.Extend('lsn.ui',function(ecma){var _colors=ecma.lsn.ui.colors;this.Status=function(){this.statusTimeout=3000;this.modalMask=null;this.loadingPopup=null;};var Status=this.Status.prototype=ecma.lang.createMethods();Status.initStyles=function(){};Status.constructPopup=function(cssClass){var vp=ecma.dom.getViewportPosition();var pad=12;var width=(vp.width/4)+(2*pad);var left=(vp.width/2)-(width/2);var popup=ecma.dom.createElement('div',{'style':{'position':'absolute','top':'5px','width':width+'px','left':left+'px','padding':pad+'px'}});ecma.dom.addClassNames(popup,'statusPopup',cssClass);return popup;};Status.attachPopup=function(popup){ecma.dom.setStyle(popup,'z-index',ecma.lsn.zIndexAlloc());ecma.dom.getBody().appendChild(popup);return popup;};Status.createModalPopup=function(cssClass){this.initStyles();var popup=this.constructPopup(cssClass);this.modalMask=new ecma.lsn.ui.Mask();this.modalMask.addActionListener('onMaskAttach',function(action,popup){this.attachPopup(popup);},this,[popup]);this.modalMask.show();return popup;};Status.createPopup=function(cssClass){this.initStyles();return this.attachPopup(this.constructPopup(cssClass));};Status.removePopup=function(event,popup){if(this.modalMask){this.modalMask.hide();this.modalMask=null;}
ecma.lsn.zIndexFree();ecma.dom.stopEvent(event);ecma.dom.removeElement(popup);};Status.notify=function(text){var contents=ecma.dom.createElements('span',{'innerHTML':text,'style':{'font-size':'12px'}});var popup=this.createPopup('statusNotify');ecma.dom.appendChildren(popup,contents);ecma.dom.setTimeout(this.removePopup,this.statusTimeout,this,[null,popup]);};Status.alert=function(text){var popup=this.createModalPopup('statusAlert');var contents=ecma.dom.createElements('span',{'innerHTML':text,'style':{'font-size':'12px'}},'div.footerButtons',['button=OK',{'onClick':[this.removePopup,this,[popup]]}]);ecma.dom.appendChildren(popup,contents);};Status.showLoading=function(text){if(this.loadingPopup)return;var innerHTML=text?text:'Loading';var popup=this.createModalPopup('statusLoading');var contents=ecma.dom.createElements('IMG.indicator',{'src':'/res/icons/16x16/status/loading.gif','width':'16','height':'16','alt':'Loading'},'SPAN',{'innerHTML':innerHTML,'style':{'font-size':'12px'}});ecma.dom.appendChildren(popup,contents);this.loadingPopup=popup;};Status.hideLoading=function(){if(!this.loadingPopup)return;this.removePopup(null,this.loadingPopup);};});ECMAScript.Extend('lsn.ui',function(ecma){var CStatus=ecma.lsn.ui.Status;this.Prompt=function(){CStatus.apply(this);};var Prompt=this.Prompt.prototype=ecma.lang.createMethods(CStatus);Prompt.confirm=function(text,cb){var popup=this.createModalPopup('statusConfirm');var contents=ecma.dom.createElements('span',{'innerHTML':text,'style':{'font-size':'12px'}},'div.footerButtons',['button=No',{'onClick':[this.onConfirm,this,[popup,false,cb]]},'button=Yes',{'onClick':[this.onConfirm,this,[popup,true,cb]]}]);ecma.dom.appendChildren(popup,contents);};Prompt.onConfirm=function(event,popup,result,cb){this.removePopup(event,popup);if(cb)ecma.lang.callback(cb,null,[result]);};});ECMAScript.Extend('lsn.forms',function(ecma){var CDispatcher=ecma.action.ActionDispatcher;this.Form=function(def,vals){CDispatcher.call(this);this.model=this.mapFormDefinition(def,vals);};var _proto=this.Form.prototype=ecma.lang.createMethods(CDispatcher);_proto.mapFormDefinition=function(def,vals){var model={'action':def.getValue('action'),'submit':def.getValue('submit'),'fieldsets':[]};def.getValue('fieldsets').iterate(function(i,fs){model.fieldsets.push(new ecma.lsn.forms.Fieldset(fs,vals));},this);return model;};_proto.getRootElement=function(){return this.uiRoot||this.createUI();};_proto.focus=function(){if(!this.uiFirstVisibleControl)return;this.uiFirstVisibleControl.focus();};_proto.disableForm=function(){};_proto.enableForm=function(){};_proto.resetForm=function(){};_proto.submitForm=function(){var values=this.getValues();this.doSubmitValues(values);};_proto.submitFormChanges=function(){if(!this.hasChanged())return false;var values=this.getChangedValues();this.doSubmitValues(values);return true;};_proto.createUI=function(){var tbody=ecma.dom.createElement('tbody');var form=ecma.dom.createElement('form',{'method':'POST','autocomplete':'off','onSubmit':[this.onFormSubmitEvent,this]},['table',[tbody]]);if(this.model.submit){form.appendChild(ecma.dom.createElement('div',{'class':'buttons'},['input',{'type':'submit','name':'submit','value':this.model.submit}]));}
delete this.uiFirstVisibleControl;for(var i=0,fs;fs=this.model.fieldsets[i];i++){if(fs.heading){tbody.appendChild(ecma.dom.createElement('tr',['th',{'colspan':2},['h4',['#text',{'nodeValue':fs.heading}]]]));}
for(var j=0,field;field=fs.fields[j];j++){if(field.isHidden()){form.appendChild(field.getControlElement());}else{tbody.appendChild(field.getRootElement());if(!this.uiFirstVisibleControl){this.uiFirstVisibleControl=field.getControlElement();}}}}
return this.uiRoot=form;};_proto.onFormSubmitEvent=function(event){ecma.dom.stopEvent(event);this.submitForm();};_proto.getFields=function(){var fields=[];var fieldsets=this.model.fieldsets;for(var i=0,fs;fs=fieldsets[i];i++){for(var j=0,field;field=fs.fields[j];j++){fields.push(field);}}
return fields;};_proto.getValues=function(){var values={};var fields=this.getFields();for(var j=0,field;field=fields[j];j++){values[field.getName()]=field.getValue();}
return values;};_proto.getChangedValues=function(){var values={};var fields=this.getFields();for(var j=0,field;field=fields[j];j++){if(field.hasChanged())values[field.getName()]=field.getValue();}
return values;};_proto.hasChanged=function(){var values=this.getChangedValues();for(var k in values){return true;}
return false;};_proto.doSubmitValues=function(values){var params=new ecma.data.HashList();for(var k in values){params.set(k,values[k]);}
if(this.model.action){var req=new ecma.lsn.Request(this.model.action);req.addEventListener('onComplete',this.doSubmitComplete,this);req.submit(params);this.dispatchClassAction('onSubmit',req);}else{this.dispatchClassAction('doSubmit',params);}};_proto.doSubmitComplete=function(req){var rc=req.xhr.status;if(rc==200){var data=req&&req.responseHash?req.responseHash.get('body'):undefined;this.dispatchClassAction('onSubmitOk',data);}else{var ex=new Error(rc+': '+req.xhr.responseText);this.dispatchClassAction('onSubmitNotOk',ex,req);}
this.dispatchClassAction('onSubmitComplete',req);};});ECMAScript.Extend('lsn.forms',function(ecma){this.Fieldset=function(def,vals){this.fields=[];this.heading=def.getValue('heading');def.getValue('fields').iterate(function(k,v){var name=v.getValue('name')?v.getValue('name'):k;var value=vals?vals.get(name):undefined;this.fields.push(new ecma.lsn.forms.Field(name,v,value));},this);};var _proto=this.Fieldset.prototype=ecma.lang.createMethods();});ECMAScript.Extend('lsn.forms',function(ecma){this.Field=function(name,data,value){this.name=name;this.original=ecma.util.defined(value)&&value!=''?value:undefined;this.model=this.loadFieldData(data);this.id=this.createId();this.adaptor=undefined;};var _proto=this.Field.prototype=ecma.lang.createMethods();_proto.createId=function(){return ecma.util.randomId(this.model.type+'_');};_proto.loadFieldData=function(data){var model={'type':'text','value':'','label':'','name':this.name};ecma.util.overlay(model,data.toObject());if(model.val&&!model.value){model.value=model.val;delete model.val;}
if(ecma.util.defined(this.original)){model.value=this.original;}
return model;};_proto.isHidden=function(){return this.model.type=='hidden';};_proto.getName=function(){return this.name;};_proto.getValue=function(){return this.adaptor?this.adaptor.serialize():this.uiControl?ecma.dom.getValue(this.uiControl):undefined;};_proto.hasChanged=function(){var value=this.getValue();return this.model.type=='password'&&value=='*****'?false:value==''&&!ecma.util.defined(this.original)?false:value!=this.original;};_proto.getRootElement=function(){return this.uiRoot||this.createUI();};_proto.getLabelElement=function(){return this.uiLabel||this.createLabel();};_proto.getControlElement=function(){return this.uiControl||this.createControl();};_proto.createUI=function(){var tr=ecma.dom.createElement('tr',['th',[this.getLabelElement()],'td',[this.getControlElement()]]);return this.uiRoot=tr;};_proto.createLabel=function(){var label=ecma.dom.createElement('label',{'for':this.id},['#text',{'nodeValue':this.model.label}]);return this.uiLabel=label;};_proto.createControl=function(){var model=this.model;var tag='';var adaptor=undefined;var attrs={'id':this.id,'class':model.type,'name':this.name};var cnodes=[];var initialValue=model.value;switch(model.type){case'text':adaptor=ecma.lsn.forms.InputText;var maxLength=ecma.util.defined(model.maxlength)?model.maxlength:64;tag='input';attrs.type='text';attrs.maxlength=maxLength;break;case'textarea':adaptor=ecma.lsn.forms.InputTextarea;tag='textarea';break;case'password':adaptor=ecma.lsn.forms.InputText;tag='input';initialValue=model.value?'*****':'';attrs.type='password';break;case'date':adaptor=ecma.lsn.forms.InputDate;tag='input';attrs.type='text';break;case'hidden':tag='input';attrs.type='hidden';break;case'select':tag='select';if(model.options){for(var i=0,opt;opt=model.options[i];i++){var opt_attrs=typeof(opt)==='string'?{'value':opt,'innerHTML':opt}:{'value':opt.value,'innerHTML':opt.text};if(opt.value==model.value)opt_attrs.selected='selected';cnodes.push('option',opt_attrs);}}
break;case'decimal':adaptor=ecma.lsn.forms.InputDecimal;tag='input';attrs.type='text';break;case'checkbox':case'radio':case'file':case'time':case'datetime':case'integer':case'currency':default:throw'Not a known form input control type: '+model.type;}
this.uiControl=ecma.dom.createElement(tag,attrs,cnodes);if(adaptor){this.adaptor=new adaptor(this.uiControl);this.adaptor.sync();}
if(initialValue){if(this.adaptor){this.adaptor.deserialize(initialValue);}else{ecma.dom.setValue(this.uiControl,initialValue);}}
return this.uiControl;}});ECMAScript.Extend('lsn.forms',function(ecma){var CAction=ecma.action.ActionDispatcher;this.InputBase=function(elem){CAction.apply(this);this.elem=null;this.value=this.emptyValue=null;this.evtChange=null;if(elem)this.attach(elem);};var InputBase=this.InputBase.prototype=ecma.lang.createMethods(CAction);InputBase.attach=function(elem){elem=ecma.dom.getElement(elem);if(!elem)throw new Error('Missing input element');this.elem=elem;this.evtChange=new ecma.dom.EventListener(this.elem,'change',function(event){this.sync();this.dispatchAction('change',this);},this);};InputBase.detach=function(){if(this.evtChange)this.evtChange.remove();};InputBase.reset=function(){return this.setValue(this.emptyValue);};InputBase.getValue=function(){this.read();return this.value;};InputBase.setValue=function(value){this.value=value;this.write();return this;};InputBase.sync=function(){this.read();this.write();return this;};InputBase.read=function(){this.value=this.unmarshal(ecma.dom.getValue(this.elem));return this;};InputBase.write=function(){ecma.dom.setValue(this.elem,this.marshal(this.value));return this;};InputBase.marshal=function(dataValue){var ctrlValue=dataValue;return ctrlValue;};InputBase.unmarshal=function(ctrlValue){var dataValue=ctrlValue;return dataValue;};InputBase.deserialize=function(storedValue){this.setValue(storedValue);return this;};InputBase.serialize=function(){return this.getValue();};});ECMAScript.Extend('lsn.forms',function(ecma){var CInputBase=this.InputBase;var _proto=ecma.lang.createMethods(CInputBase);this.InputBoolean=function(elem){CInputBase.apply(this,[elem]);this.value=this.emptyValue=new Boolean();};this.InputBoolean.prototype=_proto;_proto.marshal=function(dataValue){try{return dataValue.valueOf()?1:0;}catch(ex){js.console.log(ex);return 0;}};_proto.unmarshal=function(ctrlValue){return new Boolean(ecma.util.asInt(ctrlValue));};_proto.deserialize=function(storedValue){this.setValue(new Boolean(ecma.util.asInt(storedValue)));return this;};_proto.serialize=function(){return this.getValue().valueOf()?'1':'0';};});ECMAScript.Extend('lsn.forms',function(ecma){var CInputBase=this.InputBase;var _proto=ecma.lang.createMethods(CInputBase);this.InputDate=function(elem,format){CInputBase.apply(this,[elem]);this.format=format||'m/d/yyyy';this.invalidValue=new Date(0);this.value=this.emptyValue=new Date();};this.InputDate.prototype=_proto;_proto.marshal=function(dataValue){try{return ecma.date.format(dataValue,this.format);}catch(ex){js.console.log(ex);return ecma.date.format(this.invalidValue,this.format);}};_proto.unmarshal=function(ctrlValue){var now=new Date();var parts=ctrlValue.match(/(\d+)/g);var date;if(parts){var m=parts[0]||now.getMonth();var d=parts[1]||now.getDate();var y=parts[2]||now.getFullYear();var yyyy;y=ecma.util.pad(new String(y),2);var len=4-y.length;if(len<0)yyyy=y.substr(0,4);if(len==0)yyyy=y;if(len>0){var prefix=new String(now.getFullYear()).substr(0,len);yyyy=prefix+y;}
m=m-1;return new Date(yyyy,m,d);}else{return now;}};_proto.deserialize=function(storedValue){this.setValue(new Date(storedValue));return this;};_proto.serialize=function(){return this.getValue().toUTCString();};});ECMAScript.Extend('lsn.forms',function(ecma){var CInputBase=this.InputBase;var _proto=ecma.lang.createMethods(CInputBase);this.InputDecimal=function(elem,digits){CInputBase.apply(this,[elem]);this.digits=ecma.util.defined(digits)?digits:2;this.value=this.emptyValue=new Number();};this.InputDecimal.prototype=_proto;_proto.marshal=function(dataValue){return dataValue.toFixed(this.digits);};_proto.unmarshal=function(ctrlValue){return new Number(ctrlValue);};_proto.deserialize=function(storedValue){this.setValue(new Number(storedValue));return this;};_proto.serialize=function(){return this.getValue().valueOf();};});ECMAScript.Extend('lsn.forms',function(ecma){var CInputBase=this.InputBase;var _proto=ecma.lang.createMethods(CInputBase);this.InputText=function(elem){CInputBase.apply(this,[elem]);this.value=this.emptyValue=new String();};this.InputText.prototype=_proto;_proto.deserialize=function(storedValue){this.setValue(ecma.data.entities.encode(storedValue));return this;};_proto.serialize=function(){return ecma.data.entities.decode(this.getValue(),true);};});ECMAScript.Extend('lsn.forms',function(ecma){this.InputTextarea=this.InputText;});ECMAScript.Extend('lsn.forms',function(ecma){var CInputBase=this.InputBase;var _proto=ecma.lang.createMethods(CInputBase);this.InputCheckbox=function(elem){CInputBase.apply(this,[elem]);this.value=this.emptyValue=new Boolean(false);};this.InputCheckbox.prototype=_proto;_proto.marshal=function(dataValue){return dataValue.valueOf();};_proto.unmarshal=function(ctrlValue){var bPrimitive=ctrlValue=='off'?false:ctrlValue?true:false;return new Boolean(bPrimitive);};_proto.deserialize=function(storedValue){this.setValue(new Boolean(storedValue));return this;};_proto.serialize=function(){return this.getValue().valueOf()?1:0;};});ECMAScript.Extend('lsn.layout',function(ecma){this.css=new ecma.dom.StyleSheet();});ECMAScript.Extend('lsn.layout',function(ecma){this.ResizeRule=function(ruleName,values){this.ruleName=ruleName;this.values=values;this.update(0,0);};var ResizeRule=this.ResizeRule.prototype=ecma.lang.createMethods();ResizeRule.adjust=function(prop,px){this.values[prop]=(ecma.util.asInt(this.values[prop])+px)+'px';};ResizeRule.update=function(x,y){this.values.width+=x;this.values.height+=y;ecma.lsn.layout.css.updateRule(this.ruleName,this.toCSS());};ResizeRule.toCSS=function(){var result='';for(name in this.values){result+=name+':'+this.values[name]+'px;';}
return result;};});ECMAScript.Extend('lsn.layout',function(ecma){var BOX=0;var ROW=1;var COLUMN=2;var CDispatcher=ecma.action.ActionDispatcher;this.Area=function(type,name,size){CDispatcher.apply(this);this.type=type;this.name=name||ecma.util.randomId('area');this.ruleName='.'+this.name;this.size=size;this.ratio=null;this.fixed=null;this.sumFixed=0;this.sumRatio=0;this.splitType=null;this.splits=[];this.hasInitialized=false;this.region={};};var Area=this.Area.prototype=ecma.lang.createMethods(CDispatcher);Area.getArea=function(name){var result=null;if(this.name===name){result=this;}
for(var i=0;!result&&i<this.splits.length;i++){result=this.splits[i].getArea(name);}
return result;};Area.addArea=function(type,name,size){if(this.splitType&&this.splitType!==type){throw'Cannot mix rows and columns';}
if(this.hasInitialized){throw'Cannot create areas after initialization';}
this.splitType=type;var area=new ecma.lsn.layout.Area(type,name,size);this.splits.push(area);return area;};Area.addRow=function(name,size){return this.addArea(ROW,name,size);};Area.addColumn=function(name,size){return this.addArea(COLUMN,name,size);};Area.allocate=function(){var spread=[];for(var i=0,area;area=this.splits[i];i++){if(!ecma.util.defined(area.size)){spread.push(area);}else{if(area.size>0&&area.size<1){this.sumRatio+=area.size;area.ratio=area.size;}else{this.sumFixed+=area.size;area.fixed=area.size;}}}
if(spread.length>0){var free=Math.ceil(100*(1-this.sumRatio));var a=Math.round(free/spread.length);var r=free-(spread.length*a);for(var i=0,area;area=spread[i];i++){var ratio=i==0?(a+r)/100:a/100;area.ratio=ratio;this.sumRatio+=ratio;}}
for(var i=0,area;area=this.splits[i];i++){area.allocate();}};Area.getStyleSheet=function(){return ecma.lsn.layout.css;};Area.updateRule=function(){var ruleText='';for(name in this.region){ruleText+=name+':'+this.region[name]+'px;';}
this.getStyleSheet().updateRule(this.ruleName,ruleText);this.dispatchAction('onUpdate',this);};Area.initialize=function(region){this.createStyles();this.setRegion(region);this.hasInitialized=true;};Area.createStyles=function(){this.getStyleSheet().createRule(this.ruleName,{'position':'absolute'});for(var i=0,area;area=this.splits[i];i++){area.createStyles();}};Area.getRegion=function(){var region=ecma.util.clone(this.region);if(this.splitType==COLUMN)region.width-=this.sumFixed;if(this.splitType==ROW)region.height-=this.sumFixed;return region;};Area.setRegion=function(region){this.region.top=region.top;this.region.left=region.left;this.region.width=this.type===ROW?region.width:this.ratio?Math.floor(region.width*this.ratio):this.fixed;this.region.height=this.type===COLUMN?region.height:this.ratio?Math.floor(region.height*this.ratio):this.fixed;this.updateRule();this.propagate();};Area.propagate=function(){function _propagate(p1,p2){var region=this.getRegion();var used=0;var fill=null;for(var i=0,area;area=this.splits[i];i++){area.setRegion(region);if(area.ratio){fill=area;used+=area.region[p1];}
region[p2]+=area.region[p1];}
if(this.sumRatio&&fill){var actual=Math.round(region[p1]*this.sumRatio);var delta=actual-used;if(delta>0){fill.region[p1]+=delta;fill.updateRule();fill.propagate();}}}
if(this.splitType===COLUMN)_propagate.apply(this,['width','left']);if(this.splitType===ROW)_propagate.apply(this,['height','top']);};});ECMAScript.Extend('lsn.layout',function(ecma){var CPage=ecma.lsn.ui.Page;var CArea=ecma.lsn.layout.Area;this.ViewportLayout=function(gutter){CPage.apply(this);CArea.apply(this);this.ruleName='html body';this.pgRefreshRate=64;this.gutter=0;this.resizeRules=[];this.setGutter(gutter);};var ViewportLayout=this.ViewportLayout.prototype=ecma.lang.createMethods(CPage,CArea);ViewportLayout.onPageLoad=function(event){this.allocate();var vp=this.getViewport();this.addResizeRule('html',{'width':vp.width,'height':vp.height});this.initialize(vp);};ViewportLayout.onPageResize=function(event){var vp=this.getViewport();var w=vp.delta.width;var h=vp.delta.height;for(var i=0,rule;rule=this.resizeRules[i];i++){rule.update(w,h);}
this.region.width+=w;this.region.height+=h;this.updateRule();this.propagate();};ViewportLayout.setGutter=function(px){if(this.hasInitialized){throw'Cannot set gutter after initialization';}
return this.gutter=px||0;};ViewportLayout.getRegion=function(){var region=CArea.prototype.getRegion.apply(this);region.top=0;region.left=0;return region;};ViewportLayout.setRegion=function(region){this.region.width=region.width-(2*this.gutter);this.region.height=region.height-(2*this.gutter);this.region.top=this.gutter;this.region.left=this.gutter;this.updateRule();this.propagate();};ViewportLayout.createStyles=function(){ecma.lsn.layout.css.createRule('html',{'margin':'0','padding':'0','position':'absolute','overflow':'hidden','top':'0','left':'0'})
ecma.lsn.layout.css.createRule('html body',{'margin':'0','padding':'0','position':'absolute','top':this.gutter+'px','left':this.gutter+'px'});for(var i=0,area;area=this.splits[i];i++){area.createStyles();}};ViewportLayout.addResizeRule=function(name,values){var rule=new ecma.lsn.layout.ResizeRule(name,values);this.resizeRules.push(rule);return rule;};});js=new ECMAScript.Class(window,document);

