/*
    Copyright © 2005-2008 Apple Inc. All Rights Reserved.

    NWMatcher Copyright (c) 2007-2008 Diego Perini <http://www.iport.it>
    All rights reserved.
*/

if("undefined"!==typeof(coherent)){throw new Error("Library module (coherent) already defined")}var coherent={version:"1.2.0",revision:"",generateUid:(function(){var a=0;return function(){return ++a}})()};coherent.Browser={IE:!!(window.attachEvent&&!window.opera)&&(function(){var b=/MSIE (\d+)/;var a=b.exec(navigator.userAgent);return a&&parseInt(a[1],10)})(),Safari:navigator.userAgent.indexOf("AppleWebKit/")>-1,Safari2:(function(){var a=/AppleWebKit\/(\d+(?:\.\d+)?)/;var b=a.exec(navigator.userAgent);return(b&&parseInt(b[1],10)<420)})(),Mozilla:navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")==-1,MobileSafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/)};coherent.Support={Properties:("__defineGetter__" in Object.prototype),QuerySelector:("querySelector" in document),Touches:!!document.createTouch,CSS3ColorModel:false,CSSTransitions:false};if(coherent.Support.Properties){coherent.Support.__defineGetter__("CSS3ColorModel",function(){delete this.CSS3ColorModel;var b=document.createElement("span");try{b.style.backgroundColor="rgba(100,100,100,0.5)";return this.CSS3ColorModel=(b.style.length===1)}catch(a){}return(this.CSS3ColorModel=false)});coherent.Support.__defineGetter__("CSSTransitions",function(){delete this.CSSTransitions;var b=document.createElement("span");try{b.style.setProperty("-webkit-transition-duration","1ms","");return this.CSSTransitions=(b.style.length===1)}catch(a){}return(this.CSSTransitions=false)})}coherent.typeOf=function(b){if(null===b){return"null"}var a=typeof(b);if("object"!==a&&"function"!==a){return a}return Object.prototype.toString.call(b).slice(8,-1).toLowerCase()};coherent.compareValues=function(f,d){var c=coherent.typeOf(f);if(c!==coherent.typeOf(d)){var a=String(f);var e=String(d);return a.localeCompare(e)}switch(c){case"null":return 0;case"boolean":case"number":var b=(f-d);if(0===b){return b}return(b<0?-1:1);case"regexp":case"function":break;case"string":case"array":case"object":if(f.localeCompare){return f.localeCompare(d)}if(f.compare){return f.compare(d)}break;case"undefined":return true;default:throw new TypeError("Unknown type for comparison: "+c)}return String(f).localeCompare(String(d))};coherent.defineError=function(b){function a(c){this.message=c;this.name=b}a.prototype=new Error;a.prototype.constructor=a;a.prototype.name=b;return a};var InvalidArgumentError=coherent.defineError("InvalidArgumentError");if("undefined"==typeof(window.console)){window.console={}}if("undefined"==typeof(window.console.log)){window.console.log=function(){}}String.prototype.titleCase=function(){return this.charAt(0).toUpperCase()+this.substr(1)};String.prototype.trim=function(){var b=this.replace(/^\s+/,"");for(var a=b.length-1;a>0;--a){if(/\S/.test(b.charAt(a))){b=b.substring(0,a+1);break}}return b};String.prototype.beginsWith=function(a){return a===this.substring(0,a.length)};if(!String.prototype.localeCompare){String.prototype.localeCompare=function(a){if(this<a){return -1}else{if(this>a){return 1}else{return 0}}}}String.prototype.expand=function(c,a){function b(f,d){var e=c[d];if(null===e||"undefined"===typeof(e)){return a}return e}return this.replace(/\$\{(\w+)\}/g,b)};if("undefined"!==typeof(window.Prototype)){(function(){var a=["indexOf","lastIndexOf","forEach","filter","map","some","every","reduce","reduceRight"];for(var b=0;b<a.length;++b){delete Array.prototype[a[b]]}})()}Array.prototype.distinct=function(){var b=this.length;var a=new Array(b);var c;var f;var d=0;for(c=0;c<b;++c){f=this[c];if(-1==a.indexOf(f)){a[d++]=f}}a.length=d;return a};Array.prototype.compare=function(c){var e=this.length-c.length;if(0!==e){return e}var f;var b;var d;for(f=0,b=this.length;f<b;++f){d=coherent.compareValues(this[f],c[f]);if(0!==d){return d}}return 0};Array.from=function(a,b){return Array.prototype.slice.call(a,b||0)};if(!Array.prototype.reduce){Array.prototype.reduce=function(b){var a=this.length;if(typeof b!="function"){throw new TypeError()}if(0===a&&1===arguments.length){throw new TypeError()}var c=0;if(arguments.length>=2){var d=arguments[1]}else{do{if(c in this){d=this[c++];break}if(++c>=a){throw new TypeError()}}while(true)}for(;c<a;c++){if(c in this){d=b.call(null,d,this[c],c,this)}}return d}}if(!Array.prototype.reduceRight){Array.prototype.reduceRight=function(b){var a=this.length;if(typeof b!="function"){throw new TypeError()}if(0===a&&1===arguments.length){throw new TypeError()}var c=a-1;if(arguments.length>=2){var d=arguments[1]}else{do{if(c in this){d=this[c--];break}if(--c<0){throw new TypeError()}}while(true)}for(;c>=0;c--){if(c in this){d=b.call(null,d,this[c],c,this)}}return d}}if(!Array.indexOf){Array.indexOf=function(c,b,a){return Array.prototype.indexOf.call(c,b,a)}}if(!Array.lastIndexOf){Array.lastIndexOf=function(c,b,a){return Array.prototype.lastIndexOf.call(c,b,a)}}if(!Array.forEach){Array.forEach=function(c,a,b){return Array.prototype.forEach.call(c,a,b)}}if(!Array.filter){Array.filter=function(c,a,b){return Array.prototype.filter.call(c,a,b)}}if(!Array.map){Array.map=function(c,a,b){return Array.prototype.map.call(c,a,b)}}if(!Array.some){Array.some=function(c,a,b){return Array.prototype.some.call(c,a,b)}}if(!Array.every){Array.every=function(c,a,b){return Array.prototype.every.call(c,a,b)}}if(!Array.reduce){Array.reduce=function(b,a){if(arguments.length>2){return Array.prototype.reduce.apply(b,a,arguments[2])}else{return Array.prototype.reduce.apply(b,a)}}}if(!Array.reduceRight){Array.reduceRight=function(b,a){if(arguments.length>2){return Array.prototype.reduceRight.apply(b,a,arguments[2])}else{return Array.prototype.reduceRight.apply(b,a)}}}Array.from=function(d,e){var b=d.length;var a=[];for(var c=(e||0);c<b;++c){a.push(d[c])}return a};if(!Array.prototype.indexOf){Array.prototype.indexOf=function(c,b){if("undefined"===typeof(b)){b=0}else{if(b<0){b=Math.max(0,this.length+b)}}for(var a=b;a<this.length;a++){if(this[a]===c){return a}}return -1}}if(!Array.prototype.lastIndexOf){Array.prototype.lastIndexOf=function(c,b){if("undefined"===typeof(b)){b=this.length-1}else{if(b<0){b=Math.max(0,this.length+b)}}for(var a=b;a>=0;a--){if(this[a]===c){return a}}return -1}}if(!Array.prototype.forEach){Array.prototype.forEach=function(c,d){var a=this.length;for(var b=0;b<a;b++){c.call(d,this[b],b,this)}}}if(!Array.prototype.filter){Array.prototype.filter=function(d,e){var a=this.length;var c=[];for(var b=0;b<a;b++){if(d.call(e,this[b],b,this)){c.push(this[b])}}return c}}if(!Array.prototype.map){Array.prototype.map=function(d,e){var a=this.length;var c=[];for(var b=0;b<a;b++){c.push(d.call(e,this[b],b,this))}return c}}if(!Array.prototype.some){Array.prototype.some=function(c,d){var a=this.length;for(var b=0;b<a;b++){if(c.call(d,this[b],b,this)){return true}}return false}}if(!Array.prototype.every){Array.prototype.every=function(c,d){var a=this.length;for(var b=0;b<a;b++){if(!c.call(d,this[b],b,this)){return false}}return true}}if(!Function.prototype.bind){Function.prototype.bind=function(c){var a=this;if(!arguments.length){return a}if(1==arguments.length){return function(){return a.apply(c,arguments)}}var b=Array.from(arguments,1);return function(){return a.apply(c,b.concat(Array.from(arguments)))}}}if(!Function.prototype.bindAsEventListener){Function.prototype.bindAsEventListener=function(c){var a=this;if(1==arguments.length){return function(d){return a.call(c,d||window.event)}}var b=Array.from(arguments);b.shift();return function(d){return a.apply(c,[d||window.event].concat(b))}}}if(!Function.prototype.delay){Function.prototype.delay=function(d){var b=this;d=d||10;if(arguments.length<2){function a(){b()}return window.setTimeout(a,d)}var c=Array.from(arguments,1);function e(){b.apply(b,c)}return window.setTimeout(e,d)}}if(!Function.prototype.bindAndDelay){Function.prototype.bindAndDelay=function(f,d){var b=this;f=f||b;d=d||10;if(arguments.length<3){function a(){b.call(f)}return window.setTimeout(a,d)}var c=Array.from(arguments,2);function e(){b.apply(f,c)}return window.setTimeout(e,d)}}Function.prototype.sync=function(){var b=arguments.length?this.bind.apply(this,arguments):this;var a={};var c=false;b.stop=function(){c=true};b.waitFor=function(d){a[d]=true;return function(){a[d]=false;for(var e in a){if(a[e]){return}}if(c){return}b()}};return b};function Set(){var d=this;if(d.constructor!==Set){d=new Set()}var b=arguments;if(1==b.length&&b[0] instanceof Array){b=b[0]}var c;var a=b.length;for(c=0;c<a;++c){d[b[c]]=true}return d}Set.union=function(c,b){var a=Object.clone(c);if(!b){return a}var d;for(d in b){a[d]=true}return a};Set.intersect=function(c,b){var a=new Set();var d;for(d in c){if(d in b){a[d]=true}}return a};Set.add=function(b,a){b[a]=true;return b};Set.remove=function(b,a){delete b[a];return b};Set.toArray=function(d){var c;var b=[];for(c in d){b.push(c)}return b};Set.forEach=function(f,c,b){var d;var a=0;for(d in f){c.call(b,d,a++)}};Set.join=function(f,c){var d;var b=[];for(d in f){b.push(d)}return b.join(c||"")};var $S=Set;Object.clone=function(b){var a=(function(){});a.prototype=b;return new a()};Object.applyDefaults=function(c,b){c=c||{};if(!b){return c}for(var a in b){if(a in c){continue}c[a]=b[a]}return c};Object.extend=function(c,a){c=c||{};for(var b in a){c[b]=a[b]}return c};Object.merge=function(c,a){var b={};var d;for(d in c){b[d]=c[d]}for(d in a){if(d in b){continue}b[d]=a[d]}return b};(function(){var b=Set("file","submit","image","reset","button");var d={};function e(i,h,j){var g=i[h];var f=coherent.typeOf(g);if("string"===f){i[h]=[g,j]}else{if("array"===f){g.push(j)}else{i[h]=j}}}function c(h){var f=h.name;var g=(h.type||"").toLowerCase();if(h.disabled||g in b){return}if("radio"===g||"checkbox"===g){if(h.checked){e(this,f,h.value)}}else{if(h.multiple){function i(j){if(j.selected){e(this,f,j.value)}}this[f]=[];Array.forEach(h.options,i,this)}else{e(this,f,h.value);if("image"===g){e(this,f+".x",0);e(this,f+".y",0)}}}}Object.fromForm=function(g){var f={};Array.forEach(g.elements,c,f);return f};function a(h){h=h.split("=");if(1===h.length){return}var f=decodeURIComponent(h[0].trim());var g=decodeURIComponent(h[1].trim())||null;e(this,f,g)}Object.fromQueryString=function(g){if("?"==g.charAt(0)){g=g.slice(1)}g=g.split(/\s*&\s*/);var f={};g.forEach(a,f);return f};Object.toQueryString=function(k){if(!k){return""}var h;var j;var f;var g=[];function i(l){if(null!==l&&"undefined"!==typeof(l)){l=encodeURIComponent(l)}g.push(h+"="+l)}for(h in k){j=k[h];f=coherent.typeOf(j);if("function"===f||j===d[h]){continue}h=encodeURIComponent(h);if("array"===f){j.forEach(i)}else{i(j)}}return g.join("&")}})();RegExp.escape=function(a){return a.replace(RegExp._escapeRegex,"\\$1")};RegExp.specialCharacters=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];RegExp._escapeRegex=new RegExp("(\\"+RegExp.specialCharacters.join("|\\")+")","g");var Class=(function(){function d(i,l){var j;if(!i&&!l){return i}if(!i){j=function(){l.apply(this,arguments)}}else{var k=/this\.base/.test(i);if(!k&&!l){return i}if(!k){j=function(){l.call(this);i.apply(this,arguments)}}else{j=function(){var m=this.base;this.base=l||function(){};i.apply(this,arguments);this.base=m}}}j.valueOf=function(){return i};j.toString=function(){return String(i)};return j}function g(i,j){var k=i.prototype.__factory__.apply(i,j);if("function"!==typeof(k)){throw new Error("Factory function doesn't return a function")}k.__factoryFn__=true;return k}function f(k){if(k.__createFactoryObjects){k.__createFactoryObjects();return}var j;var i;for(j in k.__factories__){i=k[j];if(!i.__factoryFn__){continue}k[j]=i.call(k)}}function c(i,k){if(i&&!(i instanceof Function)){throw new Error("Invalid constructor")}if(k&&!(k instanceof Function)){throw new Error("Invalid superclass")}k=k?k.valueOf():null;i=d(i,k);var j;if(i){j=function(){if(!(this instanceof j)){return g(j,arguments)}this.__uid=this.__uid||coherent.generateUid();i.apply(this,arguments);f(this);if(this.__postConstruct instanceof Function){this.__postConstruct()}return this}}else{j=function(){if(!(this instanceof j)){return g(j,arguments)}this.__uid=this.__uid||coherent.generateUid();f(this);if(this.__postConstruct instanceof Function){this.__postConstruct()}return this}}j.valueOf=function(){return i};j.toString=function(){return String(i||j)};return j}function b(j){function i(){}i.prototype=j.prototype;return new i()}function e(k,i){if(!k||!/this\.base/.test(k)){return k}function j(){var m=this.base;this.base=i||function(){};var l=k.apply(this,arguments);this.base=m;return l}j.valueOf=function(){return k};j.toString=function(){return String(k)};return j}function h(k,i,l){if(l instanceof Function){var j=k[i];var m=l.valueOf();if(j instanceof Function&&j.valueOf()!==m){l=e(l,j)}if(m.__factoryFn__){k.__factories__[i]=l}}k[i]=l;return l}function a(j){var i;for(i=j.superclass;i;i=i.superclass){if("__subclassCreated__" in i){i.__subclassCreated__(j)}}}return{create:function(l,j){var i;var k={};switch(arguments.length){case 0:throw new TypeError("Missing superclass and declaration arguments");case 1:j=l;l=undefined;break;default:k=b(l);break}if("function"==typeof(j)){j=j();if(!j){throw new Error("Class declaration function did not return a prototype")}}if(j.hasOwnProperty("constructor")){i=j.constructor;delete j.constructor}i=c(i,l);i.prototype=k;i.prototype.constructor=i;i.superclass=l;if(l){k.__factories__=Object.clone(l.prototype.__factories__)}else{k.__factories__={}}this.extend(i,j);a(i);return i},findPropertyName:function(l,i){var j;for(var k in l){j=l[k];if(j===i||("function"===typeof(j)&&j.valueOf()===i)){return k}}return null},extend:(function(){if(coherent.Support.Properties){return function(i,j){var n=i.prototype;var k;for(var o in j){var m=j.__lookupGetter__(o);var l=j.__lookupSetter__(o);if(m||l){m&&n.__defineGetter__(o,m);l&&n.__defineSetter__(o,l)}else{h(n,o,j[o])}}return i}}else{return function(i,j){var k=i.prototype;for(var l in j){h(k,l,j[l])}}}})()}})();coherent.strings={"marker.input.multipleValues":"Multiple Values","marker.input.placeholder":"","marker.input.noSelection":"No Selection","marker.image.multipleValues":"","marker.image.placeholder":"","marker.image.noSelection":"","marker.text.multipleValues":"Multiple Values","marker.text.placeholder":"","marker.text.noSelection":"No Selection","error.no_description":"An unspecified error occurred.","error.invalid_value":"This value is not valid.","error.invalid_number":"This value is not a valid number."};coherent.localisedString=function(a){return{valueOf:function(){if(a in coherent.strings){return coherent.strings[a]}return null},toString:function(){if(a in coherent.strings){return coherent.strings[a]}console.log("Localisation missing string for key: "+a);return a}}};var _=coherent.localisedString;coherent.Error=Class.create({constructor:function(a){Object.extend(this,a)},description:_("error.no_description"),recoverySuggestion:null});coherent.KeyInfo=Class.create({constructor:function(d,b){var a=coherent.KVO.getPropertyMethodsForKeyOnObject(b,d);this.__uid=[b,coherent.generateUid()].join("_");this.reader=a.getter;this.mutator=a.mutator;this.validator=a.validator;this.key=b;this.mutable=((this.mutator||!this.reader)?true:false);if(!this.reader&&!this.mutator){this.mutable=true}this.changeCount=0;var c=a.value;if(!c){return}var e=coherent.typeOf(c);if(e in coherent.KVO.typesOfKeyValuesToIgnore||!c._addParentLink){return}c._addParentLink(d,this)},get:function(b){if(this.reader){return this.reader.call(b)}var a;if(this.key in b){a=b[this.key]}else{a=null}if(a&&a._addParentLink){a._addParentLink(b,this)}return a},set:function(b,a){if(this.mutator){this.mutator.call(b,a)}else{b.willChangeValueForKey(this.key,this);b[this.key]=a;b.didChangeValueForKey(this.key,this)}},validate:function(b,a){if(!this.validator){return a}return this.validator.call(b,a)},unlinkParentLink:function(){if(!this.parentLink){return}this.parentLink.observer=null;this.parentLink.callback=null;this.parentLink=null}});coherent.ChangeType={setting:0,insertion:1,deletion:2,replacement:3};coherent.ChangeNotification=Class.create({constructor:function(d,a,e,c,b){this.object=d;this.changeType=a;this.newValue=e;this.oldValue=c;this.indexes=b;this.objectKeyPath=[]},toString:function(){var a="[ChangeNotification changeType: ";switch(this.changeType){case coherent.ChangeType.setting:a+="setting";break;case coherent.ChangeType.insertion:a+="insertion";break;case coherent.ChangeType.deletion:a+="deletion";break;case coherent.ChangeType.replacement:a+="replacement";break;default:a+="<<unknown>>";break}a+=" newValue="+this.newValue+" oldValue="+this.oldValue+(this.indexes?" indexes="+this.indexes.join(", "):"")+"]";return a}});coherent.ObserverEntry=Class.create({constructor:function(a,c,b){this.observer=a;this.callback=c;this.context=b},observeChangeForKeyPath:function(a,b){if(!this.callback||!this.observer||-1!==a.objectKeyPath.indexOf(this.observer)){return}this.callback.call(this.observer,a,b,this.context)}});coherent.KVO=Class.create({constructor:function(){},__factory__:function(){var b=Array.from(arguments);var a=this;function c(){}return function(){c.prototype=a.prototype;var d=new c();a.prototype.constructor.apply(d,b);return d}},setValueForKeyPath:function(c,d){if(!d||0===d.length){throw new InvalidArgumentError("keyPath may not be empty")}if("string"==typeof(d)){d=d.split(".")}var b=d[0];if(1==d.length){this.setValueForKey(c,b);return}if("@"==b.charAt(0)){return}var a=this.valueForKey(b);if(!a){return}a.setValueForKeyPath(c,d.slice(1))},setValueForKey:function(b,a){if(!a||0===a.length){throw new InvalidArgumentError("key may not be empty")}var c=this.infoForKey(a);if(!c||!c.mutable){return}c.set(this,b)},valueForKeyPath:function(e){if(!e||0===e.length){throw new InvalidArgumentError("keyPath may not be empty")}if("string"==typeof(e)){e=e.split(".")}var d=e[0];if(1==e.length){return this.valueForKey(d)}if("@"==d.charAt(0)){var b=d.substr(1);var a=this.valueForKeyPath(e.slice(1));return coherent.ArrayOperator[b](a)}var c=this.valueForKey(d);if("undefined"===typeof(c)||null===c){return undefined}return c.valueForKeyPath(e.slice(1))},valueForKey:function(a){if(!a||0===a.length){throw new InvalidArgumentError("the key is empty")}var b=this.infoForKey(a);if(!b){return null}return b.get(this)},validateValueForKeyPath:function(c,d){if(!d||0===d.length){throw new InvalidArgumentError("keyPath may not be empty")}if("string"==typeof(d)){d=d.split(".")}var b=d[0];if(1==d.length){return this.validateValueForKey(c,b)}var a=this.valueForKey(b);if("undefined"===typeof(a)||null===a){return c}return a.validateValueForKeyPath(c,d.slice(1))},validateValueForKey:function(b,a){if(!a||!a.length){throw new InvalidArgumentError("missing key")}var c=this.infoForKey(a);return c.validate(this,b)},observeChildObjectChangeForKeyPath:function(d,c,a){if(coherent.KVO.kAllPropertiesKey!=c){c=a+"."+c}else{c=a}var b=Object.clone(d);b.object=this;this.notifyObserversOfChangeForKeyPath(b,c)},infoForKeyPath:function(d){if(!d||0===d.length){throw new InvalidArgumentError("keyPath is empty")}if("string"==typeof(d)){d=d.split(".")}var b=d[0];if(1==d.length){return this.infoForKey(b)}else{if("@"==b.charAt(0)){var c=new coherent.KeyInfo(null,null);c.mutable=false;return c}else{var a=this.valueForKey(b);if(!a){return undefined}if(!a.infoForKeyPath){return undefined}return a.infoForKeyPath(d.slice(1))}}},infoForKey:function(a){var b;if(!this.__keys){this.__keys={}}if(coherent.KVO.kAllPropertiesKey==a){return null}b=this.__keys[a];if(b){return b}b=new coherent.KeyInfo(this,a);this.__keys[a]=b;return b},setKeysTriggerChangeNotificationsForDependentKey:function(d,c){if(!d||!d.length){throw new InvalidArgumentError("keys array is not valid")}if(!c){throw new InvalidArgumentError("dependentKey can not be null")}if(-1!==c.indexOf(".")){throw new InvalidArgumentError("dependentKey may not be a key path")}var b;var f;var a;var e;if("string"===typeof(d)){d=[d]}if(!this.__dependentKeys){this.__dependentKeys={}}for(a=0;a<d.length;++a){b=d[a];if(!b){throw new InvalidArgumentError("key at index "+a+" was null")}if(!(b in this.__dependentKeys)){this.__dependentKeys[b]=[]}coherent.KVO.getPropertyMethodsForKeyOnObject(b,this);e=this.__dependentKeys[b];if(-1==e.indexOf(c)){e.push(c)}}},mutableKeys:function(){var d=[];var b;var a;var c;if("__mutableKeys" in this&&this.__mutableKeys.concat){return this.__mutableKeys}var e=Set.union(coherent.KVO.keysToIgnore,this.__keysToIgnore);for(b in this){if(b in e||"__"===b.substr(0,2)){continue}a=this[b];if("function"!==typeof(a)){d.push(b);continue}if(1!==a.length||"set"!==b.substr(0,3)){continue}c=b.charAt(3);if(c!==c.toUpperCase()){continue}b=c.toLowerCase()+b.substr(4);if(-1===d.indexOf(b)){d.push(b)}}return d},initialiseKeyValueObserving:function(){this.__uid=this.__uid||coherent.generateUid();this.__observers={}},_addParentLink:function(d,e,c){if(!this.hasOwnProperty("__observers")){this.initialiseKeyValueObserving()}var b=this.__observers[coherent.KVO.kAllPropertiesKey];if(!b){b=this.__observers[coherent.KVO.kAllPropertiesKey]={}}c=c||e.__uid;if(c in b){return}var a=new coherent.ObserverEntry(d,d.observeChildObjectChangeForKeyPath,e?e.key:"");b[c]=a;if(!e){return}e.unlinkParentLink();e.parentLink=a},_removeParentLink:function(c,d,b){if(!this.__observers){return}var a=this.__observers[coherent.KVO.kAllPropertiesKey];if(!a){a=this.__observers[coherent.KVO.kAllPropertiesKey]={}}b=b||d.__uid;if(d&&d.parentLink===a[b]){d.unlinkParentLink()}delete a[b]},addObserverForKeyPath:function(a,e,d,b){if(!d||0===d.length){throw new InvalidArgumentError("keyPath is empty")}if(!a){throw new InvalidArgumentError("Observer may not be null")}if(!e){e=a.observeChangeForKeyPath}if("string"===typeof(e)){e=a[e]}if(!e){throw new InvalidArgumentError("Missing callback method")}if(!this.hasOwnProperty("__observers")){this.initialiseKeyValueObserving()}if(!this.__observers[d]){this.infoForKeyPath(d);this.__observers[d]=[]}var c=new coherent.ObserverEntry(a,e,b);this.__observers[d].push(c)},removeObserverForKeyPath:function(c,f){if(!f||0===f.length){throw new InvalidArgumentError("keyPath may not be empty")}if(!c){throw new InvalidArgumentError("Observer may not be null")}if(!this.__observers||!this.__observers[f]){return}var e=this.__observers[f];var b=-1;var d;var a=e.length;for(b=0;b<a;++b){d=e[b];if(d.observer==c){e.splice(b,1);return}}},willChangeValueForKey:function(a,c){if(!a){throw new InvalidArgumentError("key may not be null")}c=(c instanceof coherent.KeyInfo)?c:this.infoForKey(a);if(!c){return}if(1!==++c.changeCount){return}var b=(this.__dependentKeys&&this.__dependentKeys[a]);if(b){b.forEach(this.willChangeValueForKey,this)}c.previousValue=c.get(this)},forceChangeNotificationForKey:function(a,b){if(!a){throw new InvalidArgumentError("key may not be null")}b=(b instanceof coherent.KeyInfo)?b:this.infoForKey(a);if(!b){return}if(0!==b.changeCount){return}b.changeCount=1;this.didChangeValueForKey(a,b)},didChangeValueForKey:function(b,f){if(!b){throw new InvalidArgumentError("key may not be null")}f=(f instanceof coherent.KeyInfo)?f:this.infoForKey(b);if(!f){return}if(0!==--f.changeCount){return}var c=f.get(this);var a=f.previousValue;f.previousValue=null;if(c!==a){var e=new coherent.ChangeNotification(this,coherent.ChangeType.setting,c,a);this.notifyObserversOfChangeForKeyPath(e,b);if(a&&a._removeParentLink){a._removeParentLink(this,f)}if(c&&c._addParentLink){c._addParentLink(this,f)}}var d=(this.__dependentKeys&&this.__dependentKeys[b]);if(d){d.forEach(this.didChangeValueForKey,this)}},notifyObserversOfChangeForKeyPath:function(j,l){if(!l){throw new InvalidArgumentError("keyPath may not be null")}if(!this.__observers){return}var g;var f;var h;f=this.__observers[coherent.KVO.kAllPropertiesKey];if(f){var e=Object.clone(j);var a=j.objectKeyPath.length;j.objectKeyPath.push(this);for(g in f){var b=f[g];b.observeChangeForKeyPath(e,l)}j.objectKeyPath.length=a}if(coherent.KVO.kAllPropertiesKey==l){return}f=this.__observers[l];if(f&&f.length){h=f.length;for(g=0;g<h;++g){f[g].observeChangeForKeyPath(j,l)}}var d=l+".";var i=d.length;var k;var m;var q;var p;var c;var n=!(null===j.oldValue||"undefined"===typeof(j.oldValue));for(m in this.__observers){if(m.substr(0,i)!=d){continue}f=this.__observers[m];if(!f||!f.length){continue}k=m.substr(i);p=j.oldValue;if(p&&p.valueForKeyPath){p=p.valueForKeyPath(k)}else{p=null}c=j.newValue;if(c&&c.valueForKeyPath){c=c.valueForKeyPath(k)}else{c=null}if(n&&p===c){continue}q=new coherent.ChangeNotification(j.object,j.changeType,c,p,j.indexes);h=f.length;for(g=0;g<h;++g){f[g].observeChangeForKeyPath(q,m)}}}});coherent.KVO.kAllPropertiesKey="*";coherent.KVO.keysToIgnore=$S("__keys","__observers","__keysToIgnore","__dependentKeys","__mutableKeys","__factories__");coherent.KVO.typesOfKeyValuesToIgnore=$S("string","number","boolean","date","regexp","function");coherent.KVO.getPropertyMethodsForKeyOnObject=(function(){function b(h,f){f=f||"__kvo_prop_"+h;var g={getter:function(){var i=null;if(f in this){i=this[f]}var j=this.__keys?this.__keys[h]:null;if(!j){return i}if(i&&i._addParentLink){i._addParentLink(this,j)}else{j.unlinkParentLink()}return i},mutator:function(i){this.willChangeValueForKey(h);if("undefined"===typeof(i)){i=null}this[f]=i;this.didChangeValueForKey(h);return i}};g.mutator.__key=h;g.getter.__key=h;return g}function c(h,g){function f(j){this.willChangeValueForKey(g);var i=h.call(this,j);this.didChangeValueForKey(g);return i}f.__key=g;f.valueOf=function(){return h};f.toString=function(){return String(h)};return f}function d(f,h){function g(){var i=f.call(this);var j=this.__keys?this.__keys[h]:null;if(!j){return i}if(i&&i._addParentLink){i._addParentLink(this,j)}else{j.unlinkParentLink()}return i}g.__key=h;g.valueOf=function(){return f};g.toString=function(){return String(f)};return g}function e(t,k){var m=k.constructor.prototype;var j=(m==k);var l=(m!=Object.prototype&&m!=coherent.KVO.prototype)?m:k;var u=t.titleCase();var p="get"+u;var q="set"+u;var i="validate"+u;var o;var h;var s;var f=k[i];var n=("undefined"!==typeof(o=k.__lookupGetter__(t))&&"undefined"!==typeof(h=k.__lookupSetter__(t)));if(!n){p=(p in k)?p:t;o=k[p];h=k[q]}if("function"!==typeof(o)){var r="__kvo_prop_"+t;var g=b(t,r);if(t in k){s=k[r]=("undefined"==typeof(o)?null:o);delete k[t]}o=g.getter;h=g.mutator;n=true}else{if(0!==o.length){o=null}if(h&&1!==h.length){h=null}if(o&&!j){s=o.valueOf().call(k)}if(o&&t!==o.__key){o=d(o,t)}if(h&&t!==h.__key){h=c(h,t)}}if(n){l.__defineGetter__(t,o);l.__defineSetter__(t,h)}else{if(o){if(k.hasOwnProperty(p)){k[p]=o}else{l[p]=o}}if(h){if(k.hasOwnProperty(q)){k[q]=h}else{l[q]=h}}}return{getter:o,mutator:h,validator:f,value:s}}function a(q,j){var l=j.constructor.prototype;var i=(l==j);var k=(l!=Object.prototype&&l!=coherent.KVO.prototype)?l:j;var r=q.titleCase();var o="set"+r;var n="get"+r;var h="validate"+r;n=(n in j)?n:q;var m=j[n];var g=j[o];var f=j[h];var p;if("function"!==typeof(m)){if(q in j){p=m}m=null;g=null}else{if(0!==m.length){m=null}if(g&&1!==g.length){g=null}if(m&&!i){p=m.valueOf().call(j)}if(m&&q!==m.__key){m=d(m,q)}if(g&&q!==g.__key){g=c(g,q)}}if(m){if(j.hasOwnProperty(n)){j[n]=m}else{k[n]=m}}if(g){if(j.hasOwnProperty(o)){j[o]=g}else{k[o]=g}}return{getter:m,mutator:g,validator:f,value:p}}if(coherent.Support.Properties){return e}else{return a}})();coherent.KVO.adapt=function(b){if(!b){throw new InvalidArgumentError("Can't adapt a null object")}var a;for(a in coherent.KVO.prototype){if(a in b){continue}b[a]=coherent.KVO.prototype[a]}if("keyDependencies" in b&&!("__dependentKeys" in b)){var c=b.keyDependencies;for(a in c){b.setKeysTriggerChangeNotificationsForDependentKey(c[a],a)}}return b};coherent.KVO.adaptTree=function(c){coherent.KVO.adapt(c);var b;var a;for(b in c){if(b in coherent.KVO.keysToIgnore){continue}a=c[b];if(!a){continue}if(coherent.typeOf(a) in coherent.KVO.typesOfKeyValuesToIgnore){continue}coherent.KVO.adaptTree(a)}return c};coherent.KVO.__subclassCreated__=function(a){var d=a.superclass.prototype;var b=a.prototype;if(d.keyDependencies===b.keyDependencies){return}var e=b.keyDependencies||{};for(var c in e){b.setKeysTriggerChangeNotificationsForDependentKey(e[c],c)}};coherent.Bindable=Class.create(coherent.KVO,{constructor:function(a){this.bindings={};this.__parameters=a;this.__context=coherent.dataModel},__createFactoryObjects:function(){var a=coherent.dataModel;var c=this.__context;coherent.dataModel=this.__context=this;var d;var b;for(d in this.__factories__){b=this[d];if(!b.__factoryFn__){continue}this[d]=b.call(this)}coherent.dataModel=a;this.__context=c},exposedBindings:[],automaticallySetupBindings:true,__relativeSource:null,bindNameToKeyPath:function(b,f,a){var c;var e;var d=this;if(!this.bindings){this.bindings={}}c=this["observe"+b.titleCase()+"Change"];if(!c){c=function(h){if(coherent.ChangeType.setting!==h.changeType){throw new InvalidArgumentError('Received invalid change type for synthesized binding observer (name="'+b+'" keyPath="'+f+'")')}var g=h.newValue;d.setValueForKey(h.newValue,b)}}if(this.bindings[b]){this.bindings[b].unbind()}if("*."==f.substr(0,2)){e=coherent.Binding.bindingFromString(f.substr(2),a)}else{e=coherent.Binding.bindingFromString(f,this.__context)}e.observerFn=c.bind(this);this.bindings[b]=e},__postConstruct:function(){if(!this.automaticallySetupBindings){return}this.__initialising=true;this.__copyParameters(this.__parameters||{});this.setupBindings();this.updateBindings();this.createObservers();delete this.__initialising},__copyParameters:function(c){var d;var a;var b=coherent.KVO.adaptTree;for(d in c){if(-1!==d.search(/Binding$/)){continue}a=c[d];if("object"===coherent.typeOf(a)&&!("addObserverForKeyPath" in a)){b(a)}this[d]=a}this.__parameters=c},bindingInfoForName:function(a){if(!this.__parameters){return null}return this.__parameters[a+"Binding"]||this.__parameters[a]},__createAutoObserver:function(c,b){var a=coherent.ChangeType.setting;return function(d){if(this.bindings[b]||a==d.changeType){return}c.apply(this,arguments)}},createObservers:function(){var e=this.exposedBindings;var a=e.length;var b;var d;var c;for(b=0;b<a;++b){c=e[b];d=this["observe"+c.titleCase()+"Change"];if(!d){continue}d=this.__createAutoObserver(d,c);this.addObserverForKeyPath(this,d,c,"__auto_observer__")}},setupBindings:function(){var e=this.exposedBindings;var c=e.length;var f;var a;var d;for(d=0;d<c;++d){a=e[d];f=this.bindingInfoForName(a);if(!f){continue}this.bindNameToKeyPath(a,f,this.__relativeSource)}},updateBindings:function(){var f=this.bindings;var e=this.exposedBindings;var c=e.length;var a;var d;for(d=0;d<c;++d){a=f[e[d]];if(!a){continue}a.update()}},unbind:function(){for(var a in this.bindings){this.bindings[a].unbind()}}});coherent.Bindable.__subclassCreated__=function(a){var c=a.superclass.prototype;var b=a.prototype;if(c.exposedBindings===b.exposedBindings){return}b.exposedBindings=c.exposedBindings.concat(b.exposedBindings)};coherent.SortDescriptor=Class.create({constructor:function(d,a,b){this.keyPath=d;this.ascending=a;this.comparisonFn=b||this.defaultCompare;var c=typeof(this.comparisonFn);if("string"!=c&&"function"!=c){throw new InvalidArgumentError("comparisonFn must be either the name of a method or a function reference")}},resolveComparisonFn:function(b){var a=this.comparisonFn;if("string"===typeof(a)){a=b[a]}if("function"!==typeof(a)){throw new TypeError("comparisonFn does not resolve to a function")}return a},compareObjects:function(c,b){if(!c.valueForKeyPath||!b.valueForKeyPath){throw new InvalidArgumentError("Objects are not Key Value compliant")}var e=c.valueForKeyPath(this.keyPath);var d=b.valueForKeyPath(this.keyPath);var a=this.resolveComparisonFn(e);return a.call(e,d)},defaultCompare:function(a){return coherent.compareValues(this,a)},reversedSortDescriptor:function(){return new coherent.SortDescriptor(this.keyPath,!this.ascending,this.comparisonFn)}});coherent.Controller=Class.create(coherent.Bindable,{constructor:function(a){this.base(a)},registerWithName:function(a){if(!a){return}this.name=a;coherent.registerModelWithName(this,a)}});coherent.Markers={MultipleValues:"ThisIsAnUniqueStringThatRepresentsMultipleValues",NoSelection:"ThisIsAnUniqueStringThatRepresentsNoSelection"};coherent.SelectionProxy=Class.create(coherent.KVO,{constructor:function(a){this.controller=a;this.mutable=true},infoForKey:function(b){var a=this.controller.selectedObjects();var c=a.infoForKey(b);c.mutable&=this.mutable;return c},infoForKeyPath:function(c){var a=this.controller.selectedObjects();var b=a.infoForKeyPath(c);b.mutable&=this.mutable;return b},translateValue:function(d){if("array"!==coherent.typeOf(d)){return d}if(1===d.length){return d[0]}var c;var a;var b=d[0];for(c=1,a=d.length;c<a;++c){if(0!==coherent.compareValues(b,d[c])){return coherent.Markers.MultipleValues}}return b},valueForKey:function(c){var b=this.controller.selectedObjects();if(0===b.length){return coherent.Markers.NoSelection}var a=b.valueForKey(c);return this.translateValue(a)},validateValueForKeyPath:function(e,f){var b=this.controller.selectedObjects();var a=b.length;var d;if(0===a){return e}var c;for(d=0;d<a;++d){c=b[d].validateValueForKeyPath(e,f);if(c instanceof coherent.Error){return c}}return c},valueForKeyPath:function(c){var b=this.controller.selectedObjects();if(0===b.length){return coherent.Markers.NoSelection}var a=b.valueForKeyPath(c);return this.translateValue(a)},setValueForKey:function(d,c){if(!this.mutable){return}var b=this.controller.selectedObjects();var a=this.valueForKey(c);b.setValueForKey(d,c);var e=this.valueForKey(c);if(a===e){return}var f=new coherent.ChangeNotification(this,coherent.ChangeType.setting,e,a);this.notifyObserversOfChangeForKeyPath(f,c)},setValueForKeyPath:function(c,f){if(!this.mutable){return}var b=this.controller.selectedObjects();var a=this.valueForKeyPath(f);b.setValueForKeyPath(c,f);var d=this.valueForKeyPath(f);if(a===d){return}var e=new coherent.ChangeNotification(this,coherent.ChangeType.setting,d,a);this.notifyObserversOfChangeForKeyPath(e,f)}});coherent.ObjectController=Class.create(coherent.Controller,{constructor:function(a){this.base(a);this.objectClass=coherent.KVO;this.__content=null;this.__editable=true;this.__selectedObjects=[];this.__selection=new coherent.SelectionProxy(this)},observeChildObjectChangeForKeyPath:function(f,e,b){this.base(f,e,b);if("selectedObjects"!==b){return}var c="selection."+e;var d=this.valueForKeyPath(c);var a=new coherent.ChangeNotification(this,coherent.ChangeType.setting,d,null);this.notifyObserversOfChangeForKeyPath(a,c)},keyDependencies:{},exposedBindings:["editable","content"],editable:function(){var a=this.__editable;if(this.bindings.content){a&=this.bindings.content.mutable()}return a},setEditable:function(a){if(this.bindings.content){a&=this.bindings.content.mutable()}if(this.bindings.editable){this.bingings.editable.setValue(a)}this.__editable=a},content:function(){return this.__content},setContent:function(a){if(this.bindings.content){this.bindings.content.setValue(a)}this.__content=a;this.willChangeValueForKey("selectedObjects");if(!a){this.__selectedObjects=[]}else{this.__selectedObjects=[a]}this.didChangeValueForKey("selectedObjects");this.forceChangeNotificationForKey("selection")},selectedObjects:function(){return this.__selectedObjects},selection:function(){return this.__selection}});window.XHR=(function(){var getTransport=function(){throw new Error("XMLHttpRequest not available.")};if(!coherent.Browser.IE){getTransport=function(){return new XMLHttpRequest()}}else{var progIdCandidates=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"];var len=progIdCandidates.length;var progId;var xhr;for(var i=0;i<len;++i){try{progId=progIdCandidates[i];xhr=new ActiveXObject(progId);getTransport=function(){return new ActiveXObject(progId)};break}catch(e){}}}function send(url,method,options){function noop(){}function cancel(){xhr.onreadystatechange=noop;xhr.abort()}function readyStateChanged(){if(4!==xhr.readyState){return}if(xhrSent===false){arguments.callee.delay(0);return}var status=xhr.status;var succeeded=(status>=200&&status<300)||304==status;if(0===status||"undefined"===typeof(status)){var protocol=window.location.protocol;succeeded="file:"===protocol||"chrome:"===protocol}var result=xhr.responseText;var err;if(succeeded){if("HEAD"==method){result={};try{var headers=xhr.getAllResponseHeaders();if(headers){headers=headers.split("\n");headers.forEach(function(header){var match=header.match(/^([^:]+):(.+)$/m);var name=match[1].trim();result[name]=match[2].trim()})}}catch(e){}}else{var contentType=options.responseContentType||xhr.getResponseHeader("Content-Type");if(contentType.match(/(?:application\/(?:x-)?json)|(?:text\/json)/)){try{result=eval("("+result+")")}catch(e){err=e;succeeded=false}}if(contentType.match(/(?:application|text)\/xml/)){result=xhr.responseXML}}}else{err=new Error("XHR request failed");err.url=url;err.method=method;err.xhr=xhr;err.status=xhr.status;err.statusText=xhr.statusText}if(succeeded){deferred.callback(result)}else{deferred.failure(err)}xhr.onreadystatechange=noop;xhr=null}var urlArgs=(url||"").split("?");if(2==urlArgs.length){url=urlArgs[0];urlArgs=Object.fromQueryString(urlArgs[1])}else{urlArgs={}}var xhr=getTransport();var args=Object.applyDefaults(options.parameters||{},urlArgs);var queryString=Object.toQueryString(args);var body=options.body||"";var async=!options.sync;var deferred=new coherent.Deferred(cancel);var xhrSent=false;method=(method||"GET").toUpperCase();if("GET"==method){url=url+"?"+queryString}if(options.user){xhr.open(method,url,async,options.user,options.password||"")}else{xhr.open(method,url,async)}var headers=options.headers||{};for(var h in headers){xhr.setRequestHeader(h,headers[h])}if("POST"==method){xhr.setRequestHeader("Content-Type",options.contentType||"application/x-www-form-urlencoded");body=queryString}if(async){xhr.onreadystatechange=readyStateChanged}xhr.send(body);xhrSent=true;if(!async){readyStateChanged()}return deferred}return{get:function(url,parameters,options){return XHR.request("GET",url,parameters,options)},post:function(url,parameters,options){return XHR.request("POST",url,parameters,options)},request:function(method,url,parameters,options){method=method.toUpperCase();options=options||{};options.parameters=parameters;return send(url,method,options)}}})();coherent.AjaxController=Class.create(coherent.ObjectController,{exposedBindings:["url"],flushContentBeforeQuery:false,constructor:function(a){this.base(a);this.addObserverForKeyPath(this,this.queryUpdated,"url");this.addObserverForKeyPath(this,this.queryUpdated,"method");this.queryDelay=500;this.url="";this.method="GET";this.setValueForKey(new coherent.KVO(),"parameters")},validateParameters:function(){return true},observeChildObjectChangeForKeyPath:function(c,b,a){this.base(c,b,a);if("parameters"===a){this.queryUpdated(c,b,a)}},queryUpdated:function(c,b,a){if(!this.parameters||!this.validateParameters()){return}this.setValueForKey(true,"queryInProgress");if(this.__queryTimer){window.clearTimeout(this.__queryTimer)}this.__queryTimer=this.performQuery.bindAndDelay(this,this.queryDelay)},performQuery:function(){var e={};var d=this.parameters.mutableKeys();var a=d.length;var f;var b;for(var c=0;c<a;++c){f=d[c];if(!this.parameters.hasOwnProperty(f)){continue}b=this.parameters[f];if(""===b||null===b||"undefined"===typeof(b)){continue}e[f]=b}this.finalParameters(e);this.__request=XHR.get(this.url,e,{responseContentType:"application/json"});this.__request.addMethods(this.querySucceeded.bind(this),this.queryFailed.bind(this));if(this.flushContentBeforeQuery){this.setContent(null)}},finalParameters:function(a){return a},extractContent:function(a){return a},querySucceeded:function(a){coherent.KVO.adaptTree(a);this.setContent(this.extractContent(a));this.setValueForKey("","statusCode");this.setValueForKey("","errorMessage");this.setValueForKey(false,"queryInProgress")},queryFailed:function(a){console.log("failure: "+this.url);this.setValueForKey(a.status,"statusCode");this.setValueForKey(a.statusText,"errorMessage");this.setContent(null);this.setValueForKey(false,"queryInProgress")}});function IndexRange(c,a){var b;var d=[];if(1==arguments.length&&c.length){a=c.length-1;c=0}for(b=c;b<=a;++b){d.push(b)}return d}coherent.ArrayController=Class.create(coherent.ObjectController,{constructor:function(a){this.base(a);this.arrangedObjects=[];this.__sortDescriptors=[];this.__filterPredicate=null;this.__selectionIndexes=[]},keyDependencies:{selectedObjects:["selectionIndexes"],selectionIndex:["selectionIndexes"],canRemove:["editable","selectionIndexes"],canAdd:["editable"]},selectsInsertedObjects:true,exposedBindings:["selectionIndexes","sortDescriptors","filterPredicate","contentForMultipleSelection"],observeContentChange:function(d){var a;var c;switch(d.changeType){case coherent.ChangeType.setting:this.setContent(d.newValue);break;case coherent.ChangeType.insertion:this._insertObjectsIntoArrangedObjects(d.newValue);if(this.selectsInsertedObjects){var b=this.selectedObjects();b=b.concat(d.newValue);this.setSelectedObjects(b)}break;case coherent.ChangeType.deletion:this.rearrangeObjects();break;case coherent.ChangeType.replacement:this.rearrangeObjects();break;default:break}},canAdd:function(){return this.editable()},add:function(){var a=new (this.objectClass)();var b=this.content();b.addObject(a)},canRemove:function(){return this.editable()&&this.selectionIndexes().length},remove:function(){var a=this.selectedObjects();var b=this.content();b.removeObjects(a)},setContent:function(a){a=a||[];if(this.bindings.content){this.bindings.content.setValue(a)}this.__content=a;this.rearrangeObjects(a)},sortDescriptors:function(){return this.__sortDescriptors},setSortDescriptors:function(a){if(this.bindings.sortDescriptors){this.bindings.sortDescriptors.setValue(a)}this.__sortDescriptors=a;this.rearrangeObjects()},filterPredicate:function(){return this.__filterPredicate},setFilterPredicate:function(a){if(this.bindings.filterPredicate){this.bindings.filterPredicate.setValue(a)}this.__filterPredicate=a;this.rearrangeObjects()},filterObjects:function(e){var f=this.filterPredicate();if(!f){return IndexRange(e)}var c=[];var d;var a;var b;for(d=0,a=e.length;d<a;++d){b=e[d];if(f(b)){c.push(d)}}return c},_compareObjects:function(f,e){var d;var b;var c=this.sortDescriptors();var a=c.length;for(d=0;d<a;++d){b=c[d].compareObjects(f,e);if(!c[d].ascending){b*=-1}if(0!==b){return b>0?1:-1}}return 0},sortObjects:function(d,b){b=b||IndexRange(d);var c=this.sortDescriptors();var e=c.length;function a(m,l){var i;var g;var k=d[m];var j=d[l];var f=e;var h=c;for(i=0;i<f;++i){g=h[i].compareObjects(k,j);if(!h[i].ascending){g*=-1}if(0!==g){return g}}return 0}if(0!==c.length){b.sort(a)}return b},arrangeObjects:function(e){var c=this.filterObjects(e);c=this.sortObjects(e,c);if(e===this.content()){var d=[];var a=c.length;for(var b=0;b<a;++b){d[c[b]]=b}this.__contentToArrangedMap=d;this.__arrangedToContentMap=c}return e.objectsAtIndexes(c)},rearrangeObjects:function(d){var g=d||this.content()||[];var c=this.arrangeObjects(g);var b=this.selectedObjects();var e=[];var a=b.length;var h;var f;for(f=0;f<a;++f){h=c.indexOf(b[f]);if(-1!==h){e.push(h)}}this.setValueForKey(c,"arrangedObjects");this.setValueForKey(e,"selectionIndexes")},_insertObjectsIntoArrangedObjects:function(a){var h=this.arrangeObjects(a);var k=h.length;var b=this.arrangedObjects;var f=b.length;var g=[];var j=0;var d;var c;var e;g.length=k;for(e=0;e<k;++e){d=h[e];while(j<f){c=b[j];if(-1===this._compareObjects(d,c)){break}++j}g[e]=j+e}b.insertObjectsAtIndexes(h,g)},selectedObjects:function(){return this.__selectedObjects},setSelectedObjects:function(b){var c=[];var e;var d;var a=this.arrangedObjects;for(e=0;e<b.length;++e){d=a.indexOf(b[e]);if(-1===d){continue}c.push(d)}return this.setSelectionIndexes(c)},selectionIndexes:function(){return this.__selectionIndexes},setSelectionIndexes:function(b){b=b||[];b.sort();if(0===(this.selectionIndexes()||[]).compare(b)){return false}if(this.bindings.selectionIndexes){this.bindings.selectionIndexes.setValue(b)}this.__selectionIndexes=b;var a=this.arrangedObjects;this.__selectedObjects=a.objectsAtIndexes(b);this.forceChangeNotificationForKey("selection");return true},setSelectionIndex:function(b){var a=this.setSelectionIndexes([b]);return a},selectionIndex:function(){var a=this.selectionIndexes();if(0===a.length){return -1}return a[0]}});coherent.ModelController=Class.create(coherent.Controller,{constructor:function(b,a){if(!("addObserverForKeyPath" in b)){coherent.KVO.adaptTree(b)}function c(d){this.setValueForKey(b[d],d)}b.mutableKeys().forEach(c,this);this.base(a)}});Object.extend(coherent,{dataModel:new coherent.KVO(),registerModelWithName:function(b,a){coherent.dataModel.setValueForKey(b,a)},unregisterModelWithName:function(a){delete coherent.dataModel[a]}});coherent.ValueTransformer=Class.create({transformedValue:function(a){return a},reverseTransformedValue:function(a){return a},__factory__:function(){var b=Array.from(arguments);var a=this;function c(){}return function(){c.prototype=a.prototype;var d=new c();a.prototype.constructor.apply(d,b);return d}}});coherent.ValueTransformer.__subclassCreated__=function(a){var c=coherent.ValueTransformer.prototype;var b=a.prototype;if(c.reverseTransformedValue==b.reverseTransformedValue){a.prototype.reverseTransformedValue=null}};coherent.transformer={};coherent.transformerInstances={};coherent.findTransformerWithName=function(transformerName){var valueTransformer=coherent.transformerInstances[transformerName.toLowerCase()];if(valueTransformer){return valueTransformer}if(-1===transformerName.indexOf(".")){valueTransformer=coherent.transformer[transformerName]}else{try{valueTransformer=eval(transformerName)}catch(e){}}valueTransformer=valueTransformer&&new valueTransformer();if(valueTransformer){return valueTransformer}throw new InvalidArgumentError("The transformerName argument does not specify a valid ValueTransformer: "+transformerName)};coherent.registerTransformerWithName=function(b,a){if(!b.transformedValue){throw new InvalidArgumentError("The valueTransformer argument does not support the ValueTransformer method transformedValue")}a=a.toLowerCase();coherent.transformerInstances[a]=b};coherent.transformer.Not=Class.create(coherent.ValueTransformer,{transformedValue:function(a){return(a?false:true)},reverseTransformedValue:function(a){return !!a}});coherent.registerTransformerWithName(new coherent.transformer.Not(),"not");coherent.transformer.Boolean=Class.create(coherent.ValueTransformer,{constructor:function(a,b){this.trueValue=a;this.falseValue=b},transformedValue:function(a){return(a==this.trueValue)},reverseTransformedValue:function(a){return(a?this.trueValue:this.falseValue)}});coherent.transformer.Matches=Class.create(coherent.ValueTransformer,{constructor:function(a){this.trueRegex=a},transformedValue:function(a){return this.trueRegex.test(a)}});coherent.transformer.Generic=Class.create(coherent.ValueTransformer,{constructor:function(a,b){this.modelValues=a;this.displayValues=b},transformedValue:function(b){var a=this.modelValues.indexOf(b);var c;if(-1==a){return c}else{return this.displayValues[a]}},reverseTransformedValue:function(b){var a=this.displayValues.indexOf(b);var c;if(-1==a){return c}else{return this.modelValues[a]}}});coherent.transformer.Truncated=Class.create(coherent.ValueTransformer,{constructor:function(a){this.max=a||50},ellipsis:String.fromCharCode(8230),transformedValue:function(c){if(!c&&0!==c){return c}c=""+c;var a=c.length;if(a<=this.max){return c}var b=this.max/2-2;return[c.substr(0,b),this.ellipsis,c.substr(a-b)].join(" ")}});coherent.registerTransformerWithName(new coherent.transformer.Truncated(50),"truncated");coherent.transformer.StringsToObjects=Class.create(coherent.ValueTransformer,{constructor:function(a){this.key=a||"string"},transformedValue:function(b){if(!b||!b.map){return b}function a(c){var d=new coherent.KVO();d[this.key]=c;return d}return b.map(a,this)},reverseTransformedValue:function(b){if(!b||!b.map){return b}function a(c){return c[this.key]}return b.map(a,this)}});coherent.registerTransformerWithName(new coherent.transformer.StringsToObjects("string"),"StringsToObjects");
/*
 * Sizzle CSS Selector Engine - v1.0
 *  Copyright 2009, The Dojo Foundation
 *  Released under the MIT, BSD, and GPL Licenses.
 *  More information: http://sizzlejs.com/
 */
