/*
 * DynarchLIB version: 1.0
 *                                                                ____   _____
 * A lightweight JavaScript toolkit for professionals.            \  /_  /   /
 *                                                                 \  / /   /
 * Copyright (c) Dynarch.com 2005-2008.  All rights reserved.       \/ /_  /
 * See http://www.dynarchlib.com/licensing for licensing details.    \  / /
 *                                                                     / /
 *          this package built at 2008/04/30 13:28 GMT                 \/
 */
DlTEXTS={goToday:"Go Today",_date_monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],_date_shortMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],_date_dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],_date_shortDayNames:["Su","Mo","Tu","We","Th","Fr","Sa","Su"],_date_firstDayOfWeek:1};try{document.execCommand("BackgroundImageCache",false,true);}catch(e){};Array.$=function(obj,start){if(start==null)start=0;var a,i,j;try{a=Array.prototype.slice.call(obj,start);}catch(ex){a=new Array(obj.length-start);for(i=start,j=0;i<obj.length;++i,++j)a[j]=obj[i];}return a;};Function.prototype.$=Function.prototype.closure=function(obj){var args=Array.$(arguments,1),f=this;if(obj==window.undefined)return function(){return f.apply(this,args.concat(Array.$(arguments)))};else return function(){return f.apply(obj,args.concat(Array.$(arguments)))};};Function.prototype.$0=function(obj){var f=this,args=Array.$(arguments,1);return function(){return f.apply(obj,args)};};Function.prototype.$$=function(a){return this.$.apply(this,a)};Function.prototype.$A=function(obj,a){return this.$.apply(this,[obj].concat(a))};Function.prototype.$C=function(){var args=Array.$(arguments),f=this;return function(){return f.apply(null,args.concat(Array.$(arguments)))}};Function.prototype.inverse=function(){var f=this;return function(){return!f.apply(this,arguments);};};Function.prototype.clearingTimeout=function(timeout,obj){var id=null,handler=this,args=Array.$(arguments,2),f=function(){if(id)clearTimeout(id);id=setTimeout(handler.$A(obj,args.concat(Array.$(arguments))),timeout);};f.cancel=function(){clearTimeout(id)};f.doItNow=function(){clearTimeout(id);handler.apply(obj,args.concat(Array.$(arguments)))};return f;};Function.noop=function(){};Function.identity=function(x){return x;};Function.returnTrue=function(){return true;};Function.returnFalse=function(){return false;};Function.invoke=function(x){return x();};function $_YIELD(timeout){this.timeout=timeout||0;};$_BREAK={};$_CONTINUE={};function $_RETURN(args){this.args=args;};function $YIELD(timeout){throw new $_YIELD(timeout);};function $BREAK(){throw $_BREAK;};function $CONTINUE(){throw $_CONTINUE;};function $RETURN(args){throw new $_RETURN(args);};(function(){var UA=navigator.userAgent;is_opera=/opera/i.test(UA);is_ie=/msie/i.test(UA)&&!is_opera&&!(/mac_powerpc/i.test(UA));is_ie5=is_ie&&/msie 5\.[^5]/i.test(UA);is_ie6=is_ie&&/msie 6/i.test(UA);is_ie7=is_ie&&/msie 7/i.test(UA);ie_box_model=is_ie&&document.compatMode&&document.compatMode=="BackCompat";is_mac_ie=/msie.*mac/i.test(UA);is_khtml=/Konqueror|Safari|KHTML/i.test(UA);is_safari=/Safari/i.test(UA);is_safari3=is_safari&&/Version\/3/i.test(UA);is_konqueror=is_khtml&&!is_safari3;is_gecko=/gecko/i.test(UA)&&!is_khtml&&!is_opera&&!is_ie;is_w3=!is_ie;if(is_gecko&&/rv:\s*([0-9.]+)/.test(UA))gecko_version=parseFloat(RegExp.$1);Date._MD=[31,28,31,30,31,30,31,31,30,31,30,31];Date.SECOND=1000;Date.MINUTE=60*Date.SECOND;Date.HOUR=60*Date.MINUTE;Date.DAY=24*Date.HOUR;Date.WEEK=7*Date.DAY;var F=Function.prototype,A=Array.prototype,D=Date.prototype,S=String.prototype,N=Number.prototype;INHERITANCE={};F.inherits=function(base){var p=(this.prototype=new base);p.constructor=this;this.BASE=base.prototype;this._objectType=p._objectType=Dynarch.getFunctionName(this);INHERITANCE[this._objectType]=Dynarch.getFunctionName(base);if(p.__patchSubclassPrototype instanceof Function)p.__patchSubclassPrototype();return this.BASE;};Function.getInheritanceGraph=function(){return INHERITANCE;};F.delayed=function(timeout){var f=arguments.length>1?this.$$(Array.$(arguments,1)):this;return setTimeout(f,timeout);};F.setInterval=function(timeout){var f=arguments.length>1?this.$$(Array.$(arguments,1)):this;setTimeout(f,0);return setInterval(f,timeout);};F.inject=function(props){if(props==null)props=this.OBJECT_EXTENSIONS;Dynarch.merge(this.prototype,props);return this;};F.setDefaults=function(obj,args,overwrite){return Dynarch.setDefaults.call(obj,this.DEFAULT_ARGS,args,overwrite);};Array.hashKeys=function(obj){var a=[],i=0,key;for(key in obj)a[i++]=key;return a;};Array.hashValues=function(obj){var a=[],i=0,key;for(key in obj)a[i++]=obj[key];return a;};A.accumulate=function(f,val){if(arguments.length<2)val=0;for(var i=0;i<this.length;++i)val=f(this[i],val,i);return val;};A.foreach=function(f,obj){if(obj==null)obj=this;var i=0,l=this.length;while(l-->0)try{f.call(obj,this[i],i++);}catch(ex){if(ex===$_BREAK)break;if(ex===$_CONTINUE)continue;if(ex instanceof $_RETURN)return ex.args;throw ex;}};A.r_foreach=function(f,obj){if(obj==null)obj=this;for(var i=this.length;--i>=0;)try{f.call(obj,this[i],i);}catch(ex){if(ex===$_BREAK)break;if(ex===$_CONTINUE)continue;if(ex instanceof $_RETURN)return ex.args;throw ex;}};A.assign_each=function(f,obj){return this.foreach(function(el,i){this[i]=f.call(obj,i,el);});};A.r_assign_each=function(f,obj){return this.r_foreach(function(el,i){this[i]=f.call(obj,i,el);});};A.toHash=function(val,obj){var h={};if(val instanceof Function){this.foreach(function(s,i){h[s]=val.call(obj,s,i);});}else{this.foreach(function(s,i){h[s]=val!=null?val:(i+1);});}return h;};A.toHash2=function(){var hash={},i=0;while(i<this.length)hash[this[i++]]=this[i++];return hash;};A.map=function(f,obj){var i=0,l=this.length,a=[],args,func;if(!(f instanceof Function)){args=Array.$(arguments,1);while(l-->0){obj=this[i];func=obj[f];a[i++]=(func instanceof Function)?func.apply(obj,args):func;}}else{if(obj==null)obj=this;while(l-->0)try{a.push(f.call(obj,this[i],i++));}catch(ex){if(ex===$_BREAK)break;if(ex===$_CONTINUE)continue;if(ex instanceof $_RETURN){a.push(ex.args);break;}throw ex;}}return a;};A.r_map=function(f,obj){var i=this.length,a=[],func;if(!(f instanceof Function)){args=Array.$(arguments,1);while(--i>=0){obj=this[i];func=obj[f];a[i]=(func instanceof Function)?func.apply(obj,args):func;}}else{if(obj==null)obj=this;while(--i>=0)try{a.push(f.call(obj,this[i],i));}catch(ex){if(ex===$_BREAK)break;if(ex===$_CONTINUE)continue;if(ex instanceof $_RETURN){a.push(ex.args);break;}throw ex;}}return a.reverse();};A.keys_map=function(obj){return this.map(function(key){return obj[key];});};A.grep=function(cond,obj){var i=0,l=this.length,a=[],el,args,func;if(cond instanceof RegExp){while(l-->0){el=this[i++];cond.test(el)&&a.push(el);}}else if(cond instanceof Function){if(obj==null)obj=this;while(l-->0){el=this[i];cond.call(obj,el,i++)&&a.push(el);}}else{args=Array.$(arguments,1);while(l-->0){obj=this[i++];func=obj[cond];if(obj[cond]instanceof Function){obj[cond].apply(obj,args)&&a.push(obj);}else if(obj[cond]){a.push(obj);}}}return a;};A.grep_last=function(f,i){if(i==null)i=this.length-1;while(i>=0){var el=this[i--];if(f(el))return el;}return null;};A.grep_first=function(f,i){for(i=i||0;i<this.length;++i){var el=this[i];if(f(el))return el;}return null;};A.contains=function(el){for(var i=this.length;--i>=0;)if(this[i]===el)return true;return false;};A.find=function(el){for(var i=this.length;--i>=0;)if(this[i]===el)return i;return-1;};A.remove=function(el){for(var i=this.length;--i>=0;)if(this[i]===el)this.splice(i,1);return this;};A.pushUnique=function(el){if(this.find(el)<0){this.push(el);return this.length;}return null;};function makeComparator(cmp,reverse){if(reverse){if(cmp instanceof Function)return function(el1,el2){return cmp(el2,el1);};else return function(el2,el1){return(el1<el2)?-1:((el1>el2)?1:0);};}else{if(cmp instanceof Function)return cmp;else return function(el1,el2){return(el1<el2)?-1:((el1>el2)?1:0);};}};A.mergeSort=function(cmp,reverse){if(this.length<2)return Array.$(this);var _cmp=makeComparator(cmp,reverse);function merge(a,b){var r=[],ai=0,bi=0,i=0;while(ai<a.length&&bi<b.length){_cmp(a[ai],b[bi])<=0?r[i++]=a[ai++]:r[i++]=b[bi++];}if(ai<a.length)r.push.apply(r,a.slice(ai));if(bi<b.length)r.push.apply(r,b.slice(bi));return r;};function _ms(a){if(a.length<=1)return a;var m=Math.floor(a.length/2),left=a.slice(0,m),right=a.slice(m);left=_ms(left);right=_ms(right);return merge(left,right);};return _ms(this);};A.qsort=function(cmp,reverse){if(this.length<2)return;var _cmp=makeComparator(cmp,reverse),a=this,tmp,modified=false;function _qs(st,en){var j=st,k=en,sw=false;if(j<k){do{if(_cmp(a[j],a[k])>0){tmp=a[j];a[j]=a[k];a[k]=tmp;sw=!sw;modified=true;}sw?--k:++j;}while(j<k);_qs(st,j-1);_qs(j+1,en);}};_qs(0,this.length-1);return modified;};A.peek=function(){if(this.length>0)return this[this.length-1];};A.min=function(f,obj){if(this.length==0)return null;if(arguments.length>0){var min=f!=null?f.call(obj,this[0],0):this[0];for(i=1;i<this.length;++i){min=Math.min(min,(f!=null?f.call(obj,this[i],i):this[i]));}return min;}return Math.min.apply(Math,this);};A.max=function(f,obj){if(this.length==0)return null;if(arguments.length>0){var max=f!=null?f.call(obj,this[0],0):this[0];for(i=1;i<this.length;++i){max=Math.max(max,(f!=null?f.call(obj,this[i],i):this[i]));}return max;}return Math.max.apply(Math,this);};A.rotateIndex=function(idx){return Math.rotateLimit(idx,0,this.length-1);};A.limitIndex=function(idx){return Math.limit(idx,0,this.length-1);};A.nullLimitIndex=function(idx){return Math.nullLimit(idx,0,this.length-1);};A.bytesToString=function(){var s=String.buffer(),i=0,c;while(i<this.length){c=this[i++];if(!(c&0xF0 ^ 0xF0)){c=((c&0x03)<<18)|((this[i++]&0x3F)<<12)|((this[i++]&0x3F)<<6)|(this[i++]&0x3F);}else if(!(c&0xE0 ^ 0xE0)){c=((c&0x0F)<<12)|((this[i++]&0x3F)<<6)|(this[i++]&0x3F);}else if(!(c&0xC0 ^ 0xC0)){c=((c&0x1F)<<6)|(this[i++]&0x3F);}s(String.fromCharCode(c));}return s.get();};N.map=function(start,stop){return start+(stop-start)*this;};N.mapInt=function(start,stop){return Math.round(this.map(start,stop));};N.bits1Array=function(){var n=this,a=[],v=1,i=0;while(n>0){if(n&1)a[i++]=v;v=v<<1;n=n>>1;}return a;};N.times=function(f,obj){var i=this,j=0;while(--i>=0)f.call(obj,j++,i);};N.hex=function(width){var n=this.toString(16).toUpperCase();if(width)while(n.length<width)n="0"+n;return n;};var $1K=N.$1K=1024,$1M=N.$1M=$1K*1024,$1G=N.$1G=$1M*1024,$1T=N.$1T=$1G*1024;N.formatBytes=function(fixed){var sz=this,spec,r;if(sz<$1K){spec="B";}else if(sz<$1M){sz/=$1K;spec="K";}else if(sz<$1G){sz/=$1M;spec="M";}else if(sz<$1T){sz/=$1G;spec="G";}spec=" "+spec;r=Math.round(sz);if(fixed&&sz!=r)return sz.toFixed(fixed)+spec;else return r+spec;};N.zeroPad=function(width){var s=""+Math.round(this);while(s.length<width)s="0"+s;return s;};N.formatTime=function(){var s=this,h,m;m=s/60;s%=60;h=m/60;m%=60;return[h,m,s].map("zeroPad",2).join(":");};N.limit=function(min,max){return Math.limit(this,min,max);};N.rotateLimit=function(min,max){return Math.rotateLimit(this,min,max);};N.nullLimit=function(min,max){return Math.nullLimit(this,min,max);};Math.nullLimit=function(n,min,max){if(n<min)n=null;if(n>max)n=null;return n;};Math.limit=function(n,min,max){if(n<min)n=min;if(n>max)n=max;return n;};Math.rotateLimit=function(n,min,max){if(n<min)n=max;if(n>max)n=min;return n;};Date._MN=DlTEXTS._date_monthNames;Date._SMN=DlTEXTS._date_shortMonthNames;Date._DN=DlTEXTS._date_dayNames;Date._SDN=DlTEXTS._date_shortDayNames;Date._FDOW=DlTEXTS._date_firstDayOfWeek;Date.isWeekend=function(day){return day==0||day==6;};Date.parseMySQL=function(str){var a=str.split(/\s+/),d=a[0].split(/-/),t=a[1].split(/:/);return new Date(d[0],d[1]-1,d[2],t[0],t[1],t[2]);};D.getMonthDays=function(m){var y=this.getFullYear();if(m!=null)m=this.getMonth();return(((0==(y%4))&&((0!=(y%100))||(0==(y%400))))&&m==1)?29:Date._MD[m];};D.getDayOfYear=function(){var now=new Date(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0);var then=new Date(this.getFullYear(),0,0,0,0,0);var time=now-then;return Math.floor(time/Date.DAY);};D.getWeekNumber=function(){var d=new Date(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0);var DoW=d.getDay();d.setDate(d.getDate()-(DoW+6)%7+3);var ms=d.valueOf();d.setMonth(0);d.setDate(4);return Math.round((ms-d.valueOf())/(7*864e5))+1;};D.dateEqualsTo=function(date,monthOnly){return this.getFullYear()==date.getFullYear()&&this.getMonth()==date.getMonth()&&(monthOnly||this.getDate()==date.getDate());};D.print=function(str){var m=this.getMonth();var d=this.getDate();var y=this.getFullYear();var wn=this.getWeekNumber();var w=this.getDay();var s={};var hr=this.getHours();var pm=(hr>=12);var ir=(pm)?(hr-12):hr;var dy=this.getDayOfYear();if(ir==0)ir=12;var min=this.getMinutes();var sec=this.getSeconds();s["%a"]=Date.getDayName(w,true);s["%A"]=Date.getDayName(w);s["%b"]=Date.getMonthName(m,true);s["%B"]=Date.getMonthName(m);s["%C"]=1+Math.floor(y/100);s["%d"]=(d<10)?("0"+d):d;s["%e"]=d;s["%H"]=(hr<10)?("0"+hr):hr;s["%I"]=(ir<10)?("0"+ir):ir;s["%j"]=(dy<100)?((dy<10)?("00"+dy):("0"+dy)):dy;s["%k"]=hr;s["%l"]=ir;s["%m"]=(m<9)?("0"+(1+m)):(1+m);s["%M"]=(min<10)?("0"+min):min;s["%n"]="\n";s["%p"]=pm?"PM":"AM";s["%P"]=pm?"pm":"am";s["%s"]=Math.floor(this.getTime()/1000);s["%S"]=(sec<10)?("0"+sec):sec;s["%t"]="\t";s["%U"]=s["%W"]=s["%V"]=(wn<10)?("0"+wn):wn;s["%u"]=w+1;s["%w"]=w;s["%y"]=(''+y).substr(2,2);s["%Y"]=y;s["%%"]="%";var re=/%./g;return str.replace(re,function(par){return s[par]||par;});var a=str.match(re);for(var i=0;i<a.length;i++){var tmp=s[a[i]];if(tmp){re=new RegExp(a[i],'g');str=str.replace(re,tmp);}}return str;};Date.getMonthName=function(mon,sh){var a=sh?Date._SMN:Date._MN;return a[mon%12];};Date.getFirstDayOfWeek=function(){return Date._FDOW;};Date.getDayName=function(day,sh){var a=sh?Date._SDN:Date._DN;return a[day%7];};S.breakable=function(re){if(!re)re=/([_.-])/g;return this.replace(re,"$1<span class='BreakPoint'> </span>");};S.printf=function(){var a=Array.$(arguments),i=0;return this.replace(/%[sdfo%]/g,function(s){s=s.charAt(1);var v=a[i++];switch(s){case "s":return v.toString();case "d":return parseInt(v);case "f":return parseFloat(v).toFixed(3);case "o":return v;case "%":return "%";}return "undefined";});};S.fixedWidth=function(w){return String.buffer("<div style='width:",w,"'>",this,"</div>").get();};S.noWrap=function(){return this.replace(/\x20/g,"&nbsp;");};S.lastIndexOfRegexp=function(re,caret){var m,pos=0;re.lastIndex=0;re.global=true;while(m=re.exec(this)){if(re.lastIndex>=caret)break;pos=re.lastIndex;}return pos;};S.hashWords=function(val){return this.trim().split(/\s+/).toHash(arguments.length>0?val:true);};S.arrayWords=function(){return this.trim().split(/\s+/);};S.qw=S.arrayWords;S.trim=function(nostart,noend){var str;if(!nostart)str=this.replace(/^\s+/,"");if(!noend)str=str.replace(/\s+$/,"");return str;};var CE_CACHE={};CE_CACHE.HTML_ESCAPE_DIV=document.createElement("div");CE_CACHE.HTML_ESCAPE_TEXT=document.createTextNode("");CE_CACHE.HTML_ESCAPE_DIV.appendChild(CE_CACHE.HTML_ESCAPE_TEXT);if(!is_gecko){CE_CACHE.SCROLL_INTO_VIEW=document.createElement("a");CE_CACHE.SCROLL_INTO_VIEW.href="#";}S.htmlEscape=is_gecko?function(){return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\u00A0/g,"&#xa0;");}:function(){CE_CACHE.HTML_ESCAPE_TEXT.data=this;return CE_CACHE.HTML_ESCAPE_DIV.innerHTML;};S.decodeJSON=function(safe){return DlJSON.decode(this,safe);};S.makeLabel=function(){return this.replace(/\s+/g,"&nbsp;");};S.capitalizeString=function(){return this.charAt(0).toUpperCase()+this.substr(1);};S.htmlEmbed=function(tag,c){var a=["<",tag];if(c!=null)a.push(" class='",c,"'");a.push(">",this,"</",tag,">");return a.join("");};S.bold=S.htmlEmbed.$(window.undefined,"b");S.repeat=function(i){if(i==0)return "";if(i==1)return ""+this;var d=this.repeat(i>>1);d+=d;if(i&1)d+=this;return d;};S.hexToBytes=function(unsafe){var a=[],i=0,s=this;if(unsafe)s=s.replace(/[^0-9a-f]/ig,"");if(s.length&1)s="0"+s;while(i<s.length){a.push(parseInt(s.substr(i,2),16));i++;i++;}return a;};S.toBytes=function(){var a=[],i=this.length,j=0,k=0,c;while(--i>=0){c=this.charCodeAt(k++);if(c<0x80){a[j++]=c;}else if(c<0x800){a[j++]=0xC0|((c>>>6)&0x1F);a[j++]=0x80|(c&0x3F);}else if(c<0x10000){a[j++]=0xE0|((c>>>12)&0x0F);a[j++]=0x80|((c>>>6)&0x3F);a[j++]=0x80|(c&0x3F);}else if(c<0x110000){a[j++]=0xF0|((c>>>18)&0x03);a[j++]=0x80|((c>>>12)&0x3F);a[j++]=0x80|((c>>>6)&0x3F);a[j++]=0x80|(c&0x3F);}}return a;};String.firstNonEmpty=function(){for(var i=0;i<arguments.length;++i){var s=arguments[i];if(/\S/.test(s))return s;}};var ids={};window.Dynarch={merge:function(dest,src){for(var i in src)dest[i]=src[i];},copy:function(dest,src){for(var i in dest)delete dest[i];Dynarch.merge(dest,src);},makeCopy:function(src){var i,dest={};for(i in src)dest[i]=src[i];return dest;},makeDeepCopy:function(src){if(src instanceof Array){return src.map(Dynarch.makeDeepCopy);}else if(typeof src=="object"){var i,dest={};for(i in src)dest[i]=Dynarch.makeDeepCopy(src[i]);return dest;}else return src;},mergeUndefined:function(dest,src){for(var i in src)if(!(i in dest))dest[i]=src[i];},setDefaults:function(defaults,args,overwrite){var i,val,def;for(i in defaults){if(overwrite||!(i in this)){def=defaults[i];if(def instanceof Array){if(def[0]!=null){val=def[0];if(val in args)val=args[val];else val=def[1];}else val=def[1];}else val=def;this[i]=val;}}},ID:function(namespace){if(namespace==null)namespace="generic";if(!(namespace in ids))ids[namespace]=0;return "dynarch-"+namespace+"-"+(++ids[namespace]);},getFunctionName:function(f){if(f.name)return f.name;else if(/function\s+(\$?[a-z0-9_]+)\(/i.test(f.toString()))return RegExp.$1;return "UNKNOWN_FUNCTION";},EXPORT:function(name,imp){var ret=String.buffer("var D=window.",name,"=",name,",P=",name,".prototype;");if(imp)ret(DynarchDomUtils.importCommonVars());return ret.get();},getBaseURL:function(){var u=window.Dynarch_Base_Url;if(!u){var scripts=document.getElementsByTagName("script"),i=0,s;while(s=scripts[i++])if(s.className=="DynarchLIB"){u=s.src;if(/^(.*)\x2fjs\x2f/.test(u)){Dynarch_Base_Url=u=RegExp.$1;break;}}}return u;},getFileURL:function(file){return Dynarch.getBaseURL()+"/"+file;},makeArray:Array.$,noop:Function.noop};Object.makeCopy=Dynarch.makeCopy;Object.makeDeepCopy=Dynarch.makeDeepCopy;Object.merge=Dynarch.merge;Object.isEmpty=function(o){for(var i in o)return false;return true;};window.DynarchDomUtils={related:function(element,ev){var related,type;if(is_ie){type=ev.type;if(type=="mouseover")related=ev.fromElement;else if(type=="mouseout")related=ev.toElement;}else related=ev.relatedTarget;if(is_gecko){try{related.parentNode;}catch(ex){try{related=ev.parentNode;}catch(ex){related=ev.target;}}}try{for(;related;related=related.parentNode)if(related===element)return true;}catch(ex){return true;}return false;},getScrollbarSize:function(el){return{x:el.offsetWidth-el.clientWidth,y:el.offsetHeight-el.clientHeight};},addEvent:function(el,evname,func){if(typeof evname=="string"){if(el.addEventListener){el.addEventListener(evname,func,false);}else if(el.attachEvent){el.attachEvent("on"+evname,func);}else{el["on"+evname]=func;}}else if(evname instanceof Array){DynarchDomUtils.addEvents(el,evname,func);}else{for(var i in evname)DynarchDomUtils.addEvent(el,i,evname[i]);}},addEvents:function(el,evs,func){for(var i=evs.length;--i>=0;)DynarchDomUtils.addEvent(el,evs[i],func);},removeEvent:function(el,evname,func){if(typeof evname=="string"){if(el.removeEventListener)el.removeEventListener(evname,func,false);else if(el.detachEvent)el.detachEvent("on"+evname,func);else el["on"+evname]="";}else if(evname instanceof Array){DynarchDomUtils.removeEvents(el,evname,func);}else{for(var i in evname)DynarchDomUtils.removeEvent(el,i,evname[i]);}},removeEvents:function(el,evs,func){for(var i=evs.length;--i>=0;)DynarchDomUtils.removeEvent(el,evs[i],func);},condEvent:function(cond){cond=cond?DynarchDomUtils.addEvent:DynarchDomUtils.removeEvent;return cond.apply(DynarchDomUtils,Array.$(arguments,1));},condEvents:function(cond){cond=cond?DynarchDomUtils.addEvents:DynarchDomUtils.removeEvents;return cond.apply(DynarchDomUtils,Array.$(arguments,1));},stopEvent:function(ev){if(is_ie){ev.cancelBubble=true;ev.returnValue=false;}else{ev.preventDefault();ev.stopPropagation();}return false;},addLoadHandler:function(el,handler){if(is_ie){el.onreadystatechange=function(){if(el.readyState==4){try{el.onreadystatechange=null;}catch(ex){};handler();}};}else DynarchDomUtils.addEvent(el,"load",handler);},callHandler:function(obj,method){if(!obj[method])return;if(obj[method]instanceof Function)obj[method].call(obj);else if(typeof obj[method]=="string")eval(obj[method]);},setStyleProperty:function(el,prop,val){switch(prop){case "float":prop="styleFloat";break;default:prop=prop.toLowerCase().replace(/-([a-z])/g,function(s,p1){return p1.toUpperCase();});}el.style[prop]=val;},setOpacity:function(el,o){if(o!=null){if(o==""&&o!=0){is_ie?el.style.filter="":el.style.opacity="";}else{is_ie?el.style.filter="alpha(opacity="+Math.round(o*100)+")":el.style.opacity=o;}return o;}else{if(!is_ie)return parseFloat(el.style.opacity);else if(/alpha\(opacity=([0-9.])+\)/.test(el.style.opacity))return parseFloat(RegExp.$1);}},getClosestParentByTagName:function(el,tag){tag=tag.toLowerCase();while(el&&el.tagName&&el.tagName.toLowerCase()!=tag)el=el.parentNode;return el;},isInside:function(el,parent){try{while(el){if(el===parent)return true;el=el.parentNode;}}catch(ex){}return false;},getWindowSize:function(){if(is_gecko){if(document.documentElement.clientWidth)return{x:document.documentElement.clientWidth,y:document.documentElement.clientHeight};else return{x:window.innerWidth,y:window.innerHeight};}if(is_opera)return{x:window.innerWidth,y:window.innerHeight};if(is_ie){if(!document.compatMode||document.compatMode=="BackCompat")return{x:document.body.clientWidth,y:document.body.clientHeight};else return{x:document.documentElement.clientWidth,y:document.documentElement.clientHeight};}var div=document.createElement("div"),s=div.style;s.position="absolute";s.bottom=s.right="0px";document.body.appendChild(div);s={x:div.offsetLeft,y:div.offsetTop};document.body.removeChild(div);return s;},getPos:function(el){if(document.getBoxObjectFor){var box=el.ownerDocument.getBoxObjectFor(el);var pos={x:box.x,y:box.y};while(el.parentNode&&el.parentNode!==document.body){el=el.parentNode;pos.x-=el.scrollLeft;pos.y-=el.scrollTop;}return pos;}else if(el.getBoundingClientRect){var box=el.getBoundingClientRect();return{x:box.left-document.documentElement.clientLeft,y:box.top-document.documentElement.clientTop};}if(/^body$/i.test(el.tagName))return{x:0,y:0};var SL=0,ST=0,is_div=/^div$/i.test(el.tagName),r,tmp;if(is_div&&el.scrollLeft)SL=el.scrollLeft;if(is_div&&el.scrollTop)ST=el.scrollTop;r={x:el.offsetLeft-SL,y:el.offsetTop-ST};if(el.offsetParent){tmp=DynarchDomUtils.getPos(el.offsetParent);r.x+=tmp.x;r.y+=tmp.y;}return r;},getBRPos:function(el){var pos=DynarchDomUtils.getPos(el),size=DynarchDomUtils.getOuterSize(el);pos.x+=size.x-1;pos.y+=size.y-1;return pos;},setPos:function(el,x,y){if(typeof x=="number")x+="px";if(typeof y=="number")y+="px";if(x!=null)el.style.left=x;if(y!=null)el.style.top=y;},createElement:function(tag,st,at,par,pos){var el=CE_CACHE[tag],i;if(!el)el=CE_CACHE[tag]=document.createElement(tag);el=el.cloneNode(false);if(st)for(i in st)if(is_ie)DynarchDomUtils.setStyleProperty(el,i,st[i]);else el.style.setProperty(i,st[i],"");if(at)for(i in at)el[i]=at[i];if(par){if(typeof pos=="number")pos=par.childNodes[pos];if(!pos)pos=null;par.insertBefore(el,pos);}return el;},setUnselectable:function(el,unsel){if(unsel==null)unsel=true;if(!is_ie){unsel=unsel?"none":"normal";el.style.MozUserSelect=unsel;el.style.WebkitUserSelect=unsel;el.style.userSelect=unsel;}else{unsel=unsel?"on":"off";var els=Array.$(el.getElementsByTagName("*"));els.push(el);els.foreach(function(el){el.setAttribute("unselectable",unsel);});}},addClass:function(el,ac,dc){DynarchDomUtils.delClass(el,dc,ac);},delClass:function(el,dc,ac){if(el){var cls=el.className;if(dc instanceof RegExp){cls=cls.replace(dc," ");dc=null;}if(ac||dc){var a=cls.split(/\s+/),i=a.length,r={};dc&&(r[dc]=1);ac&&(r[ac]=1);while(--i>=0)if(a[i]in r)a.splice(i,1);ac&&a.push(ac);cls=a.join(" ");}el.className=cls;}},condClass:function(el,cond,clsTrue,clsFalse){DynarchDomUtils[cond?"addClass":"delClass"](el,clsTrue,clsFalse);},hasClass:function(el,cls){return el.className.split(" ").contains(cls);},elementIsVisible:function(el){var s=DynarchDomUtils.getStyle;return s(el,"display")!="none"&&s(el,"visibility")!="hidden";},ie_getBackgroundColor:function(el){var r=document.body.createTextRange();r.moveToElementText(el);return "#"+parseInt(r.queryCommandValue("BackColor")).hex(6);},getStyle:function(el,prop){var ret=null;if(window.getComputedStyle){ret=document.defaultView.getComputedStyle(el,"").getPropertyValue(prop);}else if(el.currentStyle){prop=prop.replace(/-[a-z]/g,function(s){return s.charAt(1).toUpperCase();});if(prop=="backgroundColor"){ret=ie_getBackgroundColor(el);}else{ret=el.currentStyle[prop];}}return ret;},getStylePX:function(el,prop){var val=parseInt(DynarchDomUtils.getStyle(el,prop),10);if(isNaN(val))val=0;return val;},getBorder:function(el){return{x:el.offsetWidth-el.clientWidth,y:el.offsetHeight-el.clientHeight};},getPadding:function(el){var dx,dy,getStyle=DynarchDomUtils.getStylePX;dx=getStyle(el,"padding-left")+getStyle(el,"padding-right");dy=getStyle(el,"padding-top")+getStyle(el,"padding-bottom");return{x:dx,y:dy};},getPaddingAndBorder:function(el){var dx=0,dy=0,getStyle=DynarchDomUtils.getStylePX;dx+=getStyle(el,"border-left-width");dx+=getStyle(el,"border-right-width");dy+=getStyle(el,"border-top-width");dy+=getStyle(el,"border-bottom-width");dx+=getStyle(el,"padding-left");dx+=getStyle(el,"padding-right");dy+=getStyle(el,"padding-top");dy+=getStyle(el,"padding-bottom");return{x:dx,y:dy};},setOuterSize:function(el,x,y){var pb=DynarchDomUtils.getPaddingAndBorder(el);if(x!=null&&pb.x!=NaN)x-=pb.x;if(y!=null&&pb.y!=NaN)y-=pb.y;DynarchDomUtils.setInnerSize(el,x,y);},setInnerSize:function(el,x,y){try{if(typeof x=="number"&&x!=NaN)x=Math.abs(x)+"px";if(typeof y=="number"&&y!=NaN)y=Math.abs(y)+"px";if(x!=null&&x!=NaN)el.style.width=x;if(y!=null&&y!=NaN)el.style.height=y;}catch(ex){};},getOuterSize:function(el){return{x:el.offsetWidth,y:el.offsetHeight};},getInnerSize:function(el){var s=DynarchDomUtils.getOuterSize(el);var pb=DynarchDomUtils.getPaddingAndBorder(el);s.x-=pb.x;s.y-=pb.y;return s;},importCommonVars:function(){return["var DOM=DynarchDomUtils","AC=DOM.addClass","DC=DOM.delClass","CC=DOM.condClass","CE=DOM.createElement","ID=Dynarch.ID"].join(",");},trash:function(el){var gc=CE_CACHE._trash;if(!gc){gc=CE_CACHE._trash=DynarchDomUtils.createElement("div",{zIndex:-10000},{className:"DYNARCH-GARBAGE-COLLECTOR"},document.body);}if(el){gc.appendChild(el);gc.innerHTML="";}return gc;},createFromHtml:function(html){var div=this.trash();div.innerHTML=html;return div.firstChild;},swapNodes:function(n1,n2){var n1p=n1.parentNode,n1n=n1.nextSibling;n2.parentNode.replaceChild(n1,n2);n1p.insertBefore(n2,n1n);},scrollIntoView:function(el){var p=el.parentNode;while(p&&(p.scrollHeight==p.clientHeight&&p.scrollWidth==p.clientWidth||/table|tbody/i.test(p.tagName))){p=p.parentNode;}if(p){var a=[],tmp=p;while(tmp){a.push(tmp);tmp=tmp.parentNode;}var t=0,l=0;tmp=el;while(tmp&&tmp!=p){t+=tmp.offsetTop;l+=tmp.offsetLeft;tmp=tmp.offsetParent;if(a.contains(tmp)){if(tmp!=p){t-=p.offsetTop;l-=p.offsetLeft;}break;}}var b=t+el.offsetHeight,r=l+el.offsetWidth;if(t<p.scrollTop){p.scrollTop=t;}if(t>p.scrollTop&&b>p.scrollTop+p.clientHeight){p.scrollTop=b-p.clientHeight;}if(l<p.scrollLeft){p.scrollLeft=l;}if(l>p.scrollLeft&&r>p.scrollLeft+p.clientWidth){p.scrollLeft=r-p.clientWidth;}}}};DynarchDomUtils.CE_CACHE=CE_CACHE;})();var $=is_gecko?document.getElementById.$(document):function(id){return document.getElementById(id);};String.template=function(){var format=String.buffer.apply(this,arguments).get();return function(props){return format.replace(/(.?)\$(\{.*?\}|[a-zA-Z0-9_]+)/g,function(s,p1,p2){if(p1.charAt(0)=="\\")return s.substr(1);if(p2.charAt(0)=="{")p2=p2.substr(1,p2.length-2);eval("p2 = props."+p2);return p1+p2;});};};String.buffer=(is_ie||is_khtml)?function(){var a=[],idx=0,f=function(){for(var i=0;i<arguments.length;++i)a[idx++]=arguments[i];return f;};f.get=function(){return a.join("");};if(arguments.length>0)f.apply(this,arguments);return f;}:function(){var str="",f=function(){str=str.concat.apply(str,arguments);return f;};if(arguments.length>0)f.apply(this,arguments);f.get=function(){return str;};return f;};if(is_safari||is_ie5){if(!String.prototype.__old_replace){String.prototype.__old_replace=String.prototype.replace;String.prototype.replace=function(re,val){if(!(val instanceof Function))return this.__old_replace(re,val);else{var str=this.slice(0),v,l,a;while(a=re.exec(str)){v=val.apply(null,a);l=a[0].length;re.lastIndex-=l-v.length;str=str.substr(0,a.index)+v+str.substr(a.index+l);if(!re.global)break;}return str;}};}}function DlException(message,code){this.error=this.constructor.name;if(!message)message="*** no error message given ***";this.message=this.constructor.name+": "+message;if(code!=null)this.code=code;};DlException.prototype.toString=function(){var str=this.message;if(this.code)str+=" / code: "+this.code;return str;};DlException.defineException=function(className,base){if(base==null)base="DlException";return eval(["window.",className,"=function ",className,"(message){",base,".call(this, message);};",className,".inherits(",base,");"].join(""));};DlException.defineException("DlExInvalidOperation");DlException.defineException("DlExAbstractBaseClass");DlException.defineException("DlExStopEventDefault");DlException.defineException("DlExStopEventProcessing");DlException.defineException("DlExStopFrameEvent");DlException.defineException("DlExStopEventBubbling");DlException.defineException("DlExStopDOMEventBubbling");DlException.defineException("DlDataException");DlException.defineException("DlSecurityException");DlException.blockDefaultEvent=function(){throw new DlExStopEventDefault;};DlException.stopEventBubbling=function(){throw new DlExStopEventBubbling;};(function(){function DlEventProxy(){this.__eventHooks={};this.__disHooks={};this.registerEvents(DEFAULT_EVENTS);this.addEventListener("onDestroy",this.__onDestroy);};eval(Dynarch.EXPORT("DlEventProxy"));var DEFAULT_EVENTS=["onDestroy"];P.__onDestroy=function(){["__eventHooks","__disHooks"].foreach(function(hooks){for(var i in this[hooks]){var h=this[hooks][i];if(h){h.foreach(function(h,i){this[i]=null;});}this[hooks][i]=null;}this[hooks]=null;},this);};P.__getEventHooks=function(ev){if(!this.__eventHooks)throw new DlExStopEventBubbling;var a=this.__eventHooks[ev.toLowerCase()];if(!a)throw new DlException("Event ["+ev+"] not registered.");return a;};function _connect_callback(w2,e2){return w2.applyHooks(e2,Dynarch.makeArray(arguments,2));};P.registerEvents=function(evs){var h=this.__eventHooks,i=0,e;while(e=evs[i++]){var e=e.toLowerCase();if(!h[e])h[e]=[];}};P.condEventListener=function(cond){cond=cond?this.addEventListener:this.removeEventListener;return cond.apply(this,Array.$(arguments,1));};P.addEventListener=function(ev,handler,phase,object){if(ev instanceof Array){var i=0,e;while(e=ev[i++])this.addEventListener(e,handler,phase,object);}else if(typeof ev=="object"){for(var i in ev)this.addEventListener(i,ev[i],handler,phase);}else{var a=this.__getEventHooks(ev);a.remove(handler);if(phase==null&&ev.toLowerCase()=="ondestroy")phase=true;phase?a.unshift(handler):a.push(handler);if(object)object.addEventListener("onDestroy",this.removeEventListener.$(this,ev,handler));}};P.connectEvents=function(e1,w2,e2){if(typeof w2=="string"){e2=w2;w2=this;}else if(!e2){e2=e1;}if(e1 instanceof Array){for(var i=0;i<e1.length;++i)this.connectEvents(e1[i],w2,e2[i]);}else{this.addEventListener(e1,_connect_callback.$(null,w2,e2));}};P.removeEventListener=function(ev,handler){if(ev instanceof Array){var i=0,e;while(e=ev[i++])this.removeEventListener(e,handler);}else if(typeof ev=="object"){for(var i in ev)this.removeEventListener(i,ev[i]);}else{this.__getEventHooks(ev).remove(handler);}};P.removeAllListeners=function(ev){if(ev instanceof Array){ev.foreach(this.removeAllListeners,this);}else if(typeof ev=="object"){for(var i in ev)this.removeAllListeners(i);}else{this.__getEventHooks(ev).length=0;}};P.disableHooks=function(ev){if(ev instanceof Array)ev.r_foreach(this.disableHooks,this);else{ev=ev.toLowerCase();this.__disHooks[ev]=this.__eventHooks[ev];this.__eventHooks[ev]=[];}};P.enableHooks=function(ev){if(ev instanceof Array)ev.r_foreach(this.enableHooks,this);else{ev=ev.toLowerCase();this.__eventHooks[ev]=this.__disHooks[ev];this.__disHooks[ev]=null;}};P.callHooks=function(ev){var args=arguments.length>1?Array.$(arguments,1):[];return this.applyHooks(ev,args);};P.hasHooks=function(ev){var a=this.__eventHooks[ev.toLowerCase()];return a&&a.length>0;};P.applyHooks=function(ev,args){var ret=[],a,i=0,f;try{a=this.__getEventHooks(ev);while(f=a[i++])ret.push(f.apply(this,args));}catch(ex){if(!(ex instanceof DlExStopEventProcessing))throw ex;}return ret;};P.destroy=function(){if(!this.destroyed){this.destroying=true;this.callHooks("onDestroy");this.__eventHooks=null;this.destroying=false;this.destroyed=true;}};})();(function(){var EVENT_MAP={"mouseover":"onMouseEnter","mouseout":"onMouseLeave","mousedown":"onMouseDown","mouseup":"onMouseUp","mousemove":"onMouseMove","click":"onClick","dblclick":"onDblClick","keydown":"onKeyDown","keyup":"onKeyUp","keypress":"onKeyPress","contextmenu":"onContextMenu","focus":"on_DOM_Focus","blur":"on_DOM_Blur","mousewheel":"onMouseWheel","DOMMouseScroll":"onMouseWheel"};function DlEvent(ev){this.type=ev.type;this.dl_type=EVENT_MAP[this.type]||this.type;this.ctrlKey=ev.ctrlKey;this.altKey=ev.altKey;this.shiftKey=ev.shiftKey;this.button=ev.button;this.focusedWidget=D.focusedWidget();if(is_ie||is_konqueror){switch(ev.button){case 0:this.button=null;break;case 1:this.button=0;break;case 2:this.button=2;break;case 4:this.button=1;break;}}if(this.type.indexOf("key")==0){this.keyCode=ev.keyCode;this.charCode=(is_ie||is_opera)?ev.keyCode:ev.charCode;this.keyStr=String.fromCharCode(this.charCode);}if(this.dl_type=="onMouseWheel"){var delta;if(ev.wheelDelta){delta=ev.wheelDelta/120;}else if(ev.detail){delta=-ev.detail/3;}this.wheelDelta=delta;}this.pos={x:ev.clientX,y:ev.clientY};this.relPos=this.pos;if(is_ie){this.target=ev.srcElement;switch(this.type){case "mouseover":this.relatedTarget=ev.fromElement;break;case "mouseout":this.relatedTarget=ev.toElement;break;}}else try{this.target=ev.target;if(this.target.nodeType==3)this.target=this.target.parentNode;if(this.type=="mouseout"||this.type=="mouseover"){this.relatedTarget=ev.relatedTarget;if(this.relatedTarget&&this.relatedTarget.nodeType==3)this.relatedTarget=this.relatedTarget.parentNode;}}catch(ex){this._failed=true;}};eval(Dynarch.EXPORT("DlEvent",true));P.computePos=function(widget){var el=widget?(widget instanceof DlWidget?widget.getElement():widget):document.body;var pos=this.elPos=el?DOM.getPos(el):{x:0,y:0};return this.relPos={x:this.pos.x-pos.x,y:this.pos.y-pos.y};};P.getObject=function(){var el=this.target;var obj=this.object;if(!obj){try{while(el&&!DlWidget.getFromElement(el))el=el.parentNode;obj=el?DlWidget.getFromElement(el):null;}catch(ex){obj=null;}this.object=obj;}return obj;};P.getParentElement=function(tag){var el=this.target;try{while(el&&el.tagName.toLowerCase()!=tag)el=el.parentNode;}catch(ex){el=null;}return el;};D.stopEvent=DOM.stopEvent;function _processEvent(obj,dev,el,ev){var o2=dev.getObject();switch(dev.type){case "click":break;case "mousedown":obj._ev_mouseDown=true;obj.applyHooks(dev.dl_type,[dev]);break;case "mouseup":var tmp=obj._ev_mouseDown;obj._ev_mouseDown=false;obj.applyHooks(dev.dl_type,[dev]);if(tmp&&obj._ev_mouseInside&&dev.button===0){dev=new DlEvent(ev);dev.dl_type="onClick";this.push([obj,dev,el,ev]);}break;case "mouseover":case "mouseout":if(!el||!DOM.related(el,ev)){if(obj===o2)obj._ev_mouseInside=dev.type=="mouseover";obj.applyHooks(dev.dl_type,[dev]);}else{dev.dl_type=dev.type=="mouseover"?"onMouseOver":"onMouseOut";obj.applyHooks(dev.dl_type,[dev]);}break;case "dblclick":if((is_ie||is_opera)&&!obj.hasHooks("onDblClick")){dev=new DlEvent(ev);dev.type="click";obj.applyHooks(dev.dl_type="onClick",[dev]);break;}default:obj.applyHooks(dev.dl_type,[dev]);break;}if(ev&&dev.domStop)DOM.stopEvent(ev);};var focusedWidget=null;function on_focusedWidget_destroy(){if(this===focusedWidget)focusedWidget=null;};D.fakeBlur=function(){if(is_safari&&focusedWidget.blur)return focusedWidget.blur();var a=DynarchDomUtils.CE_CACHE.FAKE_FOCUS;if(!a){a=DynarchDomUtils.CE_CACHE.FAKE_FOCUS=CE("a",null,{className:"DYNARCH-FAKE-FOCUS"},document.body);}a.focus();if(is_ie){var r=document.body.createTextRange();r.moveStart("character",0);r.collapse(true);r.select();}a.blur();window.status="";};D.focusedWidget=function(w){if(arguments.length>0&&focusedWidget!==w){if(focusedWidget){if(focusedWidget._focusable==2){if(w._focusable<2)D.fakeBlur();}else{focusedWidget.blur();}focusedWidget.removeEventListener("onDestroy",on_focusedWidget_destroy);}focusedWidget=w;if(w){w.addEventListener("onDestroy",on_focusedWidget_destroy);var p=w.parent;while(p){p._focusedWidget=w;p=p.parent;}}}return focusedWidget;};D.checkDisabled=function(w){while(w){if(w.disabled())return true;w=w.parent;}return false;};P.destroy=function(){this.object=this.target=this.relatedTarget=null;};P.stopDomEvent=function(){D.stopEvent(D.latestDomEvent);};var GLOBAL_CAPTURES={};var KEY_EVENTS="keydown keyup keypress".hashWords();D._genericEventHandler=function(ev,ev2){ev||(ev=window.event);var el,obj,dev=ev instanceof D?ev:new D(ev);if(ev2)ev=ev2;if(dev._failed){D.stopEvent(ev);return;}D.latestEvent=dev;D.latestDomEvent=ev;if(dev.pos.x&&dev.dl_type!="onMouseWheel"){D.latestMouseEvent=dev;if(dev.dl_type=="onMouseDown")D.latestMouseDownEvent=dev;}try{var a=GLOBAL_CAPTURES[dev.dl_type];if(a)for(var i=a.length;--i>=0;)a[i](dev);if(dev.type in KEY_EVENTS&&focusedWidget)el=focusedWidget.getElement();else el=dev.target;var objects=[];while(el){obj=DlWidget.getFromElement(el);if(obj&&!D.checkDisabled(obj))objects.push([obj,dev,el,ev]);el=el.parentNode;}for(var i=0;i<objects.length;++i){try{_processEvent.apply(objects,objects[i]);}catch(ex){if(ex instanceof DlExStopDOMEventBubbling)D.stopEvent(ev);else{throw ex;}}}}catch(ex){if(ex instanceof DlExStopEventBubbling)D.stopEvent(ev);else throw ex;}dev.destroy();};var _unloadListeners=[];function _unloadHandler(){_unloadListeners.r_foreach(Function.invoke);};D._unloadHandler=_unloadHandler;D.captureGlobals=function(obj){for(var i in obj)D.captureGlobal(i,obj[i]);};D.releaseGlobals=function(obj){for(var i in obj)D.releaseGlobal(i,obj[i]);};D.captureGlobal=function(type,f){var a=GLOBAL_CAPTURES[type];if(!a)a=GLOBAL_CAPTURES[type]=[];a.push(f);};D.releaseGlobal=function(type,f){var a=GLOBAL_CAPTURES[type];if(a)a.remove(f);};D.atUnload=function(f){_unloadListeners.push(f);};DOM.addEvents(document,["contextmenu","click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove",is_gecko?"DOMMouseScroll":"mousewheel","keydown","keyup","keypress"],D._genericEventHandler);DOM.addEvent(window,"unload",_unloadHandler);})();(function(){var BASE=DlWidget.inherits(DlEventProxy);function DlWidget(args){if(args){DlEventProxy.call(this);if(args.focusable==null&&args.tabIndex)args.focusable=true;D.setDefaults(this,args);this.__propsUserData={};this.__refNodes=[];if(!(this._parent==null||this._parent instanceof DlContainer))throw new DlException("Parent must be an instance of DlContainer");this.id=ID(this._objectType||"DlWidget");WIDGETS[this.id]=this;this.initDOM();}};eval(Dynarch.EXPORT("DlWidget",true));D.DEFAULT_ARGS={userData:["data",null],_parent:["parent",null],_fillParent:["fillParent",null],_tagName:["tagName","div"],_dragArgs:["drag",null],_element:["element",null],_focusable:["focusable",false],_tabIndex:["tabIndex",0],_accessKey:["accessKey",null],__appendArgs:["appendArgs",window.undefined],__addClassName:["className",""],__disabled:["disabled",false],__tooltip:["tooltip",null],__contextMenu:["contextMenu",null],__tooltipTimeout:["tooltipTimeout",650],__refCnt:["_refCnt",0]};var DEFAULT_EVENTS=["onMouseEnter","onMouseLeave","onMouseMove","onMouseDown","onMouseUp","onMouseOver","onMouseOut","onMouseWheel","onClick","onDblClick","onDisabled","onDisplay","onFocus","on_DOM_Focus","onBlur","on_DOM_Blur","onKeyDown","onKeyUp","onKeyPress","onResize","onContextMenu","onTooltipShow","onTooltipHide"];var WIDGETS={};D.getById=function(id){return WIDGETS[id];};D.getFromElement=function(el){return el._dynarch_object;};var TOOLTIP=null;function getTooltip(){if(!TOOLTIP)TOOLTIP=new DlTooltip({});return TOOLTIP;};D.getTooltip=getTooltip;P.getWidgetId=function(){return this.id;};P._className=["DlWidget"];P.__patchSubclassPrototype=function(){(this._className=Array.$(this._className)).push(this._objectType);};var RESIZE_RECT=null;P.getResizeRect=D.getResizeRect=function(){if(!RESIZE_RECT)RESIZE_RECT=CE("div",{display:"none"},{className:"Dl-ResizeRect",innerHTML:"&nbsp;"},document.body);return RESIZE_RECT;};function onDestroy(){if(this.__tooltipActive)getTooltip().hide();if(this.__contextMenu instanceof D)this.__contextMenu.destroy();if(this.parent)try{this.parent.removeWidget(this);}catch(ex){};var el=this.getElement();if(el){el._dynarch_object=null;el._dynarch_focusable=null;}this._element=null;DOM.trash(el);if(WIDGETS[this.id]){WIDGETS[this.id]=null;delete WIDGETS[this.id];}el=null;this.__refNodes.r_foreach(function(name,i){this.__refNodes[i]=null;this[name]=null;delete this[name];},this);this.__refNodes=null;};P.destroy=function(){if(this.unref()<=0)BASE.destroy.call(this);};P.__onTooltipShow=function(){this.__tooltipActive=true;this.callHooks("onTooltipShow");};P.__onTooltipHide=function(){this.__tooltipActive=false;this.callHooks("onTooltipHide");};P._popupTooltip=function(){getTooltip().popup({timeout:this.__tooltipTimeout,content:this.__tooltip,anchor:this.getElement(),align:"mouse",onPopup:this.__onTooltipShow,onHide:this.__onTooltipHide,widget:this});};function onMouseEnter(){if(this.__tooltip)this._popupTooltip();};function onMouseLeave(){getTooltip().hide();};{function dragMouseMove(da,ev){if(!da.dragging){if(Math.abs(ev.pos.x-da.startPos.x)>=da.delta||Math.abs(ev.pos.y-da.startPos.y)>=da.delta){da.dragging=true;da.makeElementCopy(this,ev);this.addClass(da.draggingClass);}}if(da.dragging){var el=da.elementCopy;if(el){el.style.left=ev.pos.x+5+"px";el.style.top=ev.pos.y+5+"px";}if(DRAG_CURSOR==0){DRAG_CURSOR=1;AC(document.body,da.cursor.noDrop);}da.moving(this,ev);DlException.stopEventBubbling();}};function dragCancel(da,ev,wasCancel){DC(document.body,/CURSOR[^\s]*-DROP/g);this.delClass(da.draggingClass);DlEvent.releaseGlobals(da.captures);da.captures=null;DRAGGING=false;if(!wasCancel)da.doDrop(this,ev);da.reset(wasCancel);};function dragMouseUp(da,ev){if(ev.button==0){var wasDropped=da.dragging&&da.canDrop;dragCancel.call(this,da,ev,!wasDropped);}};function dragMouseOver(da,ev){DlException.stopEventBubbling();};function dragMouseOut(da,ev){DlException.stopEventBubbling();};function dragMouseEnter(da,ev){var obj=ev.getObject();var insideThis=false,p=obj;while(p){if(p===this){insideThis=true;break;}p=p.parent;}var canDrop=da.dropOK(this,ev,obj,insideThis);CC(document.body,canDrop,da.cursor.okDrop,da.cursor.noDrop);DRAG_CURSOR=canDrop?2:1;DlException.stopEventBubbling();};function dragMouseLeave(da,ev){DlException.stopEventBubbling();};function dragKeyPress(da,ev){if(ev.keyCode==DlKeyboard.ESCAPE){dragCancel.call(this,da,ev,true);}DlException.stopEventBubbling();};function dragContextMenu(da,ev){DlException.stopEventBubbling();};var DRAGGING=false;var DRAG_CURSOR=0;}function onMouseDown(ev){getTooltip().cancel();if(this._focusable&&!ev._justFocusedWidget){ev._justFocusedWidget=this;if(this._focusable<2)this.focus();}if(ev.button==0){var da=this._dragArgs,el;if(da&&!DRAGGING){if(da.startOK(this,ev)){var obj=ev.getObject();if(obj)obj.applyHooks("onMouseLeave",[ev]);DRAGGING=true;da.source=this;da.captures={onMouseMove:dragMouseMove.$(this,da),onMouseUp:dragMouseUp.$(this,da),onMouseOver:dragMouseOver.$(this,da),onMouseOut:dragMouseOut.$(this,da),onMouseEnter:dragMouseEnter.$(this,da),onMouseLeave:dragMouseLeave.$(this,da),onContextMenu:dragContextMenu.$(this,da),onKeyPress:dragKeyPress.$(this,da)};da.startPos=ev.pos;da.startElPos=this.getPos();DlEvent.captureGlobals(da.captures);}}}};function onContextMenu(ev){var content=this.__contextMenu;if(typeof content=="function")content=content.call(this);if(content){var p=this._getContextMenuPopup();p.popup({timeout:0,content:content,anchor:content.contextMenuAnchor||this.getElement(),align:content.contextMenuAlign||"mouse",widget:this,onPopup:content.contextMenuOnPopup||null,onHide:content.contextMenuOnHide||null,isContext:true});DlException.stopEventBubbling();}};P.setData=function(key,val){if(arguments.length==1)delete this.__propsUserData[key];else this.__propsUserData[key]=val;};P.getData=function(key){return this.__propsUserData[key];};P._getDlPopup=function(){var p=this.getParent(DlPopup)||0;if(p)p=p._level+1;return DlPopupMenu.get(p);};P._getContextMenuPopup=P._getDlPopup;var LISTENERS={onDestroy:onDestroy,onMouseEnter:onMouseEnter,onMouseLeave:onMouseLeave,onMouseDown:onMouseDown,onContextMenu:onContextMenu};P._setListeners=function(){this.addEventListener(LISTENERS);this.addEventListener(is_ie?"onKeyDown":"onKeyPress",this._handle_focusKeys);};P._handle_focusKeys=function(ev){};P._check_accessKey=function(ev){return this._accessKey&&DlKeyboard.checkKey(ev,this._accessKey);};P._handle_accessKey=function(ev){this.focus();};P._setFocusedStyle=function(focused){this.condClass(focused,this._className.peek()+"-focus");};P.focus=function(){if(this._focusable){DlEvent.focusedWidget(this);this._setFocusedStyle(true);this.callHooks("onFocus");if(!(this instanceof DlEntry)){this.scrollIntoView();}}else if(this.parent){this.parent.focus();}};P.blur=function(){if(this._focusable){if(!this.destroyed){this._setFocusedStyle(false);this.callHooks("onBlur");}}};P.focusInside=function(){var fw=DlEvent.focusedWidget();while(fw){if(fw==this)break;fw=fw.parent;}return!!fw;};P._createElement=function(html){var el=this._element;if(!el){var C=this.constructor,cn=C.__joinedClassName||this._className.join(" ");if(!C.__joinedClassName)C.__joinedClassName=cn;if(this.__addClassName)cn+=" "+this.__addClassName;if(html){el=DOM.createFromHtml(html);el.className=cn;}else{el=CE(this._tagName,null,{className:cn});}if(this._focusable)el._dynarch_focusable=true;this._element=el;}el._dynarch_object=this;};P.getElement=function(){return this._element;};P.setStyle=function(a,b){var s=this.getElement().style;if(arguments.length>1){s[a]=b;}else{for(var i in a)this.setStyle(i,a[i]);}};P.getContentElement=function(){return this.getElement();};P.setContent=function(content){var el=this.getContentElement();while(el.firstChild)el.removeChild(el.lastChild);if(typeof content=="string"){el.innerHTML=content;}else if(content instanceof Function){return this.setContent(content.call(this));}else if(content instanceof D){this.appendWidget(content,this.__appendArgs);}else if(content instanceof Array){el.innerHTML=content.join("");}else if(content!=null){el.appendChild(content);}return content!=null;};P.ref=function(){return this.__refCnt++;};P.unref=function(){return--this.__refCnt;};P.refCnt=function(){return this.__refCnt;};P.setContextMenu=function(menu){if(this.__contextMenu instanceof D)this.__contextMenu.destroy();if(menu instanceof D)menu.ref();this.__contextMenu=menu;};P.setTooltip=function(tt){this.__tooltip=tt;};P.initDOM=function(){this.registerEvents(DEFAULT_EVENTS);this._setListeners();this._createElement();if(this._parent){this._parent.appendWidget(this,this.__appendArgs);this._parent=null;}if(this.__disabled)this.disabled(true,true);this.__onTooltipShow=this.__onTooltipShow.$(this);this.__onTooltipHide=this.__onTooltipHide.$(this);return this;};P.setUnselectable=function(el,val){if(el==null)el=this.getElement();DOM.setUnselectable(el,val);};P.disabled=function(v,force){if(v!=null&&(force||v!=this.__disabled)){this.__disabled=v;this.condClass(v,"DlWidget-disabled");this.condClass(v,this._className.peek()+"-disabled");this.applyHooks("onDisabled",[v]);}return this.__disabled;};P.enabled=function(v,force){if(v!=null){this.disabled(!v,force);}return!this.__disabled;};P.getParent=function(type,skipThis){if(type==null)return this.parent;var parent=this;if(skipThis)parent=this.parent;while(parent&&!(parent instanceof type))parent=parent.parent;return parent;};P.getPos=function(){return DOM.getPos(this.getElement());};P.getBRPos=function(){return DOM.getBRPos(this.getElement());};P.getOffsetPos=function(){var el=this.getElement();return{x:el.offsetLeft,y:el.offsetTop};};P.setPos=function(x,y){var el=this.getElement();if(typeof x=="object"){x=x.x;y=x.y;}if(x!=null)el.style.left=x+"px";if(y!=null)el.style.top=y+"px";};P.setSize=P.setOuterSize=function(size){DOM.setOuterSize(this.getElement(),size.x,size.y);this.callHooks("onResize");};P.setInnerSize=function(size){DOM.setInnerSize(this.getContentElement(),size.x,size.y);this.callHooks("onResize");};P.getSize=P.getOuterSize=function(){return DOM.getOuterSize(this.getElement());};P.getInnerSize=function(){return DOM.getInnerSize(this.getContentElement());};P.display=function(v){var s=this.getElement().style;if(v!=null){s.display=v?"":"none";this.applyHooks("onDisplay",[v,s.display,"display"]);return v;}return s.display!="none";};P.visibility=function(v){var s=this.getElement().style;if(v!=null){s.visibility=v?"":"hidden";this.applyHooks("onDisplay",[v,s.visibility,"visibility"]);return v;}return s.visible!="hidden";};P.opacity=function(o){return DOM.setOpacity(this.getElement(),o);};P.position=function(p){var s=this.getElement().style,o=s.position;if(p!=null){s.position=p;}return o;};P.setIconClass=function(iconClass){var e2=this.getContentElement();CC(e2,iconClass!=null,this.__withIconClass||this._className.peek()+"-withIcon");if(this.iconClass)DC(e2,this.iconClass);if(iconClass)AC(e2,iconClass);this.iconClass=iconClass;};P.addClass=function(ac,dc){AC(this.getElement(),ac,dc);};P.delClass=function(dc,ac){DC(this.getElement(),dc,ac);};P.condClass=function(cond,clsTrue,clsFalse){CC(this.getElement(),cond,clsTrue,clsFalse);};P.zIndex=function(zIndex){var el=this.getElement();if(zIndex!=null){el.style.zIndex=zIndex;return zIndex;}if(el.style.zIndex)return parseInt(el.style.zIndex,10);return 0;};P.refNode=function(name,el){this[name]=el;this.__refNodes.remove(name);if(el!=null)this.__refNodes.push(name);};P.debug_highlight=function(color){this.getElement().style.backgroundColor=color||"yellow";};P.getQuickPopup=function(){var p=this.getParent(DlPopup)||0;if(p)p=p._level+1;return DlDialogPopup.get(p);};P.quickPopup=function(args){var p=this.getQuickPopup();args=Dynarch.makeCopy(args);Dynarch.mergeUndefined(args,{anchor:this.getElement(),align:{prefer:"CC"}});p.popup(args);};P.getScroll=function(){var el=this.getElement();return{x:el.scrollLeft,y:el.scrollTop};};P.scrollIntoView=function(){DOM.scrollIntoView(this.getElement());};P.flash=function(timeout,steps){if(!steps)steps=3;var el=this.getElement();var timer=setInterval(function(){el.style.visibility=(steps&1)?"hidden":"";--steps;if(steps<0)clearInterval(timer);},timeout||150);};DlEvent.atUnload(function(){do{var destroying=false;for(var i in WIDGETS){destroying=true;var w=WIDGETS[i];try{WIDGETS[i]=null;delete WIDGETS[i];}catch(ex){};try{w.destroy();}catch(ex){};break;}}while(destroying);WIDGETS=null;});})();(function(){var BASE=DlContainer.inherits(DlWidget);function DlContainer(args){if(args){DlContainer.setDefaults(this,args);this._widgets=[];DlWidget.call(this,args);}};eval(Dynarch.EXPORT("DlContainer"));D.DEFAULT_ARGS={_scrollBars:["scroll",false]};P._createElement=function(){BASE._createElement.call(this);if(this._scrollBars)this.setStyle("overflow","auto");};P.appendWidget=function(w){if(w.parent)w.parent.removeWidget(w);this._widgets.push(w);w.parent=this;this._appendWidgetElement.apply(this,arguments);};P._appendWidgetElement=function(w,p){var el=w.getElement();if(typeof p=="number"){var parent=this.getContentElement();try{p=parent.childNodes[p];parent.insertBefore(el,p);}catch(ex){parent.appendChild(el);}}else{if(p==null)p=this.getContentElement();else if(typeof p=="string")p=document.getElementById(p);if(el.parentNode!==p)p.appendChild(el);}};P.removeWidget=function(w){if(w.parent===this){this._removeWidgetElement(w);this._widgets.remove(w);w.parent=null;}};P._removeWidgetElement=function(w){if(this._widgets.contains(w)){var el=w.getElement();if(el.parentNode)el.parentNode.removeChild(el);}};P.destroyChildWidgets=function(){var a=Array.$(this._widgets);a.r_foreach(function(w){try{w.destroy();}catch(ex){};});var el=this.getContentElement();if(el)el.innerHTML="";return el;};P._setListeners=function(){BASE._setListeners.call(this);this.addEventListener("onDestroy",this.destroyChildWidgets);this.addEventListener("onResize",this.__doLayout);};P.disabled=function(v,force){var isDisabled=BASE.disabled.call(this,v,force);if(v!=null)this._widgets.r_foreach(function(w){w.disabled(v,force);});return isDisabled;};P.children=function(idx){return idx!=null?this._widgets[idx]:this._widgets;};P.__doLayout=function(){var w=this.children().grep_first(function(w){return w._fillParent;});if(w)w.setSize(this.getInnerSize());};function getAllFocusableWidgets(sub,all){sub=sub?Array.$(sub.getElement().getElementsByTagName("*")):[];return Array.$(this.getElement().getElementsByTagName("*")).grep(all?"_dynarch_object":"_dynarch_focusable").grep(DynarchDomUtils.elementIsVisible).grep(sub.contains.$(sub).inverse()).map(DlWidget.getFromElement).grep("enabled").mergeSort(function(a,b){return a._tabIndex-b._tabIndex;});};function getFocusableWidget(w,d){var a=getAllFocusableWidgets.call(this,w);var i=a.find(w);i=a.rotateIndex(i+d);if(i!=null)return a[i];};P.getNextFocusWidget=function(w){return getFocusableWidget.call(this,w,1);};P.getPrevFocusWidget=function(w){return getFocusableWidget.call(this,w,-1);};P.getFirstFocusWidget=function(){return this.getNextFocusWidget(null);};P.getLastFocusWidget=function(){return this.getPrevFocusWidget(null);};P._handleKeybinding=function(ev,w){if(ev.altKey||ev.ctrlKey){var a=getAllFocusableWidgets.call(this,w,true);a.foreach(function(w){if(w._check_accessKey(ev)){w._handle_accessKey(ev);ev.domStop=true;DlExStopEventBubbling();}});if(this.parent)this.parent._handleKeybinding(ev,this);}};var HIDDEN;D.getHiddenContainer=function(){if(!HIDDEN){HIDDEN=new this({className:"DlContainer-Hidden"});document.body.appendChild(HIDDEN.getElement());}return HIDDEN;};})();(function(){var BASE=DlRadioGroup.inherits(DlEventProxy);function DlRadioGroup(id){if(id!=null){DlEventProxy.call(this);this._maxChecked=1;this._minChecked=null;this.id=id;this.registerEvents(DEFAULT_EVENTS);this.reset();this.addEventListener("onDestroy",onDestroy);}};var GROUPS={};eval(Dynarch.EXPORT("DlRadioGroup"));var DEFAULT_EVENTS=["onChange"];D.getById=D.get=function(id){if(!id)id=Dynarch.ID("group");var g=GROUPS[id];if(!g)g=GROUPS[id]=new this(id);return g;};function onDestroy(){if(GROUPS[this.id]){this._buttons=null;this._buttonsById=null;this._buttonsByValue=null;this._history=null;delete GROUPS[this.id];}};function onChange(w){if(w!=null){this._changed=true;if(w.checked()){if(this._maxChecked!=null){while(this._history.length>=this._maxChecked){var o=this._history[0];o.checked(false,true);this._history.splice(0,1);}}this._history.push(w);}else if(this._minChecked!=null&&this._history.length<=this._minChecked){w.checked(true,true);}else this._history.remove(w);}};P.reset=function(){if(this._buttons)this._buttons.r_foreach(function(b){b.__group=b.__groupId=null;});this._changed=false;this._buttons=[];this._buttonsById={};this._buttonsByValue={};this._history=[];this.removeAllListeners("onChange");this.addEventListener("onChange",onChange);};P.changed=function(c){var r=this._changed;if(c!=null)this._changed=c;return r;};P.getSelected=function(){return this._history;};P.getButtons=function(){return this._buttons;};P.getNextButton=function(btn){if(btn==null)btn=this.getSelected()[0];var a=this._buttons,idx=a.nullLimitIndex(a.find(btn)+1);if(idx!=null)return a[idx];};P.getPrevButton=function(btn){if(btn==null)btn=this.getSelected()[0];var a=this._buttons,idx=a.nullLimitIndex(a.find(btn)-1);if(idx!=null)return a[idx];};P.getValue=function(){return this._history.map("value");};P.setValue=function(val,hooks){var h=this._buttonsByValue;if(!(val instanceof Array))val=[val];val=val.toHash(true);this._history=[];for(var i in h){h[i].checked(val[i],true);if(val[i])this._history.push(h[i]);}if(hooks)this.callHooks("onChange");};P.getByValue=function(val){return this._buttonsByValue[val];};P.addWidget=function(w,pos){if(!this._buttonsById[w.id]){if(pos==null)pos=this._buttons.length;this._buttonsById[w.id]=w;this._buttons.splice(pos,0,w);if(w.checked())this._history.push(w);var val=w.value();if(typeof val!="undefined")this._buttonsByValue[val]=w;w.addEventListener("onDestroy",this.removeWidget.$(this,w));}};P.removeWidget=function(w){if(this._buttonsById[w.id]){this._changed=true;delete this._buttonsById[w.id];var val=w.value();if(typeof val!="undefined")delete this._buttonsByValue[w.value()];this._buttons.remove(w);this._history.remove(w);}};P.minChecked=function(minChecked){if(arguments.length>0)this._minChecked=minChecked;return this._minChecked;};P.maxChecked=function(maxChecked){if(arguments.length>0)this._maxChecked=maxChecked;return this._maxChecked;};P.checkAll=function(val){if(val==null)val=true;this._buttons.foreach(function(w){w.checked(val,true);});this._history=val?Array.$(this._buttons):[];};P.unCheckAll=function(){this._history.r_foreach(function(w){w.checked(false);});};})();(function(){var DEFAULT_LISTENERS=["onMouseEnter","onMouseLeave","onMouseDown","onMouseUp","onUpdateLabel","onClick","onCheck","onChange","onDisabled"];var BASE=DlAbstractButton.inherits(DlWidget);function DlAbstractButton(args){if(args){D.setDefaults(this,args);DlWidget.call(this,args);var gid=this.__groupId;if(gid!=null){var g;if(typeof gid=="object"){g=gid;this.__groupId=g.id;}else g=DlRadioGroup.get(gid);this.__group=g;g.addWidget(this,typeof args.appendArgs=="number"?args.appendArgs:null);}if(!this._noCapture){this._btnpressCapture={onMouseMove:DlException.stopEventBubbling,onMouseUp:this._cap_onMouseUp.$(this),onMouseOver:DlException.stopEventBubbling,onMouseOut:DlException.stopEventBubbling,onMouseEnter:this._cap_onMouseEnter.$(this),onMouseLeave:this._cap_onMouseLeave.$(this)};}}};eval(Dynarch.EXPORT("DlAbstractButton",true));var DEFAULT_EVENTS=["onCheck","onUncheck","onChange","onUpdateLabel"];var TYPE={STANDARD:1,TWOSTATE:2};D.DEFAULT_ARGS={_label:["label",""],_classes:["classes",{}],_checked:["checked",false],__groupId:["group",null],_btnType:["type",TYPE.STANDARD],_value:["value",window.undefined],_noCapture:["noCapture",false],_alwaysCheck:["alwaysCheck",false]};P._cap_onMouseUp=function(ev){var obj=ev.getObject();DlEvent.releaseGlobals(this._btnpressCapture);this.applyHooks("onMouseUp",[ev]);if(!this._ev_mouseInside)this.applyHooks("onMouseLeave",[ev]);if(obj!==this){obj&&obj.applyHooks("onMouseEnter",[ev]);DlException.stopEventBubbling();}};P._cap_onMouseEnter=function(ev){var obj=ev.getObject();if(obj===this)this.addClass(this._classes.active);obj&&(obj._ev_mouseInside=true);DlException.stopEventBubbling();};P._cap_onMouseLeave=function(ev){var obj=ev.getObject();if(obj===this)this.delClass(this._classes.active);obj&&(obj._ev_mouseInside=false);DlException.stopEventBubbling();};D.TYPE=TYPE;P._onMouseEnter=function(ev){this.addClass(this._classes.hover);};P._onMouseLeave=function(ev){this.delClass(this._classes.hover);this.delClass(this._classes.active);};P._onMouseDown=function(ev){if(ev.button===0){this._ev_mouseInside=true;this.addClass(this._classes.hover);this.addClass(this._classes.active);if(!this._noCapture){DlEvent.captureGlobals(this._btnpressCapture);ev.domStop=true;}}};P._onMouseUp=function(ev){this.delClass(this._classes.active);};P._onUpdateLabel=function(){var el=this.getElement();CC(el,!/\S/.test(this._label),this._classes.empty);};P._onClick=function(){if(this._btnType==TYPE.TWOSTATE){this._alwaysCheck?this.checked(true):this.toggle();}};P.keyClicked=function(ev){this.addClass(this._classes.active);(function(){this.delClass(this._classes.hover);this.delClass(this._classes.active);this.applyHooks("onClick",[ev]);}).delayed(90,this);if(ev){ev.domStop=true;DlException.stopEventBubbling();}};P._handle_focusKeys=function(ev){var k=ev.keyCode;if(k==DlKeyboard.ENTER||ev.charCode==DlKeyboard.SPACE){this.keyClicked(ev);}else if(!this._customMoveKeys&&this.__group&&k in DlKeyboard.KEYS_MOVE){var prev=k in DlKeyboard.KEYS_MOVE_PREV,w=prev?this.__group.getPrevButton(this):this.__group.getNextButton(this);if(w){w.focus();if(ev.shiftKey){this.checked(true);w.checked(true);}ev.domStop=true;DlException.stopEventBubbling();}}BASE._handle_focusKeys.call(this,ev);};P._handle_accessKey=function(ev){this.focus();this.keyClicked(ev);};P.disabled=function(v,force){if(v!=null&&v){DC(this.getElement(),this._classes.hover);DC(this.getElement(),this._classes.active);}return BASE.disabled.call(this,v,force);};P._onChange=function(){if(this.__group!=null)this.__group.applyHooks("onChange",[this]);};P._onCheck=Dynarch.noop;P._onDisabled=function(v){CC(this.getElement(),v,this._classes.disabled);if(v&&this._capture){DlEvent.releaseCapture(this._capture);this._capture=null;}};P.initDOM=function(){this.registerEvents(DEFAULT_EVENTS);BASE.initDOM.call(this);this.setUnselectable();};P._createElement=function(){BASE._createElement.call(this);this._createLabelElement();this.label(this._label,true);this._updateState();};P._setListeners=function(){BASE._setListeners.call(this);DEFAULT_LISTENERS.r_foreach(function(ev){this.addEventListener(ev,this["_"+ev]);},this);};P._createLabelElement=Dynarch.noop;P.label=function(label,force){if(label!=null&&(force||label!==this._label)){this._label=label;if(label)label="<div class='DlButton-Label'>"+this._label+"</div>";this.setContent(label);this.applyHooks("onUpdateLabel",[this._label]);}return this._label;};P.setLabel=P.label;P.getLabel=P.label;P.group=function(){return this.__group;};P._checkTwoState=function(nothrow){var cond=this._btnType!=TYPE.TWOSTATE;if(cond&&!nothrow)throw new DlExInvalidOperation("This operation is only available for a TWOSTATE button");return!cond;};P._updateState=function(){if(this._checkTwoState(true)){var c=this._classes;CC(this.getElement(),this._checked,c.checked,c.unchecked);}};P.checked=function(checked,nohooks){this._checkTwoState();if(arguments.length>0){checked=!!checked;var diff=!nohooks&&(this._checked!==checked);this._checked=checked;this._updateState();if(diff){this.callHooks("onChange");this.callHooks(checked?"onCheck":"onUncheck");}}return this._checked;};P.toggle=function(nohooks){this._checkTwoState();this.checked(!this._checked,nohooks);};P.value=function(newval){var oldval=this._value;if(arguments.length>0)this._value=newval;return oldval;};P.setValue=P.value;P.getValue=P.value;})();(function(){DlAnimation.inherits(DlEventProxy);function DlAnimation(length,fps){DlEventProxy.call(this);this.registerEvents(DEFAULT_EVENTS);this.addEventListener("onDestroy",this.stop.$(this));if(length!=null)this.length=length;if(fps!=null)this._speed=1000/fps;this._update=update.$(this);};eval(Dynarch.EXPORT("DlAnimation"));var DEFAULT_EVENTS=["onStart","onStop","onPause","onUpdate"];P.start=function(length,fps,func){this.stop();if(length!=null)this.length=length;if(fps!=null)this._speed=1000/fps;if(func!=null){if(!(func instanceof Function))func=DlAnimation.easing[func];this.func=func;}this.t=0;this.i=0;this.callHooks("onStart");this._timer=setInterval(this._update,this._speed);};P.stop=function(finished){if(this._timer){clearInterval(this._timer);this._timer=null;this.applyHooks("onStop",[finished]);}};P.getPos=function(f){if(f==null)f=this.func;return f.call(this,this.t);};function update(){this.t=this.i/this.length;try{this.applyHooks("onUpdate",[this.t]);if(++this.i>this.length)this.stop(true);}catch(ex){this.stop();throw ex;}};var PI=Math.PI,abs=Math.abs,asin=Math.asin,pow=Math.pow,sin=Math.sin,cos=Math.cos,exp=Math.exp,round=Math.round;var E=D.easing={elastic_b:function(t){return 1-cos(-t*5.5*PI)/pow(2,7*t);},elastic_b_custom:function(elasticity,stability,t){elasticity+=0.5;return 1-cos(-t*elasticity*PI)/pow(2,stability*t);},magnetic:function(t){return 1-cos(t*t*t*10.5*PI)/exp(4*t);},accel_b:function(t){t=1-t;return 1-t*t*t;},accel_ab:function(t){t=1-t;return 1-sin(t*t*t*PI/2);},bounce_b:function(t){return t<1/2.75?7.5625*t*t:(t<2/2.75?(7.5625*(t-=1.5/2.75)*t+.75):(t<2.5/2.75?(7.5625*(t-=2.25/2.75)*t+.9375):(7.5625*(t-=2.625/2.75)*t+.984375)));},shake:function(t){return t<0.5?-cos(t*11*PI)*t*t:(t=1-t,cos(t*11*PI)*t*t);}};})();(function(){var BASE=DlBox.inherits(DlContainer);function DlBox(args){if(args){DlBox.setDefaults(this,args);args.tagName="table";DlContainer.call(this,args);}};eval(Dynarch.EXPORT("DlBox",true));D.DEFAULT_ARGS={_borderSpacing:["borderSpacing",0],_align:["align",null]};P._createElement=function(){BASE._createElement.call(this);var table=this.getElement();table.cellSpacing=this._borderSpacing;table.cellPadding=0;if(this._align)table.align=this._align;this.refNode("_tbody",CE("tbody",null,null,table));};P.getTableElement=P.getElement;P._appendWidgetElement=function(widget,where){if(where==null)this.createCellElement().appendChild(widget.getElement());else where.appendChild(widget.getElement());};P.destroyChildWidgets=function(){var a=Array.$(this._widgets);a.r_foreach(function(w){try{w.destroy();}catch(ex){};});};P.__addSep=function(sep_cls,cls,td){if(!td)td=this.createCellElement();td.separator=true;var cn=this._objectType+"-"+sep_cls;if(cls)cn+=" "+cls;td.className=cn;td.innerHTML="<div class='"+cn+"'>&nbsp;</div>";DOM.setUnselectable(td);return td;};P.addSeparator=function(cls,td){return this.__addSep("separator",cls,td);};P.addSpace=function(cls,td){return this.__addSep("spacer",cls,td);};})();(function(){var BASE=DlButton.inherits(DlAbstractButton);function DlButton(args){if(args){D.setDefaults(this,args);DlAbstractButton.call(this,args);this.setIconClass(this._iconClass);this._iconClass=null;}};eval(Dynarch.EXPORT("DlButton",true));D.TYPE=DlAbstractButton.TYPE;D.DEFAULT_ARGS={_classes:["classes",{active:"DlButton-active",hover:"DlButton-hover",checked:"DlButton-1",unchecked:"DlButton-0",empty:"DlButton-empty",disabled:"DlButton-disabled"}],_iconClass:["iconClass",null]};P._createElement=function(){BASE._createElement.call(this);this.addClass("DlWidget-3D");};P._createLabelElement=function(){this.getElement().innerHTML="<div class='DlButton-inner'><div></div></div>";};P.getContentElement=function(){return this.getElement().firstChild.firstChild;};P.setSize=P.setOuterSize=function(size){var d1=DOM.getPaddingAndBorder(this.getElement());if(size.x!=null)size.x-=d1.x;if(size.y!=null)size.y-=d1.y;d1=DOM.getPaddingAndBorder(this.getElement().firstChild);if(size.x!=null)size.x-=d1.x;if(size.y!=null)size.y-=d1.y;DOM.setOuterSize(this.getContentElement(),size.x,size.y);};})();(function(){DlHbox.inherits(DlBox);function DlHbox(args){if(args)DlBox.call(this,args);};eval(Dynarch.EXPORT("DlHbox",true));P._createElement=function(){D.BASE._createElement.call(this);this.refNode("_row",CE("tr",null,null,this._tbody));};P.createCellElement=function(pos){var td=CE("td",null,{className:"cell"});pos!=null?this._row.insertBefore(td,pos):this._row.appendChild(td);return td;};P._removeWidgetElement=function(w){if(this._widgets.contains(w)){var el=w.getElement();el.parentNode.parentNode.removeChild(el.parentNode);}};P.addFiller=function(){var td=this.createCellElement();td.className+=" DlHbox-filler";this.addClass("DlHbox-hasFiller");};P.setAlign=function(left,right){var el=this.getElement();switch(left){case "left":el.style.marginLeft="0";el.style.marginRight="auto";break;case "center":el.style.marginLeft="auto";el.style.marginRight="auto";break;case "right":el.style.marginLeft="auto";el.style.marginRight="0";break;default:el.style.marginLeft=left!=null?left:"auto";el.style.marginRight=right!=null?right:"auto";}};P.setEqualWidths=function(d){var width=this.children().max(function(w){return w.getSize().x;});if(d)width+=d;this.children().r_foreach(function(w){w.setSize({x:width});});};})();function DlPoint(x,y){if(typeof x=="object"){this.x=x.x;this.y=x.y;}else{this.x=x;this.y=y;}};DlPoint.prototype={clone:function(){return new DlPoint(this.x,this.y);},normalize:function(p){var tmp;if(this.x>p.x){tmp=this.x;this.x=p.x;p.x=tmp;}if(this.y>p.y){tmp=this.y;this.y=p.y;p.y=tmp;}return this;},distanceTo:function(p){var a=Math.abs(p.x-this.x),b=Math.abs(p.y-this.y);return Math.sqrt(a*a+b*b);}};function DlRect(x,y,w,h){if(x instanceof DlRect){this.setFromRect(x);}else if(typeof x=="object"){if(typeof y=="object"){if(y instanceof DlPoint){this.setFromPoints(x,y);}else{this.setFromValues(x.x,x.y,y.x,y.y);}}else{this.setFromValues(x.x,x.y,w,h);}}else{this.setFromValues(x,y,w,h);}};DlRect.prototype={setFromRect:function(r){this.x=r.x;this.y=r.y;this.w=r.w;this.h=r.h;return this;},setFromPoints:function(p1,p2){p1=p1.clone().normalize(p2=p2.clone());this.x=p1.x;this.y=p1.y;this.w=p2.x-p1.x+1;this.h=p2.y-p1.y+1;return this;},setFromValues:function(x,y,w,h){this.x=x;this.y=y;this.w=w;this.h=h;return this;},getTL:function(){return new DlPoint(this.x,this.y);},getBR:function(){return new DlPoint(this.x+this.w-1,this.y+this.h-1);},getPoints:function(){return[getTL(),getBR()];},height:function(h){if(h!=null)this.h=h;return this.h;},width:function(w){if(w!=null)this.w=w;return this.w;},containsPoint:function(p){return this.x<=p.x&&this.x+this.w>p.x&&this.y<=p.y&&this.y+this.h>p.y;},intersect:function(r){var ret=null,M=Math,dx=M.max(this.x,r.x),dy=M.max(this.y,r.y),dw=M.min(this.x+this.w,r.x+r.w)-dx,dh=M.min(this.y+this.h,r.y+r.h)-dy;if(dw>0&&dh>0)ret=new DlRect(dx,dy,dw,dh);return ret;},area:function(){return this.w*this.h;},makeDiv:function(bw,bc){bc||(bc="#000");bw==null&&(bw=0);var s={position:"absolute",left:this.x+"px",top:this.y+"px",width:this.w-bw*2+"px",height:this.h-bw*2+"px",overflow:"hidden",lineHeight:"1px",fontSize:"1px",border:bw+"px solid "+bc};s=DynarchDomUtils.createElement("div",s,{innerHTML:"&nbsp;"});return s;},positionDiv:function(div){div.style.left=this.x+"px";div.style.top=this.y+"px";div.style.height=this.h+"px";div.style.width=this.w+"px";},toString:function(){return this.w+"x"+this.h+"@"+this.x+","+this.y;}};(function(){var POPUPS={};var ALL_POPUPS={};var POPUPS_BY_ID={};var RE_REMOVE_SCROLL=/DlPopup-scroll(Up|Down)?-hover/g;var BASE=DlPopup.inherits(DlContainer);function DlPopup(args){if(args){D.setDefaults(this,args);this._hasScrolling=false;DlContainer.call(this,args);this.visible=false;}};eval(Dynarch.EXPORT("DlPopup",true));var DEFAULT_EVENTS=["onPopup","onHide"];D.DEFAULT_ARGS={_level:["level",0],_autolink:["autolink",true],_oscroll:["scroll",{step1:5,step2:10,speed:40}],_align:["align",null],_zIndex:["zIndex",1000],_focusable:["focusable",true],_shadows:["shadows",true]};D.get=function(level,nocreate){var type=this.prototype._objectType;var shouldAttach=false;var max=POPUPS[type].length;if(level==null||level>=max){level=max;shouldAttach=true;}var pt=ALL_POPUPS[type];if(!ALL_POPUPS[type])pt=ALL_POPUPS[type]={};var ret=pt[level];if(!ret){if(!nocreate)ret=pt[level]=new this({level:level});else ret=null;}ret.detachPopup();if(shouldAttach&&level>0)ret.attachToPopup(POPUPS[type].peek());return ret;};D.clearAll=function(lev){var a=POPUPS[this.prototype._objectType];a=a[lev||0];if(a)a.hide();};D.clearAllPopups=function(except){for(var i in POPUPS_BY_ID){if(!except||!except[i])POPUPS_BY_ID[i].hide();}};P.__patchSubclassPrototype=function(){BASE.__patchSubclassPrototype.call(this);this.constructor.get=D.get;this.constructor.clearAll=D.clearAll;POPUPS[this._objectType]=[];ALL_POPUPS[this._objectType]={};};P.initDOM=function(){this.registerEvents(DEFAULT_EVENTS);BASE.initDOM.call(this);};P._createElement=function(){var parent=this._parent;this._parent=null;BASE._createElement.call(this);var div=this.getElement();this.parent=parent;this.display(false);document.body.appendChild(div);if(this._shadows&&!is_ie6){div.appendChild(DlElementCache.get("SHADOWS"));AC(div,typeof this._shadows=="string"?this._shadows:"ThinShadows");}else{this._shadows=false;AC(div,this._objectType+"-noShadow");}if(is_gecko)div=CE("div",null,{className:"Gecko-Bug-302380"},div);this.refNode("_contentEl",CE("div",null,{className:"DlPopup-scrollArea"},div));this.zIndex(this._zIndex);};P.getContentElement=function(){return this._contentEl;};P.getScrollDiv=P.getContentElement;P._scrollSetArrowState=function(){var div=this.getScrollDiv(),s1=this._scroll_el(0),s2=this._scroll_el(1),at_start=div.scrollTop==0,at_end=div.scrollTop+div.offsetHeight==div.scrollHeight;if(at_start||at_end)this._scrollStopHandler();CC(s1,at_start,"DlPopup-scrollUp-disabled");CC(s2,at_end,"DlPopup-scrollDown-disabled");};function _scrollHandler(dir){this.getScrollDiv().scrollTop+=this._scrollStep*dir;this._scrollSetArrowState();};function _scrollStartHandler(self,dir){self._scrollStep=self._oscroll.step1;self._scrollTimer=setInterval(_scrollHandler.$(self,dir),self._oscroll.speed);AC(this,"DlPopup-scroll-hover");CC(this,dir>0,"DlPopup-scrollDown-hover","DlPopup-scrollUp-hover");};P._scrollStopHandler=function(){if(this._scrollTimer){clearInterval(this._scrollTimer);this._scrollTimer=null;this._scrollSetArrowState();}DC(this._scroll_el(0),RE_REMOVE_SCROLL);DC(this._scroll_el(1),RE_REMOVE_SCROLL);};P._scrollDoubleSpeed=function(dbl){this._scrollStep=this._oscroll[dbl?"step2":"step1"];return false;};P._scroll_setup=function(){if(!this._hasScrolling){this._hasScrolling=true;var e=this.getElement(),s1=CE("div",null,{className:"DlPopup-scrollUp"},e,0),s2=CE("div",null,{className:"DlPopup-scrollDown"},e);s1.onmouseover=_scrollStartHandler.$(null,this,-1);s2.onmouseover=_scrollStartHandler.$(null,this,1);s1.onmouseout=s2.onmouseout=this._scrollStopHandler.$(this);s1.onmousedown=s2.onmousedown=this._scrollDoubleSpeed.$(this,true);s1.onmouseup=s2.onmouseup=this._scrollDoubleSpeed.$(this,false);this.refNode("_scrollEl0",s1);this.refNode("_scrollEl1",s2);this.getScrollDiv().onscroll=this._scrollSetArrowState.$(this);}this._scroll_visibile(true);};P._scroll_el=function(p){return this["_scrollEl"+p];};P._scroll_visibile=function(vis){if(this._hasScrolling){if(is_gecko)this.getScrollDiv().parentNode.style.overflow=vis?"auto":"";vis=vis?"":"none";this._scroll_el(0).style.display=vis;this._scroll_el(1).style.display=vis;this.args.scrollVisible=!vis;}};function onPopup(){POPUPS[this._objectType][this._level]=this;if(!this._autolink||this._level==0)POPUPS_BY_ID[this.id]=this;};function onHide(){var a=POPUPS[this._objectType];var child=a[this._level+1];if(child)child.hide();a.splice(this._level,1);if(POPUPS_BY_ID[this.id])delete POPUPS_BY_ID[this.id];};function onMouseWheel(ev){if(this.args.scrollVisible){var div=this.getScrollDiv(),st=div.scrollTop;if(ev.wheelDelta<0){st+=20;}else{st-=20;if(st<0)st=0;}div.scrollTop=st;ev.domStop=true;DlException.stopEventBubbling();}};var have_doc_listener=false;function global_onMouseDown(ev){var obj=ev.getObject();var except={};while(obj&&!(obj instanceof D)){if(obj.currentPopup)except[obj.currentPopup.id]=true;obj=obj.parent;}if(obj){while(obj!=null){except[obj.id]=true;obj=obj._parentPopup;}}D.clearAllPopups(except);};P._setListeners=function(){BASE._setListeners.call(this);this.addEventListener({onPopup:onPopup,onMouseWheel:onMouseWheel,onHide:onHide});if(!have_doc_listener){have_doc_listener=true;DlEvent.captureGlobal("onMouseDown",global_onMouseDown);}};function _do_popup(args){if(args.onBeforePopup)args.onBeforePopup.call(this,args);this._timer=null;if(!this.setContent(args.content))return;if(args.onPopup)args.onPopup.call(this,args);this.applyHooks("onPopup",[args]);this.showAt(args.anchor,args.align||this._align,args.pos,args.shift,args.fluid);this._prevFocus=DlEvent.focusedWidget();this.focus();};P.popup=function(args){this.args=args;this.cancel();if(!args.timeout)_do_popup.call(this,args);else this._timer=_do_popup.$(this,args).delayed(args.timeout);};function _do_hide(){if(this.visible){if(this.args&&this.args.onHide)this.args.onHide.call(this,this.args);if(this._focusable&&this._prevFocus)try{this._prevFocus.focus();}catch(ex){}this.args=null;this._timer=null;this.callHooks("onHide");this.display(false);this.visible=false;}};P.hide=function(timeout){this.cancel();if(!timeout)_do_hide.call(this);else this._timer=_do_hide.$(this).delayed(timeout);};P.cancel=function(){if(this._timer){clearTimeout(this._timer);this._timer=null;}};P.correctPos=Dynarch.noop;P.showAt=function(anchor,align,mousePos,shift,fluid){var origpos,p,sa,div=this.getScrollDiv();if(!align)align=this._align;if(align=="mouse"){if(mousePos==null)mousePos=Dynarch.makeCopy(DlEvent.latestMouseEvent.pos);origpos=mousePos;if(this._mouseDiff){origpos.x+=this._mouseDiff.x;origpos.y+=this._mouseDiff.y;}align={prefer:"__",fallX1:"_R",fallX2:"_L",fallY1:"B_",fallY2:"T_"};}else{origpos=DOM.getPos(anchor);if(shift){if(shift.x)origpos.x+=shift.x;if(shift.y)origpos.y+=shift.y;}}sa=DOM.getOuterSize(anchor);p=Dynarch.makeCopy(origpos);this.visibility(false);div.style.height="";this._scroll_visibile(false);this.setPos(-30000,-30000);this.display(true);if(is_ie)this.getElement().style.width="";var r=this._bestPosition(align,p,sa),h=r.height();var sph=this.getScrollDiv().offsetHeight;var fuzz=this.getElement().offsetHeight-sph;p=r.getTL();if(h<sph){if(fluid){this.children(0).setSize({y:h});}else{if(is_ie)this.getElement().style.width=div.offsetWidth+"px";this._scroll_setup();var h1=this._scroll_el(0).offsetHeight,h2=this._scroll_el(1).offsetHeight;div.style.height=h-h1-h2-fuzz+"px";this._scrollSetArrowState();div.scrollTop=0;}}this.correctPos(p);this.setPos(p.x,p.y);if(this._parentPopup){var ZI=this._parentPopup.zIndex()+1;this.zIndex(ZI);}this.visibility(true);this.visible=true;};P._bestPosition=function(align,p,sa){var tmp,r1,r2,ws=DOM.getWindowSize(),r=new DlRect(0,0,ws.x,ws.y),sp=this.getSize(),p1=new DlPoint(p);this._doAlign(align.prefer,p1,sa);r1=new DlRect(p1,sp).intersect(r);tmp=this.checkXPos(p1,r);if(tmp!=0){p1.x=p.x;this._doAlign(tmp<0?align.fallX1:align.fallX2,p1,sa);r2=new DlRect(p1,sp).intersect(r);if(r1.area()>r2.area())p1=r1.getTL();this.args.fallX=true;}r1=new DlRect(p1,sp).intersect(r);tmp=this.checkYPos(p1,r);if(tmp!=0){p1.y=p.y;this._doAlign(tmp<0?align.fallY1:align.fallY2,p1,sa);r2=new DlRect(p1,sp).intersect(r);if(r1.area()>r2.area())p1=r1.getTL();this.args.fallY=true;}return new DlRect(p1,sp).intersect(r);};P._doAlign=function(align,p,sa){var sp=this.getSize(),valign=align.substr(0,1),halign="";if(align.length>1)halign=align.substr(1,1);switch(valign){case "T":p.y-=sp.y;if(this._mouseDiff&&this.args.align=="mouse")p.y-=2*this._mouseDiff.y;break;case "B":p.y+=sa.y;if(this._mouseDiff&&this.args.align=="mouse")p.y+=2*this._mouseDiff.y;break;case "C":case "c":p.y+=(sa.y-sp.y)/2;break;case "t":p.y+=sa.y-sp.y;break;case "b":break;}switch(halign){case "L":p.x-=sp.x;if(this._mouseDiff&&this.args.align=="mouse")p.x-=2*this._mouseDiff.x;break;case "R":p.x+=sa.x;if(this._mouseDiff&&this.args.align=="mouse")p.x+=2*this._mouseDiff.x;break;case "C":case "c":p.x+=(sa.x-sp.x)/2;break;case "l":p.x+=sa.x-sp.x;break;case "r":break;}};P.checkXPos=function(p,rect){if(p.x<rect.x)return p.x-rect.x;var s=this.getSize();var d=p.x+s.x-rect.x-rect.w;return d>0?d:0;};P.checkYPos=function(p,rect){if(p.y<rect.y)return p.y-rect.y;var s=this.getSize();var d=p.y+s.y-rect.y-rect.h;return d>0?d:0;};P.attachToPopup=function(popup){this._parentPopup=popup;popup._childPopup=this;};P.detachPopup=function(){if(this._parentPopup)this._parentPopup._childPopup=null;this._parentPopup=null;};P.getToplevelPopup=function(){var p=this;while(p._parentPopup)p=p._parentPopup;return p;};P._handle_focusKeys=function(ev){if(!ev.altKey&&!ev.ctrlKey){if(ev.keyCode==DlKeyboard.ESCAPE){this.hide();}else if(ev.keyCode==DlKeyboard.TAB){var w=ev.focusedWidget;w=ev.shiftKey?this.getPrevFocusWidget(w):this.getNextFocusWidget(w);if(w)w.focus();ev.domStop=true;DlException.stopEventBubbling();}}this._handleKeybinding(ev);};})();(function(){DlVbox.inherits(DlBox);function DlVbox(args){if(args)DlBox.call(this,args);};eval(Dynarch.EXPORT("DlVbox",true));P.createCellElement=function(){return CE("td",null,{className:"cell"},CE("tr",null,{className:"row"},this._tbody));};P._removeWidgetElement=function(w){if(this._widgets.contains(w)){var el=w.getElement();el.parentNode.parentNode.parentNode.removeChild(el.parentNode.parentNode);}};})();function DlMenuBase(){if(this._isMenuBase)return;this._isMenuBase=true;this._items=[];var self=this;function onNamedItemSelect(name,item,args){var widget=args?args.widget:null;if(!this._noClose)DlPopupMenu.clearAll();self.applyHooks.delayed(1,self,"onSelect",[this.name,this,widget]);};var orig_appendWidget=this.appendWidget;this.appendWidget=function(w){if(w instanceof DlMenuItem){this._items.push(w);if(w.name!=null)w.addEventListener("onSelect",onNamedItemSelect);}orig_appendWidget.apply(this,Array.$(arguments));};this.getItemByName=function(name){return this._items.grep_first(function(item){return item.name&&item.name==name;});};this.getItemById=function(name){return this._items.grep_first(function(item){return item.__itemId&&item.__itemId==name;});};if(this instanceof DlHMenu){this._popupAlign={prefer:"Br",fallX1:"__",fallX2:"_l",fallY1:"__",fallY2:"T_"};}else{this._popupAlign={prefer:"bR",fallX1:"__",fallX2:"_L",fallY1:"__",fallY2:"t_"};}this._getDlPopup=function(){var p=this.getParent(DlPopupMenu),l=0,ret;if(p)l=p._level+1;ret=DlPopupMenu.get(l);ret.detachPopup();if(p){ret.attachToPopup(p);}return ret;};this.getToplevelMenu=function(){var m=this;while(m.parentMenu)m=m.parentMenu;return m;};};(function(){var BASE=DlPopupMenu.inherits(DlPopup);function DlPopupMenu(args){if(args){DlPopup.call(this,args);this._mouseDiff={x:2,y:1};}};eval(Dynarch.EXPORT("DlPopupMenu"));function onMouseEnter(){this.cancel();var args=this.args;};D.onBeforePopup=function(args){if(!args.isContext){args.item.currentPopup=this;args.item._popupVisible=true;args.menu._popupVisible=true;args.item.activateSubmenu(true);}else{if(args.widget.activateSubmenu)args.widget.activateSubmenu(true);}var content=args.content;if(typeof content=="function")args.content=content=content();content.parentMenu=args.isContext?args.widget:args.menu;if(content instanceof DlWidget&&content.hasHooks("onPopup"))content.applyHooks("onPopup",[args]);};D.onHide=function(args,callback){if(!args.isContext){args.item.activateSubmenu(false);args.item.currentPopup=null;args.item._popupVisible=false;args.menu._popupVisible=false;args.content.parentMenu=null;}else{if(args.widget.activateSubmenu)args.widget.activateSubmenu(false);}if(callback)callback.call(this,args);};P.popup=function(args){if(!args.onBeforePopup)args.onBeforePopup=D.onBeforePopup;if(!args.onHide)args.onHide=D.onHide;else args.onHide=D.onHide.$(this,args,args.onHide);BASE.popup.call(this,args);};P._setListeners=function(){BASE._setListeners.call(this);this.addEventListener({onMouseEnter:onMouseEnter});};P.correctPos=function(p){var args=this.args;try{if(!args.isContext&&!args.scrollVisible){var m1=args.menu;if(m1&&(m1 instanceof DlVMenu)){var diff=args.content._widgets[0].getPos().y-args.content.parent.getElement().offsetTop;if(Math.abs(diff)<50){if(args.fallY)p.y+=diff;else p.y-=diff;}}}}catch(ex){};};})();(function(){DlHMenu.inherits(DlHbox);function DlHMenu(args){if(args){DlHbox.call(this,args);DlMenuBase.call(this,args);}};eval(Dynarch.EXPORT("DlHMenu"));var DEFAULT_EVENTS=["onSelect","onPopup"];P.initDOM=function(){this.registerEvents(DEFAULT_EVENTS);D.BASE.initDOM.call(this);};})();(function(){DlVMenu.inherits(DlVbox);function DlVMenu(args){if(args){DlVbox.call(this,args);DlMenuBase.call(this,args);}};eval(Dynarch.EXPORT("DlVMenu"));var DEFAULT_EVENTS=["onSelect","onPopup"];P.initDOM=function(){this.registerEvents(DEFAULT_EVENTS);D.BASE.initDOM.call(this);};})();(function(){var BASE=DlMenuItem.inherits(DlContainer);function DlMenuItem(args){if(args){DlMenuItem.setDefaults(this,args);DlContainer.call(this,args);if(!this.parentMenu)this.parentMenu=this.parent;}};eval(Dynarch.EXPORT("DlMenuItem",true));var DEFAULT_EVENTS=["onSelect"];D.DEFAULT_ARGS={label:["label","DlMenuItem"],_iconClass:["iconClass",null],_noClose:["noClose",false],parentMenu:["menu",null],name:["name",null],__itemId:["id",null]};P._inBaseMenu=function(){return!this.parentMenu.parentMenu;};P.initDOM=function(){this.registerEvents(DEFAULT_EVENTS);BASE.initDOM.call(this);};P._createElement=function(){BASE._createElement.call(this);var el=this.getElement();el.innerHTML='<div class="div1"><div class="div2"></div></div>';this.setIconClass(this._iconClass);this._iconClass=null;this.setUnselectable();if(this.label)this.setContent(this.label);};P.getContentElement=function(){return this.getElement().firstChild.firstChild;};P._getDlPopup=function(){return this.parentMenu._getDlPopup();};function onMouseEnter(){this.scrollIntoView();this.addClass("DlMenuItem-hover","DlMenuItem-active");var base=this._inBaseMenu();if(!base||this.parentMenu._popupVisible){if(this._menu){this._popupMenu(base?0:250);}else if(base){this._getDlPopup().hide(100);}}};function onMouseLeave(){this.delClass("DlMenuItem-hover");this.delClass("DlMenuItem-active");var base=this._inBaseMenu();if(!base)this._getDlPopup().hide(100);};function onMouseUp(){this.delClass("DlMenuItem-active");if(this.hasHooks("onSelect")){var args=DlPopupMenu.get(0).args;if(!this._noClose)DlPopupMenu.clearAll();this.applyHooks.delayed(1,this,"onSelect",[this.name,this,args]);}};function onMouseDown(){this.addClass("DlMenuItem-active");this._popupMenu(0);DlException.stopEventBubbling();};function onDestroy(){if(this._menu instanceof DlWidget){this._menu.destroy();this._menu=null;}};P._popupMenu=function(timeout){if(this._menu&&!this._popupVisible){var pm=this.parentMenu;var p=this._getDlPopup();if(p.visible)p.hide();p.popup({timeout:timeout,content:this.getMenu(),anchor:this.getElement(),align:pm._popupAlign,item:this,menu:this.parentMenu,onPopup:this._onPopup,onHide:this._onHide});}};P._setListeners=function(){BASE._setListeners.call(this);this.addEventListener({onMouseEnter:onMouseEnter,onMouseLeave:onMouseLeave,onMouseDown:onMouseDown,onMouseUp:onMouseUp,onDestroy:onDestroy});};P.getMenu=function(){return this._menu;};P.setMenu=function(menu,onPopup,onHide){if(this._menu instanceof DlWidget)this._menu.destroy();if(menu instanceof DlWidget)menu.ref();this._menu=menu;this._onPopup=onPopup;this._onHide=onHide;CC(this.getElement().firstChild,menu,"DlMenuItem-withPopup");};P.activateSubmenu=function(act){this.condClass(act,"DlMenuItem-popped");};})();(function(){var BASE=DlButtonMenu.inherits(DlHbox);function DlButtonMenu(args){if(args){D.setDefaults(this,args);DlMenuBase.call(this,args);DlHbox.call(this,args);}};eval(Dynarch.EXPORT("DlButtonMenu"));var DEFAULT_EVENTS=["onSelect","onPopup","onHide","onClick"];D.DEFAULT_ARGS={label:["label",null],_iconClass:["iconClass",null],_shiftMenu:["shiftMenu",null],_connected:["connected",false]};P.ALIGN={prefer:"Br",fallX1:"_r",fallX2:"_l",fallY1:"__",fallY2:"T_"};P.activateSubmenu=function(activate){this._mainBtn.condClass(activate,"DlButton-1");this._menuBtn.condClass(activate,"DlButton-1");};P._createElement=function(){BASE._createElement.call(this);this._mainBtn=new DlButton({parent:this,focusable:false,label:this.label,className:"LabelPart",noCapture:this._connected,iconClass:this._iconClass});this._mainBtn.connectEvents("onClick",this);this._menuBtn=new DlButton({parent:this,focusable:false,label:"&nbsp;",className:"MenuArrow",noCapture:true});this._menuBtn.getContentElement().className="MenuArrow-inner";if(this._connected)this._mainBtn.connectEvents("onMouseDown",this._menuBtn);this._mainBtn.connectEvents(["onMouseEnter","onMouseLeave"],this._menuBtn);};function popupMenu(ev){if(!this._popupVisible){var p=this._getContextMenuPopup();p.popup({timeout:0,content:this.getMenu(),align:this.ALIGN,anchor:this.getTableElement(),isContext:true,widget:this,shift:this._shiftMenu,onHide:this.callHooks.$(this,"onHide")});ev._justFocusedWidget=p;this.callHooks("onPopup");}};P.initDOM=function(){this.registerEvents(DEFAULT_EVENTS);BASE.initDOM.call(this);this._menuBtn.addEventListener("onMouseDown",popupMenu.$(this));this.addEventListener("onDestroy",function(){if(this._menu instanceof DlWidget)this._menu.destroy();});};P.getMenu=function(){return this._menu;};P.getButton=function(){return this._mainBtn;};P.getArrow=function(){return this._menuBtn;};P.setMenu=function(menu){if(this._menu instanceof DlWidget)this._menu.destroy();if(menu instanceof DlWidget)menu.ref();this._menu=menu;};})();var DlElementCache={get:function(tag){return this[tag].cloneNode(true);}};(function(){eval(DynarchDomUtils.importCommonVars());var C=DlElementCache;(function(){var TBODY_RC=document.createDocumentFragment();CE("td",null,null,CE("tr",null,null,CE("tbody",null,null,TBODY_RC)));C.TBODY_RC=TBODY_RC;})();(function(){var SHADOWS=document.createDocumentFragment();CE("div",null,{className:"Shadow Shadow-TL"},SHADOWS);CE("div",null,{className:"Shadow Shadow-T"},SHADOWS);CE("div",null,{className:"Shadow Shadow-TR"},SHADOWS);CE("div",null,{className:"Shadow Shadow-L"},SHADOWS);CE("div",null,{className:"Shadow Shadow-R"},SHADOWS);CE("div",null,{className:"Shadow Shadow-BL"},SHADOWS);CE("div",null,{className:"Shadow Shadow-B"},SHADOWS);CE("div",null,{className:"Shadow Shadow-BR"},SHADOWS);C.SHADOWS=SHADOWS;})();(function(){var STATIC_ROW=CE("tr");var STATIC_CELL=CE("td",null,null,STATIC_ROW);(6).times(function(){STATIC_ROW.appendChild(STATIC_CELL.cloneNode(true));});C.CAL_HEAD=CE("thead");C.CAL_HEAD.appendChild(STATIC_ROW.cloneNode(true));var STATIC_BODY=C.CAL_BODY=CE("tbody");(6).times(function(){STATIC_BODY.appendChild(STATIC_ROW.cloneNode(true));});})();C.DRAGGING_LINE=CE("div",null,{className:"DlResizeBar-DraggingLine"});DlEvent.atUnload(function(){var trash=DynarchDomUtils.trash();for(var i in C){var el=C[i];if(!(el instanceof Function)){trash.appendChild(C[i]);delete C[i];el=C[i]=null;}}C=DynarchDomUtils.CE_CACHE;for(var i in C){var el=C[i];if(el!==trash){trash.appendChild(C[i]);delete C[i];el=C[i]=null;}}trash.innerHTML="";if(is_ie)trash.outerHTML="";delete DynarchDomUtils.CE_CACHE["_trash"];DynarchDomUtils.CE_CACHE._trash=null;C=null;});})();(function(){var BASE=DlCalendar.inherits(DlWidget);function DlCalendar(args){if(args){args.tagName="table";D.setDefaults(this,args);this._dayNamesOn=-1;this._selectedDate=(this.date&&this.selected)?this.date.getDate():0;DlWidget.call(this,args);if(!this._noinit)this.init();}};eval(Dynarch.EXPORT("DlCalendar",true));var DEFAULT_EVENTS=["onSelect","onChange","onRendered"];D.DEFAULT_ARGS={firstDay:["firstDay",Date.getFirstDayOfWeek()],fixedFirstDay:["fixedFirstDay",true],_weekNumbers:["weekNumbers",false],date:["date",null],selected:["selected",true],_navigation:["navigation",2],_navDisabled:["navDisabled",false],_omDisabled:["omDisabled",false],_noinit:["noinit",false],_withMenu:["withMenu",false],_cal_tooltip:["tooltip",null],_infoDates:["infoDates",null],__tooltip:["tooltip",getTooltip]};P._createElement=function(){BASE._createElement.call(this);var trs,i,tr,td,table=this.getElement(),tbody=DlElementCache.get("CAL_BODY");table.cellSpacing=table.cellPadding=table.border=0;table.appendChild(DlElementCache.get("CAL_HEAD"));table.appendChild(tbody);if(this._weekNumbers){trs=table.getElementsByTagName("tr");for(i=trs.length;--i>=0;){tr=trs[i];td=CE("td",null,{className:"DlCalendar-WeekNumber"});tr.insertBefore(td,tr.firstChild);}}tr=CE("tr");td=CE("td",null,null,tr);tr.className="DlCalendar-Navigation";if(this._navigation==0){td.colSpan=this.getNCols();this._makeNavPart(td,0);}else{var td1=CE("td",null,null,tr);var td2=CE("td",null,null,tr);if(this._navigation==1){td1.colSpan=this.getNCols()-2;this._makeNavPart(td1,0,td,-1,td2,1);}else if(this._navigation==2){var td3=CE("td",null,null,tr);var td4=CE("td",null,null,tr);td2.colSpan=this.getNCols()-4;this._makeNavPart(td2,0,td,-2,td1,-1,td3,1,td4,2);}}i=table.rows[0];i.parentNode.insertBefore(tr,i);this.setUnselectable();if(this._withMenu)this._createQuickNavMenu();};var MENU=null;function getMenu(){if(!MENU){MENU=new DlVMenu({});MENU.setStyle("textAlign","center");new DlMenuItem({parent:MENU,label:DlTEXTS.goToday,name:"today",noClose:true});MENU.addSeparator();var year=new DlSpinner({parent:MENU,size:4});year.addEventListener("onChange",function(){if(!year.validationError)MENU.calendar.setYear(year.getValue());});year.getElement().align="center";MENU.addSeparator();(12).times(function(i){new DlMenuItem({parent:MENU,label:Date.getMonthName(i),name:i,noClose:true});});MENU.addEventListener("onPopup",function(args){this.calendar=args.widget;year.setValue(this.calendar.date.getFullYear());year.focus.$(year).delayed(5);});MENU.addEventListener("onSelect",function(mon){if(mon=="today"){this.calendar.setToday();}else{this.calendar.setMonth(mon);this.calendar.setYear(year.getValue());}MENU.getParent(DlPopup).hide();});}return MENU;};P._createQuickNavMenu=function(){this.setContextMenu(getMenu);};P._makeNavPart=function(){var td,type,i;for(var i=0;i<arguments.length;++i){td=arguments[i++];type=arguments[i];td._navType=type;switch(type){case-2:td.className="PrevYear";break;case-1:td.className="PrevMonth";break;case 0:td.className="Month";this.refNode("_monthTD",td);break;case 1:td.className="NextMonth";break;case 2:td.className="NextYear";break;}}};P.getNCols=function(){return this._weekNumbers?8:7;};P.getTableElement=function(){return this.getElement();};P._displayDayNames=function(){var td,today=new Date(),todayWD=today.getDay(),dnrow=this.getTableElement().getElementsByTagName("tr")[1],i=this._weekNumbers?1:0,j=this.firstDay;dnrow.className="DlCalendar-DayNames";while(td=dnrow.cells[i++]){td._firstDay=j%7;CC(td,j==todayWD,"Today");td.innerHTML=Date.getDayName(j++,true);CC(td,Date.isWeekend(td._firstDay),"WeekEnd");}this._dayNamesOn=this.firstDay;if(this._weekNumbers){td=dnrow.cells[0];td.innerHTML="w";td._week=-1;td.className="WeekNumber";}};P._displayCalendar=function(){var today=new Date(),TY=today.getFullYear(),TM=today.getMonth(),TD=today.getDate();this._selectedTD=null;if(this._dayNamesOn!=this.firstDay)this._displayDayNames();var date=new Date(this.date);date.setHours(12);var month=date.getMonth();var mday=date.getDate();var year=date.getFullYear();var no_days=date.getMonthDays();this._monthTD.innerHTML=String.buffer("<b>",Date.getMonthName(month,this._navigation==2),"</b> ",year).get();date.setDate(1);var day1=(date.getDay()-this.firstDay)%7;if(day1<0)day1+=7;date.setDate(-day1);date.setDate(date.getDate()+1);var row=this.getTableElement().rows[2];var cells=this._cells=[];var di=this._displayedInterval={};var tmp;for(var i=0;i<6;++i,row=row.nextSibling){row.className="Dates";var cell=row.firstChild;if(this._weekNumbers){cell.className="WeekNumber";cell.innerHTML=cell._week=date.getWeekNumber();cell=cell.nextSibling;}var iday;for(var j=0;j<7;++j,cell=cell.nextSibling,date.setDate(iday+1)){var wday=date.getDay();var cn=[];cell._iday=iday=date.getDate();cell._month=date.getMonth();cell._year=date.getFullYear();cell._info=null;tmp={y:cell._year,m:cell._month,d:cell._iday};if(this._infoDates){var str=tmp.y+"-"+(1+tmp.m).zeroPad(2)+"-"+tmp.d.zeroPad(2);var id=this._infoDates[str];if(id){cell._info=id;cn.push(id.className||"DlCalendar-infoDay");}}if(!di.start)di.start=tmp;if(cell._otherMonth=month!=tmp.m){cn.push("OtherMonth");cells[iday+(iday>15?100:200)]=cell;}else{if(month==TM&&iday==TD&&TY==tmp.y)cn.push("Today");if(this._selectedDate==iday)this._selectCell(cell);cells[iday]=cell;}if(wday==0||wday==6)cn.push("WeekEnd");cell.innerHTML=this.getDayHTML(iday);cell.className=cn.join(" ");}}di.end=tmp;this.applyHooks("onRendered",[this]);};P.getDayHTML=Function.identity;P.getDateCell=function(date){return this._cells[date];};P.getDisplayedInterval=function(){return this._displayedInterval;};P.selectDate=function(date,nohooks){if(date instanceof Date){if(!date.dateEqualsTo(this.date,true)){this.date=new Date(date);this.init();}date=date.getDate();}this._selectCell(this.getDateCell(date),!nohooks);};function onMouseOver(ev){this._clearTimer();var cell=ev.getParentElement("td");if(cell){if(this._currentHover){DC(this._currentHover,"hover");DC(this._currentHover,"rolling");this._currentHover=null;DlWidget.getTooltip().hide();}if(cell._navType!=null&&this._navDisabled)return;if(cell._otherMonth&&this._omDisabled)return;if((cell._firstDay!=null&&this.fixedFirstDay)||cell._week!=null)return;AC(cell,"hover");this._currentHover=cell;if(this.__tooltip)this._popupTooltip();}};function onMouseLeave(ev){this._clearTimer();if(this._currentHover){DC(this._currentHover,"hover");DC(this._currentHover,"rolling");this._currentHover=null;}};P.setYear=function(y){if(y!=this.date.getFullYear()){this.date.setFullYear(y);this.init();}};P.setMonth=function(m){if(m!=this.date.getMonth()){this.date.setMonth(m);this.init();}};P.setToday=function(){var today=new Date();this._selectedDate=0;this.date=today;this.init();};P._navCellClicked=function(cell,timeout,ev){AC(cell,"rolling");this._selectedDate=0;var d=this.date;if(cell._navType!=0)d.setDate(1);switch(cell._navType){case 0:if(this._withMenu){this.applyHooks("onContextMenu",[ev]);}else{var today=new Date();if(d.dateEqualsTo(today,true))return;this.date=today;}break;case-2:d.setFullYear(d.getFullYear()-1);break;case-1:d.setMonth(d.getMonth()-1);break;case 1:d.setMonth(d.getMonth()+1);break;case 2:d.setFullYear(d.getFullYear()+1);break;}this.init();this.applyHooks("onChange",[cell._navType]);this.applyHooks("onSelect",[true,cell._navType,null,d]);if(timeout&&cell._navType!=0){++this._timerStep;this._timer=setTimeout(this._navCellClicked.$(this,cell,this._timerStep>4?50:100),timeout);}};P._clearTimer=function(){if(this._timer)clearTimeout(this._timer);this._timer=null;this._timerStep=0;};function onClick(ev){onMouseOver.call(this,ev);var cell=ev.getParentElement("td");if(!cell)return;if(ev.button!=0&&(cell._navType!=null||cell._otherMonth))return;if(cell._otherMonth&&this._omDisabled)return;if(cell._navType!=null&&ev.dl_type=="onMouseDown"){this._navDisabled||this._navCellClicked(cell,cell._navType!=0?350:0,ev);}else if(cell._year!=null&&ev.dl_type=="onMouseUp"){var d=this.date;d.setDate(cell._iday);d.setMonth(cell._month);d.setFullYear(cell._year);var old_date=this._selectedDate;this._selectedDate=cell._iday;if(cell._otherMonth){this.init();this.applyHooks("onSelect",[false,true,false,d]);}else if(old_date!=this._selectedDate){this._selectCell(cell,true);}else{this.applyHooks("onSelect",[false,false,true,d]);}}else if(cell._firstDay!=null&&!this.fixedFirstDay&&ev.button==0&&ev.dl_type=="onMouseDown"){this.firstDay=cell._firstDay;this._displayCalendar();}};P._selectCell=function(cell,hooks){this._selectedDate=cell._iday;if(this._selectedTD){DC(this._selectedTD,"Selected");DC(this._selectedTD.parentNode,"Selected");}this._selectedTD=cell;AC(cell,"Selected");AC(cell.parentNode,"Selected");DC(cell,"hover");if(hooks)this.applyHooks("onSelect",[false,false,false,this.date]);};P._setListeners=function(){BASE._setListeners.call(this);this.addEventListener({onMouseOver:onMouseOver,onMouseLeave:onMouseLeave,onMouseUp:onClick,onMouseDown:onClick});};P.initDOM=function(){BASE.initDOM.call(this);this.registerEvents(DEFAULT_EVENTS);};P.setInfoDates=function(a){this._infoDates=a;if(this._initialized)this._displayCalendar();};function getTooltip(){var cal=this.args.widget,di,td;td=cal._currentHover;if(td)di=td._info;td=cal._cal_tooltip;return td?td.call(cal,di):di?di.tooltip:null;};P.init=function(){if(!this.date)this.date=new Date();this._displayCalendar();this._initialized=true;};})();(function(){var BASE=DlButtonCalendar.inherits(DlButtonMenu);function DlButtonCalendar(args){if(args){D.setDefaults(this,args);DlButtonMenu.call(this,args);}};eval(Dynarch.EXPORT("DlButtonCalendar"));D.DEFAULT_ARGS={dateFormat:["dateFormat","%Y/%m/%d"],_calendarArgs:["calendar",{}],_iconClass:["iconClass","IconCalendar"],date:["date","Select date..."]};var DEFAULT_EVENTS=["onSelect","onCalendarRendered"];function calendar_onSelect(cal,cleared,otherMonth){if(!cleared){this.getButton().setContent(cal.date.print(this.dateFormat));DlPopup.clearAllPopups();this.date=new Date(cal.date);this.applyHooks("onSelect",[this.date]);}};function button_onClick(ev){if(this.date instanceof Date){var cal=this.getCalendar();if(!cal.date.dateEqualsTo(this.date)){cal.date=new Date(this.date);cal._selectedDate=this.date.getDate();cal.init();}}this.getArrow().applyHooks("onMouseDown",[ev]);};P.getCalendar=function(){var cal=this._calendar;if(!cal){this._calendarArgs.noinit=true;cal=this._calendar=new DlCalendar(this._calendarArgs);this.addEventListener("onDestroy",cal.destroy.$(cal));cal.addEventListener("onSelect",calendar_onSelect.$(this,cal));cal.connectEvents("onRendered",this,"onCalendarRendered");if(this.date instanceof Date)cal.date=new Date(this.date);cal.init();}return this._calendar;};P.initDOM=function(){this.registerEvents(DEFAULT_EVENTS);BASE.initDOM.call(this);var b=this.getButton();if(this.date instanceof Date)b.setContent(this.date.print(this.dateFormat));else b.setContent(this.date);this.setMenu(this.getCalendar.$(this));b.addEventListener("onClick",button_onClick.$(this));};P.getValue=function(){return this.date instanceof Date?this.date:null;};})();(function(){var BASE=DlButtonColorPicker.inherits(DlButtonMenu);function DlButtonColorPicker(args){if(args){D.setDefaults(this,args);DlButtonMenu.call(this,args);this._events_cp={onSelect:onSelect.$(null,this),onHueChange:onHueChange.$(null,this),onHover:onHover.$(null,this),onHoverOut:onLeave.$(null,this)};this._updateValues();}};eval(Dynarch.EXPORT("DlButtonColorPicker",true));D.DEFAULT_ARGS={rgb:["rgb",null],hsv:["hsv",null],color:["color",null]};function onSelect(btn,rgb,hsv,color,brightness){var div=btn.getColorElement();div.style.backgroundColor=color;btn.hsv=Dynarch.makeArray(hsv);btn._updateValues();DlPopup.clearAllPopups();btn.applyHooks("onSelect",[rgb,hsv,color,brightness]);};function onHover(btn,rgb,hsv,color,brightness){btn.getColorElement().style.backgroundColor=color;};function onHueChange(btn,hue){if(btn.hsv){var hsv=[hue,btn.hsv[1],btn.hsv[2]];var color=DlColor.RGB2color(DlColor.HSV2RGB(hsv));btn.getColorElement().style.backgroundColor=color;btn.hsv=hsv;btn._updateValues();}};function onLeave(btn){var div=btn.getColorElement();div.style.backgroundColor=btn.rgb?DlColor.RGB2color(btn.rgb):"";};P._updateValues=function(){if(this.hsv){this.rgb=DlColor.HSV2RGB(this.hsv);this.color=DlColor.RGB2color(this.rgb);}else if(this.rgb){this.hsv=DlColor.RGB2HSV(this.rgb);this.color=DlColor.RGB2color(this.rgb);}else if(this.color){this.rgb=DlColor.color2RGB(this.color);this.hsv=DlColor.RGB2HSV(this.rgb);}};function _popupCP(){this._cp.addEventListener(this._events_cp);if(this.hsv)this._cp.setHSV(this.hsv);};function _hideCP(){this._cp.removeEventListener(this._events_cp);};P.setColorPicker=function(cp){this._cp=cp;this.setMenu(cp);if(this.hsv){cp.setHSV(this.hsv);onSelect.call(cp,this,this.rgb,this.hsv,DlColor.RGB2color(this.rgb),DlColor.RGBrightness(this.rgb));}};P._createElement=function(){BASE._createElement.call(this);var el=this.getButton().setContent(["<table cellspacing='0' cellpadding='0'><tr><td>","<div unselectable='on' class='ColorPart'>&nbsp;</div>","</td><td></td></tr></table>"].join(""));this.setLabel(this.label);};P.setLabel=function(label){var div=this.getLabelElement();div.innerHTML=label||"";CC(div,label,"Label","EmptyLabel");};P.getColorElement=function(){return this.getButton().getContentElement().firstChild.rows[0].cells[0].firstChild;};P.getLabelElement=function(){return this.getButton().getContentElement().firstChild.rows[0].cells[1];};P._setListeners=function(){BASE._setListeners.call(this);this.addEventListener({onPopup:_popupCP,onHide:_hideCP});};})();DlCheckbox.inherits(DlAbstractButton);function DlCheckbox(args){if(args){args.type=DlButton.TYPE.TWOSTATE;DlCheckbox.setDefaults(this,args);DlAbstractButton.call(this,args);}};DlCheckbox.DEFAULT_ARGS={_classes:["classes",{active:"DlCheckbox-active",hover:"DlCheckbox-hover",checked:"DlCheckbox-1",unchecked:"DlCheckbox-0",empty:"DlCheckbox-empty",disabled:"DlCheckbox-disabled"}]};var DlColor={RGB2HSV:function(rgb){var r=rgb[0],g=rgb[1],b=rgb[2];var min,max,delta,h,s,v;min=Math.min(r,g,b);max=Math.max(r,g,b);v=max;delta=max-min;if(max!=0){s=delta/max;if(r==max)h=(g-b)/delta;else if(g==max)h=2+(b-r)/delta;else h=4+(r-g)/delta;h*=60;if(h<0)h+=360;}else{s=0;h=-1;}return[h,s,v];},HSV2RGB:function(hsv){var h=hsv[0],s=hsv[1],v=hsv[2];var i,r,g,b,f,p,q,t;if(s==0)r=g=b=v;else{h/=60;i=Math.floor(h);f=h-i;p=v*(1-s);q=v*(1-s*f);t=v*(1-s*(1-f));switch(i){case 0:r=v;g=t;b=p;break;case 1:r=q;g=v;b=p;break;case 2:r=p;g=v;b=t;break;case 3:r=p;g=q;b=v;break;case 4:r=t;g=p;b=v;break;default:r=v;g=p;b=q;break;}}return[r,g,b];},RGB2bytes:function(rgb){var b=new Array(3);b[0]=Math.round(rgb[0]*255);b[1]=Math.round(rgb[1]*255);b[2]=Math.round(rgb[2]*255);return b;},RGB2color:function(rgb){return String.buffer("rgb(",rgb[0]*100,"%,",rgb[1]*100,"%,",rgb[2]*100,"%)").get();},RGB2hex:function(rgb){rgb=DlColor.RGB2bytes(rgb);return rgb[0].hex(2)+rgb[1].hex(2)+rgb[2].hex(2);},color2RGB:function(color){var r=0,g=0,b=0;if(/^#/.test(color)){if(color.length==4)color=color.replace(/([a-f0-9])/ig,"$1$1");r=parseInt(color.substr(1,2),16)/255;g=parseInt(color.substr(3,2),16)/255;b=parseInt(color.substr(5,2),16)/255;}else throw new DlException("Can't parse color: "+color);return[r,g,b];},brighter:function(hsv){var a=Array.$(hsv);a[1]-=0.5;if(a[1]<0)a[1]=0;return a;},darker:function(hsv){var a=Array.$(hsv);a[2]-=0.5;if(a[2]<0)a[2]=0;return a;},RGBrightness:function(rgb){return(rgb[0]*299+rgb[1]*587+rgb[2]*114)/1000;}};(function(){var BASE=DlColorPickerHSV.inherits(DlWidget);function DlColorPickerHSV(args){if(args)DlWidget.call(this,args);};eval(Dynarch.EXPORT("DlColorPickerHSV",true));var DEFAULT_EVENTS=["onSelect","onHover","onHoverOut","onHueChange"];var HTML=String.buffer("<table cellspacing='1' cellpadding='0' border='0'>","<tbody>","<tr>","<td></td>".repeat(11),"<td rowspan='11' class='DlColorPickerHSV-Sep'></td>","<td rowspan='11' class='DlColorPickerHSV-HSV' hueCell='1'>","<div class='DlColorPickerHSV-HSV-bar'></div>","</td>","</tr>",("<tr>"+"<td></td>".repeat(11)+"</tr>").repeat(10),"</tbody></table>").get();P.getHueBarElement=function(){return this.getElement().rows[0].cells[12].firstChild;};P._createElement=function(){BASE._createElement.call(this,HTML);this.setUnselectable();};function getTD(ev){var el=ev.target;try{while(el&&el.tagName.toLowerCase()!="td")el=el.parentNode;}catch(ex){el=null;}return el;};function onMouseUp(ev){var td=getTD(ev);if(!td)return;if(td.rgb){this.applyHooks("onSelect",[td.rgb,td.hsv,td.style.backgroundColor,DlColor.RGBrightness(td.rgb)]);}throw new DlExStopEventBubbling;};function onMouseDown(ev){var td=getTD(ev);if(!td)return;var isHue=td.getAttribute("hueCell");if(isHue){ev.computePos(this);this._refresh(ev);DlEvent.captureGlobals(this._dragHandlers);}throw new DlExStopEventBubbling;};function onMouseOver(ev){if(this._currentHover){DC(this._currentHover,"hover1");DC(this._currentHover,"hover2");}var td=getTD(ev);if(td){if(td.rgb){this._currentHover=td;var br=DlColor.RGBrightness(td.rgb);CC(td,br>0.6,"hover2","hover1");this.applyHooks("onHover",[td.rgb,td.hsv,td.style.backgroundColor,br]);}else if(this._currentHover){this.callHooks("onHoverOut");this._currentHover=null;}}};function onMouseLeave(){var el=this._currentHover;if(el){DC(el,"hover1");DC(el,"hover2");this.callHooks("onHoverOut");}this._currentHover=null;};function stopDrag(ev){DlEvent.releaseGlobals(this._dragHandlers);throw new DlExStopEventBubbling;};function doDrag(ev){var pos=ev.computePos(this);var y=pos.y-2;if(y<0)y=0;else if(y>119)y=119;this.getHueBarElement().style.top=y+"px";if(this.__cphsvTimeout)clearTimeout(this.__cphsvTimeout);this.__cphsvTimeout=this._refresh.$(this,ev).delayed(5);throw new DlExStopEventBubbling;};P.initDOM=function(){this.registerEvents(DEFAULT_EVENTS);BASE.initDOM.call(this);this.addEventListener({onMouseUp:onMouseUp,onMouseDown:onMouseDown,onMouseOver:onMouseOver,onMouseLeave:onMouseLeave});this._dragHandlers={onMouseMove:doDrag.$(this),onMouseUp:stopDrag.$(this),onMouseOver:DlException.stopEventBubbling,onMouseOut:DlException.stopEventBubbling,onMouseEnter:DlException.stopEventBubbling,onMouseLeave:DlException.stopEventBubbling};this._redraw(360);};P._refresh=function(ev){var y=Math.limit(ev.relPos.y-2,0,119);var hue=Math.round((1-y/120)*360);hue=this._redraw(hue);this.applyHooks("onHueChange",[hue]);this.__cphsvTimeout=null;};P.setHSV=function(hsv){this._redraw(hsv[0]);};P._redraw=function(hue){var i,c,j,cells,div=this.getHueBarElement(),table=this.getElement(),rows=table.rows,di=rows.length-1,dj=rows[0].cells.length-3;div.style.top=(120-hue/3)+"px";if(hue==360)hue=0;for(i=di;i>=0;--i){cells=rows[i].cells;for(j=dj;j>=0;--j){c=cells[j];c.hsv=[hue,1-i/di,j/dj];c.rgb=DlColor.HSV2RGB(c.hsv);c.style.backgroundColor=DlColor.RGB2color(c.rgb);}}return hue;};})();(function(){var BASE=DlEntry.inherits(DlContainer);function DlEntry(args){if(args){args.tagName="table";D.setDefaults(this,args);this._isTextArea=args.type=="textarea";DlContainer.call(this,args);}};eval(Dynarch.EXPORT("DlEntry",true));var DEFAULT_EVENTS=["onChange","onKey-ENTER","onKey-ESCAPE","onValidationError","onValidation"];D.DEFAULT_ARGS={_domType:["type","text"],_value:["value",null],_size:["size",null],_rows:["rows",null],_readonly:["readonly",false],_emptyText:["emptyText",""],_width:["width",null],_name:["name",null],_validators:["validators",[]],_allowEmpty:["allowEmpty",null],_focusable:["focusable",2],_noSelect:["noSelect",false],_noWrap:["noWrap",false]};P.validate=function(val){if(val==null)val=this.getValue();if(this._allowEmpty!=null){if(!/\S/.test(val)){this.condClass(!this._allowEmpty,"DlEntry-ValidationError");this.applyHooks("onValidation",[!this._allowEmpty]);return this._allowEmpty;}}var a=this._validators,i,v,err=false;for(i=0;i<a.length;++i){v=a[i];if(!v.ok(val)){err=v.getError()||true;break;}}if(v&&!err)this.setValue(v.getLastVal(),true);this.validationError=err;if(!this._noSelect&&this._focused&&!this.readonly()&&this._domType!="textarea")this.select();this.condClass(err,"DlEntry-ValidationError");this.applyHooks("onValidation",[err]);if(err)this.applyHooks("onValidationError",[err]);return!err;};P.timerFocus=function(timeout){return this.focus.clearingTimeout(timeout||10,this);};P.select=function(){try{if(is_gecko)this.setSelectionRange(0,this.getValue().length);else this.getInputElement().select();}catch(ex){}};P.focus=function(){this.getInputElement().focus();if(!this._noSelect&&!this.readonly()&&this._domType!="textarea")this.select();};P.blur=function(){this.getInputElement().blur();};function element_focus(){this.addClass("DlEntry-Focus");this._focused=true;BASE.focus.call(this);if(this._isEmpty){this.getInputElement().value="";this.delClass("DlEntry-empty");this._isEmpty=false;}};function element_blur(){this.delClass("DlEntry-Focus");this._focused=false;BASE.blur.call(this);this.__setEmpty();};function element_change(){this.__setEmpty();this.callHooks("onChange");};P.__setEmpty=function(value){var el=this.getInputElement();value=value!=null?value:el.value;this._isEmpty=this.__checkEmpty(value);if(!this._isEmpty){this.delClass("DlEntry-empty");}else if(!this._focused){this.addClass("DlEntry-empty");this.getInputElement().value="";(function(){if(!this.destroyed&&!this._focused&&this.__checkEmpty())this.getInputElement().value=this._emptyText;}).delayed(0,this);}else{this.getInputElement().value=value;}return this._isEmpty;};P.__checkEmpty=function(value){if(value==null)value=this.getInputElement().value;return value==="";};P._createElement=function(){BASE._createElement.call(this);var el=this.getElement();el.appendChild(DlElementCache.get("TBODY_RC"));el.cellSpacing=el.cellPadding=el.border=0;el=el.rows[0].cells[0];el.className="DlEntry-cell";var input=this._isTextArea?document.createElement("textarea"):input=document.createElement("input");input.setAttribute("autocomplete","off",1);if(this._noWrap)input.setAttribute("wrap","off");if(this._isTextArea){if(this._rows)input.rows=this._rows;}switch(this._domType){case "password":case "file":case "hidden":input.type=this._domType;}if(is_gecko&&gecko_version<1.9&&!this._no_gecko_bug)el=CE("div",null,{className:"Gecko-Bug-226933"},el);el.appendChild(input);};P.getInputElement=function(){return this.getElement().getElementsByTagName(this._isTextArea?"textarea":"input")[0];};P.getContentElement=P.getInputElement;P.setIfEmpty=function(value,nocall){if(this._isEmpty&&value)this.setValue(value,nocall);};P.isEmpty=function(){return this.__checkEmpty();};P.setValue=function(value,nocall){if(!this.__setEmpty(value))this.getInputElement().value=value;if(!nocall)this.callHooks("onChange");};P.clear=function(nocall){this.setValue("",nocall);};P.getValue=function(){return this._isEmpty?"":this.getInputElement().value;};P.getSelectionRange=function(){var input=this.getInputElement(),start,end;if(is_ie){var range,isCollapsed,b;range=document.selection.createRange();isCollapsed=range.compareEndPoints("StartToEnd",range)==0;if(!isCollapsed)range.collapse(true);b=range.getBookmark();start=b.charCodeAt(2)-2;range=document.selection.createRange();isCollapsed=range.compareEndPoints("StartToEnd",range)==0;if(!isCollapsed)range.collapse(false);b=range.getBookmark();end=b.charCodeAt(2)-2;}else{start=input.selectionStart;end=input.selectionEnd;}return{start:start,end:end};};P.setSelectionRange=function(start,end){if(typeof start=="object"){end=start.end;start=start.start;}var input=this.getInputElement();if(is_ie){var range=input.createTextRange();range.collapse(true);range.moveStart("character",start);range.moveEnd("character",end-start);range.select();}else{input.setSelectionRange(start,end);}};P.moveEOF=function(){var l=this.getValue().length;this.setSelectionRange(l,l);};P.moveBOF=function(){this.setSelectionRange(0,0);};P.collapse=function(atStart){var p=this.getSelectionRange();p=atStart?p.start:p.end;this.setSelectionRange(p,p);};function onChange(){this.validate();};function onKeyPress(ev){this.__setEmpty();if(ev.keyCode==DlKeyboard.ENTER){this.applyHooks("onKey-ENTER",[ev]);}else if(ev.keyCode==DlKeyboard.ESCAPE){this.applyHooks("onKey-ESCAPE",[ev]);}};function onDestroy(){DOM.removeEvent(this.getInputElement(),{focus:this._on_element_focus,blur:this._on_element_blur,change:this._on_element_change});};P.initDOM=function(){this.registerEvents(DEFAULT_EVENTS);BASE.initDOM.call(this);var input=this.getInputElement();DOM.addEvent(input,{focus:this._on_element_focus=element_focus.$(this),blur:this._on_element_blur=element_blur.$(this),change:this._on_element_change=element_change.$(this)});this.addEventListener({onChange:onChange,onKeyPress:onKeyPress,onDestroy:onDestroy});if(this._value!=null)this.setValue(this._value,true);else this.clear(true);if(this._width!=null)input.style.width=this._width;if(this._size!=null){this.setSize({x:this._size*9+7-this._size});}if(this._name!=null)input.name=this._name;this.readonly(this._readonly);delete this._readonly;delete this._value;};P.readonly=function(readonly){var input=this.getInputElement();if(readonly!=null){input.readOnly=readonly;readonly?input.setAttribute("readonly",true,1):input.removeAttribute("readonly");this.condClass(readonly,"DlEntry-Readonly");}return input.getAttribute("readonly");};P.disabled=function(v,force){var isDisabled=BASE.disabled.call(this,v,force);if(v!=null)this.getInputElement().disabled=!!v;return isDisabled;};P.setSize=P.setOuterSize=function(size){var input=this.getInputElement(),x=size.x,y=size.y,pb=DOM.getPaddingAndBorder(input);if(x!=null)x-=pb.x+4;if(y!=null)y-=pb.y+4;DOM.setInnerSize(input,x,y);if(x!=null){x+=8;DOM.setInnerSize(this.getElement(),x);}};})();(function(){DlCompletionPopup.inherits(DlPopup);function DlCompletionPopup(args){if(args){args.zIndex=1000;args.focusable=false;DlPopup.call(this,args);}};var BASE=DlCompletionEntry.inherits(DlEntry);function DlCompletionEntry(args){if(args){DlCompletionEntry.setDefaults(this,args);DlEntry.call(this,args);}};eval(Dynarch.EXPORT("DlCompletionEntry"));var DEFAULT_EVENTS=["onCompletion","onSelect"];D.DEFAULT_ARGS={__timeout:["timeout",500],_shiftMenu:["shift",null],__smart:["smart",true],__noTab:["noTab",false],_noSelect:["noSelect",true]};P.ALIGN={prefer:"Br",fallX1:"_r",fallX2:"_L",fallY1:"__",fallY2:"T_"};P._setListeners=function(){this.__on_itemHover=on_itemHover.$(null,this);this.__on_itemSelect=on_itemSelect.$(null,this);BASE._setListeners.call(this);this.registerEvents(DEFAULT_EVENTS);this.addEventListener({onKeyDown:onKeyDown,onBlur:onBlur,onDestroy:this.__clearTimer});};P._hideMenu=function(){_getPopup().hide(50);this.__clearTimer();};P.__clearTimer=function(){if(this.__timer)clearTimeout(this.__timer);this.__timer=null;};var POPUP=null;function _getPopup(){if(!POPUP){POPUP=DlCompletionPopup.get();}return POPUP;};var MENU=null;var ITEM=null;function _getMenu(){if(MENU){ITEM=null;MENU.destroy();}return MENU=new DlVMenu({});};function _menuVisible(){return MENU&&MENU.parent.visible;};function on_itemHover(obj){var newitem=MENU.children().find(this);if(newitem!=ITEM&&ITEM!=null)MENU.children(ITEM).callHooks("onMouseLeave");ITEM=newitem;obj._applyCompletion(this.userData);};function on_itemSelect(obj){obj._hideMenu();obj._applyCompletion(this.userData,true);obj.applyHooks("onSelect",[this.userData]);};P._applyCompletion=function(c,finish){if(!c.nomodify){var r=this.getSelectionRange();var str=c.completion||c.label;if(finish&&c.after)str+=c.after;var val=this.getValue();var start=c.start!=null?c.start:r.start;val=val.substr(0,start)+str+val.substr(r.end);this.setValue(val);r.end=start+str.length;if(c.rstart!=null)r.start=c.rstart;if(c.noselect||finish)r.start=r.end;this.setSelectionRange(r);}};P.completionReady=function(data){if(this.__timer||this.__forced){if(data!=null&&data.length>0){if(this.__smart&&data.length==1){this._applyCompletion(data[0],true);this.applyHooks("onSelect",[data[0]]);}else{var mnu=_getMenu();data.foreach(function(c){var w=new DlMenuItem({parent:mnu,label:c.label,data:c});w.addEventListener({onSelect:this.__on_itemSelect,onMouseEnter:this.__on_itemHover});},this);_getPopup().popup({timeout:0,content:mnu,align:this.ALIGN,anchor:this.getElement(),isContext:true,widget:this,shift:this._shiftMenu});mnu.children(0).callHooks("onMouseEnter");}}}this.cancelCompletion();};P.cancelCompletion=function(){this.delClass("DlCompletionEntry-busy");this.__clearTimer();this.__forced=null;};function __triggerCompletion(ev,forced){this.__origData={value:this.getValue(),range:this.getSelectionRange()};this.__forced=forced;this.addClass("DlCompletionEntry-busy");this.applyHooks("onCompletion",[this.getSelectionRange(),ev,forced]);};function handleMenuKey(ev){if(!_menuVisible())return false;var old_item=ITEM,w;switch(ev.keyCode){case DlKeyboard.ARROW_UP:if(ITEM==null)ITEM=0;ITEM=MENU.children().rotateIndex(--ITEM);break;case DlKeyboard.ARROW_DOWN:case DlKeyboard.TAB:if(ITEM==null)ITEM=-1;ITEM=MENU.children().rotateIndex(++ITEM);break;case DlKeyboard.ENTER:this.collapse(false);MENU.children(ITEM).callHooks("onSelect");DlException.stopEventBubbling();case DlKeyboard.ESCAPE:this._hideMenu();var d=this.__origData;if(d){this.setValue(d.value);this.setSelectionRange(d.range);}DlException.stopEventBubbling();}if(old_item!=ITEM){if(old_item!=null){w=MENU.children(old_item);w.callHooks("onMouseLeave");}w=MENU.children(ITEM);w.callHooks("onMouseEnter");DlException.stopEventBubbling();}else{this._hideMenu();}};function onKeyDown(ev){if(is_ie)return handleMenuKey.call(this,ev);};P._handle_focusKeys=function(ev){if(!DlKeyboard.KEYS_CONTROL[ev.keyCode]){this._hideMenu();if(this.__timeout!=null)this.__timer=__triggerCompletion.delayed(this.__timeout,this,ev,false);}else if(!is_ie){if(!this.__noTab&&ev.keyCode==DlKeyboard.TAB&&!_menuVisible()&&!this.isEmpty()){__triggerCompletion.call(this,ev,true);ev.domStop=true;DlException.stopEventBubbling();}else{return handleMenuKey.call(this,ev);}}return BASE._handle_focusKeys.call(this,ev);};function onBlur(){this.cancelCompletion();};P.completeFromWords=function(words,args){return D.completeFromWords.call(D,this,words,args);};D.completeFromWords=function(entry,words,args){if(args==null)args={};if(args.sep==null)args.sep=/\s+/g;return function(range){var comp=[],val=entry.getValue(),pos=val.lastIndexOfRegexp(args.sep,range.start);val=val.substring(pos,range.start);if(val){for(var i=0;i<words.length;++i)if(words[i].indexOf(val)==0)comp.push({label:words[i],noselect:args.noselect,after:args.addSep,start:pos});}if(comp.length>0)entry.completionReady(comp);else entry.cancelCompletion();};};})();function DlConsole(){this._messages=[];DlConsole.INSTANCE=this;};DlConsole.prototype={log:function(str){str=str.printf.apply(str,Array.$(arguments,1));this._addMsg({str:str});},line:function(){this._addMsg({str:"&nbsp;",cls:"sep"});},CC:function(text,cn){var div=this.win.document.createElement("div");div.className=cn||"msg";div.innerHTML=text;this.win.document.body.appendChild(div);this.win.scrollTo(0,div.offsetTop+div.offsetHeight);if(this._last)DynarchDomUtils.delClass(this._last,"current");DynarchDomUtils.addClass(div,"current");this._last=div;},_addMsg:function(msg){this._init();if(!this.win)this._messages.push(msg);else this.CC(msg.str,msg.cls);},_init:function(){if(!this.win){window.open(Dynarch.getFileURL("html/dlconsole.html"),"DlConsole","height=400,width=600,menubar=0,toolbar=0,scrollbars=1");}},_loaded:function(win){this._last=null;this.win=win;this.log("<b>DynarchLIB Console</b><br />Initialized at %s",new Date());this.line();this._messages.foreach(this._addMsg,this);}};if(!window.dlconsole){window.dlconsole=new DlConsole();}(function(){var BASE=DlDesktop.inherits(DlContainer);function DlDesktop(args){if(args){D.setDefaults(this,args);DlContainer.call(this,args);}};eval(Dynarch.EXPORT("DlDesktop"));D.DEFAULT_ARGS={_bounds:["bounds",new DlRect(50,30,800,600)]};P._createElement=function(){BASE._createElement.call(this);var div=this.getElement();this._bounds.positionDiv(div);document.body.appendChild(div);};var resizeDivID=Dynarch.ID("IEsux");IEresize=function(){var tmp=document.getElementById(resizeDivID);if(!tmp){tmp=document.createElement("div");tmp.style.position="absolute";tmp.style.right=tmp.style.bottom=tmp.style.width=tmp.style.height="0px";tmp.style.zIndex="-100";document.body.appendChild(tmp);}this.setSize({x:tmp.offsetLeft,y:tmp.offsetTop+tmp.offsetHeight});};P.fullScreen=function(){var s=this.getElement().style;s.top="0px";s.left="0px";s.width="100%";s.height="100%";var handler;if(!is_ie)handler=this.callHooks.$(this,"onResize");else handler=IEresize.$(this);DynarchDomUtils.addEvent(window,"resize",handler.clearingTimeout(25));};})();(function(){var BASE=DlDialog.inherits(DlContainer);function DlDialog(args){if(args){D.setDefaults(this,args);this.__doDrag=this.__moveDelay!=null?__doDrag.clearingTimeout(this.__moveDelay,this):__doDrag.$(this);DlContainer.call(this,args);this.active=false;}};eval(Dynarch.EXPORT("DlDialog",true));var DEFAULT_EVENTS=["onShow","onHide","onQuitBtn"];D.DEFAULT_ARGS={_title:["title","DlDialog"],_fixed:["fixed",false],_resizable:["resizable",false],_focusable:["focusable",true],_iconClass:["iconClass",null],_focusedWidget:["focusDefault",null],__noShadows:["noShadows",false],__quitBtn:["quitBtn",false],__maxBtn:["maxBtn",true],__modal:["modal",false],__moveDelay:["moveDelay",5000]};var HTML=("<table cellspacing='0' cellpadding='0'><tr><td>"+"<div class='DlDialog-Rel'>"+"<div class='DlDialog-WindowButtons'></div>"+"<div class='DlDialog-Title'><div></div></div>"+"<div class='DlDialog-Content'></div>"+"</div>"+"</td></tr></table>");P._setDragCaptures=function(capture){(capture?DlEvent.captureGlobals:DlEvent.releaseGlobals)(this._dragHandlers);};P._setResizeCaptures=function(capture){(capture?DlEvent.captureGlobals:DlEvent.releaseGlobals)(this._resizeHandlers);};function activateCkt(){var ckt=DOM.CE_CACHE["DlDialog.EVENT_STOPPER"];if(!ckt){ckt=DOM.CE_CACHE["DlDialog.EVENT_STOPPER"]=CE("div",null,{className:"DYNARCH-EVENT-STOPPER"},document.body);}ckt.style.visibility="";return ckt;};function deactivateCkt(){var ckt=DOM.CE_CACHE["DlDialog.EVENT_STOPPER"];if(ckt)ckt.style.visibility="hidden";return ckt;};D.activateEventStopper=function(act){return act?activateCkt():deactivateCkt();};function startDrag(ev){if(!this.dragging&&!this.__maximized){this.activate();this.dragging=true;ev||(ev=window.event);var dlev=(ev instanceof DlEvent)?ev:new DlEvent(ev);this.addClass("DlDialog-Dragging");this._dragPos=dlev.computePos(this);this._setDragCaptures(true);AC(document.body,"CURSOR-DRAGGING");activateCkt();if(this.__moveDelay!=null){var div=this.getResizeRect();AC(div,"Dl-ResizeRect-moving");var sz=this.getOuterSize();DOM.setPos(div,dlev.elPos.x,dlev.elPos.y);DOM.setOuterSize(div,sz.x,sz.y);div.style.display="";}if(dlev!==ev)return DOM.stopEvent(ev);}};function startCtrlDrag(ev){if(ev.ctrlKey&&ev.shiftKey){startDrag.call(this,ev);DlException.stopEventBubbling();}};function stopDrag(ev){if(this.dragging){var div=this.getResizeRect();this.dragging=false;this.delClass("DlDialog-Dragging");this._setDragCaptures(false);DC(document.body,"CURSOR-DRAGGING");if(this.__moveDelay!=null){if(ev){var pos=__dragGetPos.call(this,ev);this.__doDrag.doItNow(pos.x,pos.y);}else{this.__doDrag.cancel();}}DC(div,"Dl-ResizeRect-moving");(function(){div.style.display="none";deactivateCkt();}).delayed(1);}};function __dragGetPos(ev){var p=this.parent;if(p)ev.computePos(p.getContentElement());var x=ev.relPos.x-this._dragPos.x,y=ev.relPos.y-this._dragPos.y,sz=this.getOuterSize(),ws=p?p.getInnerSize():DOM.getWindowSize();if(x<0)x=0;else if(x+sz.x>ws.x)x=ws.x-sz.x;if(y<0)y=0;else if(y+sz.y>ws.y)y=ws.y-sz.y;return{x:x,y:y};};function __dragDIV(pos){var x=pos.x,y=pos.y;if(this.parent){pos=DOM.getPos(this.parent.getContentElement());x+=pos.x;y+=pos.y;}DOM.setPos(this.getResizeRect(),x,y);};function __doDrag(x,y){this.setPos(x,y);};function doDrag(ev){var pos=__dragGetPos.call(this,ev);if(this.__moveDelay!=null)__dragDIV.call(this,pos);this.__doDrag(pos.x,pos.y);DlException.stopEventBubbling();};function startResize(ev){if(!this.resizing){this.resizing=true;ev||(ev=window.event);var dlev=(ev instanceof DlEvent)?ev:new DlEvent(ev);this._dragPos=dlev.computePos(this);var sz=this.getOuterSize();this._dragPos.x-=sz.x;this._dragPos.y-=sz.y;var pos=this.getPos();var div=this.getResizeRect();DOM.setPos(div,pos.x,pos.y);DOM.setOuterSize(div,sz.x,sz.y);div.style.display="";this.addClass("DlDialog-Resizing");this._setResizeCaptures(true);AC(document.body,"CURSOR-DRAGGING");activateCkt();DOM.stopEvent(ev);doResize.call(this,dlev,true);}};function stopResize(ev){if(this.resizing){this.disableHooks("onResize");this.getElement().style.overflow="hidden";var div=this.getResizeRect();var sz=DOM.getOuterSize(div);DOM.setPos(div,0,0);div.style.display="none";this.delClass("DlDialog-Resizing");if(!is_gecko)sz.x--;if(this.__noShadows){sz.x-=4;sz.y-=4;}this.setOuterSize({x:sz.x,y:sz.y});if(is_gecko)BASE.setOuterSize.call(this,{x:"auto",y:"auto"});this.resizing=false;this._setResizeCaptures(false);DC(document.body,"CURSOR-DRAGGING");this.getElement().style.overflow="";deactivateCkt();this.enableHooks("onResize");this.callHooks("onResize");}};function doResize(ev,domStop){if(this.resizing){var div=this.getResizeRect();var pos=DOM.getPos(div);pos.x=ev.pos.x-this._dragPos.x-pos.x-1;if(pos.x<100)pos.x=100;pos.y=ev.pos.y-this._dragPos.y-pos.y-1;if(pos.y<100)pos.y=100;if(this._resizable===1)pos.y=null;if(this._resizable===2)pos.x=null;DOM.setInnerSize(div,pos.x,pos.y);if(!domStop)throw new DlExStopEventBubbling;}};var visibleDialogs=[];D.activatePrev=function(){if(visibleDialogs.length>1){visibleDialogs.peek().deactivate();visibleDialogs.unshift(visibleDialogs.pop());top=visibleDialogs.pop();top.activate();}};D.activateNext=function(){if(visibleDialogs.length>1){visibleDialogs[0].activate();}};D.getActive=function(){return visibleDialogs.peek();};var HIDE_POS={x:-30000,y:-30000};P.setInnerSize=function(sz){BASE.setInnerSize.call(this,sz);};P.setOuterSize=P.setSize=function(sz){if(sz.y!=null)sz.y-=this.getTitleElement().offsetHeight;this.setInnerSize(sz);};P.hide=function(){this.visibility(false);this.__oldDlgPos=this.getOffsetPos();this.setPos(HIDE_POS);};P.show=function(center){if(center)this.centerOnParent();else if(this.__oldDlgPos)this.setPos(this.__oldDlgPos);this.visibility(true);};function setZIndex(){visibleDialogs.r_foreach(function(d,i){var z=(d.__modal?900:500)+i;if(d.parent&&d.parent instanceof D)z+=d.parent.zIndex();d.zIndex(z);});};P.activate=function(){var act=visibleDialogs.peek();if(!this.active){if(act&&act.active&&(act!=this.parent))act.deactivate(true);this.addClass("DlDialog-Active");visibleDialogs.remove(this);visibleDialogs.push(this);setZIndex();this.active=true;this.focus();if(this._focusedWidget&&!this._focusedWidget.destroyed)this._focusedWidget.focus();}};P.deactivate=function(){if(this.active){this.delClass("DlDialog-Active");this.active=false;this.blur();}};var VISIBLE_MODALS=0;function onDisplay(disp,val){var sys=DlSystem();if(disp){this.callHooks("onShow");this.activate();this.setModal(this.__modal);if(this.__modal)++VISIBLE_MODALS;sys.applyHooks("on-dialog-show",[this]);if(this.__maximized)this.__doMaximize();}else{if(this.__modal){if(--VISIBLE_MODALS==0)this.getModalStopper().style.display="none";if(this.parent&&this.parent instanceof D)this.parent.getContentElement().style.position="";}this.callHooks("onHide");this.deactivate();visibleDialogs.remove(this);sys.applyHooks("on-dialog-hide",[this]);if(visibleDialogs.length>=1)visibleDialogs.peek().activate();}if(this.__maximized!=null)this.__maxCondResizeHandlers(disp?this.__maximized:false);};function onDestroy(){this.hide();};function onMouseWheel(ev){if(ev.shiftKey||ev.altKey){var opc=this.__dlgOpacity;if(opc==null)opc=100;if(ev.wheelDelta>0)opc+=0.05;else opc-=0.05;opc=this.__dlgOpacity=opc.limit(0.1,1);this.opacity(opc);throw new DlExStopEventBubbling;}};var MODAL_STOPPER=null;function global_modalStopper(){if(!MODAL_STOPPER)MODAL_STOPPER=CE("div",{display:"none"},{className:"DYNARCH-MODAL-STOPPER"},document.body);return MODAL_STOPPER;};P.getModalStopper=function(){if(this.parent){var p=this.parent,div=p.__modalStopper;if(!div){div=global_modalStopper().cloneNode(true);p.refNode("__modalStopper",div);p.getContentElement().appendChild(div);}return div;}else{return global_modalStopper();}};P._createElement=function(){BASE._createElement.call(this);this.setPos(HIDE_POS);this.visibility(false);this.getElement().innerHTML=HTML;var rel=this.getRelElement();if(!this.__noShadows&&!(this._parent instanceof D)&&(!is_ie||is_ie7))rel.insertBefore(DlElementCache.get("SHADOWS"),rel.firstChild);else{this.__noShadows=true;AC(rel,"DlDialog-noShadows");}this.title(this._title);this.setUnselectable(this.getTitleElement());if(!this._parent)document.body.appendChild(this.getElement());var quitBtn=this.__quitBtn;if(quitBtn){var foo=this.__quitBtn=new DlAbstractButton({parent:this,className:"DlDialog-QuitBtn",appendArgs:this.getButtonsElement(),classes:{hover:"DlDialog-QuitBtn-hover",active:"DlDialog-QuitBtn-active"}});if(quitBtn=="destroy"){quitBtn=this.destroy.$(this);}else if(quitBtn=="hide"){quitBtn=this.hide.$(this);}if(quitBtn instanceof Function)foo.addEventListener("onClick",quitBtn);else foo.connectEvents("onClick",this,"onQuitBtn");}if(this._resizable)this.makeResizable();this.setIconClass(this._iconClass);};P.setIconClass=function(iconClass){var e2=this.getTitleElement().firstChild;CC(e2,iconClass!=null,"DlDialog-Title-withIcon");if(this.iconClass)DC(e2,this.iconClass);if(iconClass)AC(e2,iconClass);this.iconClass=iconClass;};P.maximize=function(c){if(c==null)c=this.__maxBtn.checked();var pos,size;this.__maximized=c;if(c){pos=this.getOffsetPos();size=this.getSize();this.__maximizeSavePos={pos:pos,size:size};}this.condClass(c,"DlDialog-Maximized");if(c){this.__doMaximize();}else{pos=this.__maximizeSavePos;size=pos.size;pos=pos.pos;this.setOuterSize({x:size.x,y:size.y});this.setPos(pos.x,pos.y);}this.__maxBtn.checked(c,true);this.__maxCondResizeHandlers(c);};P.__maxCondResizeHandlers=function(cond){if(cond==null)cond=this.__maximized;if(this.parent){this.parent.condEventListener(cond,"onResize",this.__maxResizeHandler);}else{DOM.condEvent(cond,window,"resize",this.__maxResizeHandler);}};P.__maxResizeHandler=function(){return this.__doMaximize();};P.__doMaximize=function(){this.setPos(0,0);var ws=this.parent?this.parent.getInnerSize():DOM.getWindowSize();if(this.__noShadows){ws.x-=4;ws.y-=4;}this.setOuterSize({x:ws.x,y:ws.y});};P.setModal=function(modal,noset){if(!noset)this.__modal=modal;if(this.display()){var div=this.getModalStopper();div.style.display=modal?"":"none";setZIndex();if(this.parent&&this.parent instanceof D)this.parent.getContentElement().style.position=modal?"relative":"";}};P.makeResizable=function(){if(!this._resizeHandlers){this.getContentElement().style.overflow="hidden";var div=this.getRelElement();var el=CE("div",null,{className:"ResizeHandle"},null);div.insertBefore(el,div.firstChild);this._resizeHandlers={onMouseMove:doResize.$(this),onMouseUp:stopResize.$(this),onMouseOver:DlException.stopEventBubbling,onMouseOut:DlException.stopEventBubbling,onMouseEnter:DlException.stopEventBubbling,onMouseLeave:DlException.stopEventBubbling};DOM.addEvent(el,"mousedown",startResize.$(this));this.resizing=false;if(this.__maxBtn){this.__maxBtn=new DlAbstractButton({parent:this,className:"DlDialog-MaximizeBtn",appendArgs:this.getButtonsElement(),type:DlAbstractButton.TYPE.TWOSTATE,classes:{hover:"DlDialog-MaximizeBtn-hover",active:"DlDialog-MaximizeBtn-active",checked:"DlDialog-MaximizeBtn-1"}});this.__maxResizeHandler=this.__maxResizeHandler.$0(this);this.__maxBtn.addEventListener("onChange",this.maximize.$0(this,null));}}};P.makeDraggable=function(){if(!this._dragHandlers){var el=this.getTitleElement();el.style.cursor="default";this._dragHandlers={onMouseMove:doDrag.$(this),onMouseUp:stopDrag.$(this),onMouseOver:DlException.stopEventBubbling,onMouseOut:DlException.stopEventBubbling,onMouseEnter:DlException.stopEventBubbling,onMouseLeave:DlException.stopEventBubbling};DOM.addEvent(el,"mousedown",startDrag.$(this));this.addEventListener("onMouseDown",startCtrlDrag);this.dragging=false;}};P.title=function(title){if(title!=null){if(title instanceof Array)title=title.join("");this._title=title;this.getTitleElement().firstChild.innerHTML=title;}return this._title;};P._handle_focusKeys=function(ev){if(!ev.altKey&&!ev.ctrlKey){if(ev.keyCode==DlKeyboard.ESCAPE){if(!this.dragging&&this.__quitBtn){this.__quitBtn.keyClicked(ev);}else if(this.dragging){stopDrag.call(this);}}else if(ev.keyCode==DlKeyboard.TAB){var w=ev.focusedWidget;w=ev.shiftKey?this.getPrevFocusWidget(w):this.getNextFocusWidget(w);if(w)w.focus();ev.domStop=true;DlException.stopEventBubbling();}}this._handleKeybinding(ev);};P.initDOM=function(){this.registerEvents(DEFAULT_EVENTS);BASE.initDOM.call(this);if(!this._fixed)this.makeDraggable();this.addEventListener({onMouseDown:this.activate,onMouseWheel:onMouseWheel,onDisplay:onDisplay,onDestroy:onDestroy});};function _el(o,p){var a=o.getRelElement().childNodes;return a[a.length-p];};P.getRelElement=function(){return this.getElement().firstChild.rows[0].cells[0].firstChild;};P.getContentElement=function(){return _el(this,1);};P.getTitleElement=function(){return _el(this,2);};P.getButtonsElement=function(){return _el(this,3);};P.centerOnParent=function(){var sz=this.getOuterSize(),ps;var p=this.getElement().offsetParent;if(p)ps=DOM.getOuterSize(p);else ps=DOM.getWindowSize();this.setPos((ps.x-sz.x)/2,(ps.y-sz.y)/2);};DlWidget.prototype.getParentDialog=function(){var d=this.parent;while(d&&!(d instanceof D))d=d.parent;return d;};})();DlDialogPopup.inherits(DlPopup);function DlDialogPopup(args){if(args){args.autolink=false;args.zIndex=5000;DlPopup.call(this,args);}};(function(){DlDrag.inherits(DlEventProxy);function DlDrag(args){if(args){DlEventProxy.call(this);this.registerEvents(DEFAULT_EVENTS);D.setDefaults(this,args);}};eval(Dynarch.EXPORT("DlDrag"));var DEFAULT_EVENTS=["onDrop"];D.DEFAULT_ARGS={delta:["delta",3],dragging:["_dragging",false],draggingClass:["draggingClass","DlWidget-dragging"],_animArgs:["animation",{length:30,fps:50}],cursor:["cursor",{noDrop:"CURSOR-NO-DROP",okDrop:"CURSOR-DROP"}]};P.dropOK=function(widget,ev,target,inside){this.target=target;return this.canDrop=true;};P._handleDrop=function(src,dest,pos){this.applyHooks("onDrop",[src,dest,pos]);};P.doDrop=function(widget,ev){throw new DlExAbstractBaseClass();};P.startOK=function(widget,ev){return true;};P.moving=function(){};P.reset=function(wasCancel){var el=this.elementCopy;if(el&&el.parentNode){if(wasCancel&&this._animArgs){var anim=new DlAnimation(this._animArgs.length,this._animArgs.fps);var pos=this.startElPos||this.startPos;var cpos=DynarchDomUtils.getPos(el);anim.addEventListener({onUpdate:function(){var y=this.getPos();el.style.left=y.mapInt(cpos.x,pos.x)+"px";el.style.top=y.mapInt(cpos.y,pos.y)+"px";DynarchDomUtils.setOpacity(el,this.t.map(1,0.2));},onStop:function(){DynarchDomUtils.trash(el);el=null;}});anim.start(null,null,"accel_ab");}else el.parentNode.removeChild(el);}this.dragging=false;this.canDrop=false;this.target=null;this.elementCopy=null;this.startPos=null;this.source=null;};P.makeElementCopy=function(widget,ev){var el=this.elementCopy;if(!el){el=this.elementCopy=widget.getElement().cloneNode(true);DynarchDomUtils.addClass(el,"DlWidget-dragged-clone");el.style.top=ev.pos.y+"px";el.style.left=ev.pos.x+"px";document.body.appendChild(el);el.style.width=el.offsetWidth+"px";}return el;};})();(function(){var BASE=DlDragTreeItem.inherits(DlDrag);function DlDragTreeItem(args){if(args){DlDrag.call(this,args);DlDragTreeItem.setDefaults(this,args);}};eval(Dynarch.EXPORT("DlDragTreeItem"));D.DEFAULT_ARGS={_noReparent:["noReparent",false]};var CLASS="DlTreeItem-dropTarget";var CLASS_UPPER="DlTreeItem-dropTarget-upper";var CLASS_LOWER="DlTreeItem-dropTarget-lower";var CLASS_ALL_RE=/DlTreeItem-dropTarget[^\s]*/g;var CLASS_POS_RE=/DlTreeItem-dropTarget-[^\s]*/g;function onExpander(ev){return/DlTree-IconWidth/.test(ev.target.className);};P.startOK=function(widget,ev){return!onExpander(ev);};P.dropOK=function(item,ev,obj,inside){while(obj&&!(obj instanceof DlTreeItem))obj=obj.parent;var ok=!inside&&obj;if(ok)ok=!this._noReparent||item.parent===obj.parent;this.target=ok?obj:null;this.canDrop=!!ok;if(this.oldTarget&&this.oldTarget!==this.target)this.oldTarget.delClass(CLASS_ALL_RE);if(ok)this.target.addClass(CLASS);this.oldTarget=this.target;return ok;};P.doDrop=function(item,ev){if(this._noReparent||onExpander(ev)){var pos=this.target.getIndex();if(!this.dropBefore)++pos;this.target.parent.appendWidget(item,pos);this._handleDrop(item,this.target,this.dropBefore?"before":"after");}else{if(this.target.getSubtreeWidget()!==item.parent){this.target.addSubItem(item);this._handleDrop(item,this.target);}}};P.moving=function(item,ev){var target=this.target;if(this.canDrop&&target&&(this._noReparent||onExpander(ev))){var relPos=ev.computePos(target);var h=target.getDivElement().offsetHeight/2;var upper=relPos.y<=h;target.condClass(upper,CLASS_UPPER,CLASS_LOWER);this.dropBefore=upper;}else if(target){this.dropBefore=null;target.delClass(CLASS_POS_RE);}};P.reset=function(){if(this.target)this.target.delClass(CLASS_ALL_RE);if(this.oldTarget)this.oldTarget.delClass(CLASS_ALL_RE);BASE.reset.apply(this,arguments);this.oldTarget=null;};})();(function(){var BASE=DlTable.inherits(DlContainer);function DlTable(args){if(args){D.setDefaults(this,args);args.tagName="table";this._colSpan=0;DlContainer.call(this,args);}};eval(Dynarch.EXPORT("DlTable",true));D.DEFAULT_ARGS={__cellSpacing:["cellSpacing",null],__cellPadding:["cellPadding",null],__align:["align",null]};P._createElement=function(){BASE._createElement.call(this);var el=this.getElement();if(this.__cellPadding!=null)el.cellPadding=this.__cellPadding;if(this.__cellSpacing!=null)el.cellSpacing=this.__cellSpacing;if(this.__align!=null)el.align=this.__align;CE("tbody",null,null,el);};P.getContentElement=function(){return this.getElement().firstChild;};P.addRow=function(){return new DlTableRow({parent:this});};P.getRow=function(index){return this.children(index);};P.addCell=function(row,align,valign){var cell=new DlTableCell({parent:row});if(align!=null)cell.addClass("DlAlign-"+align);if(valign!=null){var s=cell.getElement().style;s.verticalAlign=valign;}var index=cell.getElement().cellIndex+1;if(index>this._colSpan)this._colSpan=index;return cell;};P.getColSpan=function(){return this._colSpan;};P.setColSpan=function(colSpan){this._colSpan=colSpan;};P.addSeparator=function(span){if(span==null)span=this.getColSpan();CE("div",null,{innerHTML:"&nbsp;"},CE("td",null,{colSpan:span},CE("tr",null,{className:"DlTable-RowSeparator"},this.getContentElement())));};})();DlTableRow.inherits(DlContainer);function DlTableRow(args){if(args){args.tagName="tr";DlContainer.call(this,args);}};DlTableCell.inherits(DlContainer);function DlTableCell(args){if(args){args.tagName="td";DlContainer.call(this,args);}};(function(){var BASE=DlFieldGrid.inherits(DlTable);function DlFieldGrid(args){if(args){DlTable.call(this,args);this.__fields={};}};eval(Dynarch.EXPORT("DlFieldGrid"));P.addField=function(args,opts,ret){var entry=args.widget||new DlEntry(args);var label=args.label;if(!opts)opts={};if(label){if(!(label instanceof DlWidget)){label=new DlLabel({label:args.label.makeLabel(),widget:entry});}else if(label instanceof DlLabel){label.setWidget(entry);}}var row=this.addRow();var c1=this.addCell(row,"right",args.valign);if(args.valign=="top"&&(label instanceof DlLabel))c1.getElement().style.paddingTop="3px";if(label)c1.appendWidget(label);if(opts.middleText){var tmp=this.addCell(row);tmp.setContent(opts.middleText);}var c2=this.addCell(row);c2.appendWidget(entry);if(args.name!=null)this.__fields[args.name]=entry.getWidgetId();if(opts){var el=c2.getElement();if(opts.colSpan)el.colSpan=opts.colSpan;if(opts.rowSpan)el.rowSpan=opts.rowSpan;}if(ret){ret.row=row;ret.c1=c1;ret.c2=c2;ret.label=label;ret.entry=entry;}return entry;};P.getField=function(id){return id?DlWidget.getById(this.__fields[id]):this.__fields;};P.setField=function(name,widget){this.__fields[name]=widget.getWidgetId();};P.getValue=function(){var val={};for(var name in this.__fields){var w=this.getField(name);if(w.getValue instanceof Function){if(w instanceof DlAbstractButton&&w._checkTwoState(true)){var v=w.getValue();if(v==null){val[name]=w.checked();}else if(w.checked()){val[name]=v;}}else{val[name]=w.getValue();}}}return val;};P.getValues=P.getValue;P.setValue=function(hash){for(var name in hash){var w=this.getField(name),v=hash[name];if(w&&w.setValue instanceof Function){if(w instanceof DlAbstractButton&&w._checkTwoState(true)){w.checked(typeof v=="string"?v!="0":!!v);}else{w.setValue(v);}}}};P.setValues=P.setValue;})();(function(){var BASE=DlFieldset.inherits(DlContainer);function DlFieldset(args){if(args){D.setDefaults(this,args);DlContainer.call(this,args);}};eval(Dynarch.EXPORT("DlFieldset",true));D.DEFAULT_ARGS={_label:["label","DlFieldset"]};P._createElement=function(){BASE._createElement.call(this);this.getElement().innerHTML=["<span class='DlFieldset-label'>",this._label,"</span>","<div class='DlFieldset-content'></div>"].join("");};P.getContentElement=function(){return this.getElement().childNodes[1];};P.getLabelElement=function(){return this.getElement().firstChild;};P.setOuterSize=P.setSize=function(sz){var p1=DOM.getPos(this.getLabelElement()),p2=DOM.getPos(this.getContentElement()),diff=p2.y-p1.y;DOM.setOuterSize(this.getElement(),sz.x,sz.y-diff);sz=DOM.getInnerSize(this.getElement());DOM.setOuterSize(this.getContentElement(),sz.x,sz.y);this.callHooks("onResize");};})();(function(){var CTORS={},OBJECTS={};window.DlSingleton={get:function(type,noCreate){return OBJECTS[type]||!noCreate&&(OBJECTS[type]=new CTORS[type]());},register:function(type,ctor,globalize){CTORS[type]=ctor;if(globalize)window[type]=this.get.$C(type);}};})();(function(){var DEFAULT_EVENTS=["onLoad"];DlFlashUtils.inherits(DlEventProxy);function DlFlashUtils(){DlEventProxy.call(this);this.registerEvents(DEFAULT_EVENTS);};var P=DlFlashUtils.prototype;var IE_HTML=String.template('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="1" height="1" id="DlFlashUtils-MOVIE" align="middle">','<param name="allowScriptAccess" value="always" />','<param name="movie" value="$url" />','<param name="quality" value="high" />','</object>');var HTML=String.template('<embed id="DlFlashUtils-MOVIE" src="$url" quality="high" bgcolor="#ffffff" width="1" height="1" ','allowScriptAccess="always" ','type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');var OBJ=null;window.DlFlashUtils_init=function(o){DlSingleton.get("DlFlashUtils").callHooks("onLoad");};P.init=function(){if(!OBJ){var html=(is_ie?IE_HTML:HTML)({url:Dynarch.getFileURL("swf/flash.swf")});document.write("<div style='position: absolute; left: -256px; width: 64px; height: 64px;'>"+html+"</div>");OBJ=document.getElementById('DlFlashUtils-MOVIE');}};P.getObject=function(){return OBJ;};P.isSupported=function(){var p=navigator.plugins;if(p&&p.length){p=p["Shockwave Flash"];if(p&&p.description&&/^Shockwave Flash\s+([^\s]+)/i.test(p.description))return parseFloat(RegExp.$1)>=8;}return false;};P.loadPolicyFile=function(addr){return this.getObject().DlSocket_loadPolicyFile(addr);};DlSingleton.register("DlFlashUtils",DlFlashUtils,true);})();DlFlashStore={set:function(key,val){return DlFlashUtils().getObject().DlStorage_set(key,val);},get:function(key){return DlFlashUtils().getObject().DlStorage_get(key);},remove:function(key){DlFlashUtils().getObject().DlStorage_remove(key);},clear:function(){DlFlashUtils().getObject().DlStorage_clear();},flush:function(){DlFlashUtils().getObject().DlStorage_flush();}};(function(){var BASE=DlGrid.inherits(DlContainer);function DlGrid(args){if(args){D.setDefaults(this,args);if(typeof this._rowType=="string")this._rowType=eval(this._rowType);if(!this._rowType)this._rowType=DlGridRow;if(typeof this._headType=="string")this._headType=eval(this._headType);if(!this._headType)this._headType=DlGridHeadLabel;DlContainer.call(this,args);}};eval(Dynarch.EXPORT("DlGrid",true));var MIN_COL_WID=20;D.DEFAULT_ARGS={_model:["model",null],_selType:["selType","row"],_rowType:["rowType",null],_headType:["headType",null]};var SO=DOM.setOuterSize,SI=DOM.setInnerSize;var HTML=String.buffer("<div class='DlGrid-Headers'>","<table class='DlGrid-Table' cellspacing='0' cellpadding='0'>","<tbody><tr></tr></tbody></table></div>","<div class='DlGrid-Body'>","<table class='DlGrid-Table' cellspacing='0' cellpadding='0'>","<tbody></tbody></table></div>").get();function onBodyScroll(){this.getHeaderDiv().scrollLeft=this.getBodyDiv().scrollLeft;};P._createElement=function(){BASE._createElement.call(this);this._rowsGroup=DlRadioGroup.get();this.setContent(HTML);this.getBodyDiv().onscroll=onBodyScroll.$(this);this._initHeaders();this._initBody();};P.getGroup=function(){return this._rowsGroup;};P.getHeaderDiv=function(){return this.getElement().firstChild;};P.getHandlesDiv=function(){var div=this.getHeaderDiv().childNodes[1];if(!div){div=CE("div",null,{className:"DlGrid-Handles"},this.getHeaderDiv());this._resizeCaptures={onMouseMove:doResize.$(this),onMouseUp:stopResize.$(this),onMouseOver:DlException.stopEventBubbling,onMouseOut:DlException.stopEventBubbling,onMouseEnter:DlException.stopEventBubbling,onMouseLeave:DlException.stopEventBubbling};}return div;};P.getHeaderRow=function(){return this.getHeaderDiv().firstChild.rows[0];};P.getBodyDiv=function(){return this.getElement().childNodes[1];};P.getBodyTable=function(){return this.getBodyDiv().firstChild;};P._onHeadClick=function(){};P._appendWidgetElement=function(w,pos){if(w instanceof this._rowType){var table=this.getBodyTable();if(pos!=null){var row=table.rows[pos];if(row)row.parentNode.insertBefore(w.getElement(),row);else table.firstChild.appendChild(w.getElement());}else{table.firstChild.appendChild(w.getElement());}}else BASE._appendWidgetElement.apply(this,arguments);};P._initHeaders=function(){var onHeadClick=this._onHeadClick.$(this);this._model.foreachCol(function(col){var td=document.createElement("td");this.getHeaderRow().appendChild(td);var btn=this._makeHeadLabel({parent:this,appendArgs:td,iconClass:col.getIconClass(),label:col.getLabel(),column:col,className:"DlGrid-align-"+col.getStyle("textAlign","left"),tooltip:col.tooltip});col._button=btn;btn.addEventListener("onClick",onHeadClick);},this);};P._makeRow=function(args){return new this._rowType(args);};P._makeHeadLabel=function(args){return new this._headType(args);};P._initBody=function(){this._model.foreachRow(function(row){row=this._makeRow({parent:this,group:this._rowsGroup,value:row.id,model:row});},this);this._model.addEventListener({onInsertRow:this._insertRow.$(this),onDeleteRow:this._deleteRow.$(this),onSort:this._sort.$(this)});};P._insertRow=function(row){var index=row.getIndex();row=this._makeRow({parent:this,group:this._rowsGroup,value:row.id,model:row,appendArgs:index});var cells=row.getElement().cells;var head_cells=this.getHeaderRow().cells;for(var i=cells.length;--i>=0;){var td=cells[i];var w=head_cells[i].offsetWidth;SO(td.firstChild,w,null);SI(td,w,null);}};P._deleteRow=function(row){var index=row.getIndex();row=this.getRowByIndex(index);var rows=this.getBodyTable().rows;if(index==0&&rows.length>1){}row.destroy();};P._sort=function(col,prev,desc,a){if(prev){prev._button.delClass("DlGridHeadLabel-sort-up");prev._button.delClass("DlGridHeadLabel-sort-down");}if(col){col._button.condClass(desc,"DlGridHeadLabel-sort-down","DlGridHeadLabel-sort-up");var table=this.getBodyTable(),tbody=table.firstChild,rows=table.rows;a=a.map(function(index){return rows[index];});a.foreach(function(tr){tbody.appendChild(tr);});}};P.__doLayout=function(){var size=this.getInnerSize();var body=this.getBodyDiv();var header=this.getHeaderDiv();SO(body,size.x,size.y-header.offsetHeight);SO(header,size.x,null);header.style.marginRight=-DOM.getScrollbarSize(body).x+"px";if(!this.__hasLayout){this._initColSizes();this.__hasLayout=true;this.getBodyTable().style.width="";}else{this._updateFillCols();}onBodyScroll.call(this);};P.getRowByIndex=function(index){try{return DlWidget.getFromElement(this.getBodyTable().rows[index]);}catch(ex){};};P.getRowById=function(id){return this.getRowByIndex(this._model.getRowById(id).getIndex());};P.getActualColWidth=function(i){return this.getHeaderRow().cells[i].offsetWidth;};P._initColSizes=function(){var h=this.getHeaderDiv().offsetHeight+"px";var x=0;var listWidth=this.getInnerSize().x-DOM.getScrollbarSize(this.getBodyDiv()).x;this._fillCols=[];this._model.foreachCol(function(col){if(!col.fill)x+=col.width||this.getActualColWidth(col.getIndex());else this._fillCols.push(col);},this);var fillWidth=listWidth-x;x=0;function doIt(col){var w=col.fill?Math.floor(fillWidth*col.fill):(col.width||this.getActualColWidth(col.getIndex()));w=this.setColSize(col,w,true);x+=w;if(col.isResizable&&!col._resizeHandle){var div=CE("div",{"left":x+"px",height:h},{className:"DlGrid-resizeHandle"},this.getHandlesDiv());if(is_ie)DOM.setUnselectable(div,true);div.dl_resizeCol=col;col._resizeHandle=div;div.onmousedown=startResize.$(this,div,col);}};this._model.foreachCol(doIt,this);};P._resetSizeToRow=function(tr2,tr1,del){if(!tr1)tr1=this.getBodyTable().rows[0];if(tr1!==tr2){var cells1=tr1.cells,cells2=tr2.cells;for(var i=0;i<cells1.length;++i){var td1=cells1[i],div1=td1.firstChild;var td2=cells2[i],div2=td2.firstChild;td2.style.width=td1.style.width;div2.style.width=div1.style.width;if(!del){td1.style.width="";div1.style.width="";}}}};P.setColSize=function(col,w,noUpdate){var btn=col._button;if(w!=null){btn.setOuterSize({x:w});var td=btn.getElement().parentNode;SO(td,w,null);}var row=this.getBodyTable().rows[0];w=btn.getOuterSize().x;col=col.getIndex();Array.$(this.getBodyTable().rows).foreach(function(row){if(row){td=row.cells[col];SO(td.firstChild,w,null);SI(td,w,null);}});onBodyScroll.call(this);if(!noUpdate)this._updateResizeHandles();return w;};P._updateFillCols=function(diff){if(diff==null){var body=this.getBodyDiv();diff=this.getHeaderRow().offsetWidth-body.offsetWidth+DOM.getScrollbarSize(body).x;}this._fillCols.foreach(function(col){var w=this.getActualColWidth(col.getIndex());w-=Math.round(col.fill*diff);this.setColSize(col,w);},this);};P._updateResizeHandles=function(){this._model.foreachCol(function(col){if(col._resizeHandle){var td=col._button.getElement().parentNode;col._resizeHandle.style.left=td.offsetLeft+td.offsetWidth+"px";}});};P._handle_focusKeys=function(ev){var g=this.getGroup(),row=ev.focusedWidget;switch(ev.keyCode){case DlKeyboard.ARROW_UP:case DlKeyboard.ARROW_DOWN:case DlKeyboard.PAGE_UP:case DlKeyboard.PAGE_DOWN:var wid=(ev.keyCode==DlKeyboard.ARROW_UP||ev.keyCode==DlKeyboard.PAGE_UP)?this.getPrevRow(row):this.getNextRow(row);if(wid){wid.focus();if(ev.shiftKey&&this._selType=="multiple"){g.maxChecked(null);row.checked(true);wid.checked(true);}else if(this._selType!="multiple"){g.maxChecked(1);wid.checked(true);}}else if(ev.shiftKey||ev.ctrlKey){row.checked(true);}ev.domStop=true;DlException.stopEventBubbling();break;case DlKeyboard.HOME:case DlKeyboard.END:var wid=ev.keyCode==DlKeyboard.HOME?this.getRowByIndex(0):this.getRowByIndex(this.getBodyTable().rows.length-1);if(wid){wid.focus();ev.domStop=true;if(this._selType!="multiple"){ev.keyCode=DlKeyboard.ENTER;wid._handle_focusKeys(ev);}DlException.stopEventBubbling();}break;}return BASE._handle_focusKeys.call(this,ev);};function startResize(div,col,ev){if(!ev)ev=window.event;var pos=div.offsetLeft;var bar=DlResizeBar.getDragBar(),s=bar.style;s.left=pos-this.getBodyDiv().scrollLeft+1+"px";s.height="100%";s.width=div.offsetWidth-2+"px";s.top="0px";this.getElement().appendChild(bar);var es=DlDialog.activateEventStopper(true);DOM.addClass(es,"CURSOR-RESIZE-E");DlEvent.captureGlobals(this._resizeCaptures);var dev=new DlEvent(ev);this._resize={div:div,col:col,pos:pos,orig:this.getActualColWidth(col.getIndex()),mouse:dev.pos.x};DOM.stopEvent(ev);};function doResize(ev){var bar=DlResizeBar.getDragBar();var left=this._resize.pos+ev.pos.x-this._resize.mouse;var diff=left-this._resize.pos;var w=this._resize.orig+diff;if(w<MIN_COL_WID){left+=MIN_COL_WID-w;w=MIN_COL_WID;}left-=this.getBodyDiv().scrollLeft;bar.style.left=left+1+"px";};function stopResize(ev){var left=this._resize.pos+ev.pos.x-this._resize.mouse;var diff=left-this._resize.pos;var w=this._resize.orig+diff;if(w<MIN_COL_WID){left+=MIN_COL_WID-w;w=MIN_COL_WID;}diff=w-this._resize.orig;this.setColSize(this._resize.col,w);this._updateFillCols(diff);this.getElement().removeChild(DlResizeBar.getDragBar());DlEvent.releaseGlobals(this._resizeCaptures);var es=DlDialog.activateEventStopper(false);DOM.delClass(es,"CURSOR-RESIZE-E");};P.getNextRow=function(row){return this.getRowByIndex(row.getModel().getIndex()+1);};P.getPrevRow=function(row){return this.getRowByIndex(row.getModel().getIndex()-1);};})();(function(){var BASE=DlGridRow.inherits(DlAbstractButton);function DlGridRow(args){if(args){this._customMoveKeys=true;D.setDefaults(this,args);DlAbstractButton.call(this,args);}};eval(Dynarch.EXPORT("DlGridRow",true));D.DEFAULT_ARGS={_tagName:["tagName","tr"],_classes:["classes",{active:"DlGridRow-active",hover:"DlGridRow-hover",checked:"DlGridRow-1",unchecked:"DlGridRow-0",empty:"DlGridRow-empty",disabled:"DlGridRow-disabled"}],_btnType:["type",DlButton.TYPE.TWOSTATE],_model:["model",null],_focusable:["focusable",true],__tooltip:["tooltip",getTooltip]};function getTooltip(){var row=this.args.widget;return row.getModel().tooltip;};P.getModel=function(){return this._model;};function onDestroy(){this._model.removeEventListener("onChange",this._on_modelChange);};P._onClick=function(ev){this.parent.getGroup().maxChecked(ev.ctrlKey&&this.parent._selType=="multiple"?null:1);BASE._onClick.call(this,ev);};P._handle_focusKeys=function(ev){var p=this.parent,g=p.getGroup();if(ev.keyCode==DlKeyboard.ENTER){g.maxChecked(ev.shiftKey||ev.ctrlKey&&p._selType=="multiple"?null:1);this.applyHooks("onClick",[ev]);ev.domStop=true;}else{return BASE._handle_focusKeys.call(this,ev);}};P._createElement=function(){DlWidget.prototype._createElement.call(this);var tr=this.getElement();this._model.foreachCell(function(cell,col){var td=CE("td",null,null,tr);displayCell(td,cell,col);},this);this._on_modelChange=this._on_modelChange.$(this);this._model.addEventListener("onChange",this._on_modelChange);this.addEventListener("onDestroy",onDestroy);};P._on_modelChange=function(row,cell,what,val){switch(what){case "value":displayCell(this.getElement().cells[cell.getIndex()],cell,this._model.model.getColByIndex(cell.getIndex()));break;}};function displayCell(td,cell,col){if(!td.firstChild){td.innerHTML='<div class="DlGrid-cellData">'+cell.getContent()+'</div>';}else{td.firstChild.innerHTML=cell.getContent();}td.className="DlGrid-align-"+cell.getStyle("textAlign",col.getStyle("textAlign","left"));};})();(function(){var BASE=DlGridHeadLabel.inherits(DlButton);function DlGridHeadLabel(args){if(args){this.column=args.column;args.focusable=false;this.__withIconClass="DlButton-withIcon";DlButton.call(this,args);if(!this.column.isSortable)this.__disabled=true;}};eval(Dynarch.EXPORT("DlGridHeadLabel"));P.setWidth=function(w){this.setOuterSize({x:w});};P.label=function(label){this.setContent("<div class='DlButton-Label'>"+this._label+"</div>");};P._onClick=function(){this.column.sort();};D.DEFAULT_ARGS={_classes:["classes",{active:"DlGridHeadLabel-active",hover:"DlGridHeadLabel-hover",checked:"DlGridHeadLabel-1",unchecked:"DlGridHeadLabel-0",empty:"DlGridHeadLabel-empty",disabled:"DlGridHeadLabel-disabled"}]};})();(function(){var BASE=DlLayout.inherits(DlContainer);function DlLayout(args){if(args){D.setDefaults(this,args);DlContainer.call(this,args);}};eval(Dynarch.EXPORT("DlLayout"));D.DEFAULT_ARGS={_outerSpace:["outerSpace",0],_fillParent:["fillParent",true]};D.setFill=function(widget,fill){var oldfill=widget._dllayout_args.fill;widget._dllayout_args.fill=fill;if(fill!=oldfill)widget.parent.doLayout();};D.getArgs=function(widget){return widget._dllayout_args;};P._appendWidgetElement=function(w,pos){var div=DynarchDomUtils.createElement("div",null,{className:"DlLayout-positioned"},this.getElement());if(pos.zIndex)div.style.zIndex=pos.zIndex;if(pos.overflow)div.style.overflow=pos.overflow;div.appendChild(w.getElement());w._dllayout_args=pos;};P._removeWidgetElement=function(w){if(this._widgets.contains(w)){var el=w.getElement();if(el.parentNode){el.parentNode.parentNode.removeChild(el.parentNode);el.parentNode.removeChild(el);}}};P.packWidget=function(w,args){this.appendWidget(w,args);};P.doLayout=function(){var full_size=this.getInnerSize();var left,right,bottom,top;var OS=this._outerSpace;function reinit(){if(typeof OS=="number")left=right=bottom=top=OS;else if(OS instanceof Array){top=OS[0];right=OS[1];bottom=OS[2];left=OS[3];}else{top=OS.top||0;right=OS.right||0;bottom=OS.bottom||0;left=OS.left||0;}};reinit();var wa=this._widgets;var info=new Array(wa.length);var margins={};for(var i=0;i<wa.length;++i){var w=wa[i];var div=w.getElement().parentNode;var args=w._dllayout_args;var space_before=args.before=args.before||0;var space_after=args.after=args.after||0;var fill=args.fill;if(args.resetSize){w.getElement().style.height="";w.getElement().style.width="";}var ws=w.getOuterSize();switch(args.pos){case "top":top+=space_before;if(fill==null)fill=ws.y;info[i]={sy:fill};if(typeof fill=="number")top+=fill;top+=space_after;break;case "right":right+=space_before;if(fill==null)fill=ws.x;info[i]={sx:fill};if(typeof fill=="number")right+=fill;right+=space_after;break;case "bottom":bottom+=space_before;if(fill==null)fill=ws.y;info[i]={sy:fill};if(typeof fill=="number")bottom+=fill;bottom+=space_after;break;case "left":left+=space_before;if(fill==null)fill=ws.x;info[i]={sx:fill};if(typeof fill=="number")left+=fill;left+=space_after;break;}info[i].w=w;info[i].args=args;info[i].div=div;}var remaining_x=full_size.x-left-right;var remaining_y=full_size.y-top-bottom;reinit();info.foreach(function(info,i){var args=info.args;var w=info.w;if(!w.display())return;switch(args.pos){case "top":case "bottom":if(typeof info.sy!="number"){if(info.sy=="*"){info.sy=remaining_y;}else if(/%/.test(info.sy)){info.sy=Math.floor(parseFloat(info.sy)*remaining_y/100);}if(args.min!=null&&info.sy<args.min)info.sy=args.min;if(args.max!=null&&info.sy>args.max)info.sy=args.max;remaining_y-=info.sy;}break;case "left":case "right":if(typeof info.sx!="number"){if(info.sx=="*"){info.sx=remaining_x;}else if(/%/.test(info.sx)){info.sx=Math.floor(parseFloat(info.sx)*remaining_x/100);}if(args.min!=null&&info.sx<args.min)info.sx=args.min;if(args.max!=null&&info.sx>args.max)info.sx=args.max;remaining_x-=info.sx;}break;}function doHAlign(){};function doVAlign(){var y=top;var h=full_size.y-top-bottom;var s={x:info.sx};switch(args.valign){case "top":break;case "center":y+=(h-w.getOuterSize().y)/2;break;case "bottom":y+=h-w.getOuterSize().y;default:s.y=h;}info.div.style.top=y+"px";w.setSize(s);};switch(args.pos){case "top":top+=args.before;info.div.style.left=left+"px";info.div.style.top=top+"px";w.setSize({x:full_size.x-left-right,y:info.sy});top+=info.sy+args.after;break;case "bottom":bottom+=args.before;info.div.style.left=left+"px";info.div.style.top=full_size.y-bottom-info.sy+"px";w.setSize({x:full_size.x-left-right,y:info.sy});bottom+=info.sy+args.after;break;case "left":left+=args.before;info.div.style.left=left+"px";doVAlign();left+=info.sx+args.after;break;case "right":right+=args.before;info.div.style.left=full_size.x-right-info.sx+"px";doVAlign();right+=info.sx+args.after;break;}});};P.__doLayout=function(){this.doLayout();};P.sizeToFit=function(){var wa=this._widgets;var height=0,width=0;for(var i=0;i<wa.length;++i){var w=wa[i];var args=w._dllayout_args;var ws=w.getOuterSize();switch(args.pos){case "top":case "bottom":height+=ws.y;if(ws.x>width)width=ws.x;break;case "left":case "right":width+=ws.x;if(ws.h>height)height=ws.h;break;}}this.setOuterSize({x:width,y:height});};})();(function(){var BASE=DlGridLayout.inherits(DlLayout);function DlGridLayout(args){if(args){D.setDefaults(this,args);DlLayout.call(this,args);}};eval(Dynarch.EXPORT("DlGridLayout",true));D.DEFAULT_ARGS={__layout:["layout",null],__layoutHTML:["layoutHTML",null],__cellSpacing:["cellSpacing",0],__cellPadding:["cellPadding",1]};var CELL_STYLE_PROPS=["width","padding","paddingLeft","paddingRight","paddingTop","paddingBottom","verticalAlign","textAlign","whiteSpace"];P._createElement=function(){BASE._createElement.call(this);var table;if(!this.__layoutHTML){table=CE("table",null,{cellSpacing:this.__cellSpacing,cellPadding:this.__cellPadding,className:"DlGridLayout-table"});CE("tbody",null,null,table);var rows=this.__layout;rows.foreach(function(row){var row_props=row.props;var tr=table.insertRow(-1);if(row_props&&row_props.minHeight){AC(tr,"DlGridLayout-tr-minHeight");tr.minHeight=true;}row.cells.foreach(function(cell,i){var td=tr.insertCell(-1);if(i==0&&row_props&&row_props.height){td.style.height=row_props.height;}if(cell){if(cell.colSpan)td.colSpan=cell.colSpan;if(cell.className)td.className=cell.className;if(cell.rowSpan)td.rowSpan=cell.rowSpan;if(cell.minWidth)AC(td,"DlGridLayout-td-minWidth");if(cell.minHeight){td.minHeight=true;AC(td,"DlGridLayout-td-minHeight");}CELL_STYLE_PROPS.r_foreach(function(prop){var val=cell[prop];if(val!=null)this[prop]=val;},td.style);}});});this.getElement().appendChild(table);}else{this.setContent(this.__layoutHTML);table=this.getElement().getElementsByTagName("table")[0];}this.refNode("__table",table);};P._appendWidgetElement=function(w,pos){if(pos.inCell){var td=this.getCellElement(pos.row,pos.col);td.appendChild(w.getElement());w._dllayout_args=pos;}else BASE._appendWidgetElement.call(this,w,pos);};P._removeWidgetElement=function(w){if(this._widgets.contains(w)){if(!w._dllayout_args.inCell)BASE._removeWidgetElement.call(this,w);else{var el=w.getElement();el.parentNode.removeChild(el);}}};P.getTableElement=function(){return this.__table;};P.getCellElement=function(row,col){return this.getTableElement().rows[row].cells[col];};P.doLayout=function(){var wa=this.children();(2).times(function(iteration){wa.foreach(function(wid){var pos=wid._dllayout_args;if(!pos.inCell){var td=this.getCellElement(pos.row,pos.col);var x=td.offsetLeft,y=td.offsetTop;var w=td.offsetWidth,h=td.offsetHeight;if(iteration==0){var sz=wid.getOuterSize();if((td.minHeight||td.parentNode.minHeight)&&h<sz.y){td.style.height=sz.y+"px";}}else{var div=wid.getElement().parentNode.style;div.left=x+"px";div.top=y+"px";wid.setOuterSize({x:w,y:h});}}},this);},this);};P.showWidgets=function(show){if(arguments.length==0)show=true;this.children().r_foreach(function(w){w.display(show);});};})();(function(){DlGridCellModel.inherits(DlEventProxy);function DlGridCellModel(args){if(arguments.length>0){DlEventProxy.call(this);if(typeof args!="object")args={value:args};DlGridCellModel.setDefaults(this,args);this.registerEvents(DEFAULT_EVENTS);}};eval(Dynarch.EXPORT("DlGridCellModel"));var DEFAULT_EVENTS=["onChange"];D.DEFAULT_ARGS={_value:["value",null],_style:["style",{}]};P.setValue=function(val){var oldVal=this._value;this._value=val;this.applyHooks("onChange",[this,"value",val,oldVal]);};P.getContent=function(){return this._value;};P.getStyle=function(key,def){if(key in this._style)return this._style[key];return def;};P.getIndex=function(){return this.index;};P.getId=function(){return this.model.getColByIndex(this.index).id;};P.setStyle=function(key,val){var oldval=this._style[key];this._style[key]=val;this.applyHooks("onChange",[this,"style",val,oldval,key]);};P.compareTo=function(cell){return this._value<cell._value?-1:(this._value>cell._value?1:0);};})();(function(){DlGridColModel.inherits(DlEventProxy);function DlGridColModel(args){if(arguments.length>0){DlEventProxy.call(this);DlGridColModel.setDefaults(this,args);this.registerEvents(DEFAULT_EVENTS);if(typeof this._cellType=="string")this._cellType=eval(this._cellType);}};eval(Dynarch.EXPORT("DlGridColModel"));var DEFAULT_EVENTS=["onChange"];D.DEFAULT_ARGS={width:["width",null],fill:["fill",false],_label:["label",null],id:["id",null],_cellType:["cellType",DlGridCellModel],isResizable:["resizable",false],isScrollable:["scrollable",true],isSortable:["sortable",true],tooltip:["tooltip",null],_style:["style",{}],_iconClass:["iconClass",null]};P.getId=function(){return this.id;};P.getIndex=function(){return this.index;};P.getIconClass=function(){return this._iconClass;};P.setIconClass=function(iconClass){var oldval=this._iconClass;this._iconClass=iconClass;this.applyHooks("onChange",[this,"iconClass",val,oldval]);};P.getLabel=function(){return this._label;};P.setLabel=function(label){var oldval=this._label;this._label=label;this.applyHooks("onChange",[this,"label",val,oldval]);};P.getCellType=function(){return this._cellType;};P.createCell=function(args){var cell=new this._cellType(args);return cell;};P.getStyle=function(key,def){if(key in this._style)return this._style[key];return def;};P.setStyle=function(key,val){var oldval=this._style[key];this._style[key]=val;this.applyHooks("onChange",[this,"style",val,oldval,key]);};P.sort=function(){this.model.sort(this);};P.compareRows=function(a,b){var index=this.getIndex();a=a.getCellByIndex(index);b=b.getCellByIndex(index);return a.compareTo(b);};})();(function(){DlGridRowModel.inherits(DlEventProxy);function DlGridRowModel(args){if(arguments.length>0){if(args instanceof Array){var tmp={id:args.id,model:args.model,cells:{}};args.model.foreachCol(function(col,i){tmp.cells[col.getId()]=args[i];});args=tmp;}DlEventProxy.call(this);D.setDefaults(this,args);this.registerEvents(DEFAULT_EVENTS);this._init();}};eval(Dynarch.EXPORT("DlGridRowModel"));var DEFAULT_EVENTS=["onChange"];D.DEFAULT_ARGS={id:["id",null],userData:["data",null],_cells:["cells",null],_model:["model",null],tooltip:["tooltip",null]};P.reset=function(r){this.id=r.id;this.userData=r.data;this.tooltip=r.tooltip;this.foreachCell(function(cell,col){cell.setValue(r.cells[col.getId()]);});};P.getId=function(){return this.id;};P.getIndex=function(){return this.index;};P.getCells=function(){return this._cells;};P.getCellByIndex=function(index){return this._cells[this.model.getColByIndex(index).getId()];};P.foreachCell=function(f,obj){this.model.foreachCol(function(col,index){var cell=this._cells[col.getId()];f.apply(obj,[cell,col,index]);},this);};P._onCellChange=function(cell,what,newval,oldval){this.applyHooks("onChange",[this,cell,what,newval,oldval]);};P._init=function(){var grid=this._model,c=this._cells;this.model=grid;delete this._model;var onChange=this._onCellChange.$(this);for(var i in c){var cell=c[i];var col=grid.getColById(i);cell=c[i]=col.createCell(cell);cell.model=grid;cell.colId=i;cell.index=col.getIndex();cell.parent=this;cell.addEventListener("onChange",onChange);}};})();(function(){DlGridModel.inherits(DlEventProxy);function DlGridModel(args){if(arguments.length>0){DlEventProxy.call(this);DlGridModel.setDefaults(this,args);this.registerEvents(DEFAULT_EVENTS);this._init();}};eval(Dynarch.EXPORT("DlGridModel"));var DEFAULT_EVENTS=["onInsertRow","onDeleteRow","onInsertCol","onInsertCol","onMoveRow","onMoveCol","onRowChange","onColChange","onSort"];D.DEFAULT_ARGS={_rows:["rows",[]],_cols:["cols",null]};P.getRowById=function(id){return this._rowsById[id];};P.getRowByIndex=function(i){return this._rows[i];};P.foreachRow=function(){return this._rows.foreach.apply(this._rows,arguments);};P.foreachCol=function(){return this._cols.foreach.apply(this._cols,arguments);};P.getColById=function(id){return this._colsById[id];};P.getColByIndex=function(i){return this._cols[i];};P._init=function(){this.__sortCol=null;this.__sortDesc=false;var cid=this._colsById={};var rid=this._rowsById={};this._onRowChange=this._onColChange.$(this);this._onRowChange=this._onRowChange.$(this);this._cols.r_assign_each(function(i,col){col=new DlGridColModel(col);col.model=this;col.index=i;col.addEventListener("onChange",this._onColChange);if(col.id)cid[col.id]=col;return col;},this);this._rows.r_assign_each(function(i,row){row.model=this;row=new DlGridRowModel(row);row.index=i;row.addEventListener("onChange",this._onRowChange);if(row.id)rid[row.id]=row;return row;},this);};P._onColChange=function(col,what,newval,oldval){this.applyHooks("onColChange",[this,col,what,newval,oldval]);};P._onRowChange=function(row,cell,what,newval,oldval){this.applyHooks("onRowChange",[this,row,cell,what,newval,oldval]);};P._getInsertPos=function(row){var col=this.__sortCol;return this._rows.foreach(function(r,i){var cmp=col.compareRows(r,row);if(this.__sortDesc)cmp=-cmp;if(cmp>=0)$RETURN(i);},this);return this._rows.length;};P.insertRow=function(row,pos){row.model=this;row=new DlGridRowModel(row);var r=this._rows,l=r.length;if(pos==null||pos==-1){pos=this.__sortCol?this._getInsertPos(row):l;}r.splice(pos,0,row);++l;for(var i=pos;i<l;++i)r[i].index=i;row.addEventListener("onChange",this._onRowChange);if(row.id)this._rowsById[row.id]=row;this.applyHooks("onInsertRow",[row]);return row;};P.deleteRowById=function(id){this.deleteRowByIndex(this.getRowById(id).getIndex());};P.deleteRowByIndex=function(index){var r=this._rows,row=r[index];if(row.id)delete this._rowsById[row.id];r.splice(index,1);for(var i=index;i<r.length;++i)r[i].index=i;row.removeEventListener("onChange",this._onRowChange);this.applyHooks("onDeleteRow",[row]);row.destroy();return row;};P.setValues=function(rows){this.__sortDesc=false;this.applyHooks("onSort",[null,this.__sortCol]);rows.foreach(function(r,i){if(r instanceof Array)r={cells:r};var row=this.getRowByIndex(i);if(row){if(row.id)delete this._rowsById[row.id];if(r.id)this._rowsById[r.id]=row;row.reset(r);}else{this.insertRow(r,this._rows.length);}},this);while(rows.length<this._rows.length)this.deleteRowByIndex(this._rows.length-1);};P.sort=function(col){var prevCol=this.__sortCol;if(prevCol===col)this.__sortDesc=!this.__sortDesc;else this.__sortDesc=false;this.__sortCol=col;var index=col.getIndex();this._rows=this._rows.mergeSort(function(r1,r2){return col.compareRows(r1,r2);},this.__sortDesc);var a=this._rows.map(function(row,i){var tmp=row.index;row.index=i;return tmp;});this.applyHooks("onSort",[col,prevCol,this.__sortDesc,a]);};})();DlHtmlUtils={_blockTags:("body form textarea fieldset ul ol dl li div blockquote "+"p h1 h2 h3 h4 h5 h6 quote pre table thead "+"tbody tfoot tr td iframe address").hashWords(),_quickTags:"br hr input link meta img".hashWords(),_headingTags:"h1 h2 h3 h4 h5 h6".hashWords(),_descTags:"p blockquote td div li".hashWords(),isBlockElement:function(el){return el&&el.nodeType==1&&(el.tagName.toLowerCase()in DlHtmlUtils._blockTags);},needsClosingTag:function(el){return el&&el.nodeType==1&&!(el.tagName.toLowerCase()in DlHtmlUtils._quickTags);},htmlEncode:function(s){return s.htmlEscape();},getHTML:function(root,outputRoot,withMeta){var D=DlHtmlUtils;var html=[];var hi=0;var needsClosingTag=D.needsClosingTag;var htmlEncode=D.htmlEncode;var getText=D.getInnerText;var title=null;var description=null;var content_start=null;var descTags=D._descTags;var headingTags=D._headingTags;var newlineMode=0;function rec(root,outputRoot){switch(root.nodeType){case 11:outputRoot=false;case 1:var tag=root.tagName.toLowerCase();if(root.className=="DynarchLIB-REMOVE-ME")break;if(outputRoot){var closed=!(root.hasChildNodes()||needsClosingTag(root));if(tag=="br"){if(root.previousSibling&&!root.nextSibling)break;if(newlineMode){html[hi++]="\n";break;}}if(withMeta){if(title==null&&tag in headingTags){title=getText(root);content_start=0;}else if(description==null&&tag in descTags){description=getText(root);}}html[hi++]="<";html[hi++]=tag;var attrs=root.attributes;for(var i=0;i<attrs.length;++i){var a=attrs.item(i);if(!a.specified)continue;var name=a.nodeName.toLowerCase();if(/^_moz|^_msh/.test(name))continue;var value;if(name!="style"){if(typeof root[a.nodeName]!="undefined"&&name!="href"&&name!="src"&&!/^on/.test(name))value=root[a.nodeName];else value=a.nodeValue;}else value=root.style.cssText;if(/(_moz|^$)/.test(value))continue;html[hi++]=" "+name+'="'+value+'"';}html[hi++]=closed?" />":">";}if(tag=="pre")++newlineMode;for(i=root.firstChild;i;i=i.nextSibling)rec(i,true);if(tag=="pre")--newlineMode;if(outputRoot&&!closed)html[hi++]="</"+tag+">";if(content_start===0)content_start=hi;break;case 3:if(/^(script|style)$/i.test(root.parentNode.tagName)){if(root.data.indexOf("/*<![CDATA[*/")!=0){html[hi++]="/*<![CDATA[*/";html[hi++]=root.data;html[hi++]="/*]]>*/";}else{html[hi++]=root.data;}}else html[hi++]=htmlEncode(root.data);break;case 4:case 8:html[hi++]="<!--";html[hi++]=root.data;html[hi++]="-->";break;}};rec(root,outputRoot);var content=html.join("");if(withMeta){content={title:title,description:description,content:content,contentButTitle:""};if(content_start)content.contentButTitle=html.slice(content_start).join("");}return content;},getInnerText:function(el){if(el.innerText!=null)return el.innerText;if(el.textContent!=null)return el.textContent;},getText:function(node){var tmp=node.cloneNode(true);var a=tmp.getElementsByTagName("*");for(var i=a.length;--i>=0;){var el=a[i];if(DlHtmlUtils.isBlockElement(el)){var sep=el.ownerDocument.createTextNode(" ");el.insertBefore(sep,el.firstChild);el.appendChild(sep.cloneNode(true));}}var txt=DlHtmlUtils.getInnerText(tmp);DynarchDomUtils.trash(tmp);return txt;},_can_t_DeleteFull_tags:"td".hashWords(),canDeleteFullNode:function(tag){return!(tag.toLowerCase()in DlHtmlUtils._can_t_DeleteFull_tags);},_can_t_DeleteContent_tags:"ul ol dd table tr img br hr".hashWords(),canDeleteContent:function(tag){return!(tag.toLowerCase()in DlHtmlUtils._can_t_DeleteContent_tags);},_can_t_StripNode_tags:"ul ol li dd dt dl img br hr table tr td object applet iframe form textarea".hashWords(),canStripNode:function(tag){return!(tag.toLowerCase()in DlHtmlUtils._can_t_StripNode_tags);}};DlIconListView.inherits(DlContainer);function DlIconListView(args){if(args)DlContainer.call(this,args);};(function(){var CLS={active:"DlIconListItem-active",hover:"DlIconListItem-hover",checked:"DlIconListItem-1",unchecked:"DlIconListItem-0",empty:"DlIconListItem-empty",disabled:"DlIconListItem-disabled"};var BASE=DlIconListItem.inherits(DlAbstractButton);function DlIconListItem(args){if(args){DlIconListItem.setDefaults(this,args);DlAbstractButton.call(this,args);}};eval(Dynarch.EXPORT("DlIconListItem"));D.DEFAULT_ARGS={__itemSize:["itemSize",{x:100,y:null}],__itemSpacing:["itemSpacing",0],__spaceEvenly:["spaceEvenly",false],__iconSize:["iconSize",{x:40,y:40}],__iconAbove:["iconAbove",true],_btnType:["type",DlAbstractButton.TYPE.TWOSTATE],_tagName:["tagName","table"],_classes:["classes",CLS],_iconClass:["iconClass",null]};var ICON_LABEL_CLASSES=["DlIconListItem-iconCell","DlIconListItem-labelCell"];P._createElement=function(){DlWidget.prototype._createElement.call(this);var table=this.getElement();table.cellSpacing=table.cellPadding=0;if(this.__spaceEvenly)table.style.margin=this.__itemSpacing+"px";else table.style.marginRight=table.style.marginBottom=this.__itemSpacing+"px";table.insertRow(-1).insertCell(-1);table.insertRow(-1).insertCell(-1);table.align="left";this.setIconAbove(this.__iconAbove,true);this.setIconClass(this._iconClass);this.label(this._label,true);this.setIconSize(this.__iconSize);this._updateState();};P.setIconClass=function(className){this.getIconCell().className=ICON_LABEL_CLASSES[0]+" "+className;};P.getIconCell=function(){return this.getElement().rows[this.__iconAbove?0:1].cells[0];};P.getLabelCell=function(){return this.getElement().rows[this.__iconAbove?1:0].cells[0];};P.setIconSize=function(sz){DynarchDomUtils.setInnerSize(this.getIconCell(),sz.x,sz.y);this.__iconSize=sz;};P.getIconSize=function(){return this.__iconSize;};P.setIconAbove=function(ia,init){var rows=this.getElement().rows;if(init){rows[0].cells[0].className=ICON_LABEL_CLASSES[ia?0:1];rows[1].cells[0].className=ICON_LABEL_CLASSES[ia?1:0];}else if(ia!==this.__iconAbove){rows[1].parentNode.insertBefore(rows[1],rows[0]);}this.__iconAbove=ia;};P.label=function(label,force){if(label!=null&&(force||label!==this._label)){this._label=label;this.getLabelCell().innerHTML=String.buffer("<div class='DlIconListItem-labelDiv' style='width:",this.__itemSize.x,"px'>",label,'</div>').get();this.applyHooks("onUpdateLabel",[this._label]);}return this._label;};})();DlJSON={RE_strings:/(\x22(\\.|[^\x22\\])*\x22|\x27(\\.|[^\x27\\])*\x27)/g,RE_forbid:/([\n;()+=\x2f*.-])/g,encode:function(obj){var tmp,i;if(obj instanceof Array){tmp=["[",obj.map(DlJSON.encode).join(","),"]"].join("");}else if(obj instanceof Date){tmp=DlJSON.encode(obj.toUTCString());}else if(obj==null){tmp='null';}else if(typeof obj=="object"){tmp=[];for(i in obj)tmp.push([DlJSON.encode(i),":",DlJSON.encode(obj[i])].join(""));tmp=["{",tmp.join(","),"}"].join("");}else if(typeof obj=="string"){tmp=['"',obj.replace(/\x5c/g,"\\\\").replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\x22/g,"\\\""),'"'].join("");}else tmp=obj.toString();return tmp;},decode:function(str,safe){str=str.trim();if(!safe){var tmp=str.replace(DlJSON.RE_strings,"");if(DlJSON.RE_forbid.test(tmp))throw new DlSecurityException("Character "+RegExp.$1+" not allowed in JSON input!");}try{var val;eval(['val=',str].join(""));return val;}catch(ex){throw new DlDataException("Malformed data in JSON input: "+ex);}},domToObject:function(el){var obj={};var text=String.buffer();for(var i=el.firstChild;i;i=i.nextSibling){if(i.nodeType==1){var o=DlJSON.domToObject(i),tag=i.nodeName;if(!(tag in obj)){obj[tag]=o;}else{if(!(obj[tag]instanceof Array))obj[tag]=[obj[tag]];obj[tag].push(o);}}else if(i.nodeType==3){text(i.nodeValue);}}obj.$text=text.get();return obj;}};var DlKeyboard={BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,DELETE:46,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,ARROW_LEFT:37,ARROW_UP:38,ARROW_RIGHT:39,ARROW_DOWN:40,parseKey:function(str){var o={},m;str=str.toUpperCase();if(m=/^([a-z]+)\s+\x27(.)\x27$/i.exec(str)){o[m[1]]=true;o.key=m[2];}else if(m=/^([a-z]+)-([a-z]+)\s+\x27(.)\x27$/i.exec(str)){o[m[1]]=o[m[2]]=true;o.key=m[3];}else if(m=/^([a-z]+)-([a-z]+)-([a-z]+)\s+\x27(.)\x27$/i.exec(str)){o[m[1]]=o[m[2]]=o[m[3]]=true;o.key=m[4];}return o;},checkKey:function(ev,k){if(typeof k=="string")k=DlKeyboard.parseKey(k);return(((!k.CTRL&&!ev.ctrlKey)||(k.CTRL&&ev.ctrlKey))&&((!k.ALT&&!ev.altKey)||(k.ALT&&ev.altKey))&&((!k.SHIFT&&!ev.shiftKey)||(k.SHIFT&&ev.shiftKey))&&ev.keyStr.toUpperCase()==k.key.toUpperCase());}};DlKeyboard.KEYS_CONTROL=["BACKSPACE","TAB","DELETE","ESCAPE","ENTER","PAGE_UP","PAGE_DOWN","END","HOME","ARROW_LEFT","ARROW_UP","ARROW_RIGHT","ARROW_DOWN"].keys_map(DlKeyboard).toHash(true);DlKeyboard.KEYS_MOVE=["ARROW_LEFT","ARROW_UP","ARROW_RIGHT","ARROW_DOWN"].keys_map(DlKeyboard).toHash(true);DlKeyboard.KEYS_MOVE_PREV=["ARROW_LEFT","ARROW_UP"].keys_map(DlKeyboard).toHash(true);(function(){var BASE=DlLabel.inherits(DlAbstractButton);function DlLabel(args){if(args){args.tagName=args.tagName||"span";D.setDefaults(this,args);DlAbstractButton.call(this,args);}};eval(Dynarch.EXPORT("DlLabel"));D.DEFAULT_ARGS={_activateWidget:["widget",null]};P._onMouseDown=function(ev){var w=this._activateWidget;if(w){w.focus();ev.domStop=true;DlException.stopEventBubbling();}};P.setWidget=function(widget){this._activateWidget=widget;};P.getWidget=function(){return this._activateWidget;};P._handle_accessKey=function(ev){this._onMouseDown(ev);};})();(function(){var BASE=DlMacBarIcon.inherits(DlAbstractButton);function DlMacBarIcon(args){if(args){DlMacBarIcon.setDefaults(this,args);this.__currentWidth=this.__minWidth;this.__currentHeight=this.__minHeight;this.__align=this.__align.split(/\s+/).toHash();DlAbstractButton.call(this,args);}};eval(Dynarch.EXPORT("DlMacBarIcon"));var CLS={active:"DlMacBarIcon-active",hover:"DlMacBarIcon-hover",checked:"DlMacBarIcon-1",unchecked:"DlMacBarIcon-0",empty:"DlMacBarIcon-empty",disabled:"DlMacBarIcon-disabled"};D.DEFAULT_ARGS={_classes:["classes",CLS],__image:["img",null],__minWidth:["minWidth",32],__minHeight:["minHeight",32],__maxWidth:["maxWidth",64],__maxHeight:["maxHeight",64],__align:["align","bottom"],__tooltipTimeout:["tooltipTimeout",900]};P._createElement=function(){DlWidget.prototype._createElement.call(this);this.setContent(String.buffer("<img src='",this.__image,"' width='",this.__minWidth,"' height='",this.__minHeight," ' />").get());};P.getImgElement=function(){return this.getElement().firstChild;};P.flash=function(timeout){this._onMouseEnter();this._onMouseLeave.delayed(timeout||100,this);};P.initDOM=function(){BASE.initDOM.call(this);this.addEventListener({onDestroy:onDestroy});this.__anim=new DlAnimation(25,40);this.__anim.addEventListener({onUpdate:onAnimationUpdate.$(this),onStart:onAnimationStart.$(this)});};function onDestroy(){this.__anim.destroy();};P._onMouseEnter=function(){BASE._onMouseEnter.apply(this,arguments);var a=this.__anim;a.ew=this.__maxWidth;a.eh=this.__maxHeight;a.start(30,50,DlAnimation.easing.elastic_b);};P._onMouseLeave=function(){BASE._onMouseLeave.apply(this,arguments);var a=this.__anim;a.ew=this.__minWidth;a.eh=this.__minHeight;a.start(50,50,DlAnimation.easing.accel_b);};function onAnimationStart(){this.__anim.sw=this.__currentWidth;this.__anim.sh=this.__currentHeight;};function onAnimationUpdate(){var a=this.__anim,img=this.getImgElement(),y=a.getPos(),mt;var yy=a.getPos(function(x){return 1-Math.cos(x*2.5*Math.PI)/Math.exp(5*x);});img.width=this.__currentWidth=y.mapInt(a.sw,a.ew);img.height=this.__currentHeight=yy.mapInt(a.sh,a.eh);a=this.__align;mt=this.__minWidth-this.__currentWidth;if(a.center)mt/=2;if(a.left||a.center)img.style.marginRight=mt+"px";if(a.right||a.center)img.style.marginLeft=mt+"px";mt=this.__minHeight-this.__currentHeight;if(a.middle)mt/=2;if(a.top||a.middle)img.style.marginBottom=mt+"px";if(a.bottom||a.middle)img.style.marginTop=mt+"px";};})();(function(){var BASE=DlNotebook.inherits(DlContainer);function DlNotebook(args){if(args){DlContainer.call(this,args);this._panes=[];this._currentPane=null;}};eval(Dynarch.EXPORT("DlNotebook"));var DEFAULT_EVENTS=["onChange"];P._createElement=function(){BASE._createElement.call(this);this.getElement().innerHTML="<div class='TabContent-inner'></div>";};P.appendWidget=function(w,pos){BASE.appendWidget.call(this,w);var el=w.getElement();var cont=this.getContentElement();if(pos!=null)pos=this.__widgetsPosition;else this.__widgetsPosition=pos;if(pos==null)pos=this.__widgetsPosition=DynarchDomUtils.getPadding(cont).x/2;el.style.position="absolute";el.style.visibility="hidden";el.style.left=el.style.top=pos+"px";cont.appendChild(el);this._panes.push(w);};P.initDOM=function(){this.registerEvents(DEFAULT_EVENTS);BASE.initDOM.call(this);};P.getPane=function(index){return this._panes[index];};P.getCurrentPane=function(){return this.getPane(this._currentPane);};P.getCurrentPaneIndex=function(){return this._currentPane;};P.length=function(){return this._panes.length;};P.showPane=function(index){var old=this._currentPane;if(old!=null){this.getPane(old).visibility(false);this.getPane(old).setPos({x:-30000,y:-30000});}this._currentPane=index;var pane=this.getPane(index);if(!pane._dl_notebook_has_size){pane.setSize(this.getInnerSize());pane._dl_notebook_has_size=true;}pane.setPos(this.__widgetsPosition,this.__widgetsPosition);pane.visibility(true);if(index!==old)this.applyHooks("onChange",[index,old]);return this;};P.firstPane=function(){this.showPane(0);};P.lastPane=function(){this.showPane(this.length()-1);};P.nextPane=function(){var i=this._currentPane;i==null?i=0:++i;if(i>=this._panes.length)i=0;return this.showPane(i);};P.prevPane=function(){var i=this._currentPane;i==null?i=this._panes.length-1:--i;if(i<0)i=this._panes.length-1;return this.showPane(i);};P.isFirstPane=function(){return this._currentPane==0;};P.isLastPane=function(){return this._currentPane==this._panes.length-1;};P.getContentElement=function(){return this.getElement().firstChild;};P.setSize=P.setOuterSize=function(size){BASE.setOuterSize.call(this,size);var el=this.getElement();size=DynarchDomUtils.getInnerSize(el);DynarchDomUtils.setOuterSize(this.getContentElement(),size.x,size.y);el.style.width=el.style.height="";size=DynarchDomUtils.getInnerSize(this.getContentElement());var cp=this.getCurrentPane();this._panes.foreach(function(p){p._dl_notebook_has_size=false;});cp.setSize(size);cp._dl_notebook_has_size=true;};P.setIdealSize=function(){var size={x:0,y:0};this._panes.r_foreach(function(p){var s=p.getOuterSize();if(s.x>size.x)size.x=s.x;if(s.y>size.y)size.y=s.y;});this.setInnerSize(size);};})();(function(){var BASE=DlProgressBar.inherits(DlWidget);function DlProgressBar(args){if(args){D.setDefaults(this,args);DlWidget.call(this,args);}};eval(Dynarch.EXPORT("DlProgressBar"));D.DEFAULT_ARGS={__progress_minVal:["min",0],__progress_maxVal:["max",100],__progress_val:["val",0],__label:["label",null]};P._createElement=function(){BASE._createElement.call(this);var CE=DynarchDomUtils.createElement;var el=this.getElement();CE("div",null,{className:"DlProgressBar-fill"},el);CE("div",null,{className:"DlProgressBar-label",innerHTML:"&nbsp;"},el);this.setLabel(this.__label);this.setValue(this.__progress_val);};P._getLabelElement=function(){return this.getElement().lastChild;};P._getFillElement=function(){return this.getElement().firstChild;};P.getValue=function(){return this.__progress_val;};P.getMaxVal=function(){return this.__progress_maxVal;};P.getMinVal=function(){return this.__progress_minVal;};P.setValue=function(val){this.__progress_val=val;if(val>this.__progress_maxVal)val=this.__progress_maxVal;var diff=this.__progress_maxVal-this.__progress_minVal;var pos=val-this.__progress_minVal;var percent=100*pos/diff;if(!isNaN(percent)&&percent>=0){this._getFillElement().style.width=percent+"%";this._updateLabel(percent);}};P.setLabel=function(label){this.__label=label;this._updateLabel();};P._updateLabel=function(percent){var label=this.__label;if(percent==null)percent=0;if(label!=null){if(typeof label=="function")label=label(this,percent,this.__progress_val);else{label=label.replace(/%d/g,Math.round(percent)).replace(/%f/g,percent.toFixed(2)).replace(/%v/g,this.__progress_val);}if(!/\S/.test(label))label="&nbsp;";this._getLabelElement().innerHTML=label;}};P.reset=function(min,max,val,label){if(val==null)val=min;this.__progress_minVal=min;this.__progress_maxVal=max;if(arguments.length>3)this.__label=label;this.setValue(val);};})();DlRadioButton.inherits(DlCheckbox);function DlRadioButton(args){if(args){args.alwaysCheck=true;DlRadioButton.setDefaults(this,args);DlCheckbox.call(this,args);}};DlRadioButton.DEFAULT_ARGS={_groupId:["group",0],_classes:["classes",{active:"DlRadioButton-active",hover:"DlRadioButton-hover",checked:"DlRadioButton-1",unchecked:"DlRadioButton-0",empty:"DlRadioButton-empty",disabled:"DlRadioButton-disabled"}]};DlRadioButton.prototype._className.remove("DlCheckbox");(function(){var BASE=DlRadioSelect.inherits(DlButtonMenu);function DlRadioSelect(args){if(args){D.setDefaults(this,args);DlButtonMenu.call(this,args);if(this._options.length)this.setOptions(this._options);this.value(this._value,true);}};eval(Dynarch.EXPORT("DlRadioSelect"));var DEFAULT_EVENTS=["onChange"];D.DEFAULT_ARGS={_options:["options",[]],_value:["value",null],_connected:["connected",true]};P.value=function(value,force,nocalls){var oldval=this._value;if(force||typeof value!="undefined"&&value!==oldval){this._value=value;this._updateLabel();if(!nocalls)this.applyHooks("onChange",[oldval,value]);}return oldval;};P.getValue=function(){return this.value();};P.setValue=P.value;function radioGroup_onChange(cb){if(cb.checked()){this.value(cb.userData);DlPopup.clearAllPopups();}cb._onMouseLeave();};P._updateLabel=function(){var label=null,a=this._options,i,o;for(i=a.length;--i>=0;){o=a[i];if(o==null)continue;if(this._value==o.value){this.getButton().label(o.label);o.widget.checked(true);}}};P._setListeners=function(){this.registerEvents(DEFAULT_EVENTS);BASE._setListeners.call(this);this._radioGroup=new DlRadioGroup(this.id);};P.setOptions=function(options){var g=this._radioGroup,menu,args;g.reset();g.addEventListener("onChange",radioGroup_onChange.$(this));menu=new DlVMenu({className:"DlSelect-menu"});args={parent:menu,group:g,noCapture:true};options.foreach(function(o){if(o==null)menu.addSeparator();else{args.label=o.label;args.data=o.value;args.className=o.className;var r=o.widget=new DlRadioButton(args);r.connectEvents("onMouseUp","onClick");}},this);var el=menu.getElement();el.style.position="absolute";menu.zIndex(-100);document.body.appendChild(el);var width=menu.getOuterSize().x;document.body.removeChild(el);menu.zIndex("");el.style.position="";(function(){this.getButton().setOuterSize({x:width-this.getArrow().getOuterSize().x+2});}).$(this).delayed(10);this.setMenu(menu);this._options=options;};P.addOption=function(opt,index){if(index==null)index=this._options.length;var item=opt.widget=new DlRadioButton({parent:this._menu,group:this._radioGroup,noCapture:true,label:opt.label,data:opt.value,className:opt.className});item.connectEvents("onMouseUp","onClick");this._options.splice(index,0,opt);return item;};P.initDOM=function(){BASE.initDOM.call(this);};})();DlRegexp={EMAIL:/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/,MIME_WEB_IMAGE:/^image\x2f.*(png|jpe?g|gif|tiff?)/i};(function(){var BASE=DlResizeBar.inherits(DlWidget);function DlResizeBar(args){if(args){D.setDefaults(this,args);this._invert=this._invert?-1:1;DlWidget.call(this,args);}};eval(Dynarch.EXPORT("DlResizeBar",true));D.DEFAULT_ARGS={_isHoriz:["horiz",null],_widget:["widget",null],_invert:["invert",false],_min:["min",null],_max:["max",null],_cont:["continuous",false],_keepPrc:["keepPercent",false]};D.getDragBar=function(){return DlElementCache.DRAGGING_LINE;};P.initDOM=function(){BASE.initDOM.call(this);this.condClass(this.isHoriz(),"DlResizeBar-Horizontal","DlResizeBar-Vertical");this.setUnselectable(null,true);};P.isHoriz=function(){if(this._isHoriz==null){var args=DlLayout.getArgs(this);if(args)this._isHoriz=/top|bottom/.test(args.pos);}return this._isHoriz;};P._setListeners=function(){BASE._setListeners.call(this);this._resizeHandlers={onMouseMove:mouseMove.$(this),onMouseUp:stopResize.$(this),onMouseOver:DlException.stopEventBubbling,onMouseOut:DlException.stopEventBubbling,onMouseEnter:DlException.stopEventBubbling,onMouseLeave:DlException.stopEventBubbling};this.addEventListener("onMouseDown",startDrag);};P._setResizeCaptures=function(capture){CC(document.body,capture,this.isHoriz()?"CURSOR-RESIZE-S":"CURSOR-RESIZE-E");(capture?DlEvent.captureGlobals:DlEvent.releaseGlobals)(this._resizeHandlers);DlDialog.activateEventStopper(capture);};function startDrag(ev){var el=DlElementCache.DRAGGING_LINE;var pos=this.getPos();this._dragPos=this.isHoriz()?pos.y:pos.x;var mpos=this.isHoriz()?ev.pos.y:ev.pos.x;this._mposDiff=mpos-this._dragPos;var size=this.getSize();el.style.top=pos.y+"px";el.style.left=pos.x+"px";el.style.width=size.x+"px";el.style.height=size.y+"px";if(this._widget){var s=this._widget.getSize();this._dragSize=this.isHoriz()?s.y:s.x;}document.body.appendChild(el);this._setResizeCaptures(true);DlException.stopEventBubbling();};P._doResize=function(ev){var H=this.isHoriz();var pos=DOM.getPos(DlElementCache.DRAGGING_LINE);var pos=H?pos.y:pos.x;var diff=this._invert*(pos-this._dragPos);var w=this._widget;if(w){var s=this._dragSize;var f=DlLayout.getArgs(w);if(f){f=f.fill;var isPrc=/%$/.test(f);if(isPrc&&!this._keepPrc||f==null||typeof f=="number"){DlLayout.setFill(w,s+diff);}else if(isPrc){f=parseFloat(f);DlLayout.setFill(w,f*(s+diff)/s+"%");}}else{if(this._isHoriz)w.setSize({y:s+diff});else w.setSize({x:s+diff});}}};function stopResize(ev){this._setResizeCaptures(false);this._doResize(ev);document.body.removeChild(DlElementCache.DRAGGING_LINE);};function mouseMove(ev){var el=DlElementCache.DRAGGING_LINE;var pos=this.isHoriz()?ev.pos.y:ev.pos.x;pos-=this._mposDiff;var diff=this._invert*(pos-this._dragPos);var min=this._min,max=this._max,w=this._widget;if(w){var args=DlLayout.getArgs(w);if(args){if(min==null)min=args.min;if(max==null)max=args.max;}var s;if(min!=null||max!=null){s=this._dragSize+diff;}if(min!=null&&s<min){pos+=this._invert*(min-s);}else if(max!=null&&s>max){pos+=this._invert*(max-s);}}if(this.isHoriz())el.style.top=pos+"px";else el.style.left=pos+"px";if(this._cont)this._doResize(ev);};})();(function(){DlSystem.inherits(DlEventProxy);function DlSystem(){DlEventProxy.call(this);this.registerEvents(DEFAULT_EVENTS);};var DEFAULT_EVENTS=["on-dialog-create","on-dialog-show","on-dialog-hide","on-dialog-minimize","on-dialog-restore","on-rpc-start","on-rpc-stop","on-rpc-timeout"];DlSingleton.register("DlSystem",DlSystem,true);})();(function(){var BASE=DlRPC.inherits(DlEventProxy);function DlRPC(args){if(args){DlEventProxy.call(this);DlRPC.setDefaults(this,args);this.registerEvents(DEFAULT_EVENTS);if(this.method==null)this.method=this.data!=null?"POST":"GET";this._timeoutID=0;}};eval(Dynarch.EXPORT("DlRPC"));var DEFAULT_EVENTS=["onStart","onStop","onTimeout"];D.DEFAULT_ARGS={url:["url",null],args:["args",null],callback:["callback",null],method:["method",null],data:["data",null],timeout:["timeout",null]};function onState(req){if(req.readyState==4){delete req['onreadystatechange'];this._request=null;if(this._timeoutID){clearTimeout(this._timeoutID);this._timeoutID=null;}var args={success:req.status==200,status:req.status,statusText:req.statusText,timeout:false,xml:req.responseXML,text:req.responseText};DlSystem().applyHooks("on-rpc-stop",[this,args,req]);this.applyHooks("onStop",[this,args,req]);if(this.callback)this.callback(args);}};function onTimeout(req){this._request=null;req.abort();DlSystem().applyHooks("on-rpc-timeout",[this,req]);this.applyHooks("onTimeout",[this,req]);if(this.callback)this.callback({success:false,timeout:true});};P.call=function(newArgs){if(newArgs!=null)Dynarch.merge(this,newArgs);var req,urlargs=false,i;if(window.XMLHttpRequest){req=new XMLHttpRequest();}else if(window.ActiveXObject){req=new ActiveXObject("Microsoft.XMLHTTP");}else throw "Browser does not support XMLHttpRequest";this._request=req;req.onreadystatechange=onState.$(this,req);var args=this.args;if(args){urlargs=[];for(i in args)urlargs.push(escape(i)+"="+escape(args[i]));if(urlargs.length==0)urlargs=false;else urlargs=urlargs.join("&");}var url=this.url;switch(this.method){case "POST":var data=this.data;if(urlargs&&data)url+="?"+urlargs;req.open("POST",url,true);if(!data){req.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");this._start(urlargs);}else{if(typeof data!="string"){data=DlJSON.encode(data);req.setRequestHeader("Content-Type","text/javascript; charset=UTF-8");}this._start(data);}break;case "GET":if(urlargs)url+="?"+urlargs;req.open("GET",url,true);this._start(null);break;}};P._start=function(data){if(this.timeout)this._timeoutID=setTimeout(onTimeout.$(this,this._request));else this._timeoutID=0;DlSystem().applyHooks("on-rpc-start",[this]);this.applyHooks("onStart",[this]);this._request.send(data);};})();(function(){var FORWARD_EVENTS=["mouseover","mouseout","mousemove","mousedown","mouseup","click","keydown","keyup","keypress","contextmenu"];var BR=is_gecko?"<br type='_moz' />":"";var INIT_HTML=('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" '+'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'+'<html class="DlRteFrame-HTML">'+'<head><title>DynarchLIB Rich Text Editor</title></head>'+'<body class="DlRteFrame-Body"><p>'+BR+'</p></body></html>');var BASE=DlRteFrame.inherits(DlWidget);function DlRteFrame(args){if(args){D.setDefaults(this,args);this.__eventProxy=eventProxy.$(this);this.callUpdateHooks=this.callUpdateHooks.clearingTimeout(40,this);DlWidget.call(this,args);if(this.__sections)this.setSections(this.__sections);}};eval(Dynarch.EXPORT("DlRteFrame",true));var DEFAULT_EVENTS=["onUpdate","onSectionChange"];D.DEFAULT_ARGS={__paragraphsMode:["useParagraphs",true],__sections:["sections",null],_focusable:["focusable",2],_tabChar:["tabChar","    "]};P.COMMANDS={"backcolor":{id:is_ie?"backcolor":"hilitecolor"},"forecolor":{id:"forecolor"},"bold":{id:"bold",key:"CTRL 'B'"},"italic":{id:"italic",key:"CTRL 'I'"},"underline":{id:"underline",key:"CTRL 'U'"},"strike":{id:"strikethrough",key:"CTRL '-'"},"subscript":{id:"subscript"},"superscript":{id:"superscript"},"removeformat":{id:"removeformat",key:"ALT-CTRL '0'"},"justifyleft":{id:"justifyleft",key:"ALT-CTRL 'l'"},"justifyright":{id:"justifyright",key:"ALT-CTRL 'r'"},"justifycenter":{id:"justifycenter",key:"ALT-CTRL 'e'"},"justifyfull":{id:"justifyfull",key:"ALT-CTRL 'j'"},"orderedlist":{id:"insertorderedlist",key:"ALT-CTRL 'o'"},"unorderedlist":{id:"insertunorderedlist",key:"ALT-CTRL-SHIFT 'o'"},"unorderedlist1":{id:"insertunorderedlist",key:"ALT-CTRL 'u'"},"indent":{id:"indent",key:"CTRL '.'"},"outdent":{id:"outdent",key:"CTRL ','"},"undo":{id:"undo"},"redo":{id:"redo"},"<hr>":{id:"inserthorizontalrule",key:"CTRL ' '"},"<h1>":{id:"formatblock",key:"CTRL '1'",arg:"h1"},"<h2>":{id:"formatblock",key:"CTRL '2'",arg:"h2"},"<h3>":{id:"formatblock",key:"CTRL '3'",arg:"h3"},"<h4>":{id:"formatblock",key:"CTRL '4'",arg:"h4"},"<h5>":{id:"formatblock",key:"CTRL '5'",arg:"h5"},"<h6>":{id:"formatblock",key:"CTRL '6'",arg:"h6"},"<p>":{id:"formatblock",key:"CTRL 'n'",arg:"p"},"<pre>":{id:"formatblock",key:"CTRL-ALT 'n'",arg:"pre"},"<address>":{id:"formatblock",arg:"pre"},"<blockquote>":{id:"formatblock",key:"CTRL 'q'",arg:"blockquote"},"_nextSection":{id:"_nextSection",key:"CTRL ']'"},"_prevSection":{id:"_prevSection",key:"CTRL '['"},"showHtml":{id:"showHtml",key:"CTRL-ALT-SHIFT 'h'"}};var FORMATBLOCK_TAGS="h1 h2 h3 h4 h5 h6 p pre address blockquote".hashWords();P.SEMANTIC_TAGS={"bold":true,"italic":true,"strike":true,"subscript":true,"superscript":true,"indent":true,"underline":true,"outdent":true,"strikethrough":true,"strike":true};P.callUpdateHooks=function(){if(!this.destroyed)this.callHooks("onUpdate");};P.execCommand=function(cmd,param){this.focus();var ret;var doc=this.getIframeDoc();if(is_gecko)doc.execCommand("styleWithCSS",false,!(cmd in this.SEMANTIC_TAGS));if(this.COMMANDS[cmd]){cmd=this.COMMANDS[cmd];if(typeof param=="undefined")param=cmd.arg||"";cmd=cmd.id;}if(cmd=="formatblock"){if(is_ie){var h=this.getAncestorsHash();if(h.pre){if(param=="pre"){return;}var sel=this.getSelection(),r=this.getRange(sel);var r2=this.createRange();r2.moveToElementText(h.pre);r.setEndPoint("EndToEnd",r2);r.select();var newEl,newElHtml=String.buffer("<",param,">dummy</",param,">").get();if(r.compareEndPoints("StartToStart",r2)==0){h.pre.insertAdjacentHTML("beforeBegin",newElHtml);newEl=h.pre.previousSibling;}else{var html=r.htmlText,text=r.text;r.moveStart("character",-1);if(r.text.charAt(0)!=text.charAt(0))r.moveStart("character",1);h.pre.insertAdjacentHTML("afterEnd","<br />");r.pasteHTML("");h.pre.parentNode.removeChild(h.pre.nextSibling);h.pre.insertAdjacentHTML("afterEnd",newElHtml);newEl=h.pre.nextSibling;if(/\S/.test(text)){var p2=h.pre.cloneNode(true);p2.innerHTML=html;newEl.parentNode.insertBefore(p2,newEl.nextSibling);}}r.moveToElementText(newEl);r.collapse();r.select();newEl.innerHTML="";return;}}if(is_ie)param="<"+param+">";}switch(cmd){case "showHtml":try{alert(this.getHTML());}catch(ex){alert("ERROR: "+ex);}break;case "_nextSection":this.nextSection();break;case "_prevSection":this.prevSection();break;default:ret=doc.execCommand(cmd,false,param);}this.focus();this.callUpdateHooks();return ret;};P.queryCommandState=function(cmd){if(this.COMMANDS[cmd])cmd=this.COMMANDS[cmd].id;return this.getIframeDoc().queryCommandState(cmd);};P.queryCommandValue=function(cmd){if(this.COMMANDS[cmd])cmd=this.COMMANDS[cmd].id;if(!is_gecko&&/^formatblock$/i.test(cmd)){var a=this.getAllAncestors();for(var i=0;i<a.length;++i){var tag=a[i].tagName.toLowerCase();if(tag in FORMATBLOCK_TAGS)return tag;};}return this.getIframeDoc().queryCommandValue(cmd);};P.getInnerHTML=function(){return this.getIframeBody().innerHTML;};P.getHTML=function(withMeta){return DlHtmlUtils.getHTML(this.getIframeBody(),false,withMeta);};P.getInnerText=function(){return DlHtmlUtils.getInnerText(this.getIframeBody());};P.getText=function(){return DlHtmlUtils.getText(this.getIframeBody());};P.setSections=function(sec){this.__sections=sec;var h=this.__sectionsHash={};sec.foreach(function(s,i){s.index=i;h[s.name]=s;if(s.current||i==0){this.__currentSection=i;this.setHTML(s.content);}}.$(this));};P.setSectionContent=function(name,html){var s=this.getSection(name,true);s.content=html;if(s.index==this.__currentSection)this.setHTML(html);};P.getSections=function(){var tmp=this.getHTML(true);Dynarch.merge(this.getCurrentSection(),tmp);return this.__sectionsHash;};P.getSection=function(name,noSetContent){var sec=this.__sectionsHash[name];if(sec.index==this.__currentSection&&!noSetContent){var tmp=this.getHTML(true);Dynarch.merge(sec,tmp);}return sec;};P.getCurrentSection=function(){return this.__sections[this.__currentSection];};P._setCurrentSection=function(newsec){var oldsec=this.getCurrentSection();if(oldsec!==newsec){var tmp=this.getHTML(true);Dynarch.merge(oldsec,tmp);this.__currentSection=newsec.index;this.setHTML(newsec.content);this.applyHooks("onSectionChange",[oldsec,newsec]);}};P.setCurrentSection=function(name){var newsec=this.__sectionsHash[name];this._setCurrentSection(newsec);};P.setCurrentSectionIndex=function(idx){if(idx!=this.__currentSection){var newsec=this.__sections[idx];this._setCurrentSection(newsec);}};P.prevSection=function(){this.setCurrentSectionIndex(this.__sections.rotateIndex(this.__currentSection-1));};P.nextSection=function(){this.setCurrentSectionIndex(this.__sections.rotateIndex(this.__currentSection+1));};P._setListeners=function(){this.registerEvents(DEFAULT_EVENTS);BASE._setListeners.call(this);this.addEventListener(is_ie?"onKeyDown":"onKeyPress",onKeypress);this.addEventListener({onDestroy:onDestroy});};P._createElement=function(){BASE._createElement.call(this);var iframe=CE("iframe",{display:'block'},{frameBorder:0,marginHeight:0,marginWidth:0,src:is_ie?"javascript:'';":"about:blank"},this.getElement());this.__hasFrameEvents=false;this.updateKeymap();};P.updateKeymap=function(){var keymap=this.__rte_keymap=[];for(var i in this.COMMANDS){var cmd=this.COMMANDS[i];if(cmd.key)keymap.push([DlKeyboard.parseKey(cmd.key),i]);}};P.setOuterSize=P.setSize=function(s){var pb1=DOM.getBorder(this.getElement());var pb2=DOM.getBorder(this.getContentElement());this.setInnerSize({x:s.x-pb1.x-pb2.x,y:s.y-pb1.y-pb2.y});};P.getIframeElement=function(){return this.getElement().firstChild;};P.getContentElement=P.getIframeElement;P.getIframeWin=function(){return this.getIframeElement().contentWindow;};P.getIframeDoc=function(){return this.getIframeWin().document;};P.getIframeBody=function(){return this.getIframeDoc().body;};P.initDesignMode=function(callback){var doc=this.getIframeDoc();doc.open();doc.write(INIT_HTML);doc.close();doc.designMode="on";if(!this.__hasFrameEvents)addIframeEvents.delayed(5,this,callback);};P.setHTML=function(html){if(html instanceof Array)html=html.join("");html=html.trim();if(this.__hasFrameEvents){if(is_ie){html=html.replace(/(<pre[^>]*>)((.|\n)+?)(<\x2fpre>)/gi,function(s,p1,p2,p3,p4){p2=p2.replace(/\x20/g,"\xA0").replace(/\t/g,"\xA0".repeat(4));return p1+p2+p4;});}this.getIframeBody().innerHTML=html;this._onSetHTML();this.moveBOF();this.callUpdateHooks();}else this.__pendingHTML=html;};P._onSetHTML=function(){var pres=this.getIframeDoc().getElementsByTagName("pre");for(var i=pres.length;--i>=0;){var pre=pres[i];pre.innerHTML=pre.innerHTML.replace(/\n/g,"<br>");}};P.clear=function(){this.setHTML("");};P.focus=function(){this.getIframeWin().focus();BASE.focus.call(this);};P.loadStyle=function(css){var doc=this.getIframeDoc();var id=css.replace(/\x2f/g,"_");if(!doc.getElementById(id)){var head=doc.getElementsByTagName("head")[0];var link=doc.createElement("link");link.type="text/css";link.rel="stylesheet";link.href=css;link.id=id;head.appendChild(link);link.disabled=true;link.disabled=false;}};P.createRange=function(){return is_ie?this.getIframeBody().createTextRange():this.getIframeDoc().createRange();};P.getSelection=function(){return is_ie?this.getIframeDoc().selection:this.getIframeWin().getSelection();};P.getRange=function(sel){if(sel==null)sel=this.getSelection();return is_ie?sel.createRange():sel.getRangeAt(0);};P.getParentElement=function(){var sel=this.getSelection();var range=this.getRange(sel);if(is_ie){switch(sel.type){case "Text":case "None":return range.parentElement();case "Control":return range.item(0);default:return null;}}else try{var p=range.commonAncestorContainer;if(!range.collapsed&&range.startContainer==range.endContainer&&range.startOffset-range.endOffset<=1&&range.startContainer.hasChildNodes())p=range.startContainer.childNodes[range.startOffset];while(p.nodeType==3)p=p.parentNode;return p;}catch(ex){return null;}};P.getAllAncestors=function(){var p=this.getParentElement();if(p&&p.nodeType==1)p=this.getParentElement();var body=this.getIframeBody();var a=[];while(p&&p!==body&&p.nodeType==1){a.push(p);p=p.parentNode;}a.push(body);return a;};P.getAncestorsHash=function(){var p=this.getAllAncestors(),el,i,tn,pnodes={__all:p};p.foreach(function(el){tn=el.tagName.toLowerCase();if(!pnodes[tn])pnodes[tn]=el;});return pnodes;};P.getSelectedText=function(){var range=this.getRange();return is_ie?range.text:range.toString();};P.selectRange=function(range){if(is_ie)range.select();else{var sel=this.getSelection();sel.removeAllRanges();sel.addRange(range);}};P.isCollapsed=function(){var r=this.getRange();return is_w3?r.collapsed:r.compareEndPoints("StartToEnd",r)==0;};P.collapse=function(toStart){var sel=this.getSelection();var r=this.getRange(sel);if(is_w3)sel.removeAllRanges();r.collapse(!!toStart);this.selectRange(r);};P.insertNode=function(node,select){var sel=this.getSelection(),r=this.getRange(sel);if(is_w3){r.deleteContents();r.insertNode(node);if(select){sel.removeAllRanges();r.selectNode(node);sel.addRange(r);}}else{var id=ID("rteframe");r.pasteHTML(["<span id='",id,"'></span>"].join(""));var el=this.getIframeDoc().getElementById(id);el.parentNode.insertBefore(node,el);el.parentNode.removeChild(el);if(select&&node.nodeType!=3){r.moveToElementText(node);r.select();}}return node;};P.insertText=function(str,select){var node=this.getIframeDoc().createTextNode(str);return this.insertNode(node,select);};P.selectNodeContents=function(node){var r=this.createRange();is_w3?r.selectNodeContents(node):r.moveToElementText(node);this.selectRange(r);};P.createLink=function(url,text){var tmp,as,link,i;if(text)this.insertText(text,true);tmp="javascript:"+ID("link");this.execCommand("createlink",tmp);as=this.getIframeDoc().getElementsByTagName("a");for(i=as.length;--i>=0;)if(as[i].href==tmp){link=as[i];break;}link.href=url;return link;};P.createAnchor=function(name){var text=this.getSelectedText()?null:"Anchor";var link=this.createLink("#",text);link.removeAttribute("href");AC(link,text?"DlAnchor-Empty":"DlAnchor");link.setAttribute("name",name);if(text)link.innerHTML="";return link;};P.getAnchors=function(){var as=this.getIframeDoc().getElementsByTagName("a"),i=as.length,a,ret=[];while(--i>=0){a=as[i];if(a.name)ret.unshift(a);}return ret;};P.unlink=function(){this.execCommand("unlink");};P.getSelectedImage=function(){var img=this.getParentElement();if(img&&!/^img$/i.test(img.tagName))img=null;return img;};P.insertImage=function(params){var img=this.getSelectedImage();if(!img){var sel=this.getSelection();var range=this.getRange(sel);this.execCommand("insertimage",params.url);if(is_ie){img=range.parentElement();if(img.tagName.toLowerCase()!="img")img=img.previousSibling;}else{range=this.getRange();img=range.startContainer.childNodes[range.startOffset-1];}}else{img.src=params.url;}if(params.width)img.width=params.width;if(params.height)img.height=params.height;if(params.align)img.align=params.align;if(params.alt)img.alt=params.alt;if(params.marginLeft)img.style.marginLeft=params.marginLeft;if(params.marginTop)img.style.marginTop=params.marginTop;if(params.marginRight)img.style.marginRight=params.marginRight;if(params.marginBottom)img.style.marginBottom=params.marginBottom;return img;};P.moveBOF=function(pos){var body=this.getIframeBody(),sel,r;var el=pos?body.lastChild:body.firstChild;if(!el)return;if(is_w3){r=this.getRange(sel=this.getSelection());sel.removeAllRanges();if(el.nodeType==1)r.selectNodeContents(el);else r.selectNode(el);r.collapse(!pos);sel.addRange(r);}else{r=body.createTextRange();r.collapse(!pos);r.select();}};P.moveEOF=function(pos){return this.moveBOF(!pos);};P.setParagraphsMode=function(mode){this.__paragraphsMode=mode;};P.addBlockClass=function(tagName,className,toggle){var el=this.getAncestorsHash()[tagName];if(el){if(DOM.hasClass(el,className)){if(toggle){DOM.delClass(el,className);return false;}}else{DOM.addClass(el,className);}return true;}return null;};P.canDeleteFullNode=function(el){return DlHtmlUtils.canDeleteFullNode(el.tagName);};P.canDeleteContent=function(el){return DlHtmlUtils.canDeleteContent(el.tagName);};P.canStripNode=function(el){return DlHtmlUtils.canStripNode(el.tagName);};P.deleteNodeContents=function(el){el.innerHTML=DlHtmlUtils.isBlockElement(el)?BR:"";};P.deleteNode=function(el){el.parentNode.removeChild(el);};P.stripNode=function(el){var df=el.ownerDocument.createDocumentFragment();while(el.firstChild)df.appendChild(el.firstChild);el.parentNode.insertBefore(df,el);el.parentNode.removeChild(el);this.callUpdateHooks();};function removeBR(el){if(el.lastChild.nodeType==1&&el.lastChild.tagName.toLowerCase()=="br")el.removeChild(el.lastChild);};function handleEnter(handleList,force){if(!this.__paragraphsMode)return;var anc=this.getAncestorsHash(),all=anc.__all,doit=true;if(handleList){var t2=anc.li||anc.dd;var t1=anc.p;if(t1&&t2){var r1=this.createRange();r1.selectNodeContents(t1);if(/\S/.test(r1.toString())){var sel=this.getSelection();var r2=this.getRange(sel);sel.removeAllRanges(r2);r2.setEndAfter(t1);if(r1.toString()!=r2.toString()){var df=r2.extractContents();var p=df.firstChild;r2.collapse(false);r2.insertNode(df);p.normalize();r2.selectNodeContents(p);if(r2.toString()==""){p.innerHTML=BR;r2.selectNodeContents(p);}r2.collapse(true);sel.addRange(r2);if(is_gecko)p.scrollIntoView(false);throw new DlExStopFrameEvent;}else{doit=false;r2.collapse(true);sel.addRange(r2);}}else if(t2.getElementsByTagName("p").length==1){t1.parentNode.removeChild(t1);doit=false;}else return true;}else if(t1){var sel=this.getSelection();var r=this.getRange(sel);if(r.startContainer==t1){var p=this.getIframeDoc().createElement("p");p.innerHTML=BR;t1.parentNode.insertBefore(p,t1.nextSibling);r.selectNodeContents(p);r.collapse(true);sel.removeAllRanges();sel.addRange(r);if(is_gecko)p.scrollIntoView(false);throw new DlExStopFrameEvent;}}}if(!force&&doit)for(var tag in anc){if(!/^(span|div|body|__all)$/i.test(tag)){doit=false;break;}}if(doit){this.execCommand("<p>");if(!handleList){anc=this.getAncestorsHash();var el=anc.p.nextSibling;if(el&&el.tagName.toLowerCase()=="br")el.parentNode.removeChild(el);}}return false;};function onKeypress(ev){var enterHandled=false;var key=ev.keyCode;if(is_gecko&&!ev.shiftKey&&key==DlKeyboard.ENTER){var force=handleEnter.call(this,true);handleEnter.delayed(10,this,false,force);enterHandled=true;}this.__rte_keymap.r_foreach(function(kc){if(DlKeyboard.checkKey(ev,kc[0])){this.execCommand(kc[1]);throw new DlExStopFrameEvent;}},this);if(key==DlKeyboard.TAB){var tag=this.queryCommandValue("formatblock");if(tag=="pre"){this.insertText(this._tabChar,true);this.collapse(false);throw new DlExStopFrameEvent;}}else if(key==DlKeyboard.ENTER){if(is_ie&&!ev.shiftKey){var tag=this.queryCommandValue("formatblock");if(tag=="pre"){var sel=this.getSelection(),r=this.getRange(sel);r.pasteHTML("<br/><div class='DynarchLIB-REMOVE-ME'></div>");throw new DlExStopFrameEvent;}}}if(is_gecko&&!enterHandled&&this.isCollapsed()&&!ev.ctrlKey&&!ev.altKey&&!(key in DlKeyboard.KEYS_CONTROL)){handleEnter.call(this);}};function eventProxy(ev){ev||(ev=this.getIframeWin().event);var dev=new DlEvent(ev);if(dev.type=="oncontextmenu")DOM.stopEvent(ev);dev.origTarget=dev.target;var p1=dev.origPos=dev.pos;var p2=DOM.getPos(this.getIframeElement());dev.pos={x:p1.x+p2.x,y:p1.y+p2.y};dev.target=this.getElement();try{DlEvent._genericEventHandler(dev,ev);}catch(ex){if(ex instanceof DlExStopFrameEvent)DOM.stopEvent(ev);}if(/onMouseDown|onMouseUp|onKey/.test(dev.dl_type))this.callUpdateHooks(dev,ev);};function addIframeEvents(callback){var doc=this.getIframeDoc();this.__hasFrameEvents=true;DOM.addEvents(doc,FORWARD_EVENTS,this.__eventProxy);if(this.__pendingHTML){this.getIframeBody().innerHTML=this.__pendingHTML;this._onSetHTML();this.moveBOF();this.__pendingHTML=null;}this.__rte_onFocus=onFocus.$(this);this.__rte_onBlur=onBlur.$(this);if(is_ie){doc=this.getIframeElement();doc.onfocus=this.__rte_onFocus;}else{DOM.addEvent(doc,"focus",this.__rte_onFocus);}doc.onblur=this.__rte_onBlur;if(callback)callback.call(this);};function onDestroy(){var doc=this.getIframeDoc();DOM.removeEvents(doc,FORWARD_EVENTS,this.__eventProxy);if(is_ie){doc=this.getIframeElement();delete doc["onfocus"];doc.onfocus=null;}else{DOM.removeEvent(doc,"focus",this.__rte_onFocus);}delete doc["onblur"];doc.onblur=null;};function onFocus(){AC(this.getIframeDoc().documentElement,"DlRteFrame-Focused");BASE.focus.call(this);};function onBlur(){DC(this.getIframeDoc().documentElement,"DlRteFrame-Focused");BASE.blur.call(this,true);};})();(function(){DlSocket.inherits(DlEventProxy);function DlSocket(args){if(args){if(!args.host)args.host=document.domain;D.setDefaults(this,args);DlEventProxy.call(this);this.registerEvents(DEFAULT_EVENTS);this.addEventListener("onDestroy",onDestroy);DlEvent.atUnload(this.destroy.$(this));}};eval(Dynarch.EXPORT("DlSocket"));var DEFAULT_EVENTS=["onConnect","onRelease","onData"];var SOCKETS={};function onDestroy(){DlFlashUtils().getObject().DlSocket_destroy(this.id);delete SOCKETS[this.id];};D.DEFAULT_ARGS={_host:["host",null],_port:["port",null],_json:["json",false]};P.send=function(data){DlFlashUtils().getObject().DlSocket_send(this.id,data);};P.sendJSON=function(data){DlFlashUtils().getObject().DlSocket_send(this.id,DlJSON.encode(data));};P.connect=function(){this.id=DlFlashUtils().getObject().DlSocket_connect(this._host,this._port);SOCKETS[this.id]=this;};P.reconnect=function(){DlFlashUtils().getObject().DlSocket_reconnect(this.id);};P.disconnect=function(){DlFlashUtils().getObject().DlSocket_disconnect(this.id);};window.DlSocket_onConnect=function(id,status){SOCKETS[id].applyHooks("onConnect",[status]);};window.DlSocket_onData=function(id,data){data=data .replace(/%22/g,"\"").replace(/%5c/g,"\\").replace(/%26/g,"&").replace(/%25/g,"%");var sok=SOCKETS[id];if(sok._json)data=DlJSON.decode(data);sok.applyHooks("onData",[data]);};window.DlSocket_onDisconnect=function(id,reason){SOCKETS[id].applyHooks("onRelease",[reason]);};})();(function(){DlSound.inherits(DlEventProxy);function DlSound(args){if(args){D.setDefaults(this,args);DlEventProxy.call(this);this.registerEvents(DEFAULT_EVENTS);this.addEventListener("onDestroy",onDestroy);this.addEventListener("onLoad",onLoad);this.id=DlFlashUtils().getObject().DlSound_create();SOUNDS[this.id]=this;}};eval(Dynarch.EXPORT("DlSound"));D.DEFAULT_ARGS={_volume:["volume",null],_pan:["pan",null],_url:["url",null],_stream:["stream",false]};P.load=function(url,stream){if(url==null)url=this._url;if(stream==null)stream=this._stream;this.__fileLoaded=false;this.__loadCalled=true;DlFlashUtils().getObject().DlSound_load(this.id,this._url=url,this._stream=stream);};P.play=function(offset,loop){if(this.__fileLoaded){DlFlashUtils().getObject().DlSound_play(this.id,offset,loop);}else if(!this.__loadCalled){this.__shouldPlay=[offset,loop];this.load();}};P.stop=function(){DlFlashUtils().getObject().DlSound_stop(this.id);};P.getBytesLoaded=function(){return DlFlashUtils().getObject().DlSound_getBytesLoaded(this.id);};P.getBytesTotal=function(){return DlFlashUtils().getObject().DlSound_getBytesTotal(this.id);};P.getDuration=function(){return DlFlashUtils().getObject().DlSound_getDuration(this.id);};P.getPosition=function(){return DlFlashUtils().getObject().DlSound_getPosition(this.id);};P.setPan=function(pan){DlFlashUtils().getObject().DlSound_setPan(this.id,this._pan=pan);};P.setVolume=function(volume){DlFlashUtils().getObject().DlSound_setVolume(this.id,this._volume=volume);};P.getPan=function(){return this._pan;};P.getVolume=function(){return this._volume;};P.getURL=function(){return this._url;};var DEFAULT_EVENTS=["onLoad","onComplete"];var SOUNDS={};function onDestroy(){delete SOUNDS[this.id];};function onLoad(success){this.__fileLoaded=success;if(success&&this.__shouldPlay){this.play.apply(this,this.__shouldPlay);this.__shouldPlay=null;}};window.DlSound_onLoad=function(id,success){SOUNDS[id].applyHooks("onLoad",[success]);};window.DlSound_onSoundComplete=function(id){SOUNDS[id].callHooks("onComplete");};})();(function(){DlSpinner.inherits(DlEntry);function DlSpinner(args){if(args){args.validators=[new DlValidator(DlValidator.Number,args.minVal,args.maxVal,args.integer,args.decimals)];D.setDefaults(this,args);args.type="text";DlEntry.call(this,args);this._timer=null;this._timerStep=null;this._timerState=null;this._timerPos=null;}};eval(Dynarch.EXPORT("DlSpinner",true));var DEFAULT_EVENTS=["onSpin"];D.DEFAULT_ARGS={_step:["step",1],_size:["size",4],_value:["value",0],_minVal:["minVal",null],_maxVal:["maxVal",null],_decimals:["decimals",null],_integer:["integer",false]};P.intervals=[{pos:1,step:1,speed:125},{pos:10,step:1,speed:70},{pos:20,step:1,speed:35},{pos:50,step:1,speed:20},{pos:100,step:1,speed:10},{pos:200,step:2,speed:10}];P._createElement=function(){this._no_gecko_bug=true;D.BASE._createElement.call(this);var table=this.getElement();var r1=table.rows[0].cells[0];r1.rowSpan=2;r1=r1.parentNode;var r2=CE("tr",null,null,r1.parentNode);var c1=CE("td",null,{className:"DlSpinner-Button DlSpinner-Button-Up"},r1);var c2=CE("td",null,{className:"DlSpinner-Button DlSpinner-Button-Down"},r2);this._buttonUp=new DlButton({parent:this,appendArgs:c1});this._buttonDown=new DlButton({parent:this,appendArgs:c2});};function onFocus(){this.select();};function onBlur(){this._clearTimer();};function onMouseWheel(ev){this._spinnerUpdateVal(ev.wheelDelta>0);throw new DlExStopEventBubbling;};function onKeyDown(ev){switch(ev.keyCode){case DlKeyboard.ARROW_DOWN:spinnerAct.call(this,{_direction:false});throw new DlExStopEventBubbling;break;case DlKeyboard.ARROW_UP:spinnerAct.call(this,{_direction:true});throw new DlExStopEventBubbling;break;}};function onKeyUp(ev){this._clearTimer();};function onChange(){var val=this.getValue();var min=val==this._maxVal;var max=val==this._minVal;this._buttonUp.disabled(min);this._buttonDown.disabled(max);if(min||max)this._clearTimer();};P._setListeners=function(){D.BASE._setListeners.call(this);this.registerEvents(DEFAULT_EVENTS);this.addEventListener({onFocus:onFocus,onBlur:onBlur,onMouseWheel:onMouseWheel,onKeyDown:onKeyDown,onKeyUp:onKeyUp,onChange:onChange});};P.initDOM=function(){D.BASE.initDOM.call(this);this._setupSpinnerBtn(this._buttonUp,true);this._setupSpinnerBtn(this._buttonDown,false);};P._spinnerUpdateVal=function(dir){var val=new Number(this.getValue());var step=this._timerStep||this._step;val=dir?(val+step):(val-step);if(this._minVal!=null&&val<this._minVal)val=this._minVal;if(this._maxVal!=null&&val>this._maxVal)val=this._maxVal;this.setValue(val);this.applyHooks("onSpin",[val]);this.focus();this.select();if(this._timer){var p=++this._timerPos;if(this._timerState.length&&p==this._timerState[0].pos){var o=this._timerState.shift();this._clearTimer(true);this._timerStep=o.step;this._startTimer(dir,o.speed);}}};function spinnerAct(b){this._spinnerUpdateVal(b._direction);(this._timerState=Dynarch.makeArray(this.intervals)).r_foreach(function(e){e.step*=this.step;},this);this._timerPos=0;this._startTimer(b._direction,250);throw new DlExStopEventBubbling;};function spinnerMouseUp(b){this._clearTimer();};P._clearTimer=function(restart){if(this._timer)clearInterval(this._timer);if(!restart){this._timerState=null;this._timerStep=null;this._timerPos=null;}this._timer=null;};P._startTimer=function(dir,timeout){if(this._timer)clearInterval(this._timer);this._timer=setInterval(this._spinnerUpdateVal.$(this,dir),timeout);};P._setupSpinnerBtn=function(b,up){b._direction=up;var mouseUp=spinnerMouseUp.$(this,b);b.addEventListener({onMouseDown:spinnerAct.$(this,b),onMouseUp:mouseUp});};})();(function(){var BASE=DlTabs.inherits(DlContainer);function DlTabs(args){if(args){D.setDefaults(this,args);DlContainer.call(this,args);}};eval(Dynarch.EXPORT("DlTabs",true));var DEFAULT_EVENTS=["onChange"];D.DEFAULT_ARGS={_tabPos:["tabPos","top"]};function onNotebookChange(tabs,newIndex,oldIndex){var w=newIndex!=null?this._panes[newIndex]:null;w&&w._tab.checked(true);tabs.applyHooks("onChange",[newIndex,oldIndex]);};function onTabChange(btn){if(btn.checked())this._tabContent.showPane(btn.userData);};function onTabClick(ev){this.checked(true);throw new DlExStopEventProcessing();};P.addTab=function(w,title,pos){this._tabContent.appendWidget(w,pos);w._tab=new DlButton({label:title,parent:this._tabBar,group:this._tabGroup,type:DlButton.TYPE.TWOSTATE,data:this._tabContent.length()-1});w._tab.addEventListener("onClick",onTabClick,true);};P.getTabBar=function(){return this._tabBar;};P.getNotebook=function(){return this._tabContent;};P.getTabButton=function(index){return this.getNotebook().getPane(index)._tab;};P.getTabContent=P.getNotebook;P.initDOM=function(){BASE.initDOM.call(this);this._tabGroup=DlRadioGroup.get(this.id);this._tabBar=new DlHbox({className:"TabBar"});this._tabContent=new DlNotebook({className:"TabContent"});switch(this._tabPos){case "top":case "left":this.appendWidget(this._tabBar);this.appendWidget(this._tabContent);break;case "bottom":case "right":this.appendWidget(this._tabContent);this.appendWidget(this._tabBar);break;}this.registerEvents(DEFAULT_EVENTS);this._tabContent.addEventListener("onChange",onNotebookChange.$(this._tabContent,this));this._tabGroup.addEventListener("onChange",onTabChange.$(this));AC(this.getElement(),"DlTabs-"+this._tabPos);};P.setTabPos=function(tabPos){var bar=this._tabBar.getElement();var content=this._tabContent.getElement();if(bar.parentNode)bar.parentNode.removeChild(bar);var pos=(tabPos=="top"||tabPos=="left")?pos=content:null;content.parentNode.insertBefore(bar,pos);AC(this.getElement(),"DlTabs-"+tabPos,"DlTabs-"+this._tabPos);this._tabPos=tabPos;};P.setTabAlign=function(tabAlign){return this._tabBar.setAlign(tabAlign);};P.setOuterSize=P.setSize=function(size){BASE.setSize.call(this,size);size=this.getInnerSize();var bar=this._tabBar.getSize();switch(this._tabPos){case "top":case "bottom":size.y-=bar.y;break;case "left":case "right":size.x-=bar.x;break;}this._tabContent.setSize(size);};P.showPane=function(index){return this._tabContent.showPane(index);};P.nextPane=function(){return this._tabContent.nextPane();};P.prevPane=function(){return this._tabContent.prevPane();};P.isFirstPane=function(){return this._tabContent.isFirstPane();};P.isLastPane=function(){return this._tabContent.isLastPane();};P.getCurrentPane=function(){return this._tabContent.getCurrentPane();};P.getCurrentPaneIndex=function(){return this._tabContent.getCurrentPaneIndex();};P._handle_focusKeys=function(ev){if(ev.shiftKey){if(ev.keyCode==DlKeyboard.PAGE_UP){this.prevPane();this.getCurrentPane()._tab.focus();DlException.stopEventBubbling();}else if(ev.keyCode==DlKeyboard.PAGE_DOWN){this.nextPane();this.getCurrentPane()._tab.focus();DlException.stopEventBubbling();}}else if(ev.keyCode==DlKeyboard.TAB&&this._tabBar.focusInside()){var w=this.getCurrentPane().getFirstFocusWidget();if(w){w.focus();DlException.stopEventBubbling();}}};})();DlTooltip.inherits(DlPopup);function DlTooltip(args){if(args){args.zIndex=2000;args.focusable=false;DlPopup.call(this,args);this._mouseDiff={x:8,y:12};}};(function(){var BASE=DlTree.inherits(DlContainer);function DlTree(args){if(args){DlContainer.call(this,args);this.__treeItems=[];}};eval(Dynarch.EXPORT("DlTree",true));P.getItem=function(idx){return this.__treeItems[idx];};P.getItems=function(){return this.__treeItems;};P.appendWidget=function(w,pos){if(w instanceof DlTreeItem&&w.parent===this&&pos>w.getIndex()){--pos;}BASE.appendWidget.call(this,w,pos);};P.removeWidget=function(w){BASE.removeWidget.call(this,w);if(w instanceof DlTreeItem){var i=this.__treeItems.find(w);this.__treeItems.splice(i,1);var l=this.__treeItems.length;if(l==0){if(this.parent instanceof DlTreeItem)this.destroy();}else{if(i==0)this.__treeItems[i]._setFirstLast(true,null);if(i==l)this.__treeItems[i-1]._setFirstLast(null,true);}}};P._appendWidgetElement=function(w,pos){var a=this.__treeItems;var parent=this.getContentElement();if(pos==null){if(w instanceof DlTreeItem){var last=a.peek();last?last._setFirstLast(null,false):w._setFirstLast(true,null);a.push(w);w._setFirstLast(null,true);}parent.appendChild(w.getElement());}else{if(pos==a.length)return this._appendWidgetElement(w,null);var prev=a[pos];if(prev)prev._setFirstLast(false,pos==a.length-1);w._setFirstLast(pos==0,false);a.splice(pos,0,w);parent.insertBefore(w.getElement(),parent.childNodes[pos]);}};P.addSeparator=function(cls){CE("div",null,{className:cls||"DlTree-separator",innerHTML:"&nbsp;"},this.getElement());};})();(function(){var BASE=DlTreeItem.inherits(DlContainer);function DlTreeItem(args){if(args){DlTreeItem.setDefaults(this,args);DlContainer.call(this,args);this.setIconClass(this.__iconClass);this.__iconClass=null;}};eval(Dynarch.EXPORT("DlTreeItem",true));D.DEFAULT_ARGS={__label:["label",null],__iconClass:["iconClass",null],__itemClass:["itemClassName",null]};var DEFAULT_EVENTS=["onExpand","onCollapse","onLabelMouseDown"];var HTML=("<div class='DlTreeItem-div'>"+"<table cellspacing='0' cellpadding='0' class='DlTreeItem-Table'>"+"<tbody><tr>"+"<td class='DlTreeItem-Expander'><div class='DlTree-IconWidth'>&nbsp;</div></td>"+"<td></td>"+"<td class='DlTreeItem-Label'></td>"+"</tr></tbody></table>"+"</div>"+"<div class='DlTreeItem-Subtree'></div>");function getTD(ev){var el=ev.target;try{while(el&&el.tagName.toLowerCase()!="td")el=el.parentNode;}catch(ex){el=null;}return el;};function onClick(ev){var td=getTD(ev);if(td&&/DlTreeItem-(Expander|Icon)/.test(td.className)){this.toggle();throw new DlExStopEventBubbling;}};function onDestroy(){var div=this.getSubtreeDiv();div.parentNode.removeChild(div);DOM.removeEvent(this.getDivElement(),"mousedown",this.__onLabelMouseDown);};P._setFirstLast=function(isFirst,isLast){if(isFirst!=null){this.condClass(isFirst,"DlTreeItem-First");CC(this.getTableElement(),isFirst,"DlTreeItem-First");}if(isLast!=null){this.condClass(isLast,"DlTreeItem-Last");CC(this.getTableElement(),isLast,"DlTreeItem-Last");}};P.initDOM=function(){this.registerEvents(DEFAULT_EVENTS);BASE.initDOM.call(this);};P._setListeners=function(){BASE._setListeners.call(this);this.addEventListener({onMouseDown:onClick,onDestroy:onDestroy});};P._createElement=function(){BASE._createElement.call(this);this.getElement().innerHTML=HTML;if(this.__label)this.setContent(this.__label);this.setUnselectable();this.__onLabelMouseDown=this._onLabelMouseDown.$(this);DOM.addEvent(this.getDivElement(),"mousedown",this.__onLabelMouseDown);if(this.__itemClass)AC(this.getDivElement(),this.__itemClass);};P._onLabelMouseDown=function(ev){this.callHooks("onLabelMouseDown");};P.getDivElement=function(){return this.getElement().firstChild;};P.getTableElement=function(){return this.getElement().firstChild.firstChild;};P.getExpanderElement=function(){return this.getTableElement().rows[0].cells[0];};P.getIconElement=function(){return this.getTableElement().rows[0].cells[1];};P.getContentElement=function(){return this.getTableElement().rows[0].cells[2];};P.getSubtreeDiv=function(){return this.getElement().childNodes[1];};P.getSubtreeWidget=function(){return this._subtree;};P.getIndex=function(){return this.parent.__treeItems.find(this);};P.getParentItem=function(){return this.parent.parent;};P.addSubItem=function(item,pos){var tree=this.getSubtreeWidget();if(!tree&&!this._tree){tree=new DlTree({});this.setTree(tree);this.expand();}tree.appendWidget(item,pos);};P.setTree=function(tree,expand,timeout){if(this._tree&&(typeof this._tree!="function"))this.removeWidget(this._tree);this._tree=tree;if(tree!=null){if(typeof tree!="function"){this.appendWidget(tree,true);}else if(expand==null)expand=false;if(expand)this.expand(expand);else{this.getSubtreeDiv().style.display="none";this.updateExpanderState();}}if(timeout==null){this._subtreeNeverExpires=true;this._subtreeExpires=null;}else{this._subtreeNeverExpires=false;this._subtreeExpires=new Date().getTime()+timeout;}this.condClass(tree,"DlTreeItem-hasSubtree");this.updateExpanderState();};P.isExpanded=function(){return this.getSubtreeDiv().style.display!=="none";};P.toggle=function(){this.expand(!this.isExpanded());};P.getPath=function(){var path=[];var item=this.getParentItem();while(item instanceof DlTreeItem){path.push(item);item=item.getParentItem();}return path;};P.expandParents=function(expand){var item=this.getParentItem();while(item instanceof DlTreeItem){item.expand(expand);item=item.getParentItem();}};P.expand=function(expand,nohooks){if(expand==null)expand=true;var self=this;function cont(){self.getSubtreeDiv().style.display=expand?"block":"none";self.updateExpanderState();if(!nohooks)self.callHooks(expand?"onExpand":"onCollapse");};function cont2(tree,timeout){var tmp=self._tree;if(self._subtree)try{self._subtree.destroy();}catch(ex){}self._tree=tmp;if(timeout==null){self._subtreeNeverExpires=true;self._subtreeExpires=null;}else{self._subtreeNeverExpires=false;self._subtreeExpires=new Date().getTime()+timeout;}self.appendWidget(tree,true);cont();};if(expand!==this.isExpanded()){if(expand&&typeof this._tree=="function"){if(this._subtree){if(this._subtreeNeverExpires)cont();else{var time=new Date().getTime();if(this._subtreeExpires&&time<=this._subtreeExpires)cont();else this._tree(cont2,this);}}else this._tree(cont2,this);}else cont();}};P.setIconClass=function(iconClass){var e2=this.getIconElement();CC(e2,iconClass!=null,this._className.peek()+"-Icon");if(this.iconClass){e2.innerHTML="";DC(e2,this.iconClass);}if(iconClass){e2.innerHTML="<div class='DlTree-IconWidth'>&nbsp;</div>";AC(e2,iconClass);}this.iconClass=iconClass;};P.updateExpanderState=function(){var div=this.getExpanderElement().firstChild;if(this._tree){var expanded=this.isExpanded();CC(div,expanded,"DlTreeItem-Arrow-Expanded","DlTreeItem-Arrow-Collapsed");CC(this.getTableElement(),expanded,"DlTreeItem-Table-Expanded","DlTreeItem-Table-Collapsed");}else{DC(div,"DlTreeItem-Arrow-Expanded");DC(div,"DlTreeItem-Arrow-Collapsed");this.delClass("DlTreeItem-hasSubtree");}};P._appendWidgetElement=function(w,subtree){var el=w.getElement(),t;if(w instanceof DlTreeItem){this.addSubItem(w,subtree);}else{t=(subtree||w instanceof DlTree)?this.getSubtreeDiv():this.getContentElement();if(subtree){this._subtree=w;AC(el,"DlTree-withLines");this.addClass("DlTreeItem-hasSubtree");}t.appendChild(el);}};P._removeWidgetElement=function(w){BASE._removeWidgetElement.call(this,w);if(!this.getSubtreeDiv().firstChild){this._tree=null;this._subtree=null;}this.updateExpanderState();};P._setFocusedStyle=function(focused){CC(this.getDivElement(),focused,"DlTreeItem-div-focus");};})();function DlType(name){if(name){this.name=name;DlType.TYPES[name]=this;}};DlType.TYPES={};DlType.prototype={getDisplayValue:function(val){return val;},compare:function(a,b){throw "No comparator for type: "+this.name;}};(function(){var BASE=DlUploadEntry.inherits(DlWidget);function DlUploadEntry(args){if(args){D.setDefaults(this,args);if(!(this._files instanceof Array))this._files=[this._files];DlWidget.call(this,args);this.registerEvents(DEFAULT_EVENTS);}};eval(Dynarch.EXPORT("DlUploadEntry",true));var DEFAULT_EVENTS=["onUploadStart","onUploadEnd","onChange"];D.DEFAULT_ARGS={_url:["url",null],_files:["files",["file"]],_params:["params",null]};P._createElement=function(){BASE._createElement.call(this);var iframe=CE("iframe",{width:"80px",height:"24px",display:"block"},{frameBorder:0,marginHeight:0,marginWidth:0,allowTransparency:true,src:is_ie?"javascript:'';":"about:blank"},this.getElement());this.refNode("_iframe",iframe);};P.init=function(){var HTML=String.buffer("<html style='margin: 0; padding: 0; overflow: hidden; height: 100%;'>","<head></head>","<body style='background-color: transparent; margin: 0; padding: 0; overflow: hidden; height: 100%;'>","<form action='",this._url,"' method='POST' encoding='multipart/form-data'>","<input type='hidden' name='_uploaderID' value='",this.getWidgetId(),"' />");var p=this._params;if(p){if(p instanceof Array)p=p.toHash("");for(var i in p)HTML("<input type='hidden' name='",i,"' value='",p[i],"' />");}this._files.foreach(function(name){HTML("<label class='upload'><input type='file' name='",name,"' /></label>");});HTML("</form></body></html>");var win=this._iframe.contentWindow;var doc=win.document;doc.open();doc.write(HTML.get());doc.close();var head=doc.getElementsByTagName("head")[0];var link=doc.createElement("link");link.type="text/css";link.href=Dynarch.getFileURL("css/uploadentry.css");link.rel="stylesheet";head.appendChild(link);link.disabled=true;link.disabled=false;this.refNode("_win",win);this.refNode("_doc",doc);this.refNode("_form",doc.getElementsByTagName("form")[0]);this._form.method="POST";this._form.encoding="multipart/form-data";var change_handler=onUploadChange.$(null,this);this._files.foreach(function(name){var field=this._form.elements.namedItem(name);field.onchange=change_handler;field.parentNode.onmousemove=onMouseMove;},this);};P.setParam=function(name,val){if(typeof name=="string"){var el=this.getField(name);if(!el){el=this._doc.createElement("input");el.type="hidden";el.name=name;this._form.appendChild(el);}el.value=val;}else for(var i in name)this.setParam(i,name[i]);};P.getParam=function(name){var el=this.getField(name);return el&&el.value;};P.getField=function(name){return this._form.elements.namedItem(name);};P.submit=function(){this.callHooks("onUploadStart");this._form.submit();};D.finishUpload=function(upload){if(!(upload instanceof DlUploadEntry))upload=DlWidget.getById(upload);if(upload){upload.init();upload.applyHooks("onUploadEnd",Array.$(arguments,1));}else throw("No such uploader: "+upload);};function onUploadChange(obj){obj.applyHooks("onChange",[this,this.name,this.value]);};function onMouseMove(ev){if(is_ie)ev=this.ownerDocument.parentWindow.event;this.firstChild.style.right=30-ev.clientX+"px";};})();DlException.defineException("DlValidatorException");DlValidatorException.MISMATCH=1;DlValidatorException.TOO_SMALL=2;DlValidatorException.TOO_BIG=3;(function(){function DlValidator(callback){if(callback){this._callback=callback;this._args=arguments.length>1?Array.$(arguments,1):null;}};eval(Dynarch.EXPORT("DlValidator"));P.ok=function(data){if(typeof this._lastData!="undefined"&&this._lastData===data)return true;try{var args=[data].concat(this._args||Array.$(arguments,1));var val=this._callback.apply(this,args);this._lastData=data;this._lastValue=val;return true;}catch(ex){if(ex instanceof DlValidatorException){this._error=ex;return false;}else throw ex;}};P.getLastVal=function(){return this._lastValue;};P.getLastData=function(){return this._lastData;};P.getError=function(){return this._error;};D.Number=function(data,minVal,maxVal,integer,decimals){data=data.replace(/\s/g,"");var n=new Number(data);if(isNaN(n))throw new DlValidatorException("Value must be numeric",DlValidatorException.MISMATCH);if(integer&&n!=Math.round(n))throw new DlValidatorException("Value must be an integer",DlValidatorException.MISMATCH);if(minVal!=null&&n<minVal)throw new DlValidatorException("Value must be bigger than "+minVal,DlValidatorException.TOO_SMALL);if(maxVal!=null&&n>maxVal)throw new DlValidatorException("Value must be smaller than "+maxVal,DlValidatorException.TOO_BIG);if(decimals)n=n.toFixed(decimals);return n;};D.Email=function(data){if(!/^([^@\n\r]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i.test(data)){throw new DlValidatorException("That doesn't look like an email address",DlValidatorException.MISMATCH);}return data;};D.URL=function(data,args){if(!args)args={};if(!/^(https?|ftps?):\x2f\x2f/.test(data))throw new DlValidatorException("Value must be an absolute URL",DlValidatorException.MISMATCH);return data;};})();/*
 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
 * Digest Algorithm, as defined in RFC 1321.
 * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
 * Distributed under the BSD License
 * See http://pajhome.org.uk/crypt/md5 for more info.
 *
 * Adapted for DynarchLIB by Mihai Bazon.
 */
(function(){var hexcase=0;var b64pad="";var chrsz=8;window.hex_md5=function(s){return binl2hex(core_md5(str2binl(s),s.length*chrsz));};window.b64_md5=function(s){return binl2b64(core_md5(str2binl(s),s.length*chrsz));};window.str_md5=function(s){return binl2str(core_md5(str2binl(s),s.length*chrsz));};window.hex_hmac_md5=function(key,data){return binl2hex(core_hmac_md5(key,data));};window.b64_hmac_md5=function(key,data){return binl2b64(core_hmac_md5(key,data));};window.str_hmac_md5=function(key,data){return binl2str(core_hmac_md5(key,data));};function md5_vm_test(){return hex_md5("abc")=="900150983cd24fb0d6963f7d28e17f72";};function core_md5(x,len){x[len>>5]|=0x80<<((len)%32);x[(((len+64)>>>9)<<4)+14]=len;var a=1732584193;var b=-271733879;var c=-1732584194;var d=271733878;for(var i=0;i<x.length;i+=16){var olda=a;var oldb=b;var oldc=c;var oldd=d;a=md5_ff(a,b,c,d,x[i+0],7,-680876936);d=md5_ff(d,a,b,c,x[i+1],12,-389564586);c=md5_ff(c,d,a,b,x[i+2],17,606105819);b=md5_ff(b,c,d,a,x[i+3],22,-1044525330);a=md5_ff(a,b,c,d,x[i+4],7,-176418897);d=md5_ff(d,a,b,c,x[i+5],12,1200080426);c=md5_ff(c,d,a,b,x[i+6],17,-1473231341);b=md5_ff(b,c,d,a,x[i+7],22,-45705983);a=md5_ff(a,b,c,d,x[i+8],7,1770035416);d=md5_ff(d,a,b,c,x[i+9],12,-1958414417);c=md5_ff(c,d,a,b,x[i+10],17,-42063);b=md5_ff(b,c,d,a,x[i+11],22,-1990404162);a=md5_ff(a,b,c,d,x[i+12],7,1804603682);d=md5_ff(d,a,b,c,x[i+13],12,-40341101);c=md5_ff(c,d,a,b,x[i+14],17,-1502002290);b=md5_ff(b,c,d,a,x[i+15],22,1236535329);a=md5_gg(a,b,c,d,x[i+1],5,-165796510);d=md5_gg(d,a,b,c,x[i+6],9,-1069501632);c=md5_gg(c,d,a,b,x[i+11],14,643717713);b=md5_gg(b,c,d,a,x[i+0],20,-373897302);a=md5_gg(a,b,c,d,x[i+5],5,-701558691);d=md5_gg(d,a,b,c,x[i+10],9,38016083);c=md5_gg(c,d,a,b,x[i+15],14,-660478335);b=md5_gg(b,c,d,a,x[i+4],20,-405537848);a=md5_gg(a,b,c,d,x[i+9],5,568446438);d=md5_gg(d,a,b,c,x[i+14],9,-1019803690);c=md5_gg(c,d,a,b,x[i+3],14,-187363961);b=md5_gg(b,c,d,a,x[i+8],20,1163531501);a=md5_gg(a,b,c,d,x[i+13],5,-1444681467);d=md5_gg(d,a,b,c,x[i+2],9,-51403784);c=md5_gg(c,d,a,b,x[i+7],14,1735328473);b=md5_gg(b,c,d,a,x[i+12],20,-1926607734);a=md5_hh(a,b,c,d,x[i+5],4,-378558);d=md5_hh(d,a,b,c,x[i+8],11,-2022574463);c=md5_hh(c,d,a,b,x[i+11],16,1839030562);b=md5_hh(b,c,d,a,x[i+14],23,-35309556);a=md5_hh(a,b,c,d,x[i+1],4,-1530992060);d=md5_hh(d,a,b,c,x[i+4],11,1272893353);c=md5_hh(c,d,a,b,x[i+7],16,-155497632);b=md5_hh(b,c,d,a,x[i+10],23,-1094730640);a=md5_hh(a,b,c,d,x[i+13],4,681279174);d=md5_hh(d,a,b,c,x[i+0],11,-358537222);c=md5_hh(c,d,a,b,x[i+3],16,-722521979);b=md5_hh(b,c,d,a,x[i+6],23,76029189);a=md5_hh(a,b,c,d,x[i+9],4,-640364487);d=md5_hh(d,a,b,c,x[i+12],11,-421815835);c=md5_hh(c,d,a,b,x[i+15],16,530742520);b=md5_hh(b,c,d,a,x[i+2],23,-995338651);a=md5_ii(a,b,c,d,x[i+0],6,-198630844);d=md5_ii(d,a,b,c,x[i+7],10,1126891415);c=md5_ii(c,d,a,b,x[i+14],15,-1416354905);b=md5_ii(b,c,d,a,x[i+5],21,-57434055);a=md5_ii(a,b,c,d,x[i+12],6,1700485571);d=md5_ii(d,a,b,c,x[i+3],10,-1894986606);c=md5_ii(c,d,a,b,x[i+10],15,-1051523);b=md5_ii(b,c,d,a,x[i+1],21,-2054922799);a=md5_ii(a,b,c,d,x[i+8],6,1873313359);d=md5_ii(d,a,b,c,x[i+15],10,-30611744);c=md5_ii(c,d,a,b,x[i+6],15,-1560198380);b=md5_ii(b,c,d,a,x[i+13],21,1309151649);a=md5_ii(a,b,c,d,x[i+4],6,-145523070);d=md5_ii(d,a,b,c,x[i+11],10,-1120210379);c=md5_ii(c,d,a,b,x[i+2],15,718787259);b=md5_ii(b,c,d,a,x[i+9],21,-343485551);a=safe_add(a,olda);b=safe_add(b,oldb);c=safe_add(c,oldc);d=safe_add(d,oldd);}return Array(a,b,c,d);};function md5_cmn(q,a,b,x,s,t){return safe_add(bit_rol(safe_add(safe_add(a,q),safe_add(x,t)),s),b);};function md5_ff(a,b,c,d,x,s,t){return md5_cmn((b&c)|((~b)&d),a,b,x,s,t);};function md5_gg(a,b,c,d,x,s,t){return md5_cmn((b&d)|(c&(~d)),a,b,x,s,t);};function md5_hh(a,b,c,d,x,s,t){return md5_cmn(b ^ c ^ d,a,b,x,s,t);};function md5_ii(a,b,c,d,x,s,t){return md5_cmn(c ^(b|(~d)),a,b,x,s,t);};function core_hmac_md5(key,data){var bkey=str2binl(key);if(bkey.length>16)bkey=core_md5(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_md5(ipad.concat(str2binl(data)),512+data.length*chrsz);return core_md5(opad.concat(hash),512+128);};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 bit_rol(num,cnt){return(num<<cnt)|(num>>>(32-cnt));};function str2binl(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)<<(i%32);return bin;};function binl2str(bin){var str="";var mask=(1<<chrsz)-1;for(var i=0;i<bin.length*32;i+=chrsz)str+=String.fromCharCode((bin[i>>5]>>>(i%32))&mask);return str;};function binl2hex(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]>>((i%4)*8+4))&0xF)+hex_tab.charAt((binarray[i>>2]>>((i%4)*8))&0xF);}return str;};function binl2b64(binarray){var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var str="";for(var i=0;i<binarray.length*4;i+=3){var triplet=(((binarray[i>>2]>>8*(i%4))&0xFF)<<16)|(((binarray[i+1>>2]>>8*((i+1)%4))&0xFF)<<8)|((binarray[i+2>>2]>>8*((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;};})();/* Part of DynarchLIB
   Copyright (c) Dynarch.com 2005-2008.  All rights reserved.
   See http://www.dynarchlib.com/licensing for details.

//--
// Based on a C implementation of the AES algorithm found in the
// Crypt::Rijndael Perl module.
//
//    http://search.cpan.org/~bdfoy/Crypt-Rijndael-1.05/
//    http://search.cpan.org/src/BDFOY/Crypt-Rijndael-1.05/_rijndael.c
//
// Original C code is Copyright 2000, 2001 Rafael R. Sevilla <sevillar@team.ph.inter.net>
// The Perl module is currently maintained by brian d foy, <bdfoy@cpan.org>
//
// Great work guys!
//
// The Original C code is distributed under the GNU LGPL, version 2.0 or later.
//
// Written in JavaScript for DynarchLIB by Mihai Bazon.
//--

*/
(function(){function DlCryptAES(args){D.setDefaults(this,args);expandKey.call(this,this._key);this._mode=MODES[this._mode.toUpperCase()];this._rounds=ROUNDS[this._key.length];if(!this._iv)this._iv=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];};eval(Dynarch.EXPORT("DlCryptAES"));D.DEFAULT_ARGS={_key:["key",null],_mode:["mode","ECB"],_iv:["iv",null]};var SBOX=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22];var R_SBOX=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125];var LOGTABLE=[0,0,25,1,50,2,26,198,75,199,27,104,51,238,223,3,100,4,224,14,52,141,129,239,76,113,8,200,248,105,28,193,125,194,29,181,249,185,39,106,77,228,166,114,154,201,9,120,101,47,138,5,33,15,225,36,18,240,130,69,53,147,218,142,150,143,219,189,54,208,206,148,19,92,210,241,64,70,131,56,102,221,253,48,191,6,139,98,179,37,226,152,34,136,145,16,126,110,72,195,163,182,30,66,58,107,40,84,250,133,61,186,43,121,10,21,155,159,94,202,78,212,172,229,243,115,167,87,175,88,168,80,244,234,214,116,79,174,233,213,231,230,173,232,44,215,117,122,235,22,11,245,89,203,95,176,156,169,81,160,127,12,246,111,23,196,73,236,216,67,31,45,164,118,123,183,204,187,62,90,251,96,177,134,59,82,161,108,170,85,41,157,151,178,135,144,97,190,220,252,188,149,207,205,55,63,91,209,83,57,132,60,65,162,109,71,20,42,158,93,86,242,211,171,68,17,146,217,35,32,46,137,180,124,184,38,119,153,227,165,103,74,237,222,197,49,254,24,13,99,140,128,192,247,112,7];var ALOGTABLE=[1,3,5,15,17,51,85,255,26,46,114,150,161,248,19,53,95,225,56,72,216,115,149,164,247,2,6,10,30,34,102,170,229,52,92,228,55,89,235,38,106,190,217,112,144,171,230,49,83,245,4,12,20,60,68,204,79,209,104,184,211,110,178,205,76,212,103,169,224,59,77,215,98,166,241,8,24,40,120,136,131,158,185,208,107,189,220,127,129,152,179,206,73,219,118,154,181,196,87,249,16,48,80,240,11,29,39,105,187,214,97,163,254,25,43,125,135,146,173,236,47,113,147,174,233,32,96,160,251,22,58,78,210,109,183,194,93,231,50,86,250,21,63,65,195,94,226,61,71,201,64,192,91,237,44,116,156,191,218,117,159,186,213,100,172,239,42,126,130,157,188,223,122,142,137,128,155,182,193,88,232,35,101,175,234,37,111,177,200,67,197,84,252,31,33,99,165,244,7,9,27,45,119,153,176,203,70,202,69,207,74,222,121,139,134,145,168,227,62,66,198,81,243,14,18,54,90,238,41,123,141,140,143,138,133,148,167,242,13,23,57,75,221,124,132,151,162,253,28,36,108,180,199,82,246,1];var DTBL=[0xa56363c6,0x847c7cf8,0x997777ee,0x8d7b7bf6,0x0df2f2ff,0xbd6b6bd6,0xb16f6fde,0x54c5c591,0x50303060,0x03010102,0xa96767ce,0x7d2b2b56,0x19fefee7,0x62d7d7b5,0xe6abab4d,0x9a7676ec,0x45caca8f,0x9d82821f,0x40c9c989,0x877d7dfa,0x15fafaef,0xeb5959b2,0xc947478e,0x0bf0f0fb,0xecadad41,0x67d4d4b3,0xfda2a25f,0xeaafaf45,0xbf9c9c23,0xf7a4a453,0x967272e4,0x5bc0c09b,0xc2b7b775,0x1cfdfde1,0xae93933d,0x6a26264c,0x5a36366c,0x413f3f7e,0x02f7f7f5,0x4fcccc83,0x5c343468,0xf4a5a551,0x34e5e5d1,0x08f1f1f9,0x937171e2,0x73d8d8ab,0x53313162,0x3f15152a,0x0c040408,0x52c7c795,0x65232346,0x5ec3c39d,0x28181830,0xa1969637,0x0f05050a,0xb59a9a2f,0x0907070e,0x36121224,0x9b80801b,0x3de2e2df,0x26ebebcd,0x6927274e,0xcdb2b27f,0x9f7575ea,0x1b090912,0x9e83831d,0x742c2c58,0x2e1a1a34,0x2d1b1b36,0xb26e6edc,0xee5a5ab4,0xfba0a05b,0xf65252a4,0x4d3b3b76,0x61d6d6b7,0xceb3b37d,0x7b292952,0x3ee3e3dd,0x712f2f5e,0x97848413,0xf55353a6,0x68d1d1b9,0x00000000,0x2cededc1,0x60202040,0x1ffcfce3,0xc8b1b179,0xed5b5bb6,0xbe6a6ad4,0x46cbcb8d,0xd9bebe67,0x4b393972,0xde4a4a94,0xd44c4c98,0xe85858b0,0x4acfcf85,0x6bd0d0bb,0x2aefefc5,0xe5aaaa4f,0x16fbfbed,0xc5434386,0xd74d4d9a,0x55333366,0x94858511,0xcf45458a,0x10f9f9e9,0x06020204,0x817f7ffe,0xf05050a0,0x443c3c78,0xba9f9f25,0xe3a8a84b,0xf35151a2,0xfea3a35d,0xc0404080,0x8a8f8f05,0xad92923f,0xbc9d9d21,0x48383870,0x04f5f5f1,0xdfbcbc63,0xc1b6b677,0x75dadaaf,0x63212142,0x30101020,0x1affffe5,0x0ef3f3fd,0x6dd2d2bf,0x4ccdcd81,0x140c0c18,0x35131326,0x2fececc3,0xe15f5fbe,0xa2979735,0xcc444488,0x3917172e,0x57c4c493,0xf2a7a755,0x827e7efc,0x473d3d7a,0xac6464c8,0xe75d5dba,0x2b191932,0x957373e6,0xa06060c0,0x98818119,0xd14f4f9e,0x7fdcdca3,0x66222244,0x7e2a2a54,0xab90903b,0x8388880b,0xca46468c,0x29eeeec7,0xd3b8b86b,0x3c141428,0x79dedea7,0xe25e5ebc,0x1d0b0b16,0x76dbdbad,0x3be0e0db,0x56323264,0x4e3a3a74,0x1e0a0a14,0xdb494992,0x0a06060c,0x6c242448,0xe45c5cb8,0x5dc2c29f,0x6ed3d3bd,0xefacac43,0xa66262c4,0xa8919139,0xa4959531,0x37e4e4d3,0x8b7979f2,0x32e7e7d5,0x43c8c88b,0x5937376e,0xb76d6dda,0x8c8d8d01,0x64d5d5b1,0xd24e4e9c,0xe0a9a949,0xb46c6cd8,0xfa5656ac,0x07f4f4f3,0x25eaeacf,0xaf6565ca,0x8e7a7af4,0xe9aeae47,0x18080810,0xd5baba6f,0x887878f0,0x6f25254a,0x722e2e5c,0x241c1c38,0xf1a6a657,0xc7b4b473,0x51c6c697,0x23e8e8cb,0x7cdddda1,0x9c7474e8,0x211f1f3e,0xdd4b4b96,0xdcbdbd61,0x868b8b0d,0x858a8a0f,0x907070e0,0x423e3e7c,0xc4b5b571,0xaa6666cc,0xd8484890,0x05030306,0x01f6f6f7,0x120e0e1c,0xa36161c2,0x5f35356a,0xf95757ae,0xd0b9b969,0x91868617,0x58c1c199,0x271d1d3a,0xb99e9e27,0x38e1e1d9,0x13f8f8eb,0xb398982b,0x33111122,0xbb6969d2,0x70d9d9a9,0x898e8e07,0xa7949433,0xb69b9b2d,0x221e1e3c,0x92878715,0x20e9e9c9,0x49cece87,0xff5555aa,0x78282850,0x7adfdfa5,0x8f8c8c03,0xf8a1a159,0x80898909,0x170d0d1a,0xdabfbf65,0x31e6e6d7,0xc6424284,0xb86868d0,0xc3414182,0xb0999929,0x772d2d5a,0x110f0f1e,0xcbb0b07b,0xfc5454a8,0xd6bbbb6d,0x3a16162c];var ITBL=[0x50a7f451,0x5365417e,0xc3a4171a,0x965e273a,0xcb6bab3b,0xf1459d1f,0xab58faac,0x9303e34b,0x55fa3020,0xf66d76ad,0x9176cc88,0x254c02f5,0xfcd7e54f,0xd7cb2ac5,0x80443526,0x8fa362b5,0x495ab1de,0x671bba25,0x980eea45,0xe1c0fe5d,0x02752fc3,0x12f04c81,0xa397468d,0xc6f9d36b,0xe75f8f03,0x959c9215,0xeb7a6dbf,0xda595295,0x2d83bed4,0xd3217458,0x2969e049,0x44c8c98e,0x6a89c275,0x78798ef4,0x6b3e5899,0xdd71b927,0xb64fe1be,0x17ad88f0,0x66ac20c9,0xb43ace7d,0x184adf63,0x82311ae5,0x60335197,0x457f5362,0xe07764b1,0x84ae6bbb,0x1ca081fe,0x942b08f9,0x58684870,0x19fd458f,0x876cde94,0xb7f87b52,0x23d373ab,0xe2024b72,0x578f1fe3,0x2aab5566,0x0728ebb2,0x03c2b52f,0x9a7bc586,0xa50837d3,0xf2872830,0xb2a5bf23,0xba6a0302,0x5c8216ed,0x2b1ccf8a,0x92b479a7,0xf0f207f3,0xa1e2694e,0xcdf4da65,0xd5be0506,0x1f6234d1,0x8afea6c4,0x9d532e34,0xa055f3a2,0x32e18a05,0x75ebf6a4,0x39ec830b,0xaaef6040,0x069f715e,0x51106ebd,0xf98a213e,0x3d06dd96,0xae053edd,0x46bde64d,0xb58d5491,0x055dc471,0x6fd40604,0xff155060,0x24fb9819,0x97e9bdd6,0xcc434089,0x779ed967,0xbd42e8b0,0x888b8907,0x385b19e7,0xdbeec879,0x470a7ca1,0xe90f427c,0xc91e84f8,0x00000000,0x83868009,0x48ed2b32,0xac70111e,0x4e725a6c,0xfbff0efd,0x5638850f,0x1ed5ae3d,0x27392d36,0x64d90f0a,0x21a65c68,0xd1545b9b,0x3a2e3624,0xb1670a0c,0x0fe75793,0xd296eeb4,0x9e919b1b,0x4fc5c080,0xa220dc61,0x694b775a,0x161a121c,0x0aba93e2,0xe52aa0c0,0x43e0223c,0x1d171b12,0x0b0d090e,0xadc78bf2,0xb9a8b62d,0xc8a91e14,0x8519f157,0x4c0775af,0xbbdd99ee,0xfd607fa3,0x9f2601f7,0xbcf5725c,0xc53b6644,0x347efb5b,0x7629438b,0xdcc623cb,0x68fcedb6,0x63f1e4b8,0xcadc31d7,0x10856342,0x40229713,0x2011c684,0x7d244a85,0xf83dbbd2,0x1132f9ae,0x6da129c7,0x4b2f9e1d,0xf330b2dc,0xec52860d,0xd0e3c177,0x6c16b32b,0x99b970a9,0xfa489411,0x2264e947,0xc48cfca8,0x1a3ff0a0,0xd82c7d56,0xef903322,0xc74e4987,0xc1d138d9,0xfea2ca8c,0x360bd498,0xcf81f5a6,0x28de7aa5,0x268eb7da,0xa4bfad3f,0xe49d3a2c,0x0d927850,0x9bcc5f6a,0x62467e54,0xc2138df6,0xe8b8d890,0x5ef7392e,0xf5afc382,0xbe805d9f,0x7c93d069,0xa92dd56f,0xb31225cf,0x3b99acc8,0xa77d1810,0x6e639ce8,0x7bbb3bdb,0x097826cd,0xf418596e,0x01b79aec,0xa89a4f83,0x656e95e6,0x7ee6ffaa,0x08cfbc21,0xe6e815ef,0xd99be7ba,0xce366f4a,0xd4099fea,0xd67cb029,0xafb2a431,0x31233f2a,0x3094a5c6,0xc066a235,0x37bc4e74,0xa6ca82fc,0xb0d090e0,0x15d8a733,0x4a9804f1,0xf7daec41,0x0e50cd7f,0x2ff69117,0x8dd64d76,0x4db0ef43,0x544daacc,0xdf0496e4,0xe3b5d19e,0x1b886a4c,0xb81f2cc1,0x7f516546,0x04ea5e9d,0x5d358c01,0x737487fa,0x2e410bfb,0x5a1d67b3,0x52d2db92,0x335610e9,0x1347d66d,0x8c61d79a,0x7a0ca137,0x8e14f859,0x893c13eb,0xee27a9ce,0x35c961b7,0xede51ce1,0x3cb1477a,0x59dfd29c,0x3f73f255,0x79ce1418,0xbf37c773,0xeacdf753,0x5baafd5f,0x146f3ddf,0x86db4478,0x81f3afca,0x3ec468b9,0x2c342438,0x5f40a3c2,0x72c31d16,0x0c25e2bc,0x8b493c28,0x41950dff,0x7101a839,0xdeb30c08,0x9ce4b4d8,0x90c15664,0x6184cb7b,0x70b632d5,0x745c6c48,0x4257b8d0];var IDX=[[0,1,2,3],[1,2,3,0],[2,3,0,1],[3,0,1,2]];var R_IDX=[[0,1,2,3],[3,0,1,2],[2,3,0,1],[1,2,3,0]];var ROUNDS={16:10,24:12,32:14};var ESIZE={16:16*11,24:16*13,32:16*15};function RR(w){return(w>>>8)|((w&0xFF)<<24)};function RL(w){return(w<<8)|((w>>>24)&0xFF)};function SB(w,b){return b[w&0xFF]|(b[(w>>>8)&0xFF]<<8)|(b[(w>>>16)&0xFF]<<16)|(b[(w>>>24)&0xFF]<<24)};function xtime(a){var b=(a&0x80)?0x1b:0;a<<=1;a ^=b;return a;};function mul(a,b){return a&&b?ALOGTABLE[(LOGTABLE[a]+LOGTABLE[b])%255]:0;};function invMixColumn(a,b,p){var c=[[],[],[],[]],i,j;for(j=0;j<4;++j){for(i=0;i<4;++i){c[j][i]=mul(0xe,(a[j+p]>>>(i<<3))&0xff)^ mul(0xb,(a[j+p]>>>(((i+1)&3)<<3))&0xff)^ mul(0xd,(a[j+p]>>>(((i+2)&3)<<3))&0xff)^ mul(0x9,(a[j+p]>>>(((i+3)&3)<<3))&0xff);}}for(i=0;i<4;++i){b[i+p]=0;for(j=0;j<4;++j)b[i+p]|=c[i][j]<<(j<<3);}};function packBytes(a){var b=[],n=a.length/4;for(var i=0;i<n;++i){b[i]=a[i<<2]|(a[(i<<2)+1]<<8)|(a[(i<<2)+2]<<16)|(a[(i<<2)+3]<<24);}return b;};function unpackBytes(b){var n=b.length,a=new Array(n*4),j=0,c;for(var i=0;i<n;++i){c=b[i];a[j++]=c&0xFF;a[j++]=(c>>>8)&0xFF;a[j++]=(c>>>16)&0xFF;a[j++]=(c>>>24)&0xFF;}return a;};function expandKey(k){var a=packBytes(k);var nk=k.length/4;var i,tmp;var rcon=1;var esize=ESIZE[k.length]/4;for(i=nk;i<esize;++i){tmp=a[i-1];if(i%nk==0){tmp=SB(RR(tmp),SBOX)^ rcon;rcon=xtime(rcon)&0xFF;}else if(nk>6&&(i%nk)==4){tmp=SB(tmp,SBOX);}a[i]=a[i-nk]^ tmp;}var b=[];for(i=0;i<4;++i){b[i]=a[i];b[esize-4+i]=a[esize-4+i];}for(i=4;i<esize-4;i+=4)invMixColumn(a,b,i);this._exk=a;this._rexk=b;};function addRoundKey(s,d,key,k){k<<=2;for(var j=4;--j>=0;)d[j]=s[j]^ key[k|j];};function cypher(a){var key=this._exk,n=this._rounds;a=packBytes(a);addRoundKey(a,a,key,0);var t=[];for(var r=1;r<n;++r){for(var j=0;j<4;++j){t[j]=DTBL[a[j]&0xFF]^ RL(DTBL[(a[IDX[1][j]]>>>8)&0xFF]^ RL(DTBL[(a[IDX[2][j]]>>>16)&0xFF]^ RL(DTBL[(a[IDX[3][j]]>>>24)&0xFF])));}addRoundKey(t,a,key,r);}for(j=0;j<4;++j){t[j]=SB(((a[j]&0xFF)|(a[IDX[1][j]]&0xFF00)|(a[IDX[2][j]]&0xFF0000)|(a[IDX[3][j]]&0xFF000000)),SBOX);}addRoundKey(t,a,key,n);return unpackBytes(a);};function r_cypher(a){var key=this._rexk,n=this._rounds;a=packBytes(a);addRoundKey(a,a,key,n);var t=[];for(var r=n;--r>0;){for(var j=0;j<4;++j){t[j]=ITBL[a[j]&0xFF]^ RL(ITBL[(a[R_IDX[1][j]]>>>8)&0xFF]^ RL(ITBL[(a[R_IDX[2][j]]>>>16)&0xFF]^ RL(ITBL[(a[R_IDX[3][j]]>>>24)&0xFF])));}addRoundKey(t,a,key,r);}for(j=0;j<4;++j){t[j]=SB(((a[j]&0xFF)|(a[R_IDX[1][j]]&0xFF00)|(a[R_IDX[2][j]]&0xFF0000)|(a[R_IDX[3][j]]&0xFF000000)),R_SBOX);}addRoundKey(t,a,key,0);return unpackBytes(a);};P.encodeBytes=function(input){return this._mode[0].call(this,input);};P.decodeBytes=function(input){return this._mode[1].call(this,input);};P.encodeText=function(str){str=str.length+":"+str;var input=str.toBytes(),diff=input.length%16;while(diff++<16)input.push(32);return this.encodeBytes(input);};P.decodeText=function(input){var str=this.decodeBytes(input).bytesToString(),pos=str.indexOf(":"),len=parseInt(str.substr(0,pos));return str.substr(pos+1).substr(0,len);};P.setIV=function(iv){this._iv=iv};P.getIV=function(){return this._iv};P.setTimestampIV=function(){this.setIV(new Date().getTime().hex(16).hexToBytes().concat([0,0,0,0,0,0,0,0]));};function _runBytesECB(input,decode){decode=decode?r_cypher:cypher;var output=[];for(var k=0;k<input.length;k+=16){var state=input.slice(k,k+16);state=decode.call(this,state);output.push.apply(output,state);}return output;};function _encodeECB(input){return _runBytesECB.call(this,input,false)};function _decodeECB(input){return _runBytesECB.call(this,input,true)};function _runBytesCTR(input){var cb=this._iv.slice(0),k,i,output=[],n=input.length,tmp;for(k=0;k<n;k+=16){tmp=cb.slice(0);tmp=cypher.call(this,tmp);for(i=16;--i>=0&&!(cb[i]=((cb[i]+1)&0xFF));){}for(i=16;--i>=0;)output[i+k]=tmp[i]^ input[i+k];}return output;};function _encodeCBC(input){var cb=this._iv.slice(0),k,i,output=[],n=input.length;for(k=0;k<n;k+=16){for(i=16;--i>=0;)cb[i]^=input[i+k];cb=cypher.call(this,cb);for(i=16;--i>=0;)output[i+k]=cb[i];}return output;};function _decodeCBC(input){var cb=input.slice(0,16),k,i,output=[],n=input.length;cb=r_cypher.call(this,cb);for(i=16;--i>=0;)output[i]=cb[i]^ this._iv[i];for(k=16;k<n;k+=16){cb=input.slice(k,k+16);cb=r_cypher.call(this,cb);for(i=16;--i>=0;)output[i+k]=cb[i]^ input[k-16+i];}return output;};function _encodeCFB(input){var cb=this._iv.slice(0),k,i,output=[],n=input.length;for(k=0;k<n;k+=16){cb=cypher.call(this,cb);for(i=16;--i>=0;)cb[i]^=input[i+k];output.push.apply(output,cb);}return output;};function _decodeCFB(input){var cb=this._iv.slice(0),k,i,output=[],n=input.length;for(k=0;k<n;k+=16){cb=cypher.call(this,cb);for(i=16;--i>=0;)output[i+k]=cb[i]^ input[i+k];cb=input.slice(k,k+16);}return output;};function _runBytesOFB(input){var cb=this._iv.slice(0),k,i,output=[],n=input.length;for(k=0;k<n;k+=16){cb=cypher.call(this,cb);for(i=16;--i>=0;)output[i+k]=cb[i]^ input[i+k];}return output;};var MODES={"ECB":[_encodeECB,_decodeECB],"CBC":[_encodeCBC,_decodeCBC],"CFB":[_encodeCFB,_decodeCFB],"OFB":[_runBytesOFB,_runBytesOFB],"CTR":[_runBytesCTR,_runBytesCTR]};})();/*
 * Dynarch Chess
 *                                                                ____   _____
 * Online JavaScript-based Chess Game                             \  /_  /   /
 *                                                                 \  / /   /
 * Copyright (c) Dynarch.com 2007-2008.  All rights reserved.       \/ /_  /
 * http://chess.dynarch.com                                          \  / /
 *                                                                     / /
 *          this package built at 2008/04/30 13:29 GMT                 \/
 */
(function(){var DEFAULT_EVENTS=["onMove","onCheck","onMate","onDraw","onAnalyze"];Position.inherits(DlEventProxy);function Position(){DlEventProxy.call(this);this.registerEvents(DEFAULT_EVENTS);};eval(Dynarch.EXPORT("Position"));var TMPL_PGN_TXT=String.template(['[Event "Dynarch Chess"]','[Site "http://chess.dynarch.com/"]','[Date "$date"]','[Time "$time"]','[White "$white_name"]','[Black "$black_name"]','[Result "$result"]','[WhiteElo "$white_elo"]','[BlackElo "$black_elo"]','\n$moves'].join("\n"));var TMPL_PGN_HTML=String.template(['[<span class="kword">Event</span> "Dynarch Chess"]','[<span class="kword">Site</span> "http://chess.dynarch.com/"]','[<span class="kword">Date</span> "$date"]','[<span class="kword">Time</span> "$time"]','[<span class="kword">White</span> "$white_name"]','[<span class="kword">Black</span> "$black_name"]','[<span class="kword">Result</span> "$result"]','[<span class="kword">WhiteElo</span> "$white_elo"]','[<span class="kword">BlackElo</span> "$black_elo"]','<br/>$moves'].join("<br/>"));D.FEN_STANDARD="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";D.printMove=function(m){return Math.ceil(m.number/2)+(m.number&1?". ":". ... ")+m.pgn;};var PIECES=D.PIECES={P:{id:"P",lid:"p",name:"pawn",color:true},N:{id:"N",lid:"n",name:"knight",color:true},B:{id:"B",lid:"b",name:"bishop",color:true},R:{id:"R",lid:"r",name:"rook",color:true},Q:{id:"Q",lid:"q",name:"queen",color:true},K:{id:"K",lid:"k",name:"king",color:true},p:{id:"p",lid:"p",name:"pawn",color:false},n:{id:"n",lid:"n",name:"knight",color:false},b:{id:"b",lid:"b",name:"bishop",color:false},r:{id:"r",lid:"r",name:"rook",color:false},q:{id:"q",lid:"q",name:"queen",color:false},k:{id:"k",lid:"k",name:"king",color:false}};P.getRowCol=D.getRowCol=function(id){if(typeof id=="string"){return{col:id.toUpperCase().charCodeAt(0)-65,row:id.charCodeAt(1)-49};}else{id-=21;return{row:Math.floor(id/10),col:id%10}}};P.getIndex=D.getIndex=function(row,col){if(typeof row=="string"){row=D.getRowCol(row);col=row.col;row=row.row;}else if(typeof row=="object"){col=row.col;row=row.row;}return row*10+col+21;};P.getCellId=D.getCellId=function(row,col){if(typeof row=="object"){col=row.col;row=row.row;}return String.fromCharCode(col+65)+(row+1);};P.getIndexId=D.getIndexId=function(index){return this.getCellId(this.getRowCol(index));};D.newPiece=function(id){return Object.makeCopy(PIECES[id]);};D.newMove=function(from,to){if(to==null){to=from.split(/-/);from=to[0];to=to[1];}return{from:from,to:to,move:from+"-"+to,from_index:D.getIndex(from),to_index:D.getIndex(to)}};P.reset=function(){var a=[];for(var i=0;i<120;i++){a[i]=i<21||i>98||i%10==0||i%10==9?-1:0;}this._pos=a;this._status={};this._pieces=[];this._castle={"true":{oo:true,ooo:true},"false":{oo:true,ooo:true}};this._to_move=true;this._halfmove=0;this._fullmove=1;};P.initialize=function(pos,last_move){this._moves=[];if(!pos){this.setFromFEN(D.FEN_STANDARD);}else{this.setFromMoves(pos.getMoves().map(function(m){var txt=m.move;if(m.transform)txt+=m.transform.id;if(m.pgn)txt+=":"+m.pgn;if(m===last_move)$RETURN(txt);else return txt;}).join(","));}};P.setFromFEN=function(fen){this.reset();var data=fen.split(/\s+/),board=data[0],to_move=data[1],castle=data[2],en_passant=data[3],halfmove=data[4],fullmove=data[5];board=board.split(/\x2f/).reverse();for(var row=0;row<8;row++){data=board[row];var col=0,p;while(data.length>0){p=data.charAt(0);if(/[pnbrqk]/i.test(p)){this.setPieceAt(row,col++,D.newPiece(p));}else if(/[1-8]/i.test(p)){col+=parseInt(p);}else{throw "Error parsing FEN position";}data=data.substr(1);}}var c=this._castle;c["true"].oo=castle.indexOf("K")>=0;c["true"].ooo=castle.indexOf("Q")>=0;c["false"].oo=castle.indexOf("k")>=0;c["false"].ooo=castle.indexOf("q")>=0;if(/^w$/i.test(to_move)){this._to_move=true;}else if(/^b$/i.test(to_move)){this._to_move=false;}else{this._to_move=null;}if(en_passant!="-")this._en_passant_target=this.getIndex(en_passant);this._halfmove=halfmove;this._fullmove=fullmove;this.analyze();};P.setFromMoves=function(moves){this.playback=true;this.initialize();moves.split(/,/).foreach(function(m){m=m.split(/:/);var pgn=m[1];m=m[0].replace(/-/g,'');var from=m.substr(0,2),to=m.substr(2,2),trans=m.substr(4,1);m=this.move(from,to,trans,pgn);},this);this.playback=false;this.analyze();};P.toFEN=function(){var a=[];for(var row=8;--row>=0;){var str="",empty=0;for(var col=0;col<8;col++){var p=this.getPieceAt(row,col);if(p){if(empty)str+=empty;empty=0;str+=p.id;}else{empty++;}}if(empty)str+=empty;a.push(str);}var pos=a.join("/");a=[pos];a[1]=this.activeColor()?"w":"b";var castle="",c=this._castle;if(c["true"].oo)castle+="K";if(c["true"].ooo)castle+="Q";if(c["false"].oo)castle+="k";if(c["false"].ooo)castle+="q";a[2]=castle||"-";a[3]=this._en_passant_target?this.getIndexId(this._en_passant_target):"-";a[4]=this._halfmove;a[5]=this._fullmove;return a.join(" ");};P.toPGN=function(args,html){var moves=String.buffer();if(html){moves("<table class='pgn'><tr>");this.getMoves().foreach(function(m,i){if(!(i&1)){var mn=i/2+1;if(i>0&&args.mpl&&i>1&&mn%args.mpl==1)moves("</tr><tr>");moves("<td class='mnum'>",mn,".","</td>");}var txt=m.pgn;if(!txt){txt=m.move;if(m.transform)txt+="="+m.transform.id;}moves("<td class='move ",i&1?"move-black":"move-white","'>",txt,"</td>");});moves("</tr></table>");}else{this.getMoves().foreach(function(m,i){if(!(i&1)){var mn=i/2+1;if(i>0)moves(args.mpl&&i>1&&mn%args.mpl==1?"\n":" ");moves(mn,".");}else moves(" ");var txt=m.pgn;if(!txt){txt=m.move;if(m.transform)txt+="="+m.transform.id;}moves(txt);});}moves=moves.get();var date=args.date||new Date;var tmpl=html?TMPL_PGN_HTML:TMPL_PGN_TXT;return tmpl({white_name:args.white||"",black_name:args.black||"",white_elo:args.white_elo||"",black_elo:args.black_elo||"",result:args.result,date:date.print("%Y.%m.%d"),time:date.print("%H:%M:%S"),moves:moves});};P.getStatus=function(){return this._status;};P.getPieces=function(){return this._pieces;};P.getMoves=function(){return this._moves;};P.getLastMove=function(color,pos){return this._moves.grep_last(function(m){return m.piece.color===color;},pos);};P.canCastle=function(ooo,color){if(color==null)color=this._to_move;if(ooo==null)return this._castle[color];return this._castle[color][ooo?"ooo":"oo"];};P.moveIsAllowed=function(id_from,id_to){var p=this.getPieceAt(id_from);return p.canmove&&p.canmove[id_to];};P._setPGN=function(move,pgnFields){var s=this._status,pgn=move.pgn;if(pgnFields&&!pgn){var p=move.piece,f=pgnFields[move.to_index].grep(function(m){return m.piece.id==p.id&&m.piece!==p;}),t=move.transform,id=t?"P":p.id.toUpperCase(),c=move.captured,from_id=this.getIndexId(move.from_index).toLowerCase(),to_id=this.getIndexId(move.to_index).toLowerCase(),len=c&&id=="P"||f.length>0?1:0;f.foreach(function(m){if(m.piece.index%10==move.from_index%10){len=2;$BREAK();}});pgn=(id!="P"?id:"")+from_id.substr(0,len);if(c)pgn+="x";pgn+=to_id;if(t)pgn+="="+t.id.toUpperCase();}if(s.mate){pgn+="#";}else if(s.draw){pgn+="½-½";}else if(s.inCheck){pgn+="+";}move.pgn=pgn;};P.move=function(id_from,id_to,transform,pgn){var from=this.getRowCol(id_from),to=this.getRowCol(id_to);var move={move:id_from+"-"+id_to,from:from,from_index:this.getIndex(from),to:to,to_index:this.getIndex(to),fen_before:this.toFEN(),number:this._moves.length+1,pgn:pgn,timestamp:new Date().getTime()};this._moves.push(move);this._en_passant_target=null;var p=this.setPieceAt(from.row,from.col,null);if(transform){transform=p.color?transform.toUpperCase():transform.toLowerCase();transform=p=D.newPiece(transform);move.transform=transform;}move.piece=p;var captured=move.captured=this.setPieceAt(to.row,to.col,p);if(p.lid=="k"||p.lid=="r"){var castle=this._castle[p.color];if(p.lid=="k"){castle.oo=false;castle.ooo=false;}else if(from.col==0){castle.ooo=false;}else if(from.col==7){castle.oo=false;}}if(captured&&captured.lid=="r"){var castle=this._castle[captured.color];if(to.col==0){castle.ooo=false;}else if(to.col==7){castle.oo=false;}}if(p.lid=='k'&&from.row==to.row){if(Math.abs(to.col-from.col)==2){var rook,rook_to_index,type;if(to.col==6){rook=this.getPieceAt(move.to_index+1);rook_to_index=move.to_index-1;type="O-O";}else if(to.col==2){rook=this.getPieceAt(move.to_index-2);rook_to_index=move.to_index+1;type="O-O-O";}if(rook&&rook!=-1){from=this.getRowCol(rook.index);to=this.getRowCol(rook_to_index);var rook_move={move:this.getCellId(from)+"-"+this.getCellId(to),from:from,from_index:rook.index,to:to,to_index:rook_to_index,implicit:true,piece:rook};this.setPieceAt(from.row,from.col,null);this.setPieceAt(to.row,to.col,rook);move.alt_move=rook_move;move.pgn=type;}}}else if(p.lid=="p"){if(from.col!=to.col&&!captured){move.captured=this.setPieceAt(from.row,to.col,null);move.captured.en_passant=true;}else if(Math.abs(from.row-to.row)==2){this._en_passant_target=this.getIndex((from.row+to.row)/2,from.col);}}var pgnFields=this._status.pgnFields;this._to_move=!p.color;this.analyze();if(p.lid!="p"||!captured){this._halfmove++;}else{this._halfmove=0;}if(this._to_move)this._fullmove++;move.fen_after=this.toFEN();this._setPGN(move,pgnFields);move.inCheck=this._status.inCheck;if(this.moveArgs)Object.merge(move,this.moveArgs);this.callHooks("onMove",move,p,transform);return move;};P.activeColor=function(color){if(color==null)return this._to_move;return this._to_move===color;};P.getPieceAt=function(row,col){var a=this._pos;if(col==null){if(typeof row=="string"){return a[this.getIndex(this.getRowCol(row))];}return a[row];}return a[this.getIndex(row,col)];};P.setPieceAt=function(row,col,p){var old=this.getPieceAt(row,col);if(old){this._pieces.remove(old);old.pos=null;}var index=this.getIndex(row,col);this._pos[index]=p;if(p){this._pieces.push(p);p.pos={row:row,col:col};p.index=index;}return old;};P.enPassantTarget=function(){return this._en_passant_target;};P.dumpArray=function(){var a=[];for(var row=0;row<8;row++){var tmp='';for(var col=0;col<8;col++){var p=this.getPieceAt(row,col);tmp+=p?p.id:' ';}a[7-row]=tmp;}return a;};P.analyze=function(){if(!this.playback)this._do_analyze();};})();(function(){var MT=Position.MOVE_TYPE={NO:0,YES:1,TAKE:2,TRANS:4,CASTLE:8};function hashPush(hash,key,val){var a=hash[key]||(hash[key]=[]);a.push(val);};var SORT_ORDER={p:0,n:1,b:2,r:3,q:4,k:5};Position.prototype._do_analyze=function(){var attacked_fields={};var attacked_pieces={};var in_check=false;var to_move=this.activeColor();var en_passant=this.enPassantTarget();var test_move=null;var pos=this;var moves=[];function getPiece(index){if(test_move){if(index==test_move.from)return null;if(index==test_move.to)return test_move.piece;}return pos.getPieceAt(index);};function addIfValid(piece,index){var what=getPiece(index);if(what==-1)return null;if(piece.lid=="k"&&attacked_fields[index]){return null;}var m={piece:piece,type:MT.YES,index:index};if(!what){if(piece.lid=="p"){if(Math.abs(piece.index%10-index%10)==1){if(piece.color!=to_move)hashPush(attacked_fields,index,piece);if(en_passant==index){m.takes=en_passant;m.type|=MT.TAKE;moves.push(m);return m;}return null;}else{if((index>=91&&index<=98)||(index>=21&&index<=28))m.type|=MT.TRANS;moves.push(m);return m;}}moves.push(m);if(piece.color!=to_move)hashPush(attacked_fields,index,piece);return m;}if(what.color!=piece.color){if(piece.lid=="p"){if(piece.index%10==index%10){return null;}if((index>=91&&index<=98)||(index>=21&&index<=28))m.type|=MT.TRANS;}m.type|=MT.TAKE;m.takes=what.index;moves.push(m);if(piece.color!=to_move){hashPush(attacked_fields,index,piece);hashPush(attacked_pieces,index,piece);if(what.lid=="k")in_check=true;}return m;}return null;};var FUNCS={p:function(piece){var index=piece.index;var step=piece.color?10:-10;var init_pos=piece.color?(index>=31&&index<=38):(index>=81&&index<=88);addIfValid(piece,index+step)&&init_pos&&addIfValid(piece,index+2*step);addIfValid(piece,index+(piece.color?11:-9));addIfValid(piece,index+(piece.color?9:-11));},r:function(piece){var index=piece.index,m,i;[1,10,-1,-10].foreach(function(step,i,m){for(i=index;m=addIfValid(piece,i+=step);)if(m.type&MT.TAKE)break;});},n:function(piece){var index=piece.index;[19,21,8,12,-19,-21,-8,-12].foreach(function(step){addIfValid(piece,index+step);});},b:function(piece){var index=piece.index;[11,9,-11,-9].foreach(function(step,i,m){for(i=index;m=addIfValid(piece,i+=step);)if(m.type&MT.TAKE)break;});},q:function(piece){this.r(piece);this.b(piece);},k:function(piece){var index=piece.index,can_castle=pos.canCastle(null,piece.color),m;[9,10,11,-9,-10,-11].foreach(function(step){addIfValid(piece,index+step);});if(m=addIfValid(piece,index+1)){if(!in_check&&can_castle.oo&&!getPiece(index+1)&&!getPiece(index+2)){if(m=addIfValid(piece,index+2))m.type|=MT.CASTLE;}}if(m=addIfValid(piece,index-1)){if(!in_check&&can_castle.ooo&&!getPiece(index-1)&&!getPiece(index-2)&&!getPiece(index-3)){if(m=addIfValid(piece,index-2))m.type|=MT.CASTLE;}}}};function test_adverse_piece(type,index){var p=getPiece(index);if(p&&p!=-1&&p.color!=to_move&&p.lid.search(type)>=0)throw true;return p;};function is_attacked(i){var t=test_adverse_piece;try{if(to_move){t(/^p/,i+9);t(/^p/,i+11);}else{t(/^p/,i-9);t(/^p/,i-11);}t(/^n/,i+19);t(/^n/,i+21);t(/^n/,i+8);t(/^n/,i+12);t(/^n/,i-19);t(/^n/,i-21);t(/^n/,i-8);t(/^n/,i-12);[11,9,-11,-9].foreach(function(step,j,m){j=i;while(true){m=t(/^[bq]/,j+=step);if(m)break;}});[1,10,-1,-10].foreach(function(step,j,m){j=i;while(true){m=t(/^[rq]/,j+=step);if(m)break;}});[9,10,11,-1,1,-9,-10,-11].foreach(function(step){t(/^k/,i+step);});}catch(ex){return true;}return false;};function sortOrder(piece){var o=SORT_ORDER[piece.lid];if(piece.color==to_move)o+=6;return o;};var pieces=pos.getPieces().mergeSort(function(a,b){return sortOrder(a)-sortOrder(b);});pieces.foreach(function(p){p.canmove={};FUNCS[p.lid](p);});var king_index=pieces.peek().index;moves=moves.grep(function(m){if(m.piece.color!=to_move)return false;test_move={from:m.piece.index,to:m.index,piece:m.piece};return!is_attacked(test_move.from==king_index?test_move.to:king_index);});test_move=null;var pgnFields={};moves.foreach(function(m){m.piece.canmove[pos.getIndexId(m.index)]=m;hashPush(pgnFields,m.index,m);});var mate=false;var draw=false;if(moves.length==0){if(in_check){pos.callHooks("onMate",to_move);mate=true;}else{pos.callHooks("onDraw",to_move,"stalemate");draw=true;}}else if(in_check){pos.callHooks("onCheck",to_move);}pos._status={color:to_move,inCheck:in_check,mate:mate,draw:draw,attackedFields:attacked_fields,pgnFields:pgnFields,attackedPieces:attacked_pieces};pos.callHooks("onAnalyze",pos._status);};})();var Chess={};Chess.FLAGS="STARTED PAUSED FINISHED WHITE_OO WHITE_OOO BLACK_OO BLACK_OOO CHECK CHECKMATE STALEMATE DRAW WHITE_WINS BLACK_WINS" .split(/\s/).toHash(function(el,i){return 1<<i;});DlDesktop.prototype._handle_focusKeys=function(ev){this._handleKeybinding(ev);};(function(){var sok;var PING_TIMEOUT=10*60*1000;var GAMES_BY_ID={};var RECONNECT_TIMEOUT=30;var TMPL_SERVER_INFO=String.template("<div class='RightBarPane ServerInfo'>","<div class='title'>Server info</div>","<table>","<tr><td class='label'>Users online:</td><td>$n_users_online</td></tr>","<tr><td class='label'>Engines online:</td><td>$n_bots ($bots_business)</td></tr>","<tr><td class='label'>Active games:</td><td>$n_games_online</td></tr>","<tr><td class='label'>Total users:</td><td>$n_users</td></tr>","<tr><td class='label'>Total games:</td><td>$n_games</td></tr>","</table>","</div>");var TMPL_USER_INFO=String.template("<div class='RightBarPane UserInfo'>","<div class='title'>Your profile</div>","<table>","<tr><td class='label'>User ID:</td><td>$id</td></tr>","<tr><td class='label'>Name:</td><td>$name</td></tr>","<tr><td class='label'>Rating:</td><td>$rating</td></tr>","<tr><td class='label'>Games played:</td><td>$games_played</td></tr>","<tr><td class='label'>Games won:</td><td>$games_won</td></tr>","<tr><td class='label'>Games lost:</td><td>$games_lost</td></tr>","</table>","</div>");var TMPL_ONE_ACTIVE_GAME=String.template("<table>","<tr>","<td class='Presence'><div class='$presence'></div></td>","<td class='Color'><div class='Playing-$color'></div></td>","<td class='Opponent'>$name (${opponent.getRating()})</td>","</tr>","</table>");var TMPL_LOGOUT_O=String.template("<table>","<tr>","<td><div style='padding:10px'>","You connected from another machine.<br />","This window is disabled until you reconnect.","</div></td></tr>","<tr><td><table align='center'><tr><td id='logout_o_btn' style='padding: 3px'></td></tr></table>","</td></tr></table>");var ID_ACTIVE_GAMES=Dynarch.ID();var TMPL_MY_ACTIVE_GAMES=String.template("<div class='RightBarPane MyActiveGames'>","<div class='title'>Your active games</div>","<div id='",ID_ACTIVE_GAMES,"'></div>","</div>");var TMPL_BROADCAST_MSG=String.template("<div class='BroadcastMessage'>","<div class='subject'><div style='float:right'>$time</div>$subject</div>","<div class='message'>$message</div>","</div>");function onSocketData(data){Chess.schedulePing();if(data instanceof Array)data.foreach(this.callHooks.$(this,"onCommand"));else this.callHooks("onCommand",data);};Chess.retrieveActiveGame=function(args){sok.sendJSON({op:"retrieve_active_game",args:{game:args.id}});};var GAME_DATA_BY_ID={};Chess.retrieveGame=function(args){var game=GAME_DATA_BY_ID[args.id];if(game)Chess.displayGame(game,true);else sok.sendJSON({op:"retrieve_game",args:{game:args.id}});};var ACTIVE_BUDDIES={};var ACTIVE_GAMES={};function addActiveGame(g){if(!ACTIVE_GAMES[g.game]){var op=g.white.id==Chess.user.id?g.black:g.white;op=ChessUser.get(op);var args={id:g.game,name:op.getShortName(),opponent:op,color:g.white.id==Chess.user.id?'black':'white',presence:op.isOnline()?'Online':'Offline',game:g};var b=new DlAbstractButton({parent:ACTIVE_GAMES_CONTAINER,appendArgs:ID_ACTIVE_GAMES,tooltip:Chess.getBoardTooltip.$C({game:g}),classes:ChessMoveBtn.DEFAULT_ARGS._classes,value:args});if(!ACTIVE_BUDDIES[op.id])ACTIVE_BUDDIES[op.id]=[];ACTIVE_BUDDIES[op.id].push(b);ACTIVE_GAMES[g.game]=b;b.setContent(TMPL_ONE_ACTIVE_GAME(args));b.addEventListener("onClick",Chess.retrieveActiveGame.$C(args));b.addEventListener("onDestroy",function(){ACTIVE_BUDDIES[this.value().opponent.id].remove(this);delete ACTIVE_GAMES[this.value().ID];});}};function askEditProfile(){if(Chess.user.isPending()){alert("Sorry, this feature is available only to confirmed accounts!");}else{Chess.sok.sendJSON({op:"get_challenge",args:{op:"edit_profile"}});}};var WELCOME_NO_EMAIL="first-time-1 first-time-noemail first-time-2 thanks";var WELCOME_EMAIL="first-time-1 first-time-email first-time-2 thanks";function onPrefsChange(key,val,oldVal){switch(key){case "skin_color_theme":$("skin-"+oldVal).disabled=true;var link=$("skin-"+val);if(!link){var head=document.getElementsByTagName("head")[0];link=DynarchDomUtils.createElement("link");link.id="skin-"+val;link.rel="stylesheet";link.type="text/css";link.href="css/skin-"+val+".css";head.appendChild(link);}else{link.disabled=true;link.disabled=false;}break;}};function onSocketCommand(data){var args=data.args;switch(data.op){case "info":alert(args.text);break;case "login":if(args.success){Chess.user=ChessUser.get(args.user);Chess.prefs=new ChessPrefs(args.prefs);Chess.prefs.addEventListener("onChange",onPrefsChange);onPrefsChange("skin_color_theme",Chess.prefs.get("skin_color_theme"),"default");if(Chess.loginDlg){Chess.loginDlg.destroy();Chess.loginDlg=null;}if(!Chess.controls){DESKTOP_CONTAINER.destroyChildWidgets();Chess.controls=new ChessControls({parent:DESKTOP_CONTAINER});DESKTOP_CONTAINER.callHooks("onResize");}PROFILE_CONTAINER.getElement().firstChild.innerHTML=TMPL_USER_INFO(args.user);var box=new DlHbox({parent:PROFILE_CONTAINER});box.setAlign("center");if(Chess.user.get("registered")){new DlButtonMenu({parent:box,label:"Prefs",iconClass:"IconConfig",connected:true}).setMenu(Chess.prefs.getPopup.$(Chess.prefs));box.addSeparator("wide-separator");new DlButton({parent:box,label:"Edit profile"}).addEventListener("onClick",askEditProfile);}else{new DlButton({parent:box,label:"<b>Register your account!</b>"}).addEventListener("onClick",function(){var email=prompt(["Please enter your email address.\n","You will receive an email with a password to confirm your account"].join(""));if(email){Chess.registerUser(email);}});}PROFILE_CONTAINER.setStyle({paddingBottom:"10px"});if(Chess.user.isPending()){var welcome=Chess.user.get("email")?WELCOME_EMAIL:WELCOME_NO_EMAIL;Chess.displayHTML("Welcome to Dynarch Chess",welcome.qw().map($).map("innerHTML"));}if(args.was_pending)askEditProfile();}else{SND.play("error");alert("Login failed");DlFlashStore.remove("chess_last_login");Chess.showLoginDlg();}break;case "register_user":alert(["Thank you for registering your account!","You will receive an email with a password shortly.","In order to confirm your account, you just have to login","with that password within the next 48 hours."].join(" "));break;case "edit_profile":Chess.CHALLENGE=args;Chess.showEditProfile();break;case "challenge_auth":Chess.CHALLENGE=args;var last_login=DlFlashStore.get("chess_last_login");if(last_login){var tmp=last_login.split(/:/);Chess.login({user:tmp[0],password:tmp[1],remember:true});}else{Chess.showLoginDlg();}break;case "logout":delete Chess.user;delete Chess.prefs;DlFlashStore.remove("chess_last_login");window.location.replace(window.location);return;case "logout_o":var dlg=new DlDialog({title:"Logged in from another machine",modal:true});dlg.setContent(TMPL_LOGOUT_O());var btn=new DlButton({parent:dlg,appendArgs:"logout_o_btn",label:"Reconnect!"});btn.addEventListener("onClick",function(){var last_login=DlFlashStore.get("chess_last_login");if(last_login){var tmp=last_login.split(/:/);Chess.login({user:tmp[0],password:tmp[1],remember:true});}else{Chess.showLoginDlg(null,true);}dlg.destroy();});dlg.centerOnParent();dlg.show();break;case "get_my_active_games":ACTIVE_GAMES_CONTAINER.setContent(TMPL_MY_ACTIVE_GAMES());args.foreach(addActiveGame);break;case "retrieve_active_game":Chess.displayGame(args.game);break;case "retrieve_game":var game=args.game;game.data=game.data.decodeJSON(true);game.messages=game.data.messages;game.moves=game.data.moves;GAME_DATA_BY_ID[game.game]=game;Chess.displayGame(game,true);break;case "restore_game":SND.play("new_game");Chess.controls.newGameWaitingState(false);addActiveGame(args.game);Chess.displayGame(args.game);break;case "game_started":Chess.controls.newGameWaitingState(false);addActiveGame(args);Chess.displayGame(args);break;case "presence":ACTIVE_BUDDIES[args.user.id].foreach(function(b){b.value().presence=args.type;b.setContent(TMPL_ONE_ACTIVE_GAME(b.value()));var game=GAMES_BY_ID[b.value().id];if(game)game.addMessage({type:"warn",text:"Opponent is "+args.type});});break;case "update_user":var user=ChessUser.get(args.user);user.set(args.user);if(args.user.id==Chess.user.id){PROFILE_CONTAINER.getElement().firstChild.innerHTML=TMPL_USER_INFO(args.user);}break;case "server_info":args.bots_business='n/a';if(args.n_bots>0){args.bots_business=Math.round(args.n_bots_ag*100/args.n_bots_maxg)+"% busy";args.n_users_online-=args.n_bots;}SERVER_INFO_CONTAINER.setContent(TMPL_SERVER_INFO(args));break;case "error":if(Chess.controls)Chess.controls.newGameWaitingState(false);alert(args.text);break;case "contact":alert("Your message has been sent.  Thank you for contacting us!");break;case "broadcast":Chess.showMessage(args.subject,args.message);break;case "game_ended":case "cancel_game":removeActiveGame(args.game);break;case "challenge_game":if(args.declined){Chess.controls.newGameWaitingState(false);var txt=ChessUser.get(args.user).getName()+" declined your challenge.";if(args.reason)txt+="\nReason: "+args.reason;alert(txt);}else{SND.play("challenge");if(args.game&&GAMES_BY_ID[args.game]){args.answer="accept";args.user=args.user.id;Chess.sok.sendJSON({op:"answer_challenge_game",args:args});}else{Chess.showChallengeDlg(args);}}break;}var game=args.game;if(game){game=GAMES_BY_ID[game];if(game){game.callHooks("onSocketData",data);}}};function removeActiveGame(game){var g=ACTIVE_GAMES[game];if(g)g.destroy();};var PROFILE_CONTAINER;var DESKTOP_CONTAINER;var SERVER_INFO_CONTAINER;Chess.displayGame=function(game,saved){ChessBoard.clearBoardPopups();var game_id=game.game;if(saved)game_id="saved"+game_id;var w=GAMES_BY_ID[game_id];if(!w){var white,black,our_color,opponent;if(saved){opponent=ChessUser.savedOpponent(game);if(game.color){our_color=true;white=ChessUser.savedOwner(game);black=opponent;}else{our_color=false;black=ChessUser.savedOwner(game);white=opponent;}}else{white=ChessUser.get(game.white);black=ChessUser.get(game.black);our_color=white.id==Chess.user.id;opponent=our_color?black:white;}var title=white.getShortName()+"&nbsp;&nbsp;—vs—&nbsp;&nbsp;"+black.getShortName();var dlg=new DlDialog({title:title,resizable:1,quitBtn:function(){if(!w.canClose()&&!game.duplicate){alert("Can't quit — game not finished!");}else{w.close();dlg.destroy();}}});w=new ChessGame({game_id:game.game,white:white,black:black,opponent:opponent,color:our_color,moves:game.moves,messages:game.messages||[],state:game.state||0,parent:dlg,t_created:game.t_created,game:game,saved:saved});dlg.centerOnParent();dlg.show();GAMES_BY_ID[game_id]=w;w.addEventListener("onDestroy",function(){delete GAMES_BY_ID[game_id];});}else{var dlg=w.getParentDialog();if(dlg)dlg.activate();}};Chess.showLoginDlg=function(p,modal){if(!Chess.loginDlg){Chess.loginDlg=new ChessLogin({parent:(arguments.length>0?p:DESKTOP_CONTAINER),modal:modal});Chess.loginDlg.centerOnParent();}Chess.loginDlg.show();return Chess.loginDlg;};var ping_timer=null;Chess.schedulePing=function(){if(ping_timer)clearTimeout(ping_timer);ping_timer=setTimeout(function(){Chess.sok.send(1);Chess.schedulePing();},PING_TIMEOUT);};Chess.init=function(){var desktop=new DlDesktop({className:"ChessDesktop",focusable:true});desktop.fullScreen();var layout=new DlLayout({parent:desktop});var right_bar=new DlContainer({scroll:true,className:"RightBarCont"});SERVER_INFO_CONTAINER=new DlContainer({parent:right_bar});PROFILE_CONTAINER=new DlContainer({parent:right_bar});PROFILE_CONTAINER.setContent("<div></div>");ACTIVE_GAMES_CONTAINER=new DlContainer({parent:right_bar});DESKTOP_CONTAINER=new DlContainer({className:"DesktopCont"});DESKTOP_CONTAINER.setContent($("desktop_welcome"));var rb=new DlResizeBar({widget:right_bar,className:"DeskResizeBar",invert:true});layout.packWidget(right_bar,{pos:"right",min:50,max:300});layout.packWidget(rb,{pos:"right"});layout.packWidget(DESKTOP_CONTAINER,{pos:"left",fill:"*"});desktop.callHooks("onResize");function moveOn(){var domain=window.PORT?document.domain:'s.chess.dynarch.com';var port=window.PORT||80;sok=Chess.sok=new DlSocket({host:domain,port:port,json:true});sok.registerEvents(["onCommand"]);var initConnect=function(state){if(state){flashblock_dlg.destroy();this.removeEventListener("onConnect",initConnect);this.send("<ChessConnect/>");Chess.schedulePing();}else{SND.play("error");alert("Initial connection failed!  The server may be down.  Please try again after a few minutes.");}};sok.addEventListener({onConnect:initConnect,onRelease:on_socketRelease,onData:onSocketData,onCommand:onSocketCommand});DlFlashUtils().addEventListener("onLoad",function(){DlFlashUtils().loadPolicyFile("xmlsocket://"+domain+":"+port);sok.connect();});var flashblock_dlg=new DlDialog({title:"Flash player required"});flashblock_dlg.setContent($("flashblock-warning"));flashblock_dlg.centerOnParent();flashblock_dlg.show();DlFlashUtils().init();};if(is_ie6){var dlg=new DlDialog({title:"Internet Explorer 6 Warning",modal:true});var vbox=new DlVbox({parent:dlg,borderSpacing:5});var cont=new DlContainer({parent:vbox});cont.setContent($("ie6-warning"));vbox.addSeparator();new DlButton({label:"Okay, let me play!",parent:vbox}).addEventListener("onClick",function(){this.destroy();moveOn();}.$(dlg));dlg.centerOnParent();dlg.show();}else moveOn();};Chess.login=function(args){if(args.remember)DlFlashStore.set("chess_last_login",args.user+":"+args.password);else DlFlashStore.remove("chess_last_login");if(Chess.CHALLENGE){Chess.pass=hex_hmac_md5("jont",args.password);args.password=hex_hmac_md5(Chess.CHALLENGE,Chess.pass);}args.user_agent=navigator.userAgent;sok.sendJSON({op:"login",args:args});};Chess.loginAnonymous=function(user){sok.sendJSON({op:"login_anonymous",args:{user:user}});};Chess.registerUser=function(email){sok.sendJSON({op:"register_user",args:{email:email}});};Chess.restoreGame=function(id){sok.sendJSON({op:"restore_game",args:{game:id}});};function on_socketRelease(reason){function reconnect(){if(timer)clearInterval(timer);progress.setValue(RECONNECT_TIMEOUT);sok.reconnect();};function tmpConnect(state){if(state)dlg.destroy();else{progress.setLabel("<b style='color:red'>Failed :-(</b>");startTimer();}};var timer;function startTimer(){var sec=RECONNECT_TIMEOUT;timer=setInterval(function(){if(sec==RECONNECT_TIMEOUT)progress.setLabel(makeLabel);sec--;progress.setValue(RECONNECT_TIMEOUT-sec);if(sec==0){clearInterval(timer);timer=null;reconnect();}},1000);};function makeLabel(pb,percent,val){val=RECONNECT_TIMEOUT-val;return "Reconnecting in "+val+" seconds";};var dlg=new DlDialog({modal:true,title:"Connection error"});var vbox=new DlVbox({parent:dlg,borderSpacing:10,fillParent:true});new DlLabel({parent:vbox,label:"Lost connection with server".bold()});var progress=new DlProgressBar({parent:vbox,max:RECONNECT_TIMEOUT,label:makeLabel});vbox.addSeparator();var b=new DlButton({parent:vbox,label:"Do it now!",focusable:true});b.getElement().parentNode.style.padding="0 80px";b.addEventListener("onClick",reconnect);sok.addEventListener("onConnect",tmpConnect,null,dlg);dlg._focusedWidget=b;dlg.setSize({x:300});dlg.centerOnParent();dlg.show();startTimer();};var SOCKET_RELEASE_REASONS=["Server closed the connection","Client closed the connection","Socket destroying"];Chess.showMessage=function(subject,message,title){var dlg=new DlDialog({title:title||"Administrator message",modal:true,quitBtn:"destroy"});subject=subject.htmlEscape();message=message.htmlEscape().replace(/\n/g,"<br/>");dlg.setContent(TMPL_BROADCAST_MSG({subject:subject,time:new Date().print("%I:%M %p"),message:message}));dlg.centerOnParent();dlg.show();};Chess.askResumeGame=function(id){Chess.sok.sendJSON({op:"ask_resume_game",args:{game:id}});ChessBoard.clearBoardPopups();var game=GAMES_BY_ID[id];if(game){game.addMessage({type:"warn",text:"Your opponent has been challenged, please wait."});}};var TMPL_CHALLENGE_DLG=String.template("<div style='padding:10px'>","<b>${user.getShortName()}</b> (${user.getRating()}, $registered) wants to play with you.<br/>","You will be playing ${color}.","</div>");var TMPL_CHALLENGE_RESUME_DLG=String.template("<div style='padding:10px'>","<b>${user.getShortName()}</b> (${user.getRating()}, $registered) wants to<br />","resume a game you're currently playing.<br/>","You are playing ${color}.<br />","Agree to resume paused game?","</div>");Chess.showChallengeDlg=function(args){var dlg=new DlDialog({title:"Game challenge",quitBtn:function(){group.setValue(["decline"]);answer();}});function answer(){args.answer=group.getValue()[0];args.user=args.user.id;Chess.sok.sendJSON({op:"answer_challenge_game",args:args});dlg.destroy();};var vbox=new DlVbox({parent:dlg,borderSpacing:5});var textCont=new DlContainer({parent:vbox});vbox.addSeparator();var cont=new DlContainer({parent:vbox});cont.setStyle({padding:"5px"});var group=DlRadioGroup.get();new DlRadioButton({parent:cont,focusable:true,value:"accept",checked:true,group:group,label:"Accept"});new DlRadioButton({parent:cont,focusable:true,value:"decline",group:group,label:"Decline this time"});new DlRadioButton({parent:cont,focusable:true,value:"ignore1h",group:group,label:"Ignore this user for one hour"});new DlRadioButton({parent:cont,focusable:true,value:"ignore1d",group:group,label:"Ignore this for 24 hours"});vbox.addSeparator();var hbox=new DlHbox({parent:vbox});hbox.addFiller();var ok=new DlButton({parent:hbox,focusable:true,label:"OK".fixedWidth("5em")});ok.addEventListener("onClick",answer);dlg._focusedWidget=ok;CHALLENGE_DLG=dlg;var color="random colors";if(args.color===true)color="black";if(args.color===false)color="white";var tmpl=args.game?TMPL_CHALLENGE_RESUME_DLG:TMPL_CHALLENGE_DLG;var user=ChessUser.get(args.user);var registered=user.isPending()&&user.get("registered")?"pending":user.isPending()?"unregistered":"registered";textCont.setContent(tmpl({user:user,color:color,game:args.game,registered:registered}));dlg.centerOnParent();dlg.show();};Chess.displayHTML=function(title,content){var dlg=new DlDialog({title:title,quitBtn:"destroy",resizable:true});var cont=new DlContainer({parent:dlg,fillParent:true,scroll:true,className:"HTML"});cont.setSize({x:500,y:400});cont.setContent(content);dlg.centerOnParent();dlg.show();};(function(){var board,tooltip,cont;var tmpl_game=String.template("<table align='center'>","<tr><td class='label'>White:</td><td>$white</td></tr>","<tr><td class='label'>Black:</td><td>$black</td></tr>","<tr><td class='label'>Started:</td><td>$started</td></tr>","<tr><td class='label'>Modified:</td><td>$modified</td></tr>","<tr><td class='label'>Last move:</td><td>$move</td></tr>","<tr><td class='label'>Result:</td><td>$result</td></tr>","</table>");var tmpl_move=String.template("<table align='center'>","<tr><td class='label'>Move:</td><td><b class='SariInOchi'>$move</b></td></tr>","</table>");Chess.getBoardTooltip=function(args){if(!board){tooltip=new DlVbox({});cont=new DlContainer({parent:tooltip});var box=new DlHbox({parent:tooltip});box.getElement().align="center";board=new ChessBoard({parent:box,className:"TooltipBoard"});}if(args.game){var game=args.game;var white=ChessUser.get(game.white),black=ChessUser.get(game.black);var result;if(game.state&Chess.FLAGS.WHITE_WINS)result="1-0";if(game.state&Chess.FLAGS.BLACK_WINS)result="0-1";if(result){if(game.state&Chess.FLAGS.CHECKMATE)result+=" (checkmate)";else result+=" (resignation)";}if(game.state&Chess.FLAGS.DRAW){result="½-½";if(game.state&Chess.FLAGS.STALEMATE)result+=" (stalemate)";else result+=" (agreement)";}if(!result)result="* (unfinished)";var move=Math.ceil(game.n_moves/2)+(game.n_moves&1?". ":". ... ")+game.last_move;cont.setContent(tmpl_game({white:white.getShortName(),black:black.getShortName(),started:game.t_created,move:move,result:result,modified:game.t_modified}));board.goToFEN(game.fen_pos);if(black===Chess.user&&!board._reversed)board.reverse();if(white===Chess.user&&board._reversed)board.reverse();}else if(args.move){var move=args.move;board.goToFEN(move.fen_after);board.highlightMove(move.from,move.to);var m=Position.printMove(move);cont.setContent(tmpl_move({move:m}));if(args.reversed!=null&&args.reversed!==board._reversed)board.reverse();}return tooltip;};})();})();(function(){var HTML=String.buffer();(function(){HTML("<div class='WhiteSideFields ChessFields'>");for(var row=0;row<8;row++){for(var col=0;col<8;col++){var colID=String.fromCharCode(65+col);var rowID=row+1;var id=colID+rowID;var fieldColor=(row+col)&1?"WhiteField":"BlackField";HTML("<div chessField='",id,"' class='Field ",id," Row-",rowID," Col-",colID," ",fieldColor,"'></div>");}}for(var i=0;i<8;i++){rowID=i+1;colID=String.fromCharCode(65+i);HTML("<div class='Notation-Row Row-",rowID,"'>",rowID,"</div>");HTML("<div class='Notation-Col Col-",colID,"'>",colID.toLowerCase(),"</div>");}HTML("</div>");HTML=HTML.get();})();HTML_TRANS_DLG=String.buffer("<div class='Title'>Promote to:</div>","<div class='Content'></div>").get();var PROMOTE_PIECES={"true":"N B R Q".qw(),"false":"n b r q".qw()};var ANIMATION={slow:{factor:2,fps:50},fast:{factor:1,fps:50},faster:{factor:0.5,fps:50}};ChessBoard.inherits(DlContainer);function ChessBoard(args){D.setDefaults(this,args);DlContainer.call(this,args);this.registerEvents(["onReverse"]);this.init();};eval(Dynarch.EXPORT("ChessBoard",true));D.DEFAULT_ARGS={_pos:["position",null],_anim:["animation",true]};D.clearBoardPopups=function(){BoardPopup.clearAll();};P.init=function(){this.setContent(HTML);DOM.addClass(this.getFieldsElement(),"PieceSet-"+Chess.prefs.get("skin_piece_set"));this.setUnselectable();this._highlightFields=[];this._pieces_off=[];this._pieces_on=[];this._reversed=false;if(this._pos){this._on_posMove=this._on_posMove.$(this);this._on_promoteClicked=this._on_promoteClicked.$(null,this);this._on_promoteHide=this._on_promoteHide.$(this);this._animArray=[];this._dlg_transform={};this.resetToPosition();this._attachToPosition();this.addEventListener("onDisabled",function(v){this.condClass(v,"DisabledBoard")});}};P.getMyColor=function(){return this._pos._my_color;};P._attachToPosition=function(){this._pos.addEventListener({onMove:this._on_posMove});};P.resetToPosition=function(){Array.$(this._pieces_on).foreach(this.capturePiece,this);this._pos.getPieces().foreach(this.newPiece,this);DOM.delClass(this.getFieldsElement(),"InactiveBoard");this.lookingBack=false;var m=this._pos.getMoves().peek();this.highlightMove(m&&m.from,m&&m.to);};P.getPosition=function(){return this._pos;};P.goToFEN=function(fen){this.highlightMove();Array.$(this._pieces_on).foreach(this.capturePiece,this);var pos=fen.split(/\s+/)[0].split(/\x2f/);for(var row=0;row<8;row++){var data=pos[row];var col=0,p;while(data.length>0){p=data.charAt(0);if(/[pnbrqk]/i.test(p)){p=Position.newPiece(p);p.pos={row:7-row,col:col++};this.newPiece(p);}else if(/[1-8]/i.test(p)){col+=parseInt(p);}else{throw "Error parsing FEN position";}data=data.substr(1);}}if(this._pos)DOM.addClass(this.getFieldsElement(),"InactiveBoard");this.lookingBack=true;};P.newPiece=function(p){var w=this._pieces_off.grep_first(function(w){return w.getPData().id===p.id;});var cell=this.getCellElement(p.pos);if(!w){w=new ChessPiece({parent:this,piece:p,drag:ChessDragMove(),appendArgs:cell});}else{w.setPData(p);cell.appendChild(w.getElement());this._pieces_off.remove(w);}this._pieces_on.push(w);return w;};P.capturePiece=function(piece){var el=piece.getElement();el.parentNode.removeChild(el);this._pieces_on.remove(piece);this._pieces_off.push(piece);};P.getPieceAt=function(cell){if(!cell.ownerDocument)cell=this.getCellElement(cell);if(cell.firstChild)return DlWidget.getFromElement(cell.firstChild);};P.getFieldsElement=function(){return this.getElement().firstChild;};P.getCellElement=function(rc){if(typeof rc!="object")rc=Position.getRowCol(rc);return this.getFieldsElement().childNodes[rc.row*8+rc.col];};P.getCellPos=function(cell){return{x:cell.offsetLeft+2,y:cell.offsetTop+2};};P.getCellAtPosition=function(pos){if(!this._fSize)this._fSize=DOM.getInnerSize(this.getFieldsElement());var col=Math.floor(pos.x/(this._fSize.x/8)).nullLimit(0,7),row=(7-Math.floor(pos.y/(this._fSize.y/8))).nullLimit(0,7);if(col&&row){if(this._reversed){col=7-col;row=7-row;}return this.getCellElement({row:row,col:col});}};P.highlightMove=function(from,to,ac){var a=this._highlightFields;if(!ac)ac="LastMoved";a.foreach(function(f){DOM.delClass(f,ac);});a=this._highlightFields=[];if(Chess.prefs.get("highlight_last_move")){if(from)DOM.addClass(from=this.getCellElement(from),ac),a.push(from);if(to)DOM.addClass(to=this.getCellElement(to),ac),a.push(to);}};P._getTransDlg=function(){var color=this._pos.activeColor();var d=this._dlg_transform[color];if(!d){d=this._dlg_transform=new DlContainer({className:"TransformDlg"});d.setContent(HTML_TRANS_DLG);var el=d.getElement().childNodes[1];var box=new DlHbox({parent:d,appendArgs:el,borderSpacing:5});PROMOTE_PIECES[color].foreach(function(p){new ChessPiece({parent:box,className:"PieceButton",piece:Position.newPiece(p)}).addEventListener("onClick",this._on_promoteClicked);},this);this.addEventListener("onDestroy",d.destroy.$(this));}d.delClass(/PieceSet-[^\s]+/gi,"PieceSet-"+Chess.prefs.get("skin_piece_set"));return d;};P.boardPopup=function(args){BoardPopup.get().popup(args);};P._on_dndMoveDrop=function(from_id,to_id,move){if(move.type&Position.MOVE_TYPE.TRANS){DOM.addClass(this.getCellElement(from_id),"PromoteFrom");DOM.addClass(this.getCellElement(to_id),"PromoteTo");this._promotion={from_id:from_id,to_id:to_id,move:move};this.boardPopup({content:this._getTransDlg(),anchor:this.getElement(),onHide:this._on_promoteHide});}else this._pos.move(from_id,to_id);};function castleEasing(x){with(Math){return 1-cos(x*3*PI/2)/exp(6*x)}};function checkEasing(x){with(Math){if(x<0.5)x=1-x;return-sin(x*11*PI)*x*x;}};P._on_posMove=function(move,p,transform){var piece=this.getPieceAt(move.from),anim=(this.lookingBack||move.implicit||this.getMyColor()==null||p.color!=this.getMyColor())&&this._anim,cell=this.getCellElement(move.to),captured=move.captured,captured_cell,a;if(!piece)return;if(!move.implicit)this.highlightMove(move.from,move.to);if(captured){captured_cell=this.getCellElement(captured.index);captured=this.getPieceAt(captured_cell);}if(anim){if(piece.anim)piece.anim.stop();this._animArray.push(anim=new DlAnimation);a=anim.args={board:this,el:piece.getElement().cloneNode(true),capel:captured?captured.getElement().cloneNode(true):null,start:piece.getRelPos(),end:this.getCellPos(cell),x:move.implicit?castleEasing:DlAnimation.easing.accel_ab,y:DlAnimation.easing.accel_b,piece:piece};if(captured){var cp=captured_cell?this.getCellPos(captured_cell):a.end;AC(a.capel,"PieceCapAnimated");if(Chess.prefs.get("anim_hl_captured"))AC(a.capel,"PieceCapAnimatedHl");DOM.setPos(a.capel,cp.x,cp.y);this.getFieldsElement().appendChild(a.capel);}AC(a.el,"PieceAnimated","MovingPiece");DOM.setPos(a.el,a.start.x,a.start.y);this.getFieldsElement().appendChild(a.el);anim.addEventListener({onUpdate:_on_animUpdate,onStop:_on_animStop});piece.opacity(0);piece.anim=anim;}else{piece.delClass("MovingPiece");}if(captured)this.capturePiece(captured);cell.appendChild(piece.getElement());if(transform)piece.setPData(transform);var prefs=ANIMATION[this._anim];var f=1;if(anim){f=prefs.factor;if(move.implicit)f*=2;anim.start(Math.round(f*Math.sqrt(DlPoint.prototype.distanceTo.call(a.start,a.end))),prefs.fps);}if(move.alt_move){this._on_posMove.delayed(150*f,this,move.alt_move);}};function _on_animUpdate(t){var a=this.args;DOM.setPos(a.el,a.x(t).map(a.start.x,a.end.x),a.y(t).map(a.start.y,a.end.y));if(Chess.prefs.get("anim_fade")){a.piece.opacity(t);if(a.capel)DOM.setOpacity(a.capel,1-t);DOM.setOpacity(a.el,t.map(1,0.3));}};function _on_animStop(){this.args.board._animArray.remove(this);this.args.piece.opacity(is_ie?1:"");(function(){DOM.trash(this.args.el);DOM.trash(this.args.capel);this.args.el=null;this.args.capel=null;this.args.piece.anim=null;this.args.piece=null;this.args.board=null;this.args=null;this.destroy();}).delayed(1,this);};P._on_promoteClicked=function(self){var p=self._promotion;self._pos.move(p.from_id,p.to_id,this.getPData().id);BoardPopup.clearAll();};P._on_promoteHide=function(){var p=this._promotion;this._promotion=null;DOM.delClass(this.getCellElement(p.from_id),"PromoteFrom");DOM.delClass(this.getCellElement(p.to_id),"PromoteTo");};P.reverse=function(){DOM.condClass(this.getFieldsElement(),this._reversed=!this._reversed,"BlackSideFields","WhiteSideFields");this.callHooks("onReverse",this._reversed);};})();BoardPopup.inherits(DlPopup);function BoardPopup(args){args.autolink=false;args.align={prefer:"CC",fallX1:"_r",fallX2:"_l",fallY1:"b_",fallY2:"t_"};DlPopup.call(this,args);};(function(){var MAX_MESSAGES=50;var buddies,conversation,entry,grp_buddies;Chess.makeChatWidgets=function(cont){var layout=new DlLayout({parent:cont});buddies=new DlContainer({scroll:true,className:"Buddies"});conversation=new DlContainer({scroll:true,className:"Conversation"});entry=new DlCompletionEntry({emptyText:"Public chat!",timeout:null,accessKey:"ALT 'm'"});var label=new DlLabel({tagName:"div",widget:entry,label:"&nbsp;"+Chess.user.getName()+":&nbsp;"});label.setStyle({paddingTop:"2px"});var rb_buddies=new DlResizeBar({widget:buddies,invert:true});layout.packWidget(buddies,{pos:"right",fill:200,min:20,max:350});layout.packWidget(rb_buddies,{pos:"right"});layout.packWidget(conversation,{pos:"top",fill:"*"});layout.packWidget(label,{pos:"left",valign:"center"});layout.packWidget(entry,{pos:"bottom",after:3});grp_buddies=DlRadioGroup.get();Chess.sok.addEventListener("onCommand",onSocketCommand);entry.addEventListener("onKey-ENTER",sendMessage);entry.addEventListener("onCompletion",function(range){var words=grp_buddies.getButtons().map(function(b){return b.userData.getName();});var sep=/\s+/g;var comp=[],val=this.getValue().toLowerCase(),pos=val.lastIndexOfRegexp(sep,range.start);val=val.substring(pos,range.start);if(val){for(var i=0;i<words.length;++i)if(words[i].toLowerCase().indexOf(val)==0)comp.push({label:words[i],noselect:true,after:': ',start:pos});}if(comp.length>0)this.completionReady(comp);else this.cancelCompletion();});};function onSocketCommand(data){var args=data.args;switch(data.op){case "public_chat":handleChatOperation(args);break;case "update_user":var user=ChessUser.get(args.user);var btn=grp_buddies.getByValue(user.id);btn.setLabel(_userLabel(user));break;}};function handleChatOperation(args){if(args instanceof Array)args.foreach(handleChatOperation);else{switch(args.what){case "system_message":displayMessage(args,true);break;case "message":displayMessage(args);break;case "userlist":fillBuddyList(args.data);break;case "enter":addBuddy(args.data);break;case "leave":removeBuddy(args.data);break;}}};var TMPL_MESSAGE_SYS=String.template("<table class='message message-system $cls'><tr>","<td class='from' valign='top'>[$time] ***</td>","<td class='body' valign='top'>$body</td>","</tr></table>");var TMPL_MESSAGE=String.template("<table class='message $cls'><tr>","<td class='from' valign='top'>[$time] $from</td>","<td class='body' valign='top'>$body</td>","</tr></table>");function displayMessage(args,sys){var user;if(args.from){user=ChessUser.get(args.from);args.from=user.getName();}else{args.from="*?*";}args.time=new Date().print("%H:%M");args.cls="";if(user&&user===Chess.user){args.cls="message-own";}else if(args.body.indexOf(Chess.user.getName())>=0){SND.play("message");args.cls="message-interesting";}var w=new DlWidget({parent:conversation});w.setContent(sys?TMPL_MESSAGE_SYS(args):TMPL_MESSAGE(args));w.scrollIntoView();var a=conversation.children();if(a.length>MAX_MESSAGES)a[0].destroy();};function fillBuddyList(data){data.foreach(addBuddy);};var TMPL_ONE_BUDDY=String.template("<table>","<tr>","<td class='Presence'><div class='$presence'></div></td>","<td class='Opponent'>$name ($rating)</td>","</tr>","</table>");function addBuddy(user){user=ChessUser.get(user);var w=grp_buddies.getByValue(user.id);if(!w){var btns=grp_buddies.getButtons();for(var i=0;i<btns.length;i++){if(btns[i].userData.getName().toLowerCase()>=user.getName().toLowerCase())break;}w=new DlAbstractButton({parent:buddies,label:_userLabel(user),appendArgs:i,focusable:true,classes:ChessMoveBtn.DEFAULT_ARGS._classes,data:user,value:user.id,group:grp_buddies,type:DlButton.TYPE.TWOSTATE,contextMenu:buddyContextMenu});w.connectEvents("onCheck","onContextMenu");}return w;};function _userLabel(user){return TMPL_ONE_BUDDY({name:user.getName(),presence:"Online",rating:user.getRating()});};function sendMessage(){var msg=this.getValue().trim();if(/\S/.test(msg)){Chess.sok.sendJSON({op:"public_chat",args:{what:"send",data:msg}});}this.clear();};function removeBuddy(id){var btn=grp_buddies.getByValue(id);if(btn)btn.destroy();};var BUDDY_CONTEXT_MENU;function buddyContextMenu(){var m=BUDDY_CONTEXT_MENU;if(!m){m=BUDDY_CONTEXT_MENU=new DlVMenu({});new DlMenuItem({name:"challenge",parent:m,iconClass:"IconWKing",label:"Challenge this player"});m.contextMenuAlign={prefer:"cL",fallX1:"_R",fallX2:"_L",fallY1:"B_",fallY2:"T_"};m.addEventListener({onSelect:function(name,item,btn){var d=Chess.controls.getNewGameDlg();d.entry.setValue(btn.userData.id);d.playerGroup.setValue(["user"]);d.show();},onPopup:function(args){var user=args.widget.userData;if(user===Chess.user)user="<b>yourself?</b>";else user=user.getName();m.getItemByName("challenge").setContent("Challenge "+user);}});}return m;};})();Chess.showContactDlg=function(operation){if(Chess.user.isPending()){alert("Sorry, this feature is available only to confirmed accounts!");return;}var dlg=Chess.CONTACT_DLG;if(!dlg){dlg=Chess.CONTACT_DLG=new DlDialog({title:"Contact us",resizable:true,iconClass:"IconEmail",quitBtn:"hide"});var layout=new DlLayout({parent:dlg,outerSpace:5});var l2=new DlLayout({});var subjectEntry=new DlEntry({tabIndex:1,parent:DlContainer.getHiddenContainer(),emptyText:"Please type a subject!"});var subjLabel=new DlLabel({widget:subjectEntry,label:"<u>S</u>ubject:",accessKey:"ALT 's'"});var msgEntry=new DlEntry({tabIndex:2,type:"textarea",emptyText:"Write your message here."});var height=subjectEntry.getSize().y;l2.packWidget(subjLabel,{pos:"left",valign:"center",before:5,after:3});l2.packWidget(subjectEntry,{pos:"right",fill:"*"});var box=new DlHbox({});box.addFiller();new DlButton({parent:box,focusable:true,label:"Send",iconClass:"IconOK"}).addEventListener("onClick",function(){Chess.sok.sendJSON({op:dlg.operation||"contact",args:{subject:subjectEntry.getValue(),message:msgEntry.getValue()}});subjectEntry.clear(true);msgEntry.clear(true);dlg.hide();});box.addSpace();new DlButton({parent:box,focusable:true,label:"Cancel",iconClass:"IconCancel"}).addEventListener("onClick",dlg.hide.$(dlg));layout.packWidget(l2,{pos:"top",after:5});layout.packWidget(box,{pos:"bottom",after:5});layout.packWidget(msgEntry,{pos:"bottom",fill:"*"});l2.setSize({y:height});layout.setSize({x:400,y:300});dlg._focusedWidget=subjectEntry;dlg.centerOnParent();}dlg.title(operation=="broadcast"?"Broadcast message":"Contact us");dlg.operation=operation;dlg.show();};(function(){ChessControls.inherits(DlContainer);function ChessControls(args){args.fillParent=true;DlContainer.call(this,args);this._on_filterCalRender=this._on_filterCalRender.clearingTimeout(250,this);this._applyFilters=this._applyFilters.clearingTimeout(250,this);this._resetFilters=this._resetFilters.clearingTimeout(250,this);Chess.sok.addEventListener("onCommand",onSocketCommand.$(this));this.init();};eval(Dynarch.EXPORT("ChessControls"));var newGamePopup;P.getNewGameDlg=function(){if(!newGamePopup){newGamePopup=this.newGamePopup=new DlDialog({title:"New game",quitBtn:"hide"});var cont=new DlVbox({parent:newGamePopup,borderSpacing:5});var grp=newGamePopup.playerGroup=DlRadioGroup.get();var tmp=new DlHbox({parent:cont,borderSpacing:2});new DlRadioButton({parent:tmp,focusable:true,group:grp,value:"random",checked:true,label:"Play to a random user who waits for a new game."});tmp=new DlHbox({parent:cont,borderSpacing:2});new DlRadioButton({parent:tmp,focusable:true,group:grp,value:"user",label:"User ID of your opponent:"});var entry=newGamePopup.entry=new DlEntry({parent:tmp});entry.addEventListener("onFocus",function(){grp.setValue(["user"],true);});grp.addEventListener("onChange",function(){if(this.getValue()[0]=="user")entry.focus();});tmp=new DlHbox({parent:cont,borderSpacing:2});new DlRadioButton({parent:tmp,focusable:true,group:grp,value:"engine",label:"Play against an engine!"});cont.addSeparator();tmp=new DlHbox({parent:cont,borderSpacing:2});tmp.setAlign("center");var colorGrp=newGamePopup.colorGrp=DlRadioGroup.get();new DlLabel({parent:tmp,label:"Your color:&nbsp;"});new DlRadioButton({parent:tmp,group:colorGrp,focusable:true,value:"random",label:"Don't care",checked:true});new DlRadioButton({parent:tmp,group:colorGrp,focusable:true,value:"white",label:"White"});new DlRadioButton({parent:tmp,group:colorGrp,focusable:true,value:"black",label:"Black"});cont.addSeparator();tmp=new DlHbox({parent:cont});tmp.addFiller();var OK=function(){this.newGame(grp.getValue()[0],colorGrp.getValue()[0],entry.getValue());}.$(this);entry.addEventListener("onKey-ENTER",OK);new DlButton({label:"OK".fixedWidth("5em"),focusable:true,parent:tmp}).addEventListener("onClick",OK);new DlButton({label:"Cancel".fixedWidth("5em"),focusable:true,parent:tmp}).addEventListener("onClick",newGamePopup.hide.$(newGamePopup));newGamePopup.setPos(100,100);}return newGamePopup;};P.init=function(){var layout=new DlLayout({parent:this,fillParent:true});var toolbar=new DlHbox({borderSpacing:2});var btn=new DlButton({parent:toolbar,label:"New game",iconClass:"IconNewGame"});this._newGameBtn=btn;var newGamePopup;btn.addEventListener("onClick",function(){this.getNewGameDlg().show();}.$(this));new DlButton({label:"View random game",tooltip:"Open a random saved game",parent:toolbar}).addEventListener("onClick",function(){Chess.sok.sendJSON({op:"retrieve_random_game"});});toolbar.addSeparator("wide-separator");if(Chess.user.get("is_admin")){var btn=new DlButton({parent:toolbar,label:"Broadcast",iconClass:"IconBroadcast"});btn.addEventListener("onClick",Chess.showContactDlg.$C("broadcast"));toolbar.addFiller();}var btn=new DlButton({parent:toolbar,label:"Email us",iconClass:"IconEmail"});btn.addEventListener("onClick",Chess.showContactDlg.$C("contact"));if(!Chess.user.get("is_admin"))toolbar.addFiller();var btn=new DlButton({parent:toolbar,label:"Logout",iconClass:"IconLogout"});btn.addEventListener("onClick",function(){Chess.sok.sendJSON({op:"logout"});});var statusbar=new DlHbox({className:"StatusBar"});var copyright=new DlWidget({parent:statusbar});copyright.setContent($("copyright"));var tmp=new DlWidget({parent:statusbar});tmp.setContent($("build_stamp"));var center=new DlContainer({className:"CenterDesktopCont"});var brand=new DlContainer({className:"DynarchBox"});var brandbox=new DlHbox({parent:brand});var logo=new DlWidget({parent:brandbox,className:"DynarchLogo"});logo.setContent("<a href='http://www.dynarch.com/' target='_blank'></a>");brandbox.addFiller();new DlWidget({parent:brandbox}).setContent($("top-copyright"));layout.packWidget(brand,{pos:"top",after:5});layout.packWidget(toolbar,{pos:"top"});layout.packWidget(statusbar,{pos:"bottom"});var chat=this._makeChat();layout.packWidget(chat,{pos:"bottom",fill:"30%",before:5,min:30,max:500});var center_rb=new DlResizeBar({widget:chat,horiz:true,invert:true});layout.packWidget(center_rb,{pos:"bottom"});layout.packWidget(center,{pos:"bottom",fill:"*",after:5});center.setStyle({marginBottom:"-12px"});center.getElement().parentNode.style.overflow="hidden";this._makeCenterWidgets(center);};P._makeChat=function(){var topcont=new DlContainer({});Chess.makeChatWidgets(topcont);return topcont;};P._makeCenterWidgets=function(cont){cont=new DlFieldset({parent:cont,fillParent:true,className:"PreviousGamesCont",label:"Browse your previous games"});var layout=new DlLayout({parent:cont,fillParent:true});var search_cont=new DlContainer({className:"DlToolbar DlToolbar3"});var box=new DlHbox({parent:search_cont,borderSpacing:2});new DlButton({parent:box,iconClass:"IconFind",tooltip:"Apply filters"}).addEventListener("onClick",this._applyFilters);new DlButton({parent:box,iconClass:"IconCancel",tooltip:"Reset filters"}).addEventListener("onClick",this._resetFilters);box.addSeparator("wide-separator");var userEntry=new DlEntry({parent:box,emptyText:"filter by opponent",size:15});userEntry.addEventListener("onKey-ENTER",this._applyFilters);userEntry.addEventListener("onKey-ESCAPE",function(ct){this.clear();ct._applyFilters();}.$(null,this));box.addSpace();var calBtn=new DlButtonCalendar({parent:box,date:"Filter by date",calendar:{withMenu:true,navigation:1}});calBtn.addEventListener({onCalendarRendered:this._on_filterCalRender.$(this),onSelect:this._on_filterCalSelect.$(this)});box.addSpace();var resultGrp=DlRadioGroup.get();resultGrp.maxChecked(null);resultGrp.addEventListener("onChange",this._applyFilters);var vm=new DlVMenu({});new DlButtonMenu({parent:box,label:"Flags filter",connected:true}).setMenu(vm);new DlCheckbox({parent:vm,checked:true,group:resultGrp,value:"won",label:"Won",tooltip:"Show games you won"});new DlCheckbox({parent:vm,checked:true,group:resultGrp,value:"lost",label:"Lost",tooltip:"Show games you lost"});new DlCheckbox({parent:vm,checked:true,group:resultGrp,value:"draw",label:"Draw",tooltip:"Show draw games"});vm.addSeparator();var cmCheckbox=new DlCheckbox({parent:vm,checked:false,group:resultGrp,value:"checkmate",label:"Checkmate",tooltip:"Show only games that<br/>ended up with checkmate"});var smCheckbox=new DlCheckbox({parent:vm,checked:false,group:resultGrp,value:"stalemate",label:"Stalemate",tooltip:"Show only games that<br/>ended up with stalemate"});cmCheckbox.addEventListener("onChange",function(){if(this.checked())smCheckbox.checked(false);});smCheckbox.addEventListener("onChange",function(){if(this.checked())cmCheckbox.checked(false);});box.addFiller();var firstPageBtn=new DlButton({parent:box,iconClass:"IconFirstPg",tooltip:"First page",disabled:true});firstPageBtn.addEventListener("onClick",function(){if(this._fgPage>1){this._fgPage=1;this._updateLoadingLabel();}}.$(this));var prevPageBtn=new DlButton({parent:box,iconClass:"IconPrevPg",tooltip:"Previous page",disabled:true});prevPageBtn.addEventListener("onClick",function(){if(this._fgPage>1){this._fgPage--;this._updateLoadingLabel();}}.$(this));var curPageLabel=new DlLabel({parent:box,label:"...",tagName:"div"});curPageLabel.setStyle({width:"3em",textAlign:"center"});var nextPageBtn=new DlButton({parent:box,iconClass:"IconNextPg",tooltip:"Next page",disabled:true});nextPageBtn.addEventListener("onClick",function(){if(this._fgPage<this._fgMaxPage){this._fgPage++;this._updateLoadingLabel();}}.$(this));var lastPageBtn=new DlButton({parent:box,iconClass:"IconLastPg",tooltip:"Last page",disabled:true});lastPageBtn.addEventListener("onClick",function(){if(this._fgPage<this._fgMaxPage){this._fgPage=this._fgMaxPage;this._updateLoadingLabel();}}.$(this));var cols=[{id:"white",label:"White",resizable:true,width:120,iconClass:"Playing-white"},{id:"black",label:"Black",resizable:true,width:120,iconClass:"Playing-black"},{id:"result",label:"Result",resizable:false,width:50,style:{textAlign:"center"}},{id:"n_moves",label:"Mvs.",tooltip:"Number of moves",resizable:true,width:40,style:{textAlign:"center"}},{id:"date",label:"Game start date",fill:true}];var model=new DlGridModel({cols:cols,rows:[]});var grid=new DlGrid({model:model,selType:"multiple",rowType:"ChessGameRow"});layout.packWidget(search_cont,{pos:"top",after:3});layout.packWidget(grid,{pos:"bottom",fill:"*"});this.center={userEntry:userEntry,calBtn:calBtn,grid:grid,model:model,resultGrp:resultGrp,nextPageBtn:nextPageBtn,prevPageBtn:prevPageBtn,firstPageBtn:firstPageBtn,lastPageBtn:lastPageBtn,curPageLabel:curPageLabel};};var DAY_INFO_BY_YEAR={};P._resetFilters=function(){this.center.userEntry.clear();this.center.calBtn.getButton().setContent("Filter by date");this.center.calBtn.date=null;this.center.calBtn.getCalendar().setToday();this.center.resultGrp.setValue(["won","lost","draw"]);this._fgPage=null;this._applyFilters();};P._updateLoadingLabel=function(){this.center.curPageLabel.addClass("DlLabel-Loading");this.center.curPageLabel.setLabel(this._fgPage+"/"+this._fgMaxPage);this._applyFilters();};P._applyFilters=function(){var filters={won:0,lost:0,draw:0,checkmate:0,stalemate:0},tmp;if(this._fgPage!=null)filters.page=this._fgPage;tmp=this.center.userEntry.getValue();if(/\S/.test(tmp))filters.opponent=tmp;tmp=this.center.calBtn.getValue();if(tmp)filters.date=tmp.print("%Y-%m-%d");tmp=this.center.resultGrp.getValue();tmp.foreach(function(v){filters[v]=1;});Chess.sok.sendJSON({op:"search_get_finished_games",args:{filters:filters}});};P._on_filterCalSelect=function(date){this._applyFilters();};P._on_filterCalRender=function(cal){var date=cal.date;var di=DAY_INFO_BY_YEAR[date.getFullYear()];if(!di){Chess.sok.sendJSON({op:"search_get_cal_dates",args:{start:date.print("%Y-01-01"),end:date.print("%Y-12-31")}});}else if(di!==cal._infoDates){cal.setInfoDates(di);}this.center.calendar=cal;};var TMPL_DAY_INFO=String.template("<div class='Title'>$date</div>","$games games.");P._setFilterCalDates=function(args){var di=args.result;for(var i in di)di[i]={tooltip:TMPL_DAY_INFO({date:i,games:di[i]})};DAY_INFO_BY_YEAR[args.start.substr(0,4)]=di;this.center.calendar.setInfoDates(di);};function onSocketCommand(data){var args=data.args;switch(data.op){case "search_get_cal_dates":this._setFilterCalDates(args);break;case "get_my_finished_games":this.displayFinishedGames(args);break;case "add_finished_game":this.insertFinishedGame(args);break;case "delete_games":var model=this.center.model;args.foreach(function(id){var row=model.getRowById(id);if(row)model.deleteRowByIndex(row.getIndex());});break;}};function getGameTooltip(){var g=this.args.widget.getModel().userData,i=g.last_move.indexOf(":");if(i)g.last_move=g.last_move.substr(i+1);return Chess.getBoardTooltip({game:g});};P.displayFinishedGames=function(args){var games=args.games;var pages=Math.ceil(args.total/args.limit);this._fgPage=args.page;this._fgMaxPage=pages;with(this.center){curPageLabel.setLabel(pages?args.page+"/"+pages:"none");curPageLabel.delClass("DlLabel-Loading");[prevPageBtn,firstPageBtn].map("disabled",args.page<=1);[nextPageBtn,lastPageBtn].map("disabled",args.page>=pages);model.setValues(games.map(getGameRowData));grid.callHooks("onResize");}};function getGameRowData(g){if(g.color){g.white=Chess.user;g.black=ChessUser.savedOpponent(g);}else{g.black=Chess.user;g.white=ChessUser.savedOpponent(g);}return{id:g.game,cells:{white:g.white.getName(),black:g.black.getName(),result:ChessGame.getResult(g.state),n_moves:Math.ceil(g.n_moves/2),date:g.t_created},data:g,tooltip:getGameTooltip};};P.insertFinishedGame=function(game){this.center.model.insertRow(getGameRowData(game),0);};P.newGame=function(type,color,user){var args={};if(type=="user"){args.opponent=user;}else if(type=="engine"){args.wants_bot=1;}if(color=="white"){args.white=true;args.color=true;}else if(color=="black"){args.black=true;args.color=false;}var op={args:args};op.op=type=="random"?"create_game":"challenge_user";Chess.sok.sendJSON(op);newGamePopup.hide();this.newGameWaitingState(true);};P.newGameWaitingState=function(state){this._newGameBtn.setLabel(state?"Waiting for user":"New game");this._newGameBtn.setIconClass(state?"IconLoading":"IconNewGame");};})();(function(){ChessGameRow.prototype=new DlGridRow;function ChessGameRow(args){DlGridRow.call(this,args);this.setContextMenu(makeMenu);this.addEventListener("onDblClick",openGame);};eval(Dynarch.EXPORT("ChessGameRow"));P._handle_focusKeys=function(ev){var p=this.parent,g=p.getGroup();if(ev.keyCode==DlKeyboard.ENTER){this.checked(true);Chess.retrieveGame({id:this.getModel().id});ev.domStop=true;}else{return DlGridRow.prototype._handle_focusKeys.call(this,ev);}};function openGame(){this.checked(true);Chess.retrieveGame({id:this.getModel().id});};function deleteGames(){var ids=this.group().getValue();Chess.sok.sendJSON({op:"delete_games",args:ids});};function onMenuSelect(name,item,widget){switch(name){case "open":openGame.call(widget);break;case "del":deleteGames.call(widget);break;}};var S_MENU,M_MENU;function makeMenu(){this.checked(true);var s=this.group().getSelected();if(s.length==1){if(!S_MENU){S_MENU=new DlVMenu({});new DlMenuItem({label:"Review this game",name:"open",parent:S_MENU,iconClass:"IconOpen"});S_MENU.addSeparator();new DlMenuItem({label:"Delete this game",name:"del",parent:S_MENU,iconClass:"IconDelete"});S_MENU.addEventListener("onSelect",onMenuSelect);}return S_MENU;}if(s.length>1){if(!M_MENU){M_MENU=new DlVMenu({});new DlMenuItem({label:"Delete games",name:"del",parent:M_MENU,iconClass:"IconDelete"});M_MENU.addEventListener("onSelect",onMenuSelect);}return M_MENU;}};})();(function(){ChessDragMove.inherits(DlDrag);function ChessDragMove(){DlDrag.call(this,{cursor:{noDrop:"CHESS-CURSOR-NO-DROP",okDrop:"CHESS-CURSOR-DROP"}});this.prevField=null;};DlSingleton.register("ChessDragMove",ChessDragMove,true);eval(DynarchDomUtils.importCommonVars());var P=ChessDragMove.prototype,BASE=DlDrag.prototype;P.startOK=function(piece,ev){var board=piece.parent,p=piece.getPData();if((board.getMyColor()!=null&&p.color!=board.getMyColor())||(!board._pos.activeColor(p.color))||(board.lookingBack)||(board._pos.getStatus().inCheck&&Object.isEmpty(p.canmove)))return false;this.board=board;this.boardPos=DOM.getPos(this.board.getFieldsElement());this.piece=piece;return true;};P.makeElementCopy=function(piece,ev){var el=piece.getElement();var p=piece.getRelPos();el=this.clone=el.cloneNode(true);AC(el,"PieceDragged");piece.addClass("MovingPiece");DOM.setPos(el,p.x+16,p.y+16);this.board.getFieldsElement().appendChild(el);return null;};P.reset=function(wasCancel){DOM.trash(this.clone);this.clone=null;this.piece.delClass("MovingPiece");this._resetHover();this.piece=null;this.board=null;this.move=null;this.target_id=null;BASE.reset.call(this,wasCancel);};P._resetHover=function(){if(this.prevField){DC(this.prevField,/drop-here([^\s]+)?/g);this.prevField=null;}this.target_id=null;this.move=null;};P._setHover=function(el,move){AC(el,"drop-here");if(move.type&Position.MOVE_TYPE.TAKE){AC(el,"drop-here-capture");}if(move.type&Position.MOVE_TYPE.TRANS){AC(el,"drop-here-transform");}this.prevField=el;};P.doDrop=function(){if(this.target_id){var from_id=Position.getCellId(this.piece.getPData().pos);this.board._on_dndMoveDrop(from_id,this.target_id,this.move);}};P.moving=function(piece,ev){var pos={x:ev.pos.x-this.boardPos.x,y:ev.pos.y-this.boardPos.y};DOM.setPos(this.clone,pos.x,pos.y);var f=this.board.getCellAtPosition(pos);if(f&&f!=this.prevField){this._resetHover();var id=f.getAttribute("chessField");this.move=this.piece.getPData().canmove[id];if(this.move){this._setHover(f,this.move);this.target_id=id;}}else if(!f){this._resetHover();}};})();(function(){var TMPL_PLAYER_INFO=String.template("<table align='center'>","<tr>","<td class='Color'><div class='Playing-$color'></div></td>","<td class='Name'>$name</td>","<td class='Rating'>($rating)</td>","<td class='Move'>[$move]</td>","</tr>","</table>");var TMPL_MESSAGE_LINE=String.template("<div class='line'>$text</div>");var TMPL_MESSAGE_FROM=String.template("<div class='message message-$type'>","<div class='from'>$from:</div>","<div class='body'></div>","</div>");var TMPL_MESSAGE_SYS=String.template("<div class='message message-system'>","<div class='from'>***</div>","<div class='body'></div>","</div>");var TMPL_CANCEL_GAME=String.template("<div style='padding:10px'>","<b>${user.getShortName()}</b> cancelled this game.<br/>","You can close this dialog now.","</div>");var TMPL_CANCEL_GAME_AUTO=String.template("<div style='padding:10px'>","Your opponent disconnected.<br/>","The game was cancelled.<br/>","You can close this dialog now.","</div>");var TMPL_CANCEL_GAME_REASON=String.template("<div style='padding:10px'>","The game was cancelled because:<br/>","<b>${reason}</b><br/>","You can close this dialog now.","</div>");var HTML_RESUME_DLG=String.template("<div class='Title'>Resume game?</div>","<div class='Content' style='width:17em'>","This game is paused, but your opponent is online. ","Would you like to resume this game? ","(if not, please click outside to ignore this popup)","<div style='text-align: center; padding: 7px 0 3px 0;'><b><a onclick='Chess.askResumeGame($id)'>Resume game</a></b></div>","</div>");var TMPL_PROPOSE={undo:String.template("Allow your opponent to take back the last move?"),undo_to_position:String.template("Your opponent wants to get back ","to position: <b>$mtext</b>.  Allow?"),draw:String.template("<b>${user.name}</b> proposed draw.<br/>Do you agree?"),pause:String.template("<b>${user.name}</b> wants to pause the game.  ","Do you agree?  ","(note that if ${user.name} disconnects, the game ","will pause automatically, so generally this is an offer you can't refuse.)"),duplicate:String.template("<b>${user.name}</b> wants to clone this game.","<br/><br/>","Note that the score of a clone game will not modify the player ratings (ELO)."),duplicate_r:String.template("<b>${user.name}</b> wants to clone this game, <u>with colors reversed</u>.","<br/><br/>","Note that the score of a clone game will not modify the player ratings (ELO).")};ChessGame.inherits(DlContainer);function ChessGame(args){args.fillParent=true;D.setDefaults(this,args);if(this._white===this._black)this._my_color=null;DlContainer.call(this,args);this.registerEvents(["onSocketData"]);window.game=this;if(this._t_created)this._t_created=Date.parseMySQL(this._t_created);this.init();};eval(Dynarch.EXPORT("ChessGame",true));D.DEFAULT_ARGS={_game_id:["game_id",null],_moves:["moves",null],_white:["white",null],_opponent:["opponent",null],_black:["black",null],_my_color:["color",null],_t_created:["t_created",null],_state:["state",0],_messages:["messages",null],_game_obj:["game",null],_saved:["saved",false]};D.getResult=function(state){return state&Chess.FLAGS.WHITE_WINS?"1 - 0":state&Chess.FLAGS.BLACK_WINS?"0 - 1":state&Chess.FLAGS.DRAW?"½ - ½":"*";};P.init=function(){var game_id=this._game_id;var top_layout=new DlLayout({parent:this});var dis=this._disableGameWidgets=[];this._wTbCont=new DlContainer({className:"DlToolbar DlToolbar2"});top_layout.packWidget(this._wTbCont,{pos:"top"});var box=new DlHbox({parent:this._wTbCont});new DlButtonMenu({parent:box,label:"Prefs",iconClass:"IconConfig",connected:true}).setMenu(Chess.prefs.getPopup.$(Chess.prefs));box.addSpace();new DlButton({parent:box,type:DlButton.TYPE.TWOSTATE,tooltip:"Reverse board (ALT-R)",iconClass:"IconRotate",accessKey:"ALT 'r'"}).addEventListener("onClick",function(){this._wBoard.reverse();}.$(this));var clone=new DlButton({parent:box,tooltip:"Clone this game<br />Shift+Click to swap colors!",iconClass:"IconDuplicate"});clone.addEventListener("onClick",function(ev){this.askPropose(ev.shiftKey?"duplicate_r":"duplicate");}.$(this));this._disableGameWidgets.push(clone);box.addSeparator("wide-separator");var undoMenu;(this._wUndoBtn=new DlButton({parent:box,label:"<u>U</u>ndo",accessKey:"ALT 'u'",tooltip:"Take back your last move",iconClass:"IconTakeBack"})).addEventListener("onClick",function(){function askUndo(move){Chess.sok.sendJSON({op:"ask_undo",args:{game:game_id,move:move}});};if(this.last_pm){if(!undoMenu){undoMenu=new DlVMenu({});new DlMenuItem({parent:undoMenu,label:"Undo to this position",name:"pos"});new DlMenuItem({parent:undoMenu,label:"Undo your last move",name:"move"});undoMenu.addEventListener("onSelect",function(name){askUndo(name=="pos"?this.last_pm.number:null);}.$(this));}var popup=DlPopupMenu.get();popup.popup({content:undoMenu,anchor:this._wUndoBtn.getElement(),isContext:true,item:this._wUndoBtn,widget:this._wUndoBtn,align:DlButtonMenu.prototype.ALIGN});}else{askUndo();}}.$(this));this._wUndoBtn.activateSubmenu=function(activate){this.condClass(activate,"DlButton-1");};dis.push(this._wUndoBtn);var pause=this._wPauseBtn=new DlButton({parent:box,tooltip:"Propose to pause this game",iconClass:"IconPause"});pause.addEventListener("onClick",function(){this.askPropose("pause");}.$(this));dis.push(pause);var draw=new DlButton({parent:box,tooltip:"Propose draw to your opponent",iconClass:"IconDraw"});draw.addEventListener("onClick",function(){this.askPropose("draw");}.$(this));dis.push(draw);var resign=new DlButton({parent:box,tooltip:"Resign this game.<br />Your opponent wins immediately.",iconClass:"IconResign"});resign.addEventListener("onClick",function(){this.askPropose("resign");}.$(this));dis.push(resign);box.addFiller();new DlButton({parent:box,iconClass:"IconIdea",tooltip:"Open a test board"}).addEventListener("onClick",function(){var dlg=Chess.newTestBoard(this._pos,this.getPGNArgs(),this.last_pm,this._wBoard._reversed);dlg.centerOnParent();dlg.show();}.$(this));new DlButton({parent:box,iconClass:"IconList",label:"PGN",tooltip:"Get current game in PGN"}).addEventListener("onClick",function(){var dlg=this._pgnDlg;if(!dlg){dlg=this._pgnDlg=new DlDialog({title:"DynarchChess Game",quitBtn:"hide",resizable:true});var l=new DlLayout({parent:dlg,outerSpace:5});dlg.entry=new DlEntry({type:"textarea",readonly:true,className:"ChessPGN"});l.packWidget(dlg.entry,{pos:"top",fill:"*"});dlg.setSize({x:400,y:300});dlg.centerOnParent();this.addEventListener("onDestroy",dlg.destroy.$(dlg));}dlg.entry.setValue(this.toPGN());dlg.show();}.$(this));new DlButton({parent:box,iconClass:"IconPrint",tooltip:"Print the game and current diagram"}).addEventListener("onClick",function(){Chess.printReady=function(win,doc){var board=String.buffer("<div class='ChessBoard'>",this._wBoard.getElement().innerHTML,"</div>");if(this.last_pm){board("<p style='text-align:center;margin-top:2.5em'>","Diagram after ",Position.printMove(this.last_pm).bold(),"</p>");}doc.getElementById("diagram").innerHTML=board.get();doc.getElementById("pgn-game").innerHTML=this.toPGN(4,true);doc.getElementById("title").innerHTML=String.buffer(this._white.getShortName()," -vs- ",this._black.getShortName()).get();}.$(this);var win=window.open("print.html","DYNARCHCHESSPRINT");win.focus();}.$(this));box.addSeparator("wide-separator");new DlButton({parent:box,iconClass:"IconPrev",tooltip:"Go to prev move (ALT-P)",accessKey:"ALT 'p'"}).addEventListener("onClick",function(ev){var prev;prev=ev.shiftKey?this._wMoves._group.getButtons()[0]:this._wMoves._group.getPrevButton();if(prev)prev.checked(true);}.$(this));new DlButton({parent:box,iconClass:"IconNext",tooltip:"Go to next move (ALT-N)",accessKey:"ALT 'n'"}).addEventListener("onClick",function(ev){if(ev.shiftKey){var btns=this._wMoves._group.getButtons(),i=0;var timer=function(){if(i<btns.length)btns[i].checked(true);else clearInterval(timer);i++;}.setInterval(100);}else{var next=this._wMoves._group.getNextButton();if(next){next.checked(true);}}}.$(this));this._wMoves=new ChessMoves({});var btn=new DlButtonMenu({parent:box,label:"Moves",iconClass:"IconMovesList",connected:true,noCapture:true});btn.setMenu(this._wMoves);this.last_pm=null;this._wMoves.addEventListener("onSelect",function(move,sel){if(!sel){this._wBoard.resetToPosition();this.last_pm=null;}else{if(this.last_pm&&move.number-this.last_pm.number==1)this._wBoard._on_posMove(move,move.piece,move.transform);else this._wBoard.goToFEN(move.fen_after);this.last_pm=move;}this._resetUndoBtn(sel);this.updateWidgets();}.$(this));var pos=this._pos=new Position();pos._my_color=this._my_color;pos.initialize();pos.addEventListener("onMove",function(pos,move,piece,transform){if(!move.implicit){this._wMoves.addMove(move,pos.getStatus());this._game_obj.fen_pos=move.fen_after;this._game_obj.n_moves=move.number;this._game_obj.last_move=move.pgn;if(!pos.playback){this.updateWidgets();this._sendMove(pos,move,piece,transform);}}}.$(this,pos));if(this._moves){pos.setFromMoves(this._moves);}var gb_cont;if(is_ie6){gb_cont=new DlVbox({});this._wGameBoard=new DlContainer({parent:gb_cont});}else{gb_cont=this._wGameBoard=new DlContainer({});}this._wGameBoard.setStyle({padding:"5px 0"});var box=new DlVbox({parent:this._wGameBoard});this._wBlackPlayerInfo=new DlWidget({parent:box,tooltip:this._saved?null:getPlayerTooltip.$C(this._black)});this._wBoard=new ChessBoard({parent:box,position:pos,className:"LargeChessBoard",animation:Chess.prefs.get("animation")});this._wWhitePlayerInfo=new DlWidget({parent:box,tooltip:this._saved?null:getPlayerTooltip.$C(this._white)});top_layout.packWidget(gb_cont,{pos:"left",before:3,after:3});this.updateWidgets=function(undo){var pos=this.last_pm?this.last_pm.number-1:null,m=this._pos.getLastMove(false,pos),color=this.last_pm?!this.last_pm.piece.color:this._wBoard.getPosition().activeColor(),move;move=" - ";if(m)move=Position.printMove(m);this._wBlackPlayerInfo.setContent(TMPL_PLAYER_INFO({name:this._black.getShortName(),rating:this._black.getRating(),move:move,color:"black"}));if(!this._my_color&&!this.canClose())this._wUndoBtn.disabled(!m);m=this._pos.getLastMove(true,pos);move=" - ";if(m)move=Position.printMove(m);this._wWhitePlayerInfo.setContent(TMPL_PLAYER_INFO({name:this._white.getShortName(),rating:this._white.getRating(),move:move,color:"white"}));if(this._my_color&&!this.canClose())this._wUndoBtn.disabled(!m);this._wBlackPlayerInfo.condClass(!color,"PlayerInfoActive");this._wWhitePlayerInfo.condClass(color,"PlayerInfoActive");}.$(this);this.updateWidgets();this._white.addEventListener("onChange",this.updateWidgets,null,this);this._black.addEventListener("onChange",this.updateWidgets,null,this);this._wBoard.addEventListener("onReverse",function(){DOM.swapNodes(this._wBlackPlayerInfo.getElement(),this._wWhitePlayerInfo.getElement());}.$(this));if(this._my_color!==null&&!this._my_color)this._wBoard.reverse();this._lastMsg={};var msgLayout=new DlLayout({outerSpace:7});this._wMsgDisplay=new DlContainer({scroll:true,className:"Conversation"});this._wMsgEntry=new DlEntry({accessKey:"ALT 'm'",type:"textarea",emptyText:"Chat! (ALT-M)"});this._wMsgEntry.setStyle({height:"40px"});this._wMsgDisplay.setContextMenu(function(){var menu=new DlVMenu({});new DlMenuItem({parent:menu,label:"Clear conversation",iconClass:"IconDelete"}).addEventListener("onSelect",this.clearConversation.$(this));new DlMenuItem({parent:menu,label:"Show all messages",iconClass:"IconShowAll"}).addEventListener("onSelect",this.showAllMessages.$(this));return menu;}.$(this));var last_hl;this._wMsgDisplay.addEventListener("onMouseOver",function(ev){var el=ev.target,hl=null;if(el&&el.tagName.toLowerCase()=="span"){var f=el.getAttribute("chessField");if(f){hl=this._wBoard.getCellElement(f);}}if(hl&&hl!=last_hl){DOM.addClass(hl,"Highlight");}if(last_hl&&last_hl!=hl){DOM.delClass(last_hl,"Highlight");}last_hl=hl;}.$(this));this._wMsgDisplay.addEventListener("onMouseLeave",function(){if(last_hl){DOM.delClass(last_hl,"Highlight");last_hl=null;}});msgLayout.packWidget(this._wMsgDisplay,{pos:"top",fill:"*"});if(!(this._state&Chess.FLAGS.FINISHED)){msgLayout.packWidget(new DlResizeBar({widget:this._wMsgEntry,horiz:true,invert:true}),{pos:"top",fill:5});msgLayout.packWidget(this._wMsgEntry,{pos:"bottom",min:30,max:170});}this._wMsgEntry.addEventListener("onKey-ENTER",function(ev){if(!ev.shiftKey){var args={op:"message",args:{text:this.getValue(),game:game_id}};this.clear();Chess.sok.sendJSON(args);ev.domStop=true;}});var y=this._wGameBoard.getSize().y;msgLayout.setSize({x:200,y:y});top_layout.packWidget(msgLayout,{pos:"right",fill:"*"});top_layout.setSize({x:550,y:y+this._wTbCont.getSize().y});this.addEventListener("onSocketData",onSocketData);this._on_prefsChange=this._on_prefsChange.$(this);Chess.prefs.addEventListener("onChange",this._on_prefsChange,null,this);if((this._state&Chess.FLAGS.PAUSED)&&!(this._state&Chess.FLAGS.FINISHED)){this.addMessage({type:"warn",text:"Opponent is "+(this._opponent.isOnline()?"Online":"Offline")});(function(){if(this._opponent.isOnline()){this._wBoard.boardPopup({content:HTML_RESUME_DLG({id:this._game_id}),anchor:this._wBoard.getElement()});}}).delayed(10,this);}this.updateState();this.addEventListener("onDestroy",this.clearConversation);};function getPlayerTooltip(user){return user.isPending()&&user.get("registered")?"Pending account":user.isPending()?"Unregistered account":"Registered account";};P._on_prefsChange=function(key,val,oldval){switch(key){case "highlight_last_move":if(val)val=this.last_pm||this._pos.getMoves().peek();this._wBoard.highlightMove(val&&val.from,val&&val.to);break;case "animation":this._wBoard._anim=val;break;case "skin_piece_set":DOM.delClass(this._wBoard.getFieldsElement(),/PieceSet-[^\s]+/gi,"PieceSet-"+val);break;}};P.disableGame=function(val){this._disableGameWidgets.map("disabled",val);this._wBoard.disabled(val);};P.ask_propose=function(what){Chess.sok.sendJSON({op:"propose",args:{game:this._game_id,what:what}});};P.answer_propose=function(what,val){Chess.sok.sendJSON({op:"answer_propose",args:{game:this._game_id,what:what,accept:val}});};P.showConfirmDlg=function(text,handler){function onButton(val){dlg.hide();dlg.handler(val);dlg.handler=null;this.disableGame(false);};var dlg=this._confirm_dlg;if(!dlg){dlg=new DlDialog({parent:this.getParentDialog(),quitBtn:onButton.$(this,false),className:"ConfirmDlg",title:"Confirm"});var box=new DlVbox({parent:dlg});dlg.text=new DlContainer({parent:box,className:"Message"});dlg.text.setStyle({padding:"20px"});box.addSeparator();var buttons=new DlHbox({parent:box,borderSpacing:5});buttons.addFiller();new DlButton({parent:buttons,value:true,label:"Accept".fixedWidth("5em")}).addEventListener("onClick",onButton.$(this,true));new DlButton({parent:buttons,value:false,label:"Decline".fixedWidth("5em")}).addEventListener("onClick",onButton.$(this,false));this._confirm_dlg=dlg;}this.disableGame(true);dlg.handler=handler;dlg.text.setContent(text);dlg.centerOnParent();dlg.show();return dlg;};P.askPropose=function(what){Chess.sok.sendJSON({op:"propose",args:{game:this._game_id,what:what}});};P.answerPropose=function(what,val){Chess.sok.sendJSON({op:"answer_propose",args:{game:this._game_id,what:what,accept:val}});};P.showAskUndo=function(args){var txt=args.move?TMPL_PROPOSE.undo_to_position(args):TMPL_PROPOSE.undo();this.showConfirmDlg(txt,function(accept){Chess.sok.sendJSON({op:"accept_undo",args:{game:this._game_id,move:args.move,accept:accept}});}.$(this));};P.getPGNArgs=function(){return{white:this._white.getShortName(),black:this._black.getShortName(),white_elo:this._white.getRating(),black_elo:this._black.getRating(),result:D.getResult(this._state),date:this.getGameDate()};};P.toPGN=function(mpl,html){var args=this.getPGNArgs();args.mpl=mpl;return this._pos.toPGN(args,html);};function onSocketData(data){var args=data.args;if(args.game_state)this.updateState(args.game_state);switch(data.op){case "move":if(this._my_color!==null){var wm=this._wMoves.children().peek();if(wm)wm.checked(true);var from=args.move.substr(0,2),to=args.move.substr(2,2),trans=args.move.substr(4);this._pos.move(from,to,trans);SND.play("piece_moved");this.updateState();var s=this._pos.getStatus();if(s.mate){SND.play("check_mate");}else if(s.inCheck){SND.play("check");}}break;case "ask_undo":SND.play("propose");this.showAskUndo(args);break;case "accept_undo":SND.play("piece_moved");if(args.accept)this.doUndo(args);break;case "message":this.addMessage(args);break;case "game_ended":this._wBoard.addClass("FinishedBoard");this._ended=true;SND.play("cancelled");break;case "propose":var what=TMPL_PROPOSE[args.what];if(what){SND.play("propose");this.showConfirmDlg(what(args),this.answerPropose.$(this,args.what));}break;case "cancel_game":this._cancelled=true;var dlg=new DlDialog({title:"Game cancelled",modal:true,parent:this.getParentDialog()});var t;if(args.who){t=TMPL_CANCEL_GAME({user:ChessUser.get(args.who)});}else if(args.reason){t=TMPL_CANCEL_GAME_REASON(args);}else{t=TMPL_CANCEL_GAME_AUTO();}dlg.setContent(t);dlg.centerOnParent();dlg.show();SND.play("cancelled");break;}};P.updateState=function(state){if(state!=null)this._game_obj.state=this._state=state;var dlg=this.parent;if(dlg instanceof DlDialog)dlg.__quitBtn.display(this.canClose());if(!this.canClose()){this.disableGame(false);}else if(this._state&(Chess.FLAGS.FINISHED|Chess.FLAGS.PAUSED)){this.disableGame(true);}};P.close=function(){if((this.playingToMyself()||this._pos.getMoves().length<4)&&!this._cancelled){Chess.sok.sendJSON({op:"cancel_game",args:{game:this._game_id}});}};P.playingToMyself=function(){return this._white===this._black&&this._white===Chess.user;};P.canClose=function(){return this.playingToMyself()||this._state==0||this._pos.getMoves().length<4||this._ended||(this._state&(Chess.FLAGS.PAUSED|Chess.FLAGS.FINISHED));};P.doUndo=function(args){this.last_pm=null;var a=Array.$(this._wMoves.children());var i=args.undo_moves;while(i-->0&&a.length)a.pop().destroy();var btn=a.peek();a=this._pos.getMoves();a.splice(a.length-args.undo_moves,args.undo_moves);if(a.length>0)this._pos.setFromFEN(a.peek().fen_after);else this._pos.initialize();this._wBoard.resetToPosition();if(btn)btn.checked(true);this._resetUndoBtn(false);};P._resetUndoBtn=function(toPos){this._wUndoBtn.setLabel(toPos?"<u>U</u>ndo...":"<u>U</u>ndo");this._wUndoBtn.setTooltip(toPos?"Take back your last move<br />or return to this position.":"Take back your last move");};P._sendMove=function(pos,move,piece,transform){if(this._my_color===null||piece.color==this._my_color){var state=this._pos.getStatus();var args={op:"move",args:{game:this._game_id,move:(Position.getIndexId(move.from_index)+Position.getIndexId(move.to_index)+(transform?transform.id:'')).toLowerCase()}};Chess.sok.sendJSON(args);this.updateState();}};P.getGameDate=function(){return this._t_created||new Date;};var TMPL_FIELD_SPAN=String.template("<span class='highlight' chessField='$field'>$origfield</span>");P.clearConversation=function(){this._wMsgDisplay.destroyChildWidgets();this._lastMsg.div=null;this._lastMsg={};};P.showAllMessages=function(){this.clearConversation();this._messages.foreach(function(m){this.addMessage(m,true);},this);};P.addMessage=function(data,noScroll){if(!noScroll)this._messages.push(data);data=Object.makeCopy(data);if(!data.e)data.text=data.text.htmlEscape();data.text=data.text.replace(/\n/g,"<br/>");var tmp,div;if(data.from){if(!noScroll)SND.play("message");if(!data.type)data.type="text";tmp=TMPL_MESSAGE_FROM;}else{if(!data.type)data.type="system";tmp=TMPL_MESSAGE_SYS;data.from="system";}var p=this._wMsgDisplay.getElement();if(!(this._lastMsg.type==data.type&&this._lastMsg.from==data.from)){div=DynarchDomUtils.createFromHtml(tmp(data));p.appendChild(div);}else{div=this._lastMsg.div;}var line=TMPL_MESSAGE_LINE(data);var w=new DlWidget({parent:this,appendArgs:div.childNodes[1],data:data.move});w.getMove=f_get_move;if(data.move){w.addEventListener("onMouseEnter",f_hl_msg);w.addEventListener("onMouseLeave",f_unhl_msg);w.setTooltip(f_msg_tooltip);w.addEventListener("onClick",f_go_to_move);}w.setContent(line);if(!noScroll)p.scrollTop=div.offsetTop+div.offsetHeight;this._lastMsg.type=data.type;this._lastMsg.from=data.from;this._lastMsg.div=div;};function f_go_to_move(ev){if(ev.ctrlKey){var m=this.getMove();if(m){m=this.parent._wMoves._group.getButtons()[m.number-1];m.callHooks("onClick");}}};function f_get_move(){var moves=this.parent._pos.getMoves();return this.userData?moves[this.userData-1]:null;};function f_hl_msg(){this.addClass("message-hover");};function f_unhl_msg(){this.delClass("message-hover");};function f_msg_tooltip(){var w=this.args.widget,m=w.getMove();if(m)return Chess.getBoardTooltip({move:m,reversed:w.parent._wBoard._reversed});};})();(function(){var HTML=String.buffer("<table>","<tr class='header'><td class='num'>#</td><td class='white'></td><td class='black'></td></tr>","</table>").get();ChessMoves.inherits(DlContainer);function ChessMoves(args){args.scroll=true;DlContainer.call(this,args);this.registerEvents(["onSelect"]);this.init();};eval(Dynarch.EXPORT("ChessMoves",true));function onChange(){var val=this._group.getValue()[0];var last=this.children().peek();if(!val){val=last.value();last.checked(true);}else{var sel=!!val;if(sel&&this._group.getSelected()[0]===last)sel=false;this.callHooks("onSelect",val,sel);}};P.init=function(){this._group=DlRadioGroup.get();this.__onGroupChange=onChange.$(this);this._group.addEventListener("onChange",this.__onGroupChange);this.setContent(HTML);};P.getTableElement=function(){return this.getElement().firstChild;};P.addMove=function(move,status){var row,cls,table=this.getTableElement();if(table.rows.length==1||table.rows[table.rows.length-1].childNodes.length==3){row=CE("tr",null,null,table.firstChild);var td=CE("td",null,{className:"num",innerHTML:table.rows.length-1},row);cls="white";}else{row=table.rows[table.rows.length-1];cls="black";}if(move.variant)cls+=" ChessMoveVariant";var label=move.pgn;if(!label){label=move.move;if(status.mate){label+="<span class='mate'>#</span>";}else if(status.inCheck){label+="<span class='check'>+</span>";}}var w=new ChessMoveBtn({parent:this,className:cls,label:label,group:this._group,value:move,appendArgs:row});this._group.removeEventListener("onChange",this.__onGroupChange);w.checked(true);this._group.addEventListener("onChange",this.__onGroupChange);};})();(function(){var BASE=ChessMoveBtn.inherits(DlAbstractButton);function ChessMoveBtn(args){if(args){D.setDefaults(this,args);BASE.constructor.call(this,args);this.setTooltip(getTooltip);}};function getTooltip(){var w=this.args.widget,move=w.getValue();return Chess.getBoardTooltip({move:move});};eval(Dynarch.EXPORT("ChessMoveBtn"));D.DEFAULT_ARGS={_focusable:true,_classes:{active:"ChessMoveBtn-active",hover:"ChessMoveBtn-hover",checked:"ChessMoveBtn-1",unchecked:"ChessMoveBtn-0",empty:"ChessMoveBtn-empty",disabled:"ChessMoveBtn-disabled"},_tagName:"td",_btnType:DlAbstractButton.TYPE.TWOSTATE};P.destroy=function(){var row=this.getElement().parentNode;BASE.destroy.call(this);if(row.cells.length==1)row.parentNode.removeChild(row);};})();(function(){var TMPL_ENCRYPTED_LOGIN=String.buffer("<b>Encrypted login</b><br/>","— Your password is not sent through the network!").get();var TMPL_LOST_PASS_TOOLTIP=String.template("If you forgot your password, check this box and<br />","enter the email address for your account.<br />","We will send you a new password by email.");var TMPL_LOST_PASS_INFO=String.template("A new password has been sent to $email\n","Please check your email and login with the given credentials");ChessLogin.inherits(DlDialog);function ChessLogin(args){args.title="Play Chess Online";DlDialog.call(this,args);this.init();};eval(Dynarch.EXPORT("ChessLogin"));P.init=function(){var ttop_hbox=new DlHbox({parent:this,borderSpacing:5});var tmp=new DlWidget({className:"LoginIconBlackKnightBig",parent:ttop_hbox});tmp.getElement().parentNode.style.verticalAlign="top";var top_box=new DlVbox({parent:ttop_hbox,borderSpacing:5});var fs=new DlFieldset({label:"Existing user?".bold(),parent:top_box});var fg_login=this.fg_login=new DlFieldGrid({parent:fs,align:"center"});var lostPass=new DlCheckbox({label:"Forgot password?",focusable:true,tooltip:TMPL_LOST_PASS_TOOLTIP()});lostPass.addEventListener("onChange",function(){entries.user.label.setLabel(this.checked()?"Email:":"User ID:");entries.password.row.display(!this.checked());entries.remember.row.display(!this.checked());loginBtn.setLabel(this.checked()?"Reset password":"Login");});var entries={};fg_login.addField({name:"lost_password",widget:lostPass});var cell=fg_login.addCell(fg_login.getField("lost_password").parent.parent);new WSmallIcon({parent:cell,tooltip:TMPL_LOST_PASS_TOOLTIP(),iconClass:"IconHint"}).addEventListener("onClick",lostPass.toggle.$(lostPass,null));fg_login.addField({label:"User ID:",name:"user",size:15},null,entries.user={});fg_login.addField({label:"Password:",name:"password",type:"password",size:15},null,entries.password={});fg_login.addField({name:"remember",widget:new DlCheckbox({label:"Remember me",focusable:true})},null,entries.remember={});var loginBtn=new DlButton({label:"Login",focusable:true});fg_login.addField({widget:loginBtn});fg_login.getField("password").addEventListener("onKey-ENTER",loginBtn.keyClicked.$(loginBtn));fs=new DlFieldset({label:"Don't have an account?".bold(),parent:top_box});var vbox=new DlVbox({parent:fs});new DlWidget({parent:vbox}).setContent(["<p>","You can still play, and register it later if you want.","It's <b>all free</b>.","</p>"].join(" ").fixedWidth("20em"));var fg_signup=this.fg_signup=new DlFieldGrid({parent:vbox,align:"center"});fg_signup.addField({label:"User ID:",name:"user",size:15});var signupBtn=new DlButton({label:"Enter",focusable:true});fg_signup.addField({widget:signupBtn});fg_signup.getField("user").addEventListener("onKey-ENTER",signupBtn.keyClicked.$(signupBtn));this._focusedWidget=fg_login.getField("user");loginBtn.addEventListener("onClick",this._loginClicked.$(this));signupBtn.addEventListener("onClick",this._signupClicked.$(this));var cell=fg_login.addCell(fg_login.getField("password").parent.parent);new WSmallIcon({parent:cell,tooltip:TMPL_ENCRYPTED_LOGIN,iconClass:"IconEncrypted"});Chess.sok.addEventListener("onCommand",function(data){if(data.op=="lost_password"){lostPass.checked(false);fg_login.getField("user").setValue(data.args.user);alert(TMPL_LOST_PASS_INFO(data.args));}});};P._loginClicked=function(){Chess.login(this.fg_login.getValues());};P._signupClicked=function(){var val=this.fg_signup.getValues();Chess.loginAnonymous(val.user);};})();(function(){ChessPiece.inherits(DlWidget);function ChessPiece(args){D.setDefaults(this,args);DlWidget.call(this,args);this.init();};eval(Dynarch.EXPORT("ChessPiece"));D.DEFAULT_ARGS={_piece:["piece",null]};P.init=function(){this.setUnselectable();this.setPData(this._piece);this.getElement().onmousedown=Function.returnFalse;};P.getPData=function(){return this._piece;};P.setPData=function(p){this._piece=p;this.addClass("Piece-type-"+(p.color?"white-":"black-")+p.name);};P.getRelPos=function(){return this.parent.getCellPos(this.getElement().parentNode);};})();(function(){ChessPrefs.inherits(DlEventProxy);function ChessPrefs(prefs){DlEventProxy.call(this);this.registerEvents(["onChange"]);if(!prefs)prefs="{}";this._prefs={};prefs=DlJSON.decode(prefs);Dynarch.setDefaults.call(this._prefs,DEFAULT_PREFS,prefs);this._handlers={setCheckbox:function(self){self.set(this.userData,this.checked());if(!DlEvent.latestMouseDownEvent.shiftKey)DlPopup.clearAllPopups();}.$(null,this),setRadioGroup:function(self){self.set(this.userData,this.getValue()[0]);if(!DlEvent.latestMouseDownEvent.shiftKey)DlPopup.clearAllPopups();}.$(null,this)};};var DEFAULT_PREFS={highlight_last_move:["highlight_last_move",true],animation:["animation","fast"],anim_fade:["anim_fade",true],anim_hl_captured:["anim_hl_captured",true],skin_piece_set:["skin_piece_set","Alpha"],skin_color_theme:["skin_color_theme","default"],sounds_on:["sounds_on",true]};eval(Dynarch.EXPORT("ChessPrefs"));P.get=function(key){return this._prefs[key];};P.set=function(key,val){var o=this._prefs[key];this._prefs[key]=val;this.callHooks("onChange",key,val,o);this.save();return o;};P.save=function(){Chess.sok.sendJSON({op:"save_prefs",args:{prefs:DlJSON.encode(this._prefs)}});};P.getPopup=function(){var p=this._popup;if(!p){p=this._popup=new DlVMenu({});var self=this;new DlCheckbox({parent:p,data:"highlight_last_move",label:"Highlight last move",checked:this.get("highlight_last_move")}).addEventListener("onChange",this._handlers.setCheckbox);p.addSeparator();var anim=new DlMenuItem({parent:p,label:"Animation",iconClass:"IconAnimation"});var anim_menu=new DlVMenu({});anim.setMenu(anim_menu);var anim_group=DlRadioGroup.get();anim_group.addEventListener("onChange",this._handlers.setRadioGroup);anim_group.userData="animation";new DlCheckbox({parent:anim_menu,data:"anim_fade",label:"Fade piece",checked:this.get("anim_fade")}).addEventListener("onChange",this._handlers.setCheckbox);new DlCheckbox({parent:anim_menu,data:"anim_hl_captured",label:"Highlight captured piece",checked:this.get("anim_hl_captured")}).addEventListener("onChange",this._handlers.setCheckbox);anim_menu.addSeparator();new DlRadioButton({group:anim_group,parent:anim_menu,value:"slow",label:"Slow"});new DlRadioButton({group:anim_group,parent:anim_menu,value:"fast",label:"Fast"});new DlRadioButton({group:anim_group,parent:anim_menu,value:"faster",label:"Very fast"});anim_menu.addSeparator();new DlRadioButton({group:anim_group,parent:anim_menu,value:false,label:"Disable animation"});anim_group.setValue([this.get("animation")]);var pieces=new DlMenuItem({parent:p,label:"Piece set",iconClass:"IconWKing"});var pieces_group=DlRadioGroup.get();pieces_group.addEventListener("onChange",this._handlers.setRadioGroup);pieces_group.userData="skin_piece_set";var pieces_menu=new DlVMenu({className:"DlSelect-menu"});pieces.setMenu(pieces_menu);var tooltip=String.template("<div class='PieceSkinTooltip'><div class='PieceSet-$id'><div class='ChessPiece'></div></div></div>");"Alpha Adventurer Condal Leipzig Magnetic Marroquin".qw().foreach(function(v){new DlRadioButton({group:pieces_group,parent:pieces_menu,value:v,label:v,tooltip:tooltip({id:v})});});pieces_group.setValue([this.get("skin_piece_set")]);var skins=new DlMenuItem({parent:p,label:"Color theme",iconClass:"IconColors"});var skins_group=DlRadioGroup.get();skins_group.addEventListener("onChange",this._handlers.setRadioGroup);skins_group.userData="skin_color_theme";var skins_menu=new DlVMenu({className:"DlSelect-menu"});skins.setMenu(skins_menu);["default      : Default","ds           : Default (desaturated)","grey         : Monochrome",null,"red          : Red","green        : Green","blue         : Blue","yellow       : Yellow","magenta      : Magenta","cyan         : Cyan",null,"red-ds       : Red (desaturated)","green-ds     : Green (desaturated)","blue-ds      : Blue (desaturated)","yellow-ds    : Yellow (desaturated)","magenta-ds   : Magenta (desaturated)","cyan-ds      : Cyan (desaturated)"].foreach(function(v){if(v==null)skins_menu.addSeparator();else{var a=v.split(/\s*:\s*/),id=a[0],label=a[1];new DlRadioButton({group:skins_group,parent:skins_menu,value:id,label:label});}});skins_group.setValue([this.get("skin_color_theme")]);var sounds=new DlMenuItem({parent:p,label:"Sounds",iconClass:"IconSound"});var sounds_menu=new DlVMenu({});sounds.setMenu(sounds_menu);new DlCheckbox({parent:sounds_menu,data:"sounds_on",label:"Enable",checked:this.get("sounds_on")}).addEventListener("onChange",this._handlers.setCheckbox);}return p;};var SOUNDS={};var SOUND_EVENTS={"piece_moved":"/snd/KDE_TypeWriter_End_Of_Line.mp3","check_mate":"/snd/KDE_Drum_Break.mp3","check":"/snd/KDE_Error_3.mp3","error":"/snd/KDE_Error_3.mp3","propose":"/snd/KDE_Beep_Digital_2.mp3","challenge":"/snd/KDE_Beep_Phone_2.mp3","message":"/snd/KDE_Beep_Connect.mp3","new_game":"/snd/KDE_Dialog_Appear.mp3","cancelled":"/snd/KDE_Dialog_Disappear.mp3","login":"/snd/KDE_Startup_1.mp3"};window.SND={play:function(event){if(!Chess.prefs||Chess.prefs.get("sounds_on")){var url=SOUND_EVENTS[event];if(!url){console.log("No sound for event: %o",event);return;}var snd=SOUNDS[url];if(!snd){snd=SOUNDS[url]=new DlSound({url:url});}snd.play();}}};})();Chess.showEditProfile=function(){var dlg=Chess.EDIT_PROFILE_DLG;if(!dlg){var TMPL_NO_PASSWD=String.buffer("Leave empty to keep your existing password.").get();dlg=Chess.EDIT_PROFILE_DLG=new DlDialog({title:"Your profile",quitBtn:"hide"});var vbox=new DlVbox({parent:dlg,borderSpacing:5});var fieldset=new DlFieldset({parent:vbox,label:"User ID: "+Chess.user.id});var fg=dlg.fg=new DlFieldGrid({parent:fieldset});fg.addField({label:"<u>N</u>ame:",accessKey:"ALT 'n'",name:"name",size:20});fg.addField({label:"<u>E</u>mail:",accessKey:"ALT 'e'",name:"email",size:20});var confirmPassVal=new DlValidator(function(val){if(fg.getField("password1").getValue()!=fg.getField("password2").getValue())throw new DlValidatorException("Passwords don't match",1);return val;});var passCharsVal=new DlValidator(function(val){for(var i=val.length;--i>=0;)if(val.charCodeAt(i)>255)throw new DlValidatorException("Invalid character",2);return val;});fg.addField({label:"<u>W</u>eb site:",accessKey:"ALT 'w'",name:"url",size:20});fg.addSeparator(3);fg.addField({label:"New password:",name:"password1",type:"password",size:20,validators:[passCharsVal]});var cell=fg.addCell(fg.getField("password1").parent.parent);new WSmallIcon({parent:cell,tooltip:TMPL_NO_PASSWD,iconClass:"IconHint"});fg.addField({label:"Confirm password:",name:"password2",type:"password",size:20,validators:[confirmPassVal]});var hbox=new DlHbox({parent:vbox,borderSpacing:4});new WSmallIcon({parent:hbox,iconClass:"IconEncrypted",tooltip:("<b>Encrypted form!</b><br />"+"— Your password and email address are safe!")});hbox.addFiller();new DlButton({parent:hbox,label:"OK".fixedWidth("5em"),focusable:true}).addEventListener("onClick",function(){if(!fg.getField("password1").validate()){alert("Password contains invalid characters -- please use only ASCII");}else if(fg.getField("password2").validate()){var pass=fg.getField("password2").getValue();var data=DlJSON.encode(fg.getValue());var aes=new DlCryptAES({key:hex_hmac_md5(Chess.CHALLENGE,Chess.pass).hexToBytes(),mode:"CTR"});aes.setTimestampIV();data=aes.encodeText(data).concat(aes.getIV());Chess.sok.sendJSON({op:"edit_profile",args:data.map("hex",2).join("")});dlg.hide();Chess.CHALLENGE=null;if(/\S/.test(pass)){Chess.pass=hex_hmac_md5("jont",pass);var last_login=DlFlashStore.get("chess_last_login");if(last_login){last_login=Chess.user.id+":"+pass;DlFlashStore.set("chess_last_login",last_login);}}}else{alert("Passwords don't match!");}});new DlButton({parent:hbox,label:"Cancel".fixedWidth("5em"),focusable:true}).addEventListener("onClick",dlg.hide.$(dlg));dlg.centerOnParent();}dlg.fg.setValue({name:Chess.user.get("name"),email:Chess.user.get("email"),url:Chess.user.get("url")});dlg.show();};Chess.newTestBoard=function(clonepos,pgnargs,last_move,reversed){if(!pgnargs)pgnargs={};var dlg=new DlDialog({title:"DynarchChess Test Board",resizable:true,quitBtn:"destroy"});var layout=new DlLayout({parent:dlg,outerSpace:1});var tbcont=new DlContainer({});var toolbar=new DlHbox({parent:tbcont,className:"DlToolbar"});new DlButton({parent:toolbar,iconClass:"IconRotate",type:DlButton.TYPE.TWOSTATE,tooltip:"Reverse board"}).addEventListener("onClick",function(){board.reverse();});new DlButton({parent:toolbar,iconClass:"IconMagnifier",type:DlButton.TYPE.TWOSTATE,tooltip:"Big board"}).addEventListener("onClick",function(){toggleBoardSize(this.checked());});toolbar.addSeparator("wide-separator");new DlButton({parent:toolbar,iconClass:"IconDuplicate",toolbar:"Clone this board"}).addEventListener("onClick",function(){var clone=Chess.newTestBoard(pos,pgnargs),p=dlg.getPos();clone.setPos(p.x+30,p.y+30);clone.show();});toolbar.addSeparator("wide-separator");new DlButton({parent:toolbar,iconClass:"IconPrev",tooltip:"Previous position"}).addEventListener("onClick",function(){var btn=wMoves._group.getPrevButton();if(btn)btn.checked(true);});new DlButton({parent:toolbar,iconClass:"IconNext",tooltip:"Next position"}).addEventListener("onClick",function(){var btn=wMoves._group.getNextButton();if(btn)btn.checked(true);});toolbar.addSeparator("wide-separator");new DlButton({parent:toolbar,iconClass:"IconReset",tooltip:"Reset to this position"}).addEventListener("onClick",function(){var btn=wMoves._group.getSelected()[0];if(!btn)return;var m=btn.value(),moves=pos.getMoves();if(m.number==moves.length)return;moves.splice(m.number,moves.length-m.number);pos.setFromFEN(m.fen_after);board.resetToPosition();wMoves.children().slice(m.number).map("destroy");});toolbar.addFiller();var wMoves=new ChessMoves({});var pos=new Position;pos.addEventListener("onMove",function(move,piece,transform){if(!move.implicit)wMoves.addMove(move,pos.getStatus());});pos.initialize(clonepos,last_move);pos.moveArgs={variant:true};var board_cont=new DlVbox({});var board=new ChessBoard({position:pos,animation:false,parent:board_cont,className:"SmallChessBoard"});board.getElement().parentNode.style.verticalAlign="top";if(reversed)board.reverse();wMoves.addEventListener("onSelect",function(move,sel){if(!sel)board.resetToPosition();else board.goToFEN(move.fen_after);});layout.packWidget(wMoves,{pos:"right",fill:"*"});layout.packWidget(tbcont,{pos:"top",after:5});layout.packWidget(board_cont,{pos:"left",before:5,after:5,resetSize:true});var sz=board_cont.getSize();layout.setSize({x:sz.x+200,y:sz.y+15+tbcont.getSize().y});function toggleBoardSize(big){board.condClass(big,"LargeChessBoard","SmallChessBoard");board._fSize=null;layout.doLayout();if(big){var sz=layout.getSize();var dirty;if(sz.x<530){sz.x=530;dirty=true;}if(sz.y<360){sz.y=360;dirty=true;}if(dirty)dlg.setInnerSize(sz);}};return dlg;};(function(){ChessUser.inherits(DlEventProxy);function ChessUser(args){DlEventProxy.call(this);this.registerEvents(["onChange"]);D.setDefaults(this,args);};eval(Dynarch.EXPORT("ChessUser"));D.DEFAULT_ARGS={id:["id","test_user"],_name:["name","Test User"],_is_admin:["is_admin",false],_email:["email",null],_url:["url",null],_rating:["rating",1500],_online:["online",null],_pending:["pending",null],_registered:["registered",null],_games_played:["games_played",0],_games_won:["games_won",0],_games_lost:["games_lost",0],_t_created:["t_created",null],_t_last_seen:["t_last_seen",null]};var USERS={};D.get=function(args){if(args instanceof ChessUser)return args;if(typeof args=="string")args={id:args};user=USERS[args.id];if(user)user.set(args);else user=USERS[args.id]=new ChessUser(args);return user;};D.savedOpponent=function(g){var rating=g.color?g.black_elo:g.white_elo;return new ChessUser({id:g.opponent||g.opponent_name,name:g.opponent_name||g.opponent,rating:rating});};D.savedOwner=function(g){if(g.owner){var rating=g.color?g.white_elo:g.black_elo;return new ChessUser({id:g.owner||g.owner_name,name:g.owner_name||g.owner,rating:rating});}else return Chess.user;};P.get=function(key){return this["_"+key];};P.getShortName=P.toString=function(){var name=this.getName();if(name.length>16)name=name.substr(0,16)+"…";return name;};P.getName=function(){return this._name||this.id;};P.getRating=function(){return this._rating;};P.isOnline=function(){return this._online;};P.isPending=function(){return this._pending;};P.set=function(args){var d=D.DEFAULT_ARGS,i,a;for(i in d){a=d[i][0];if(a in args)this[i]=args[a];}this.callHooks("onChange",args);};})();(function(){WSmallIcon.inherits(DlAbstractButton);function WSmallIcon(args){D.setDefaults(this,args);DlAbstractButton.call(this,args);this.setIconClass(this._iconClass);};eval(Dynarch.EXPORT("WSmallIcon"));D.DEFAULT_ARGS={_iconClass:["iconClass",null],_classes:{active:"WSmallIcon-active",hover:"WSmallIcon-hover",checked:"WSmallIcon-1",unchecked:"WSmallIcon-0",empty:"WSmallIcon-empty",disabled:"WSmallIcon-disabled"}};})();Chess.init()
