/*!
    Copyright 2009 5to1.com
*/

/*
    Copyright © 2005-2008 Apple Inc. All Rights Reserved.
    
    Sizzle selector engine Copyright (c) 2009 John Resig <http://sizzlejs.com/>
*/
if("undefined"!==typeof(coherent)){throw new Error("Library module (coherent) already defined")}var coherent={version:"2.0.1",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/),SeleniumActive:(-1!==window.name.indexOf("selenium"))};coherent.Support={Properties:("__defineGetter__" in Object.prototype),QuerySelector:("querySelector" in document),Touches:!!document.createTouch,CSS3ColorModel:false,CSSTransitions:false,BorderImage:false,DragAndDrop:!coherent.Browser.SeleniumActive&&((coherent.Browser.Safari&&!coherent.Browser.MobileSafari)||coherent.Browser.IE||(coherent.Browser.Mozilla&&!!window.localStorage))};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.Support.__defineGetter__("BorderImage",function(){delete this.BorderImage;var a=document.createElement("div").style;try{a.cssText="-webkit-border-image: inherit; -moz-border-image: inherit;";return this.BorderImage=((a.WebkitBorderImage=="inherit")||(a.MozBorderImage=="inherit"))}catch(b){}return(this.BorderImage=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.compareNumbers=function(b,a){return b-a};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(){}}if("undefined"===typeof(window.console.error)){window.console.error=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 a=arguments.length?this.bind.apply(this,arguments):this;var c={};var b=false;a.stop=function(){b=true};a.waitFor=function(d){if(d in c){c[d]+=1}else{c[d]=1}return function(){if(0!==(c[d]-=1)){return}if(b){return}for(var e in c){if(c[e]){return}}a()}};return a};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.markMethods=function(d,b){var a;b=b?(b+"."):"";for(var c in d){a=d[c];if("function"===typeof(a)){a.displayName=b+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)}else{l=""}if(l){g.push(h+"="+l)}else{g.push(h)}}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("&")}})();Object.markMethods(Object,"Object");RegExp.escape=function(a){return a.replace(RegExp._escapeRegex,"\\$1")};RegExp.specialCharacters=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];RegExp._escapeRegex=new RegExp("(\\"+RegExp.specialCharacters.join("|\\")+")","g");var Class=(function(){function h(j,m){var k;if(!j&&!m){return j}if(!j){k=function(){return m.apply(this,arguments)}}else{var l=/this\.base/.test(j);if(!l&&!m){return j}if(!l){k=function(){m.call(this);return j.apply(this,arguments)}}else{k=function(){var o=this.base;this.base=m||function(){};var n=j.apply(this,arguments);this.base=o;return n}}}k.valueOf=function(){return j};k.toString=function(){return String(j)};k.displayName="Constructor wrapper";return k}function e(j,k){var l=j.prototype.__factory__.apply(j,k);if("function"!==typeof(l)){throw new Error("Factory function doesn't return a function")}l.__factoryFn__=true;return l}function a(l){if(l.__createFactoryObjects){l.__createFactoryObjects();return}var k;var j;for(k in l.__factories__){j=l[k];if(!j.__factoryFn__){continue}l[k]=j.call(l)}}function d(j,l){if(j&&!(j instanceof Function)){throw new Error("Invalid constructor")}if(l&&!(l instanceof Function)){throw new Error("Invalid superclass")}l=l?l.valueOf():null;j=h(j,l);var k;if(j){j.displayName="Constructor";k=function(){if(!(this instanceof k)){return e(k,arguments)}this.__uid=this.__uid||coherent.generateUid();var m=j.apply(this,arguments);if(m){return m}a(this);if(this.__postConstruct instanceof Function){this.__postConstruct()}return this}}else{k=function(){if(!(this instanceof k)){return e(k,arguments)}this.__uid=this.__uid||coherent.generateUid();a(this);if(this.__postConstruct instanceof Function){this.__postConstruct()}return this}}k.valueOf=function(){return j};k.toString=function(){return String(j||k)};k.displayName="Generated constructor";return k}function g(k){function j(){}j.prototype=k.prototype;return new j()}function f(){}function b(m,k,l){if(!m||!/this\.base/.test(m)){return m}function j(){var o=this.base;this.base=l[k]||f;var n=m.apply(this,arguments);this.base=o;return n}j.valueOf=function(){return m};j.toString=function(){return String(m)};if("__factoryFn__" in m){j.__factoryFn__=m.__factoryFn__}j.displayName=m.displayName||k;return j}function i(k,j,l,n){var m=(l instanceof Function);if(m){l.displayName=j;if(n){l=b(l,j,n)}if(l.__factoryFn__){k.__factories__[j]=l}}k[j]=l;return l}function c(k){var j;for(j=k.superclass;j;j=j.superclass){if("__subclassCreated__" in j){j.__subclassCreated__(k)}}}return{create:function(m,k){var j;var l={};switch(arguments.length){case 0:throw new TypeError("Missing superclass and declaration arguments");case 1:k=m;m=undefined;break;default:l=g(m);break}if("function"==typeof(k)){k=k();if(!k){throw new Error("Class declaration function did not return a prototype")}}if(k.hasOwnProperty("constructor")){j=k.constructor;delete k.constructor}j=d(j,m);j.prototype=l;j.prototype.constructor=j;j.superclass=m;if(m){l.__factories__=Object.clone(m.prototype.__factories__)}else{l.__factories__={}}j.__class_id__=coherent.generateUid();l.__class_id__=coherent.generateUid();this.extend(j,k);c(j);return j},findPropertyName:function(m,j){var k;for(var l in m){k=m[l];if(k===j||("function"===typeof(k)&&k.valueOf()===j)){return l}}return null},extend:(function(){if(coherent.Support.Properties){return function(j,k){var o=j.prototype;var r=j.superclass&&j.superclass.prototype;var l;for(var q in k){var n=k.__lookupGetter__(q);var m=k.__lookupSetter__(q);if(n||m){n&&o.__defineGetter__(q,n);m&&o.__defineSetter__(q,m)}else{i(o,q,k[q],r)}}return j}}else{return function(j,k){var l=j.prototype;var n=j.superclass&&j.superclass.prototype;for(var m in k){i(l,m,k[m],n)}}}})()}})();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();XHR.numberOfActiveRequests--}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{if(""!==result){result=eval("("+result+")")}else{result=null}}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;err.body=body}if(succeeded){deferred.callback(result)}else{deferred.failure(err)}xhr.onreadystatechange=noop;xhr=null;XHR.numberOfActiveRequests--;if(XHR.logActivity){console.log("XHR: "+method+" "+url+" complete @ "+(new Date()).valueOf())}}var xhr=getTransport();var queryString=Object.toQueryString(options.parameters||{});var body=options.body||"";var async=!options.sync;var deferred=new coherent.Deferred(cancel);var xhrSent=false;method=(method||"GET").toUpperCase();if(!body&&("POST"===method||"PUT"===method)){body=queryString;queryString=""}if("GET"===method&&coherent.Browser.IE&&!options.allowCache){var cache_bust="ie_cache_buster="+(new Date()).getTime();queryString=queryString?(queryString+"&"+cache_bust):cache_bust}if(queryString){var join="";if(-1===url.indexOf("?")){join="?"}else{if("&"!==url.slice(-1)){join="&"}}url=[url,queryString].join(join)}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||"PUT"==method){xhr.setRequestHeader("Content-Type",options.contentType||"application/x-www-form-urlencoded")}if(async){xhr.onreadystatechange=readyStateChanged}if(XHR.logActivity){console.log("XHR: "+method+" "+url+" @ "+(new Date()).valueOf())}xhr.send(body);xhrSent=true;if(!async){readyStateChanged()}XHR.numberOfActiveRequests++;return deferred}return{numberOfActiveRequests:0,get:function(url,parameters,options){return XHR.request("GET",url,parameters,options)},post:function(url,parameters,options){return XHR.request("POST",url,parameters,options)},put:function(url,parameters,options){return XHR.request("PUT",url,parameters,options)},request:function(method,url,parameters,options){method=method.toUpperCase();options=options||{};options.parameters=parameters;return send(url,method,options)}}})();(function(){function findBaseScriptName(){var scripts=document.getElementsByTagName("script");if(!scripts||!scripts.length){throw new Error("Could not find script")}var l=scripts.length;var s;for(--l;l>=0;--l){s=scripts[l];if(s.src){return s.src}}throw new Error("No script tags with src attribute.")}function installCss(css){var head=document.getElementsByTagName("head")[0];var style=document.createElement("style");var content=document.createTextNode(css);style.appendChild(content);head.appendChild(style)}window.INC=function(relativePath,content){if(!content){var scriptname=window.__filename__||findBaseScriptName();var lastSlash=scriptname.lastIndexOf("/");var prefix=scriptname.substring(0,lastSlash+1);var href=prefix+relativePath;content="";var d=XHR.get(href,null,{sync:true,responseContentType:"text/plain"});function received(data){content=data}d.addCallback(received)}var lastDot=relativePath.lastIndexOf(".");var ext=relativePath.substring(lastDot).toLowerCase();switch(ext){case".html":return content.replace(/>\s+</g,"><");case".js":coherent.Scripts.install(content);return"";case".css":installCss(content);return"";case".json":return eval("("+content+")");default:return content}return content}})();(function(){var a=this.Event;this.Event={};Object.extend(this.Event,a||{})}).call(window);Object.extend(Event,{KEY_BACKSPACE:8,KEY_TAB:9,KEY_CLEAR:12,KEY_RETURN:13,KEY_ENTER:13,KEY_SHIFT:16,KEY_CTRL:17,KEY_ALT:18,KEY_PAUSE:19,KEY_CAPS_LOCK:20,KEY_ESCAPE:27,KEY_SPACE:32,KEY_PAGE_UP:33,KEY_PAGE_DOWN:34,KEY_END:35,KEY_HOME:36,KEY_LEFT_ARROW:37,KEY_UP_ARROW:38,KEY_RIGHT_ARROW:39,KEY_DOWN_ARROW:40,KEY_INSERT:45,KEY_DELETE:46,KEY_HELP:47,KEY_LEFT_WINDOW:91,KEY_RIGHT_WINDOW:92,KEY_SELECT:93,KEY_NUMPAD_0:96,KEY_NUMPAD_1:97,KEY_NUMPAD_2:98,KEY_NUMPAD_3:99,KEY_NUMPAD_4:100,KEY_NUMPAD_5:101,KEY_NUMPAD_6:102,KEY_NUMPAD_7:103,KEY_NUMPAD_8:104,KEY_NUMPAD_9:105,KEY_NUMPAD_MULTIPLY:106,KEY_NUMPAD_PLUS:107,KEY_NUMPAD_ENTER:108,KEY_NUMPAD_MINUS:109,KEY_NUMPAD_PERIOD:110,KEY_NUMPAD_DIVIDE:111,KEY_F1:112,KEY_F2:113,KEY_F3:114,KEY_F4:115,KEY_F5:116,KEY_F6:117,KEY_F7:118,KEY_F8:119,KEY_F9:120,KEY_F10:121,KEY_F11:122,KEY_F12:123,KEY_F13:124,KEY_F14:125,KEY_F15:126,KEY_NUM_LOCK:144,KEY_SCROLL_LOCK:145,isNumpadNumKey:function(a){return a>=96&&a<=111},isAlphaNumKey:function(a){if(!this._reverseKeys){this._reverseKeys=(function(){var d={};var c=Event;for(var b in c){if("KEY_"!==b.slice(0,4)){continue}d[c[b]]=b}return d})()}return this.isNumpadNumKey(a)||!this._reverseKeys[a]},_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)}});Object.markMethods(Event,"Event");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=javascript:void(0)><\/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)}})}
/*
 * 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},set3PiecesBorderImage:function(g,b,e,j){if(coherent.Support.BorderImage){g.style.borderWidth=b?"0px "+j+"px 0px "+e+"px ":"0px";var k=b?"url("+b+") 0 "+j+" 0 "+e+" repeat stretch":"";g.style.webkitBorderImage=k;g.style.MozBorderImage=k}else{if(!b){g.innerHTML="";return}var a=document.createElement("div");var f=a.style;f.position="absolute";f.top="0px";f.bottom="0px";var l=a.cloneNode(false);l.style.left="0px";l.style.right="0px";var c=a.cloneNode(false);var d=c.style;d.backgroundImage="url("+b+")";d.backgroundRepeat="no-repeat";var h=c.cloneNode(false);var i=h.style;d.left="0px";d.width=e+"px";i.right="0px";i.width=j+"px";i.backgroundPosition="100% 0px";f.left=e+"px";f.right=j+"px";f.backgroundImage="url("+b.replace(/.png/,"__mid.png")+")";f.backgroundRepeat="repeat-x";if(g.firstChild){g.insertBefore(l,g.firstChild)}else{g.appendChild(l)}l.appendChild(c);l.appendChild(a);l.appendChild(h)}},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(f){var e;var c=Element.getStyles;var a=document.body;while(f&&f!=a){e=c(f,["overflow","overflowX","overflowY"]);for(var b in e){var d=e[b];if("auto"==d||"scroll"==d){return f}}f=f.parentNode}return f},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}},fromPoint:function(d,c){if(coherent.Browser.Safari){var b=document.documentElement;var a=document.body;d+=window.scrollLeft||b.scrollLeft||a.scrollLeft;c+=window.scrollTop||b.scrollTop||a.scrollTop}var f=document.elementFromPoint(d,c);return f}});Element.getStyle=Element.getStyles;Element.assignId.uniqueId=1;if(!coherent.Support.QuerySelector){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)}})}if("undefined"===typeof(document.documentElement.children)){HTMLElement.prototype.__defineGetter__("children",function(){var b=[];var a=this.childNodes.length;var d;for(var c=0;c<a;++c){d=this.childNodes[c];if(Node.ELEMENT_NODE!==d.nodeType){continue}b.push(d)}return b})}if("undefined"===typeof(document.documentElement.innerText)){HTMLElement.prototype.__defineGetter__("innerText",function(){return this.textContent});HTMLElement.prototype.__defineSetter__("innerText",function(a){this.textContent=a})}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}}Element.colours={black:"#000000",white:"#ffffff"};coherent.strings={"marker.input.multipleValues":"Multiple Values","marker.input.placeholder":"","marker.input.noSelection":"No Selection","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{toString:function(){if(a in coherent.strings){return coherent.strings[a]}console.log("Localisation missing string for key: "+a);return a},toJSON:function(){return this.toString()}}};var _=coherent.localisedString;coherent.Error=Class.create({constructor:function(a){Object.extend(this,a)},description:_("error.no_description"),recoverySuggestion:null,recoveryOptions:null,recoveryAttempter: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.notifiedObserverUids={}},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(b,a){if(!this.callback||!this.observer||this.observer.__uid in b.notifiedObserverUids){return}this.callback.call(this.observer,b,a,this.context)}});coherent.KVO=Class.create({constructor:function(b){if(b){for(var a in b){this.setValueForKey(b[a],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}},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(!a.__uid){a.__uid=coherent.generateUid()}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(i,j){if(!j){throw new InvalidArgumentError("keyPath may not be null")}if(!this.__observers){return}var f;var e;var g;if(coherent.KVO.kAllPropertiesKey!==j){e=this.__observers[j];if(e&&e.length){g=e.length;for(f=0;f<g;++f){e[f].observeChangeForKeyPath(i,j)}}var c=j+".";var h=c.length;var k;var l;var p;var n;var b;var m=!(null===i.oldValue||"undefined"===typeof(i.oldValue));for(l in this.__observers){if(l.substr(0,h)!=c){continue}e=this.__observers[l];if(!e||!e.length){continue}k=l.substr(h);n=i.oldValue;if(n&&n.valueForKeyPath){n=n.valueForKeyPath(k)}else{n=null}b=i.newValue;if(b&&b.valueForKeyPath){b=b.valueForKeyPath(k)}else{b=null}if(m&&n===b){continue}p=new coherent.ChangeNotification(i.object,i.changeType,b,n,i.indexes);g=e.length;for(f=0;f<g;++f){e[f].observeChangeForKeyPath(p,l)}}}e=this.__observers[coherent.KVO.kAllPropertiesKey];if(e){var d=Object.clone(i);i.notifiedObserverUids[this.__uid]=true;for(f in e){var a=e[f];a.observeChangeForKeyPath(d,j)}delete i.notifiedObserverUids[this.__uid]}}});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(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(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)}};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({constructor:function(){if(arguments.length==1&&"object"===typeof(arguments[0])){Object.extend(this,arguments[0])}},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]}if(!valueTransformer){try{valueTransformer=eval(transformerName)}catch(e){}}if(!valueTransformer){throw new InvalidArgumentError("The transformerName argument does not specify a valid ValueTransformer: "+transformerName)}if("function"!==typeof(valueTransformer)){return valueTransformer}if(valueTransformer.__factoryFn__){valueTransformer=valueTransformer()}else{valueTransformer=new valueTransformer()}return valueTransformer};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?false:true)}});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");coherent.transformer.FirstObject=Class.create(coherent.ValueTransformer,{transformedValue:function(a){if(coherent.typeOf(a)=="array"){return a[0]}return a}});coherent.transformer.Trimmed=Class.create(coherent.ValueTransformer,{compressWhitespace:false,transformedValue:function(a){if("string"!==typeof(a)){return a}if(this.compressWhitespace){return a.trim().replace(/\s+/g," ")}return a.trim()},reverseTransformedValue:function(a){if("string"!==typeof(a)){return a}if(this.compressWhitespace){return a.trim().replace(/\s+/g," ")}return a.trim()}});coherent.registerTransformerWithName(new coherent.transformer.Trimmed(),"trim");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:[],maskedBindings:[],defaultPlaceholders:{},automaticallySetupBindings:true,__relativeSource:null,defaultPlaceholderForMarkerWithBinding:function(b,c){var a=this.defaultPlaceholders[c];if(!a){return null}return a[b]||null},__createObserverMethod:function(b){function a(d){if(coherent.ChangeType.setting!==d.changeType){return}var c=d.newValue;this.setValueForKey(d.newValue,b)}return a},bindNameToKeyPath:function(b,g,a){var d;var f;var e={};if(!this.bindings){this.bindings={}}d=this["observe"+b.titleCase()+"Change"]||this.__createObserverMethod(b);if(this.bindings[b]){this.bindings[b].unbind()}var c=this.__context;if("object"===typeof(g)){Object.extend(e,g);g=e.keypath}Object.extend(e,coherent.Binding.bindingInfoFromString(g));if("transformedValue" in e){e.transformer={transformedValue:e.transformedValue,reverseTransformedValue:e.reverseTransformedValue||null};delete e.transformValue;delete e.reverseTransformedValue}if("*."===e.keypath.substr(0,2)){if(a){c=a}else{c=new coherent.KVO()}e.keypath=e.keypath.substr(2)}e.name=b;e.object=c;e.observer=this;e.observerFn=d;f=new coherent.Binding(e);f.bind();this.bindings[b]=f},__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"]},__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(c){var e=c.superclass.prototype;var d=c.prototype;if(d.hasOwnProperty("defaultPlaceholders")){var b=Object.clone(e.defaultPlaceholders);d.defaultPlaceholders=Object.extend(b,d.defaultPlaceholders)}if(e.exposedBindings===d.exposedBindings&&!d.maskedBindings){return}var a=(e.maskedBindings===d.maskedBindings)?{}:$S(d.maskedBindings);function f(h){return !(h in a)}var g=e.exposedBindings.filter(f);if(e.exposedBindings!==d.exposedBindings){g=g.concat(d.exposedBindings.filter(f))}d.exposedBindings=g};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,{registerWithName:function(a){if(!a){return}this.name=a;coherent.registerModelWithName(this,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",kDragAndDropCopy:"drag-and-drop-copy",kDragAndDropMove:"drag-and-drop-move",kDragAndDropLink:"drag-and-drop-link",kDragAndDropNo:"drag-and-drop-no"};coherent.Style.__styles=(function(){var a=[];var b=coherent.Style;for(var c in b){a.push(b[c])}return a})();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}};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)}},onswipe:function(a){var b=this.nextResponder();if(b){b.onswipe(a)}},ondragstart:function(a){var b=this.nextResponder();if(b){b.ondragstart(a)}}});coherent.Page=Class.create(coherent.Responder,{focusedElement:null,constructor:function(){this.firstResponder=null;this.__hoverTrackingIds={};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()){this.willChangeValueForKey("firstResponder");this.firstResponder=null;this.didChangeValueForKey("firstResponder");return false}var b=this.firstResponder;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)},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){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._mousedownPoint={x:b.clientX,y:b.clientY,dragging:false}}this._mousedownView=a},_onmouseup:function(a){if(this._dragging){this._dragging.onmouseup(a);delete this._dragging}else{if(this._mousedownView){this._mousedownView.onmouseup(a)}}this._mousedownView=null;Event.stopObserving(document,"mousemove",this._onmousedragHandler)},_onmousedrag:function(c){if(this._dragging){this._dragging.onmousemove(c);return}if(this._draggingSourceView){return}if(!this._mousedownView){return}if(!coherent.Support.DragAndDrop&&!this._mousedownPoint.dragging){var b=c.clientX-this._mousedownPoint.x;var a=c.clientY-this._mousedownPoint.y;if(25>=(b*b+a*a)){return}this._mousedownPoint.dragging=true;this._mousedownView.ondragstart(c);return}this._mousedownView.onmousedrag(c)},_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)==window;if(c){if(!this._documentFocused){this.makeFirstResponder(this._previousFirstResponder||null);this._previousFirstResponder=null;this._documentFocused=true;if(window.dashcode&&!window.dashcode.inDesign&&document.body){Element.removeClassName(document.body,"DC_windowInactive")}}}else{var a=this.targetViewForEvent(b);if(a&&a.acceptsFirstResponder()){this.makeFirstResponder(a)}else{this.makeFirstResponder(null)}this.focusedElement=b.target||b.srcElement}},_onblur:function(b){var c=(b.target||b.srcElement)==window;if(c){this._documentFocused=false;this._previousFirstResponder=this.firstResponder;this.makeFirstResponder(null);if(window.dashcode&&!window.dashcode.inDesign&&document.body){Element.addClassName(document.body,"DC_windowInactive")}}else{var a=this.targetViewForEvent(b);this.focusedElement=null;if(a&&a.acceptsFirstResponder()){this.makeFirstResponder(null)}}},_ontouchstart:function(c){var a=this.targetViewForEvent(c);if(a){var b=this;a.ontouchstart(c);this._touchstartMouseDownDelay=window.setTimeout(function(){a.onmousedown(c);b._touchsentMD=true;delete b._touchstartMouseDownDelay},100)}this._touchstartView=a;this._touchmovedX=false;this._touchmovedY=false;this._touchsentMD=false;this._touchstartX=c.targetTouches[0].clientX;this._touchstartY=c.targetTouches[0].clientY},_ontouchmove:function(d){var a=d.targetTouches[0].clientX;var e=d.targetTouches[0].clientY;var b=false;var c=false;if(!this._touchmovedX&&Math.abs(this._touchstartX-a)>5){b=this._touchmovedX=true}if(!this._touchmovedY&&Math.abs(this._touchstartY-e)>5){c=this._touchmovedY=true}if(this._touchstartView){this._touchstartView.ontouchmove(d);if(this._touchstartMouseDownDelay){window.clearTimeout(this._touchstartMouseDownDelay);delete this._touchstartMouseDownDelay}if(b||c){if(this._touchsentMD){this._touchstartView.onmouseup(d);this._touchsentMD=false}if(!this._touchmovedY&&b){this._touchstartView.onswipe(d)}}}},_ontouchend:function(a){if(this._touchstartView){this._touchstartView.ontouchend(a);if(this._touchstartMouseDownDelay){var b=this._touchstartView;window.clearTimeout(this._touchstartMouseDownDelay);delete this._touchstartMouseDownDelay;this._touchstartView.onmousedown(a);this._touchsentMD=true;window.setTimeout(function(){b.onmouseup(a);b.onclick(a)},0)}else{if(this._touchsentMD){this._touchstartView.onmouseup(a);if(!this._touchmovedX&&!this._touchmovedY){this._touchstartView.onclick(a)}}}}},_ontouchcancel:function(a){if(this._touchstartView){this._touchstartView.ontouchend(a);if(this._touchstartMouseDownDelay){window.clearTimeout(this._touchstartMouseDownDelay);delete this._touchstartMouseDownDelay}else{if(this._touchsentMD){this._touchstartView.onmouseup(a)}}}},_onunload:function(){var b;var a=coherent.View.viewLookup;for(b in a){a[b].teardown();delete a[b]}},_ondragstart:function(a){if(this._mousedownView){this._draggingSourceView=null;this._mousedownView.ondragstart(a);if(!this._draggingSourceView){Event.preventDefault(a)}}},_ondrag:function(a){if(this._dragging){this._dragging.onmousemove(a)}},_ondragend:function(a){if(this._draggingView){this._draggingView.concludeDragOperation(this._draggingLastDropEffect)}this._draggingView=null;if(this._draggingSourceView){this._draggingSourceView.draggingEndedWithOperation(this._draggingLastDropEffect)}this._draggingSourceView=null;if(this._dragging){this._dragging.cleanup();delete this._dragging}},_exitOldDragView:function(a){if(!this._draggingView){return}var b=this._dragInfoFromEvent(a);this._draggingView.draggingExited(b);this._draggingLastDropEffect=null;this._draggingView=null},_dragInfoFromEvent:(function(){if(coherent.Browser.IE){var a={"text/plain":"Text","text/uri-list":"URL"};return function(d){var e=this._draggingData;var c=this._dragging.node;var g=c.style.display;c.style.display="none";var f=Element.fromPoint(d.clientX,d.clientY);c.style.display=g;if(e){return{location:{x:d.clientX,y:d.clientY},target:f,types:Set.toArray(e),operation:this._draggingLastDropEffect,getData:function(h){return e[h]||null}}}else{var b=[];if(d.dataTransfer.getData("Text")){b.push("text/plain")}if(d.dataTransfer.getData("URL")){b.push("text/uri-list")}return{location:{x:d.clientX,y:d.clientY},target:f,types:b,operation:d.dataTransfer.dropEffect,getData:function(h){h=a[h];return d.dataTransfer.getData(h)}}}}}if(coherent.Support.DragAndDrop){return function(b){return{location:{x:b.clientX,y:b.clientY},target:Element.fromPoint(b.clientX,b.clientY),types:Array.from(b.dataTransfer.types),operation:b.dataTransfer.dropEffect||this._draggingLastDropEffect,getData:function(c){return b.dataTransfer.getData(c)}}}}return function(c){var d=this._draggingData;var b=this._dragging.node;var f;if(b){f=b.style.display;b.style.display="none"}var e=Element.fromPoint(c.clientX,c.clientY);if(b){b.style.display=f}return{location:{x:c.clientX,y:c.clientY},target:e,types:Set.toArray(d),operation:this._draggingLastDropEffect,getData:function(g){return d[g]||null}}}})(),_ondragenter:function(f){var b=this.targetViewForEvent(f);if(!b){this._exitOldDragView(f);return}var g=this._dragInfoFromEvent(f);var d=g.types;var a=g.types.length;var c;var e;while(b){if(b.registeredDraggedTypes){for(c=0;c<a;++c){if(d[c] in b.registeredDraggedTypes){e=b;break}}}b=b.superview()}if(e===this._draggingView){return}if(!e){this._exitOldDragView(f);this._draggingLastDropEffect="none";return}var h=e.draggingEntered(g);this._draggingView=e;this._draggingLastDropEffect=h;if(f.dataTransfer){f.dataTransfer.dropEffect=h}Event.preventDefault(f)},_ondragleave:function(a){},_ondragover:function(a){if(!this._draggingView){return}var b=this._dragInfoFromEvent(a);var c=this._draggingView.draggingUpdated(b);this._draggingLastDropEffect=c||this._draggingLastDropEffect;if(coherent.Support.DragAndDrop){a.dataTransfer.dropEffect=this._draggingLastDropEffect}Event.preventDefault(a)},_ondrop:function(a){if(!this._draggingView){return}var b=this._dragInfoFromEvent(a);if(!this._draggingView.prepareForDragOperation(b)){this._draggingLastDropEffect="none";a.dataTransfer.dropEffect="none";Event.preventDefault(a);return}if(!this._draggingView.performDragOperation(b)){this._draggingLastDropEffect="none";Event.preventDefault(a);return}}});(function(){coherent.page=new coherent.Page();window._setTimeout=window.setTimeout;window.setTimeout=function(f,d){if(!f){return null}if("string"===typeof(f)){f="coherent.EventLoop.begin();do {"+f+"} while (false); coherent.EventLoop.end();";return window._setTimeout(f,d)}var c=Array.from(arguments,2);function e(){coherent.EventLoop.begin();var g=f.apply(this,c);coherent.EventLoop.end();return g}return window._setTimeout(e,d)};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()}};b._onmousedragHandler=a("_onmousedrag");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("onunload",a("_onunload"));if(coherent.Support.DragAndDrop){document.attachEvent("ondragstart",a("_ondragstart"));document.documentElement.attachEvent("ondragend",a("_ondragend"));document.documentElement.attachEvent("ondragenter",a("_ondragenter"));document.documentElement.attachEvent("ondrag",a("_ondrag"));document.documentElement.attachEvent("ondragover",a("_ondragover"));document.documentElement.attachEvent("ondrop",a("_ondrop"))}}else{a=function(c){return function(d){coherent.EventLoop.begin(d);b[c](d);coherent.EventLoop.end()}};b._onmousedragHandler=a("_onmousedrag");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)}if(coherent.Support.DragAndDrop){document.addEventListener("dragstart",a("_ondragstart"),false);document.addEventListener("dragend",a("_ondragend"),false);document.addEventListener("dragenter",a("_ondragenter"),false);document.addEventListener("dragover",a("_ondragover"),false);document.addEventListener("drop",a("_ondrop"),false)}}})();(function(){function a(b){return parseInt(b||"",10)||0}coherent.DragAndDropHelper=function(){};coherent.DragAndDropHelper.prototype={initFakeDragAndDrop:function(e,d){var f=Element.clone(e);var c=Element.getRect(e,true);var b=Element.getStyles(e,["borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","paddingTop","paddingRight","paddingBottom","paddingLeft","opacity"]);f.style.position="fixed";f.style.top=c.top+"px";f.style.left=c.left+"px";f.style.width=(c.width-a(b.borderLeftWidth)-a(b.borderRightWidth)-a(b.paddingLeft)-a(b.paddingRight))+"px";f.style.heigh=(c.height-a(b.borderTopWidth)-a(b.borderBottomWidth)-a(b.paddingTop)-a(b.paddingBottom))+"px";e.parentNode.appendChild(f);this.node=f;this.originalNode=e;this.offset={left:c.left-d.clientX,top:c.top-d.clientY};this.classname=e.className;this.rect=c;this.viewport=Element.getViewport();this.originalScroll=this.getScrollOffset(c.left,c.top)},getScrollOffset:function(d,c){var e;var b;if(c<0){b=c}else{b=c+this.rect.height-this.viewport.height;if(b<0){b=0}}if(d<0){e=d}else{e=d+this.rect.width-this.viewport.width;if(e<0){e=0}}return{scrollX:e,scrollY:b}},emptyFn:function(){},onmousemove:function(b){var c=(b.clientX+this.offset.left);var i=(b.clientY+this.offset.top);var d=this.node;d.style.left=c+"px";d.style.top=i+"px";var f=this.getScrollOffset(c,i);if(!f.scrollX){this.originalScroll.scrollX=0}if(!f.scrollY){this.originalScroll.scrollY=0}var l=!this.originalScroll.scrollX&&f.scrollX;var k=!this.originalScroll.scrollY&&f.scrollY;window.scrollBy(l,k);var h=d.style.display;d.style.display="none";var j=Element.fromPoint(b.clientX,b.clientY);d.style.display=h;var g={target:j,clientX:b.clientX,clientY:b.clientY,preventDefault:this.emptyFn,dataTransfer:b.dataTransfer||{}};if(j!==this.overNode){coherent.page._ondragenter(g);this.overNode=j}else{coherent.page._ondragover(g)}var e=null;switch(coherent.page._draggingLastDropEffect){case"copy":e=coherent.Style.kDragAndDropCopy;break;case"move":e=coherent.Style.kDragAndDropMove;break;case"link":e=coherent.Style.kDragAndDropLink;break;case"none":default:e=coherent.Style.kDragAndDropNo;break}if(e){d.className=this.classname+" "+e}if(!coherent.Support.DragAndDrop){Event.preventDefault(b)}},cleanup:function(){if(this.node){this.node.parentNode.removeChild(this.node)}this.node=null},onmouseup:function(b){this.cleanup();if(coherent.Support.DragAndDrop){return}var c={target:this.overNode,clientX:b.clientX,clientY:b.clientY,dataTransfer:{},preventDefault:this.emptyFn};coherent.page._ondrop(c);coherent.page._ondragend(c)}}})();coherent.View=Class.create(coherent.Responder,{exposedBindings:["visible","class","enabled","editable","html","text"],defaultPlaceholders:{text:{multipleValues:_("marker.text.multipleValues"),nullValue:_("marker.text.placeholder"),noSelection:_("marker.text.noSelection")},html:{multipleValues:_("marker.text.multipleValues"),nullValue:_("marker.text.placeholder"),noSelection:_("marker.text.noSelection")}},automaticallySetupBindings:false,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(null===a&&this.markup){this.__view=a=coherent.View.createNodeFromMarkup(this.markup);this.id=Element.assignId(a)}else{if("string"===typeof(a)){this.id=a;this.__view=document.getElementById(a)}else{this.id=Element.assignId(a);this.__view=a}}if("object"===coherent.typeOf(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.viewElement().object=this;this.__updating=null;coherent.View.viewLookup[this.id]=this},__postConstruct:function(){var b=this;function c(){if(coherent.Browser.IE){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;var b=f.getAttribute("__parametersId");var h=this.__parameters||coherent.View.nodeParameters[b]||{};this.__copyParameters(h);if(this.formatter&&"function"===typeof(this.formatter)){if(this.formatter.__factoryFn__){this.formatter=this.formatter()}else{this.formatter=new (this.formatter)()}}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.initFromDOM();this.updateBindings();this.createObservers();delete this.__initialising;delete this.viewElement},teardown:function(){for(var a in this.bindings){this.bindings[a].unbind()}if(this.viewElement()){this.viewElement().object=null}if(!coherent.Browser.IE){delete this.__view;delete this.__container}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);if("action" in i&&!i.target){j.target=this}}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}Array.forEach(j,k?c:b,this);e=true;return coherent.View.fromNode(j[0])}},init:function(){},initFromDOM:function(){},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},addSubview:function(b){var a=this.viewElement();a.appendChild(b.viewElement())},viewWithSelector:function(a){var c=Element.query(this.viewElement(),a);var b=coherent.View.fromNode(c);return b},nextResponder:function(){return this.__nextResponder||this.superview()},focus:function(){var a=this.viewElement();a.focus()},blur:function(){var a=this.viewElement();a.blur()},sendAction:function(){if(!this.action){return}var b=coherent.EventLoop.currentEvent;if(FIRST_RESPONDER!==this.target&&"string"!==typeof(this.action)){this.action.call(this.target||this.action,this,b);return}var c=this.action;var a;if(FIRST_RESPONDER===this.target){a=coherent.page.firstResponder}else{a=this.target||this}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(g,f,c){var a=this.viewElement();var e=coherent.Style.kFadingClass;function d(){a.style.display="none";Element.removeClassName(a,e)}if(!this.animated){a.style.display=(g.newValue?"":"none")}else{function b(){if(g.newValue){if(a.style.display!==""){Element.addClassName(a,e);a.style.display=""}coherent.Animator.removeClassName(a,e,{duration:this.updateAnimationDuration||300})}else{coherent.Animator.addClassName(a,e,{duration:this.updateAnimationDuration||300,callback:d})}}b.bindAndDelay(this,10)}},observeEnabledChange:function(b){var a=this.viewElement();this.disabled=a.disabled=!b.newValue;if(!this.animated){if(a.disabled){Element.addClassName(a,coherent.Style.kDisabledClass)}else{Element.removeClassName(a,coherent.Style.kDisabledClass)}}else{if(a.disabled){coherent.Animator.addClassName(a,coherent.Style.kDisabledClass,{duration:300})}else{coherent.Animator.removeClassName(a,coherent.Style.kDisabledClass,{duration:300})}}},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:300})}else{a.className=b}},_beginUpdate:function(h,f){if(window.dashcode&&h){h.call(this);return}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(g,f,c){var b=this.viewElement();var a=this.bindings.text&&this.bindings.text.markerType;var e=g.newValue;if(a){if(null===e||"undefined"===typeof(e)){e=""}Element.addClassName(b,coherent.Style.kMarkerClass)}else{Element.removeClassName(b,coherent.Style.kMarkerClass);if(this.formatter){e=this.formatter.stringForValue(e)}}function d(){var h=document.createTextNode(e);b.innerHTML="";b.appendChild(h)}this._beginUpdate(d)},observeHtmlChange:function(g,f,c){var b=this.viewElement();var a=this.bindings.html&&this.bindings.html.markerType;var e=g.newValue;if(a){if(null===e||"undefined"===typeof(e)){e=""}Element.addClassName(b,coherent.Style.kMarkerClass)}else{Element.removeClassName(b,coherent.Style.kMarkerClass);if(this.formatter){e=this.formatter.stringForValue(e)}}function d(){b.innerHTML=e}this._beginUpdate(d)},removeChild:function(a){if(!a){return null}coherent.View.teardownViewsForNodeTree(a);if(this.beforeRemoveElement){this.beforeRemoveElement(a)}return a.parentNode.removeChild(a)},clonedFrom:function(a){},registerForDraggedTypes:function(d){var c=d;if(1===arguments.length&&"string"===typeof(d)){c=[d]}else{if(arguments.length>1){c=arguments}}var a=c.length;if(!this.registeredDraggedTypes){this.registeredDraggedTypes={}}for(var b=0;b<a;++b){this.registeredDraggedTypes[c[b]]=true}},unregisterForDraggedTypes:function(d){var c=d;if(arguments.length>1){c=arguments}var a=c.length;if(!this.registeredDraggedTypes){return}for(var b=0;b<a;++b){delete this.registeredDraggedTypes[c[b]]}},dragElementWithOperationAndData:function(j,g,i,h,a){var f;var b=coherent.EventLoop.currentEvent;if(!coherent.page._mousedownView){throw new Error("Can't initiate a drag & drop operation except during dragstart event.")}coherent.page._draggingSourceView=this;coherent.page._draggingData=i;if(coherent.Support.DragAndDrop){var d=b.dataTransfer;d.clearData();d.effectAllowed=g;if(coherent.Browser.IE){if(j){f=coherent.page._dragging=new coherent.DragAndDropHelper();f.initFakeDragAndDrop(j,b)}if("text/plain" in i){d.setData("Text",i["text/plain"])}if("text/uri-list" in i){d.setData("URL",i["text/uri-list"])}}else{for(var c in i){d.setData(c,i[c])}var k=Element.getRect(j);d.setDragImage(j,b.pageX-k.left,b.pageY-k.top)}}else{f=coherent.page._dragging=new coherent.DragAndDropHelper();f.initFakeDragAndDrop(j,b);Event.preventDefault(b)}},draggingEndedWithOperation:function(a){},draggingEntered:function(a){return"none"},draggingExited:function(a){},draggingUpdated:function(a){return null},prepareForDragOperation:function(a){return false},performDragOperation:function(a){return false},concludeDragOperation:function(a){}});coherent.View.nodeParameters={};coherent.View.viewLookup={};coherent.View.__subclassCreated__=function(a){var b=a.prototype;var c=a.superclass.prototype;if(b.__structure__!==c.__structure__){Object.applyDefaults(b.__structure__,c.__structure__)}};coherent.View.viewClassForNode=function(b,a){var c=b.getAttribute("__parametersId");if(!c){return null}return coherent.View.nodeParameters[c].viewClass};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;var c=null;if(coherent.typeOf(a)=="string"){c=a}else{if("id" in a){c=a.id}}if(!b||!c||!b[c]){return null}return b[c]};coherent.View.rebindNodeTreeWithRelativeSource=function(b,d,c){function a(f){var e=coherent.View.fromNode(f);if(!e||(d&&e.__relativeSource!==d)){return true}e.__relativeSource=c;e.setupBindings();e.updateBindings();if(e instanceof coherent.ListView){return false}return true}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}if(coherent.DashcodePart){new (g)(f,c,coherent.DashcodePart.PropertiesForNode(f))}else{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.cloneViewsForTreeNode=function(d,a,c){var f={};var b=Element.clone(d);function e(k){var g=k.id;if(k==d&&!g){g=d.id}if(g){f[g]=k}k.originalID=g;k.id="";var h=coherent.View.fromNode(g);var i=coherent.View.viewClassForNode(k);var j=null;if(!i||k.object){return true}j=new (i)(k,a,coherent.DashcodePart.PropertiesForNode(k));if(h&&j){j.clonedFrom(h)}return true}Element.depthFirstTraversal(b,e);if(!b.object){b.object={}}b.object.templateElements=f;return b};coherent.View.addToHoldingArea=function(b){var a=coherent.View.__holdingArea;if(!a){coherent.View.__holdingArea=a=document.createElement("div");a.style.position="absolute";a.style.left="-9999px";a.style.top="-9999px";a.style.width="0";a.style.height="0";a.style.overflow="hidden";document.body.appendChild(a)}a.appendChild(b)};coherent.View.createNodeFromMarkup=function(a){var b=coherent.View.__incubator;if(!b){coherent.View.__incubator=b=document.createElement("div");b.style.position="absolute";b.style.left="-9999px";b.style.top="-9999px";b.style.width="0";b.style.height="0";b.style.overflow="hidden";document.body.appendChild(b)}b.innerHTML=String(a).trim();var c=b.removeChild(b.firstChild);var d=Element.assignId(c);coherent.View.addToHoldingArea(c);return c};Object.markMethods(coherent.View,"coherent.View");coherent.FieldGroup=Class.create(coherent.View,{validateFields:function(){var c=this.viewElement();var b=Element.queryAll(c,"input,textarea");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()}return h}});coherent.ImageView=Class.create(coherent.View,{exposedBindings:["src","alt","width","height"],maskedBindings:["text","html"],init:function(){this.base();var a=this.viewElement();if(!this.defaultPlaceholders.src&&a.src){var b=this.defaultPlaceholders.src={};b.nullValue=b.noSelection=a.src}Event.observe(a,"error",this.onerror.bind(this));Event.observe(a,"load",this.onload.bind(this))},onload:function(){var a=this.viewElement();if(!a){return}this.setValueForKey(false,"loading");Element.removeClassName(a,coherent.Style.kLoadingClass)},onerror:function(){var a=this.viewElement();if(!a){return}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(c){var b=this.viewElement();var a=this.bindings.src&&this.bindings.src.markerType;if(a){Element.addClassName(b,coherent.Style.kMarkerClass)}else{Element.removeClassName(b,coherent.Style.kMarkerClass)}this.setSrc(c.newValue)},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(b){var a=this.viewElement();a.alt=b.newValue||""},observeHeightChange:function(c){var b=this.viewElement();var a=parseInt(c.newValue,10);if(isNaN(a)){b.removeAttribute("height")}else{b.height=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)},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}});function IndexRange(d,a){var c;var e=[];if(1==arguments.length&&d.length){a=d.length-1;d=0}if(d>a){var b=a;a=d;d=b}for(c=d;c<=a;++c){e.push(c)}return e}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"],hasSelection:["selectionIndexes"],canRemove:["editable","selectionIndexes"],canAdd:["editable"],canSelectNext:["selectionIndexes"],canSelectPrevious:["selectionIndexes"]},selectsInsertedObjects:true,exposedBindings:["selectionIndexes","sortDescriptors","filterPredicate"],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)}else{if(!this.selectionIndexes().length&&this.avoidsEmptySelection()){this.setValueForKey([0],"selectionIndexes")}}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)},canSelectNext:function(){var b=this.selectionIndex();var a=this.content().length;return a&&b<a-1},selectNext:function(){var b=this.selectionIndex();var a=this.content().length;if(!a||b===a-1){return}this.setSelectionIndexes([b+1])},canSelectPrevious:function(){var b=this.selectionIndex();var a=this.content().length;return a&&b>0},selectPrevious:function(){var b=this.selectionIndex();var a=this.content().length;if(!a||!b){return}this.setSelectionIndexes([b-1])},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;this._inReArrangeObjects=true;for(f=0;f<a;++f){h=c.indexOf(b[f]);if(-1!==h){e.push(h)}}if(c.length&&this.avoidsEmptySelection()&&!e.length){e.push(0)}this.setValueForKey(c,"arrangedObjects");this.setValueForKey(e,"selectionIndexes");this._inReArrangeObjects=false},_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(coherent.compareNumbers);if((0===(this.selectionIndexes()||[]).compare(b))&&!this._inReArrangeObjects){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]},hasSelection:function(){return(this.selectionIndexes().length>0)},setAvoidsEmptySelection:function(a){this.__avoidsEmptySelection=a;if(!this.hasSelection()&&this.arrangedObjects.length){this.setValueForKey([0],"selectionIndexes")}},avoidsEmptySelection:function(){return this.__avoidsEmptySelection}});coherent.ListView=Class.create(coherent.View,{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");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"===(b.getAttribute("multiple")||"").toLowerCase()){this.multiple=true}this.templateElement.id="";if(this.template&&"function"!==typeof(this.template)){delete this.template}if(this.template&&!this.template.__factoryFn__){this.template=this.template()}},initFromDOM:function(){var a=this.container();a.innerHTML="";if(this._items&&this._items.removeAll){this._items.removeAll()}},computeSelectionIndexes:function(){var b=[];var a=this._items();function c(f,d){if(f.selected){b.push(d)}}a.forEach(c);return b},acceptsFirstResponder:function(){var a=this.viewElement();if(a.disabled||a.readOnly){return false}return true},highlightSelectionIndexes:function(d){var k=this.viewElement();var j=this._items();var g=j.length;var e;var f=0;var b=!!this._isSelectElement;var c;var a=coherent.Style.kSelectedClass;var h;var l;if(this.animated){var m={curve:coherent.easing.inOutSine,duration:300};h=function(n,i){coherent.Animator.addClassName(n,i,m)};l=function(n,i){coherent.Animator.removeClassName(n,i,m)}}else{h=Element.addClassName;l=Element.removeClassName}for(e=0;e<g;++e){j[e].selected=c=(e==d[f]);if(c){f++}if(b){continue}if(e===0){Element.addClassName(j[e],coherent.Style.kFirstClass)}else{Element.removeClassName(j[e],coherent.Style.kFirstClass)}if(g>1&&e===g-1){Element.addClassName(j[e],coherent.Style.kLastClass)}else{Element.removeClassName(j[e],coherent.Style.kLastClass)}if(c){h(j[e],a)}else{l(j[e],a)}}if(1===d.length){this.selectedIndex=k.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(coherent.compareNumbers);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(l){var n=coherent.View.rebindNodeTreeWithRelativeSource;var r=coherent.View.unbindNodeTree;var s=this.selectedObjects();var j=[];var c=l.length;var m=this._items();var o=m.length;var f=Math.min(o,c);var d=this._isSelectElement;var h=0;var g;var k;var a;var p;while(h<f){g=l[h];if(-1!==s.indexOf(g)){j.push(h)}k=m[h];a=k.objectValue;k.objectValue=g;if("undefined"===typeof(a)){this.setupElement(k,k.objectValue)}else{n(k,a,g)}p=coherent.View.fromNode(k);if(!p||!p.bindings.visible){k.style.display="";Element.removeClassName(k,"deleted-listview-node")}++h}if(h<c){var b=this.container();var q=document.createDocumentFragment();while(h<c){g=l[h];if(-1!==s.indexOf(g)){j.push(h)}k=this.createElement(g,null,q);this._items.add(k);++h}b.appendChild(q)}else{while(h<o){k=m[h];if(d){this._items.removePartAtIndex(h);this.removeChild(k)}else{r(k);k.objectValue=null;k.style.display="none";Element.addClassName(k,"deleted-listview-node")}++h}}this.highlightSelectionIndexes(j)},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="";Element.removeClassName(r,"deleted-listview-node")}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.refresh();this.bindings.displayValues.update()}if(this.bindings.contentValues){this.bindings.contentValues.refresh();this.bindings.contentValues.update()}},setupElement:function(d,c){d.objectValue=c;if(this.template){var a=coherent.dataModel;var b;try{coherent.dataModel=this.__context;this.template.call(this,d,c)}finally{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().concat();if(a.shiftKey){this.setSelectionIndexes(IndexRange(this.selectedIndex,d))}else{if(this.singleClickSelect||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.SelectField=Class.create(coherent.ListView,{exposedBindings:["displayValues","contentValues","selectedValue","name"],removeChild:function(a){if(!a){return null}if(this.beforeRemoveElement){this.beforeRemoveElement(a)}return this.viewElement().remove(a.index)},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;if(!this.bindings.enabled){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},highlightSelectionIndexes:function(g){var b=this.viewElement();var c=b.options;var a=c.length;var e;var d=0;var f;for(e=0;e<a;++e){c[e].selected=f=(e==g[d]);if(f){d++}}if(1===g.length){this.selectedIndex=b.selectedIndex=g[0]}this.__selectionIndexes=g}});coherent.TableHeaderView=Class.create(coherent.View,{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.Media=Class.create(coherent.View,{exposedBindings:["src","currentTime","volume","muted","autoplay","controls","loop","playing"],init:function(){this.base();if(this.initialVolume){this.setVolume(this.initialVolume)}var a=this.viewElement();Event.observe(a,"ended",this.mediaDidEnd.bind(this));Event.observe(a,"play",this.mediaPlayingStateChanged.bind(this));Event.observe(a,"pause",this.mediaPlayingStateChanged.bind(this))},isSupported:function(){var a=this.viewElement();if("paused" in a){return true}return false},pause:function(){var a=this.viewElement();if(!a.paused){a.pause()}},mediaPlayingStateUpdated:function(){this.forceChangeNotificationForKey("playing")},play:function(){var a=this.viewElement();a.play();this.forceChangeNotificationForKey("ended")},playing:function(){var a=this.viewElement();return !a.paused},stop:function(){var a=this.viewElement();a.currentTime=a.duration},muted:function(){var a=this.viewElement();return a.muted},setMuted:function(b){var a=this.viewElement();if(this.bindings.muted){this.bindings.muted.setValue(b)}a.muted=b},volume:function(){var a=this.viewElement();return a.volume},setVolume:function(b){var a=this.viewElement();if(this.bindings.volume){this.bindings.volume.setValue(b)}a.volume=Math.min(1,b)},mediaDidEnd:function(a){this.forceChangeNotificationForKey("ended");this.forceChangeNotificationForKey("playing")},ended:function(){var a=this.viewElement();return a.ended},autoplay:function(){var a=this.viewElement();return a.autoplay},setAutoplay:function(b){if(this.bindings.autoplay){this.bindings.autoplay.setValue(b)}var a=this.viewElement();a.autoplay=b},controls:function(){var a=this.viewElement();return a.controls},setControls:function(b){if(this.bindings.controls){this.bindings.controls.setValue(b)}var a=this.viewElement();a.controls=b},loop:function(){var a=this.viewElement();return a.loop},setLoop:function(b){if(this.bindings.loop){this.bindings.loop.setValue(b)}var a=this.viewElement();a.loop=b},src:function(){var a=this.viewElement();return a.src},setSrc:function(b){if(this.bindings.src){this.bindings.src.setValue(b)}var a=this.viewElement();a.src=b;a.load();this.forceChangeNotificationForKey("ended")}});coherent.Video=Class.create(coherent.Media,{exposedBindings:["poster","height","width"],poster:function(){var a=this.viewElement();return a.poster},setPoster:function(a){if(this.bindings.poster){this.bindings.poster.setValue(a)}var b=this.viewElement();b.poster=a},observeHeightChange:function(c){var b=this.viewElement();var a=parseInt(c.newValue,10);if(isNaN(a)){b.style.height=null}else{b.style.height=a+"px"}},observeWidthChange:function(c){var a=this.viewElement();var b=parseInt(c.newValue,10);if(isNaN(b)){a.style.width=null}else{a.style.width=b+"px"}}});coherent.FormControl=Class.create(coherent.View,{exposedBindings:["value","name"],maskedBindings:["text","html"],observeValueChange:function(d){var b=this.viewElement();var c=d.newValue;var a=this.bindings.value&&this.bindings.value.markerType;if(coherent.NoSelectionMarkerType===a){b.disabled=true}else{if(!this.bindings.enabled){b.disabled=false}}if(!this.bindings.editable){b.readOnly=!this.bindings.value.mutable()}if(b.readOnly){Element.addClassName(b,coherent.Style.kReadOnlyClass)}else{Element.removeClassName(b,coherent.Style.kReadOnlyClass)}if(b.disabled){Element.addClassName(b,coherent.Style.kDisabledClass)}else{Element.removeClassName(b,coherent.Style.kDisabledClass)}b.value=c},observeNameChange:function(d,c,b){var a=this.viewElement();a.name=d.newValue},validate:function(){return this.viewElement().value}});(function(){function a(){var b=document.getElementsByTagName("script");var d;for(var c=b.length-1;c>=0;--c){d=b[c];if(d.onnibload){return d}}return null}window.VIEW=function(c,b){var d=INC(c);function e(){var h=document.createElement("div");h.innerHTML=d.trim();var g=h.firstChild;var f;var k={};var j;var l;var i={viewElement:function(){return g}};for(l in b){j=b[l];if(!j||"function"!==typeof(j)||!j.__factoryFn__){continue}if(":root"===l){f=j.call(this,g,null);continue}k[l]=j;j.call(i,l,true)}for(l in k){k[l].call(i,l,false)}return f}e.__factoryFn__=true;return e};window.NIB=function(f){var h=a();if(!h){throw new Error("Couldn't find NIB script")}f.objects=f.objects||{};var b=coherent.dataModel;var d=coherent.dataModel=h.model;try{var c;var g;var i=coherent.KVO.typesOfKeyValuesToIgnore;var e=coherent.typeOf;for(g in f.objects){if("owner"===g){continue}c=f.objects[g];if(c&&"function"===typeof(c)&&c.__factoryFn__){c=c.call(d)}if(!(e(c) in i)&&!("addObserverForKeyPath" in c)){coherent.KVO.adaptTree(c)}d.setValueForKey(c,g)}}finally{coherent.dataModel=b}if(f.setup){f.setup(d)}h.onnibload(d)};Object.extend(window.NIB,{load:function(e,b){var f=document.getElementsByTagName("head")[0];var c=document.createElement("script");var g=new coherent.Deferred();c.type="text/javascript";c.defer=false;c.model=new coherent.KVO();c.model.setValueForKey(b,"owner");c.onnibload=function(d){g.callback(d)};c.src=e;f.appendChild(c);return g}})})();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()},viewWithSelector:function(a){return this.view.viewWithSelector(a)},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;if(this.innerHTML&&""===String(d.innerHTML).trim()){d.innerHTML=this.innerHTML}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__)}};coherent.TextField=Class.create(coherent.FormControl,{init:function(){this.base();var a=this.viewElement();Event.observe(a,"drop",this.fieldReceivedDropEvent.bindAsEventListener(this));this.editing=false;this.validationError=null},exposedBindings:["errorMessage"],maskedBindings:["text","html"],defaultPlaceholders:{value:{nullValue:_("marker.input.placeholder"),multipleValues:_("marker.input.multipleValues"),noSelection:_("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()}if(!this.validationError&&!this.__showingPlaceholder&&this.formatter){var a=this.viewElement();var b=this.formatter.valueForString(a.value);b=this.formatter.stringForValue(b);a.value=b}},validate:function(){var a=this.viewElement();var c=a.value;if(this.__showingPlaceholder){c=""}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}}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}this.hidePlaceholder();this.hasFocus=true;this.beginEditing();return true},resignFirstResponder:function(b){var a=this.viewElement();this.hasFocus=false;if(""===a.value){this.showPlaceholder()}this.valueChanged(b);this.endEditing();return true},showPlaceholder:function(){var a=this.viewElement();if(this.bindings.value){a.value=this.bindings.value.placeholderValue()}else{if(this.placeholder){a.value=this.placeholder}else{return}}this.__showingPlaceholder=true;Element.addClassName(a,coherent.Style.kMarkerClass)},hidePlaceholder:function(){if(!this.__showingPlaceholder){return}var a=this.viewElement();var b;if(this.bindings.value){b=this.bindings.value.placeholderValue()}else{if(this.placeholder){b=this.placeholder}}b=String(b);if(a.value===b){a.value=""}this.__showingPlaceholder=false;Element.removeClassName(a,coherent.Style.kMarkerClass)},valueChanged:function(a){if(this.updateTimer){window.clearTimeout(this.updateTmer);this.updateTimer=null}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_ENTER){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(d){var b=this.viewElement();var c=d.newValue;var a=this.bindings.value&&this.bindings.value.markerType;if(!a&&this.formatter){c=this.formatter.stringForValue(c)}if(coherent.NoSelectionMarkerType===a){b.disabled=true}else{if(!this.bindings.enabled){b.disabled=false}}if(!this.bindings.editable){b.readOnly=!this.bindings.value.mutable()}if(b.readOnly){Element.addClassName(b,coherent.Style.kReadOnlyClass)}else{Element.removeClassName(b,coherent.Style.kReadOnlyClass)}if(b.disabled){Element.addClassName(b,coherent.Style.kDisabledClass)}else{Element.removeClassName(b,coherent.Style.kDisabledClass)}if(!this.bindings.errorMessage){this.clearAllErrors()}if(this.hasFocus){return}if(a){this.placeholder=c;b.value="";this.showPlaceholder()}else{b.value=c;this.hidePlaceholder()}},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,{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.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.ToggleButton=Class.create(coherent.FormControl,{exposedBindings:["checked","selection"],onclick:function(c){var a=this.viewElement();var b=a.checked;var d=a.value;if(this.bindings.selection){this.bindings.selection.setValue(d)}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.Anchor=Class.create(coherent.View,{exposedBindings:["href","title"],observeHrefChange:function(b){var a=this.viewElement();a.href=b.newValue},observeTitleChange:function(b){var a=this.viewElement();a.title=b.newValue},onclick:function(c){var a=this.viewElement();var b=a.getAttribute("href");if("#"===b){Event.preventDefault(c)}this.base(c)}});coherent.Button=Class.create(coherent.FormControl,{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)}});coherent.Form=Class.create(coherent.FieldGroup,{exposedBindings:["actionUrl","method"],sendActionOn:["submit"],init:function(){this.base();var a=this.viewElement();Event.observe(a,"submit",this.onsubmit.bind(this))},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}});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)}});Class.extend(Array,{containsObject:function(a){return -1!==this.indexOf(a)},valueForKey:function(d){if(!d||0===d.length){throw new InvalidArgumentError("the key is empty")}if("@count"==d){return this.length}var e=new Array(this.length);var c;var a=this.length;var b;for(c=0;c<a;++c){b=this[c];e[c]=b?b.valueForKey(d):null}return e},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(h){var b=h.length;var f=this.length;var c=[];var a=[];var g=new coherent.ChangeNotification(this,coherent.ChangeType.insertion,c,null,a);for(var e=0;e<b;++e){var d=h[e];this.push(d);this.observeElementAtIndex(f);c.push(d);a.push(f++)}this.notifyObserversOfChangeForKeyPath(g,coherent.KVO.kAllPropertiesKey)},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(d){var c;var e=d.sort(function(i,h){return h-i});var a=d.length;var b=[];for(c=0;c<a;++c){var f=e[c];this.stopObservingElementAtIndex(f);b.push(this[f]);this.splice(f,1)}var g=new coherent.ChangeNotification(this,coherent.ChangeType.deletion,null,b,e);this.notifyObserversOfChangeForKeyPath(g,coherent.KVO.kAllPropertiesKey)},removeObjectsInRange:function(c,f){if(0===f){return}if(!f){if(c.splice){f=c[1];c=c[0]}else{if(c.location){f=c.length;c=c.location}}}var b=c+f;var e=[];for(var d=c;d<b;++d){this.stopObservingElementAtIndex(d);e.push(d)}var a=this.splice(c,f);var g=new coherent.ChangeNotification(this,coherent.ChangeType.deletion,null,a,e);this.notifyObserversOfChangeForKeyPath(g,coherent.KVO.kAllPropertiesKey)},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]);a.notifiedObserverUids=Object.clone(f.notifiedObserverUids);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);Object.extend(coherent,{NoSelectionMarkerType:"noSelection",MultipleValuesMarkerType:"multipleValues",NullValueMarkerType:"nullValue"});coherent.Binding=Class.create({constructor:function(a){Object.extend(this,a);if("string"===typeof(this.transformer)){this.transformer=coherent.findTransformerWithName(this.transformer)}if("function"===typeof(this.transformer)){if(this.transformer.__factoryFn__){this.transformer=this.transformer()}else{this.transformer=new this.transformer()}}this.refresh()},bind:function(){this.object.addObserverForKeyPath(this,this.observeChangeForKeyPath,this.keypath)},unbind:function(){this.object.removeObserverForKeyPath(this,this.keypath)},refresh:function(){var a=this.object.valueForKeyPath(this.keypath);this.cachedModelValue=a;a=this.transformedValue(a);this.markerType=this.markerTypeFromValue(a);if(this.markerType){if((this.markerType+"Placeholder") in this){a=this[this.markerType+"Placeholder"]}else{a=this.observer.defaultPlaceholderForMarkerWithBinding(this.markerType,this.name)}}this.cachedValue=a},transformedValue:function(a){if(!this.transformer){return a}if("array"!==coherent.typeOf(a)){return this.transformer.transformedValue(a)}return a.map(this.transformer.transformedValue,this.transformer)},reverseTransformedValue:function(a){if(!this.transformer){return a}if(!this.transformer.reverseTransformedValue){return undefined}if("array"!==coherent.typeOf(a)){return this.transformer.reverseTransformedValue(a)}return a.map(this.transformer.reverseTransformedValue,this.transformer)},validateProposedValue:function(c){if(this.transformer&&!this.transformer.reverseTransformedValue){throw new Error("Can't validate a value when the transformer doesn't have a reverseTransformedValue method")}var b=this.reverseTransformedValue(c);var a=this.object.validateValueForKeyPath(b,this.keypath);if(a instanceof coherent.Error){return a}if(a===b){return c}return this.transformedValue(a)},setValue:function(b){if(this.cachedValue===b){return}this.markerType=this.markerTypeFromValue(b);this.cachedValue=b;if(this.transformer&&!this.transformer.reverseTransformedValue){return}var a=this.reverseTransformedValue(b);this.cachedModelValue=a;var c=this.updating;this.updating=true;this.object.setValueForKeyPath(a,this.keypath);this.updating=c},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},update:function(){var b=this.value();var c=new coherent.ChangeNotification(this.object,coherent.ChangeType.setting,b);this.updating=true;try{this.observerFn.call(this.observer,c,this.keypath)}catch(a){console.error('Exception while bindng "'+this.name+'" to keypath "'+this.keypath+' ": '+a)}this.updating=false},observerFn:function(c,a,b){},markerTypeFromValue:function(a){if(null===a||"undefined"===typeof(a)||""===a){return coherent.NullValueMarkerType}if(coherent.Markers.MultipleValues===a){return coherent.MultipleValuesMarkerType}if(coherent.Markers.NoSelection===a){return coherent.NoSelectionMarkerType}return null},placeholderValue:function(a){var b;a=a||this.markerType;if((a+"Placeholder") in this){b=this[a+"Placeholder"]}else{b=this.observer.defaultPlaceholderForMarkerWithBinding(a,this.name)}if("function"===typeof(b)){b=b.call(this.object)}return b},observeChangeForKeyPath:function(h,a,b){if(this.updating&&h.newValue===this.cachedModelValue){return}if(coherent.ChangeType.setting===h.changeType){this.cachedModelValue=h.newValue}var f=this.transformedValue(h.newValue);this.markerType=this.markerTypeFromValue(f);if(this.markerType){f=this.placeholderValue()}var c=Object.clone(h);c.newValue=f;if(coherent.ChangeType.setting===h.changeType){this.cachedValue=f}var g=this.updating;this.updating=true;try{this.observerFn.call(this.observer,c,a,b)}catch(d){console.error('Exception while bindng "'+this.name+'" to keypath "'+this.keypath+' ": '+d)}this.updating=g}});coherent.Binding.bindingRegex=/^(.*?)(?:\((.*)\))?$/;coherent.Binding.compoundRegex=/^\s*([^&|].*?)\s*(\&\&|\|\|)\s*(\S.+)\s*$/;coherent.Binding.bindingInfoFromString=function(b){var a;var c;a=b.match(coherent.Binding.bindingRegex);if(!a||a.length<3){throw new InvalidArgumentError("bindingString isn't in correct format")}var d={keypath:a[1]};if(a[2]){d.transformer=coherent.findTransformerWithName(a[2])}return d};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}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)}};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.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="||";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:140,contentScreen:null,spinnerDelay:250,timeout:5000,loading:false,displayCloseWidget:true,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.__urlCache={};this.__nodeCache={};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("div");this.contentScreen.className="overlayScreen";Element.assignId(this.contentScreen);document.body.appendChild(this.contentScreen);Element.setStyle(this.contentScreen,"opacity",0);this.contentScreen.style.display="none"}else{this.contentScreen.parentNode.removeChild(this.contentScreen);document.body.appendChild(this.contentScreen)}var a=this.viewElement();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.cacheNode(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)},cacheNode:function(a){var b=Element.assignId(a);this.__nodeCache[b]=a;coherent.View.addToHoldingArea(a)},__getNodeById:function(b){var a=document.getElementById(b);if(a.parentNode){a.parentNode.removeChild(a)}return a},__clearNode:function(a){while(a.firstChild){var b=a.removeChild(a.firstChild);if(b.id in this.__nodeCache){this.cacheNode(b)}}},__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){var b=this.__getNodeById(d.sourceId);this.cacheNode(b);this.__clearNode(f);f.appendChild(b)}else{if("html" in d){var e=coherent.Scripts.extract(d.html);d.scripts=e.scripts;f.innerHTML=e}else{if("text" in d){i=document.createTextNode(d.text);f.innerHTML="";f.appendChild(i)}else{if("error" in d){i=document.createTextNode(d.error.description);f.innerHTML="";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){Element.setStyle(i,"opacity",0);i.style.display="block"}var h=this.viewElement();h.style.display="";h.style.position="fixed";h.style.left="50%";h.style.top="50%";Element.setStyle(h,"opacity",0);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(){coherent.Scripts.install(e.scripts)}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,callback:b})},close:function(){return this.hide()},hide:function(){var d=this.contentScreen;var b=this.viewElement();var a=this.container();var c=this.content();a.style.position="absolute";Element.setStyle(a,"opacity",0);this.__clearNode(c);coherent.Animator.setStyles(d,{opacity:0},{duration:250,callback:function(){d.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(){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,obscurePage: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.SegmentedControl=Class.create(coherent.View,{exposedBindings:["selectedIndex","selectedLabel"],segmentSelector:"button",init:function(){this.__selectedIndex=-1;var b=this.viewElement();var c=Element.queryAll(b,this.segmentSelector);var a=c.length;for(var d=0;d<a;++d){c[d].segmentIndex=d}},selectedIndex:function(){return this.__selectedIndex},setSelectedIndex:function(c){var a=this.viewElement();var b=Element.queryAll(a,this.segmentSelector);if("number"!==typeof(c)||c<-1||c>=b.length){return}this.willChangeValueForKey("selectedLabel");if(-1!==this.__selectedIndex){Element.removeClassName(b[this.__selectedIndex],coherent.Style.kSelectedClass)}this.__selectedIndex=c;if(-1!==this.__selectedIndex){Element.addClassName(b[this.__selectedIndex],coherent.Style.kSelectedClass)}if(this.bindings.selectedIndex){this.bindings.selectedIndex.setValue(c)}if(this.bindings.selectedLabel){this.bindings.selectedLabel.setValue(this.selectedLabel())}this.didChangeValueForKey("selectedLabel")},selectedLabel:function(){if(-1===this.__selectedIndex){return""}var a=this.viewElement();var b=Element.queryAll(a,this.segmentSelector);var c=b[this.__selectedIndex];if(!c){return""}return c.textContent||c.innerText},onclick:function(b){var a=this.viewElement();var c=b.target||b.srcElement;while(c&&c!=a&&!("segmentIndex" in c)){c=c.parentNode}if(!c||c===a){return}this.setSelectedIndex(c.segmentIndex);this.sendAction()}});coherent.CalendarView=Class.create(coherent.View,{exposedBindings:["selectedDate"],captionFormat:"${monthShortName} ${year}",previousMonthClass:"cal-previous-month",nextMonthClass:"cal-next-month",todayClass:"cal-today",animationDuration:100,animated:false,monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthShortNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],daysOfWeek:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysPerMonth:[31,28,31,30,31,30,31,31,30,31,30,31],today:new Date(),markup:'<div class="calendar"></div>',innerHTML:'<div class="cal-caption"><button class="cal-previous-month">Previous</button><span class="cal-caption"></span><button class="cal-next-month">Next</button></div>',__structure__:{"button.cal-previous-month":coherent.Button({action:"showPreviousMonth"}),"button.cal-next-month":coherent.Button({action:"showNextMonth"})},init:function(){this._previousMonthNodes=[];this._nextMonthNodes=[];this._monthNodes=[];this.buildCalendar(this.viewElement());this.selectedDate=new Date(0);this.setDate(this.today,false)},setDate:function(a,c){if(1===arguments.length){c=this.animated}this.date=new Date(a.getTime());var g=this.date.getMonth();var d=this.date.getFullYear();var f={month:g+1,monthName:this.monthNames[g],monthShortName:this.monthShortNames[g],year:d};var b=this.captionFormat.expand(f);var e=Element.query(this.viewElement(),"span.cal-caption");e.innerHTML=b;this.updatePreviousMonthDays(c);this.updateMonthDays(c);this.updateNextMonthDays(c)},getDate:function(){return this.date},getSelectedDate:function(){if(0===this.selectedDate.getTime()){return null}return this.selectedDate},setSelectedDate:function(a,b){if(1===arguments.length){b=this.animated}if("date"!==coherent.typeOf(a)){a=new Date(0)}this.selectedDate=new Date(a.getTime());this.setDate(this.selectedDate);if(this.bindings.selectedDate){this.bindings.selectedDate.setValue(this.selectedDate)}},buildCalendar:function(a){var f=31+12;var c=document.createElement("li");var g=document.createDocumentFragment();var e=document.createElement("ol");g.appendChild(e);var b;var d;c.className="cal-previous-month day";for(b=0;b<6;++b){d=c.cloneNode(true);d.innerHTML="P";e.appendChild(d);this._previousMonthNodes.push(d)}c.className="cal-current-month day";for(b=0;b<31;++b){d=c.cloneNode(true);d.innerHTML=(b+1);e.appendChild(d);this._monthNodes.push(d)}c.className="cal-next-month day";for(b=0;b<13;++b){d=c.cloneNode(true);d.innerHTML="N";e.appendChild(d);this._nextMonthNodes.push(d)}a.appendChild(g)},updatePreviousMonthDays:function(c){var b=this.previousMonth(this.date);var j=this.daysInMonth(b);var g=this.firstDayOfMonth(this.date);var f=g.getDay();var l=f;var h=j;for(var e=0;e<6;++e){var a=this._previousMonthNodes[5-e];var k=e<l;var d=("none"!==a.style.display);a.innerHTML=h--;if(!c){a.style.display=k?"":"none"}else{if(k&&!d){Element.addClassName(a,coherent.Style.kFadingClass);a.style.display="";coherent.Animator.removeClassName(a,coherent.Style.kFadingClass,{duration:this.animationDuration})}else{if(!k&&d){coherent.Animator.addClassName(a,coherent.Style.kFadingClass,{duration:this.animationDuration,callback:function(i){i.style.display="none";Element.removeClassName(i,coherent.Style.kFadingClass)}})}}}}},updateNextMonthDays:function(b){var f=this.nextMonth(this.date);var h=this.firstDayOfMonth(f);var g=h.getDay();var d;if((this.firstDayOfMonth(this.date).getDay()+this.daysInMonth(this.date))<35){d=14-g}else{d=7-g}for(var e=0;e<13;++e){var a=this._nextMonthNodes[e];var j=e<d;var c=("none"!==a.style.display);a.innerHTML=(e+1);if(!b){a.style.display=j?"":"none"}else{if(j&&!c){Element.addClassName(a,coherent.Style.kFadingClass);a.style.display="";coherent.Animator.removeClassName(a,coherent.Style.kFadingClass,{duration:this.animationDuration})}else{if(!j&&c){coherent.Animator.addClassName(a,coherent.Style.kFadingClass,{duration:this.animationDuration,callback:function(i){i.style.display="none";Element.removeClassName(i,coherent.Style.kFadingClass)}})}}}}},updateMonthDays:function(d){var c=this.daysInMonth(this.date);var h=(this.date.getMonth()===this.today.getMonth()&&this.date.getFullYear()===this.today.getFullYear());var j=this.today.getDate();var a=(this.selectedDate.getMonth()===this.date.getMonth()&&this.selectedDate.getFullYear()===this.date.getFullYear());var g=this.selectedDate.getDate();for(var f=0;f<31;++f){var b=this._monthNodes[f];var k=f<c;var e=("none"!==b.style.display);b.innerHTML=(f+1);if(h&&j==(f+1)){Element.addClassName(b,this.todayClass)}else{Element.removeClassName(b,this.todayClass)}if(a&&g==(f+1)){Element.addClassName(b,coherent.Style.kSelectedClass)}else{Element.removeClassName(b,coherent.Style.kSelectedClass)}if(!d){b.style.display=k?"":"none"}else{if(k&&!e){Element.addClassName(b,coherent.Style.kFadingClass);b.style.display="";coherent.Animator.removeClassName(b,coherent.Style.kFadingClass,{duration:this.animationDuration})}else{if(!k&&e){coherent.Animator.addClassName(b,coherent.Style.kFadingClass,{duration:this.animationDuration,callback:function(i){i.style.display="none";Element.removeClassName(i,coherent.Style.kFadingClass)}})}}}}},firstDayOfMonth:function(a){a=new Date(a.getTime());a.setDate(1);return a},daysInMonth:function(a){var c=a.getMonth();var b=a.getFullYear();if(c<0){c=12-c;b--}if(c>11){c-=12;b++}var e=this.daysPerMonth[c];if(1!=c){return e}var d=(0===b%4&&(0!==b%100||0===b%400));if(d){return e+1}return e},previousMonth:function(b){var a=new Date(b.getTime());var c=b.getMonth()-1;if(c<0){c=11;a.setFullYear(b.getFullYear()-1)}a.setDate(1);a.setMonth(c);a.setDate(Math.min(b.getDate(),this.daysInMonth(a)));return a},nextMonth:function(b){var a=new Date(b.getTime());a.setDate(1);a.setMonth(b.getMonth()+1);a.setDate(Math.min(b.getDate(),this.daysInMonth(a)));return a},onclick:function(e){var d=e.target||e.srcElement;var a=this.viewElement();while(d&&d!=a&&"LI"!==d.tagName){d=d.parentNode}if(!d||d==a){return}var c=new Date(this.date.getTime());var b;if(-1!==(b=this._previousMonthNodes.indexOf(d))){c=this.previousMonth(c);c.setDate(26+b)}else{if(-1!==(b=this._monthNodes.indexOf(d))){c.setDate(b+1)}else{if(-1!==(b=this._nextMonthNodes.indexOf(d))){c=this.nextMonth(c);c.setDate(b+1)}}}Event.preventDefault(e);this.setSelectedDate(c)},showPreviousMonth:function(b){var a=this.previousMonth(this.date);this.setDate(a)},showNextMonth:function(b){var a=this.nextMonth(this.date);this.setDate(a)}});coherent.Fieldset=Class.create(coherent.FieldGroup,{bubbleClass:"bubble",bubblePosition:"above",presentErrorsImmediately:false,constructor:function(a,b,c){this.base(a,b,c);this.__currentViewId=false;this.__fieldErrors={}},init:function(){coherent.page.addObserverForKeyPath(this,"observeFirstResponderChange","firstResponder")},presentError:function(a){var b=a.field;if(!b){return}this.__fieldErrors[b.id]=a;if(this.presentErrorsImmediately){this.__presentError(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)})}},__presentError:function(a){var b=a.field;this.__currentViewId=b.id;coherent.Bubble.display({classname:this.bubbleClass,error:a,position:this.bubblePosition,target:b.viewElement(),within:this.viewElement()})},observeFirstResponderChange:function(c){var b=c.newValue;var a=!!b&&this.__fieldErrors[b.id];if(!a||!b.isDescendantOf(this)){if(this.__currentViewId){coherent.Bubble.hide({target:document.getElementById(this.__currentViewId)})}this.__currentViewId=false;return}this.__presentError(a)}});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.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")}});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)}};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.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.NumberFormatter=Class.create(coherent.Formatter,{invalidValueMessage:_("error.invalid_number"),validFloatCharacters:"0123456789.-",validIntCharacters:"0123456789-",valueForEmptyString:0,allowsFloats:true,allowsEmptyString:false,stringForValue:function(a){if(null===a||"undefined"===typeof(a)){return""}return String(a)},valueForString:function(a){a=a.trim();if(!a&&this.allowsEmptyString){return this.valueForEmptyString}if(this.allowsFloats){return parseFloat(a)}else{return parseInt(a,10)}},isStringValid:function(a){a=a.trim();if(!a&&this.allowsEmptyString){return true}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))}}});Package=(function(){var a={};return function(c){if(c in a){return}a[c]=true;var e=window;var g=c.split(".");var b=g.length;var d;var f;for(d=0;d<b;++d){f=g[d];if(!e[f]){e[f]={}}e=e[f]}}})();var JSON=JSON||{};(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==="string"){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}if(typeof JSON.stringify!=="function"){JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" "}}else{if(typeof space==="string"){indent=space}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify")}return str("",{"":value})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}}());var Cookie=Class.create(coherent.KVO,{constructor:function(e,d){var g=document.cookie;this.name=e;this.options=d;var b=g.lastIndexOf(e+"=");if(-1!==b){var f=b+e.length+1;var a=g.indexOf(";",f);if(-1===a){a=g.length}this.__value=decodeURIComponent(g.slice(f,a))}else{this.__value=""}},getValue:function(){return this.__value},setValue:function(b,a){a=Object.applyDefaults(a,this.options);b=encodeURIComponent(b);this.__value=b;if("number"===typeof(a.expires)){a.expires=new Date(new Date().valueOf()+a.expires*24*60*60*1000)}document.cookie=this.name+"="+b+(a.expires?"; expires="+a.expires.toUTCString():"")+(a.path?"; path="+a.path:"")+(a.domain?"; domain="+a.domain:"")+(a.secure?"; secure":"")},clear:function(){this.setValue("",{expires:new Date(0)})},getObjectValue:function(){if(!this.__value){return{}}if(!this.__objectValue){this.__objectValue=JSON.parse(this.__value)}return this.__objectValue},setObjectValue:function(b,a){this.__objectValue=b;this.setValue(JSON.stringify(b),a)}});if(window.Cookie!==Cookie){window.Cookie=Cookie}function redirectToLogin(){window.open(app.VIRTUAL_ROOT+"/login","_top")}function getCurrentUserId(){var a=new Cookie("LoginInfo").getObjectValue();if(!("userSettings" in a)){redirectToLogin();return null}return a.userSettings.id}(function(){var b=document.documentElement.className;if(coherent.Browser.Safari){b+=" safari"}if(coherent.Browser.MobileSafari){b+=" mobile-safari"}if(coherent.Browser.Mozilla){b+=" mozilla"}if(coherent.Browser.IE){b+=" msie msie"+coherent.Browser.IE}var a=window.navigator.userAgent;if(/Windows/.test(a)){b+=" windows"}if(/Macintosh/.test(a)){b+=" mac"}document.documentElement.className=b.trim()})();Package("app");Package("dashboard");Package("gallery");Package("views");Package("model");Package("formatters");app.VIRTUAL_ROOT="/publisher/v2";app.LOGIN_DESTINATION=(app.VIRTUAL_ROOT+"/gallery");coherent.transformer.Dasherize=Class.create(coherent.ValueTransformer,{transformedValue:function(a){if("string"!==typeof(a)){return a}return a.toLowerCase().replace(/\s+/g,"-")}});coherent.transformer.Dasherise=coherent.transformer.Dasherize;coherent.transformer.Integer=Class.create(coherent.ValueTransformer,{transformedValue:function(a){return parseInt(a||0,10)},reverseTransformedValue:function(a){return a}});coherent.transformer["int"]=coherent.transformer.Integer;coherent.transformer.ArrayToString=Class.create(coherent.ValueTransformer,{joinString:", ",transformedValue:function(a){if(!a){return""}return a.join(this.joinString)}});coherent.transformer["array-to-string"]=coherent.transformer.ArrayToString;formatters.DateFormatter=Class.create(coherent.Formatter,{allowsEmptyString:true,stringForValue:function(a){if(null===a||"undefined"===typeof(a)){return""}if("date"!==coherent.typeOf(a)){return String(a)}var b=[a.getMonth()+1,a.getDate(),a.getFullYear()];return b.join("/")},valueForString:function(b){b=b.trim();if(!b&&this.allowsEmptyString){return null}var e=b.split(/[-\/]/);var d=parseInt(e[0]||1,10)-1;var a=parseInt(e[1]||1,10);var c=parseInt(e[2]||0,10);if(c<100){c+=2000}return new Date(c,d,a)},isStringValid:function(c){c=c.trim();if(!c&&this.allowsEmptyString){return true}var f=c.split(/[-\/]/);var e=parseInt(f[0]||1,10)-1;var a=parseInt(f[1]||1,10);var d=parseInt(f[2]||0,10);if(d<100){d+=2000}var b=new Date(d,e,a);if(e==b.getMonth()&&a==b.getDate()&&d==b.getFullYear()){return true}return new coherent.Error({description:this.invalidValueMessage})},isValidInputCharacter:function(a){return -1!==("0123456789-/".indexOf(a))}});formatters.CurrencyFormatter=Class.create(coherent.Formatter,{invalidValueMessage:_("error.invalid_currency"),validCharacters:"0123456789.-$",allowsEmptyString:true,stringForValue:function(a){if(null===a||"undefined"===typeof(a)){return""}a=Number(a);if(isNaN(a)){return""}return"$"+a.toFixed(2)},valueForString:function(a){a=a.trim();if(!a&&this.allowsEmptyString){return this.valueForEmptyString}if("$"==a.charAt(0)){a=a.substring(1)}return parseFloat(a)},isStringValid:function(a){a=a.trim();if(!a&&this.allowsEmptyString){return true}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){return(-1!==this.validCharacters.indexOf(a))}});views.InlineDialog=Class.create(coherent.Fieldset,{markup:'<div class="inline-dialog"></div>',animated:true,presentErrorsImmediately:true,show:function(d,e,a,g){if(!this.clickHandler){this.clickHandler=this.onclickOutside.bind(this)}Event.observe(document,"click",this.clickHandler);this.setNextResponder(a);this.setValueForKey(e,"representedObject");this.setValueForKey(a,"owner");this.callback=g;var c;var b=this.viewElement();if(d.viewElement){c=d.viewElement()}else{c=d}Element.addClassName(b,coherent.Style.kFadingClass);b.style.display="";c.parentNode.insertBefore(b,c.nextSibling);function f(){var h=Element.query(b,"input[type=text]");h.focus()}if(this.animated){coherent.Animator.removeClassName(b,coherent.Style.kFadingClass,{duration:300,callback:f})}else{Element.removeClassName(b,coherent.Style.kFadingClass)}this.anchorNode=c;this.setValueForKey(true,"displayed")},hide:function(){var a=this.viewElement();if(coherent.page.firstResponder&&coherent.page.firstResponder.isDescendantOf(this)){coherent.page.firstResponder.blur()}function b(){this.setNextResponder(null);this.setValueForKey(null,"owner");this.setValueForKey(null,"representedObject");this.setValueForKey(false,"displayed");a.style.display="none";Element.removeClassName(a,coherent.Style.kFadingClass);coherent.View.__holdingArea.appendChild(a)}if(this.animated){coherent.Animator.addClassName(a,coherent.Style.kFadingClass,{callback:b.bind(this),duration:300})}else{b.call(this)}},onclickOutside:function(c){var b=this.viewElement();var d=c.target||c.srcElement;var a=document.body;while(d&&d!=a){if(d===b||d===this.anchorNode){return}d=d.parentNode}this.hide()}});views.Dialog=Class.create(coherent.FieldGroup,{dialogClassName:"dialog",displayCloseButton:true,markup:"<div></div>",reset:function(){},show:function(d,a,g){if(!this.__overlay){var e=document.createElement("div");var c=Element.assignId(e);document.body.appendChild(e);this.__overlay=new coherent.Overlay(e,null,{});this.__overlay.cacheNode(this.viewElement())}this.setValueForKey(true,"displayed");this.setNextResponder(a);this.setValueForKey(d,"representedObject");this.setValueForKey(a,"owner");this.callback=g;this.reset();this.__overlay.display({classname:this.dialogClassName,sourceId:this.id,grow:false,displayCloseWidget:this.displayCloseButton});var b=this.viewElement();function f(){var h=Element.query(b,"input[type=text]");if(h){h.focus()}}f.delay(300)},showProgress:function(b){var a=this.__overlay.viewElement();if(this.__progressTimer){window.clearTimeout(this.__progressTimer);this.__progressTimer=0}if(!this.__progress){this.__progress=document.createElement("div");this.__progress.className="dialog-progress"}Element.setStyle(this.__progress,"opacity",0);this.__progress.style.display="";this.__progress.innerHTML="";this.__progress.appendChild(document.createTextNode(b));a.parentNode.insertBefore(this.__progress,a);coherent.Animator.setStyles(this.__progress,{opacity:1},{duration:100})},disconnectRepresentedObject:function(){var a=this.representedObject;this.setValueForKey(null,"representedObject");return a},hide:function(c){function a(){b.style.display="none"}if(coherent.page.firstResponder&&coherent.page.firstResponder.isDescendantOf(this)){coherent.page.firstResponder.blur()}var b=this.__overlay.viewElement();coherent.Animator.setStyles(b,{opacity:0},{duration:300,callback:a});this.setValueForKey(false,"displayed");if(c){this.__progressTimer=this.showProgress.bindAndDelay(this,300,c)}},close:function(){function a(){this.__progress.style.display="none"}if(this.__progress){coherent.Animator.setStyles(this.__progress,{opacity:0},{duration:100,callback:a.bind(this)})}if(this.__progressTimer){window.clearTimeout(this.__progressTimer);this.__progressTimer=0}this.setNextResponder(null);this.setValueForKey(null,"owner");this.setValueForKey(null,"representedObject");if(this.__overlay){this.__overlay.hide()}}});views.ModelDialog=Class.create(views.Dialog,{displayCloseButton:false,savingProgressMessage:_("progress.saving"),deletingProgressMessage:_("progress.deleting"),__structure__:{fieldset:coherent.Fieldset({bubblePosition:"below"}),"h2 em":coherent.View({textBinding:"representedObject.name"}),"button.cancel":coherent.Button({action:"cancel"}),"button.save":coherent.Button({action:"save"}),"button.delete":coherent.Button({visibleBinding:"representedObject.id",action:"deleteObject"})},callbackOperation:function(a){return a},cancel:function(b){this.hide();var a=this.disconnectRepresentedObject();var c;if(this.callback){c=this.callback.call(this.owner,this.callbackOperation("cancel"),a,this)}if(c){c.addCallback(this.cancelCompleted.bind(this))}else{this.close()}},saveCompleted:function(a){if(this.callback){this.callback.call(this.owner,this.callbackOperation("saved"),a,this)}this.close();return a},deleteCompleted:function(a){this.close();return a},cancelCompleted:function(a){this.close();return a},recoverFromValidationErrors:function(c,b,a){app.clearError();if(1===a){this.show(c.object,c.owner,c.callback)}else{if(this.callback){this.callback.call(c.owner,this.callbackOperation("cancel"),c.object,this)}}},saveFailed:function(object,error){if(409!==error.status){return error}try{var errorInfo=eval("("+error.xhr.responseText+")")}catch(e){return error}var info={owner:this.owner,object:object,callback:this.callback};this.close();coherent.KVO.adaptTree(errorInfo);var err=new coherent.KVO({title:this.savingProgressMessage,validationErrors:errorInfo.validationErrors,recoveryOptions:[new coherent.KVO({string:"Undo Changes"}),new coherent.KVO({string:"Edit..."})],recoveryAttempter:this.recoverFromValidationErrors.bind(this,info)});app.reportError(err);return null},save:function(b){if(!this.validateFields()){return}this.hide(this.savingProgressMessage);var a=this.disconnectRepresentedObject();var c;if(this.callback){c=this.callback.call(this.owner,this.callbackOperation("save"),a,this)}if(c){c.addCallback(this.saveCompleted.bind(this));c.addErrorHandler(this.saveFailed.bind(this,a))}else{this.saveCompleted(a)}},deleteObject:function(b){this.hide(this.deletingProgressMessage);var a=this.disconnectRepresentedObject();var c;if(this.callback){c=this.callback.call(this.owner,this.callbackOperation("delete"),a,this)}if(c){c.addCallback(this.deleteCompleted.bind(this))}else{this.deleteCompleted()}}});Package("views");views.SetToggleButton=Class.create(coherent.ToggleButton,{exposedBindings:["selectionSet"],onclick:function(a){this.base(a);this._updateSelectionSet()},_updateSelectionSet:function(){var b=this.viewElement();var d=b.checked;var f=this.bindings.value?this.bindings.value.value():b.value;if(!this.bindings.selectionSet){return}var c=this.bindings.selectionSet.value();var a=false;if(!c){a=true;c=[]}var e=(-1!==c.indexOf(f));if(d){if(!e){c.addObject(f)}}else{if(e){c.removeObject(f)}}if(a){this.bindings.selectionSet.setValue(c)}},observeValueChange:function(g){this.base(g);var a=this.viewElement();var e=a.checked;var f=g.newValue;var c=g.oldValue;var d=this.bindings.selectionSet&&this.bindings.selectionSet.value();if(d){var b=d.indexOf(c);if(-1!==b){d.replaceObjectAtIndex(f,b)}}},observeCheckedChange:function(a){this.base(a);this._updateSelectionSet()},observeSelectionChange:function(a){this.base(a);this._updateSelectionSet()},observeSelectionSetChange:function(f){var a=this.viewElement();var e=this.bindings.value?this.bindings.value.value():a.value;var d;var c;var b=false;switch(f.changeType){case coherent.ChangeType.setting:d=f.newValue;c=d&&(-1!==d.indexOf(e));b=true;break;case coherent.ChangeType.insertion:d=f.newValue;if(d&&(-1!==d.indexOf(e))){b=true;c=true}break;case coherent.ChangeType.deletion:d=f.oldValue;if(d&&(-1!==d.indexOf(e))){b=true;c=false}break;case coherent.ChangeType.replacement:d=f.oldValue;if(d&&(-1!==d.indexOf(e))){b=true;c=false}d=f.newValue;if(d&&(-1!==d.indexOf(e))){b=true;c=true}break;default:throw new Error("unknown change type: "+f.changeType)}if(!b){return}a.checked=c;if(this.bindings.checked){this.bindings.checked.setValue(c)}}});views.MeterView=Class.create(coherent.View,{userRatedClass:"user-rating",exposedBindings:["networkValue","maxValue","userValue"],innerHTML:INC("js/views/MeterView.html",'<span><em class="rating">4</em> out of <i>5</i> stars\n</span><u></u><button title="Clear rating">Clear rating</button>'),__structure__:{"em.rating":coherent.View({classBinding:{keypath:"value",transformedValue:function(b){var a=parseInt(b||0,10);if(isNaN(a)){a=0}return"rating rating-"+a}},textBinding:"value"}),i:coherent.View({textBinding:"maxValue"}),u:coherent.View({htmlBinding:{keypath:"maxValue",transformedValue:function(b){var a=[];while(b){a.push('<b class="rating-'+(b--)+'"></b>')}return a.join("")}}})},keyDependencies:{value:["userValue","networkValue"]},init:function(){this.setValueForKey(0,"userValue");this.setValueForKey(0,"networkValue");this.setValueForKey(5,"maxValue")},getUserValue:function(){return this.userValue},setUserValue:function(b){if(b==this.userValue){return}var a=this.viewElement();this.userValue=b;if(b){Element.addClassName(a,this.userRatedClass)}else{Element.removeClassName(a,this.userRatedClass)}if(this.bindings.userValue){this.bindings.userValue.setValue(b)}},getValue:function(){return this.userValue||this.networkValue},onclick:function(b){if(this.disabled){return}var c=b.target||b.srcElement;if("BUTTON"===c.tagName){this.setUserValue(0);this.sendAction();Event.preventDefault(b);return}if("B"!==c.tagName){return}var a=parseInt(c.className.split("-")[1],10);this.setUserValue(a);this.sendAction();Event.preventDefault(b)}});views.AnchoredBubble=Class.create(coherent.Bubble,{init:function(){this.base();this.clickHandler=this.onclickOutside.bind(this)},__show:function(c){if(this.__timer){window.clearTimeout(this.__timer)}this.__timer=null;Event.observe(document,"click",this.clickHandler);this.setNextResponder(c.owner);this.currentTarget=Element.assignId(c.target);var j=this.viewElement();var k=this.arrow();var g=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 h=Element.getViewport();var i;var e=Element.query(g,c.anchorSelector);var d=Element.getRect(e);var f=Element.getRect(j);i={left:a.left-(d.left-f.left),top:a.top-(d.top-f.top),width:c.dimensions.width};j.style.left=i.left+"px";j.style.top=i.top+"px";j.style.width=i.width+"px";k.style.display="none";d=Element.getRect(e);coherent.Animator.setStyles(j,{opacity:1},{duration:100})},__hide:function(){Event.stopObserving(document,"click",this.clickHandler);this.base()},onclickOutside:function(c){var b=this.viewElement();var d=c.target||c.srcElement;var a=document.body;while(d&&d!=a){if(d===b){return}d=d.parentNode}if(this.canHide&&!this.canHide()){return}this.hide()}});views.AnchoredBubble.display=function(d){var b="anchored_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 views.AnchoredBubble(c)}a.display(d)};views.AnchoredBubble.hide=function(d){var b="anchored_bubble_node";var c=document.getElementById(b);if(!c){return}var a=coherent.View.fromNode(c);a.hide(d)};views.OopsOverlay=Class.create(views.Dialog,{dialogClassName:"oops-dialog",displayCloseButton:false,innerHTML:INC("js/views/OopsOverlay.html",'<h2></h2><p class="description">We&rsquo;re sorry, but an error has occurred. You\'ll need to <a href="/login/">restart your session</a>.</p><p class="more-info"></p><ul class="validation-errors"><li><h3></h3><p></p></li></ul><ul class="recovery-options"><li><a href="#"></a></li></ul><div class="error-details"><div class="label url"><span>URL:</span><a href="#"></a></div><div class="label line-number"><span>Line:</span><em></em></div><div class="label status"><span>Status:</span><b></b>&nbsp;<em></em></div><div class="label stack"><span>Stack:</span><pre></pre></div><div class="label response-text"><span>Response:</span><pre></pre></div><div class="label exception-message"><span>Exception:</span><pre></pre></div></div>\n'),__structure__:{h2:coherent.View({htmlBinding:"representedObject.title"}),"p.description":coherent.View({htmlBinding:"representedObject.description"}),"p.more-info":coherent.View({visibleBinding:"representedObject.moreInfo",htmlBinding:"representedObject.moreInfo"}),"ul.validation-errors":coherent.ListView({contentBinding:"representedObject.validationErrors",visibleBinding:"representedObject.validationErrors"}),"ul.validation-errors li h3":coherent.View({textBinding:"*.description"}),"ul.validation-errors li p":coherent.View({textBinding:"*.recoverySuggestion"}),"ul.recovery-options":coherent.ListView({visibleBinding:"representedObject.recoveryAttempter",contentBinding:"representedObject.recoveryOptions",action:"recoveryOptionClicked"}),"ul.recovery-options li a":coherent.Anchor({textBinding:"*.string"}),"div.url":coherent.View({visibleBinding:"representedObject.url"}),"div.url a":coherent.Anchor({srcBinding:"representedObject.url",textBinding:"representedObject.url"}),"div.status":coherent.View({visibleBinding:"representedObject.status"}),"div.status b":coherent.View({textBinding:"representedObject.status"}),"div.status em":coherent.View({textBinding:"representedObject.statusText"}),"div.stack":coherent.View({visibleBinding:"representedObject.stack"}),"div.stack pre":coherent.View({textBinding:"representedObject.stack"}),"div.line-number":coherent.View({visibleBinding:"representedObject.lineNumber"}),"div.line-number em":coherent.View({textBinding:"representedObject.lineNumber"}),"div.exception-message":coherent.View({visibleBinding:"representedObject.exception"}),"div.exception-message pre":coherent.View({textBinding:"representedObject.exception"}),"div.response-text":coherent.View({visibleBinding:"representedObject.responseText"}),"div.response-text pre":coherent.View({textBinding:"representedObject.responseText"})},recoveryOptionClicked:function(c){var b=c.selectedIndex;var a=this.representedObject;if(-1==b||!a.recoveryAttempter){return}a.recoveryAttempter(a,b)}});views.FileUpload=Class.create(coherent.View,{exposedBindings:["value","modified"],innerHTML:'<a href="#"></a><label class="file-upload"><span>Upload</span><input name="file" class="file" type="file"></label>',__structure__:{a:coherent.Anchor({textBinding:"value",srcBinding:"value",enabledBinding:"modified(not)",action:"showCurrentBanner"})},init:function(){var a=this.viewElement();var b=Element.query(a,"input");Event.observe(b,"change",this.fileChanged.bind(this))},fileChanged:function(a){var b=a.target||a.srcElement;this.setValueForKey(b.value,"value");this.setValueForKey(true,"modified")},showCurrentBanner:function(a){window.open(this.valueForKey("value"),"_blank")},modified:function(){return this.__modified},setModified:function(a){this.__modified=a;if(this.bindings.modified){this.bindings.modified.setValue(a)}}});views.BetterTextFieldLabel=Class.create(coherent.View,{acceptsFirstResponder:function(){return true},becomeFirstResponder:function(){var b=coherent.View.fromNode(this.viewElement().htmlFor);if(!b){return false}function a(){coherent.page.makeFirstResponder(b)}a.delay(0);return false}});views.BetterTextField=Class.create(coherent.TextField,{WRAPPER_CLASS:"wrapper",LABEL_CLASS:"placeholder",FOCUS_CLASS:"focus",ANIMATION_DEFAULTS:{duration:200},init:function(){this.base();var a=this.viewElement();var c=document.createElement("span");c.className=this.WRAPPER_CLASS;a.parentNode.replaceChild(c,a);c.appendChild(a);var b=document.createElement("label");b.htmlFor=this.id;b.className=this.LABEL_CLASS;c.appendChild(b);this.__label=new views.BetterTextFieldLabel(b)},showPlaceholder:function(){var e;var b=this.viewElement();var d=b.value;var a;if(this.bindings.value){a=this.bindings.value.markerTypeFromValue(d);e=this.bindings.value.placeholderValue(a)}else{if(this.placeholder){e=this.placeholder}else{return}}var c=this.__label.viewElement();c.innerHTML="";c.appendChild(document.createTextNode(e));c.style.display="";coherent.Animator.setClassName(c,this.LABEL_CLASS,this.ANIMATION_DEFAULTS);this.__showingPlaceholder=true},hidePlaceholder:function(){if(!this.__showingPlaceholder){return}var a=this.viewElement();var b=this.__label.viewElement();if(!a.value&&!this.hasFocus){coherent.Animator.addClassName(b,this.FOCUS_CLASS,this.ANIMATION_DEFAULTS);return}b.style.display="none";this.__showingPlaceholder=false},onkeydown:function(a){this.base(a);var b=a.keyCode;if(Event.isAlphaNumKey(b)||Event.KEY_SPACE===b){this.hidePlaceholder()}}});(function(){var g=coherent.KVO.prototype.valueForKey;var d=[Number,String,Boolean,Date];model.ManagedObject=Class.create(coherent.KVO,{__fault:true,__typename__:null,constructor:function(i){this.id=i;this.__fault=true;this.__dirtyKeys={};this.__managedObjectContext=null;this.__fetchedRelations={};this.__modified=false;for(var h in this.__schema__){this.addObserverForKeyPath(this,this.observePersistentValueChange,h)}},fault:function(){return this.__fault},hasFaultForRelation:function(h){return !this.__fetchedRelations[h]&&-1!==this.__relationFields.indexOf(h)},hasModifiedValueForKey:function(h){return h in this.__dirtyKeys},hasModifiedValueForKeyPath:function(h){if(!h||0===h.length){throw new InvalidArgumentError("key path may not be empty")}if("string"==typeof(h)){h=h.split(".")}var j=h[0];if(1==h.length){return this.hasModifiedValueForKey(j)}var i=this.valueForKey(j);if("undefined"===typeof(i)||null===i){return false}return i.hasModifiedValueForKeyPath(h.slice(1))},awakeFromFetch:function(){},willSave:function(){},didSave:function(){},modified:function(){return this.__modified},setModified:function(h){this.__modified=h;if(!this.__modified){this.__dirtyKeys={}}},__callMethodOnThisAndChildren:function(k){var j;var h;var i;if(this.__fault){return}for(j in this.__schema__){i=this.__schema__[j];if(this.hasFaultForRelation(j)){continue}h=this.valueForKey(j);if(!h){continue}if(h.__callMethodOnThisAndChildren){h.__callMethodOnThisAndChildren(k)}}this[k]()},observeChildObjectChangeForKeyPath:function(j,h,i){if(i in this.__dirtyKeys||h===coherent.KVO.kAllPropertiesKey||!(i in this.__schema__)||!j.object.__modified){this.base(j,h,i);return}Set.add(this.__dirtyKeys,i);this.setModified(true);this.base(j,h,i)},observePersistentValueChange:function(i,h){if(h in this.__dirtyKeys){return}Set.add(this.__dirtyKeys,h);this.setModified(true)},managedObjectContext:function(){return this.__managedObjectContext},setManagedObjectContext:function(h){this.__managedObjectContext=h},changedValues:function(k){var h={};var n;var i;var l;var m;var j=0;if(!this.__modified){return this.id}if(!k&&this.id){h.id=this.id}for(n in this.__dirtyKeys){i=this.valueForKey(n);m=this.__schema__[n];if(m.readonly){continue}j++;l=m.jsonKey;if(!i){h[l]=i;continue}if(i.splice){i=i.map(function(o){return(o&&o.changedValues)?o.changedValues():o})}else{if(i.changedValues){i=i.changedValues(k)}}h[l]=i}if(!j){return this.id}return h},toJSON:function(){var h={};var k;var i;var j;if(this.__fault){return this.id}for(k in this.__schema__){j=this.__schema__[k];if(j.readonly){continue}i=this.valueForKey(k);if("id"===k&&!i){continue}if(i instanceof model.ManagedObject&&!i.modified()&&i.id){i=i.id}h[j.jsonKey]=i}return h},fromJSON:function(r){if(null===r){this.__fault=false;this.setModified(false);return}var n=this.__schema__||{};var k=coherent.typeOf;var m=coherent.KVO.typesOfKeyValuesToIgnore;var l=coherent.KVO.adaptTree;var i;var q;var o;var j;var h=this.__managedObjectContext;for(i in n){j=n[i];if(!(j.jsonKey in r)){continue}o=r[j.jsonKey];q=j.fromJSON(o,h);this.setValueForKey(q,i)}this.__fault=false;this.setModified(false)},applyJSON:function(r){if(null===r){return}var n=this.__schema__||{};var k=coherent.typeOf;var m=coherent.KVO.typesOfKeyValuesToIgnore;var l=coherent.KVO.adaptTree;var i;var q;var o;var j;var h=this.__managedObjectContext;for(i in n){j=n[i];if(!(j.jsonKey in r)){continue}o=r[j.jsonKey];q=this.valueForKey(i);if(q&&q.applyJSON){q.applyJSON(o)}else{this.setValueForKey(j.fromJSON(o,h),i)}}},copyFrom:function(j){var m;var h;var l;var i=this.__managedObjectContext;if(!j){this.__fault=false;return this}for(var k in this.__schema__){if("id"===k){continue}m=this.__schema__[k];h=j.valueForKey(k);l=m.copyFrom(h,i);this.setValueForKey(l,k)}this.__fault=false;return this},valueForKey:function(h){if(h in this.__dirtyKeys){return g.call(this,h)}if(-1!==this.__relationFields.indexOf(h)){if(!(h in this.__fetchedRelations)){this.fetchRelation(h)}return g.call(this,h)}if(this.__fault&&this.id&&h in this.__schema__){this.fetch()}return g.call(this,h)},fetchRelation:function(h,i){if(!this.id){return null}this.__fetchedRelations[h]=true;var j=this.__schema__[h];var k=this.__managedObjectContext.resolveRelationFault(this,j.jsonKey,j.type,i);k.addCallback(this._fetchRelationCompleted.bind(this,j));this.setValueForKey(true,"busy");return k},_fetchRelationCompleted:function(k,j){if(k.jsonKey in j){j=j[k.jsonKey]}if("array"!==coherent.typeOf(j)){throw new Error("Invalid relation json value")}var h=k.fromJSON(j,this.__managedObjectContext);var i=this.__modified;this.setValueForKey(h,k.key);Set.remove(this.__dirtyKeys,k.key);this.setModified(i);this.setValueForKey(false,"busy");return h},fetch:function(h){var i;if(!this.__fault){i=new coherent.Deferred();i.callback(this);return i}if(this.__deferred){return this.__deferred}i=this.__managedObjectContext.resolveFault(this,h);i.addCallback(this._fetchCompleted.bind(this));this.__deferred=i;this.setValueForKey(true,"busy");return i},_fetchCompleted:function(h){this.fromJSON(h);this.awakeFromFetch();this.__deferred=null;this.setValueForKey(false,"busy");return this},revert:function(){if(!this.id){return null}this.setModified(false);this.__fault=true;return this.fetch()},_saveCompleted:function(h){this.fromJSON(h);this.__callMethodOnThisAndChildren("didSave");this.setValueForKey(false,"busy");this.__deferred=null;return this},_saveFailed:function(h){this.setValueForKey(false,"busy");this.__deferred=null;return h},save:function(h){var i;this.__callMethodOnThisAndChildren("willSave");if(!this.__modified){i=new coherent.Deferred();i.callback(this);return i}i=this.__managedObjectContext.save(this,h);this.__deferred=i;this.setValueForKey(true,"busy");i.addCallback(this._saveCompleted.bind(this));i.addErrorHandler(this._saveFailed.bind(this));return i},_copyCompleted:function(h){var i=this.__managedObjectContext.create(this.constructor);i.fromJSON(h);this.setValueForKey(false,"busy");this.__deferred=null;return i},copy:function(h){if(!this.id){throw new Error("Can't copy an object until it's been saved.")}var i=this.__managedObjectContext.copy(this,h);i.addCallback(this._copyCompleted.bind(this));this.setValueForKey(true,"busy");this.__deferred=i;return i}});function b(i,h){var j;if(null===i){j=new (this.type)()}else{j=new (this.type)(i)}if(this.primitive&&Date!==this.type){j=j.valueOf()}return j}function f(i,h){var j;if(null===i||"undefined"===typeof(i)){return i}if("object"!==coherent.typeOf(i)){j=new this.type(i);j.setManagedObjectContext(h);return j}j=new this.type();j.setManagedObjectContext(h);j.fromJSON(i);j.awakeFromFetch();return j}function e(j,h){var i=new this.type();i.setManagedObjectContext(h);i.copyFrom(j);return i}function c(j,i){if(!j){return j}var h=this;return j.map(function(k){return h.fromJSONValue(k,i)})}function a(i,h){if(!i){return i}return i.concat()}model.PROPERTY=function(m,l,i){if("string"!==typeof(m)){i=l;l=m;m=null}var h=(-1!==d.indexOf(l));var j=(model.ManagedObject.prototype.isPrototypeOf(l.prototype));i=Object.applyDefaults(i,{inline:false,readonly:false});function k(n){return{jsonKey:m||n,key:n||m,type:l,primitive:h,inline:(!!i.inline),readonly:(!!i.readonly),defaultValue:i.defaultValue,fromJSON:j?f:b,copyFrom:j?e:b}}k.__factoryFn__=true;return k};model.RELATION=function(l,k,i){if("string"!==typeof(l)){i=k;k=l;l=null}var h=(-1!==d.indexOf(k));var j=(model.ManagedObject.prototype.isPrototypeOf(k.prototype));i=Object.applyDefaults(i,{lazy:false,inline:false,readonly:false});function m(n){return{jsonKey:l||n,key:n||l,type:k,relation:true,primitive:h,lazy:!!i.lazy,inline:!!i.inline,readonly:!!i.readonly,fromJSONValue:j?f:b,fromJSON:c,copyFrom:a}}m.__factoryFn__=true;return m};model.ManagedObject.__subclassCreated__=function(i){var l=i.prototype;var q=i.superclass.prototype;i.__typename__=l.__typename__;if(l.__schema__!==q.__schema__){var j=Object.clone(q.__schema__);var k=l.__schema__;var r;var n=(q.__scalarFields||[]).concat();var o=(q.__relationFields||[]).concat();var m;for(var h in k){r=k[h];if("function"===typeof(r)){if(r.__factoryFn__){r=r(h)}else{r=model.PROPERTY(h,r)(h)}}j[h]=r;if(r.relation&&r.lazy){o.push(h)}else{if(r.inline){m=["{",r.jsonKey,":[",r.type.prototype.__scalarFields.join(","),"]}"].join("");n.push(m)}else{n.push(r.jsonKey)}}}l.__scalarFields=n;l.__relationFields=o;l.__schema__=j}}})();model.Keyword=Class.create(model.ManagedObject,{__schema__:{id:Number,name:String},constructor:function(a){if(this.__cache&&this.__cache[a]){return this.__cache[a]}},fromJSON:function(a){this.base(a);if(this.__cache){this.__cache[this.id]=this}},toJSON:function(){return this.id},copyFrom:function(a){if(a instanceof model.Keyword){return a}return this},changedValues:function(a){return this.id},toString:function(){return this.name}});model.Keyword.__subclassCreated__=function(a){a.prototype.__cache={}};model.Enum=Class.create(model.ManagedObject,{__schema__:{key:model.PROPERTY(String),label:model.PROPERTY("value",String)},constructor:function(a){if(this.__cache&&this.__cache[a]){return this.__cache[a]}},fromJSON:function(a){this.base(a);if(this.__cache){this.__cache[this.key]=this}},toJSON:function(){return this.key},copyFrom:function(a){if(a instanceof model.Enum){return a}return this},changedValues:function(a){return this.key},toString:function(){return this.label}});model.Enum.__subclassCreated__=function(a){a.prototype.__cache={}};model.Category=Class.create(model.Keyword,{});model.CostType=Class.create(model.Keyword,{});model.CPAType=Class.create(model.Keyword,{});model.IncomeRange=Class.create(model.Keyword,{});model.AdType=Class.create(model.Keyword,{});model.Education=Class.create(model.Keyword,{});model.Country=Class.create(model.Keyword,{});model.City=Class.create(model.Keyword,{});model.Household=Class.create(model.Keyword,{});model.Gender=Class.create(model.Keyword,{});model.Language=Class.create(model.Keyword,{});model.Race=Class.create(model.Keyword,{});model.State=Class.create(model.Keyword,{});model.Product=Class.create(model.Keyword,{});model.AgeRange=Class.create(model.Keyword,{});model.ZoneType=Class.create(model.Enum,{});model.Size=Class.create(model.Keyword,{__schema__:{width:Number,height:Number},keyDependencies:{label:["name","width","height"]},label:function(){return this.name+" ("+this.width+"\u00D7"+this.height+")"}});model.KeywordCollection=Class.create(model.ManagedObject,{__typename__:"keywords",__schema__:{categories:model.RELATION(model.Category),costTypes:model.RELATION(model.CostType),cpaTypes:model.RELATION(model.CPAType),incomeRanges:model.RELATION(model.IncomeRange),sizes:model.RELATION(model.Size),adTypes:model.RELATION(model.AdType),educations:model.RELATION(model.Education),countries:model.RELATION(model.Country),cities:model.RELATION("citys",model.City),households:model.RELATION(model.Household),genders:model.RELATION(model.Gender),languages:model.RELATION(model.Language),races:model.RELATION(model.Race),states:model.RELATION(model.State),products:model.RELATION("productsAdvertised",model.Product),ages:model.RELATION("ageRanges",model.AgeRange),zoneTypes:model.RELATION(model.ZoneType)}});model.SortKeys={id:"id",rating:"rating",cost:"cost",ctr:"ctr",revenue:"revenue"};model.NamedObject=Class.create(model.ManagedObject,{__schema__:{id:Number,name:String},uniqueNameMessage:_("error.name-not-unique"),__parentRelationName__:null,validateName:function(b){if(!this.parent||!this.__parentRelationName__){return b}var d=this.parent.valueForKey(this.__parentRelationName__);var a=d&&d.length;for(var c=0;c<a;++c){if(d[c]===this||d[c].id===this.id){continue}if(d[c].name===b){return new coherent.Error({description:this.uniqueNameMessage})}}return b}});model.Campaign=Class.create(model.NamedObject,{__typename__:"campaign",__schema__:{startDate:Date,endDate:Date}});model.Vote=Class.create(model.ManagedObject,{__typename__:"vote",__schema__:{id:Number,score:Number,user:Number,banner:Number}});model.Banner=Class.create(model.NamedObject,{__typename__:"banner",__schema__:{openXId:Number,targetUrl:String,imageURL:String,imageThumbURL:String,displayCost:model.PROPERTY(String,{readonly:true}),cost:model.PROPERTY(Number,{readonly:true}),costType:model.PROPERTY(model.CostType,{readonly:true}),cpaType:model.PROPERTY("CPAType",model.CPAType,{readonly:true}),networkRating:model.PROPERTY("rating",Number,{readonly:true}),campaign:model.PROPERTY(model.Campaign,{inline:true,readonly:true}),userVote:model.PROPERTY(model.Vote,{readonly:true}),size:model.PROPERTY(model.Size)}});model.FacetValue=Class.create(model.ManagedObject,{__schema__:{value:String,count:Number}});model.FacetData=Class.create(model.ManagedObject,{__schema__:{keywords:model.RELATION("Banner.KeywordsString",model.FacetValue)}});model.FilterDefinition=Class.create(model.ManagedObject,{__typename__:"filterDefinition",__schema__:{id:Number,keywords:String,categories:model.RELATION(Number),households:model.RELATION(Number),languages:model.RELATION(Number),races:model.RELATION(Number),education:model.RELATION("educations",Number),states:model.RELATION(Number),sizes:model.RELATION(Number),countries:model.RELATION(Number),cities:model.RELATION(Number),products:model.RELATION("productsAdvertised",Number),incomeRanges:model.RELATION(Number),genders:model.RELATION(Number),costTypes:model.RELATION(Number),ages:model.RELATION("ageRanges",Number),adTypes:model.RELATION(Number)}});model.UserOverview=Class.create(model.ManagedObject,{__typename__:"userSettings",__schema__:{id:Number,userId:model.PROPERTY("user",Number),contactName:String}});model.Review=Class.create(model.ManagedObject,{__typename__:"review",__schema__:{id:Number,text:String,subject:String,date:model.PROPERTY("authoredOn",Date),author:model.PROPERTY(model.UserOverview,{inline:true}),currentUserIsAuthor:Boolean,vote:model.PROPERTY(model.Vote,{inline:true}),banner:Number}});model.Statistics=Class.create(model.ManagedObject,{__typename__:"statistics",__schema__:{impressionCount:Number,clickCount:Number,conversionCount:Number,amount:Number}});model.BannerDetail=Class.create(model.Banner,{__schema__:{description:model.PROPERTY("bannerCampaignDescription",String),advertiser:model.PROPERTY(model.NamedObject,{inline:true}),playlists:model.RELATION(model.NamedObject,{inline:true}),filterDefinition:model.PROPERTY(model.FilterDefinition,{inline:true}),directEmbedCode:String,numberOfVotes:model.PROPERTY("votes__count",Number),size:model.Size,adType:model.AdType,reviews:model.RELATION(model.Review,{inline:true}),statistics:model.PROPERTY("publisherStats",model.Statistics,{inline:true,readonly:true})}});model.SmartlistNamedObject=Class.create(model.NamedObject,{__typename__:"smartlist",__parentRelationName__:"smartlists"});model.Smartlist=Class.create(model.SmartlistNamedObject,{__schema__:{readOnly:Boolean,parentZone:Number,stemmedBody:String,unstemmedBody:String,keywords:model.PROPERTY("keywordsString",String),notes:String,networkMaximumRating:Number,networkMinimumRating:Number,myMaximumRating:Number,myMinimumRating:Number,minimumPrice:Number,maximumPrice:Number,runStartDateBefore:Date,runStartDateAfter:Date,runEndDateBefore:Date,runEndDateAfter:Date,ignoreVertical:Boolean,ignoreRating:Boolean,ignoreProduct:Boolean,ignoreGeo:Boolean,ignoreDemo:Boolean,ignoreDate:Boolean,ignoreAdUnit:Boolean,daysValidFor:model.PROPERTY(Number,{defaultValue:365}),daysUploadedWithin:Number,filterDefinition:model.PROPERTY("filterDef",model.FilterDefinition,{inline:true}),numberOfBanners:model.PROPERTY("banners__count",Number,{readonly:true})},constructor:function(a){this.base(a);this.banners=[];this.addObserverForKeyPath(this,"observeKeywordArrayChange","keywordArray")},_fetchBannersCompleted:function(a){var b=new model.SearchResultsData();b.setManagedObjectContext(this.managedObjectContext());b.fromJSON(a);b.awakeFromFetch();b.sortable=true;return b},fetchBanners:function(g,f,b){var e;if(!this.modified()&&0===f&&b<=this.banners.length&&g===model.SortKeys.id){e=new coherent.Deferred();var c=new model.SearchResultsData();c.setManagedObjectContext(this.managedObjectContext());c.sortable=true;c.start=0;c.count=Math.min(this.banners.length,b);c.total=this.numberOfBanners;c.banners=this.banners.slice(0,b);e.callback(c);return e}var a={sortBy:g||model.SortKeys.id,start:f||0,count:b||50,object:this,facets:false,facetFields:"Banner.KeywordsString"};e=this.managedObjectContext().callMethod("POST","/api/gallery/search",model.Banner,a);e.addCallback(this._fetchBannersCompleted.bind(this));return e},fetchFacets:function(){var b;var a={count:0,object:this,facets:true,facetFields:"Banner.KeywordsString"};b=this.managedObjectContext().callMethod("POST","/api/gallery/search",model.Banner,a);b.addCallback(this._fetchBannersCompleted.bind(this));return b},fetchRelatedBannersCompleted:function(a){var c=new model.SearchResultsData();c.sortable=false;c.related=true;c.setManagedObjectContext(this.managedObjectContext());c.fromJSON(a);var b=new model.SearchResultsData();b.setManagedObjectContext(this.managedObjectContext());b.fromJSON(a.similarBanners);c.total+=b.total;c.count+=b.total;c.banners=c.banners.concat(b.banners);c.awakeFromFetch();return c},fetchRelatedBanners:function(a,g,c,f){var b={start:g||0,count:c||50,object:this,mlt:true,mltFields:"Banner.KeywordsString",bannerIds:a.join(",")};if(f){b.sortBy=f}var e=this.managedObjectContext().callMethod("POST","/api/gallery/search",model.Banner,b);e.addCallback(this.fetchRelatedBannersCompleted.bind(this));return e},searchFieldRegex:/\s*keyword:([^" \t]+)|keyword:"([^"\\]*(?:\\.[^"\\]*)*)"|([^" \t]+)|"([^"\\]*(?:\\.[^"\\]*)*)"/g,filterRegex:/"([^"\\]*(?:\\.[^"\\]*)*)"/g,parseSearchString:function(){var c=this.valueForKey("searchString");var b=[];var e=[];var d=[];var a;while(null!==(a=this.searchFieldRegex.exec(c))){if(a[1]||a[2]){d.push('"'+a[1]||a[2]+'"')}else{if(a[3]){b.push('"'+a[3]+'"')}else{if(a[4]){e.push('"'+a[4]+'"')}}}}this.setValueForKey(b.join(" "),"stemmedBody");this.setValueForKey(e.join(" "),"unstemmedBody");this.__termsNeedUpdating=false},observeKeywordArrayChange:function(a){if(coherent.ChangeType.setting===a.changeType){return}this.setKeywordArray(this.__keywordArray)},keywordArray:function(){if(this.__keywordArray){return this.__keywordArray}},setKeywordArray:function(d){this.__keywordArray=d;var c=[];var a=d.length;var b;d=d.sort();for(b=0;b<a;++b){c.push('"'+d[b]+'"')}c=c.join(" ");if(c===this.keywords){return}this.setValueForKey(c,"keywords")},searchString:function(){return this.__searchString},setSearchString:function(a){if(this.__searchString===a.trim()){return}this.__searchString=a;this.__termsNeedUpdating=true;this.setModified(true);Set.add(this.__dirtyKeys,"stemmedBody");Set.add(this.__dirtyKeys,"unstemmedBody")},stemmedBody:function(){if(this.__termsNeedUpdating){this.parseSearchString()}return this.__stemmedBody},setStemmedBody:function(a){this.__stemmedBody=a},unstemmedBody:function(){if(this.__termsNeedUpdating){this.parseSearchString()}return this.__unstemmedBody},setUnstemmedBody:function(a){this.__unstemmedBody=a},awakeFromFetch:function(){this.base();var f=this.valueForKey("stemmedBody");var d=this.valueForKey("unstemmedBody");var e=[];var b;while(null!==(b=this.filterRegex.exec(f))){e.push(b[1])}while(null!==(b=this.filterRegex.exec(d))){e.push(b[0])}this.setValueForKey(e.join(" "),"searchString");var a=this.valueForKey("keywords");var c=[];while(null!==(b=this.filterRegex.exec(a))){c.push(b[1])}c=c.sort();this.willChangeValueForKey("keywordArray");this.__keywordArray=c;this.didChangeValueForKey("keywordArray");this.setModified(false)}});model.Playlist=Class.create(model.NamedObject,{__typename__:"playlist",__parentRelationName__:"playlists",__schema__:{running:Boolean,isScheduled:Boolean,startDate:Date,endDate:Date,notes:String,active:Boolean,parentZone:Number,numberOfBanners:model.PROPERTY("banners__count",Number,{readonly:true})},constructor:function(a){this.base(a);this.banners=[]},_fetchBannersCompleted:function(a){var b=new model.SearchResultsData();b.setManagedObjectContext(this.managedObjectContext());b.fromJSON(a);b.awakeFromFetch();b.sortable=true;return b},fetchBanners:function(e){var c;if(e===model.SortKeys.id&&this.banners.length===this.numberOfBanners){c=new coherent.Deferred();var b=new model.SearchResultsData();b.setManagedObjectContext(this.managedObjectContext());b.start=0;b.count=this.banners.length;b.total=this.banners.length;b.banners=this.banners;b.sortable=true;c.callback(b);return c}var a={};if(e){a.sortBy=e}c=this.managedObjectContext().resolveRelationFault(this,"banners",model.Banner,a);c.addCallback(this._fetchBannersCompleted.bind(this));return c},_bannersUpdated:function(a){this.setValueForKey(a.total,"numberOfBanners")},addBanners:function(a){var b=this.managedObjectContext();var f=b.endpointForObjectAndAttribute(this,"banners");var c={object:{banners:a}};var e=b.callMethod("POST",f,null,c);e.addCallback(this._bannersUpdated.bind(this));return e},removeBanners:function(a){var b=this.managedObjectContext();var f=b.endpointForObjectAndAttribute(this,"banners");var c={object:{banners:a}};var e=b.callMethod("DELETE",f,null,c);e.addCallback(this._bannersUpdated.bind(this));return e}});model.Zone=Class.create(model.NamedObject,{__typename__:"zone",__parentRelationName__:"zones",__schema__:{publisher:Number,page:Number,zoneType:model.ZoneType,playlists:model.RELATION("activePlaylists",model.Playlist,{inline:true,readonly:true}),smartlists:model.RELATION("activeSmartlists",model.SmartlistNamedObject,{inline:true,readonly:true}),smartlist:model.Smartlist,notes:String,pageUrl:String,invocationCode:String,size:model.Size,active:Boolean,defaultBanner:model.Banner},willSave:function(){if(!this.modified()){return}if(!this.valueForKeyPath("smartlist.name")){this.setValueForKeyPath(this.name+" Internal Smartlist","smartlist.name")}if(!this.valueForKeyPath("defaultBanner.name")){this.setValueForKeyPath(this.name+" Default Banner","defaultBanner.name")}if(!this.valueForKeyPath("defaultBanner.size")){this.setValueForKeyPath(this.size,"defaultBanner.size")}if(!this.valueForKeyPath("smartlist.filterDefinition.sizes")){this.setValueForKeyPath([this.size.id],"smartlist.filterDefinition.sizes")}}});model.Page=Class.create(model.NamedObject,{__typename__:"page",__parentRelationName__:"pages",__schema__:{publisher:Number,zones:model.RELATION("activeZones",model.NamedObject,{inline:true,readonly:true})}});model.PublisherOverview=Class.create(model.NamedObject,{__typename__:"publisher"});model.Publisher=Class.create(model.PublisherOverview,{__schema__:{contactName:String,emailAddress:String,pages:model.RELATION(model.NamedObject,{inline:true,readonly:true}),zones:model.RELATION("activeZones",model.NamedObject,{lazy:true,readonly:true})}});model.SearchResultsData=Class.create(model.ManagedObject,{__schema__:{total:Number,start:Number,count:Number,banners:model.RELATION(model.Banner),facets:model.FacetData}});model.SearchResults=Class.create(coherent.KVO,{keyDependencies:{paged:["total","count"],last:["start","count"],first:["start"],canShowPrevious:["start"],canShowNext:["start","count","total"]},constructor:function(){this.sortable=false;this.source=null;this.banners=[];this.start=0;this.count=0;this.total=0;this.sortKey=model.SortKeys.id;this.facets=null},first:function(){return this.start+1},last:function(){return this.start+this.count},paged:function(){return this.banners&&(this.total>this.count)},canShowPrevious:function(){return this.start>0},canShowNext:function(){return(this.start+this.count+1)<this.total},clear:function(){this.setValueForKey([],"banners");this.setValueForKey(0,"start");this.setValueForKey(0,"total");this.setValueForKey(0,"count");if(this.__deferred){this.__deferred.cancel();this.__deferred=null}this.setValueForKey(false,"busy");this.setValueForKey(false,"sortable");this.setValueForKey(null,"facets")},fetchBanners:function(b,h,e,a){if(this.__deferred){this.__deferred.cancel();this.__deferred=null}var f=b;var k=h;var j=(a&&this.source&&a.id===this.source.id);var g=(b===this.start);var c=(e===this.sortKey);if(j&&g&&c&&!a.modified()){if(h===this.count){return}if(h<this.count){this.banners.removeObjectsInRange(h,this.count-h);this.setValueForKey(h,"count");return}else{f=this.start+this.count;k=h-this.count}}else{this.setValueForKey(a,"source");this.setValueForKey(e,"sortKey");this.setValueForKey([],"banners");this.setValueForKey(b,"start");if(!j){this.setValueForKey(0,"total");this.setValueForKey(0,"count");this.setValueForKey(null,"facets")}}var i=this.source.fetchBanners(this.sortKey,f,k);this.setValueForKey(true,"busy");this.__deferred=i;i.addCallback(this._fetchBannersCompleted.bind(this));i.addErrorHandler(this._fetchBannersFailed.bind(this));if(!this.facets&&this.source.fetchFacets){i=this.source.fetchFacets();i.addCallback(this._fetchFacetsCompleted.bind(this))}},_fetchFacetsCompleted:function(a){if(a.facets){this.setValueForKey(a.facets,"facets")}},_fetchBannersFailed:function(a){this.__deferred=null;this.clear()},_fetchBannersCompleted:function(d){this.__deferred=null;this.setValueForKey(d.total,"total");if(d.facets){this.setValueForKey(d.facets,"facets")}var e=(d.start||0)-this.start;var b=d.banners.length;var f=this.banners;var c=d.banners;for(var a=0;a<b;++a){if(a+e>=f.length){f.addObject(c[a])}else{if(f[a+e].id===c[a].id){f[a+e].copyFrom(c[a])}else{f.replaceObjectAtIndex(c[a],a+e)}}}this.setValueForKey(f.length,"count");this.setValueForKey(!!d.sortable,"sortable");this.setValueForKey(!!d.related,"related");this.setValueForKey(false,"busy")},fetchRelatedBanners:function(a,c,b){if(!this.source||!this.source.fetchRelatedBanners){return}this.clear();var e=this.source.fetchRelatedBanners(a,0,c,b);this.__deferred=e;this.setValueForKey(true,"busy");e.addCallback(this._fetchBannersCompleted.bind(this));e.addErrorHandler(this._fetchBannersFailed.bind(this))}});model.ManagedObjectContext=Class.create({endpoints:{},defaultEndpoint:null,defaultAttributeEndpoint:null,XHR_OPTIONS:{responseContentType:"application/json",contentType:"application/json",headers:{accept:"application/json"}},DEFAULT_FETCH_PARAMETERS:{},DEFAULT_SAVE_PARAMETERS:{},DEFAULT_COPY_PARAMETERS:{},DEFAULT_DELETE_PARAMETERS:{},defaultErrorHandler:function(a){return a},fetch:function(a,c){var b=new a(c);if(b instanceof model.ManagedObject){b.setManagedObjectContext(this);b.fetch()}return b},create:function(a){var b=new a();if(b instanceof model.ManagedObject){b.setManagedObjectContext(this)}b.__fault=false;return b},endpointForObject:function(b){var a=this.endpoints[b.__typename__];if(a){return a.expand(b,"")}if(!this.defaultEndpoint){throw new Error("Unable to determine endpoint for typename: "+b.__typename__)}return this.defaultEndpoint.expand(b,"")},endpointForObjectAndAttribute:function(d,a){var c=Object.clone(d);c.__attr__=a;var b=this.endpoints[d.__typename__+"/"+a];if(b){return b.expand(c,"")}if(!this.defaultAttributeEndpoint){throw new Error("Unable to determine endpoint for typename: "+d.__typename__)}return this.defaultAttributeEndpoint.expand(c,"")},resolveFault:function(c,b){var f=this.endpointForObject(c);var a=Object.applyDefaults({},this.XHR_OPTIONS);b=Object.applyDefaults(b,this.DEFAULT_FETCH_PARAMETERS);if(c.__scalarFields){a.headers["x-5to1-fields"]="["+c.__scalarFields.join(",")+"]"}var e=XHR.get(f,b,a);e.addErrorHandler(this.defaultErrorHandler.bind(this));return e},resolveRelationFault:function(f,e,b,c){var h=this.endpointForObjectAndAttribute(f,e);var a=Object.applyDefaults({},this.XHR_OPTIONS);c=Object.applyDefaults(c,this.DEFAULT_FETCH_PARAMETERS);if(b&&b.prototype.__scalarFields){a.headers["x-5to1-fields"]="["+b.prototype.__scalarFields.join(",")+"]"}var g=XHR.get(h,c,a);g.addErrorHandler(this.defaultErrorHandler.bind(this));return g},callMethod:function(c,a,e,f){var b=Object.applyDefaults({},this.XHR_OPTIONS);c=c||"POST";if(f.object){b.body=JSON.stringify(f.object);delete f.object}if(e&&e.prototype.__scalarFields){b.headers["x-5to1-fields"]="["+e.prototype.__scalarFields.join(",")+"]"}var g=XHR.request(c,a,f,b);g.addErrorHandler(this.defaultErrorHandler.bind(this));return g},save:function(c,b){var f=this.endpointForObject(c);b=Object.applyDefaults(b,this.DEFAULT_SAVE_PARAMETERS);var g;var a=Object.applyDefaults({},this.XHR_OPTIONS);if(c.id){g="PUT";a.body=JSON.stringify(c.changedValues())}else{g="POST";a.body=JSON.stringify(c)}if(c.__scalarFields){a.headers["x-5to1-fields"]="["+c.__scalarFields.join(",")+"]"}var e=XHR.request(g,f,b,a);e.addErrorHandler(this.defaultErrorHandler.bind(this));return e},copy:function(e,c){var g=this.endpointForObject(e);c=Object.applyDefaults(c,this.DEFAULT_COPY_PARAMETERS);var h="POST";var b=e.changedValues(true);b.id=e.id;var a=Object.applyDefaults({},this.XHR_OPTIONS);a.body=JSON.stringify(b);a.headers["x-5to1-method"]="COPY";if(e.__scalarFields){a.headers["x-5to1-fields"]="["+e.__scalarFields.join(",")+"]"}console.log("COPY body",b,JSON.stringify(b));var f=XHR.request(h,g,c,a);f.addErrorHandler(this.defaultErrorHandler.bind(this));delete a.headers["x-5to1-method"];return f},deleteObject:function(b,a){var e=this.endpointForObject(b);a=Object.applyDefaults(a,this.DEFAULT_DELETE_PARAMETERS);var c=XHR.request("DELETE",e,a,this.XHR_OPTIONS);c.addErrorHandler(this.defaultErrorHandler.bind(this));return c}});model.HtmlFragment=Class.create(model.ManagedObject,{__typename__:"htmlFragment",__schema__:{id:Number,name:String,html:String},constructor:function(a){this.base();this.name=a}});model.UserSettingsCurrentValues=Class.create(model.UserOverview,{__schema__:{currentPublisher:Number,currentPage:Number,currentZone:Number,currentSmartlist:Number,currentPlaylist:Number}});model.makeUserSettingsGetterForProperty=function(b){function a(){return this[a.prop]}a.prop="__"+b;a.displayName=b;return a};model.makeUserSettingsSetterForPropertyOfType=function(c,a){function b(f){var g=b.prop;if(this.busy){this[g]=f;return}var d=f?f.id:null;if(this[g]&&this[g].id===d){return}if(!this[g]&&!f){return}if(!f||f instanceof b.type){this[g]=f}else{var e=new b.type(d);e.setManagedObjectContext(this.managedObjectContext());e.copyFrom(f);e.setModified(false);this[g]=e}this.scheduleSave();if(this[g]){this[g].setValueForKey(true,"busy")}}b.clearProp=c;b.prop="__"+c;b.type=a;b.displayName="set"+c.titleCase();return b};model.UserSettings=Class.create(model.UserOverview,{__schema__:{emailAddress:String,password:String,publishers:model.RELATION(model.PublisherOverview,{readonly:true,inline:true}),currentPublisher:model.PROPERTY(model.Publisher,{inline:true}),currentPage:model.PROPERTY(model.Page,{inline:true}),currentZone:model.PROPERTY(model.Zone,{inline:true}),currentSmartlist:model.PROPERTY(model.Smartlist,{inline:true}),currentPlaylist:model.PROPERTY(model.Playlist,{inline:true})},_saveCompleted:function(c){c=this.base(c);var a;for(var b in c.__schema__){if("id"===b){continue}a=c.valueForKey(b);if(a&&a.setValueForKey){a.setValueForKey(false,"busy")}}return c},save:function(){if(this.__timer){window.clearTimeout(this.__timer);this.__timer=0}return this.base()},scheduleSave:function(){if(this.__timer){window.clearTimeout(this.__timer);this.__timer=0}this.__timer=window.setTimeout(this.save.bind(this),250)},awakeFromFetch:function(){this.normaliseValues()},didSave:function(){this.normaliseValues()},normaliseValues:function(){this.willChangeValueForKey("currentPage");this.willChangeValueForKey("currentZone");this.willChangeValueForKey("currentPlaylist");this.willChangeValueForKey("currentSmartlist");if(!this.__currentPublisher){this.__currentPage=null}if(!this.__currentPage){this.__currentZone=null}if(!this.__currentZone){this.__currentPlaylist=null;this.__currentSmartlist=null}this.didChangeValueForKey("currentPage");this.didChangeValueForKey("currentZone");this.didChangeValueForKey("currentPlaylist");this.didChangeValueForKey("currentSmartlist");this.setModified(false)},currentPublisher:model.makeUserSettingsGetterForProperty("currentPublisher"),setCurrentPublisher:model.makeUserSettingsSetterForPropertyOfType("currentPublisher",model.Publisher),currentPage:model.makeUserSettingsGetterForProperty("currentPage"),setCurrentPage:model.makeUserSettingsSetterForPropertyOfType("currentPage",model.Page),currentZone:model.makeUserSettingsGetterForProperty("currentZone"),setCurrentZone:model.makeUserSettingsSetterForPropertyOfType("currentZone",model.Zone),currentSmartlist:model.makeUserSettingsGetterForProperty("currentSmartlist"),setCurrentSmartlist:model.makeUserSettingsSetterForPropertyOfType("currentSmartlist",model.Smartlist),currentPlaylist:model.makeUserSettingsGetterForProperty("currentPlaylist"),setCurrentPlaylist:model.makeUserSettingsSetterForPropertyOfType("currentPlaylist",model.Playlist)});Object.extend(coherent.strings,{"error.uncaught-exception.title":"Oops&hellip;","error.uncaught-exception.description":'We&rsquo;re sorry, but an error has occurred. You&rsquo;ll need to <a href="/publisher/v2/login/">restart your session</a>.',"error.server-error.title":"Oops&hellip;","error.server-error.description":'We&rsquo;re sorry, but an error has occurred. You&rsquo;ll need to <a href="/publisher/v2/login/">restart your session</a>.',"error.account-setup.title":"Oops&hellip;","error.account-setup.description":"We&rsquo;re sorry, but your account doesn&rsquo;t seem to be configured correctly. Please, contact your account manager to get this problem corrected.","error.account-setup.no-publishers":"Your account doesn&rsquo;t have any publishers associated with it."});app.AppController=Class.create(coherent.ViewController,{exposedBindings:["currentUser"],innerHTML:INC("js/app/AppController.html",'<div class="navigation"><ul><li class="home"><a href="http://5to1.com/">5:1</a></li><li class="gallery"><a href="/publisher/v2/gallery/">Home</a></li><!--        <li class="dashboard"><a href="/publisher/v2/dashboard/">Dashboard</a></li> --><li class="help"><a href="/publisher/v2/help/">Help</a></li><li class="logout"><a href="/publisher/v2/login">Sign Out</a></li><li class="account"><a href="/publisher/v2/account/">Account</a></li><li class="publisher"><select size="1"><option>Sports Illustrated</option></select></li></ul></div>\n'),__structure__:{"li.publisher em":coherent.View({textBinding:"currentUser.contactName"}),"li.publisher select":coherent.SelectField({visibleBinding:{keypath:"currentUser.publishers",transformedValue:function(a){return a&&a.length&&a.length>1}},contentBinding:"currentUser.publishers",displayValuesBinding:"currentUser.publishers.name",contentValuesBinding:"currentUser.publishers.id",selectedValueBinding:"currentPublisherId"}),"li.logout a":coherent.Anchor({action:"logout"})},init:function(){this.context=new model.ManagedObjectContext();this.context.defaultErrorHandler=this.handleTransportError.bind(this);this.context.defaultEndpoint="/api/model/${__typename__}/${id}";this.context.defaultAttributeEndpoint="/api/model/${__typename__}/${id}/${__attr__}";this.context.endpoints[model.KeywordCollection.__typename__]="/api/gallery/keywords";this.context.endpoints[model.HtmlFragment.__typename__]="/api/model/${__typename__}/name/${name}";this.addObserverForKeyPath(this,"observePublisherIdChange","currentUser.currentPublisher.id");app.context=this.context;app.reportError=this.reportError.bind(this);app.clearError=this.clearError.bind(this);var c=this.context.fetch(model.KeywordCollection);this.setValueForKey(c,"keywords");model.keywords=c;var j=c.fetch();j.addCallback(this.keywordsLoaded.bind(this));window.onerror=this.handleUncaughtException.bind(this);var f=Element.queryAll(this.viewElement(),"ul li a");var a=f.length;var b=String(document.location);var h=null;var e;for(var g=0;g<a;++g){e=f[g].href;if(!b.beginsWith(e)){continue}if(!h||h.href.length<=e.length){h=f[g]}}if(h){Element.addClassName(h,coherent.Style.kSelectedClass)}},clearError:function(){this.oops.close()},reportError:function(a){if(!this.oops){this.oops=new views.OopsOverlay(null)}this.oops.show(a,this)},handleUncaughtException:function(c,b,a){var d=new coherent.KVO({title:_("error.uncaught-exception.title"),description:_("error.uncaught-exception.description"),url:b,lineNumber:a,exception:c});this.reportError(d)},handleTransportError:function(a){if(a instanceof CancelledError){return a}if(401===a.status){redirectToLogin();return a}var b=new coherent.KVO({title:_("error.server-error.title"),description:_("error.server-error.description"),status:a.status,statusText:a.statusText,url:a.url,stack:String(a.stack||""),responseText:(a.xhr?a.xhr.responseText:null)});this.reportError(b);return a},currentUser:function(){return this.__user},setCurrentUser:function(a){this.__user=a;app.currentUser=a;if(this.bindings.currentUser){this.bindings.currentUser.setValue(a)}},observePublisherIdChange:function(){this.forceChangeNotificationForKey.bindAndDelay(this,0,"currentPublisherId")},currentPublisherId:function(){if(!this.__user||this.__user.fault()){return 0}return this.valueForKeyPath("currentUser.currentPublisher.id")},setCurrentPublisherId:function(c){c=parseInt(c,10);if(c===this.__user.currentPublisher().id){return}var b=this.__user;var a=b.publishers.length;for(var d=0;d<a;++d){var e=b.publishers[d];if(e.id===c){b.setValueForKey(e,"currentPublisher");return}}b.setValueForKey(null,"currentPublisher")},_userSettingsLoaded:function(a){var h=a.valueForKey("publishers");if(!h||!h.length){var c=new coherent.KVO({title:_("error.account-setup.title"),description:_("error.account-setup.description"),moreInfo:_("error.account-setup.no-publishers")});this.reportError(c);return a}var d=a.valueForKey("currentPublisher");if(!d||!h.valueForKey("id").containsObject(d.id)){var b=app.context.fetch(model.Publisher,h[0].id);a.setValueForKey(b,"currentPublisher")}this.setCurrentUser(a);var g=new Cookie("smartlist",{path:"/"});if(g.getValue()){var f=g.getObjectValue();var e=a.valueForKey("currentSmartlist");if(f.id==e.id){e.applyJSON(f)}}return a},keywordsLoaded:function(){var b=getCurrentUserId();var a=this.context.fetch(model.UserSettings,b);var c=a.fetch();c.addCallback(this._userSettingsLoaded.bind(this))},logout:function(a){new Cookie("LoginInfo",{path:"/"}).clear();new Cookie("LoginToken",{path:"/"}).clear();redirectToLogin()}});