/*
 * ATTENTION: This file has been modified to remove all handling of XML
 */
(function(){var q=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,j=0,d=Object.prototype.toString,l=Array.prototype.splice,n=Array.prototype.push,i=Array.prototype.sort;var b=function(w,s,z,A){z=z||[];var C=s=s||document;if(s.nodeType!==1&&s.nodeType!==9){return[]}if(!w||typeof w!=="string"){return z}var x=[],u,E,H,e,B,t,v=true;q.lastIndex=0;while((u=q.exec(w))!==null){x.push(u[1]);if(u[2]){t=RegExp.rightContext;break}}if(x.length>1&&k.exec(w)){if(x.length===2&&f.relative[x[0]]){E=g(x[0]+x[1],s)}else{E=f.relative[x[0]]?[s]:b(x.shift(),s);while(x.length){w=x.shift();if(f.relative[w]){w+=x.shift()}E=g(w,E)}}}else{if(!A&&x.length>1&&s.nodeType===9&&f.match.ID.test(x[0])&&!f.match.ID.test(x[x.length-1])){var D=b.find(x.shift(),s);s=D.expr?b.filter(D.expr,D.set)[0]:D.set[0]}if(s){var D=A?{expr:x.pop(),set:a(A)}:b.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&s.parentNode?s.parentNode:s);E=D.expr?b.filter(D.expr,D.set):D.set;if(x.length>0){H=a(E)}else{v=false}while(x.length){var G=x.pop(),F=G;if(!f.relative[G]){G=""}else{F=x.pop()}if(F==null){F=s}f.relative[G](H,F)}}else{H=x=[]}}if(!H){H=E}if(!H){throw"Syntax error, unrecognized expression: "+(G||w)}if(d.call(H)==="[object Array]"){if(!v){n.apply(z,H)}else{if(s&&s.nodeType===1){for(var y=0;H[y]!=null;y++){if(H[y]&&(H[y]===true||H[y].nodeType===1&&h(s,H[y]))){n.call(z,E[y])}}}else{for(var y=0;H[y]!=null;y++){if(H[y]&&H[y].nodeType===1){n.call(z,E[y])}}}}}else{a(H,z)}if(t){b(t,C,z,A);b.uniqueSort(z)}return z};b.uniqueSort=function(s){if(c){hasDuplicate=false;i.call(s,c);if(hasDuplicate){for(var e=1;e<s.length;e++){if(s[e]===s[e-1]){l.call(s,e--,1)}}}}};b.matches=function(e,s){return b(e,null,null,s)};b.find=function(x,u){var y,s;if(!x){return[]}for(var t=0,e=f.order.length;t<e;t++){var v=f.order[t],s;if((s=f.match[v].exec(x))){var w=RegExp.leftContext;if(w.substr(w.length-1)!=="\\"){s[1]=(s[1]||"").replace(/\\/g,"");y=f.find[v](s,u);if(y!=null){x=x.replace(f.match[v],"");break}}}}if(!y){y=u.getElementsByTagName("*")}return{set:y,expr:x}};b.filter=function(A,z,D,u){var t=A,F=[],x=z,w,e;while(A&&z.length){for(var y in f.filter){if((w=f.match[y].exec(A))!=null){var s=f.filter[y],E,C;e=false;if(x==F){F=[]}if(f.preFilter[y]){w=f.preFilter[y](w,x,D,F,u);if(!w){e=E=true}else{if(w===true){continue}}}if(w){for(var v=0;(C=x[v])!=null;v++){if(C){E=s(C,w,v,x);var B=u^!!E;if(D&&E!=null){if(B){e=true}else{x[v]=false}}else{if(B){F.push(C);e=true}}}}}if(E!==undefined){if(!D){x=F}A=A.replace(f.match[y],"");if(!e){return[]}break}}}if(A==t){if(e==null){throw"Syntax error, unrecognized expression: "+A}else{break}}t=A}return x};var f=b.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(e){return e.getAttribute("href")}},relative:{"+":function(x,s){var u=typeof s==="string",w=u&&!/\W/.test(s),y=u&&!w;if(w){s=s.toUpperCase()}for(var t=0,e=x.length,v;t<e;t++){if((v=x[t])){while((v=v.previousSibling)&&v.nodeType!==1){}x[t]=y||v&&v.nodeName===s?v||false:v===s}}if(y){b.filter(s,x,true)}},">":function(x,s){var v=typeof s==="string";if(v&&!/\W/.test(s)){s=s.toUpperCase();for(var t=0,e=x.length;t<e;t++){var w=x[t];if(w){var u=w.parentNode;x[t]=u.nodeName===s?u:false}}}else{for(var t=0,e=x.length;t<e;t++){var w=x[t];if(w){x[t]=v?w.parentNode:w.parentNode===s}}if(v){b.filter(s,x,true)}}},"":function(u,s){var t=j++,e=r;if(!s.match(/\W/)){var v=s=s.toUpperCase();e=p}e("parentNode",s,t,u,v)},"~":function(u,s){var t=j++,e=r;if(typeof s==="string"&&!s.match(/\W/)){var v=s=s.toUpperCase();e=p}e("previousSibling",s,t,u,v)}},find:{ID:function(s,t){if(typeof t.getElementById!=="undefined"){var e=t.getElementById(s[1]);return e?[e]:[]}},NAME:function(t,w){if(typeof w.getElementsByName!=="undefined"){var s=[],v=w.getElementsByName(t[1]);for(var u=0,e=v.length;u<e;u++){if(v[u].getAttribute("name")===t[1]){s.push(v[u])}}return s.length===0?null:s}},TAG:function(e,s){return s.getElementsByTagName(e[1])}},preFilter:{CLASS:function(u,s,t,e,x){u=" "+u[1].replace(/\\/g,"")+" ";for(var v=0,w;(w=s[v])!=null;v++){if(w){if(x^(w.className&&(" "+w.className+" ").indexOf(u)>=0)){if(!t){e.push(w)}}else{if(t){s[v]=false}}}}return false},ID:function(e){return e[1].replace(/\\/g,"")},TAG:function(s,e){return s[1].toUpperCase()},CHILD:function(e){if(e[1]=="nth"){var s=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(e[2]=="even"&&"2n"||e[2]=="odd"&&"2n+1"||!/\D/.test(e[2])&&"0n+"+e[2]||e[2]);e[2]=(s[1]+(s[2]||1))-0;e[3]=s[3]-0}e[0]=j++;return e},ATTR:function(v,s,t,e,w){var u=v[1].replace(/\\/g,"");if(f.attrMap[u]){v[1]=f.attrMap[u]}if(v[2]==="~="){v[4]=" "+v[4]+" "}return v},PSEUDO:function(v,s,t,e,w){if(v[1]==="not"){if(v[3].match(q).length>1||/^\w/.test(v[3])){v[3]=b(v[3],null,null,s)}else{var u=b.filter(v[3],s,t,true^w);if(!t){e.push.apply(e,u)}return false}}else{if(f.match.POS.test(v[0])||f.match.CHILD.test(v[0])){return true}}return v},POS:function(e){e.unshift(true);return e}},filters:{enabled:function(e){return e.disabled===false&&e.type!=="hidden"},disabled:function(e){return e.disabled===true},checked:function(e){return e.checked===true},selected:function(e){e.parentNode.selectedIndex;return e.selected===true},parent:function(e){return !!e.firstChild},empty:function(e){return !e.firstChild},has:function(t,s,e){return !!b(e[3],t).length},header:function(e){return/h\d/i.test(e.nodeName)},text:function(e){return"text"===e.type},radio:function(e){return"radio"===e.type},checkbox:function(e){return"checkbox"===e.type},file:function(e){return"file"===e.type},password:function(e){return"password"===e.type},submit:function(e){return"submit"===e.type},image:function(e){return"image"===e.type},reset:function(e){return"reset"===e.type},button:function(e){return"button"===e.type||e.nodeName.toUpperCase()==="BUTTON"},input:function(e){return/input|select|textarea|button/i.test(e.nodeName)}},setFilters:{first:function(s,e){return e===0},last:function(t,s,e,u){return s===u.length-1},even:function(s,e){return e%2===0},odd:function(s,e){return e%2===1},lt:function(t,s,e){return s<e[3]-0},gt:function(t,s,e){return s>e[3]-0},nth:function(t,s,e){return e[3]-0==s},eq:function(t,s,e){return e[3]-0==s}},filter:{PSEUDO:function(x,t,u,y){var s=t[1],v=f.filters[s];if(v){return v(x,u,t,y)}else{if(s==="contains"){return(x.textContent||x.innerText||"").indexOf(t[3])>=0}else{if(s==="not"){var w=t[3];for(var u=0,e=w.length;u<e;u++){if(w[u]===x){return false}}return true}}}},CHILD:function(e,u){var x=u[1],s=e;switch(x){case"only":case"first":while(s=s.previousSibling){if(s.nodeType===1){return false}}if(x=="first"){return true}s=e;case"last":while(s=s.nextSibling){if(s.nodeType===1){return false}}return true;case"nth":var t=u[2],A=u[3];if(t==1&&A==0){return true}var w=u[0],z=e.parentNode;if(z&&(z.sizcache!==w||!e.nodeIndex)){var v=0;for(s=z.firstChild;s;s=s.nextSibling){if(s.nodeType===1){s.nodeIndex=++v}}z.sizcache=w}var y=e.nodeIndex-A;if(t==0){return y==0}else{return(y%t==0&&y/t>=0)}}},ID:function(s,e){return s.nodeType===1&&s.getAttribute("id")===e},TAG:function(s,e){return(e==="*"&&s.nodeType===1)||s.nodeName===e},CLASS:function(s,e){return(" "+(s.className||s.getAttribute("class"))+" ").indexOf(e)>-1},ATTR:function(w,u){var t=u[1],e=f.attrHandle[t]?f.attrHandle[t](w):w[t]!=null?w[t]:w.getAttribute(t),x=e+"",v=u[2],s=u[4];return e==null?v==="!=":v==="="?x===s:v==="*="?x.indexOf(s)>=0:v==="~="?(" "+x+" ").indexOf(s)>=0:!s?x&&e!==false:v==="!="?x!=s:v==="^="?x.indexOf(s)===0:v==="$="?x.substr(x.length-s.length)===s:v==="|="?x===s||x.substr(0,s.length+1)===s+"-":false},POS:function(v,s,t,w){var e=s[2],u=f.setFilters[e];if(u){return u(v,t,s,w)}}}};var k=f.match.POS;for(var o in f.match){f.match[o]=new RegExp(f.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var a=function(s,e){s=Array.prototype.slice.call(s);if(e){n.apply(e,s);return e}return s};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(m){a=function(v,u){var s=u||[];if(d.call(v)==="[object Array]"){Array.prototype.push.apply(s,v)}else{if(typeof v.length==="number"){for(var t=0,e=v.length;t<e;t++){s.push(v[t])}}else{for(var t=0;v[t];t++){s.push(v[t])}}}return s}}var c;if(document.documentElement.compareDocumentPosition){c=function(s,e){var t=s.compareDocumentPosition(e)&4?-1:s===e?0:1;if(t===0){hasDuplicate=true}return t}}else{if("sourceIndex" in document.documentElement){c=function(s,e){var t=s.sourceIndex-e.sourceIndex;if(t===0){hasDuplicate=true}return t}}else{if(document.createRange){c=function(u,s){var t=u.ownerDocument.createRange(),e=s.ownerDocument.createRange();t.selectNode(u);t.collapse(true);e.selectNode(s);e.collapse(true);var v=t.compareBoundaryPoints(Range.START_TO_END,e);if(v===0){hasDuplicate=true}return v}}}}(function(){var s=document.createElement("form"),t="script"+(new Date).getTime();s.innerHTML="<input name='"+t+"'/>";var e=document.documentElement;e.insertBefore(s,e.firstChild);if(!!document.getElementById(t)){f.find.ID=function(v,w){if(typeof w.getElementById!=="undefined"){var u=w.getElementById(v[1]);return u?u.id===v[1]||typeof u.getAttributeNode!=="undefined"&&u.getAttributeNode("id").nodeValue===v[1]?[u]:undefined:[]}};f.filter.ID=function(w,u){var v=typeof w.getAttributeNode!=="undefined"&&w.getAttributeNode("id");return w.nodeType===1&&v&&v.nodeValue===u}}e.removeChild(s)})();(function(){var e=document.createElement("div");e.appendChild(document.createComment(""));if(e.getElementsByTagName("*").length>0){f.find.TAG=function(s,w){var v=w.getElementsByTagName(s[1]);if(s[1]==="*"){var u=[];for(var t=0;v[t];t++){if(v[t].nodeType===1){u.push(v[t])}}v=u}return v}}e.innerHTML="<a href='#'></a>";if(e.firstChild&&typeof e.firstChild.getAttribute!=="undefined"&&e.firstChild.getAttribute("href")!=="#"){f.attrHandle.href=function(s){return s.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var e=b,t=document.createElement("div");t.innerHTML="<p class='TEST'></p>";if(t.querySelectorAll&&t.querySelectorAll(".TEST").length===0){return}b=function(x,w,u,v){w=w||document;if(!v&&w.nodeType===9){try{return a(w.querySelectorAll(x),u)}catch(y){}}return e(x,w,u,v)};for(var s in e){b[s]=e[s]}})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var e=document.createElement("div");e.innerHTML="<div class='test e'></div><div class='test'></div>";if(e.getElementsByClassName("e").length===0){return}e.lastChild.className="e";if(e.getElementsByClassName("e").length===1){return}f.order.splice(1,0,"CLASS");f.find.CLASS=function(s,t){if(typeof t.getElementsByClassName!=="undefined"){return t.getElementsByClassName(s[1])}}})()}function p(s,x,w,A,y){var z=s=="previousSibling";for(var u=0,t=A.length;u<t;u++){var e=A[u];if(e){if(z&&e.nodeType===1){e.sizcache=w;e.sizset=u}e=e[s];var v=false;while(e){if(e.sizcache===w){v=A[e.sizset];break}if(e.nodeType===1){e.sizcache=w;e.sizset=u}if(e.nodeName===x){v=e;break}e=e[s]}A[u]=v}}}function r(s,x,w,A,y){var z=s=="previousSibling";for(var u=0,t=A.length;u<t;u++){var e=A[u];if(e){if(z&&e.nodeType===1){e.sizcache=w;e.sizset=u}e=e[s];var v=false;while(e){if(e.sizcache===w){v=A[e.sizset];break}if(e.nodeType===1){e.sizcache=w;e.sizset=u;if(typeof x!=="string"){if(e===x){v=true;break}}else{if(b.filter(x,[e]).length>0){v=e;break}}}e=e[s]}A[u]=v}}}var h=document.compareDocumentPosition?function(s,e){return s.compareDocumentPosition(e)&16}:function(s,e){return s!==e&&(s.contains?s.contains(e):true)};var g=function(e,y){var u=[],v="",w,t=y.nodeType?[y]:y;while((w=f.match.PSEUDO.exec(e))){v+=w[0];e=e.replace(f.match.PSEUDO,"")}e=f.relative[e]?e+"*":e;for(var x=0,s=t.length;x<s;x++){b(e,t[x],u)}return b.filter(v,u)};window.Sizzle=b})();(function(){var a=this.Element;this.Element={};Object.extend(this.Element,a||{})}).call(window);Object.extend(Element,{uniqueId:function(){return"coherent_id_"+Element.assignId.uniqueId++},assignId:function(a){return a.id||(a.id=("coherent_id_"+Element.assignId.uniqueId++))},regexForClassName:function(b){var a=arguments.callee;if(!a._lookup){a._lookup={}}if(b in a._lookup){return a._lookup[b]}return(a._lookup[b]=new RegExp("(^|\\s)"+b+"(\\s|$)"))},hasClassName:function(a,b){var c=a.className;if(!c){return false}if(c==b){return true}return Element.regexForClassName(b).test(c)},addClassName:function(a,b){if(!b){return}if(Element.hasClassName(a,b)){return}a.className+=" "+b},removeClassName:function(a,b){if(!a||!b){return}var c=Element.regexForClassName(b);a.className=a.className.replace(c," ").trim()},replaceClassName:function(b,c,a){if(!c){return}if(!a){Element.removeClassName(b,c);return}var d=Element.regexForClassName(c);b.className=b.className.replace(d,"$1"+a+"$2").trim()},toggleClassName:function(a,b){if(!b){return}var c=Element.regexForClassName(b);var d=a.className;if(c.test(d)){a.className=d.replace(c," ").trim()}else{a.className+=" "+b}},updateClass:function(f,g,c){var e=$S(f.className.split(" "));var h=Set.add;var b=Set.remove;var d;var a;if("string"===typeof(g)){h(e,g)}else{for(d=0,a=g.length;d<a;++d){h(e,g[d])}}if("string"===typeof(c)){b(e,c)}else{for(d=0,a=c.length;d<a;++d){b(e,c[d])}}f.className=Set.join(e," ")},PROPERTIES:["backgroundColor","backgroundPosition","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","color","display","fontSize","letterSpacing","lineHeight","opacity","width","height","top","bottom","left","right","marginTop","marginRight","marginBottom","marginLeft","paddingTop","paddingRight","paddingBottom","paddingLeft"],getStyles:function(e,d){var f={};var b=window.getComputedStyle(e,null);if("string"===typeof(d)){return e.style[d]||b[d]||null}d=d||Element.PROPERTIES;var g;var a=d.length;for(var c=0;c<a;++c){g=d[c];f[g]=e.style[g]||b[g]||null}return f},setStyle:function(a,b,c){a.style[b]=c},setStyles:function(a,b){var c=a.style;for(var d in b){c[d]=b[d]}},getDimensions:function(e){var g=Element.getStyle(e,"display");if(g&&g!="none"){return{left:e.offsetLeft,top:e.offsetTop,width:e.offsetWidth,height:e.offsetHeight}}var b=e.style;var f=b.visibility;var c=b.position;var a=b.display;b.visibility="hidden";b.position="absolute";b.display="block";var d={width:e.offsetWidth,height:e.offsetHeight,left:e.offsetLeft,top:e.offsetTop};b.display=a;b.position=c;b.visibility=f;return d},clone:function(a){return a.cloneNode(true)},depthFirstTraversal:function(d,e,c){if(!d||!e){return}var a=d.nextSibling||d.parentNode;var b;c=c||e;while(d!==a){if(1===d.nodeType){b=e.call(c,d);if(false!==b&&d.firstChild){d=d.firstChild;continue}}while(!d.nextSibling){d=d.parentNode;if(d===a){return}}d=d.nextSibling}},query:function(b,a){if(1==arguments.length){a=b;b=document}else{if(b!=document){a="#"+Element.assignId(b)+" "+a}}return b.querySelector(a)},queryAll:function(b,a){if(1==arguments.length){a=b;b=document}else{if(b!=document){a="#"+Element.assignId(b)+" "+a}}return Array.from(b.querySelectorAll(a))},match:function(b,a){return Sizzle.matches(a,[b]).length==1},getViewport:function(){var b=document.documentElement;var a=document.body;return{left:window.scrollLeft||b.scrollLeft||a.scrollLeft,top:window.scrollTop||b.scrollTop||a.scrollTop,width:window.innerWidth||b.clientWidth||a.clientWidth,height:window.innerHeight|b.clientHeight||a.clientHeight}},scrollParent:function(d){var c;var b=Element.getStyles;var a=document.body;while(d&&d!=a){c=b(d,["overflow","overflowX","overflowY"]);if(("visible"!==c.overflowX||"visible"!==c.overflowY)||"visible"!==c.overflow){return d}d=d.parentNode}return d},getRect:function(p,n){if(!p){return null}var r=document.documentElement;var m=document.body;var d=0;var o=0;if(p!=document.body&&p.getBoundingClientRect){var l=p.getBoundingClientRect();l={left:l.left,right:l.right,top:l.top,bottom:l.bottom};if(!!n===false){l.left+=Math.max(r.scrollLeft,m.scrollLeft);l.right+=Math.max(r.scrollLeft,m.scrollLeft);l.top+=Math.max(r.scrollTop,m.scrollTop);l.bottom+=Math.max(r.scrollTop,m.scrollTop)}l.left-=r.clientLeft;l.right-=r.clientLeft;l.top-=r.clientTop;l.bottom-=r.clientTop;l.width=l.right-l.left+1;l.height=l.bottom-l.top+1;return l}var j=p.parentNode;var f=p;var a=p.offsetParent;var k=coherent.Browser.Mozilla;var q=coherent.Browser.Safari&&!coherent.Browser.Safari2;var b=coherent.Browser.Safari2;var h=Element.getStyles;var g=Element.getDimensions(p);var c=("fixed"===Element.getStyles(p,"position"));var i;d+=p.offsetLeft;o+=p.offsetTop;while(!c&&a){d+=a.offsetLeft;o+=a.offsetTop;if(k&&!((/^t(able|d|h)$/i).test(a.tagName))||q){i=h(a,["borderLeftWidth","borderTopWidth"]);d+=parseInt(i.borderLeftWidth||0,10);o+=parseInt(i.borderTopWidth||0,10)}if(!c){c=("fixed"===h(a,"position"))}if("BODY"!==a.tagName){f=a}a=a.offsetParent}var e=k?["display","overflow","borderLeftWidth","borderTopWidth"]:["display"];while(j&&j.tagName&&"BODY"!==j.tagName&&"HTML"!==j.tagName){i=h(j,e);if(!((/^inline|table.*$/i).test(i.display))){d-=j.scrollLeft;o-=j.scrollTop}if(k&&"visible"!=i.overflow){d+=parseInt(i.borderLeftWidth||0,10);o+=parseInt(i.borderTopWidth||0,10)}j=j.parentNode}var s=h(f,"position");if((b&&(c||s=="absolute"))||(k&&s!="absolute")){d-=m.offsetLeft;o-=m.offsetTop}if(n===true&&!c){d-=Math.max(r.scrollLeft,m.scrollLeft);o-=Math.max(r.scrollTop,m.scrollTop)}return{left:d,top:o,right:d+g.width-1,bottom:o+g.height-1,width:g.width,height:g.height}}});Element.getStyle=Element.getStyles;Element.assignId.uniqueId=1;Object.extend(Element,{query:function(b,a){if(1==arguments.length){a=b;b=document}return(Sizzle(a,b)[0]||null)},queryAll:function(b,a){if(1==arguments.length){a=b;b=document}return(Sizzle(a,b)||null)}});(function(){var a=this.Event;this.Event={};Object.extend(this.Event,a||{})}).call(window);Object.extend(Event,{KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,KEY_INSERT:45,_domHasFinishedLoading:function(){if(arguments.callee.done){return}arguments.callee.done=true;if(this._domLoadedTimer){window.clearInterval(this._domLoadedTimer)}var c=Event._readyCallbacks;var a=c.length;var b;for(b=0;b<a;++b){c[b]()}Event._readyCallbacks=null},observe:function(c,a,b){if("on"==a.slice(0,2)){a=a.slice(2)}c.addEventListener(a,b,false)},stopObserving:function(c,a,b){if("on"==a.slice(0,2)){a=a.slice(2)}c.removeEventListener(a,b,false)},stop:function(a){a.preventDefault();a.stopPropagation()},preventDefault:function(a){a.preventDefault()},onDomReady:function(a){if(Event._domHasFinishedLoading.done){window.setTimeout(a,0);return}if(!Event._readyCallbacks){document.addEventListener("DOMContentLoaded",Event._domHasFinishedLoading,false);function b(){if((/loaded|complete/).test(document.readyState)){Event._domHasFinishedLoading()}}if(coherent.Browser.Safari){Event._domLoadedTimer=window.setInterval(b,10)}Event.observe(window,"load",Event._domHasFinishedLoading);Event._readyCallbacks=[]}Event._readyCallbacks.push(a)}});coherent.PartFinder=(function(){function c(g,e){var h=g.length;var d=Array.from(e);function i(){g=[];d=null;h=0}function m(p){g.splice(p,1);if(d){d.splice(p,1)}h=g.length}function f(p){var r=Element.assignId(p);var q=g.indexOf(r);if(-1==q){return}g.splice(q,1);if(d){d.splice(q,1)}h=g.length}function o(r,q){var p=Element.assignId(r);g.splice(q,0,p);if(d){d.splice(q,0,r)}h=g.length}function n(p){g.push(Element.assignId(p));h=g.length;if(d){d.push(p)}}function k(){d=null}function j(){var r=[];var p;for(var q=0;q<h;++q){p=document.getElementById(g[q]);if(!p){continue}r.push(g[q])}g=r;h=r.length;d=null}function l(r){if(d){if(1==arguments.length){return d[r]}return d}if(1==arguments.length){return document.getElementById(g[r])}var p=[];for(var q=0;q<h;++q){p[q]=document.getElementById(g[q])}d=p;window.setTimeout(k,250);return p}if(e){window.setTimeout(k,250)}l.removePartAtIndex=m;l.removePart=f;l.insertPartAtIndex=o;l.add=n;l.removeAll=i;l.refresh=j;return l}function a(g,e){var d=e;function f(){d=null}function h(){if(d){return d}d=document.getElementById(g);window.setTimeout(f,250);return d}return h}function b(e,d){var f=Element.queryAll(e,d);var g=Array.map(f,Element.assignId);return{nodes:f,ids:g}}return{singlePart:function(e,d){function f(){var k=d;var g=typeof(k);if("function"===g){k=k()}else{if("string"===g){k=document.getElementById(k)}else{if(!k){k=this.viewElement()}}}var h=b(k,e);var j=a(h.ids[0],h.nodes[0]);var i=Class.findPropertyName(this,arguments.callee);if(i){this[i]=j}return h.nodes[0]}return f},multipleParts:function(e,d){function f(i){var l=d;var g=typeof(l);if("function"===g){l=l()}else{if("string"===g){l=document.getElementById(l)}else{if(!l){l=this.viewElement()}}}var h=b(l,e);var k=c(h.ids,h.nodes);var j=Class.findPropertyName(this,arguments.callee);if(j){this[j]=k}if(arguments.length){return h.nodes[i]}else{return Array.from(h.nodes)}}return f}}})();var Part=coherent.PartFinder.singlePart;var PartList=coherent.PartFinder.multipleParts;coherent.Style={kSelectedClass:"selected",kDisabledClass:"disabled",kReadOnlyClass:"read-only",kMarkerClass:"nullValue",kFocusClass:"focused",kHoverClass:"hover",kAscendingClass:"asc",kDescendingClass:"desc",kActiveClass:"active",kUpdatingClass:"updating",kFadingClass:"invisible",kInvalidValueClass:"invalid",kInsertedClass:"inserted",kDeletedClass:"deleted",kReplacingClass:"replacing",kLoadingClass:"loading",kFirstClass:"first",kLastClass:"last"};coherent.Style.__styles=(function(){var a=[];var b=coherent.Style;for(var c in b){a.push(b[c])}return a})();coherent.setupSelectors=function(b,h,e){b=b||document.body;var a;var d;var g;var c=Element.queryAll;function f(j){for(var i in g){j.setAttribute(i,g[i])}}for(a in h){d=c(b,a);g=h[a];Array.forEach(d,f)}coherent.View.createViewsForNodeTree(b,e)};window.FIRST_RESPONDER="__first_responder__";coherent.Responder=Class.create(coherent.Bindable,{sendActionToView:function(b,a){if(FIRST_RESPONDER===a){a=coherent.page.firstResponder}var c=a||coherent.page.firstResponder||this;while(c){if(b in c){c[b](this);return true}c=c.nextResponder()}return false},acceptsFirstResponder:function(){return false},becomeFirstResponder:function(){return true},resignFirstResponder:function(){return true},nextResponder:function(){return this.__nextResponder||null},setNextResponder:function(a){this.__nextResponder=a},presentError:function(b){this.willPresentError(b);if(!("field" in b)){b.field=this}var a=this.nextResponder();if(a){return a.presentError(b)}return false},clearAllErrors:function(b){var a=this.nextResponder();if(a){a.clearAllErrors(b||this)}},willPresentError:function(a){},onmousedown:function(a){var b=this.nextResponder();if(b){b.onmousedown(a)}},onmouseup:function(a){var b=this.nextResponder();if(b){b.onmouseup(a)}},onmousedrag:function(a){var b=this.nextResponder();if(b){b.onmousedrag(a)}},onmouseenter:function(a){var b=this.nextResponder();if(b){b.onmouseenter(a)}},onmouseleave:function(a){var b=this.nextResponder();if(b){b.onmouseleave(a)}},onclick:function(a){var b=this.nextResponder();if(b){b.onclick(a)}},ondblclick:function(a){var b=this.nextResponder();if(b){b.ondblclick(a)}},onkeydown:function(a){var b=this.nextResponder();if(b){b.onkeydown(a)}},onkeyup:function(a){var b=this.nextResponder();if(b){b.onkeyup(a)}},onkeypress:function(a){var b=this.nextResponder();if(b){b.onkeypress(a)}},ontouchstart:function(a){var b=this.nextResponder();if(b){b.ontouchstart(a)}},ontouchmove:function(a){var b=this.nextResponder();if(b){b.ontouchmove(a)}},ontouchend:function(a){var b=this.nextResponder();if(b){b.ontouchend(a)}}});coherent.View=Class.create(coherent.Responder,{__viewClassName__:"View",__tagSpec__:["div","b","strong","em","i","q","p","span","li","h1","h2","h3","h4","td","label"],multipleValuesPlaceholder:_("marker.text.multipleValues"),nullPlaceholder:_("marker.text.placeholder"),noSelectionPlaceholder:_("marker.text.noSelection"),exposedBindings:["visible","class","enabled","editable","html","text"],automaticallySetupBindings:false,requireBindingsForInferredViewType:true,formatter:null,target:null,action:null,sendActionOn:["click"],animated:false,updateAnimationDuration:0,updateAnimationDelay:0,postUpdateAnimationDuration:0,postUpdateAnimationDelay:0,preUpdateAnimationDuration:0,preUpdateAnimationDelay:0,constructor:function(a,b,c){this.base(c);if("string"===typeof(a)){this.id=a;this.__view=document.getElementById(a)}else{this.id=Element.assignId(a);this.__view=a}if(b&&!("addObserverForKeyPath" in b)){coherent.KVO.adaptTree(b)}this.__relativeSource=b;if(this.id in coherent.View.viewLookup){throw new Error("Two views share the same ID: "+this.id)}this.__updating=null;coherent.View.viewLookup[this.id]=this},__postConstruct:function(){var b=this;function c(){delete b.__view;delete b.__container}c.delay(250);var a=this.viewElement();if(a){this.__init()}else{Event.onDomReady(this.__init.bind(this))}},__init:function(){this.__initialising=true;var f=this.viewElement();if(!f){throw new Error("Unable to locate node with ID: "+this.id)}this.viewElement=function(){return f};var g;var a;if("true"===f.getAttribute("animated")){this.animated=true}var b=f.getAttribute("__parametersId");var h=this.__parameters||coherent.View.nodeParameters[b]||{};this.__copyParameters(h);if(this.innerHTML&&""===String(f.innerHTML).trim()){f.innerHTML=this.innerHTML}var i=coherent.dataModel;var c=this.__context;coherent.dataModel=this.__context=this;var d=this.structure()||{};var e={};for(a in d){g=d[a];if(g&&"function"==typeof(g)&&(g=g.valueOf()).__factoryFn__){e[a]=g;g.call(this,a,true)}}for(a in e){e[a].call(this,a,false)}this.__context=c;coherent.dataModel=i;this.setupBindings();this.init();this.updateBindings();this.createObservers();delete this.__initialising;delete this.viewElement},bindingInfoForName:function(c){var b=this.viewElement();var a=c+"Binding";return b.getAttribute(a)||this.__parameters[a]||this.__parameters[c]},teardown:function(){for(var a in this.bindings){this.bindings[a].unbind()}delete coherent.View.viewLookup[this.id]},__factory__:function(d,i,a){var g=this;var f=Element.queryAll;var e=false;if("string"!==typeof(d)){a=i;i=d;d=null}i=i||{};var h="parameters_"+coherent.generateUid();coherent.View.nodeParameters[h]=i;i.viewClass=g;function c(k){k.setAttribute("__parametersId",h);var j;if("sortKey" in i){k.setAttribute("sortKey",i.sortKey)}}function b(k){if(!e){c(k)}var l=this.__relativeSource||this;var j=coherent.View.fromNode(k)||new g(k,l);coherent.View.createViewsForNodeTree(k,l,this.__context)}return function(l,k){if(l&&1===l.nodeType){return new g(l,k,i)}var m=a||(this?this.viewElement():document);var j=f(m,d||l);if(!j.length){return null}if("action" in i){if(!i.target){i.target=this}if(FIRST_RESPONDER!==i.target&&"string"===typeof(i.action)){i.action=(i.target)[i.action]}}Array.forEach(j,k?c:b,this);e=true;return coherent.View.fromNode(j[0])}},init:function(){var a=this.viewElement();var g=this.bindings;if(g["class"]&&!g["class"].hasValue()){var b=$S(a.className.split(" "));function e(h){delete b[h]}coherent.Style.__styles.forEach(e);var f=Set.join(b," ");g["class"].setValue(f)}if(g.enabled&&!g.enabled.hasValue()){g.enabled.setValue(!a.disabled)}if(g.text&&!g.text.hasValue()){var c=(a.textContent||a.innerText||"").trim();if(c){g.text.setValue(c)}}if(g.html&&!g.html.hasValue()){var d=(a.innerHTML||"").trim();if(d){g.html.setValue(d)}}},structure:function(){return this.__structure__},viewElement:function(){return this.__view||document.getElementById(this.id)},container:function(){return this.__container||this.__view||document.getElementById(this.__containerId||this.id)},setContainer:function(a){if(this.__view){this.__container=a}this.__containerId=Element.assignId(a);return a},superview:function(){var b=this.viewElement();if(!b){return null}var a=null;while(b&&!a){b=b.parentNode;if(!b){return null}if(document==b){return coherent.page}a=coherent.View.fromNode(b)}return a},isDescendantOf:function(b){if(!b){return false}var a=b.viewElement();var c=this.viewElement();while(c&&c!==document.body){if(c.id==a.id){return true}c=c.parentNode}return false},nextResponder:function(){return this.__nextResponder||this.superview()},focus:function(){var a=this.viewElement();function c(){a.focus()}if(coherent.Browser.IE){var b=/^(?:a|button|iframe|input|label|select|textarea)$/i;if(b.test(a.nodeName)){this.focus=c;c()}else{this.focus=function(){}}return}else{this.focus=c;c()}},blur:function(){var a=this.viewElement();function c(){a.blur()}if(coherent.Browser.IE){var b=/^(?:a|button|iframe|input|label|select|textarea)$/i;if(b.test(a.nodeName)){this.blur=c;c()}else{this.blur=function(){}}return}else{this.blur=c;c()}},sendAction:function(){var b=coherent.EventLoop.currentEvent;if(!this.action){return}if(FIRST_RESPONDER!==this.target||"string"!==typeof(this.action)){this.action.call(this.target||this.action,this,b);return}var a=coherent.page.firstResponder||this;var c=this.action;while(a){if(c in a){a[c](this,b);return}a=a.nextResponder()}},onclick:function(a){if(this.disabled){Event.stop(a);return}if(this.action&&this.sendActionOn.containsObject("click")){this.sendAction();Event.stop(a)}else{this.base(a)}},addTrackingInfo:function(a){coherent.page.addTrackingInfo(this.id,a)},observeVisibleChange:function(f,e,b){var a=this.viewElement();var d=coherent.Style.kFadingClass;function c(){a.style.display="none";Element.removeClassName(a,d)}if(!this.animated){a.style.display=(f.newValue?"":"none")}else{if(f.newValue){if(a.style.display!==""){Element.addClassName(a,d);a.style.display=""}coherent.Animator.removeClassName(a,d,{duration:this.updateAnimationDuration||300})}else{coherent.Animator.addClassName(a,d,{duration:this.updateAnimationDuration||300,callback:c})}}},observeEnabledChange:function(b){var a=this.viewElement();this.disabled=a.disabled=!b.newValue;if(a.disabled){Element.addClassName(a,coherent.Style.kDisabledClass)}else{Element.removeClassName(a,coherent.Style.kDisabledClass)}},observeEditableChange:function(b){var a=this.viewElement();a.readOnly=!b.newValue;if(a.readOnly){Element.addClassName(a,coherent.Style.kReadOnlyClass)}else{Element.removeClassName(a,coherent.Style.kReadOnlyClass)}},observeClassChange:function(h,g,d){var a=this.viewElement();var c=$S(a.className.split(" "));var f=$S((h.newValue||"").split(" "));function e(i){if(i in c){Set.add(f,i)}}coherent.Style.__styles.forEach(e);var b=Set.join(f," ");if(this.animated){coherent.Animator.setClassName(a,b,{duration:500})}else{a.className=b}},translateValue:function(c){var a=this.viewElement();var b=true;if(this.formatter){c=this.formatter.stringForValue(c)}switch(c){case"":case null:case undefined:c=this.attributeOrProperty("nullPlaceholder");break;case coherent.Markers.NoSelection:c=this.attributeOrProperty("noSelectionPlaceholder");break;case coherent.Markers.MultipleValues:c=this.attributeOrProperty("multipleValuesPlaceholder");break;default:c=String(c);b=false;break}if(b){Element.addClassName(a,coherent.Style.kMarkerClass)}else{Element.removeClassName(a,coherent.Style.kMarkerClass)}return c},_beginUpdate:function(h,f){var c=(this.preUpdateAnimationDuration||this.updateAnimationDuration||this.postUpdateAnimationDuration)===0;if(c&&h){h.call(this);return}f=f||coherent.Style.kUpdatingClass;var a=this.viewElement();var e=this;if(this.__updating){this.__updating=h||null;return}this.__updating=h||null;function b(){if(e.__updating){e.__updating.call(e)}e.__updating=null;var j=e.postUpdateAnimationDuration||e.updateAnimationDuration;var i=e.postUpdateAnimationDelay||e.updateAnimationDelay;coherent.Animator.removeClassName(a,f,{duration:j,delay:i})}var g=this.preUpdateAnimationDuration||this.updateAnimationDuration;var d=this.preUpdateAnimationDelay||this.updateAnimationDelay||0;coherent.Animator.addClassName(a,f,{duration:g,callback:b})},observeTextChange:function(f,e,b){var a=this.viewElement();var d=(this.translateValue(f.newValue)||"").trim();if((a.textContent||a.innerText||"").trim()===d){return}function c(){var g=document.createTextNode(d);a.innerHTML="";a.appendChild(g)}this._beginUpdate(c)},observeHtmlChange:function(h,g,b){var a=this.viewElement();var f=h.newValue;if("string"===typeof(f)){f=f.trim()}var d=(this.translateValue(f)||"").trim();function c(){var i=document.createTextNode(d);a.innerHTML="";a.appendChild(i)}function e(){a.innerHTML=d}if(d!==f){if((a.textContent||a.innerText||"").trim()===d){return}this._beginUpdate(c)}else{if((a.innerHTML||"").trim()===d){return}this._beginUpdate(e)}},removeChild:function(a){if(!a){return null}coherent.View.teardownViewsForNodeTree(a);if(this.beforeRemoveElement){this.beforeRemoveElement(a)}return a.parentNode.removeChild(a)},attributeOrProperty:(function(){if(coherent.Browser.IE){return function(b){var a=this.viewElement();var c=a[b];if(c||""===c){return c}return String(this[b])}}else{return function(b){var a=this.viewElement();var c=a.getAttribute(b);if(c||""===c){return c}c=a[b];if(c||""===c){return c}return String(this[b])}}})()});coherent.View.nodeParameters={};coherent.View.viewLookup={};coherent.View.registry={};coherent.View.tagToViewLookup={};coherent.View.tagSpecRegex=/^(\w+)\s*(?:\[(\w*)\s*=\s*(\w*)\s*\])?$/;coherent.View.__updateTagSpecTable=function(c){var b=c.prototype;function d(e){var g=e.match(coherent.View.tagSpecRegex);if(!g){throw new Error("Invalid view spec: "+e)}var h=g[1].toUpperCase();var f=g[2];var i=g[3];var j=coherent.View.tagToViewLookup[h]||{};if(!(h in coherent.View.tagToViewLookup)){coherent.View.tagToViewLookup[h]=j}if(!f){if(j.viewClass){console.log((b.__viewClassName__+": "||"")+"Redefining view spec: "+e+": previously registered to "+(j.viewClass.prototype.__viewClassName__||"unknown"));throw new Error("Redefining view spec: "+e)}j.viewClass=c;return}if(!j.attr){j.attr={}}if(!(f in j.attr)){j.attr[f]={}}if(i in j.attr[f]){console.log((b.__viewClassName__+": "||"")+"Redefining view spec: "+e+": previously registered to "+(j.viewClass.prototype.__viewClassName__||"unknown"));throw new Error("Redefining view spec: "+e)}j.attr[f][i]=c}if(b.hasOwnProperty("__tagSpec__")){var a=b.__tagSpec__;if("string"==typeof(a)){d(a)}else{if("forEach" in a){a.forEach(d)}else{console.log("Invalid type for __tagSpec__")}}}if(b.hasOwnProperty("__viewClassName__")){coherent.View.registry[b.__viewClassName__]=c}};coherent.View.__subclassCreated__=function(a){if(!coherent.View.registry){coherent.View.registry={}}var b=a.prototype;var c=a.superclass.prototype;coherent.View.__updateTagSpecTable(a);if(b.__structure__!==c.__structure__){Object.applyDefaults(b.__structure__,c.__structure__)}};coherent.View.viewClassForNode=function(f,d){function a(s){var o=[];var r=s.split(" ");var q;var p=coherent.View.registry;for(q=0;q<r.length;++q){if(r[q] in p){o[o.length]=p[r[q]]}}return o}var h=f.getAttribute("view");var c=f.getAttribute("__parametersId");var j;if(c){return coherent.View.nodeParameters[c].viewClass}if(h){j=coherent.View.registry[h];if(!j){throw new InvalidArgumentError("Invalid view type: "+h)}return j}var e=a(f.className);if(1==e.length){return e[0]}if(e.length>1){throw new InvalidArgumentError("CSS class matches multiple view types: "+f.className)}var g=coherent.View.tagToViewLookup[f.tagName];if(!g){return null}var i;var l;var m=g.attr||{};var n;for(var b in m){n=m[b];l=f.getAttribute(b);if(l in n){j=n[l];break}l=f[b];if(l in n){i=n[l]}}j=j||i||g.viewClass;if(!j){return null}function k(r){var s=j.prototype.exposedBindings||[];var o=s.length;var q;var p;for(p=0;p<o;++p){q=s[p]+"Binding";if(r.getAttribute(q)){return true}}return false}if(!d&&j.prototype.requireBindingsForInferredViewType&&!k(f)){return null}return j};coherent.View.createViewForNode=function(c,e,b){var a=coherent.View.fromNode(c);if(a){return a}var d=coherent.View.viewClassForNode(c,b);return new (d||coherent.View)(c,e,b)};coherent.View.fromNode=function(a){var b=coherent.View.viewLookup;if(!b||!b[a.id]){return null}return b[a.id]};coherent.View.rebindNodeTreeWithRelativeSource=function(b,d,c){function a(f){var e=coherent.View.fromNode(f);if(!e||(d&&e.__relativeSource!==d)){return}e.__relativeSource=c;e.setupBindings();e.updateBindings()}Element.depthFirstTraversal(b,a)};coherent.View.unbindNodeTree=function(b){function a(d){var c=coherent.View.fromNode(d);if(!c){return}c.unbind()}Element.depthFirstTraversal(b,a)};coherent.View.createViewsForNodeTree=function(e,c,d){function b(f){if(coherent.View.fromNode(f)){return}var g=coherent.View.viewClassForNode(f);if(!g){return}new (g)(f,c)}var a=coherent.dataModel;if(d){coherent.dataModel=d}Element.depthFirstTraversal(e||document.body,b);if(d){coherent.dataModel=a}};coherent.View.teardownViewsForNodeTree=function(a){function b(d){var c=coherent.View.fromNode(d);if(!c){return}c.teardown()}Element.depthFirstTraversal(a||document.body,b)};coherent.View.__updateTagSpecTable(coherent.View);coherent.Anchor=Class.create(coherent.View,{__viewClassName__:"Anchor",__tagSpec__:"a",exposedBindings:["href","title"],init:function(){this.base();var a=this.viewElement();var b=this.bindings;if(b.href&&!b.href.hasValue()&&a.href){b.href.setValue(a.href)}if(b.title&&!b.title.hasValue()&&a.title){b.title.setValue(a.title)}},observeHrefChange:function(b){var a=this.viewElement();a.href=b.newValue},observeTitleChange:function(b){var a=this.viewElement();a.title=b.newValue}});coherent.ListView=Class.create(coherent.View,{__viewClassName__:"List",__tagSpec__:["table","ul"],exposedBindings:["content","selectionIndexes","selectedIndex","selectedObject"],_items:null,_activeItem:-1,init:function(){this.base();var b=this.viewElement();var a;switch(b.tagName){case"SELECT":this._isSelectElement=true;this._items=PartList("option");this.templateElement=document.createElement("option");coherent.Form.setupResetLogic(b.form);Event.observe(b,"change",this.selectedIndexChanged.bindAsEventListener(this));break;case"TABLE":a=this.setContainer(b.tBodies[0]);this._items=PartList("> tbody tr");this.templateElement=Element.clone(this._items(0));break;default:a=this.container();var c=b.firstChild;while(c){if(1===c.nodeType){break}c=c.nextSibling}if(!c){return}this._items=PartList("> "+c.nodeName);this.templateElement=Element.clone(c);break}if("true"===(this.attributeOrProperty("multiple")||"").toLowerCase()){this.multiple=true}this.templateElement.id="";if(this.template&&"function"!==typeof(this.template)){delete this.template}if(this.template&&!(this.template.valueOf()).__factoryFn__){this.template=this.template()}if(!this.template&&this.initFromDOM!==false){this._initFromDOM()}else{if(a){a.innerHTML=""}}},computeSelectionIndexes:function(){var b=[];var a=this._items();function c(f,d){if(f.selected){b.push(d)}}a.forEach(c);return b},_initFromDOM:function(){var b=this.container();var m=this.viewElement();var c=this.bindings;var g=[];var o=[];var k=[];var l=this._items();var h=l.length;var j;if(!h||(c.content&&c.content.hasValue())){return}var d=this.objectClass||coherent.KVO;var a=coherent.Style.kSelectedClass;var n=Element.hasClassName;for(var f=0;f<h;++f){j=l[f];j.objectValue=k[f]=new d();if(j.selected||n(j,a)){g.push(f);o.push(j.objectValue)}this.setupElement(j,j.objectValue)}this.__selectionIndexes=g;this.selectedIndex=g.length?g[0]:-1;this.__content=k;if(c.content){c.content.setValue(k)}if(c.selectionIndexes){c.selectionIndexes.setValue(g)}if(c.selectedObject){c.selectedObject.setValue(o[0])}if(c.selectedIndex){c.selectedIndex.setValue(this.selectedIndex)}},acceptsFirstResponder:function(){var a=this.viewElement();if(a.disabled||a.readOnly){return false}return true},highlightSelectionIndexes:function(d){var m=this.viewElement();var l=this._items();var h=l.length;var f;var g=0;var b=!!this._isSelectElement;var c;var a=coherent.Style.kSelectedClass;var k;var n;if(this.animated){var o={curve:coherent.easing.inOutSine,duration:300};k=function(i,e){coherent.Animator.addClassName(i,e,o)};n=function(i,e){coherent.Animator.removeClassName(i,e,o)}}else{k=Element.addClassName;n=Element.removeClassName}for(f=0;f<h;++f){if(f===0){Element.addClassName(l[f],coherent.Style.kFirstClass)}else{Element.removeClassName(l[f],coherent.Style.kFirstClass)}if(h>1&&f===h-1){Element.addClassName(l[f],coherent.Style.kLastClass)}else{Element.removeClassName(l[f],coherent.Style.kLastClass)}c=(f==d[g]);try{l[f].selected=c}catch(j){l[f].setAttribute("selected",c)}if(c){g++}if(b){continue}if(c){k(l[f],a)}else{n(l[f],a)}}if(1===d.length){this.selectedIndex=m.selectedIndex=d[0]}this.__selectionIndexes=d},selectionIndexes:function(){return this.__selectionIndexes},setSelectionIndexes:function(e){var a;var b=this.viewElement();var f=this.bindings;e=(e||[]).concat().sort();if(String(e)===String(this.__selectionIndexes)){e=this.__selectionIndexes}if(1===e.length){a=this.selectedIndex=b.selectedIndex=e[0]}else{if(e.length){a=b.selectedIndex=e[0]}else{a=b.selectedIndex=-1}}if(f.selectionIndexes){f.selectionIndexes.setValue(e)}if(f.selectedIndex){f.selectedIndex.setValue(a)}if(f.selectedObject&&f.content){var c=null;if(-1!==a){c=(this.__content||[])[a]}f.selectedObject.setValue(c)}if(f.selectedValue){var d=null;if(-1!==a){d=b.options[a].value}f.selectedValue.setValue(d)}this.__selectionIndexes=e;this.highlightSelectionIndexes(e)},selectedObjects:function(){var a=this.__content||[];return a.objectsAtIndexes(this.selectionIndexes()||[])},onkeydown:function(b){var j=this.viewElement();if(j.disabled){return}if(Event.KEY_UP!=b.keyCode&&Event.KEY_DOWN!=b.keyCode){return}Event.stop(b);var i=this.selectionIndexes();var e=(this.__content||[]).length-1;var l;if(this.multiple&&b.shiftKey&&i.length){var h=(this.selectedIndex==i[0]);var g=i[0];var k=i[i.length-1];if(1==i.length){if(Event.KEY_UP==b.keyCode){l=g-1}else{l=g+1}if(l<0||l>e){return}i.push(l)}else{if(h){if(Event.KEY_UP==b.keyCode){i.length--}else{if(k<e){i.push(l=k+1)}}}else{if(this.KEY_DOWN==b.keyCode){i.splice(0,1)}else{if(g>0){i.push(l=g-1)}}}}}else{if(!i.length){if(Event.KEY_UP==b.keyCode){this.selectedIndex=e}else{if(Event.KEY_DOWN==b.keyCode){this.selectedIndex=0}}i=[l=this.selectedIndex]}else{if(Event.KEY_UP==b.keyCode&&this.selectedIndex>0){this.selectedIndex--}else{if(Event.KEY_DOWN==b.keyCode&&this.selectedIndex<e){this.selectedIndex++}}i=[l=this.selectedIndex]}}if(!isNaN(l)){var n=this._items(l);var m=Element.scrollParent(j);var f=m.offsetHeight;var c=n.offsetTop-m.scrollTop;var d=n.offsetHeight;var a=this.container();if(n.offsetParent!==a){c-=a.offsetTop}if(c<0){n.scrollIntoView(true)}else{if(c+d>f){n.scrollIntoView(false)}}}this.setSelectionIndexes(i);return},selectedIndexChanged:function(c){if(!this.bindings.selectionIndexes&&!this.bindings.selectedIndex&&!this.bindings.selectedObject&&!this.bindings.selectedValue){return}var a=this.viewElement();var b;if(this.multiple){b=this.computeSelectionIndexes()}else{b=[this.selectedIndex=a.selectedIndex]}this.setSelectionIndexes(b)},_clearSelection:function(){var a=this.viewElement();var e=("SELECT"!==a.tagName);var f=Element.removeClassName;var c=coherent.Style.kSelectedClass;function d(g){g.selected=false;if(e){f(g,c)}}var b=this._items();b.forEach(d);a.selectedIndex=-1},observeSelectedIndexChange:function(d){var c=d.newValue;var b=(-1!==c&&null!==c&&"undefined"!==typeof(c));var a=b?[c]:[];this.setSelectionIndexes(a)},observeSelectedObjectChange:function(e){var d=e.newValue;var c=this.__content||[];var a=c.indexOf(d);var b=(-1===a?[]:[a]);this.setSelectionIndexes(b)},observeSelectionIndexesChange:function(b){var a=b.newValue||[];this.setSelectionIndexes(a)},_updateDomWithContent:function(k){var m=coherent.View.rebindNodeTreeWithRelativeSource;var q=coherent.View.unbindNodeTree;var r=this.selectedObjects();var h=[];var c=k.length;var l=this._items();var n=l.length;var d=Math.min(n,c);var g=0;var f;var j;var a;var o;while(g<d){f=k[g];if(-1!==r.indexOf(f)){h.push(g)}j=l[g];a=j.objectValue;j.objectValue=f;if("undefined"===typeof(a)){this.setupElement(j,j.objectValue)}else{m(j,a,f)}o=coherent.View.fromNode(j);if(!o||!o.bindings.visible){j.style.display=""}++g}if(g<c){var b=this.container();var p=document.createDocumentFragment();while(g<c){f=k[g];if(-1!==r.indexOf(f)){h.push(g)}j=this.createElement(f,null,p);this._items.add(j);++g}b.appendChild(p)}else{while(g<n){j=l[g];q(j);j.objectValue=null;j.style.display="none";++g}}this.highlightSelectionIndexes(h)},observeContentChange:function(k){var a=this.container();var m=this.viewElement();var g;var l;var i;var j;var h;var f=[];var n=coherent.View.rebindNodeTreeWithRelativeSource;var o=coherent.View.unbindNodeTree;function c(r,q){var p=r.objectValue;r.objectValue=q;n(r,p,q);r.style.display=""}switch(k.changeType){case coherent.ChangeType.setting:this.__content=k.newValue||[];this._updateDomWithContent(this.__content);break;case coherent.ChangeType.insertion:for(g=0;g<k.indexes.length;++g){l=this._items(k.indexes[g]);if(l&&"none"===l.style.display){i=l;c(l,k.newValue[g])}else{i=this.createElement(k.newValue[g],l);this._items.insertPartAtIndex(i,k.indexes[g])}if(this.animated){Element.addClassName(i,coherent.Style.kInsertedClass);coherent.Animator.removeClassName(i,coherent.Style.kInsertedClass,{discreteTransitionPoint:1,duration:this.updateAnimationDuration})}}break;case coherent.ChangeType.replacement:function d(p){c(p,p.newObjectValue);p.newObjectValue=null;coherent.Animator.removeClassName(p,coherent.Style.kReplacingClass,{duration:250,discreteTransitionPoint:1})}for(g=0;g<k.indexes.length;++g){i=this._items(k.indexes[g]);if(!this.animated){c(i,k.newValue[g])}else{i.newObjectValue=k.newValue[g];coherent.Animator.addClassName(i,coherent.Style.kReplacingClass,{duration:this.updateAnimationDuration,discreteTransitionPoint:0,callback:d.bind(this)})}}break;case coherent.ChangeType.deletion:f=this.selectionIndexes();for(g=k.indexes.length-1;g>=0;--g){var b=k.indexes[g];f.removeObject(b);i=this._items(b);this._items.removePartAtIndex(b);if(!this.animated){this.removeChild(i)}else{coherent.Animator.addClassName(i,coherent.Style.kDeletedClass,{duration:this.updateAnimationDuration,discreteTransitionPoint:0,callback:this.removeChild.bind(this)})}}this.setSelectionIndexes(f);break;default:console.log("Unknown change type: "+k.changeType);break}if(this.bindings.displayValues){this.bindings.displayValues.update()}if(this.bindings.contentValues){this.bindings.contentValues.update()}},setupElement:function(d,c){d.objectValue=c;if(this.template){var a=coherent.dataModel;var b;coherent.dataModel=this.__context;this.template.call(this,d,c);coherent.dataModel=a}else{coherent.View.createViewsForNodeTree(d,c,this.__context)}return d},createElement:function(c,d,b){var a=this.viewElement();b=b||this.container();var f=Element.clone(this.templateElement);var g=b.insertBefore(f,d||null);return this.setupElement(g,c)},onmousedown:function(d){var b=this.viewElement();if(b.disabled){return}if("SELECT"===b.tagName){this.base(d);return}var f=d.target||d.srcElement;var a=this.container();var c=this._items();if(f==a){return}while(f&&f.parentNode!=a){f=f.parentNode}if(f==a){return}this._activeItem=c.indexOf(f);Element.addClassName(f,coherent.Style.kActiveClass)},onmouseup:function(b){var a=this.viewElement();if(a.disabled){return}if(-1!==this._activeItem){Element.removeClassName(this._items(this._activeItem),coherent.Style.kActiveClass)}this._activeItem=-1},ontouchmove:function(b){var a=this.viewElement();if(a.disabled){return}if(-1!==this._activeItem){Element.removeClassName(this._items(this._activeItem),coherent.Style.kActiveClass)}this._activeItem=-1;this.base(b)},onclick:function(a){var j=this.viewElement();if(j.disabled){this.base(a);Event.stop(a);return}if("SELECT"===j.tagName){this.base(a);return}var h=a.target||a.srcElement;var d=-1;var c=null;var b=this.container();var i=this._items();if(h==b){return}while(h&&h.parentNode!=b){h=h.parentNode}if(h){d=i.indexOf(h);c=h.objectValue}var g;if(!this.multiple){this.selectedIndex=d;this.setSelectionIndexes(g=[d])}else{g=this.selectionIndexes();if(a.shiftKey){this.setSelectionIndexes(IndexRange(this.selectedIndex,d))}else{if(a.ctrlKey||a.metaKey){var f=g.indexOf(d);if(-1===f){this.selectedIndex=d;g.push(d)}else{g.splice(f,1)}this.setSelectionIndexes(g)}else{this.selectedIndex=d;this.setSelectionIndexes([d])}}}if(h&&"A"==h.tagName){h.blur()}this.sendAction()}});coherent.Overlay=Class.create(coherent.View,{content:Part(".content"),container:Part(".container"),__structure__:{".close":coherent.Anchor({action:"close",visibleBinding:"canClose"}),".spinner":coherent.View({visibleBinding:"loading"}),".buttons":coherent.ListView({visibleBinding:"error",contentBinding:"recoveryOptions",action:"recoveryButtonClicked"}),".buttons li button":coherent.View({textBinding:"*.text"})},minWidth:200,minHeight:200,contentScreen:null,spinnerDelay:250,timeout:5000,innerHTML:'<span class="chrome tl"></span><span class="chrome tr"></span><span class="chrome top"></span><span class="chrome left"></span><span class="chrome right"></span><span class="chrome bottom"></span><span class="chrome bl"></span><span class="chrome br"></span><a href="#" class="close">close</a><span class="chrome center"></span><div class="spinner"></div><div class="container"><div class="content"></div><ul class="buttons"><li><button></button></li></ul></div>',keyDependencies:{canClose:["loading","displayCloseWidget"]},init:function(){this.__cache={};this.__urlCache={};var a=this.viewElement();a.style.display="none"},canClose:function(){return !this.loading&&this.displayCloseWidget},display:function(b){b=Object.applyDefaults(b||{},{timeout:this.timeout,obscurePage:true,displayCloseWidget:true,grow:true,dimensions:{width:this.minWidth,height:this.minHeight}});if(!b.url&&!b.sourceId&&!b.html&&!b.text&&!b.error){throw new Error("No source specified for the overlay.")}if(!this.contentScreen){this.contentScreen=document.createElement("iframe");this.contentScreen.className="overlayScreen";this.contentScreen.scrolling="no";this.contentScreen.frameBorder="0";this.contentScreen.src="about:blank";Element.assignId(this.contentScreen);document.body.appendChild(this.contentScreen)}var a=this.viewElement();if(a.parentNode!==document.body){a.parentNode.removeChild(a);document.body.appendChild(a)}if(this.__request){this.__request.abort()}this.__clearTimers();if(b.grow){this.__show(b)}this.setValueForKey(b.displayCloseWidget,"displayCloseWidget");if(b.url){this.__loadContent(b);return}this.__showContent(b)},__clearTimers:function(){if(this.__loadingTimer){window.clearTimeout(this.__loadingTimer);this.__loadingTimer=0}},__loadContent:function(b){function e(){console.log("Failed to display overlay: timeout exceeded");this.__clearTimers();this.close()}function g(d){console.log("Failed to display overlay: "+d.message);this.__clearTimers();this.close()}function a(i){var h=document.createElement("div");var d=coherent.Scripts.extract(i);h.innerHTML=d;b.scripts=d.scripts;b.sourceId=Element.assignId(h);this.__urlCache[b.url]=h.id;this.__cache[h.id]=h;this.__clearTimers();this.__showContent(b)}var c=this.__urlCache[b.url];if(c){b.sourceId=c;this.__clearTimers();this.__showContent(b);return}var f=XHR.get(b.url);f.addMethods(a.bind(this),g.bind(this));this.setValueForKey(true,"loading");this.__loadingTimer=e.bindAndDelay(this,b.timeout)},__getNodeById:function(a){return this.__cache[a]=(document.getElementById(a)||this.__cache[a])},__removeChildren:function(a){while(a.firstChild){a.removeChild(a.firstChild)}},__suspendScrolling:function(){if(coherent.Browser.IE===6){Element.query("html").style.overflow="hidden"}},__resumeScrolling:function(){if(coherent.Browser.IE===6){Element.query("html").style.overflow=""}},__showContent:function(d){var g=this.viewElement();var f=this.content();var a=this.container();var i;var h;this.setValueForKey(false,"loading");if("classname" in d){g.className=d.classname}Element.setStyle(g,"opacity",0);g.style.display="";a.style.position="absolute";Element.setStyle(a,"opacity",0);if("sourceId" in d){this.__removeChildren(f);var b=this.__getNodeById(d.sourceId);if(b.parentNode){b.parentNode.removeChild(b)}f.appendChild(b)}else{if("html" in d){var e=coherent.Scripts.extract(d.html);d.scripts=e.scripts;f.innerHTML=e;console.log("scripts= ",d.scripts)}else{if("text" in d){i=document.createTextNode(d.text);this.__removeChildren(f);f.appendChild(i)}else{if("error" in d){i=document.createTextNode(d.error.description);this.__removeChildren(f);f.appendChild(i);this.setValueForKey(d.error,"error");if(this.error.recoveryOptions&&this.error.recoveryAttempter){function c(l){var k=new coherent.KVO();k.text=l;return k}var j=this.error.recoveryOptions.map(c);this.setValueForKey(j,"recoveryOptions")}}}}}if(!d.error){this.setValueForKey(null,"error");this.setValueForKey(null,"recoveryOptions")}if(d.dimensions&&d.dimensions.width==this.minWidth&&d.dimensions.height==this.minHeight){d.dimensions=Element.getDimensions(a)}d.dimensions.height=Math.max(this.minHeight,d.dimensions.height);d.dimensions.width=Math.max(this.minWidth,d.dimensions.width);this.__show(d)},load:function(a){this.display({url:a})},__show:function(e){var c=e.dimensions.width;var k=e.dimensions.height;var a=this.container();a.style.position="";var i=this.contentScreen;if(e.obscurePage){this.__suspendScrolling();i.style.display="block"}var h=this.viewElement();h.style.display="";h.style.position="fixed";h.style.left="50%";h.style.top="50%";h.style.display="";if(6===coherent.Browser.IE){var f=Element.getViewport();var g=Math.round(f.height/2+f.top)+"px";var d=Math.round(f.width/2+f.left)+"px";h.style.position="absolute";h.style.top=g;if(e.obscurePage){i.style.position="absolute";i.style.top="0px";i.style.left="0px";i.style.width=document.body.offsetWidth+"px";i.style.height=document.body.offsetHeight+"px"}}function j(){if(e.scripts){coherent.Scripts.install(e.scripts)}e.scripts=null}function b(){coherent.Animator.setStyles(a,{opacity:1},{duration:100,callback:j})}if(e.obscurePage){coherent.Animator.setStyles(i,{opacity:0.85},{duration:250})}coherent.Animator.setStyles(h,{opacity:1,width:c,height:k,marginLeft:{value:-c/2,cleanup:false},marginTop:{value:-k/2,cleanup:false}},{duration:250,cleanup:(coherent.Browser.IE?true:false),callback:b})},close:function(){return this.hide()},hide:function(){this.__resumeScrolling();var e=this.contentScreen;var b=this.viewElement();var a=this.container();var d=this.content();Element.setStyle(a,"opacity",0);var c=this.__removeChildren;coherent.Animator.setStyles(e,{opacity:0},{duration:250,callback:function(){e.style.display="none"}});coherent.Animator.setStyles(b,{opacity:0,width:this.minWidth,height:this.minHeight,marginLeft:-this.minWidth/2,marginTop:-this.minHeight/2},{duration:250,callback:function(){c(d);b.style.display="none"}})},recoveryButtonClicked:function(c){var b=c.selectedIndex;var a=this.error;if(-1==b||!a.recoveryAttempter){return}a.recoveryAttempter(a,b)}});coherent.Bubble=Class.create(coherent.Overlay,{arrow:Part(".arrow"),innerHTML:'<span class="chrome tl"></span><span class="chrome tr"></span><span class="chrome top"></span><span class="chrome left"></span><span class="chrome right"></span><span class="chrome bottom"></span><span class="chrome bl"></span><span class="chrome br"></span><a href="#" class="close">close</a><span class="chrome center"></span><div class="spinner"></div><div class="container"><div class="content"></div><ul class="buttons"><li><button></button></li></ul></div><span class="chrome arrow"></span>',minWidth:50,minHeight:20,maxWidth:800,maxHeight:500,init:function(){this.base();this.currentTarget=null},display:function(a){a=Object.applyDefaults(a,{grow:false});var b=Element.assignId(a.target);if(this.currentTarget==b){return}if(this.currentTarget){this.base(a);return}if(this.__timer){window.clearTimeout(this.__timer)}this.currentTarget=b;this.__timer=this.base.bindAndDelay(this,150,a)},hide:function(a){if(a&&this.currentTarget!==a.target.id){return}this.__hide()},__show:function(c){if(this.__timer){window.clearTimeout(this.__timer)}this.__timer=null;this.currentTarget=Element.assignId(c.target);var j=this.viewElement();var l=this.arrow();var f=this.content();var b=this.container();Element.setStyle(b,"opacity",1);b.style.position="";Element.setStyle(j,"opacity",0);j.style.display="";var a=Element.getRect(c.target);var g=Element.getViewport();var h;if(c.within){h=Element.getRect(c.within)}else{if(c.dimensions){var k=parseInt(a.left,10)+Math.floor(a.width/2);var m=Math.floor(c.dimensions.width/2);h={left:k-m,right:k+m,width:c.dimensions.width}}else{h=Element.getRect(document.body)}}j.style.left=h.left+"px";j.style.width=h.width+"px";Element.removeClassName(j,"below");var d=l.offsetHeight;var e=d+parseInt(Element.getStyle(l,"marginBottom")||0,10);var i=parseInt(a.top,10)-j.offsetHeight-e;if(i<g.top||"below"==c.position){Element.addClassName(j,"below");e=d+parseInt(Element.getStyle(l,"marginTop")||0,10);i=parseInt(a.bottom,10)+e}j.style.top=i+"px";l.style.left=(a.left-h.left+a.width/2)+"px";coherent.Animator.setStyles(j,{opacity:1},{duration:100})},__hide:function(){if(this.__timer){window.clearTimeout(this.__timer)}this.__timer=null;this.currentTarget=null;var a=this.viewElement();coherent.Animator.setStyles(a,{opacity:0},{duration:100,callback:function(){a.style.display="none"}})}});coherent.Bubble.display=function(d){var b="coherent_bubble_node";var c=document.getElementById(b);var a;if(c){a=coherent.View.fromNode(c)}else{c=document.createElement("div");c.id=b;document.body.appendChild(c);a=new coherent.Bubble(c)}a.display(d)};coherent.Bubble.hide=function(d){var b="coherent_bubble_node";var c=document.getElementById(b);if(!c){return}var a=coherent.View.fromNode(c);a.hide(d)};coherent.FieldGroup=Class.create(coherent.View,{validateFields:function(){var c=this.viewElement();var b=Element.query(c,"input");var a=b.length;var j;var g;var d;var h=true;for(var e=0;e<a;++e){j=coherent.View.fromNode(b[e]);if(!j){continue}if("validate" in j){d=j.validate();if(d instanceof coherent.Error){h=false;g=g||j}}}if(g){g.focus()}}});coherent.Fieldset=Class.create(coherent.FieldGroup,{bubbleClass:"bubble",init:function(){this.__currentViewId=false;this.__fieldErrors={};coherent.page.addObserverForKeyPath(this,"observeFirstResponderChange","firstResponder")},presentError:function(a){var b=a.field;if(!b){return}this.__fieldErrors[b.id]=a},clearAllErrors:function(a){delete this.__fieldErrors[a.id];if(this.__currentViewId==a.id){this.__currentViewId=false;coherent.Bubble.hide({target:document.getElementById(a.id)})}},observeFirstResponderChange:function(e){var d=e.newValue;var c=!!d&&this.__fieldErrors[d.id];if(!c||!d.isDescendantOf(this)){if(this.__currentViewId){var a=this.__currentViewId;function b(){coherent.Bubble.hide({target:document.getElementById(a)})}b.delay(250)}this.__currentViewId=false;return}this.__currentViewId=d.id;coherent.Bubble.display({classname:this.bubbleClass,error:c,target:d.viewElement(),within:this.viewElement()})}});coherent.Binding=Class.create({constructor:function(b,c,a){if(0===arguments.length){return}this.object=b;this.keyPath=c;this.transformer=a;this.refresh()},bind:function(){this.object.addObserverForKeyPath(this,this.observeChangeForKeyPath,this.keyPath)},unbind:function(){this.object.removeObserverForKeyPath(this,this.keyPath)},refresh:function(){this.cachedOriginalValue=this.object.valueForKeyPath(this.keyPath);this.cachedValue=this.transformedValue(this.cachedOriginalValue)},transformedValue:function(a){if(!this.transformer){return a}return this.transformer.transformedValue(a)},validateProposedValue:function(b){if(this.transformer){if(!this.transformer.reverseTransformedValue){throw new Error("Can't validate a value when the transformer doesn't have a reverseTransformedValue method")}b=this.transformer.reverseTransformedValue(b)}var a=this.object.validateValueForKeyPath(b,this.keyPath);if(a instanceof coherent.Error){return a}return this.transformedValue(a)},setValue:function(a){if(this.cachedValue===a){return}this.cachedValue=a;if(this.transformer){if(!this.transformer.reverseTransformedValue){return}a=this.transformer.reverseTransformedValue(a)}this.cachedOriginalValue=a;var b=this.updating;this.updating=true;this.object.setValueForKeyPath(a,this.keyPath);this.updating=b},mutable:function(){if(this.transformer&&!this.transformer.reverseTransformedValue){return false}var a=this.object.infoForKeyPath(this.keyPath);return a&&a.mutable},value:function(){return this.cachedValue},hasValue:function(){var a=this.value();return !(null===a||"undefined"===typeof(a))},update:function(){var a=this.value();var b=new coherent.ChangeNotification(this.object,coherent.ChangeType.setting,a);this.updating=true;this.observerFn(b,this.keyPath);this.updating=false},observerFn:function(c,b,a){},observeChangeForKeyPath:function(f,e,a){if(this.updating&&f.newValue===this.cachedOriginalValue){return}this.cachedOriginalValue=f.newValue;var d=this.transformedValue(f.newValue);var b=Object.clone(f);b.newValue=d;b.oldValue=null;if(coherent.ChangeType.setting===f.changeType){this.cachedValue=d}var c=this.updating;this.updating=true;this.observerFn(b,e,a);this.updating=c}});coherent.Binding.bindingRegex=/^(.*?)(?:\((.*)\))?$/;coherent.Binding.compoundRegex=/^\s*([^&|].*?)\s*(\&\&|\|\|)\s*(\S.+)\s*$/;coherent.Binding.bindingFromString=function(d,c){var b;var e;b=d.match(coherent.Binding.compoundRegex);if(b&&4==b.length){e=new coherent.CompoundBinding(b[2],coherent.Binding.bindingFromString(b[1],c),coherent.Binding.bindingFromString(b[3],c));e.bind();return e}b=d.match(coherent.Binding.bindingRegex);if(!b||b.length<3){throw new InvalidArgumentError("bindingString isn't in correct format")}var f=b[1];var a;if(b[2]){a=coherent.findTransformerWithName(b[2])}e=new coherent.Binding(c||coherent.dataModel,f,a);e.bind();return e};coherent.CompoundBinding=Class.create(coherent.Binding,{constructor:function(a,c,b){this.base();if(!a||!c||!b){throw new InvalidArgumentError("No parameters to CompoundBinding initialiser are optional")}this.operation=a;this.left=c;this.right=b;this.left.observerFn=this.right.observerFn=this.observeChange.bind(this);switch(this.operation){case coherent.CompoundBinding.AND:this.cachedValue=this.left.value()&&this.right.value();break;case coherent.CompoundBinding.OR:this.cachedValue=this.left.value()||this.right.value();break;default:throw new InvalidArgumentError("Unknown operation value for CompoundBinding");break}},bind:function(){this.left.bind();this.right.bind()},unbind:function(){this.left.unbind();this.right.unbind()},mutable:function(){return false},setValue:function(a){throw new Error("Attempting to set value of CompoundBinding")},observeChange:function(c,b){var a=this.cachedValue;switch(this.operation){case coherent.CompoundBinding.AND:this.cachedValue=this.left.value()&&this.right.value();break;case coherent.CompoundBinding.OR:this.cachedValue=this.left.value()||this.right.value();break;default:throw new Error("Unknown operation value for CompoundBinding");break}if(a===this.cachedValue){return}this.update()}});coherent.CompoundBinding.AND="&&";coherent.CompoundBinding.OR="||";Class.extend(Array,{containsObject:function(a){return -1!==this.indexOf(a)},valueForKey:function(c){if(!c||0===c.length){throw new InvalidArgumentError("the key is empty")}if("@count"==c){return this.length}var d=new Array(this.length);var b;var a=this.length;for(b=0;b<a;++b){d[b]=this[b].valueForKey(c)}return d},setValueForKey:function(d,c){if(!c||0===c.length){throw new InvalidArgumentError("key is empty")}var b;var a=this.length;for(b=0;b<a;++b){this[b].setValueForKey(d,c)}},indexesOfObjects:function(e){var d;var b=e.length;var a=[];var c;for(d=0;d<b;++d){c=this.indexOf(e[d]);if(-1===c){continue}a.push(c)}return a},addObject:function(b){var a=this.length;var c=new coherent.ChangeNotification(this,coherent.ChangeType.insertion,[b],null,[a]);this.push(b);this.observeElementAtIndex(a);this.notifyObserversOfChangeForKeyPath(c,coherent.KVO.kAllPropertiesKey)},addObjects:function(c){var b;var a=c.length;for(b=0;b<a;++b){this.addObject(c[b])}},insertObjectAtIndex:function(b,a){if(a<0||a>=this.length){throw new RangeError("index must be within the bounds of the array")}var c=new coherent.ChangeNotification(this,coherent.ChangeType.insertion,[b],null,[a]);this.splice(a,0,b);this.observeElementAtIndex(a);this.notifyObserversOfChangeForKeyPath(c,coherent.KVO.kAllPropertiesKey)},insertObjectsAtIndexes:function(e,c){if(e.length!==c.length){throw new InvalidArgumentError("length of objects and indexes parameters must be equal")}var a=e.length;var d;var b;for(d=0;d<a;++d){b=c[d];this.splice(b,0,e[d]);this.observeElementAtIndex(b)}var f=new coherent.ChangeNotification(this,coherent.ChangeType.insertion,e,null,c);this.notifyObserversOfChangeForKeyPath(f,coherent.KVO.kAllPropertiesKey)},replaceObjectAtIndex:function(c,b){var a=this[b];this[b]=c;var d=new coherent.ChangeNotification(this,coherent.ChangeType.replacement,[c],[a],[b]);this.notifyObserversOfChangeForKeyPath(d,coherent.KVO.kAllPropertiesKey)},replaceObjectsAtIndexes:function(f,d){var b=[];var a=f.length;var e;var c;for(e=0;e<a;++e){c=d[e];b[e]=this[c];this.stopObservingElementAtIndex(c);this[c]=f[e];this.observeElementAtIndex(c)}var g=new coherent.ChangeNotification(this,coherent.ChangeType.replacement,f,null,d);this.notifyObserversOfChangeForKeyPath(g,coherent.KVO.kAllPropertiesKey)},removeObject:function(b){var a=this.indexOf(b);if(-1===a){return}this.removeObjectAtIndex(a)},removeObjects:function(d){var a=d.length;var b;for(var c=0;c<a;++c){b=this.indexOf(d[c]);if(-1===b){continue}this.removeObjectAtIndex(b)}},removeObjectsAtIndexes:function(b){var a=b.length;for(var c=0;c<a;++c){this.removeObjectAtIndex(b[c])}},removeObjectAtIndex:function(b){if(b<0||b>=this.length){throw new RangeError("index must be within the bounds of the array")}this.stopObservingElementAtIndex(b);var a=this.splice(b,1);var c=new coherent.ChangeNotification(this,coherent.ChangeType.deletion,null,a,[b]);this.notifyObserversOfChangeForKeyPath(c,coherent.KVO.kAllPropertiesKey)},removeAllObjects:function(){var d;var c=[];var a=this.length;c.length=a;for(d=0;d<a;++d){this.stopObservingElementAtIndex(d);c[d]=d}var b=this.splice(0,a);var e=new coherent.ChangeNotification(this,coherent.ChangeType.deletion,null,b,c);this.notifyObserversOfChangeForKeyPath(e,coherent.KVO.kAllPropertiesKey)},objectsAtIndexes:function(c){var d;var b=[];var a=c.length;b.length=c.length;for(d=0;d<a;++d){b[d]=this[c[d]]}return b},observeChildObjectChangeForKeyPath:function(f,e,b){var d=f.object;var c=this.indexOf(d);if(!this.__uid){this.initialiseKeyValueObserving()}if(-1===c){d._removeParentLink(this,null,this.__uid);return}var a=new coherent.ChangeNotification(d,coherent.ChangeType.replacement,[f.newValue],[f.oldValue],[c]);this.notifyObserversOfChangeForKeyPath(a,e)},observeElementAtIndex:function(a){var b=this[a];if(!b||!b._addParentLink){return}if(!this.__uid){this.initialiseKeyValueObserving()}b._addParentLink(this,null,this.__uid)},stopObservingElementAtIndex:function(a){var b=this[a];if(!b||!b._removeParentLink){return}if(!this.__uid){this.initialiseKeyValueObserving()}b._removeParentLink(this,null,this.__uid)},initialiseKeyValueObserving:function(){var b;var a=this.length;this.__observers={};this.__uid=this.__uid||coherent.generateUid();for(b=0;b<a;++b){this.observeElementAtIndex(b)}}});coherent.KVO.adapt(Array.prototype);coherent.ArrayOperator={avg:function(a){return this.sum(a)/a.length},count:function(a){throw new InvalidArgumentError("@count operator must end the keyPath")},distinctUnionOfArrays:function(a){return this.unionOfArrays(a).distinct()},distinctUnionOfObjects:function(a){return a.distinct()},max:function(d){var b=null;var e;var a;var c;for(e=0,a=d.length;e<a;++e){c=d[e];if(null===b||c>b){b=c}}return b},min:function(c){var e=null;var d;var a;var b;for(d=0,a=c.length;d<a;++d){b=c[d];if(null===e||b<e){e=b}}return e},sum:function(b){var d=0;var a=b.length;var c;for(c=0;c<a;++c){d+=b[c]}return d},unionOfArrays:function(b){var d=[];var a;var c;for(c=0,a=b.length;c<a;++c){d=d.concat(b[c])}return d},unionOfObjects:function(a){return a}};coherent.KVOTable=Class.create(coherent.KVO,{valueForKeyPath:function(a){if("array"===coherent.typeOf(a)){a=a.join(".")}return this.valueForKey(a)},setValueForKeyPath:function(a,b){if("array"===coherent.typeOf(b)){b=b.join(".")}return this.setValueForKey(a,b)},infoForKeyPath:function(a){if("array"===coherent.typeOf(a)){a=a.join(".")}return this.infoForKey(a)}});coherent.Scripts={extract:function(b){var c=RegExp("(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)","img");var a=[];var d=new String(b.replace(c,function(){a.push(arguments[1]);return""}));d.scripts=a;return d},install:function(a){if(!a){return}function b(f){if(!f||!f.length){return}if(window.execScript){window.execScript(f)}else{var c=document.createElement("script");var e=document.createTextNode(f);c.appendChild(e);c.type="text/javascript";c.defer=false;var d=document.getElementsByTagName("head").item(0);d.appendChild(c)}}if("string"===typeof(a)){b(a);return}a.forEach(b)}};Element.colours={black:"#000000",white:"#ffffff"};if(coherent.Browser.IE){Element.setStyle=function(a,e,d){if("opacity"!=e){a.style[e]=d;return}var c=a.style.filter;var b=a.style;if(d==1||d===""){b.filter=c.replace(/alpha\([^\)]*\)/gi,"");return}if(d<0.00001){d=0}b.filter=c.replace(/alpha\([^\)]*\)/gi,"")+"alpha(opacity="+(d*100)+")"};Element.setStyles=function(a,b){var c=a.style;for(var d in b){if("opacity"==d){Element.setStyle(a,d,b[d])}else{c[d]=b[d]}}};Element.getStyles=function(e,c){var b=e.currentStyle;function j(k){var i=0;if("width"===k){i+=parseInt(b.borderLeftWidth,10)||0+parseInt(b.borderRightWidth,10)||0+parseInt(b.paddingLeft,10)||0+parseInt(b.paddingRight,10)||0;return Math.max(0,e.offsetWidth-i)+"px"}else{i+=parseInt(b.borderTopWidth,10)||0+parseInt(b.borderBottomWidth,10)||0+parseInt(b.paddingTop,10)||0+parseInt(b.paddingBottom,10)||0;return Math.max(0,e.offsetHeight-i)+"px"}}var h={};var f;if("string"===typeof(c)){if("opacity"===c){f=b.filter.match(/opacity=(\d+)/i);return(null===f?1:parseInt(f[1],10)/100)}if(c=="height"||c=="width"){return j(c)}else{if(a=="backgroundPosition"){return b.backgroundPositionX+" "+b.backgroundPositionY}else{return b[c]}}}c=c||Element.PROPERTIES;var a;var g=c.length;for(var d=0;d<g;++d){a=c[d];if("opacity"===a){f=b.filter.match(/opacity=(\d+)/i);h[a]=(null===f?1:parseInt(f[1],10)/100)}else{if(a==="height"||a==="width"){h[a]=j(a)}else{if(a==="backgroundPosition"){h[a]=b.backgroundPositionX+" "+b.backgroundPositionY}else{h[a]=b[a]}}}}return h};Element.getStyle=Element.getStyles;Element.clone=function(c){var d=c.cloneNode(false);if("TR"!=c.tagName){d.innerHTML=c.innerHTML;return d}var b;var a;var e;for(b=0;b<c.children.length;++b){a=c.children[b];e=a.cloneNode(false);e.id="";e.innerHTML=a.innerHTML;d.appendChild(e)}return d}}if(coherent.Browser.IE){Object.extend(Event,{observe:function(c,a,b){if("on"!=a.slice(0,2)){a="on"+a}c.attachEvent(a,b)},stopObserving:function(c,a,b){if("on"!=a.slice(0,2)){a="on"+a}c.detachEvent(a,b)},stop:function(a){a=a||window.event;a.returnValue=false;a.cancelBubble=true},preventDefault:function(a){a.returnValue=false},onDomReady:function(b){if(Event._domHasFinishedLoading.done){window.setTimeout(b,0);return}if(!Event._readyCallbacks){document.write('<script id=__ie_onload defer src="//:"><\/script>');var a=document.getElementById("__ie_onload");a.onreadystatechange=function(){if("complete"===this.readyState){Event._domHasFinishedLoading()}};a=null;Event.observe(window,"load",Event._domHasFinishedLoading);Event._readyCallbacks=[]}Event._readyCallbacks.push(b)}})}coherent.Formatter=Class.create({invalidValueMessage:_("error.invalid_value"),constructor:function(a){Object.extend(this,a)},stringForValue:function(a){if(null===a||"undefined"===typeof(a)){return""}return String(a)},valueForString:function(a){return a},isStringValid:function(a){return true},isValidInputCharacter:function(a){return true}});coherent.NumberFormatter=Class.create(coherent.Formatter,{invalidValueMessage:_("error.invalid_number"),validFloatCharacters:"0123456789.-",validIntCharacters:"0123456789-",allowsFloats:true,stringForValue:function(a){if(null===a||"undefined"===typeof(a)){return""}return String(a)},valueForString:function(a){if(this.allowsFloats){return parseFloat(a)}else{return parseInt(a,10)}},isStringValid:function(a){var c=this.valueForString(a);var b=!isNaN(c);if(b&&!isNaN(this.minimum)){b=(c>=this.minimum)}if(b&&!isNaN(this.maximum)){b=(c<=this.maximum)}if(b){return true}return new coherent.Error({description:this.invalidValueMessage})},isValidInputCharacter:function(a){if(this.allowsFloats){return(-1!==this.validFloatCharacters.indexOf(a))}else{return(-1!==this.validIntCharacters.indexOf(a))}}});coherent.RegexFormatter=Class.create(coherent.Formatter,{constructor:function(a){this.base(a);this.typeofValidCharacters=typeof(this.validCharacters);if(this.invalidRegex&&"exec" in this.invalidRegex){this.invalidRegex=[this.invalidRegex]}if(this.validRegex&&"exec" in this.validRegex){this.validRegex=[this.validRegex]}},isStringValid:function(b){var c;var a;var e;var d=true;if(this.invalidRegex){e=this.invalidRegex;for(c=0,a=e.length;c<a;++c){if(e[c].test(b)){d=false;break}}}if(d&&this.validRegex){d=false;e=this.validRegex;for(c=0,a=e.length;c<a;++c){if(e[c].test(b)){d=true;break}}}if(d){return true}return new coherent.Error({description:this.invalidValueMessage})},isValidInputCharacter:function(a){if(!this.validCharacters){return true}if("string"===this.typeofValidCharacters){return(-1!==this.validCharacters.indexOf(a))}else{return this.validCharacters.test(a)}}});coherent.easing=(function(){var b=Math.PI/2;var a=Math.PI;return{linear:function(c){return c},linearCompleteAndReverse:function(c){return(c>0.5)?2-2*c:2*c},inSine:function(c){return 1-Math.cos(c*b)},outSine:function(c){return Math.sin(c*b)},inOutSine:function(c){return(1-Math.cos(c*a))/2},inBack:function(c,d){if(d==undefined){d=1.70158}return c*c*((d+1)*c-d)},outBack:function(c,d){if(d==undefined){d=1.70158}c=c-1;return(c*c*((d+1)*c+d)+1)},outBackStrong:function(c,d){if(d==undefined){d=1.70158*1.5}c=c-1;return(c*c*((d+1)*c+d)+1)}}})();coherent.Animator=function(){var a={duration:500,actions:{}};var h=null;var w={};var b=0;var u=0;var e=Element.getStyles;function c(A,z){var C={};function B(D){var E=Element.assignId(D);C[E]=e(D,z)}Element.depthFirstTraversal(A,B);return C}function o(){return[this.r,this.g,this.b,this.a].join(",")}function l(z){if(typeof(z)!="string"){return z}var A;if((A=Element.colours[z.toLowerCase()])){z=A}if((A=z.match(/^rgb(?:a)?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d(?:\.\d+)?)\s*)?\)$/i))){return{r:parseInt(A[1],10),g:parseInt(A[2],10),b:parseInt(A[3],10),a:parseInt(A[4]||1,10),toString:o}}if("#"!==z.charAt(0)){if(z=="transparent"){return{r:255,g:255,b:255,a:0}}throw new Error("Invalid colour: "+z)}if(4==z.length){return{r:parseInt(z.charAt(1)+z.charAt(1),16),g:parseInt(z.charAt(2)+z.charAt(2),16),b:parseInt(z.charAt(3)+z.charAt(3),16),a:1,toString:o}}else{return{r:parseInt(z.substr(1,2),16),g:parseInt(z.substr(3,2),16),b:parseInt(z.substr(5,2),16),a:1,toString:o}}}function k(z){if("margin" in z){z.marginLeft=z.marginRight=z.marginTop=z.marginBottom=z.margin;delete z.margin}if("padding" in z){z.paddingLeft=z.paddingRight=z.paddingTop=z.paddingBottom=z.padding;delete z.padding}if("borderColor" in z){z.borderLeftColor=z.borderRightColor=z.borderTopColor=z.borderBottomColor=z.borderColor;delete z.borderColor}if("borderWidth" in z){z.borderLeftWidth=z.borderRightWidth=z.borderTopWidth=z.borderBottomWidth=z.borderWidth;delete z.borderWidth}return z}function f(){if(h){return}u=(new Date()).getTime();h=window.setInterval(d,10)}function m(){if(!h){return}window.clearInterval(h);h=null}function d(){var E,D,z;var B=(new Date()).getTime();coherent.EventLoop._start=B;for(var A in w){var F=w[A];var C=F.properties;for(var G in C){z=C[G][0];if(B>=z.endTime){z.step(1);x(A,G)}else{if(z.startTime<=B){D=(B-z.startTime)/z.totalTime;z.step(D)}}}}u=B}function n(C,A,D,z,B){this.property=C;this.element=A;this.start=l(D);this.end=l(z);if(coherent.Support.CSS3ColorModel){if(this.start.a===0){this.start.r=this.end.r;this.start.g=this.end.g;this.start.b=this.end.b}else{if(this.end.a===0){this.end.r=this.start.r;this.end.g=this.start.g;this.end.b=this.start.b}}this.step=this.stepRGBA}else{this.step=this.stepRGB}this.delta={r:this.end.r-this.start.r,g:this.end.g-this.start.g,b:this.end.b-this.start.b,a:this.end.a-this.start.a};this.shouldCleanup=!!B}n.prototype.stepRGB=function(A){if(this.curve){A=this.curve(A)}var z=["rgb(",Math.round(A*this.delta.r+this.start.r),",",Math.round(A*this.delta.g+this.start.g),",",Math.round(A*this.delta.b+this.start.b),")"].join("");this.element.style[this.property]=z};n.prototype.stepRGBA=function(A){if(this.curve){A=this.curve(A)}var z=["rgba(",Math.round(A*this.delta.r+this.start.r),",",Math.round(A*this.delta.g+this.start.g),",",Math.round(A*this.delta.b+this.start.b),",",A*this.delta.a+this.start.a,")"].join("");this.element.style[this.property]=z};n.prototype.cleanup=function(){this.element.style[this.property]=""};function g(C,A,D,z,B){this.property=C;this.element=A;this.start=parseInt(D||0,10);this.end=parseInt(z||0,10);this.delta=this.end-this.start;this.shouldCleanup=!!B}g.prototype.step=function(z){if(this.curve){z=this.curve(z)}this.element.style[this.property]=Math.round(z*this.delta+this.start)+"px"};g.prototype.cleanup=function(){this.element.style[this.property]=""};function s(A,C,z,B){this.element=A;this.start=parseFloat(C||0);this.end=parseFloat(z||0);this.delta=z-C;this.shouldCleanup=!!B}if(coherent.Browser.IE){s.prototype.step=function(A){if(this.curve){A=this.curve(A)}var z=A*this.delta+this.start;this.element.style.filter=(z>=1)?"":"Alpha(Opacity="+z*100+")"};s.prototype.cleanup=function(){this.element.style.filter=""}}else{s.prototype.step=function(A){if(this.curve){A=this.curve(A)}var z=A*this.delta+this.start;this.element.style.opacity=(z>=1)?1:z};s.prototype.cleanup=function(){this.element.style.opacity=""}}function t(C,A,D,z,B){this.property=C;this.element=A;this.start=D;this.end=z;this.shouldCleanup=!!B}t.prototype.step=function(z){if(z>=this.discreteTransitionPoint){this.element.style[this.property]=this.end;this.step=function(A){}}};t.prototype.cleanup=function(){this.element.style[this.property]=""};function i(A,B,z){this.element=A;this.start=B;this.end=z}i.prototype.step=function(z){if(z>=this.discreteTransitionPoint){this.element.className=this.end;this.step=function(A){}}};function q(D,G,A,F){function E(H){switch(H){case"top":return"0% 50%";case"right":return"100% 50%";case"bottom":return"50% 100%";case"left":return"0% 50%";case"center":return"50% 50%";default:H=H.replace(/top|left/g,"0%");H=H.replace(/bottom|right/g,"100%");return H}}function B(H){return parseInt(H,10)}G=E(G);A=E(A);var C=G.match(/%|px/)[0];var z=A.match(/%|px/)[0];if(C!=z){return new t("backgroundPosition",D,G,A,F)}this.element=D;this.unit=C;this.start=Array.map(G.split(" "),B);this.end=Array.map(A.split(" "),B);this.delta=[this.end[0]-this.start[0],this.end[1]-this.start[1]];this.shouldCleanup=!!F;return this}q.prototype.step=function(z){if(this.curve){z=this.curve(z)}this.element.style.backgroundPosition=Math.round(z*this.delta[0]+this.start[0])+this.unit+" "+Math.round(z*this.delta[1]+this.start[1])+this.unit};q.prototype.cleanup=function(){if(coherent.Browser.IE){this.element.style.backgroundPositionX="";this.element.style.backgroundPositionY=""}else{this.element.style.backgroundPosition=""}};function v(C,A,D,z,B){switch(C){case"_className":return new i(A,D,z);case"display":return new t(C,A,D,z,B);case"backgroundPosition":return new q(A,D,z,B);case"backgroundColor":case"color":case"borderColor":case"borderTopColor":case"borderRightColor":case"borderBottomColor":case"borderLeftColor":return new n(C,A,D,z,B);case"opacity":return new s(A,D,z,B);default:return new g(C,A,D,z,B)}}function x(B,E){var D=[];var C=w[B];var z=C.properties[E].shift();if(z.shouldCleanup&&"function"===typeof(z.cleanup)){z.cleanup()}if("function"==typeof(z.callback)){D.push(z.callback)}if(!C.properties[E].length){delete C.properties[E];C.propCount--}if(!C.propCount){if("function"==typeof(w[B]._callback)){D.push(C._callback)}delete (w[B]);b--}if(!b){m()}var A=D.length;for(var F=0;F<A;F++){D[F](document.getElementById(B),E)}}function j(C,B,E){E=Object.applyDefaults(E,a);if(E.delay){arguments.callee.delay(E.delay,C,B,E);delete E.delay;return}var K=Element.assignId(C);var D=w[K];if(!D){b++;D=w[K]={_node:C,propCount:0,properties:{}}}if("function"==typeof(E.callback)){D._callback=E.callback}var A=coherent.EventLoop.getStart();var z=A+E.duration;var R=E.startStyles||e(C,Set.toArray(B));k(B);for(var M in B){var I=B[M];var N=I;if("object"===typeof(N)&&"value" in N){N=N.value}var S=I.delay||0;var H=A+S;var F;if(I.duration){F=I.duration+H}else{F=z}var L=I.curve||E.curve;var Q=I.discreteTransitionPoint||E.discreteTransitionPoint||0.5;var J=typeof(I.cleanup)!=="undefined"?I.cleanup:E.cleanup;var G;if(M in D.properties){G=D.properties[M]}else{D.propCount++;G=[]}function P(W,X,T){var V=X.startTime<F&&X.endTime>F;var U=X.startTime<H&&X.endTime>H;var Y=X.startTime<=H&&X.endTime>=F;if(!(U||V||Y)){W.push(X)}return W}if(G.length){G=G.reduce(P,[])}var O=v(M,C,R[M],N,J);O.startTime=H;O.endTime=F;O.totalTime=F-H;O.curve=L;O.discreteTransitionPoint=Q;if("object"===typeof(I)&&"callback" in I){O.callback=I.callback}if(E.stepBackToZero){O.step(0)}G.push(O);D.properties[M]=G}f()}function p(z){var A=Element.assignId(z);return !!document.getElementById(A)}function y(I,L,M){M=Object.applyDefaults(M,a);if(M.delay){arguments.callee.delay(M.delay,I,L,M);delete M.delay;return}if(!p(I)){I.className=L;if(M.callback){M.callback()}return}var H=M.only;var D=c(I,H);var B=I.className;I.className=L;for(var A in D){var G=w[A];if(!G){continue}for(var z in G.properties){G._node.style[z]=""}}var F=c(I,H);I.className=B;var K={};K[I.id]={_className:{value:L,duration:M.duration,callback:M.callback}};delete M.callback;function J(Q){var P=Q.id;var S=M.actions[P];var V=D[P];var W=F[P];var Y={};if(!S){var X=V.display;var U=W.display;if(X=="none"&&U=="none"){S=coherent.Animator.IGNORE_NODE}if(X=="none"&&U!=="none"){S=coherent.Animator.FADE_IN_NODE}if(X!=="none"&&U=="none"){S=coherent.Animator.FADE_OUT_NODE}}if("function"===typeof(S)){S=S(Q,D,F)}if("object"==typeof(S)){Y=S;S=coherent.Animator.MORPH_NODE}switch(S){case coherent.Animator.IGNORE_NODE:return false;case coherent.Animator.FADE_NODE:K[P]=K[P]||{};K[P].opacity={value:0,duration:M.duration,curve:coherent.easing.linearCompleteAndReverse};return false;case coherent.Animator.FADE_OUT_NODE:K[P]=K[P]||{};K[P].opacity={value:0,duration:M.duration/2,cleanup:false};return false;case coherent.Animator.FADE_IN_NODE:V.opacity=0;K[P]=K[P]||{};K[P].opacity={value:1,duration:M.duration/2,delay:M.duration/2};return false;case coherent.Animator.MORPH_NODE:default:for(var O in V){var R=w[P];var T=Y[O];var N=T?(T.value||T):W[O];if((R&&O in R.properties)||(String(V[O])!=String(N))){K[P]=K[P]||{};if(O in Y){if(T.value){K[P][O]=T}else{K[P][O]={value:T}}K[P][O].cleanup=false}else{K[P][O]=N}}}return true}}Element.depthFirstTraversal(I,J);M.stepBackToZero=true;M.cleanup=true;for(var C in K){var E=document.getElementById(C);if(!E){continue}M.startStyles=D[C];j(E,K[C],M)}}function r(B,z){var A=Element.regexForClassName(z);return B.replace(A," ")}return{addClassName:function(A,B,z){if(!B){return}var C=Element.regexForClassName(B);var D=A.className;if(!C.test(D)){if(D){D+=" "+B}else{D=B}}y(A,D,z)},removeClassName:function(A,B,z){var D=A.className;var C;if(D===B){y(A,"",z);return}if("string"===typeof(B)){D=r(D,B)}else{D=B.reduce(r,D)}y(A,D,z)},setClassName:function(A,B,z){var C=A.className;y(A,B,z)},replaceClassName:function(C,B,z,A){if(B){var D=Element.regexForClassName(B);z=C.className.replace(D,"$1"+z+"$2")}else{z=C.className+" "+z}y(C,z,A)},setStyles:j,abort:function(){w={};m()}}}();coherent.Animator.FADE_NODE="fade";coherent.Animator.FADE_IN_NODE="fade_in";coherent.Animator.FADE_OUT_NODE="fade_out";coherent.Animator.IGNORE_NODE="ignore";coherent.Animator.MORPH_NODE="morph";coherent.Animator.innerHTML=function(b,a,d){d=d||500;function e(){var h=b.innerHTML;var i=Element.getStyles(b,"height");b.innerHTML=a;var g=Element.getStyles(b,"height");b.innerHTML=h;b.style.height=i;b.style.overflow="hidden";coherent.Animator.setStyles(b,{opacity:{value:0,callback:c}},{duration:d/2});coherent.Animator.setStyles(b,{height:{value:g,curve:coherent.easing.inOutSine}},{duration:d,cleanup:true})}function c(){b.innerHTML=a;coherent.Animator.setStyles(b,{opacity:1},{duration:d/2,callback:f,cleanup:true})}function f(){b.style.overflow=""}if(b.style.display!="none"){e()}else{b.innerHTML=a}};coherent.Animator.innerText=function(b,e,d){d=d||500;function a(g){var f=document.createTextNode(g);b.innerHTML="";b.appendChild(f)}function c(){a(e);coherent.Animator.setStyles(b,{opacity:1},{duration:d/2,cleanup:true})}if(b.style.display!="none"){coherent.Animator.setStyles(b,{opacity:0},{duration:d/2,callback:c})}else{a(e)}};var CancelledError=coherent.defineError("CancelledError");var InvalidStateError=coherent.defineError("InvalidStateError");(function(){var c=-1;var a=0;var b=1;coherent.Deferred=Class.create({constructor:function(d){this.canceller=d;this._result=null;this._status=c;this._callbacks=[]},_fire:function(d){while(this._callbacks.length){this._status=(d instanceof Error)?b:a;this._result=d;var e=this._callbacks.shift()[this._status];if(!e){continue}d=e(d);if(d instanceof coherent.Deferred){var f=this;function g(h){f._fire(h);return h}d.addMethods(g,g);return}}this._status=(d instanceof Error)?b:a;this._result=d},result:function(){return this._result},cancel:function(){if(c!==this._status){throw new InvalidStateError("Can not cancel Deferred because it is already complete")}var d=(this.canceller&&this.canceller());if(!(d instanceof Error)){d=new CancelledError("Deferred operation cancelled")}this.failure(d)},addMethods:function(d,e){this._callbacks.push([d,e]);if(c===this._status){return this}this._fire(this._result);return this},addCallback:function(d){return this.addMethods(d,null)},addErrorHandler:function(d){return this.addMethods(null,d)},callback:function(d){if(c!==this._status){throw new InvalidStateError("Can not signal callback because Deferred is already complete: result="+d)}this._fire(d)},failure:function(d){if(c!==this._status){throw new InvalidStateError("Can not signal failure because Deferred is already complete: error="+d)}this._fire(d)}})})();function URL(b){this.url=b.trim();var c=(/^(([^\:\/\?#]+)\:)?(\/\/([^\/\?#]*))?([^\?#]*)(\?([^#]*))?(#(.*))?$/);var a=this.url.match(c)||[];this.protocol=a[2]||"";this.authority=a[4]||"";this.path=a[5].trim()||"";this.query=a[7]||"";this.fragment=a[9]||"";c=(/^(([^@]+)@)?([^\:]+)(:(.+))?$/);a=this.authority.match(c);this.userInfo=a[2]||"";this.host=a[3]||"";this.port=a[5]||""}coherent.FormControl=Class.create(coherent.View,{exposedBindings:["value","name"],init:function(){this.base();var a=this.viewElement();coherent.Form.setupResetLogic(a.form);var b=this.bindings;if(b.value&&!b.value.hasValue()&&a.value){b.value.setValue(a.value)}if(b.name&&!b.name.hasValue()&&a.name){b.name.setValue(a.name)}},onreset:function(){var a=this.viewElement();if(this.bindings.value&&a.value){this.bindings.value.setValue(a.value)}},observeValueChange:function(c){var a=this.viewElement();var b=c.newValue;if("undefined"===typeof(b)){a.disabled=true}else{if(!this.bindings.enabled){a.disabled=false}}if(!this.bindings.editable){a.readOnly=!this.bindings.value.mutable()||coherent.Markers.MultipleValues===b||coherent.Markers.NoSelection===b}if(a.readOnly){Element.addClassName(a,coherent.Style.kReadOnlyClass)}else{Element.removeClassName(a,coherent.Style.kReadOnlyClass)}if(a.disabled){Element.addClassName(a,coherent.Style.kDisabledClass)}else{Element.removeClassName(a,coherent.Style.kDisabledClass)}a.value=b},observeNameChange:function(d,c,b){var a=this.viewElement();a.name=d.newValue},validate:function(){return this.viewElement().value}});coherent.Button=Class.create(coherent.FormControl,{__viewClassName__:"Button",__tagSpec__:["input[type=button]","input[type=submit]","input[type=reset]","button"],requireBindingsForInferredViewType:false,onmousedown:function(b){var a=this.viewElement();Element.addClassName(a,coherent.Style.kActiveClass)},onmouseup:function(b){var a=this.viewElement();Element.removeClassName(a,coherent.Style.kActiveClass)},onclick:function(a){this.sendAction()}});coherent.EventLoop={currentEvent:null,getStart:function(){if(!this._start){this._start=new Date().getTime()}return this._start},begin:function(a){this._start=new Date().getTime();this.currentEvent=a},end:function(){this.currentEvent=null;this._start=null}};coherent.Form=Class.create(coherent.FieldGroup,{exposedBindings:["actionUrl","method"],sendActionOn:["submit"],init:function(){this.base();var a=this.viewElement();var b=this.bindings;if(b.actionUrl&&!b.actionUrl.hasValue()&&a.action){b.actionUrl.setValue(a.action)}if(b.method&&!b.method.hasValue()&&a.method){b.method.setValue(a.method)}coherent.Form.removeResetLogic(a);Event.observe(a,"submit",this.onsubmit.bind(this));Event.observe(a,"reset",this.onreset.bind(this))},onreset:function(b){var a=this.viewElement();coherent.Form.resetAllFields.delay(50,a)},onsubmit:function(a){if(!this.action||!this.sendActionOn.containsObject("submit")){return}Event.stop(a);this.sendAction()},observeActionUrlChange:function(d,c,b){var a=this.viewElement();a.action=d.newValue},observeMethodChange:function(d,c,b){var a=this.viewElement();a.method=d.newValue}});(function(){var b={};coherent.Form.resetAllFields=function(f){var g=f.elements;var c=g.length;var e;var d;for(e=0;e<c;++e){d=coherent.View.fromNode(g[e]);if(!d||!d.onreset){continue}d.onreset()}};function a(d){d=d||window.event;var c=d.target||d.srcElement;coherent.Form.resetAllFields.delay(50,c)}coherent.Form.setupResetLogic=function(c){if(!c){return}var d=Element.assignId(c);if(b[d]){return}Event.observe(c,"reset",a);b[d]=true};coherent.Form.removeResetLogic=function(c){if(!c){return}Event.stopObserving(c,"reset",a);delete b[c.id]}})();coherent.ImageView=Class.create(coherent.View,{__viewClassName__:"Image",__tagSpec__:["img","input[type=image]"],exposedBindings:["src","alt","width","height"],multipleValuesPlaceholder:_("marker.image.multipleValues"),nullPlaceholder:_("marker.image.placeholder"),noSelectionPlaceholder:_("marker.image.noSelection"),init:function(){this.base();var a=this.viewElement();Event.observe(a,"error",this.onerror.bind(this));Event.observe(a,"load",this.onload.bind(this));var b=this.bindings;if(b.src&&!b.src.hasValue()&&a.src){b.src.setValue(a.src)}if(b.alt&&!b.alt.hasValue()&&a.alt){b.alt.setValue(a.alt)}if(b.width&&!b.width.hasValue()&&a.width){b.width.setValue(a.width)}if(b.height&&!b.height.hasValue()&&a.height){b.height.setValue(a.height)}},onload:function(){var a=this.viewElement();this.setValueForKey(false,"loading");Element.removeClassName(a,coherent.Style.kLoadingClass)},onerror:function(){var a=this.viewElement();this.setValueForKey(false,"loading");Element.updateClass(a,coherent.Style.kInvalidValueClass,coherent.Style.kLoadingClass)},src:function(){var a=this.viewElement().src;return("about:blank"===a)?null:a},setSrc:function(c){if(this.bindings.src){this.bindings.src.setValue(c)}this.setValueForKey(true,"loading");var b=this.viewElement();Element.updateClass(b,coherent.Style.kLoadingClass,coherent.Style.kInvalidValueClass);if(!c){c="about:blank"}var a=b.src;b.src=c;if(coherent.Browser.Safari&&b.src===a){this.onload()}},observeSrcChange:function(e){var c=this;var a=this.viewElement();var d=e.newValue;var b=true;switch(d){case"":case null:case undefined:d=this.attributeOrProperty("nullPlaceholder");break;case coherent.Markers.NoSelection:d=this.attributeOrProperty("noSelectionPlaceholder");break;case coherent.Markers.MultipleValues:d=this.attributeOrProperty("multipleValuesPlaceholder");break;default:b=false;break}if(b){Element.addClassName(a,coherent.Style.kMarkerClass)}else{Element.removeClassName(a,coherent.Style.kMarkerClass)}this.setSrc(d)},observeWidthChange:function(c){var a=this.viewElement();var b=parseInt(c.newValue,10);if(isNaN(b)){a.removeAttribute("width")}else{a.width=b}},observeAltChange:function(c){var a=this.viewElement();var b=c.newValue;if(b===null||"undefined"===typeof(b)){a.alt=""}else{a.alt=b}},observeHeightChange:function(c){var b=this.viewElement();var a=parseInt(c.newValue,10);if(isNaN(a)){b.removeAttribute("height")}else{b.height=a}}});coherent.Media=Class.create(coherent.View,{exposedBindings:["src","currentTime","volume","muted"],init:function(){var a=this.viewElement();var b=this.bindings;if(b.src&&!b.src.hasValue()&&a.src){b.src.setValue(a.src)}if(b.currentTime&&!b.currentTime.hasValue()){b.currentTime.setValue(a.currentTime)}if(b.duration&&!b.duration.hasValue()){b.duration.setValue(a.duration)}if(b.volume&&!b.volume.hasValue()){b.volume.setValue(a.volume)}if(b.muted&&!b.muted.hasValue()){b.muted.setValue(a.muted)}Event.observe(a,"ended",this.mediaDidEnd.bindAsEventListener(this))},pause:function(){var a=this.viewElement();if(!a.paused){a.pause()}},play:function(){var a=this.viewElement();a.play();this.forceChangeNotificationForKey("ended")},stop:function(){var a=this.viewElement();a.currentTime=a.duration},muted:function(){var a=this.viewElement();return a.muted},mediaDidEnd:function(a){this.forceChangeNotificationForKey("ended")},ended:function(){var a=this.viewElement();return a.ended},src:function(){var a=this.viewElement();return a.src},setSrc:function(c){if(this.bindings.src){this.bindings.src.setValue(c)}var b=this.viewElement();var d=this;function a(){b.src=c;b.load();d.forceChangeNotificationForKey("ended")}a.delay(0)}});coherent.Page=Class.create(coherent.Responder,{constructor:function(){this.firstResponder=null;this.__hoverTrackingIds={};this._onmousedragHandler=this._onmousedrag.bindAsEventListener(this);this._delegates={click:[]};this.onclick=this._fireDelegates},targetViewForEvent:function(c){var b=c.target||c.srcElement;var a;var d=coherent.View.fromNode;while(b&&b!=document&&!(a=d(b))){b=b.parentNode}if(!b||b==document){return null}return a},makeFirstResponder:function(a){if(this.firstResponder==a){return true}if(this.firstResponder&&!this.firstResponder.resignFirstResponder()){return false}if(this.firstResponder){Element.removeClassName(this.firstResponder.viewElement(),coherent.Style.kFocusClass)}if(a&&!a.becomeFirstResponder()){return false}this.willChangeValueForKey("firstResponder");this.firstResponder=a;this.didChangeValueForKey("firstResponder");if(a){a.focus();Element.addClassName(a.viewElement(),coherent.Style.kFocusClass)}return true},addTrackingInfo:function(c,b){if("string"!==typeof(c)){c=Element.assignId(c)}var a=this.__hoverTrackingIds[c];if(!a){a=this.__hoverTrackingIds[c]=[]}a.push(b)},superview:function(){return null},presentError:function(a){function b(){var c=a.description;if(a.recoverySuggestion){c+="\n"+a.recoverySuggestion}window.alert(c);coherent.page.makeFirstResponder(a.field)}b.delay(0)},delegate:function(a,c,b){if("string"===typeof(c)){this._delegates[c].push({sel:a,fn:b})}else{var d;for(d in c){if(!(d in this._delegates)){throw new Error("Invalid delegation event type: "+d)}this._delegates[d].push({sel:a,fn:c[d]})}}},superview:function(){return null},_fireDelegates:function(e){var c=e.target||e.srcElement;var b=Element.match;var a=this._delegates[e.type]||[];function d(f){if(b(c,f.sel)){f.fn(e)}}a.forEach(d)},_findFirstResponder:function(a){while(a&&!a.acceptsFirstResponder()){a=a.superview()}if(!a){this.makeFirstResponder(null);return}this.makeFirstResponder(a)},_onmousedown:function(b){var a=this.targetViewForEvent(b);if(a){this._findFirstResponder(a);a.onmousedown(b);Event.observe(document,"mousemove",this._onmousedragHandler)}this._mousedownView=a},_onmouseup:function(a){if(this._mousedownView){this._mousedownView.onmouseup(a)}Event.stopObserving(document,"mousemove",this._onmousedragHandler)},_onmousedrag:function(a){if(this._mousedownView){this._mousedownView.onmousedrag(a)}},_onmouseover:function(a){var g=this.__hoverTrackingIds||{};var o=this.__mouseOverIds||{};var d={};var k=a.target||a.srcElement;var h=document.body;var l;var n;var b;var f;var j;var m;for(;k&&k!=h;k=k.parentNode){b=k.id;if(!b||!(b in g)){continue}d[b]=true;if(b in o){continue}l=g[b];j=l.length;for(f=0;f<j;++f){m=l[f];if(m.onmouseenter){m.onmouseenter.call(m.owner,k,m.ownerInfo)}}}for(b in o){if(b in d){continue}k=document.getElementById(b);if(!k){continue}l=g[b];j=l.length;for(f=0;f<j;++f){m=l[f];if(m.onmouseleave){m.onmouseleave.call(m.owner,k,m.ownerInfo)}}}this.__mouseOverIds=d},_onmouseout:function(a){},_onclick:function(b){if(coherent.Browser.Mozilla&&b.button===2){return}var a=this.targetViewForEvent(b);if(a){a.onclick(b)}else{this._fireDelegates(b)}},_ondblclick:function(a){if(this._mousedownView){this._mousedownView.ondblclick(a)}},_onkeydown:function(a){var b=this.firstResponder;if(b){b.onkeydown(a)}},_onkeyup:function(a){var b=this.firstResponder;if(b){b.onkeyup(a)}},_onkeypress:function(a){var b=this.firstResponder;if(b){b.onkeypress(a)}},_onfocus:function(b){var c=(b.target||b.srcElement)==document;if(c){this.makeFirstResponder(this._previousFirstResponder||null);this._previousFirstResponder=null}else{var a=this.targetViewForEvent(b);if(a&&a.acceptsFirstResponder()){this.makeFirstResponder(a)}else{this.makeFirstResponder(null)}}},_onblur:function(b){var c=(b.target||b.srcElement)==document;if(c){this._previousFirstResponder=this.firstResponder;this.makeFirstResponder(null)}else{var a=this.targetViewForEvent(b);if(a&&a.acceptsFirstResponder()){this.makeFirstResponder(null)}}},_ontouchstart:function(b){var a=this.targetViewForEvent(b);if(a){a.ontouchstart(b);a.onmousedown(b)}this._touchstartView=a;this._touchmoved=false},_ontouchmove:function(a){if(this._touchstartView){this._touchstartView.ontouchmove(a)}this._touchmoved=true},_ontouchend:function(a){if(this._touchstartView){this._touchstartView.ontouchend(a);this._touchstartView.onmouseup(a);if(!this._touchmoved){this._touchstartView.onclick(a)}}},_ontouchcancel:function(a){if(this._touchstartView){this._touchstartView.ontouchend(a);this._touchstartView.onmouseup(a);if(!this._touchmoved){this._touchstartView.onclick(a)}}},_onunload:function(){var b;var a=coherent.View.viewLookup;for(b in a){a[b].teardown();delete a[b]}}});(function(){coherent.page=new coherent.Page();window._setTimeout=window.setTimeout;window.setTimeout=function(f,e){if(!f){return null}if("string"===typeof(f)){f="coherent.EventLoop.begin();do {"+f+"} while (false); coherent.EventLoop.end();";return window._setTimeout(f,e)}var d=Array.from(arguments,2);function c(){coherent.EventLoop.begin();var g=f.apply(this,d);coherent.EventLoop.end();return g}return window._setTimeout(c,e)};window._setInterval=window.setInterval;window.setInterval=function(f,e){if(!f){return null}if("string"===typeof(f)){f="coherent.EventLoop.begin();do {"+f+"} while (false); coherent.EventLoop.end();";return window._setInterval(f,e)}var d=Array.from(arguments,2);function c(){coherent.EventLoop.begin();var g=f.apply(this,d);coherent.EventLoop.end();return g}return window._setInterval(c,e)};var b=coherent.page;var a;if(coherent.Browser.IE){a=function(c){return function(){coherent.EventLoop.begin(window.event);b[c](window.event);coherent.EventLoop.end()}};document.attachEvent("onmouseover",a("_onmouseover"));document.attachEvent("onmouseout",a("_onmouseout"));document.attachEvent("onmousedown",a("_onmousedown"));document.attachEvent("onmouseup",a("_onmouseup"));document.attachEvent("onclick",a("_onclick"));document.attachEvent("ondblclick",a("_ondblclick"));document.attachEvent("onkeydown",a("_onkeydown"));document.attachEvent("onkeyup",a("_onkeyup"));document.attachEvent("onkeypress",a("_onkeypress"));document.attachEvent("onfocusin",a("_onfocus"));document.attachEvent("onfocusout",a("_onblur"));window.attachEvent("focus",a("_onfocus"));window.attachEvent("blur",a("_onblur"));window.attachEvent("onunload",a("_onunload"))}else{a=function(c){return function(d){coherent.EventLoop.begin(d);b[c](d);coherent.EventLoop.end()}};document.addEventListener("mouseover",a("_onmouseover"),false);document.addEventListener("mouseout",a("_onmouseout"),false);document.addEventListener("mousedown",a("_onmousedown"),false);document.addEventListener("mouseup",a("_onmouseup"),false);document.addEventListener("keydown",a("_onkeydown"),false);document.addEventListener("keyup",a("_onkeyup"),false);document.addEventListener("keypress",a("_onkeypress"),false);document.addEventListener("focus",a("_onfocus"),true);document.addEventListener("blur",a("_onblur"),true);window.addEventListener("focus",a("_onfocus"),false);window.addEventListener("blur",a("_onblur"),false);if(!coherent.Browser.MobileSafari){document.addEventListener("click",a("_onclick"),false);document.addEventListener("dblclick",a("_ondblclick"),false)}if(coherent.Support.Touches){document.addEventListener("touchstart",a("_ontouchstart"),true);document.addEventListener("touchmove",a("_ontouchmove"),true);document.addEventListener("touchend",a("_ontouchend"),true);document.addEventListener("touchcancel",a("_ontouchcancel"),true)}}})();coherent.TextField=Class.create(coherent.FormControl,{__viewClassName__:"TextField",__tagSpec__:["input[type=text]","input[type=password]","input[type=hidden]","textarea"],init:function(){this.base();var a=this.viewElement();Event.observe(a,"change",this.valueChanged.bindAsEventListener(this));Event.observe(a,"drop",this.fieldReceivedDropEvent.bindAsEventListener(this));this.editing=false;this.validationError=null},exposedBindings:["errorMessage"],multipleValuesPlaceholder:_("marker.input.multipleValues"),nullPlaceholder:_("marker.input.placeholder"),noSelectionPlaceholder:_("marker.input.noSelection"),keypressUpdateTimeout:500,continuallyUpdatesValue:true,sendsActionOnEndEditing:true,sendActionOn:["blur","keydown"],beginEditing:function(){this.editing=true},endEditing:function(){this.editing=false;if(this.sendsActionOnEndEditing&&this.action){this.sendAction()}},validate:function(){var a=this.viewElement();var c=a.value;if(this.formatter){var b=this.formatter.isStringValid(c);if(b!==true){this.presentError(b);return b}c=this.formatter.valueForString(c)}if(this.bindings.value){c=this.bindings.value.validateProposedValue(c);if(c instanceof coherent.Error){this.presentError(c);return c}}this.clearAllErrors();return c},presentError:function(a){this.validationError=a;Element.addClassName(this.viewElement(),coherent.Style.kInvalidValueClass);return this.base.apply(this,arguments)},clearAllErrors:function(){this.validationError=null;Element.removeClassName(this.viewElement(),coherent.Style.kInvalidValueClass);return this.base.apply(this,arguments)},acceptsFirstResponder:function(){var a=this.viewElement();if(a.disabled||a.readOnly){return false}return true},becomeFirstResponder:function(){var a=this.viewElement();if(a.disabled||a.readOnly){return false}if(this.markerValue){this.clearMarkerValue()}this.hasFocus=true;this.beginEditing();return true},resignFirstResponder:function(b){var a=this.viewElement();this.hasFocus=false;if(""===a.value){this.setMarkerValue("nullPlaceholder")}this.endEditing();return true},setMarkerValue:function(b){var a=this.viewElement();var c=this.attributeOrProperty(b);this.markerValue=b;a.value=c;Element.addClassName(a,coherent.Style.kMarkerClass)},clearMarkerValue:function(){var a=this.viewElement();this.markerValue=false;a.value="";Element.removeClassName(a,coherent.Style.kMarkerClass)},valueChanged:function(a){if(this.updateTimer){window.clearTimeout(this.updateTmer);this.updateTimer=null}if(this.markerValue){return}var b=this.validate();if(!(b instanceof coherent.Error)&&this.bindings.value){this.bindings.value.setValue(b);if(this.validationError){this.clearAllErrors()}}},fieldReceivedDropEvent:function(b){var a=this.viewElement();a.value=""},onkeyup:function(b){if(!this.continuallyUpdatesValue){return}var a=this.viewElement();if(this.updateTimer){window.clearTimeout(this.updateTimer)}if(a.readOnly||a.disabled){return}this.updateTimer=this.valueChanged.bindAndDelay(this,this.keypressUpdateTimeout)},onkeydown:function(a){if(this.action&&a.keyCode===Event.KEY_RETURN){this.valueChanged(null);if(this.validationError){return}this.sendAction();Event.stop(a)}},onkeypress:function(a){if(!this.formatter){return}if(!a.charCode||a.altKey||a.metaKey||a.ctrlKey){return}var b=String.fromCharCode(a.charCode||a.keyCode);if(!this.formatter.isValidInputCharacter(b)){Event.stop(a)}},observeValueChange:function(c){var a=this.viewElement();var b=c.newValue;if(this.formatter){b=this.formatter.stringForValue(b)}if("undefined"===typeof(b)){a.disabled=true}else{if(!this.bindings.enabled){a.disabled=false}}if(!this.bindings.editable){a.readOnly=!this.bindings.value.mutable()||coherent.Markers.MultipleValues===b||coherent.Markers.NoSelection===b}if(a.readOnly){Element.addClassName(a,coherent.Style.kReadOnlyClass)}else{Element.removeClassName(a,coherent.Style.kReadOnlyClass)}if(a.disabled){Element.addClassName(a,coherent.Style.kDisabledClass)}else{Element.removeClassName(a,coherent.Style.kDisabledClass)}if(!this.bindings.errorMessage){this.clearAllErrors()}if(this.hasFocus){return}switch(a.type){case"text":case"password":case"textarea":if(null===b||"undefined"===typeof(b)||""===b){this.setMarkerValue("nullPlaceholder")}else{if(coherent.Markers.NoSelection===b){this.setMarkerValue("noSelectionPlaceholder")}else{if(coherent.Markers.MultipleValues===b){this.setMarkerValue("multipleValuesPlaceholder")}else{this.clearMarkerValue();a.value=b}}}break;default:a.value=b;break}},observeErrorMessageChange:function(c){var b=c.newValue;if(!b){this.clearAllErrors();return}var a=new coherent.Error({description:c.newValue});this.presentError(a)}});coherent.SearchField=Class.create(coherent.TextField,{__viewClassName__:"Search",__tagSpec__:"input[type=search]",exposedBindings:["predicate"],init:function(){this.base();var a=this.viewElement();if("search"===a.type){Event.observe(a,"search",this.valueChanged.bindAsEventListener(this))}},keypressUpdateTimeout:25,valueChanged:function(a){this.base(a);if(this.bindings.predicate){this.bindings.predicate.setValue(this.createFilterPredicate())}},createFilterPredicate:function(){var a=this.viewElement();var d=this.attributeOrProperty("predicate");var c=a.value.toLowerCase();function b(f){var e=f.valueForKeyPath(d);if(!e){return !!c}if(e.toLocaleString){e=e.toLocaleString()}else{e=e.toString()}e=e.toLowerCase();return(-1!==e.indexOf(c))}return b},observePredicateChange:function(a){}});coherent.SelectField=Class.create(coherent.ListView,{__viewClassName__:"Select",__tagSpec__:"select",exposedBindings:["displayValues","contentValues","selectedValue","name"],_initFromDOM:function(){var a=this.container();var p=this.viewElement();var c=this.bindings;var k=[];var q=[];var o=[];var m=[];var n=this._items();var j=n.length;var l;if(p.name&&c.name&&!c.name.hasValue()){c.name.setValue(p.name)}if(!j||(c.content&&c.content.hasValue())){return}var h=c.displayValues&&c.displayValues.keyPath;var b=c.contentValues&&c.contentValues.keyPath;var d=c.content&&c.content.keyPath;if(h&&h.beginsWith(d)){h=h.substring(d.length+1)}else{h=null}if(b&&b.beginsWith(d)){b=b.substring(d.length+1)}else{b=null}var f=this.objectClass||coherent.KVO;for(var g=0;g<j;++g){l=n[g];l.objectValue=m[g]=new f();if(h){l.objectValue.setValueForKeyPath(l.innerText||l.text,h)}if(b){l.objectValue.setValueForKeyPath(l.value,b)}if(l.selected){k.push(g);q.push(l.objectValue);o.push(l.value)}}this._selectionIndexes=k;this.selectedIndex=k.length?k[0]:-1;if(c.content){c.content.setValue(m)}if(c.selectionIndexes&&k.length){c.selectionIndexes.setValue(k)}if(c.selectedObject&&q.length){c.selectedObject.setValue(q[0])}if(c.selectedIndex){c.selectedIndex.setValue(this.selectedIndex)}if(c.selectedValue&&o.length){c.selectedValue.setValue(o[0])}},observeContentValuesChange:function(g){var b=this.viewElement();var e;var d;var f=b.options;var a=f.length;switch(g.changeType){case coherent.ChangeType.setting:if(!g.newValue){break}for(e=0;e<a;++e){f[e].value=g.newValue[e]}break;case coherent.ChangeType.insertion:case coherent.ChangeType.replacement:var c;for(c=0;c<g.indexes.length;++c){e=g.indexes[c];d=f[e];d.value=g.newValue[c]}break;default:console.log("Unknown change type: "+g.changeType);break}},observeDisplayValuesChange:function(g){var b=this.viewElement();var e;var d;var f=b.options;var a=f.length;switch(g.changeType){case coherent.ChangeType.setting:if(!g.newValue){break}for(e=0;e<a;++e){if(coherent.Browser.IE){f[e].innerText=g.newValue[e]}else{f[e].text=g.newValue[e]}}break;case coherent.ChangeType.insertion:case coherent.ChangeType.replacement:var c;for(c=0;c<g.indexes.length;++c){e=g.indexes[c];d=f[e];d.text=g.newValue[c]}break;default:console.log("Unknown change type: "+g.changeType);break}},observeSelectedValueChange:function(f,h,b){if(this.bindings.content&&!this.bindings.content.value()){return}var g=this.viewElement();var i=g.options;var e=i.length;var a=f.newValue;g.disabled="undefined"===typeof(a)||coherent.Markers.MultipleValues===a||coherent.Markers.NoSelection===a;var d=[];for(var c=0;c<e;++c){if(i[c].value==a){d=[c];break}}this.setSelectionIndexes(d)},observeNameChange:function(d,c,b){var a=this.viewElement();a.name=d.newValue}});coherent.TableHeaderView=Class.create(coherent.View,{__viewClassName__:"TableHeader",exposedBindings:["sortDescriptors"],init:function(){this.base();var a=this.viewElement();if(!a.rows.length){return}var e=a.rows[0];var d=e.cells;var f=d.length;var c;this.__selectedColumn=-1;this.__sortKeyIndex={};for(var b=0;b<f;++b){c=d[b].getAttribute("sortKey");if(!c){continue}this.__sortKeyIndex[c]=b}},selectedColumn:function(){return this.__selectedColumn},setSelectedColumn:function(c){var b=this.viewElement();if(!b.rows.length){return}if(this.__selectedColumn===c){return}var e;var d=b.rows[0];if(-1!==this.__selectedColumn){e=d.cells[this.__selectedColumn];var a=e.__ascending?coherent.Style.kAscendingClass:coherent.Style.kDescendingClass;Element.updateClass(e,[],[coherent.Style.kSelectedClass,a])}this.__selectedColumn=c;if(-1!==this.__selectedColumn){e=d.cells[this.__selectedColumn];var f=e.__ascending?coherent.Style.kAscendingClass:coherent.Style.kDescendingClass;var g=e.__ascending?coherent.Style.kDescendingClass:coherent.Style.kAscendingClass;Element.updateClass(e,[coherent.Style.kSelectedClass,f],g)}},onclick:function(e){var a=this.viewElement();var b;var h=e.target||e.srcElement;while(h&&!(b=h.getAttribute("sortKey"))){if(h.parentNode==a){return}h=h.parentNode}if(!h){return}var d=this.__sortKeyIndex[b];if(this.__selectedColumn==d){h.__ascending=h.__ascending?false:true;var c=coherent.Style.kAscendingClass;var g=coherent.Style.kDescendingClass;if(h.__ascending){Element.updateClass(h,c,g)}else{Element.updateClass(h,g,c)}}else{this.setSelectedColumn(d)}var f=new coherent.SortDescriptor(b,h.__ascending?true:false);if(this.bindings.sortDescriptors){this.bindings.sortDescriptors.setValue([f])}},observeSortDescriptorsChange:function(c){var b=c.newValue;if(!b||!b.length||b.length>1){this.setSelectedColumn(-1);return}var a=this.__sortKeyIndex[b[0].keyPath];if("undefined"===typeof(a)||null===a){a=-1}this.setSelectedColumn(a)}});coherent.ToggleButton=Class.create(coherent.FormControl,{exposedBindings:["checked","selection"],__viewClassName__:"ToggleButton",__tagSpec__:["input[type=checkbox]","input[type=radio]"],init:function(){this.base();var a=this.viewElement();var b=this.bindings;if(b.checked&&!b.checked.hasValue()){b.checked.setValue(a.checked)}if(b.selection&&!b.selection.hasValue()&&a.checked&&a.value){b.selection.setValue(a.value)}},onreset:function(){this.base();var a=this.viewElement();if(this.bindings.checked){this.bindings.checked.setValue(a.checked)}if(this.bindings.selection&&a.checked&&a.value){this.bindings.selection.setValue(a.value)}},onclick:function(c){var a=this.viewElement();var b=a.checked;if(this.bindings.selection){this.bindings.selection.setValue(a.value)}if(this.bindings.checked){this.bindings.checked.setValue(b)}this.sendAction()},observeValueChange:function(c){this.base(c);var a=this.viewElement();var b=c.newValue;a.value=b;if(!this.bindings.selection){return}a.checked=(this.bindings.selection.value()==b);if(this.bindings.checked){this.bindings.checked.setValue(a.checked)}},observeCheckedChange:function(e,d,b){var a=this.viewElement();var c=!!e.newValue;a.checked=c;if(this.bindings.selection){this.bindings.selection.setValue(a.value)}},observeSelectionChange:function(e,d,b){var a=this.viewElement();var c=(e.newValue===a.value);a.checked=c;if(this.bindings.checked){this.bindings.checked.setValue(c)}}});coherent.ViewController=Class.create(coherent.Responder,{view:null,title:null,automaticallySetupBindings:false,constructor:function(b,c){this.base(c);if("string"===typeof(b)){this.__viewId=b}else{if(b&&1===b.nodeType){this.__viewId=Element.assignId(b)}else{this.__viewId=b.id}}var a=document.getElementById(this.__viewId);this.viewElement=function(){return a}},registerWithName:function(a){if(!a){return}this.name=a;coherent.registerModelWithName(this,a)},nextResponder:function(){return this.view.superview()},structure:function(){return this.__structure__},viewElement:function(){return this.view.viewElement()},addTrackingInfo:function(a,b){coherent.page.addTrackingInfo(a,b)},__postConstruct:function(){var a=document.getElementById(this.__viewId);if(a){this.__init()}else{Event.onDomReady(this.__init.bind(this))}},__init:function(){this.__initialising=true;var d=document.getElementById(this.__viewId);if(!d){throw new Error("Unable to locate node with ID: "+this.__viewId)}var f=this.__context;var a=coherent.dataModel;this.__context=coherent.dataModel=this;var c=this.structure()||{};var g={};var e;var h;this.__copyParameters(this.__parameters||{});var b=coherent.View.fromNode(d);for(h in c){e=c[h];if(e&&"function"==typeof(e)&&(e=e.valueOf()).__factoryFn__){g[h]=e;e.call(this,h,true)}}for(h in g){g[h].call(this,h,false)}if(!b){coherent.View.createViewsForNodeTree(d,null,this);b=coherent.View.createViewForNode(d)}this.view=b;this.view.setNextResponder(this);coherent.dataModel=a;this.__context=f;this.setupBindings();this.init();this.updateBindings();this.createObservers();delete this.__initialising;delete this.viewElement},init:function(){}});coherent.ViewController.__subclassCreated__=function(a){var b=a.prototype;var c=a.superclass.prototype;if(b.__structure__!==c.__structure__){Object.applyDefaults(b.__structure__,c.__structure__)}};