if(typeof (this.include)!=="function"){this.include=function(A){document.write('<script type="text/javascript" src="'+A+'"><\/script>')}}function extract(D,E,B){var C;if(!empty(E)){C=D.indexOf(E);if(C<0){return null}C+=E.length}var A=D.indexOf(B,C);if(A<C){return null}return D.substring(C,A)}var Browser={IE:(window.attachEvent&&!window.opera)?extract(navigator.appVersion,"MSIE ",";"):false,Opera:window.opera?extract(navigator.appVersion,""," "):false,WebKit:navigator.appVersion.indexOf("AppleWebKit/")>-1?extract(navigator.appVersion,"AppleWebKit/"," "):false,Gecko:navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")==-1?extract(navigator.userAgent,"rv:",")"):false,KHTML:navigator.appVersion.indexOf("KHTML")>-1&&navigator.appVersion.indexOf("AppleWebKit")==-1?extract(navigator.appVersion,"KHTML/"," "):false,MobileSafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/)};function internal(A){A()}function pass(A){return A}pass.toTarget=pass;pass.toSource=pass;function invert(A){return !A}invert.toTarget=invert;invert.toSource=invert;function exists(A){return A!==undefined&&A!==null}function empty(A){return !exists(A)||A===""||(isArray(A)&&A.length===0)||(isObject(A)&&(A.Enumerable?A.isEmpty():!hasProperties(A)))}function hasProperties(A){for(var B in A){return true}return false}function any(){for(var B=0,C=arguments.length;B<C;B++){var A=arguments[B];if(exists(A)){return A}}}function tryAny(){for(var A=0;A<arguments.length;A++){var C=arguments[A];try{return C()}catch(B){}}}function get(B,A){return exists(B)?B:A()}function getByKey(A,C,B){return C in A?A[C]:B}function isObject(A){return typeof (A)=="object"&&A!==null}function isNumber(A){return typeof (A)=="number"}function isString(A){return typeof (A)=="string"}function isFunction(A){return typeof (A)=="function"}function isArray(A){return A instanceof Array}function isDom(A){return exists(A)&&isNumber(A.nodeType)}function init(B,D,C){var A=B[D];return exists(A)?A:B[D]=C}function obtain(B,D,C){var A=B[D];return exists(A)?A:B[D]=C()}function obtainGet(B,D,C){var A=B.get(D);if(!exists(A)){A=C();B.set(D,A)}return A}function obtainSet(A,D,B,C){obtain(A,D,newObject)[B]=C}function obtainAdd(A,C,B){obtain(A,C,newArray).push(B)}function clone(B){var A=new B.constructor();for(var C in B){A[C]=B[C]}return A}function extend(C,B){for(var A in B){C[A]=B[A]}return C}function nothing(){}function str(A){switch(typeof (A)){case"boolean":return A?"true":"false";case"number":case"object":if(A===null){return""}case"string":return String(A);default:return""}}function construct(A){return function(){return new A()}}function provide(A){return function(B){return exists(B)?B:new A()}}var newObject=construct(Object);var newArray=construct(Array);var getObject=provide(newObject);var getArray=provide(newArray);function objectize(A,B){var C={};C[A]=B;return C}function setExisting(A,B,C){if(exists(C)){A[B]=C}}function Exception(B,C,A){this.message=B;this.data=C;this.inner=A}Exception.prototype.toString=function(){var A=this.message;if(this.data){A+=" "+Json.write(this.data)}if(this.inner){A+=" < "+this.inner}return A};function times(C,B){for(var A=0;A<C;A++){B(A)}return B.result}function iterate(D,B,E){for(var A=any(E,0),C=D.length;A<C;A++){B(D[A],A)}return B.result}function iterateReplace(D,B,E){for(var A=any(E,0),C=D.length;A<C;A++){D[A]=B(D[A],A)}return B.result}function enumerate(A,C){for(var B in A){C(A[B],B)}return C.result}function enumerateReplace(D,B,E){for(var A=any(E,0),C=D.length;A<C;A++){D[A]=B(D[A],A)}return B.result}function each(B,A){if(!exists(B)){return }if(B.Enumerable){return B.each(A)}if(isArray(B)||isNumber(B.length)){return iterate(B,A)}if(isNumber(B)){return times(B,A)}return enumerate(B,A)}function builder(B,D){var A=B();var C=function(F,E){D(A,E,F)};C.result=A;return C}function stacker(C){var A=[];var B;if(exists(C)){B=function(E,D){A.push(C(E,D))}}else{B=function(D){A.push(D)}}B.result=A;return B}function mapper(C){var A={};var B;if(exists(C)){B=function(E,D){A[D]=C(E,D)}}else{B=function(E,D){A[D]=E}}B.result=A;return B}function writer(B){var A;if(exists(B)){A=function(D,C){A.result+=B(D,C)}}else{A=function(D,C){A.result+=D}}A.result="";return A}function linearizing(B){function A(C){if(isArray(C)){iterate(C,A)}else{B(C)}}A.result=B.result;return A}function existing(B){function A(C){if(exists(C)){B(C)}}A.result=B.result;return A}function processing(C,B){function A(E,D){C(B(E,D))}A.result=C.result;return A}var $found={type:"Found"};function indexOf(A,C){var B=0;try{each(A,function(F,E){if(C(F,E)){throw $found}B++});return null}catch(D){if(D===$found){return B}throw D}}function search(B,C){var A;try{each(B,function(F,E){if(C(F,E)){A=[F,E];throw $found}});return null}catch(D){if(D===$found){return A}throw D}}function lookup(B,C){var A;try{each(B,function(F,E){A=C(F,E);if(exists(A)){throw $found}});return null}catch(D){if(D===$found){return A}throw D}}function match(B,A){if(exists(A)){return function(C){return C[A]===B}}else{return function(C){return C===B}}}function matchGet(B,A){if(exists(A)){return function(C){return C[A].get()===B}}else{return function(C){return C.get()===B}}}function isArrayOrListable(A){return isArray(A)||(A.Enumerable&&!A.Dictionary)}function $A(B,C,A){return iterate(B,stacker(A),C)}function translate(B,A){return each(B,stacker(A))}function map(B,A){return each(B,mapper(A))}function dict(B,A){return each(B,builder(newObject,function(E,C,D){var F=A(D,C);E[F[0]]=F[1]}))}function extractStrings(B,A){return translate(dict(B,function(D,C){return[A(D,C),null]}),function(D,C){return C})}function compact(B,C,A){return iterate(B,existing(stacker(A)),C)}function linearize(B,C,A){return iterate(B,linearizing(existing(stacker(A))),C)}function includes(B,A){return exists(indexOf(B,A))}function concat(){var A=[];iterate(arguments,function(B){if(exists(B)){iterate(B,function(C){A.push(C)})}});return A}function merge(){var A={};iterate(arguments,function(B){if(exists(B)){extend(A,B)}});return A}function withoutProperties(B){var A=merge(B);iterate(arguments,function(C){delete A[C]},1);return A}function addProperty(B,D,A){var C=1;while(C in B){C++}B[C]=D;A(D,C,null);return C}function changeProperty(C,D,E,B){var A=C[D];if(A!==E){if(exists(E)){C[D]=E}else{delete C[D]}B(E,D,A)}return A}function changeProperties(C,B,A){var D={};enumerate(B,function(G,F){var E=C[F];if(E!==G){D[F]=E;C[F]=G}});enumerate(D,function(F,E){A(C[E],E,F)});return D}function replaceProperties(C,B,A){var D=clone(B);enumerate(C,function(F,E){if(!(E in D)){D[E]=null}});return changeProperties(C,D,A)}function objectAccessor(A,B){return new Accessor(function(){return A[B]},function(D){var C=A[B];A[B]=D;return C})}function getWatchGetter(A){return new WatchGetter(A.get,A.observe,A.invokeObserver)}function cannotGet(A){return A.CanGet?!A.canGet():false}function setter(A,B){return function(){A.set(B)}}function getAccessorDeep(A){while(true){var B=A.get();if(!exists(B)||!B.Accessor){return A}A=B}}function date(E,F,B,A,C,D){return new Date(E,F-1,B,A,C,D)}function copyDate(A){return new Date(A.getTime())}function getArgumentsCount(B){var A=B.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(",");return A.length==1&&!A[0]?0:A.length}function multiDictSet(C,A,B){return obtain(C,A,newWatchList).append(B)}function tryGet(B,A){return exists(B)?B.get(A):null}function multiGet(A,B){indexOf(B,function(C){if(!exists(A)){return true}A=A.get(C)});return A}function contains(B,A){return B.indexOf(A)!=-1}function startsWith(B,A){return A==B.slice(0,A.length)}function endsWith(B,A){return A==B.slice(-A.length)}var specialCharMap={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\\":"\\\\",'"':'\\"'};function escapeString(A){return'"'+A.replace(/[\x00-\x1f\\\"]/g,function(B){if(B in specialCharMap){return specialCharMap[B]}else{return"\\u00"+zeroPad(B.charCodeAt(0).toString(16),2)}})+'"'}function textTemplate(A){return function(B){return format(template,B)}}function format(B,A){return B.replace(/(\{\{)|(\}\})|(\{[^\}]*\})/g,function(C){switch(C){case"{{":return"{";case"}}":return"}"}if(!exists(A)){return""}return str(A[C.slice(1,-1)])})}function trim(A){return trimEnd(trimStart(A))}function trimStart(A){return A.replace(/^\s+/,"")}function trimEnd(A){return A.replace(/\s+$/,"")}function padLeft(C,A,B){while(C.length<A){C=B+C}return C}function zeroPad(B,A){return padLeft(B,A,"0")}function camelToDash(A){return A.replace(/[A-Z]/g,function(B){return"-"+B.toLowerCase()})}function decodeHtml(C){var E=obtain(decodeHtml,"dom",function(){return document.createElement("div")});E.innerHTML=C;var A=[];var D="";(function B(F){iterate(F.childNodes,function(G){if(G.nodeType==1){A.push(D);D="";B(G);A.push(D);D=""}else{D+=G.nodeValue}})})(E);A.push(D);return A}function type(C,A,B,D){D=any(D,function(){});B=getObject(B);B[C]=D;B.constructor=D;D.prototype=B;D.mixins=[C];mixinType(D,A);this[C]=D;return D}function mixinType(target,mixins){var code=target.prototype;var mixs=target.mixins;iterate(mixins,function(mixinName){var mixinCode=eval(mixinName);enumerate(mixinCode.prototype,function(value,key){if(!exists(code[key])||code[key]===Object.prototype[key]){code[key]=value}});if(exists(mixinCode.mixins)){iterate(mixinCode.mixins,function(item){if(!code[item]){mixs.push(item)}})}else{if(!code[mixinName]){mixs.push(mixinName)}init(code,mixinName,mixinCode)}});return target}function mixinInstance(C,B,A){enumerate(A.prototype,function(E,D){C[D]=B[D]});return C}function Enum(){var A=this;iterate(arguments,function(C,B){A[C]=B})}function NamedEnum(){var A=this;iterate(arguments,function(B){A[B]=B})}type("Getter",[],{get:function(){}},function(A){this.get=A});type("Accessor",["Getter"],{set:function(A){}},function(A,B){this.get=A;this.set=B});type("Observable",[],{observe:function(A){}},function(A){this.observe=A});type("InvokableObservable",["Observable"],{invokeObserver:function(A){}},function(A,B){this.observe=A;this.invokeObserver=B});type("WatchGetter",["Getter","InvokableObservable"],{},function(A,C,B){this.get=A;this.observe=C;this.invokeObserver=B});type("WatchAccessor",["WatchGetter","Accessor"],{},function(A,D,C,B){this.get=A;this.set=D;this.observe=C;this.invokeObserver=B});type("CanGet",[],{canGet:function(){throw new Error("Not implemented")}});type("Refreshable",[],{refresh:function(){}},function(A){this.refresh=A});var SourceState=new Enum("None","Loading","Loaded","Error");type("Source",["Refreshable"],{state:null,error:null});type("Enumerable",[],{each:function(A){},isEmpty:function(){}},function(A,B){this.each=A;this.isEmpty=B});type("WatchListable",["Enumerable"],{observe:function(A){}});type("List",["Enumerable"],{length:null,item:function(A){},allItems:function(){},append:function(A){},appendExisting:function(A){if(exists(A)){return this.append(A)}else{return this.length}},insert:function(B,A){},remove:function(A){},removeAt:function(A){},replaceAt:function(B,C){var A=this.removeAt(B);this.insert(B,C);return A},move:function(C,A){var B=this.removeAt(C);this.insert(B,A);return B},clear:function(){},indexOf:function(A){}},function(B){B=getArray(B);var A=this;this.length=new Getter(function(){return B.length});this.item=function(C){return B[C]};this.allItems=function(){return B.slice(0)};this.append=function(C){B.push(C);return B.length-1};this.insert=function(D,C){if(!exists(C)){C=0}B.splice(C,0,D);return C};this.remove=function(D){var C=this.indexOf(D);if(exists(C)){B.splice(C,1)}return C};this.removeAt=function(C){return B.splice(C,1)[0]};this.clear=function(){var C=B;B=[];return C};if(isFunction(B.indexOf)){this.indexOf=function(D){var C=B.indexOf(D);return(C===-1)?null:C}}else{this.indexOf=function(D){for(var C in B){if(B[C]===D){return C}}return null}}this.each=function(C){return iterate(B,C)};this.isEmpty=function(){return B.length===0}});type("Dictionary",["Enumerable"],{get:function(A){throw new Error("Not implemented")},set:function(A,B){throw new Error("Not implemented")},getAll:function(){throw new Error("Not implemented")},update:function(A){throw new Error("Not implemented")},replace:function(A){throw new Error("Not implemented")},clear:function(){throw new Error("Not implemented")}});type("Attachable",[],{attach:function(A){throw new Error("Not implemented")}});type("EnumerableAttachable",["Attachable","Enumerable"]);function curry(B){var A=$A(arguments,1);return function(){return B.apply(this,concat(A,arguments))}}function apply(C,A){var B=$A(arguments,2);return function(){return C.apply(A,concat(B,arguments))}}function methodize(A,B){return function(){var C=A[B];if(exists(C)){return C.apply(A,$A(arguments))}}}function invoker(C,B){B=any(B,[]);return function A(D){return(arguments.callee.result=D.apply(C,B))}}function objectInvoker(B,A){A=any(A,[]);return function(C){var D=B[C];if(exists(D)){return D.apply(B,A)}}}function methodInvoker(B,A){A=any(A,[]);if(isFunction(B)){return function(C){return B.apply(C,A)}}else{return function(C){var D=C[B];if(exists(D)){return D.apply(C,A)}}}}function sequence(){var B=compact(arguments);return function A(){iterate(B,invoker(this,$A(arguments)))}}function commander(B){var A=new Bag();return mixinInstance(function(){return A.each(methodInvoker(B,$A(arguments)))},A,Attachable)}function commands(){var A=new Bag();return mixinInstance(function(){return A.each(invoker(this,$A(arguments)))},A,Attachable)}function command(C,A){function B(){return C.apply(this,$A(arguments))}B.caption=A;return B}function invoke(A){if(exists(A)){return A.apply(this,$A(arguments,1))}}function delay(C,A){var B=setTimeout(C,A);return function(){clearTimeout(B)}}function defer(A){return delay(A,1)}function schedule(A){if(exists(A.scheduled)){return A.scheduled}else{A.scheduled=defer(function(){delete A.scheduled;A()});return A.scheduled}}function delayedBind(C,B,A){C[B]=function(){var D=$A(arguments);var E=A.apply(this,D);C[B]=E;return E.apply(this,D)}}function Point(A,B){if(!exists(A)){this.x=0;this.y=0}else{if(isObject(A)){this.x+=A.x;this.y+=A.y}else{if(!exists(B)){this.x=A;this.y=A}else{this.x=A;this.y=B}}}}Point.fromPolar=function(B,A){return new Point(B*Math.cos(A),B*Math.sin(A))};Point.fromArray=function(A){return new Point(A[0],A[1])};Point.fromVector=function(B,A){return new Point(A.x-B.x,A.y-B.y)};Point.prototype={fromPolar:function(B,A){this.x=B*Math.cos(A);this.y=B*Math.sin(A);return this},fromArray:function(A){this.x=A[0];this.y=A[1];return this},toArray:function(){return[this.x,this.y]},getRadius:function(){return Math.sqrt(MathEx.sqr(this.x)+MathEx.sqr(this.y))},getAngle:function(){return Math.atan2(this.y,this.x)},move:function(A,B){if(isObject(A)){this.x+=A.x;this.y+=A.y}else{this.x+=A;this.y+=B}return this},scale:function(A,B){if(isObject(A)){this.x*=A.x;this.y*=A.y}else{if(!exists(B)){this.x*=A;this.y*=A}else{this.x*=A;this.y*=B}}return this},getOffset:function(A,B){return new Point(this.x-A,this.y-B)},placeToCircle:function(A,E,B){var D=this.getOffset(A,E);var C=D.getRadius();if(C>B){this.fromPolar(B,D.getAngle());this.move(A,E)}return this},setMinimum:function(A,B){if(A<this.x){this.x=A}if(B<this.y){this.y=B}},setMaximum:function(A,B){if(A>this.x){this.x=A}if(B>this.y){this.y=B}}};var Rad={};times(4,function(A){Rad["q"+(A+1)]=Math.PI*(A+1)/2});var MathEx={sqr:function(A){return A*A},degToRad:function(A){return A*Math.PI/180},radToDeg:function(A){return A*180/Math.PI},getLength:function(B,A){return Point.fromVector(B,A).getRadius()},getPolylineLength:function(A){var C=0;var B=null;each(A,function(D){if(exists(B)){C+=MathEx.getLength(B,D)}B=D});return C},getPointOnPolyline:function(C,E){var B=null;var D=null;var A=lookup(C,function(F){if(exists(D)){var G=Point.fromVector(D,F);var H=G.getRadius();if(E<H){var I=G.getAngle();G.scale(E/H).move(D);G.angle=I;return G}E-=H}B=D;D=F});if(!exists(A)){A=new Point(D);A.angle=MathEx.radToDeg(Point.fromVector(B,D).getAngle())}return A}};function even(A){return A%2===0}function odd(A){return A%2!==0}type("Bag",["EnumerableAttachable"],{},function(){var A=0;var B={};var D=null;function C(F){return function E(){if(F in B){delete B[F];return true}return false}}this.each=function(F){D={};var E=enumerate(B,F);extend(B,D);D=null;return E};this.attach=function(E){var F=A++;if(exists(D)){D[F]=E}else{B[F]=E}return C(F)}});function watchize(C){if(!exists(C)||!isObject(C)){return C}if(isArray(C)){var B=new WatchList();iterate(C,function(D){B.append(watchize(D,setter))});return B}var A=new WatchObject();enumerate(C,function(E,D){A.set(D,watchize(E));init(A,D,A.accessor(D))});return A}function watch(A,B){if(isObject(A)){if(A.WatchGetter){A.observe(function(D,C){if(exists(C)){unwatch(C,B)}if(exists(D)){watch(D,B)}B()})}else{if(A.WatchList){A.observe({itemAdded:function(E,D,C){watch(E,B);B()},itemRemoved:function(E,D,C){unwatch(E,B);B()}})}else{if(A.WatchObject){A.observe(function(F,E,D,C){if(exists(C)){unwatch(C,B)}if(exists(F)){watch(F,B)}B()})}else{each(A,function(C){watch(C,B)})}}}}return A}function unwatch(){}function $V(B,A){return bind.toAccessor(new WatchValue(),B,A)}function $C(B,A){return bind.accessor(new WatchValue(),B,A)}type("WatchValue",["WatchAccessor"],{},function(B){var A=commands();this.WatchAccessor(function(){return B},function(D){if(B!=D){var C=B;B=D;A(D,C)}},A.attach,function(C){return C(B,B)})});function watchSetter(B){var A=new WatchValue(B);return mixinInstance(function(C){A.set(C);return this},A,WatchAccessor)}type("WatchPair",["WatchValue"],{key:null},function(A,B){this.key=A;this.WatchValue(B)});function $L(B,A){return bind.toList(new WatchList(),B,A)}type("WatchList",["WatchListable","List"],{accessor:function(B){var A=this;return new WatchAccessor(function(){return A.item(B)},function(C){return A.replaceAt(B,C)},function(C){return A.observe({itemAdded:function(E,D){if(D==B){C(E,A.item(B+1))}else{if(D<B){C(A.item(B),A.item(B+1))}}},itemRemoved:function(E,D){if(D==B){C(A.item(B),E)}else{if(D<B){C(A.item(B),A.item(B-1))}}},itemMoved:function(E,D){var F=D[0];var G=D[1];if(F==B){if(G!=B){C(A.item(B),E)}}else{if(F<B){if(G>=B){C(A.item(B),A.item(B-1))}}else{if(G<=B){C(A.item(B),A.item(B+1))}}}}})},function(C){var D=A.item(B);return C(D,D)})}},function(){var A=new List($A(arguments));var C=$V(A.length);var B=commands();this.each=A.each;this.isEmpty=A.isEmpty;this.length=getWatchGetter(C);this.item=A.item;this.allItems=A.allItems;this.append=function(E){var D=A.append(E);B("itemAdded",E,D,self);C.set(A.length.get());return D};this.insert=function(E,D){if(!exists(D)||D<A.length){D=A.insert(E,D);B("itemAdded",E,D,self);C.set(A.length.get());return D}while(D-->A.length){this.append(null)}return this.append(E)};this.remove=function(E){var D=A.remove(E);if(D>=0){B("itemRemoved",E,D,self);C.set(A.length.get())}return D};this.removeAt=function(D){var E=A.removeAt(D);if(exists(E)){B("itemRemoved",E,D,self)}C.set(A.length.get());return E};this.move=function(F,D){var E=A.move(F,D);B("itemMoved",E,[F,D],self);C.set(A.length.get());return E};this.clear=function(){var D=A.clear();iterate(D,function(E){B("itemRemoved",E,0,self)});C.set(A.length.get());return D};this.indexOf=A.indexOf;this.observe=function(E){var D=isFunction(E)?E:function(F){var G=E[F];if(exists(G)){G.apply(E,$A(arguments,1))}};return B.attach(D)}});function processListable(B,A){each(B,A.itemAdded);if(B.WatchListable){return B.observe(A)}}function processListableAccessor(D,C,B,A){processListable(D,{itemAdded:function(F){var E=F[C];if(exists(E)){bind.setter(E,E,function(H,G){if(exists(G)){A(G)}if(exists(H)){B(H)}})}},itemRemoved:function(G){var E=G[C];if(exists(E)){bind.stop(E);var F=E.get();if(exists(F)){A(F)}}}})}newWatchList=construct(WatchList);getWatchList=provide(WatchList);function $O(B,A){return bind.toDictionary(new WatchObject(),B,A)}type("WatchObject",["Dictionary","Observable"],{add:function(A){},getter:function(B){var A=this;return new WatchGetter(function(){return A.get(B)},function(C){return A.observe(function(G,F,E,D){return C(G,D)},B)},function(C){var D=A.get(B);return C(D,D)})},accessor:function(B){var A=this;return new WatchAccessor(function(){return A.get(B)},function(C){return A.set(B,C)},function(C){return A.observe(function(G,F,E,D){return C(G,D)},B)},function(C){var D=A.get(B);return C(D,D)})}},function(){var B=this;var E={};var A={};var D=commands();var C=function(I,H,G){var F=A[H];if(exists(F)){F(I,H,B,G)}D(I,H,B,G)};this.each=function(F){return enumerate(E,F)};this.isEmpty=function(){return !hasProperties(E)};this.get=function(F){return E[F]};this.set=function(F,G){return changeProperty(E,F,G,C)};this.getAll=function(){return clone(E)};this.update=function(F){return changeProperties(E,F,C)};this.replace=function(F){return replaceProperties(E,F,C)};this.clear=function(){var F=E;E={};enumerate(F,function(G,H){C(null,G,H)});return F};this.observe=function(G,H){if(exists(H)){var F=A[H];if(!exists(F)){F=commands();A[H]=F}return F.attach(G)}else{return D.attach(G)}};this.add=function(F){return addProperty(E,F,C)};return mixWatchAccessors(this,arguments,this)});function watchType(B,D,A){var C=type(B,any(A,[]),{},function(G){if(this instanceof arguments.callee){var F=new WatchObject();var E=this;iterate(C.mixins,function(H){mixWatchAccessors(E,E[H].watchProperties,F)});watchType.init(this,arguments)}else{return watchType.load(new arguments.callee(),G)}});C.watchProperties=D;return C}watchType.init=function(C,B){var A=0;iterate(C.constructor.mixins,function(D){iterate(C[D].watchProperties,function(E){C[E].set(B[A++])})});return C};watchType.load=function(B,A){if(A instanceof B.constructor){iterate(B.constructor.mixins,function(C){iterate(B[C].watchProperties,function(E){var D=A[E];if(exists(D)&&D.Getter){B[E].set(D.get())}})})}else{iterate(B.constructor.mixins,function(C){iterate(B[C].watchProperties,function(D){B[D].set(A[D])})})}return B};function mixWatchGetters(C,B,A){if(!exists(A)){A=new WatchObject()}iterate(B,function(D){C[D]=A.getter(D)});return A}function mixWatchAccessors(C,B,A){if(!exists(A)){A=new WatchObject()}iterate(B,function(D){C[D]=A.accessor(D)});return A}function mixWatchObject(D,B,C,A){if(!exists(A)){A=new WatchObject()}iterate(properties,function(E){D[E]=A.accessor(E)});iterate(C,function(E){D[E]=A.getter(E)});return A}newWatchObject=construct(WatchObject);getWatchObject=provide(WatchObject);function $B(C,B,A){if(exists(C)&&C.XElement&&cannotGet(C)){return bind.element(C,B,A)}else{return bind(C,B,A)}}var bind=function(C,B,A){if(!exists(B)){return bind.detach(C)}if(!exists(C)){return obtainTemplate(A)(B)}if(C.Accessor){return bind.accessor(C,B,A)}if(C.List){return bind.toList(C,B,A)}if(C.Dictionary){return bind.toDictionary(C,B,A)}bind.detach(C);throw new Error("Not implemented.")};bind.element=function(C,B,A){return bind.attach(C,bind.internal.element(C,B,A))};bind.accessor=function(E,D,C){if(cannotGet(E)){if(cannotGet(D)){return bind.detach(E)}else{return bind.toAccessor(E,D,C)}}else{if(D.Accessor){if(cannotGet(D)){return bind.toAccessor(D,E,C)}else{var B,A;if(!exists(C)){B=null;A=null}else{if(isString(C)){B=C;A=function(F){D[C]=F}}else{B=C.toTarget;A=C.toSource}}bind.toAccessor(E,D,B);bind.toAccessor(D,E,A);return E}}else{return bind.toAccessor(E,D,C)}}};bind.toAccessor=function(C,B,A){return bind.setter(C,B,templatedSetter(A,function(D){C.set(D)}))};bind.toList=function(C,B,A){return bind.setter(C,B,function(D){if(!exists(D)){C.clear();return null}if(isArrayOrListable(D)){return bind.internal.list(C,D,A)}return bind.internal.objectToList(C,D,A)})};bind.toDictionary=function(C,B,A){return bind.setter(C,B,function(D){if(!exists(D)){C.clear();return null}if(isArrayOrListable(D)){return bind.internal.listToDictionary(C,D,A)}return bind.internal.objectToDictionary(C,D,A)})};bind.list=function(C,B,A){return bind.attach(C,bind.internal.list(C,B,A))};bind.objectToList=function(C,B,A){return bind.attach(C,bind.internal.objectToList(C,B,A))};bind.listToDictionary=function(C,B,A){return bind.attach(C,bind.internal.listToDictionary(C,B,A))};bind.objectToDictionary=function(C,B,A){return bind.attach(C,bind.internal.objectToDictionary(C,B,A))};bind.sequence=function(C,B,A){return bind.attach(C,bind.internal.sequence(C,B,A))};bind.listEx=function(C,B,A,D,E){return bind.attach(C,bind.internal.listEx(C,B,A,D,E))};bind.setter=function(C,B,D){function A(E){if(exists(E)&&E.Getter){return bind.internal.getter(A,E)}return D(E)}return bind.attach(C,A(B))};bind.attach=function(B,A){if(B.unbind){B.unbind();if(A){B.unbind=A}else{delete B.unbind}}else{if(A){B.unbind=A}}return B};bind.detach=function(A){if(A.unbind){A.unbind();delete A.unbind}return A};bind.internal={};bind.internal.element=function(D,C,A){if(!exists(D)){return obtainTemplate(A)(C)}function B(E){if(!exists(E)||E.XElement||!isObject(E)){D.clear();D.append(obtainTemplate(A)(E,D));return null}if(E.Getter){return bind.internal.getter(B,E)}if(isArrayOrListable(E)){return bind.internal.list(D,E,A)}return bind.internal.list(D,$L(E),A)}return B(C)};bind.internal.getter=function(C,B){var A=C(B.get());if(B.WatchGetter){return sequence(A,B.observe(sequence(A,function(D){C(D)})))}return A};bind.internal.list=function(D,C,B){B=obtainTemplate(B);function A(F,E){D.insert(B(F,D),E)}D.clear();processListable(C,{itemAdded:A,itemRemoved:function(F,E){D.removeAt(E)},itemMoved:function(F,G,E){D.move(G,E)}});return null};bind.internal.objectToList=function(D,A,B){B=obtainTemplate(B);if(A.WatchObject){var C=new WatchList();each(A,function(F,E){C.append(new WatchPair(E,F))});return sequence(bind.internal.list(D,C,B),A.observe(function(I,H,J,F){if(exists(I)){var E=search(C,match(H,"key"));if(exists(E)){E[0].set(I)}else{C.append(new WatchPair(H,I))}}else{var G=indexOf(C,match(H,"key"));if(exists(G)){C.removeAt(G)}}}))}else{D.clear();each(A,function(F,E){D.append(B(new WatchPair(E,F),D))})}return null};bind.internal.listToDictionary=function(C,B,A){throw new Error("Not implemented.")};bind.internal.objectToDictionary=function(C,B,A){if(B.WatchObject){throw new Error("Not implemented.")}if(exists(A)){B=map(B,A)}C.update(B);return null};bind.internal.sequence=function(C,B,A){A=obtainTemplate(A);function D(){C.clear();each(B,function(F,E){C.insert(A(F,E,C),E)})}D();if(B.WatchList){return B.observe(D)}return null};bind.internal.listEx=function(D,C,B,E,F){B=obtainTemplate(B);if(!exists(E)){E=0}if(!exists(F)){F=1}function A(J,H){var G=B(J,D);var K=E+F*H;for(var I=0;I<F;I++){D.insert(G[I],K+I)}}each(C,A);if(C.WatchList){return C.observe({itemAdded:A,itemRemoved:function(H,G){G=E+F*G;times(F,function(){D.removeAt(G)})},itemMoved:function(H,I,G){I=E+F*I;G=E+F*G;times(F,function(){D.move(I,G)})}})}return null};function callOrGet(A){return isFunction(A)?A():A}function obtainTemplate(A){if(!exists(A)){return pass}if(isFunction(A)){return A}return function(B){return exists(B)?B[A]:null}}function templatedSetter(A,B){if(!exists(A)){return B}if(isFunction(A)){return function(C){B(A(C))}}return function(C){B(exists(C)?C[A]:null)}}function getNoneTemplate(A){return function(B){return exists(B)?B:callOrGet(A)}}function getBlankTemplate(A){return function(B){return empty(B)?callOrGet(A):B}}function replaceEmpty(B,A){return empty(B)?callOrGet(A):B}function existenceTemplator(C,B,A){return function(D){return exists(D)?empty(D)?A:C(D):B}}function templateSplitter(B,A){A=obtainTemplate(A);return function(D){var C=B[D];if(exists(C)){return C(D)}else{return A(D)}}}function splitter(A){if(A.Dictionary){return function(B){return A.get(B)}}else{return function(B){return A[B]}}}type("Chooser",["WatchAccessor"],{option:function(B){var A=this;return function(){A.set(B)}}},function(A){var B=$V();mixinInstance(this,B,WatchGetter);this.set=templatedSetter(splitter(A),B.set)});type("Switch",["WatchGetter"],{},function(){var B=$V();var A=this;mixinInstance(this,B,WatchGetter);iterate(arguments,function(C){if(isArray(C)){A[C[0]]=function(){iterate(C,function(D){B.set(D)})}}else{A[C]=function(){B.set(C)}}})});var Logic={onlyOne:function(B,A){iterate(B,function(C){C.observe(function(D){if(D!==A){iterate(B,function(E){if(E!==C){E.set(A)}})}})})}};var Json={validate:function(A){A=A.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,"");return(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(A)},read:function(json){try{if(!Json.validate(json)){throw"Invalid json."}return eval("("+json+")")}catch(e){throw"Cannot read json. "+e}},write:function(A){if(!exists(A)){return"null"}switch(typeof (A)){case"boolean":case"number":return str(A);case"string":return escapeString(A);case"object":if(A.Getter){return Json.write(A.get())}if(A.Dictionary){A=A.getAll()}if(A.Enumerable){return"["+A.each(stacker(Json.write)).join(",")+"]"}if(isArray(A)){return"["+iterate(A,stacker(Json.write)).join(",")+"]"}var B=[];enumerate(A,function(D,C){if(!isFunction(D)){B.push(escapeString(C)+":"+Json.write(D))}});return"{"+B.join(",")+"}";default:throw"Invalid object: "+str(A)}}};function jsonAlert(A){alert(Json.write(A))}var ReadyState=new Enum("Uninitialized","Loading","Loaded","Interactive","Complete");function jsonRpcObject(D,C,F,K){var L=new Source();var I=mixWatchGetters(L,["state","error"]);var G=new WatchObject();mixinInstance(L,G,WatchObject);var J=false;var B={};function H(M,P){var O={};var N=true;enumerate(B,function(R,Q){if(R){O[Q]=G.get(Q);N=false}});B={};if(!N){jsonRpcCommit(D,C,F,O,E,D)}}function A(M){if(!J){B[M]=true;defer(H)}}function E(M,N){if(exists(N)){I.update({state:SourceState.Error,error:N})}else{if(exists(M)){J=true;if(!K){enumerate(M,function(P,O){G.set(O,watch(watchize(P),curry(A,O)))})}else{enumerate(M,function(P,O){G.set(O,P)})}J=false}I.update({state:SourceState.Loaded,error:null})}}G.observe(function(N,M){A(M)});L.refresh=function(){I.update({state:SourceState.Loading,error:null});return jsonRpc(D,C,F,E)};L.refresh();return L}function jsonRpcValue(C,F,E){var A=new Source();var B=mixWatchGetters(A,["state","error"]);mixinInstance(A,B.accessor("value"),WatchAccessor);function D(G,H){if(exists(H)){B.update({state:SourceState.Error,error:H})}else{B.update({state:SourceState.Loaded,value:G,error:null})}}A.set=function(H){var G=A.get();jsonRpcCommit(C,F,E,H,D);return G};A.refresh=function(){B.update({state:SourceState.Loading,error:null});return jsonRpc(C,F,E,D)};A.refresh();return A}function jsonRpcCommit(B,F,E,D,C){var A;if(!exists(E)){A=D}else{if(isArray(E)){A=$A(E);A.push(D)}else{if(isObject(E)){A=clone(E);A.value=D}else{A=D}}}return jsonRpc(B,F,A,C)}function jsonRpc(A,D,C,B){return jsonRequest(A,{version:"1.1",method:D,params:C},function(E,F){if(exists(F)){B(E,"SERVER: "+F)}else{B(E.result,E.error)}})}function jsonRequest(A,C,B){return webRequest(A,"application/json",Json.write(C),function(D,E){B(exists(D)?Json.read(D):D,E)})}function webRequest(B,F,A,C){var E=Web.transport();try{E.open("POST",B,true);E.setRequestHeader("Accept","text/javascript, text/html, application/xml, text/xml, application/json, */*");E.setRequestHeader("Content-Type",F);E.onreadystatechange=function(){if(E.readyState!=ReadyState.Complete){return }delete E.onreadystatechange;var G=E.status;if(G>=200&&G<300){C(E.responseText,null)}else{C(E.responseText,[G,E.statusText])}};E.send(A)}catch(D){C(null,D)}return E.abort}function webGet(A,B){var D=Web.transport();try{D.open("GET",A,true);D.setRequestHeader("Accept","text/javascript, text/html, application/xml, text/xml, application/json, */*");D.setRequestHeader("Cache-Control","max-age=1000000000");D.onreadystatechange=function(){if(D.readyState!=ReadyState.Complete){return }D.onreadystatechange=null;var E=D.status;if(E>=200&&E<300){B(D.responseText,null)}else{B(D.responseText,[E,D.statusText])}};D.send(null)}catch(C){B(null,C)}return D.abort}var Web={};if("XMLHttpRequest" in window){Web.transport=function(){return new XMLHttpRequest()}}else{Web.transport=function(){return tryAny(function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")})}}type("DataReference",["Source","WatchGetter"],{id:Getter,revision:Getter});type("DataStore",["DataReference"],{getReference:function(B,A){},fetchNew:function(A){},submit:function(B,A){}},function(C){var I=this;var H={};var G={};var E={};var D={};var A=[];var K=[];var B=0;function F(){var L;if(!empty(D)){L.getLatestRevisions=enumerate(D,stacker(function(O,N){return N}));D={}}if(!empty(E)){L.submit=E;E={}}var M=B-K.length+10;if(M>0){B=0;L.getNewIds=M+10}if(empty(L)){return }L.date=new Date().toString();jsonRequest(C,L,function(N,O){if(exists(N)&&!exists(O)){enumerate(N.latestRevisions,function(Q,P){var R=G[P];if(exists(R)){R(Q)}});K.splice(K.length,0,N.newIds);iterate(A,function(P){thisStore.fetchNew(P)});enumerate(N.submitErrors,function(Q,P){})}else{}})}function J(L){D[L]=true;schedule(F)}I.getReference=function(R,N){var L;if(!exists(N)){L=H[R];if(exists(L)){return L}}L=new DataReference();var M=mixWatchGetters(self,["state","error"]);mixinInstance(L,M.accessor("data"),WatchGetter);var P=L.observe;var O=0;function Q(S){if(exists(S)){webGet(C+R+"/"+S,function(T,U){if(exists(U)){M.update({state:SourceState.Error,error:U})}else{M.update({state:SourceState.Loaded,error:null,data:Json.read(T)})}})}else{if(isFunction(N)){submit(R,N())}else{M.update({state:SourceState.Loaded,error:null,data:null})}}}if(!exists(N)){H[R]=L;G[R]=Q}L.id=new Getter(function(){return R});L.revision=new Getter(function(){return N});L.refresh=function(){M.update({state:SourceState.Loading,error:null});if(exists(N)){Q(N)}else{J(R)}};L.observe=function(S){if(O++==0){L.refresh()}var T=P(S);return function(){if(!T()){return false}if(--O==0){M.set("data",null)}return true}};M.update({state:SourceState.None,error:null,id:R,revision:N,data:null});return L};I.fetchNew=function(L){var M=getArgumentsCount(L);if(K.length>=M){L.apply(null,K.splice(0,M))}else{A.push(L);B+=M}schedule(F)};I.submit=function(M,L){E[M]=L;schedule(F)}});function parseTime(E){E=trim(E);if(E==""){return null}var A=0;var D=0;if(/^\d{1,4}$/.test(E)){switch(E.length){case 1:A=parseInt(E,10);break;case 2:A=parseInt(E.substr(0,2),10);break;case 3:A=parseInt(E.substr(0,1),10);D=parseInt(E.substr(1,2),10);break;case 4:A=parseInt(E.substr(0,2),10);D=parseInt(E.substr(2,2),10);break}}else{var C=/^(\d{1,2})[\W]+(\d{1,2})?/.exec(E);if(!C){return null}A=parseInt(C[1],10);var B=any(C[2],"");if(B!=""){D=parseInt(B,10)}}return[A,D]}function formatTime(A){return A.getHours().toString()+":"+A.getMinutes().toPaddedString(2)}function setTime(B,A){B.setHours(any(A[0],0),any(A[1],0),any(A[2],0),any(A[3],0))}function getTime(A){return[A.getHours(),A.getMinutes(),A.getSeconds(),A.getMilliseconds()]}function parseDate(F){F=trim(F);if(F==""){return null}var A=null;var E=null;var C=null;if(/^\d{1,8}$/.test(F)){switch(F.length){case 1:A=parseInt(F.substr(0,1),10);break;case 2:A=parseInt(F.substr(0,1),10);E=parseInt(F.substr(1,1),10);break;case 3:A=parseInt(F.substr(0,2),10);E=parseInt(F.substr(2,1),10);break;case 4:A=parseInt(F.substr(0,2),10);E=parseInt(F.substr(2,2),10);break;case 5:A=parseInt(F.substr(0,2),10);E=parseInt(F.substr(2,2),10);C=[parseInt(F.substr(4,1),10)];break;case 6:A=parseInt(F.substr(0,2),10);E=parseInt(F.substr(2,2),10);C=[parseInt(F.substr(4,2),10)];break;case 7:A=parseInt(F.substr(0,2),10);E=parseInt(F.substr(2,2),10);C=parseInt(F.substr(4,3),10);break;case 8:A=parseInt(F.substr(0,2),10);E=parseInt(F.substr(2,2),10);C=parseInt(F.substr(4,4),10);break}}else{var B=/^(\d{1,2})[\W]+((\d{1,2})([\W]+(\d{1,4})?)?)?/.exec(F);if(!B){return null}A=parseInt(B[1],10);var D=any(B[3],"");if(D!=""){E=parseInt(D,10)}var G=any(B[5],"");if(exists(G)){C=parseInt(G,10);if(G.length<3){C=[C]}}}return[A,E,C]}function formatDate(A){return A.getDate().toString()+"."+(A.getMonth()+1).toString()+"."+A.getFullYear().toPaddedString(3)}function setDate(C,A){var B=A[0];var E=A[1];var D=A[2];if(exists(B)){C.setDate(B)}if(exists(E)){C.setMonth(E-1)}if(exists(D)){if(isArray(D)){D=Math.floor(C.getFullYear()/100)*100+D[0]}C.setFullYear(D)}}function getDate(A){return[A.getDate(),A.getMonth()+1,A.getFullYear()]}function addMiliseconds(B,C){var A=new Date();A.setTime(B.getTime()+C);return A}function addSeconds(A,B){return addMiliseconds(A,B*1000)}function addMinutes(A,B){return addSeconds(A,B*60)}function addHours(A,B){return addMinutes(A,B*60)}function addDays(A,B){return addHours(A,B*24)}function __test__parseTime(){var A=[];iterate([["1",1,0],["12",12,0],["27",27,0],["123",1,23],["023",0,23],["1234",12,34],["0034",0,34],["1:",1,0],["12:",12,0],["3:4",3,4],["12:3",12,3],["02:3",2,3],["12:34",12,34],["00:34",0,34]],function(C){var B=parseTime(C[0]);if(B==null){if(C[1]!=null){A.push(format("{0}> {1}:{2} != null",[C[0],C[1],C[2]]))}}else{if(B[0]!=C[1]||B[1]!=C[2]){A.push(format("{0}> {1}:{2} != {3}:{4}",[C[0],C[1],C[2],B[0],B[1]]))}}});return A}function __test__parseDate(){var A=[];iterate([["2",2,null,null],["23",2,3,null],["231",23,1,null],["2310",23,10,null],["23104",23,10,[4]],["231045",23,10,[45]],["2310456",23,10,456],["23104567",23,10,4567],["23107",23,10,[7]],["231007",23,10,[7]],["2310007",23,10,7],["23100007",23,10,7],["30.",30,null,null],["2.10",2,10,null],["23.1",23,1,null],["23.10",23,10,null],["30.12.",30,12,null],["2.10.4",2,10,[4]],["23.1.4",23,1,[4]],["2.10.45",2,10,[45]],["23.1.45",23,1,[45]],["23.10.45",23,10,[45]],["2.10.4567",2,10,4567],["23.1.4567",23,1,4567],["23.10.4567",23,10,4567]],function(C){var B=parseDate(C[0]);if(B==null){if(C[1]!=null){A.push(format("{0}> {1}.{2}.{3} != null",[C[0],C[1],C[2],C[3]]))}}else{if(B[0]!=C[1]||B[1]!=C[2]||(B[2]!=C[3]&&(B[2]!=null&&C[3]!=null&&B[2][0]!=C[3][0]))){A.push(format("{0}> {1}.{2}.{3} != {4}.{5}.{6}",[C[0],C[1],C[2],C[3],B[0],B[1],B[2]]))}}});return A}var File={};File.getSystem=function(){return obtain(File,"FileSystemObject",function(){return new ActiveXObject("Scripting.FileSystemObject")})};File.read=function(A){var C=File.getSystem().OpenTextFile(A,1);var B;try{B=C.ReadAll()}finally{C.Close()}return B};File.write=function(A,B){var C=File.getSystem().OpenTextFile(A,2,true);try{C.Write(B)}finally{C.Close()}};File.append=function(A,B){var C=File.getSystem().OpenTextFile(A,8,true);try{C.Write(B)}finally{C.Close()}};File.exists=function(A){return File.getSystem().FileExists(A)};var Cookies={set:function(A,B,C){document.cookie=A+"="+B+"; expires="+addDays(new Date(),any(C,600)).toGMTString()+"; path=/"},erase:function(A){Cookies.set(A,"",-1)},get:function(A){return Cookies.all()[A]},all:function(){var A={};iterate(document.cookie.split(";"),function(C){var E=C.split("=",2);if(E.length<2){return }var B=trim(E[0]);var F=trim(E[1]);var D=A[B];if(isArray(D)){D.push(F)}else{if(exists(D)){A[B]=[D,F]}else{A[B]=F}}});return A}};function MimeType(B,C,D,A){this.name=B;this.classid=C;this.codebase=D;this.url=A}MimeType.QuickTime=new MimeType("image/x-quicktime","clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B","http://www.apple.com/qtactivex/qtplugin.cab","http://www.apple.com/quicktime/download/");MimeType.RealPlayer=new MimeType("audio/x-pn-realaudio-plugin","clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA",null,null);MimeType.Flash=new MimeType("application/x-shockwave-flash","clsid:D27CDB6E-AE6D-11cf-96B8-444553540000","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab","http://www.macromedia.com/go/getflashplayer");function getDom(A){if(!exists(A)){return Html.hidden().dom}if(isDom(A)){return A}if(A.XElement){return A.dom}return document.createTextNode(str(A))}var Dom={Event:{observe:function(C,B,A){if(C.addEventListener){C.addEventListener(B,A,false);return function(){C.removeEventListener(B,A,false)}}else{B="on"+B;C.attachEvent(B,A);return function(){C.detachEvent(B,A)}}},observeOnce:function(D,B,A){var C;var E=function(F){C();A(F)};C=Dom.observe(D,B,E);return C},dispatch:function(C,A){var B;if(document.createEvent){B=document.createEvent("HTMLEvents");B.initEvent(A,true,true);C.dispatchEvent(B)}else{B=document.createEventObject();C.fireEvent("on"+A,B)}return B}},List:{each:function(B,A){return iterate(B.childNodes,A)},length:function(A){return A.childNodes.length},item:function(B,A){return B.childNodes[A]},append:function(B,A){B.appendChild(getDom(A));return B.childNodes.length-1},insert:function(D,C,B){if(!exists(B)){B=0}var A=D.childNodes;if(B<A.length){D.insertBefore(getDom(C),A[B]);return B}while(B-->A.length){Dom.List.append(D,null)}return Dom.List.append(D,C)},remove:function(C,A){try{C.removeChild(getDom(A));return Number.MAX_VALUE}catch(B){return -1}},removeAt:function(C,B){var A=C.childNodes;if(B>=A.length){return null}return C.removeChild(A[B])},clear:function(C){var A=[];var B;while((B=C.firstChild)){A.push(C.removeChild(B))}return A}},Content:{get:function(A){return any(A.textContent,A.innerText)},add:function(C,B){if(!exists(B)){return 0}if(!isDom(B)){if(B.XElement){B=B.dom}else{if(isArray(B)||B.Enumerable){var A=0;each(B,function(D){A+=Dom.Content.add(C,D)});return A}else{B=document.createTextNode(str(B))}}}C.appendChild(B);return 1},set:function(B){var A=Dom.List.clear(B);iterate(arguments,function(C){if(exists(C)){Dom.Content.add(B,C)}},1);return A}},Style:{},getHead:function(){return obtain(Dom,"$head",function(){return document.getElementsByTagName("head")[0]})}};delayedBind(Dom,"createElementNS",function(){return document.createElementNS?function(A,C,B){return A.createElementNS(C,B)}:function(A,D,B){var C=B.split(":",2)[0];if(!includes(A.namespaces,function(E){return E.name==C&&E.urn==D})){A.namespaces.add(C,D)}return A.createElement(B)}});Dom.get=function(B,A){return B[A]};delayedBind(Dom,"set",function(A){return A.setAttributeNS?function(D,B,C){if(exists(C)){D.setAttributeNS(null,B,C)}else{D.removeAttributeNS(null,B)}return D}:function(D,B,C){D[B]=C;return D}});delayedBind(Dom.Style,"get",function(A){return A.defaultView?function(E,C){var D=E.style[C];if(!exists(D)){var B=A.defaultView.getComputedStyle(E,null);if(exists(B)){D=B[C]}}return D}:function(C,B){return C.style[B]}});Dom.Style.set=function(C,A,B){if(exists(B)){C.style[A]=B}else{C.style[A]=""}return C};type("XElement",["List"],{observeClick:function(A){return this.observeEvent("click",A)},observeDblClick:function(A){return this.observeEvent("dblclick",A)},observeChange:function(A){return this.observeEvent("change",A)},observeMouseWheel:function(A){},observeKeyPress:function(A){return this.observeEvent("keypress",function(C){var B=C.keyCode||C.which;return A(B)})},observeEvent:function(C,B){var A=this;return obtain(obtain(this,"eventObservers",construct(Object)),C,function(){var D=commands();A.dom["on"+C]=function(E){if(window.event){E=window.event}D(E)};return D}).attach(B)},observeEventEx:function(B,A){return Dom.Event.observe(this.dom,B,A)},dispatchEvent:function(A){return Dom.Event.dispatch(this.dom,A)},getters:{},setters:{},getAttribute:function(B){var A=this.getters[B];return exists(A)?A.call(this):Dom.get(this.dom,B)},setAttribute:function(A,B){var C=this.setters[A];if(exists(C)){return C.call(this,B)}Dom.set(this.dom,A,B);return this},attribute:function(B){var A=this;enumerate(B,function(E,C){if(C.charAt(0)=="$"){var D=C.substr(1);if(isFunction(A[D])){A[D](E)}else{A[D]=E}}else{A.setAttribute(C,E)}});return this},styleGetters:{},styleSetters:{},getStyle:function(B){var A=this.styleGetters[B];return exists(A)?A(this.dom):Dom.Style.get(this.dom,name)},setStyle:function(B,C){var D=this.styleSetters[B];if(exists(D)){var A=this;enumerate(D(C),function(F,E){Dom.Style.set(A.dom,E,F)})}else{Dom.Style.set(this.dom,B,C)}return this},style:function(B){var A=this;enumerate(B,function(D,C){A.setStyle(C,D)});return this},accessor:function(B){var A=this;return new Accessor(function(){return A.getAttribute(B)},function(C){return A.setAttribute(B,C)})},styleAccessor:function(B){var A=this;return new Accessor(function(){return A.getStyle(B)},function(C){return A.setStyle(B,C)})},getContent:function(){return Dom.Content.get(this.dom)},addContent:function(A){schedule(this.itemsUpdated);return Dom.Content.add(this.dom,A)},setContent:function(A){schedule(this.itemsUpdated);return Dom.Content.set(this.dom,A)},getTag:function(){return this.dom.tagName.toLowerCase()},inTree:function(){return exists(this.dom.offsetParent())},getParent:function(){return $E(this.dom.parentElement)},detach:function(){var A=this.getParent();if(exists(A)){A.remove(this)}},destroy:function(){delete this.dom.$element;delete this.dom},each:function(A){return Dom.List.each(this.dom,function(C,B){return A($E(C),B)})},length:function(){return Dom.List.length(this.dom)},item:function(A){return $E(Dom.List.item(this.dom,A))},append:function(A){schedule(this.itemsUpdated);return Dom.List.append(this.dom,A)},insert:function(B,A){schedule(this.itemsUpdated);return Dom.List.insert(this.dom,B,A)},remove:function(A){schedule(this.itemsUpdated);return Dom.List.remove(this.dom,A)},removeAt:function(A){schedule(this.itemsUpdated);return Dom.List.removeAt(this.dom,A)},move:function(B,A){schedule(this.itemsUpdated);return Dom.List.move(this.dom,B,A)},clear:function(){schedule(this.itemsUpdated);return Dom.List.clear(this.dom)}},function(C,B){var A=this;A.itemsUpdated=commands();if(isString(C)){C=document.createElement(C)}else{if(isArray(C)){C=Dom.createElementNS(document,C[0],C[1])}}A.dom=C;C.$element=A;XElement.elements.push(A);A.length=new Getter(curry(XElement.getLength,A));if(exists(B)){A.attribute(B)}iterate(arguments,function(D){A.addContent(D)},2)});XElement.prototype.setters.style=XElement.prototype.style;XElement.getLength=function(A){return Dom.List.length(A.dom)};XElement.elements=[];XElement.cleanNow=function(){var C=[];var A=document.body;var B=A.parentNode;iterate(XElement.elements,function(D){if(D.dom&&D.dom.offsetParent||D===A||D===B){C.push(D)}else{D.destroy()}});XElement.elements=C};XElement.clean=function(){schedule(XElement.cleanNow)};function $E(B){if(isString(B)){B=document.getElementById(B)}if(!exists(B)){return B}var A=B.$element;if(exists(A)){return A}return new Html(B)}type("Html",["XElement","WatchAccessor","CanGet"],{isField:function(){return exists(Html.isCheckField(this.dom))},isCheckField:function(){return Html.isCheckField(this.dom)},getters:merge(XElement.prototype.getters),setters:merge(XElement.prototype.setters),styleGetters:merge(XElement.prototype.styleGetters),styleSetters:merge(XElement.prototype.styleSetters),getStyleBase:XElement.prototype.getStyle,getStyle:function(A){var B=this.getStyleBase(A);return B=="auto"?null:B},get:function(){var A=Html.isCheckField(this.dom);if(!exists(A)){return Dom.Content.get(this.dom)}else{if(A){return this.dom.checked}else{return this.dom.value}}},set:function(C){var B=Html.isCheckField(this.dom);if(!exists(B)){return Dom.Content.set(this.dom,$A(arguments))}else{if(B){var A=this.dom.checked;if(A==!C){this.dom.checked=!A;if(exists(this.observers)){this.observers(!A)}}}else{this.dom.value=str(C)}}},observe:function(B){var D=Html.isCheckField(this.dom);if(!exists(D)){return }else{var A=this;var C=function(E){B(A.get())};if(!exists(this.observers)){this.observers=commands();var C=function(E){A.observers(A.get())};if(D){this.observeClick(C)}else{this.observeChange(C)}}return this.observers.attach(B)}},invokeObserver:function(A){return A(this.get())},notifyObservers:function(){if(this.observers){this.invokeObserver(this.observers)}},canGet:function(){return this.isField()}},Browser.IE?function(B,A){if(isString(B)){if(!empty(A.name)){B="<"+B+' name="'+A.name+'">';delete A.name}}this.XElement(B,A)}:function(B,A){this.XElement(B,A)});extend(Html,{toDimensions:function(A){return isNumber(A)?Math.round(A)+"px":A},isCheckField:function(A){switch(A.tagName.toLowerCase()){case"input":switch(A.type.toLowerCase()){case"checkbox":case"radio":return true;default:return false}case"select":case"textarea":return false;default:return null}},makeAttributes:function(B,A){var C;if(exists(B)){C=isString(B)?{className:B}:B;if(exists(A)){extend(C,A)}}else{C=exists(A)?A:{}}for(key in C){if(C[key]===undefined){delete C[key]}}return C},h:function(C,B,A){return new Html("h"+C,Html.makeAttributes(A),B)},input:function(B,A,C){return new Html("input",Html.makeAttributes(A,{type:B,value:C}))},edit:function(A,B){return new Html("input",Html.makeAttributes(A,{type:"text",value:B}))},checkbox:function(A,B){return new Html("input",Html.makeAttributes(A,{type:"checkbox",checked:B}))},radio:function(A,B){return new Html("input",Html.makeAttributes(A,{type:"radio",checked:B}))},email:function(A){return new Html("input",Html.makeAttributes(A,{type:"text",vcard_name:"vCard.Email"}))},password:function(A){return new Html("input",Html.makeAttributes(A,{type:"password",autocomplete:"on"}))},hidden:function(A){return new Html("div",Html.makeAttributes(A)).style({display:"none"})}});iterate(["a","div","span","p","ul","ol","li","table","caption","thead","tfoot","tbody","tr","th","td","strong","em","emp","pre","small","h1","h2","h3","h4","h5","h6","form","button","label","textarea","img","select","option","optgroup","object","param","embed","iframe","br"],function(A){Html[A]=function(B){return new Html(A,Html.makeAttributes(B),$A(arguments,1))}});Html.prototype.getters.enctype=function(){return this.dom.enctype};Html.prototype.setters.enctype=function(A){this.dom.enctype=A;if("encoding" in this.dom){this.dom.encoding=A}return this.dom};delayedBind(Html.prototype.styleGetters,"opacity",function(A){return Dom.Style.get(A,"opacity")===undefined?function(C){var B=C.filters.opacity;return exists(B)?(B.opacity/100):1}:function(C){var B=Dom.Style.get(C,"opacity");return exists(B)?parseFloat(B):1}});delayedBind(Html.prototype.styleSetters,"opacity",function(){return Browser.IE?function(A){return objectize("filter",(A==1||A==="")?"":("progid:DXImageTransform.Microsoft.Alpha(opacity="+Math.round(((A<0.00001)?0:A)*100)+")"))}:function(A){return objectize("opacity",(A==1||A==="")?"":(A<0.00001)?0:A)}});delayedBind(Html.prototype.styleGetters,"cssFloat",function(A){return Dom.Style.get(A,"cssFloat")===undefined?function(B){return Dom.Style.get(B,"styleFloat")}:function(B){return Dom.Style.get(B,"cssFloat")}});delayedBind(Html.prototype.styleSetters,"cssFloat",function(){return Browser.IE?function(A){return objectize("styleFloat",Html.toDimensions(A))}:function(A){return objectize("cssFloat",Html.toDimensions(A))}});iterate(["left","right","top","bottom","width","height","borderWidth","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","margin","marginTop","marginRight","marginBottom","marginLeft","border","borderTop","borderRight","borderBottom","borderLeft","lineHeight"],function(A){Html.prototype.styleSetters[A]=function(B){return objectize(A,Html.toDimensions(B))}});iterate(["margin","padding","border"],function(A){iterate(["Top","Right","Bottom","Left"],function(B){var C=A+B;Html.prototype.styleSetters[C]=function(D){return objectize(C,Html.toDimensions(D))}});Html.prototype.styleSetters[A]=function(B){if(isObject(B)){var C={};iterate(["Top","Right","Bottom","Left"],function(D){var E=D.toLowerCase();if(E in B){C[A+D]=B[E]}});return C}else{return objectize(A,Html.toDimensions(B))}}});Html.generateId=function(){return"_GID"+Html.generateId.current++};Html.generateId.current=1;Html.addScript=function(B){var A=document.createElement("script");A.src=B;A.type="text/javascript";document.getElementsByTagName("head")[0].appendChild(A)};Html.Target={New:"_blank"};function Color(){}Color.dark={};Color.light={};Color.white="#FFFFFF";Color.black="#000000";enumerate({yellow:["#fce94f","#edd400","#c4a000"],orange:["#fcaf3e","#f57900","#ce5c00"],brown:["#e9b96e","#c17d11","#8f5902"],green:["#8ae234","#73d216","#4e9a06"],blue:["#729fcf","#3465a4","#204a87"],violet:["#ad7fa8","#75507b","#5c3566"],red:["#ef2929","#cc0000","#a40000"],silver:["#eeeeec","#d3d7cf","#babdb6"],gray:["#888a85","#555753","#2e3436"]},function(A,B){Color.light[B]=A[0];Color[B]=A[1];Color.dark[B]=A[2]});var StyleSheet={disableAll:function(){iterate(document.styleSheets,function(A){A.disabled=true})},add:function(C){var A=StyleSheet.obtain();var B=StyleSheet.getRules(A);enumerate(C,function(F,E){if(A.insertRule){var D=B.length;A.insertRule(E+" "+StyleSheet.buildRule(F),D)}else{iterate(E.split(","),function(G){var H=B.length;A.addRule(G,StyleSheet.buildRule(F))})}})},create:function(B){var A;if(document.createStyleSheet){A=document.createStyleSheet()}else{A=document.createElement("style");A.type="text/css";Dom.getHead().appendChild(A);A=A.sheet}if(exists(B)){A.media=B}return A},obtain:function(A){return get(A,function(){return obtain(StyleSheet,"$sheet",function(){StyleSheet.disableAll();return StyleSheet.create()})})},getRules:function(A){return exists(A.cssRules)?A.cssRules:A.rules},buildRule:function(A){var B={};enumerate(A,function(D,C){var E=Html.prototype.styleSetters[C];if(exists(E)){enumerate(E(D),function(G,F){B[F]=G})}else{B[C]=D}});return"{"+enumerate(B,writer(function(D,C){return camelToDash(C)+":"+D+";"}))+"}"}};extend(Html.prototype,{visible:function(){var A=this;return new Accessor(function(){return A.style("display")!="none"},function(B){return A.style("display",B?null:"none")})},scroll:function(A,C){var B={overflow:"auto",height:A};if(exists(C)){B.width=C}return this.style(B)},show:function(){return this.style({display:null,visibility:"visible"})},hide:function(){return this.style({display:null,visibility:"hidden"})},disable:function(){return this.setAttribute("disabled","disabled")},enable:function(){return this.setAttribute("disabled",null)},collapse:function(){return this.style({display:null,visibility:"hidden"})},hide:function(){return this.style({display:null,visibility:"hidden"})}});iterate(["padding","margin","border"],function(A){Html.prototype[A]=function(){var B={};switch(arguments.length){case 1:B[A]=arguments[0];break;case 2:B[A+"Top"]=arguments[0];B[A+"Right"]=arguments[1];B[A+"Bottom"]=arguments[0];B[A+"Left"]=arguments[1];break;case 4:B[A+"Top"]=arguments[0];B[A+"Right"]=arguments[1];B[A+"Bottom"]=arguments[2];B[A+"Left"]=arguments[3];break}return this.style(B)}});enumerate({relative:{set:{position:"relative"}},inline:{set:{display:"inline"}},block:{set:{display:"block"}},opacity:{args:["opacity"]},size:{args:["width","height","padding","margin","border"]},floating:{args:["cssFloat","width","height"],set:{position:"relative"}},fill:{args:["padding","margin","border"],set:{position:"absolute",width:"100%",height:"100%"}},place:{args:["top","left","bottom","right","padding","margin","border"],set:{position:"absolute"}},topLeft:{args:["left","top","width","height","padding","margin","border"],set:{position:"absolute",bottom:null,right:null}},topRight:{args:["right","top","width","height","padding","margin","border"],set:{position:"absolute",bottom:null,left:null}},bottomLeft:{args:["left","bottom","width","height","padding","margin","border"],set:{position:"absolute",top:null,right:null}},bottomRight:{args:["right","bottom","width","height","padding","margin","border"],set:{position:"absolute",top:null,left:null}},border:{args:["borderWidth","borderStyle","borderColor"]},color:{args:["color"]},background:{args:["background"]},lineHeight:{args:["lineHeight"]},textAlign:{args:["textAlign","verticalAlign"]},verticalAlign:{args:["verticalAlign"]}},function(B,A){Html.prototype[A]=function(){var C=getObject(B.set);iterate(arguments,function(D,E){C[B.args[E]]=D});invoke(B.compute,C);return this.style(C)}});internal(function(){function B(D){if(D.left<0){if(D.right<0){D.display="none"}else{D.width=-(D.left+D.right);D.left=null}}else{if(D.right<0){D.width=-(D.left+D.right);D.right=null}}}function A(D){if(D.top<0){if(D.bottom<0){D.display="none"}else{D.height=-(D.top+D.bottom);D.top=null}}else{if(D.bottom<0){D.height=-(D.top+D.bottom);D.bottom=null}}}function C(D){return exists(D)?D?"auto":"hidden":null}extend(Html.prototype,{wrap:function(D){return this.style({whiteSpace:exists(D)?D?"normal":"nowrap":null})},scrolling:function(){var D={};switch(arguments.length){case 0:D.overflow=null;break;case 1:D.overflow=C(arguments[0]);break;case 2:D.overflowX=C(arguments[0]);D.overflowY=C(arguments[1]);break}return this.style(D)},locateX:function(F,D){var E={left:F,right:D,width:null,position:"absolute"};B(E);return this.style(E)},locateY:function(F,D){var E={top:F,bottom:D,height:null,position:"absolute"};A(E);return this.style(E)},locate:function(H,G,D,E){var F={left:G,right:E,width:null,top:H,bottom:D,height:null,position:"absolute"};B(F);A(F);return this.style(F)},messageBox:function(E,D){return this.style({left:"50%",top:"40%",marginLeft:-E/2,marginTop:-D/2,width:E,height:D,display:"block",position:"fixed"})},fixedBox:function(H,G,D,E){var F={left:G,right:E,width:null,top:H,bottom:D,height:null,display:"block",position:"fixed"};B(F);A(F);return this.style(F)}})});extend(Html.prototype,{layout:function(C){var B=this;invoke(B.removeLayout);if(isString(C)){C=Layout[C]}if(exists(C)){var A=function(){schedule(function(){C(B)})};B.removeLayout=B.itemsUpdated.attach(A);A()}return B}});var Layout={row:function(){var A=$A(arguments);return function(B){var C=0;B.each(function(E,D){var F=A[D];if(!exists(C)){E.close()}else{if(exists(F)){E.locate(0,C,0,-F)}else{E.locate(0,C,0,0)}}C=F})}},rows:function(A,B){return function(D){var C=B;D.each(function(E){E.style({position:"absolute",display:"block",left:0,right:0,margin:0,padding:0,border:"0",width:null,top:C,height:A});C+=A+B});D.style({height:C,display:"block",position:"relative"})}}};extend(Html.prototype,{lookupField:function(){if(this.isField()){return this}return lookup(this,function(A){return A.lookupField()})}});type("DrawingGroup",[],{transform:watchSetter},function(){this.transform=watchSetter()});type("Drawing",[],{stroke:watchSetter,fill:watchSetter},function(){this.stroke=watchSetter();this.fill=watchSetter()});type("SvgGroup",["DrawingGroup","XElement"],{setTransform:function(A){var B=exists(A)?"translate("+any(A.x,0)+","+any(A.y,0)+"),rotate("+any(A.angle,0)+")":"";this.attribute({transform:B})}},function(B,A){this.XElement(Svg.tag(B),A);this.DrawingGroup();this.transform.observe(apply(this.setTransform,this))});type("Svg",["Drawing","SvgGroup"],{setStroke:function(A){this.attribute(exists(A)?{stroke:any(A.color,"black"),"stroke-width":any(A.width,1),"stroke-opacity":any(A.opacity,1),"stroke-linecap":any(A.cap,"butt"),"stroke-linejoin":any(A.join,"miter"),"stroke-dasharray":Svg.internal.computeDashArray(A.dash,A.width)}:{stroke:"none","stroke-width":"0","stroke-opacity":"1","stroke-linecap":"butt","stroke-linejoin":"miter","stroke-dasharray":"0"})},setFill:function(F){var B={fill:"none","fill-opacity":1};var C=null;if(exists(F)){if(empty(F.gradient)||F.gradient=="none"){if(exists(F.opacity)){if(isArray(F.opacity)){B["fill-opacity"]=F.opacity[0]}else{B["fill-opacity"]=F.opacity}}if(exists(F.color)){if(isArray(F.opacity)){B.fill=F.color[0]}else{B.fill=F.color}}}else{B.fill="url(#"+this.fillId+")";var E=[{offset:"0%"},{offset:"100%"}];if(!exists(F.opacity)){E[0]["stop-opacity"]=1;E[1]["stop-opacity"]=1}else{if(isArray(F.opacity)){E[0]["stop-opacity"]=F.opacity[0];E[1]["stop-opacity"]=F.opacity[1]}else{E[0]["stop-opacity"]=F.opacity;E[1]["stop-opacity"]=F.opacity}}if(!exists(F.color)){E[0]["stop-color"]="black";E[1]["stop-color"]="black"}else{if(isArray(F.color)){E[0]["stop-color"]=F.color[0];E[1]["stop-color"]=F.color[1]}else{E[0]["stop-color"]=F.color;E[1]["stop-color"]=F.color}}var D=translate(E,function(G){return new XElement(Svg.tag("stop"),G)});if(F.gradient=="linear"){C=$B(new XElement(Svg.tag("linearGradient"),{id:this.fillId,x1:"0%",y1:"0%",x2:"0%",y2:"100%"}),D)}else{switch(this.getTag()){case"svg:ellipse":var A=Point.fromArray(F.position).placeToCircle(0.5,0.5,0.48);C=$B(new XElement(Svg.tag("radialGradient"),{id:this.fillId,cx:"50%",cy:"50%",r:"50%",fx:A.x*100+"%",fy:A.y*100+"%"}),D);break;default:C=$B(new XElement(Svg.tag("radialGradient"),{id:this.fillId,cx:"50%",cy:"50%",r:(50*Math.sqrt(2))+"%",fx:F.position[0]*100+"%",fy:F.position[1]*100+"%"}),D);break}}}}this.fillElement.set(C);this.attribute(B)}},function(B,A){this.SvgGroup(B,A);this.Drawing();this.fillElement=new WatchValue();this.fillId=Html.generateId();this.setStroke(null);this.setFill(null);this.stroke.observe(apply(this.setStroke,this));this.fill.observe(apply(this.setFill,this))});Svg.tag=function(A){return["http://www.w3.org/2000/svg","svg:"+A]};Svg.internal={computeDashArray:function(B,A){return replaceEmpty(iterate(getArray(B),stacker(function(C){return C*A})).join(","),"0")},parsePath:function(E,B){var G=[];var C=0;if(E.List){E=E.allItems()}while(C<E.length){if(isArray(E[C])){var D=E[C++];var A,F;if(C<=E.length-2){A=E[C++];F=E[C++]}else{A=E[0];F=E[1]}switch(D.length){case 0:throw"Arc not yet implemented.";case 2:G.push("Q",D[0],D[1],A,F);break;case 4:G.push("C",D[0],D[1],D[2],D[3],A,F);break;default:throw"Unsupported control point specification"}}else{G.push(C==0?"M":"L",E[C++],E[C++])}}if(B){G.push("Z")}return G.join(" ")}};Svg.canvas=function(C,F,D,B,E){var A=new XElement(Svg.tag("defs"));processListableAccessor(E,"fillElement",function(G){A.append(G)},function(G){G.detach()});return $B(new Html(Svg.tag("svg"),{version:"1.1",width:D,height:B}),[A,$B(new SvgGroup("g").transform({x:-C,y:-F}),E)])};Svg.group=function(A){return $B(new SvgGroup("g"),A)};Svg.shape=function(C,A){var B=Svg.internal.parsePath(C,A);return new Svg("path",{d:B})};var Vml={scale:100,units:0};type("VmlGroup",["DrawingGroup","Html"],{setTransform:function(A){var B={};if(exists(A)){B.left=Vml.internal.getScalar(any(A.x,0)-1)+Vml.units;B.top=Vml.internal.getScalar(any(A.y,0)-1)+Vml.units;B.rotation=Math.round(any(A.angle,0))}else{B.left=Vml.internal.getScalar(-1)+Vml.units;B.top=Vml.internal.getScalar(-1)+Vml.units;B.rotation=0}this.style(B)}},function(B,A){Vml.internal.initialize();this.Html(Vml.tag(B),A);this.DrawingGroup();this.setTransform(null);this.transform.observe(apply(this.setTransform,this))});type("VmlShape",["Drawing","VmlGroup"],{setStroke:function(B){var A=this;obtain(this,"strokeElement",function(){var C=new XElement(Vml.tag("stroke"));A.append(C);return C}).attribute(exists(B)?{on:"true",color:B.color,weight:any(B.width,1)+"px",opacity:any(B.opacity,1),endcap:Vml.internal.lineCapToEndcap(B.cap),joinstyle:any(B.join,"miter"),dashstyle:Vml.internal.computeDashArray(B.dash)}:{on:"false"})},setFill:function(C){var B={};if(exists(C)){B.on="true";if(!exists(C.opacity)){B.opacity=1;B["o:opacity2"]=1}else{if(isArray(C.opacity)){B.opacity=C.opacity[1];B["o:opacity2"]=C.opacity[0]}else{B.opacity=C.opacity;B["o:opacity2"]=C.opacity}}if(!exists(C.color)){B.color="black";B.color2="black"}else{if(isArray(C.color)){B.color=C.color[1];B.color2=C.color[0]}else{B.color=C.color;B.color2=C.color}}if(empty(C.gradient)||C.gradient=="none"){B.type="solid"}else{if(C.gradient=="linear"){B.type="gradient";B.angle=C.angle;B.method="none"}else{switch(this.getTag()){case"v:oval":B.type="gradientradial";B.focusposition=Vml.internal.computeFocus(Point.fromArray(C.position).placeToCircle(0.5,0.5,0.48).toArray());B.focussize="0,0";B.method="none";break;default:B.type="gradientradial";B.focusposition=Vml.internal.computeFocus(C.position);B.focussize="0,0";B.method="none";break}}}}else{B.on="false"}var A=this;obtain(this,"fillElement",function(){var D=new XElement(Vml.tag("fill"));A.append(D);return D}).attribute(B)}},function(B,A){this.VmlGroup(B,A);this.Drawing();this.setStroke(null);this.setFill(null);this.stroke.observe(apply(this.setStroke,this));this.fill.observe(apply(this.setFill,this))});Vml.tag=function(A){return["urn:schemas-microsoft-com:vml","v:"+A]};Vml.tagOffice=function(A){return["urn:schemas-microsoft-com:office:office","o:"+A]};Vml.internal={initialize:function(){obtain(Vml.internal,"$initialized",function(){StyleSheet.add({"v\\:*":{behavior:"url(#default#VML)"},"o\\:*":{behavior:"url(#default#VML)"}});return true})},lineCapToEndcap:function(A){return(empty(A)||A=="butt")?"flat":A},computeFocus:function(A){return !exists(A)?"0,0":translate(A,function(B){return(B*100)+"%"}).join(",")},getScalar:function(A){return Math.round(A*Vml.scale)},getPoint:function(A,B){return Vml.internal.getScalar(A)+","+Vml.internal.getScalar(B)},computeDashArray:function(A){return getArray(A).join(" ")},computeColors:function(A){return translate(A,function(C,B){return(B*100)+"% "+C}).join(",")},parsePath:function(F,B){var H=[];var D=new Point(Number.POSITIVE_INFINITY);var A=new Point(Number.NEGATIVE_INFINITY);if(F.List){F=F.allItems()}function G(I,J){I=Vml.internal.getScalar(I);J=Vml.internal.getScalar(J);D.setMinimum(I,J);A.setMaximum(I,J);H.push(I,J)}var C=0;while(C<F.length){if(isArray(F[C])){var E=F[C++];switch(E.length){case 0:throw"Arc not yet implemented.";case 2:H.push("QB");G(E[0],E[1]);break;case 4:H.push("C");G(E[0],E[1]);G(E[2],E[3]);break;default:throw"Unsupported control point specification"}}else{H.push(C==0?"M":"L");G(F[C++],F[C++])}}if(B){H.push("X")}H.push("E");return{path:H.join(" "),width:A.x-D.x+1,height:A.y-D.y+1}}};Vml.canvas=function(B,E,C,A,D){return $B(new Html(Vml.tag("group"),{style:{position:"absolute",left:-B,top:-E,width:2,height:2},coordorigin:Vml.internal.getPoint(0,0),coordsize:Vml.internal.getPoint(2,2)}),D)};Vml.group=function(A){return $B(new VmlGroup("group",{style:{position:"absolute",width:Vml.internal.getScalar(2)+Vml.units,height:Vml.internal.getScalar(2)+Vml.units},coordorigin:Vml.internal.getPoint(-1,-1),coordsize:Vml.internal.getPoint(2,2)}),A)};Vml.shape=function(E,C){var B=Vml.internal.parsePath(E,C);var D=new XElement(Vml.tag("path"),{v:B.path});var A=new VmlShape("shape",{style:{position:"absolute",width:Vml.internal.getScalar(2)+Vml.units,height:Vml.internal.getScalar(2)+Vml.units},coordorigin:Vml.internal.getPoint(-1,-1),coordsize:Vml.internal.getPoint(2,2)});A.append(D);return A};var Draw=Browser.IE?Vml:Svg;Draw.rect=function(B,D,C,A){return Draw.shape([B,D,B+C,D,B+C,D+A,B,D+A],true)};Draw.rounded=function(B,F,C,A,E,D){E=Math.min(E,C/2);D=Math.min(D,A/2);return Draw.shape([B+E,F,B+C-E,F,[B+C,F],B+C,F+D,B+C,F+A-D,[B+C,F+A],B+C-E,F+A,B+E,F+A,[B,F+A],B,F+A-D,B,F+D,[B,F]],true)};Draw.potato=function(B,D,C,A){return Draw.rounded(B,D,C,A,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)};Draw.polygon=function(A){return Draw.shape(bind.listEx(new WatchList(),A,function(B){return[B.x,B.y]},0,2))};Draw.Stroke=function(A,B){this.color=A;this.width=B};Draw.Fill=function(A){this.color=A};Draw.Join=new NamedEnum("miter","round","bevel");Draw.Cap=new NamedEnum("square","round","butt");var Widget={view:function(E,B){var D=new WidgetContext();var C=(this instanceof WidgetContext)?this:null;if(exists(C)){extend(D,C);D.parent=C;if(isFunction(D.nextLevel)){D.nextLevel(D)}}if(exists(B)){extend(D,B)}var A=new WatchList();mixinInstance(D,A,WatchListable);D.navigate=function(F){bind.setter(A,F,function(G){if(!isFunction(G)){G=D.getTarget(G)}return bind.internal.element(A,G(D))});return A};if(exists(E)){D.navigate(E)}return D},navigator:function(A){return curry(this.navigate,A)},getTarget:function(A){throw new Exception("Cannot lookup target.",{target:A})},template:function(C,A){var B=this;return function(E){var F={};if(exists(A)){extend(F,A)}var D;if(exists(E)&&E.WatchGetter){if("key" in E){F.key=E.key}F.value=E.get();E.observe(function(G){D.value=G;D.navigate(C)})}else{F.value=E}D=B.view(C,F);return D}},presenter:function(B,C,A){return this.template(C,A)(B)},repeater:function(B,C,A){return $L(B,this.template(C,A))}};function WidgetContext(A){return(A===window)?new WidgetContext():A}WidgetContext.prototype=Widget;function WidgetBuilder(C,B){var A=function(E,F){var D=$A(arguments);if(D.length>=2){D[1]=merge(D[1],B)}return C.apply(this,D)};A.customize=function(D){return WidgetBuilder(C,merge(B,D))};extend(A,WidgetBuilder);return A}function WidgetDocument(A,D,B){var E=0;var F=new WatchObject();var C=new WatchList();WidgetDocument.attachHidden=function(H){var G=++E;F.set(G,H);return function(){F.set(G,null)}};WidgetDocument.setOverlay=function(G){$B(C,G)};window.onload=function(){invoke(B);var G=Widget.block(C).fixedBox(0,0,0,0);$B(G.styleAccessor("display"),C.length,function(H){return H==0?"none":"block"});$B($E(window.document.body),[Widget.block($L(F,function(H){return H.get()})),Widget.block(Widget.view(A,D)),G])}}function WidgetPage(A,B){WidgetPage.pages[WidgetPage.getKey(A)]=function(C){C.page=A;return B(C)}}WidgetPage.pages={};WidgetPage.getKey=function(A){return"/"+A.join("/")};Widget.getTarget=function(A){if(empty(A)){throw"Empty target."}return function(C){if(exists(C.parent)){A=concat(C.parent.page,A)}var B=WidgetPage.pages[WidgetPage.getKey(A)];if(!isFunction(B)){throw new Exception("Page not found.",{page:A})}return B(C)}};WidgetBuilder.resize=function(B,A){return this.customize({style:{width:B,height:A}})};WidgetBuilder.place=function(D,C,B,A){return this.customize({style:{position:"absolute",left:D,top:C,right:B,bottom:A}})};function StyledItem(A,B){this.attributes=A;this.content=B}Widget.t=function(A){return A};Widget.option=function(B){var A=Html.option();if(B.WatchPair){$B(A,B);$B(A.accessor("value"),B.key);$B(A.accessor("selected"),B.selected);$B(A.accessor("disabled"),B.disabled)}else{A.setAttribute("value",B);A.set(B)}return A};Widget.link=function(D,C){var B;if(isFunction(D)){B=Html.a({href:"#"});B.observeClick(function(){D();return false})}else{var A={};if(isString(D)){A.href=D}else{A.href=D.url;setExisting(A,"rel",D.rel);setExisting(A,"rev",D.rev);setExisting(A,"target",D.target)}B=Html.a(A)}return $B(B,C)};Widget.button=function(C,B){var A=Html.button();A.observeClick(function(){C();return false});return $B(A,B)};Widget.clickable=function(B,A){invoke(A.stopClickable);A.stopClickable=A.observeClick(function(){B();return false});if(A.getTag()=="a"){A.setAttribute("href","#")}return B.caption};Widget.image=function(A,B){return Html.img({alt:B,src:A})};Widget.object=Browser.IE?function(C,D,B,A){return Html.object({classid:C.classid,codebase:C.codebase,width:B,height:A},$A(D,0,function(F,E){return Html.param({name:E,value:F})}))}:function(C,D,B,A){return Html.object({type:C.name,data:D.src,width:B,height:A},Html.param({name:"pluginurl",value:C.url}),$A(D,0,function(F,E){return Html.param({name:E,value:F})}))};Widget.edit=WidgetBuilder(function(C,A,B){return $B(Html.div(A),$B(Html.div().place(0,0,2,2,0,0),$B(any(B,Html.edit)().fill(0,0).border(1,"solid","#808080"),C)))});Widget.memo=function(A){return $B(Html.div(),$B(Html.textarea().fill(0,0).border(1,"solid","#808080"),A))};Widget.label=function(B,A){var C=WidgetContext(this);A=C.getCaption(A);var B=B.lookupField();var D=B.getAttribute("id");if(empty(D)){D=Html.generateId();B.setAttribute("id",D)}A.attributes.htmlFor=D;return $B(Html.label(A.attributes),$B(Html.div().place(1,1,1,1,0,0),A.content))};Widget.getCaption=function(A){if(A instanceof StyledItem){return A}var E=str(A);var D=E.split("_",2);if(D.length<2){return new StyledItem({},D.join(""))}if(D[1]==""){return new StyledItem({},D[0])}var B=D[1].slice(0,1);var C=D[1].slice(1);if(D[0]==""){return new StyledItem({accessKey:B.toLowerCase()},[Html.span("access-key",B),C])}return new StyledItem({accessKey:B.toLowerCase()},[D[0],Html.span("access-key",B),C])};Widget.textAlign=function(A,B){return Widget.block(A).textAlign(B)};Widget.align=Browser.IE?function(C,A,B){return Widget.block(Widget.block(Widget.table({tableAttributes:{style:{padding:0,margin:0,borderCollapse:"collapse",tableLayout:"fixed"}},body:[{rowAttributes:{padding:0,margin:0,borderCollapse:"collapse"},cells:[new StyledItem({style:{padding:0,margin:0,borderCollapse:"collapse",textAlign:A,verticalAlign:B,textOverflow:"ellipsis"}},C)]}]}).fill()).fill())}:function(C,A,B){return $B(Html.div({style:{overflow:"hidden"}}),$B(Html.div({style:{display:"table",position:"static",width:"100%",height:"100%",overflow:"hidden"}}),$B(Html.div({style:{display:"table-cell",position:"static",textAlign:A,verticalAlign:B,overflow:"hidden",textOverflow:"ellipsis"}}),C)))};function WidgetControl(B,D,A){var C=function(E){return bind.element(B(A),E,D)};C.customize=function(E){return WidgetControl(B,D,merge(A,E))};extend(C,WidgetBuilder);return C}Widget.text=WidgetControl(Html.span);Widget.inline=WidgetControl(Html.span,Widget.text);Widget.line=WidgetControl(Html.p);Widget.inlineBlock=WidgetControl(function(){return Html.span({display:"inline-block"})});Widget.block=WidgetControl(Html.div);Widget.wrap=WidgetControl(Html.p,Widget.text);Widget.lines=WidgetControl(Html.div,Widget.line);Widget.stack=WidgetControl(Html.div,Widget.block);Widget.listItem=WidgetControl(Html.li);Widget.unordered=WidgetControl(Html.ul,Widget.listItem);Widget.ordered=WidgetControl(Html.ol,Widget.listItem);Widget.select=WidgetControl(Html.select,Widget.option);Widget.list=Widget.unordered;Widget.header6=WidgetControl(Html.h6);Widget.header6.next=Widget.header6;times(5,function(A){var B=5-A;Widget["header"+B]=extend(WidgetControl(Html["h"+B]),{next:Widget["header"+(B+1)]})});Widget.header=Widget.header1;Widget.strong=WidgetControl(Html.strong);Widget.em=WidgetControl(Html.em);Widget.small=WidgetControl(Html.small);Widget.hidden=WidgetControl(Html.hidden);function WidgetEditor(B,A){return function(E){var D=isFunction(B)?B():B;var C;if(!exists(A)){C=A}else{if(isFunction(A)){C=function(F){return A(F,E)}}else{C={toTarget:function(F){return A.toTarget(F,E)},toSource:function(F){return A.toSource(F,E)}}}}return bind.accessor(D,E,C)}}Widget.timeTemplate={toTarget:formatTime,toSource:function(B,A){var C=copyDate(A.get());setTime(C,parseTime(B));return C}};Widget.dateTemplate={toTarget:formatDate,toSource:function(C,B){var A=copyDate(B.get());setDate(A,parseDate(C));return A}};Widget.textEditor=WidgetEditor(Html.edit);Widget.timeEditor=WidgetEditor(Html.edit,Widget.timeTemplate);Widget.dateEditor=WidgetEditor(Html.edit,Widget.dateTemplate);Widget.multiLineEditor=WidgetEditor(Html.textarea);function WidgetTable(C,D,B){if(D){D.isHeader=true;C.head=$L([D])}if(B){C.foot=$L([B])}var A=new List();A.appendExisting(WidgetTable.rows(Html.thead(C.headAttributes),C.head));A.appendExisting(WidgetTable.rows(Html.tfoot(C.footAttributes),C.foot));A.appendExisting(WidgetTable.rows(Html.tbody(C.bodyAttributes),any(C.body,C)));return $B(Html.table(C.tableAttributes),A)}WidgetTable.cell=function(A,C,B){constructor=B?Html.th:Html.td;if(exists(A)){if(A.XElement){switch(A.getTag()){case"td":case"th":return A;default:return $B(constructor(),A)}}else{if(A.constructor===StyledItem){return $B(constructor(A.attributes),A.content)}}}else{return constructor()}};WidgetTable.headerCell=function(A,B){return WidgetTable.cell(A,B,true)};WidgetTable.row=function(C){var B=WidgetContext(this);if(C.XElement&&C.getTag()=="tr"){return C}else{var A=C.isHeader?WidgetTable.headerCell:WidgetTable.cell;return $B(Html.tr(C.rowAttributes),any(C.cells,C),A)}};WidgetTable.rows=function(A,B){if(B){return $B(A,B,WidgetTable.row)}};Widget.table=WidgetTable;function Field(B,A,C){this.name=B;this.caption=A;this.editor=C}Widget.field=function(D,A,B){var C=WidgetContext(this);B=any(B,C.textEditor);return C.labelled(B(D),A)};Widget.form=function(C,A){var B=WidgetContext(this);return B.block([B.table($L(A.fields,function(D){return B.field(C[D.name],D.caption,D.editor)})),B.button(command(A.save,B.t("Save"))),B.button(command(A.cancel,B.t("Cancel")))])};Widget.editableContainer=Widget.text;type("WidgetEditableContext",["Switch"],{},function(){this.Switch("view","edit",["save","view"]);this.view()});function WidgetEditable(A,B){return function(G,D){var F=WidgetContext(this);if(!exists(D)){D=new WidgetEditableContext()}var I=F.editableContainer();var J=null;var E=null;var H={view:function(K){if(exists(E)){invoke(E.stop)}J=A(I,G,function(){D.edit();E.activate()})},edit:function(K){invoke(J);E=B(I,G)},save:function(K){if(exists(E)){invoke(E.save)}}};var C=objectInvoker(H);D.observe(C);D.invokeObserver(C);return I}}WidgetEditable.getTemplatedTextView=function(A){return function(D,C,B){$B(D,C,A);return function(){bind.detach(D)}}};WidgetEditable.textView=WidgetEditable.getTemplatedTextView(null);WidgetEditable.getSelectViewTemplate=function(A){if(isArrayOrListable(A)){return null}return splitter(A)};WidgetEditable.getClickableView=function(A){return function(D,C,B){return sequence(D.observeClick(B),A(D,C))}};WidgetEditable.textViewClickable=WidgetEditable.getClickableView(WidgetEditable.textView);WidgetEditable.getFieldEditor=function(A){return function(E,C){var D=A();var B=getAccessorDeep(C);D.set(B.get());$B(E,D);return{activate:function(){if(exists(D.dom.select)){D.dom.select()}else{D.dom.focus()}},save:function(){B.set(D.get())},stop:function(){bind.detach(E)}}}};WidgetEditable.textEdit=WidgetEditable.getFieldEditor(Html.edit);WidgetEditable.getSelectEdit=function(A){return WidgetEditable.getFieldEditor(function(){return Widget.select(A)})};Widget.textEditable=WidgetEditable(WidgetEditable.textView,WidgetEditable.textEdit);Widget.textEditableClickable=WidgetEditable(WidgetEditable.textViewClickable,WidgetEditable.textEdit);Widget.selectEditable=function(A,C,B){return WidgetEditable(WidgetEditable.getTemplatedTextView(WidgetEditable.getSelectViewTemplate(A)),WidgetEditable.getSelectEdit(A))(C,B)};Widget.selectEditableClickable=function(A,C,B){return WidgetEditable(WidgetEditable.getClickableView(WidgetEditable.getTemplatedTextView(WidgetEditable.getSelectViewTemplate(A))),WidgetEditable.getSelectEdit(A))(C,B)};Widget.menu=function(A){return Widget.list($L(A,Widget.link))};function Column(B,A,C){this.name=B;this.caption=A;this.editable=C}Widget.grid=function(F,C){var E=WidgetContext(this);var D=null;function G(I){if(D==I){return }if(exists(D)&&D.get()=="edit"){D.save()}D=I}var H=Html.tr({},Html.th());bind.listEx(H,C.columns,function(I,J){return[$B(Html.th(),I.caption)]},1);var B=$B(Html.thead(),H);var A=bind.listEx(Html.tbody(),$L(F),function(K,M){var J=new WidgetEditableContext();var N=Html.tr();N.set($B(Html.th({rowSpan:2}),K.key));bind.listEx(N,C.columns,function(O){var P=$V(K.value,O.name);if(exists(O.editable)){P=O.editable.call(E,P,J)}return[$B(Html.td(),P)]},1);var I=Html.td();var L=$B(Html.tr(),I);$B(I.accessor("colSpan"),C.columns.length);J.observe(objectInvoker({view:function(){I.clear()},edit:function(){G(J);I.set(Widget.button(command(J.save,"Save")),Widget.button(command(J.view,"Cancel")),Widget.button(command(function(){F.set(K.key.get(),null)},"Delete")))}}));return[N,L]},0,2);return $B(Html.table(),[B,A])};function MessageBox(F,A,B,C){var G=function(){E();WidgetDocument.setOverlay([]);C()};var D=Widget.block().fixedBox(0,0,0,0).background(Color.black).opacity(0.5);var E=D.observeClick(G);WidgetDocument.setOverlay([D,Widget.block(Widget.view(B,{close:G})).messageBox(F,A)])}function SHA1(J){function I(C,B){var A=(C<<B)|(C>>>(32-B));return A}function V(D){var C="";var A;var E;var B;for(A=0;A<=6;A+=2){E=(D>>>(A*4+4))&15;B=(D>>>(A*4))&15;C+=E.toString(16)+B.toString(16)}return C}function Y(D){var C="";var B;var A;for(B=7;B>=0;B--){A=(D>>>(B*4))&15;C+=A.toString(16)}return C}function G(B){B=B.replace(/\r\n/g,"\n");var A="";for(var D=0;D<B.length;D++){var C=B.charCodeAt(D);if(C<128){A+=String.fromCharCode(C)}else{if((C>127)&&(C<2048)){A+=String.fromCharCode((C>>6)|192);A+=String.fromCharCode((C&63)|128)}else{A+=String.fromCharCode((C>>12)|224);A+=String.fromCharCode(((C>>6)&63)|128);A+=String.fromCharCode((C&63)|128)}}}return A}var M;var a,Z;var H=new Array(80);var Q=1732584193;var O=4023233417;var N=2562383102;var L=271733878;var K=3285377520;var X,U,T,S,R;var b;J=G(J);var F=J.length;var P=new Array();for(a=0;a<F-3;a+=4){Z=J.charCodeAt(a)<<24|J.charCodeAt(a+1)<<16|J.charCodeAt(a+2)<<8|J.charCodeAt(a+3);P.push(Z)}switch(F%4){case 0:a=2147483648;break;case 1:a=J.charCodeAt(F-1)<<24|8388608;break;case 2:a=J.charCodeAt(F-2)<<24|J.charCodeAt(F-1)<<16|32768;break;case 3:a=J.charCodeAt(F-3)<<24|J.charCodeAt(F-2)<<16|J.charCodeAt(F-1)<<8|128;break}P.push(a);while((P.length%16)!=14){P.push(0)}P.push(F>>>29);P.push((F<<3)&4294967295);for(M=0;M<P.length;M+=16){for(a=0;a<16;a++){H[a]=P[M+a]}for(a=16;a<=79;a++){H[a]=I(H[a-3]^H[a-8]^H[a-14]^H[a-16],1)}X=Q;U=O;T=N;S=L;R=K;for(a=0;a<=19;a++){b=(I(X,5)+((U&T)|(~U&S))+R+H[a]+1518500249)&4294967295;R=S;S=T;T=I(U,30);U=X;X=b}for(a=20;a<=39;a++){b=(I(X,5)+(U^T^S)+R+H[a]+1859775393)&4294967295;R=S;S=T;T=I(U,30);U=X;X=b}for(a=40;a<=59;a++){b=(I(X,5)+((U&T)|(U&S)|(T&S))+R+H[a]+2400959708)&4294967295;R=S;S=T;T=I(U,30);U=X;X=b}for(a=60;a<=79;a++){b=(I(X,5)+(U^T^S)+R+H[a]+3395469782)&4294967295;R=S;S=T;T=I(U,30);U=X;X=b}Q=(Q+X)&4294967295;O=(O+U)&4294967295;N=(N+T)&4294967295;L=(L+S)&4294967295;K=(K+R)&4294967295}var b=Y(Q)+Y(O)+Y(N)+Y(L)+Y(K);return b.toLowerCase()}var SID={Root:"100",Link:"101",Label:"102",X:"0"};function ServiceRef(B,A){this.ref=B;this.key=A}ServiceRef.prototype={setKey:function(A){this.key=A;return this}};function Service(E){this.rpc=curry(jsonRpc,E);var F=[];var D=0;var B=this;var A=commands();var C=function(){if(exists(B.abort)){B.scheduled=true;return }var G={session:SessionId,number:(D++).toString(),email:B.email,requests:F};F=[];var H=A;A=commands();G.code=SHA1(B.code+SessionId+G.number);obtain(B,"clientInfoSent",function(){G.client=clientInfo;return true});B.abort=B.rpc("Request",G,function(I,J){delete B.abort;if(B.scheduled){delete B.scheduled;schedule(C)}if(exists(J)){throw J}H(I)})};this.addRequest=function(I,H){var G=F.length;F.push(I);if(exists(H)){A.attach(function(J){H(J.responses[G])})}schedule(C);return new ServiceRef(G.toString(),"id")};this.validateUser=function(G){A.attach(function(H){G(H.user)});schedule(C)};this.commit=function(){schedule(C)}}Service.idCounter=0;Service.newId=function(){return Service.idCounter++};Service.prototype={createUser:function(A,B){this.email=A;delete this.code;this.rpc("CreateUser",{session:SessionId,email:A,client:clientInfo},function(C,D){B(C)})},setUser:function(A,B){this.email=A;this.code=SHA1(B)},refreshCse:function(B,A){return this.addRequest({operation:"RefreshCse",id:B},A)},createStatement:function(C,A,B,D){return this.addRequest({operation:"CreateStatement",subject:C,predicate:A,object:B},D)},obtainUri:function(B,A){return this.addRequest({operation:"ObtainUri",uri:B},A)},obtainName:function(A,B){return this.addRequest({operation:"ObtainName",name:A},B)},getObjects:function(B,A,C){return this.addRequest({operation:"GetObjects",subject:B,predicate:A},C)},getPredicateObjects:function(A,B){return this.addRequest({operation:"GetPredicateObjects",subject:A},B)},getName:function(B,A){return this.addRequest({operation:"GetName",id:B},A)},getUri:function(B,A){return this.addRequest({operation:"GetUri",id:B},A)}};var clientInfo=Json.write({browser:Browser,screen:{width:window.screen.width,height:window.screen.height,colorDepth:window.screen.colorDepth,availWidth:window.screen.availWidth,availHeight:window.screen.availHeight},zone:new Date().getTimezoneOffset(),referrer:window.document.referrer,navigator:merge(withoutProperties(window.navigator,"mimeTypes","plugins"),{plugins:extractStrings(window.navigator.plugins,function(A){return A.name})}),java:window.navigator.javaEnabled()});var Account={};Account.using=function(A){if(Account.user){A(Account.user.email,Account.user.id)}else{if(Account.loadedHandlers){Account.loadedHandlers.attach(A)}else{Account.loadedHandlers=commands();Account.loadedHandlers.attach(A);Account.login(function(){A(Account.user.email,Account.user.id)},function(){Account.loadedHandlers=null})}}};Account.login=function(B,A){MessageBox(400,300,function(F){var J=new WatchValue();var I=new WatchValue();var H=F.edit(J,null,Html.email);var G=F.edit(I,null,Html.password);J.set(Cookies.get("email"));var D=new WatchValue();var K=F.button(function(){var L=J.get();if(empty(L)){D.set("Není vyplněná emailová adresa.");return }K.disable();service.createUser(L,function(M){if(M){D.set("Ověřovací kód byl zaslán na emailovou adresu.")}else{D.set("Chyba při zasílání kódu: zkontrolujte email.");K.enable()}})},"Zaslat");var E=F.button(function(){var L=J.get();var M=I.get();if(empty(L)){D.set("Není vyplněná emailová adresa.");return }if(empty(M)){D.set("Není vyplněný ověřovací kód.");return }E.disable();service.setUser(L,M);service.validateUser(function(N){if(exists(N)){F.close();Account.user={email:L,id:N};Cookies.set("email",L);B()}else{D.set("Uživatele nelze ověřit. Zkontrolujte email a kód.");E.enable()}})},"Ověřit");var C=F.button(F.close,"Zavřít");return F.block([F.header("Ověření uživatele").locate(20,20,-60,20),F.lines(["Vyplněte vaši emailovou adresu a ověřovací kód.","Pokud ověřovací kód nemáte, nechte si ho zaslat."]).locate(70,20,-120,20),F.label(H,"Email:").locate(132,20,-154,-100),H.locate(132,100,-154,30),F.label(G,"Kód:").locate(172,20,-194,-100),G.locate(172,100,-194,140),K.locate(170,-120,-196,30),F.block(D).color(Color.red).locate(-80,20,60,20),E.locate(-46,60,20,-160),C.locate(-46,-160,20,60)]).locate(0,0,0,0).background(Color.white).border(3,"solid",Color.orange)},A)};var google;var Google={};Google.script="http://www.google.com/jsapi?key=ABQIAAAATt2g37-G8ppQGCwL5SOQ4xQx2dEgEK7reJzdu83ca_PE6xCmkxShNCO_e3UKLKLK2emUM7TyIncOPw&callback=GoogleLoader.apiLoaded";Google.usingApi=function(A){if(google){A()}else{if(Google.apiLoadedHandlers){Google.apiLoadedHandlers.attach(A)}else{Google.apiLoadedHandlers=commands();Google.apiLoadedHandlers.attach(function(){Google.apiLoadedHandlers=null});Google.apiLoadedHandlers.attach(A);Html.addScript("http://www.google.com/jsapi?key=ABQIAAAATt2g37-G8ppQGCwL5SOQ4xQx2dEgEK7reJzdu83ca_PE6xCmkxShNCO_e3UKLKLK2emUM7TyIncOPw&callback=Google.apiLoadedHandlers")}}};Google.usingSearch=function(A){Google.usingApi(function(){if(google.search){A()}else{if(Google.searchLoadedHandlers){Google.searchLoadedHandlers.attach(A)}else{Google.searchLoadedHandlers=commands();Google.searchLoadedHandlers.attach(function(){Google.searchLoadedHandlers=null});Google.searchLoadedHandlers.attach(A);google.load("search","1",{nooldnames:true,language:"cs",callback:Google.searchLoadedHandlers})}}})};Google.webSearch=function(B,C,A){Google.usingSearch(function(){var D=new google.search.WebSearch();D.setSiteRestriction({crefUrl:B});D.setResultSetSize(google.search.Search.LARGE_RESULTSET);D.setSearchCompleteCallback(D,A);D.setNoHtmlGeneration();D.execute(C)})};var Index={Sidebar:function(A){return[A.header("Navigace").padding(0),A.stack([A.block([A.link(function(){A.mainPane.set(Panes.Search)},"Vyhledávání")]).padding(4,0),A.block([A.link(function(){A.mainPane.set(Editor.ShowLinks)},"Seznam odkazů")]).padding(4,0),A.block([A.link(function(){A.mainPane.set(Editor.AddLinks)},"Přidat odkaz")]).padding(4,0)]).margin(4,0,12,0)]}};function Editor(){}Editor.LinkInput=function(B){var A=new WatchValue();return[B.block([B.block([B.text("Odkaz: ").locate(2,2,2,-80),B.edit(A).locate(2,80,2,100),B.button(function(){B.addLinks([A.get()])},["Přidat"]).locate(0,-90,0,0)]).fill().relative()]).size("100%",26),B.textAlign(B.link(function(){B.navigate(Editor.MultipleLinkInput)},B.small("Přidání více odkazů")),"right").padding(0,100,0,0)]};Editor.MultipleLinkInput=function(B){var A=new WatchValue();return[B.block([B.block([B.block("Odkazy:").locate(2,2,-24,0),B.memo(A).locate(26,2,-400,2),B.button(function(){var C=A.get();B.addLinks(C.split("\n"))},["Přidat"]).locate(0,-90,-26,0)]).fill().relative()]).size("100%",400),B.textAlign(B.link(function(){B.navigate(Editor.LinkInput)},B.small("Přidání jednoho odkazu")),"right").padding(4,0,4,0)]};Editor.AddLinks=function(B){var C=new WatchList();function A(D){C.clear();C.append("Probíhá přidávání...");Account.using(function(){each(D,function(F){var E=trim(F);service.createStatement(SID.Root,SID.Link,service.obtainUri(E),function(G){if(exists(G)){C.append(E+" OK");anyOk=true}else{C.append(E+" chyba")}})})})}return[B.header("Přidání odkazů do vyhledávače"),B.block(B.view(Editor.LinkInput,{addLinks:A})).margin(4,0),B.stack(C).color(Color.red).margin(16,0),B.line(["Vyhledávač je určen pro křesťanské stránky (stránky farností a komunit, informace o kostelech a akcích, apod.)."]).color(Color.light.gray).margin(32,0)]};Editor.ShowLinks=function(B){var A=new WatchList();service.getUri(service.getObjects(SID.Root,SID.Link).setKey("object"),function(C){A.clear();if(!empty(C)){iterate(C,function(D){A.append(D.uri)})}});return[B.header("Seznam odkazů"),B.block([B.stack(A)])]};var News={Data:{"08.04.08":["Jednoduchá verze vyhledávače."],"20.03.08":["Zřízena doména."]},Sidebar:function(A){return A.block([A.header("Informace").padding(0),A.block([A.block("Systém je ve vývoji.").padding(4,0),A.block("Omluvte prosím případné výpadky.").padding(4,0)]).margin(4,0,12,0)])}};var Search={};Search.engineUrl="http://ahoj.krestane.cz/Service.ashx/resources/cse?id=100";Search.query=Google.webSearch;Search.Pane=function(E){var D=new WatchValue();var A=new WatchList();var F;var C;function B(){if(empty(D.get())){return }$B(A,["Hledám..."]);Search.query(Search.engineUrl,D.get(),function(){if(!exists(this.cursor)){$B(A,[E.strong("Nebylo nic nalezeno.")]);return }if(this.cursor.currentPageIndex==0){F=new WatchList();C=new WatchList("Hledám...");$B(A,[E.lines(E.repeater(F,Search.ResultItemView)).padding(8,0),E.block(C),google.search.Search.getBranding()])}iterate(this.results,function(G){F.append(G)});if(this.cursor.currentPageIndex==this.cursor.pages.length-1){$B(C,[E.link({url:this.cursor.moreResultsUrl,target:Html.Target.New},["Další výsledky..."])])}this.gotoPage(this.cursor.currentPageIndex+1)})}return[E.header("Vyhledávání"),E.block([E.block([E.text("Hledaný výraz: ").locate(2,0,2,-120),E.edit(D,null,function(){var G=Html.edit();G.observeKeyPress(function(H){if(H===13){G.notifyObservers();B();return false}return true});return G}).locate(2,120,2,100),E.button(B,["Hledej"]).locate(0,-90,0,0)]).fill().relative()]).size("100%",26).padding(8,2),E.block(A).margin(8,0),E.block([E.line(["Současná verze systému obsahuje vyhledávač stránek s křesťanskou tématikou zejména v českém jazyce. "]).margin(8,0),E.line([E.text("Znáte křesťanské stránky, které vyhledávač neprohledává? "),E.link(function(){E.mainPane.set(Editor.AddLinks)},"Přidejte je!")]).margin(8,0)]).margin(32,0).color(Color.light.gray)]};Search.ResultItemView=function(A){return A.line([A.link({url:A.value.unescapedUrl,target:"externalLink"},Search.htmlToDom(A.value.title)),Html.br(),Search.htmlToDom(A.value.content),Html.br(),A.small([Search.htmlToDom(A.value.unescapedUrl)])]).margin(8,0)};Search.htmlToDom=function(A){return Widget.text(translate(decodeHtml(A),function(C,B){return odd(B)?Widget.strong([C]):C}))};Search.refreshIndex=function(A){service.refreshCse("100",function(B){invoke(A,B&&B.result)})};var css={html:{margin:0,padding:0,color:Color.gray},body:{fontFamily:"arial, helvetica, sans-serif",margin:0,padding:0},p:{fontSize:"100%",padding:0,margin:0},"h1, h2, h3, h4, h5, h6":{margin:0,color:Color.orange},h1:{fontSize:"150%",padding:0},h2:{fontSize:"140%",padding:"0px 0px 8px 0px"},h3:{fontSize:"130%",padding:"0px 0px 6px 0px"},h4:{fontSize:"120%",padding:"0px 0px 4px 0px"},h5:{fontSize:"110%",padding:"0px 0px 4px 0px"},h6:{fontSize:"100%",padding:"0px 0px 4px 0px"},input:{fontFamily:"arial, helvetica, sans-serif"},button:{fontFamily:"arial, helvetica, sans-serif",margin:0,padding:0},a:{textDecoration:"none",color:Color.orange,margin:"0px 0px -1px 0px"},"a strong":{color:Color.dark.orange},"a:hover, a:hover *":{textDecoration:"underline"},"a:visited":{color:Color.orange},"a:visited strong":{color:Color.dark.orange},"a:visited:hover, a:visited:hover *":{textDecoration:"underline"},strong:{fontWeight:"normal",color:Color.black},small:{color:Color.light.gray}};var Panes={Search:function(A){return[A.block(A.view(Search.Pane))]},Root:function(A){A.mainPane=new WatchValue(Panes.Search);return A.block([A.image("res/header.png","Ahoj křesťane! Interaktivní informační databáze"),A.block(A.view(Index.Sidebar,{header:A.header4})).fixedBox(120,8,-200,-128),A.block(A.view(A.mainPane)).locate(120,160,0,340),A.block(A.view(News.Sidebar,{header:A.header4})).locate(120,-300,0,0)])}};var service=new Service("Service.ashx/rpc/json");WidgetDocument(Panes.Root,{nextLevel:function(A){A.header=A.header.next}},function(){StyleSheet.add(css);service.commit()});
