var ENV={platform:"classic",mode:"production"},SC=SC||{BUNDLE_INFO:{},LAZY_INSTANTIATION:{}};SC.json=JSON;
SC.browser=function(){var a=navigator.userAgent.toLowerCase(),b=(a.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1];a={version:b,safari:/webkit/.test(a)?b:0,opera:/opera/.test(a)?b:0,msie:/msie/.test(a)&&!/opera/.test(a)?b:0,mozilla:/mozilla/.test(a)&&!/(compatible|webkit)/.test(a)?b:0,mobileSafari:/apple.*mobile.*safari/.test(a)?b:0,windows:!!/(windows)/.test(a),mac:!!(/(macintosh)/.test(a)||/(mac os x)/.test(a)),language:(navigator.language||navigator.browserLanguage).split("-",1)[0]};a.current=
a.msie?"msie":a.mozilla?"mozilla":a.safari?"safari":a.opera?"opera":"unknown";return a}();SC.bundleDidLoad=function(a){var b=this.BUNDLE_INFO[a];b||(b=this.BUNDLE_INFO[a]={});b.loaded=true};SC.bundleIsLoaded=function(a){return(a=this.BUNDLE_INFO[a])?!!a.loaded:false};SC.loadBundle=function(){throw"SC.loadBundle(): SproutCore is not loaded.";};
SC.setupBodyClassNames=function(){var a=document.body;if(a){var b,c,e,g,d;b=SC.browser.current;c=SC.browser.windows?"windows":SC.browser.mac?"mac":"other-platform";g=document.documentElement.style;e=g.MozBoxShadow!==undefined||g.webkitBoxShadow!==undefined||g.oBoxShadow!==undefined||g.boxShadow!==undefined;g=g.MozBorderRadius!==undefined||g.webkitBorderRadius!==undefined||g.oBorderRadius!==undefined||g.borderRadius!==undefined;d=a.className?a.className.split(" "):[];e&&d.push("box-shadow");g&&d.push("border-rad");
d.push(b);d.push(c);SC.browser.mobileSafari&&d.push("mobile-safari");a.className=d.join(" ")}};
if("undefined"===typeof tiki)var tiki=function(){function a(d,f){b.push({m:d,a:f})}var b=[],c={},e={},g={_modules:e,_factories:c,isBootstrap:true,queue:b,register:function(){a("register",arguments);return this},script:function(){a("script",arguments);return this},stylesheet:function(){a("stylesheet",arguments);return this},module:function(d,f){c[d]=f;a("module",arguments);return this},require:function(d){var f,h,i;f=e[d];if(!f){f=e[d]={};i={id:d};h=c[d];if(typeof h!=="function")throw d+" is not function";
h.call(f,g.require,f,i)}return f},destroy:function(){if(this.isDestroyed)return this;this.isDestroyed=true;e=c=b=this.queue=null;return this}};return g}();tiki.register("tiki",{scripts:[{url:"/static/tiki/en/1fd621c214115da84f497cbcf3691b42074a4261/javascript.js",id:"tiki:en/1fd621c214115da84f497cbcf3691b42074a4261/javascript.js"}]});
tiki.module("tiki:core",function(a,b){var c=[];b.setupDisplayNames=function(e,g){c[0]=g;var d;for(d in e)if(e.hasOwnProperty(d)){g=e[d];if("function"===typeof g){c[1]=d;g.displayName=c.join(".")}}c.length=0;return e}});
tiki.module("tiki:lib/loader",function(a,b){function c(n,r){k[0]=n;k[1]=r;return k.join("::")}function e(n){var r=o[n];if(r)return r;return o[n]="tiki/"+n}var g=a("tiki:core"),d=a("tiki:lib/promise"),f=a("tiki:lib/sandbox"),h,i=["(function(require, exports, module) {",null,"\n});\n//@ sourceURL=",null,"\n"],j={},k=[],l=Object.keys;l||(l=function(n){var r,p=[];for(r in n)n.hasOwnProperty(r)&&p.push(r);return p});var o={};h=function(n,r,p){this.id=n;this.scripts=[];this.packages=[];this.stylesheets=
[];this.modules=[];this.sandbox=f.create(n,this,p);this.register("default",{});this.register("tiki",{});n=r?r.length:0;var m;for(p=0;p<n;p++){m=r[p];this[m.m].apply(this,m.a)}this._queue=r;return this};h.prototype={scripts:null,stylesheets:null,packages:null,sandbox:null,modules:null,logLoadFailures:false,destroy:function(){},resolve:function(n,r){var p,m,q,s,t,u;if(n.match(/(^\.\.?\/)|(\/\.\.?\/)|(\/\.\.?\/?$)/)){if((q=n.indexOf(":"))>=0){s=n.slice(0,q);n=n.slice(q+1);p=[]}else if(n.match(/^\.\.?\//)){if(!r)throw"base required to resolve relative: "+
n;q=r.indexOf(":");s=r.slice(0,q);r=r.slice(q+1);p=r.split("/");p.pop()}else p=[];u=n.split("/");m=u.length;for(q=0;q<m;q++){t=u[q];if(t===".."){if(p.length<1)throw"invalid path: "+n;p.pop()}else t!=="."&&p.push(t)}n=p.join("/");if(s)n=s+":"+n}if(n.indexOf(":")<0)if(r&&(q=r.indexOf(":"))>0){s=r.slice(0,q);n=s+":"+n}return n},canonical:function(n,r){r=this.resolve(n,r);var p=this._factories,m=this._catalog,q;if((q=n.indexOf(":"))<0){if(!m||p&&p[r])return r;if(m[n])return n+":index";else if(m[e(n)])return e(n)+
":index"}else{p=n.slice(0,q);if(m&&!m[p]&&m[e(p)])r=e(n)}return r},evaluate:function(n,r){i[1]=n;i[3]=r||"(unknown module)";n=i.join("");n=eval(n);i[1]=i[3]=null;return n},load:function(n,r){var p=this._factories;n=this.canonical(n,r);if(!this.ready(n))throw n+" is not ready";if((r=p[n])&&"string"===typeof r){r=this.evaluate(r,n);p[n]=r}return r},global:function(n){var r,p,m,q,s,t;n=this.canonical(n);if((m=n.indexOf(":"))<0)throw"package not found: "+n;s=n.slice(0,m);n.split(":");r=this._catalog[s];
if(!r)throw s+" is not registered";p=(r=r.depends)?r.length:0;if(p<=0)return this;q=this._factories;if(!q)return this;for(m=0;m<p;m++){s=r[m];if(!j[s]){j[s]=true;if(!this.ready(s))throw"cannot make "+s+" global because it is not ready";n=this.canonical(s);if(q[n]){s=this.require(n);for(t in s)if(s.hasOwnProperty(t))window[t]=s[t]}}}},register:function(n,r){if(n.indexOf(":")>0)return this.module(n,r);var p=this._catalog,m;if(!p)p=this._catalog={};if(r=(p[n]=r)?r.packages:null)for(m in r)!r.hasOwnProperty(m)||
p[m]||(p[m]=r[m]);this._resolved("catalog",n)||this.packages.push(n);this._promiseFor("catalog",n).resolve(n)},script:function(n){this._resolved("scripts",n)||this.scripts.push(n);this._promiseFor("scripts",n).resolve(n);return this},stylesheet:function(n){this._resolved("stylesheets",n)||this.stylesheets.push(n);this._promiseFor("stylesheets",n).resolve(n);return this},module:function(n,r){var p=this._factories;if(!p)p=this._factories={};p[n]=r;this._resolved("modules",n)||this.modules.push(n);this._promiseFor("modules",
n).resolve(n)},async:function(n){return this._async(n,null)},_async:function(n,r){var p=this._promiseFor("loads",n);if(p.status===d.PENDING)if(this.ready(n))p.resolve();else{var m=this;p.action(function(q){m._promiseFor("catalog",n).then(q,function(){m._loadPackage(n,q,r||{});q.resolve()},function(s){q.cancel(s)});m._loadPackage(n,q,r||{})}).run()}return p},require:function(n,r){return this.sandbox.require(n,r)},ready:function(n){return this._ready(n,null)},_ready:function(n,r){if(r)if(r[n])return true;
else r[n]=true;var p,m,q,s;p=n.indexOf(":");p=p>=0?n.slice(0,p):n;if(!this._resolved("catalog",p)){this.logLoadFailures&&console.log(n+" is not ready: '"+p+"' is not loaded");return false}m=this._catalog[p];for(s=(q=m.depends)?q.length:0;--s>=0;){r||(r={});if(!this._ready(q[s],r)){this.logLoadFailures&&console.log(n+" is not ready: dependency '"+q[s]+"' is not ready");return false}}for(s=(q=m.stylesheets)?q.length:0;--s>=0;){r=q[s];if("string"!==typeof r)r=r.id;if(!this._resolved("stylesheets",r)){this.logLoadFailures&&
console.log(n+" is not ready: stylesheet '"+r+"' is unresolved");return false}}for(s=(q=m.scripts)?q.length:0;--s>=0;){r=q[s];if("string"!==typeof r)r=r.id;if(!this._resolved("scripts",r)){this.logLoadFailures&&console.log(n+" is not ready: script '"+r+"' is unresolved");return false}}if(n!==p)if(!this._resolved("modules",n)){this.logLoadFailures&&console.log(n+" is not ready: module is unresolved");return false}return true},main:function(n,r){var p=this.require("system").ready;if(!p)throw"cannot register main because system.ready does not exist";
p.main(this,function(){this.async(n).then(this,function(){this.require(n)[r]()})});return this},_loadScript:function(n){var r,p;if("string"!==typeof n){r=n.id;p=n.url}else r=p=n;n=this._promiseFor("scripts",r);n.status===d.PENDING&&n.action(function(){var m=document.body,q;m||d.cancel("no document to append script");q=document.createElement("script");q.setAttribute("src",p);m.appendChild(q)});return n},_loadStylesheet:function(n){var r,p;if("string"!==typeof n){r=n.id;p=n.url}else r=p=n;n=this._promiseFor("stylesheets",
r);if(n.status===d.PENDING){var m=this;n.action(function(q){var s=document.body;s||q.cancel("no document to append stylesheet");q=document.createElement("link");q.setAttribute("rel","stylesheet");q.setAttribute("href",p);s.appendChild(q);m.stylesheet(r)})}return n},_loadPackage:function(n,r,p){if(p)if(p[n]){console.warn("detected cyclical reference to "+n+" seen="+l(p).join(", "));return}else p[n]=true;var m=this._catalog?this._catalog[n]:null,q,s,t,u;if(!m)return this;s=(q=m.depends)?q.length:0;
for(n=d.create(c("load-package",n));--s>=0;)n.depends(this._async(q[s],p));r.depends(n);n.resolve();s=(q=m.scripts)?q.length:0;u=null;for(t=m.ordered!==false;--s>=0;){p=this._loadScript(q[s]);r.depends(p);if(t)u&&p.then(u,u.run,u.cancel);else p.run();u=p}u&&t&&n.then(u,u.run,u.cancel);s=(q=m.stylesheets)?q.length:0;for(u=null;--s>=0;){p=this._loadStylesheet(q[s]);r.depends(p);u&&p.then(u,u.run,u.cancel);u=p}u&&n.then(u,u.run,u.cancel)},_promiseFor:function(n,r,p){var m=this._promises,q;if(!m)m=this._promises=
{};(q=m[n])||(q=m[n]={});if(p===undefined){m=q;p=r}else(m=q[r])||(m=q[r]={});(q=m[p])||(q=m[p]=d.create(c(n,r)));return q},_discoveredStylesheets:false,discoverStylesheets:function(){this._discoveredStylesheets=true;if("undefined"===typeof document)return this;for(var n=document.getElementsByTagName("link"),r=n?n.length:0,p;--r>=0;){p=n[r];if(!(!p||p.rel!=="stylesheet"))if(p=p.getAttribute("loadid")||p.getAttribute("LOADID")){this.stylesheet(p.toString());(p=p.href)&&this.stylesheet(p.toString())}}return this},
_resolved:function(n,r,p){n==="stylesheets"&&!this._discoveredStylesheets&&this.discoverStylesheets();var m=this._promises;if(m)m=m[n];if(m)m=m[r];if(m&&p)m=m[p];return m?m.status===d.RESOLVED:false},_inspectLoader:function(){var n=[],r,p;n.push("Loader<id="+this.id+">:");if(this.packages.length>0){n.push("  packages: "+this.packages.join(","));n.push("")}if(this.scripts.length>0){n.push("  scripts:");r=this.scripts.length;for(p=0;p<r;p++)n.push("    "+this.scripts[p]);n.push("")}if(this.stylesheets.length>
0){n.push("  stylesheets:");r=this.scripts.length;for(p=0;p<r;p++)n.push("    "+this.scripts[p]);n.push("")}if(this.modules.length>0){n.push("  modules: ");r=this.modules.length;for(p=0;p<r;p++)n.push("    "+this.modules[p]);n.push("")}return n.join("\n")},_inspectModule:function(n){var r=[],p=n.slice(0,n.indexOf(":")),m;if(this._catalog&&!this._catalog[p]){m="tiki/"+p;if(this._catalog[m]){p=m;n="tiki/"+n}}r.push(n+" ("+(this.ready(n)?"READY":"NOT READY")+"):");r.push(this._inspectPackage(p));return r.join("\n")},
_inspectPackage:function(n){if(this._catalog&&!this._catalog[n]){var r="tiki/"+n;if(this._catalog[r])n=r}r=[];var p=this._catalog?this._catalog[n]:null,m,q,s;r.push(n+" ("+(this.ready(n)?"READY":"NOT READY")+"): "+(p?"":"Not in Catalog!"));if(!p)return r.join("\n");m=p.depends?p.depends.length:0;if(m>0){s=[];for(n=0;n<m;n++){q=p.depends[n];s.push(q+" ("+(this.ready(q)?"READY":"NOT READY")+")")}r.push("  depends: "+s.join(", "))}m=p.scripts?p.scripts.length:0;if(m>0){r.push("\n  scripts:");for(n=0;n<
m;n++){q=p.scripts[n];if("string"!==typeof q)q=q.id;r.push("    "+q+" ("+(this._resolved("scripts",q)?"READY":"NOT READY")+")")}}m=p.stylesheets?p.stylesheets.length:0;if(m>0){r.push("\n  stylesheets:");for(n=0;n<m;n++){q=p.stylesheets[n];if("string"!==typeof q)q=q.id;r.push("    "+q+"("+(this._resolved("stylesheets",q)?"READY":"NOT READY")+")")}}return r.join("\n")},inspect:function(n){return arguments.length===0?this._inspectLoader():n.indexOf(":")<0?this._inspectPackage(n):this._inspectModule(n)},
toString:function(){return"Loader<id="+this.id+">"}};g.setupDisplayNames(h.prototype,"Loader");b.Loader=h;b.create=function(n){return new h(n)};b.setup=function(n,r){if(n&&!n.isBootstrap)return n;r||(r={});if(!r.global&&"undefined"!==typeof window)r.global=window;if(!r.document&&"undefined"!==typeof document)r.document=document;r=new h(n?n.id:"default",n?n.queue:null,r);n&&n.destroy&&n.destroy();return r}});
tiki.module("tiki:lib/promise",function(a,b){a=a("tiki:core");var c;c=function(e){this.id=e;return this};c.prototype={status:"pending",outstandingDependencies:0,hasAction:false,resolve:function(e){var g=this.status;if(g==="resolved"||g==="cancelled")return this;this._value=e;if(this.outstandingDependencies>0)this.status="blocked";else{this.status="resolved";this.value=e;this._notify("resolved",e)}return this},cancel:function(e){var g=this.status;if(g==="resolved"||g==="cancelled")return this;this.status=
"cancelled";this.value=e;this._notify("cancelled",e);return this},then:function(e,g,d){if(arguments.length<3&&"function"===typeof e){d=g;g=e;e=this}g&&this._register("resolved",e,g);d&&this._register("cancelled",e,d);return this},run:function(){if(this.method&&this.status==="pending"){this.status="busy";this.method.call(this.target||this,this)}return this},reset:function(){var e=this.status;if(e!=="busy"||e!=="blocked")this.status="pending";this.value=null;return this},action:function(e,g){if(arguments.length===
1){g=e;e=this}this.target=e;this.method=g;this.hasAction=true;return this},depends:function(e){this.outstandingDependencies++;e.then(this,this._resolveDepends,this._cancelDepends);return this},_resolveDepends:function(){this.outstandingDependencies--;this.outstandingDependencies<=0&&this.status==="blocked"&&this.resolve(this.value);return this},_cancelDepends:function(e){this.cancel(e);return this},_notify:function(e,g){var d=this._actions,f;e=(d=d?d[e]:null)?d.length:0;this._actions=null;for(f=0;f<
e;f++)this._invoke(d[f].target,d[f].method,g)},_invoke:function(e,g,d){if("string"===typeof g&&e)g=e[g];e||(e=this);g.call(e,d,this)},_register:function(e,g,d){var f=this.status,h;if(f==="resolved"||f==="cancelled")f===e&&this._invoke(g,d,this.value);else{f=this._actions;if(!f)f=this._actions={};(h=f[e])||(h=f[e]=[]);h.push({target:g,method:d})}},toString:function(){return"Promise<id="+this.id+" status="+this.status+">"}};a.setupDisplayNames(c.prototype,"Promise");b.Promise=c;b.create=function(e){return new c(e)};
b.RESOLVED="resolved";b.PENDING="pending";b.CANCELLED="cancelled";b.BUSY="busy";b.BLOCKED="blocked"});
tiki.module("tiki:lib/sandbox",function(a,b){var c;c=function(e,g,d){function f(k,l,o){var n;if(l){n=k.indexOf(":");if(n>=0)k=k.slice(0,n);k=l+":"+k}k=g.canonical(k,o);if(exp=h[k])return exp;i.push(k);h[k]=o={};l=function(p,m){return f(p,m,k)};l.displayName="Sandbox.require";l.loader=g;l.clear=j;l.env=d||{};l.sandbox=this;n={id:k};var r=g.load(k);if(!r)throw"could not load function for "+k;r.call(o,l,o,n);return o}var h={},i=[];this.id=e;this.modules=i;this.loader=g;var j=this.clear=function(){var k=
arguments.length,l;if(k>0)for(;--k>=0;){if((l=arguments[k])&&h[l]){delete h[l];i.splice(i.indexOf(l),1)}}else{h={};i.length=0}};j.displayName="Sandbox.clear";this.require=function(k,l){return f(k,l)};this.require.displayName="Sandbox.require"};c.prototype={};b.Sandbox=c;b.create=function(e,g,d){return new c(e,g,d)}});
tiki.module("tiki:index",function(a,b){var c;c=a("tiki:core");b.setupDisplayNames=c.setupDisplayNames;c=a("tiki:lib/loader");b.Loader=c.Loader;c=a("tiki:lib/promise");b.Promise=c.Promise;c=a("tiki:lib/sandbox");b.Sandbox=c.Sandbox});tiki=tiki.require("tiki:lib/loader").setup(tiki,"undefined"===typeof ENV?null:ENV);tiki.script("tiki:en/1fd621c214115da84f497cbcf3691b42074a4261/javascript.js");tiki.stylesheet("sproutcore/foundation:en/d5356c4dc5eed765f3239fcaaa4b599b3de5c4b0/stylesheet.css");tiki.stylesheet("sproutcore/testing:en/1e0d6dc675d3d9adb05a01b524dd7fc8fb2ad475/stylesheet.css");
tiki.stylesheet("sproutcore/designer:en/3080eb96d6f0ac8d0e9236af215ac0647848d08b/stylesheet.css");tiki.stylesheet("sproutcore/desktop:en/57a37cf8f2abf4dfdcfdbc5bcf79f41605b5ca83/stylesheet.css");tiki.stylesheet("sproutcore/standard_theme:en/4448cf3c8117a1e50376695dc8ea12138b0f9099/stylesheet.css");
tiki.register("tiki/platform/classic",{packages:{tiki:{scripts:[{url:"/static/tiki/en/1fd621c214115da84f497cbcf3691b42074a4261/javascript.js",id:"tiki:en/1fd621c214115da84f497cbcf3691b42074a4261/javascript.js"}]}},depends:["tiki"],scripts:[{url:"/static/tiki/platform/classic/en/ded01fe6fcc484028c695eebd4c5274b4f895508/javascript.js",id:"tiki/platform/classic:en/ded01fe6fcc484028c695eebd4c5274b4f895508/javascript.js"}]});
tiki.module("tiki/platform/classic:lib/console",function(a,b){a=a.env;b.console=a&&a.global?a.global.console:null});tiki.module("tiki/platform/classic:lib/event","var info = require('tiki/platform/classic:lib/info');var add,remove,event,ready,unload,NATIVE_EVENTS;// ==========================================================================\n// Project:   Tiki\n// Copyright: \u00a92006-2009 Sprout Systems, Inc. and contributors.\n//            Portions \u00a92008-2009 Apple Inc. All rights reserved.\n// License:   Licened under MIT license (see license.js)\n// ==========================================================================\n/*globals event exports add remove ready unload info NATIVE_EVENTS */\n\n\"import lib/info as info\";\n\"export add remove\";\n\"export package event ready unload NATIVE_EVENTS\";\n\n/**\n  @file\n  \n  Implements a low-level interface for registering interest in native events\n  delivered by the web browser.  If you are implementing this API for a non-\n  browser environment, add() and remove() may do nothing.\n  \n  ready() and unload() should still invoke the passed callback when the \n  JS environment is ready for the app to run and just before the app exits,\n  respectively.\n\n  ready() and unload() should both expect to be called exactly once (by the\n  system event module).  They may throw an error if called more than once.\n*/\n\n\nvar readyCalled  = false, \n    unloadCalled = false,\n    browser      = info.browser,\n    isReady      = false,\n    isUnloaded   = false,\n    ecache       = {};\n    \n\n// returns a handler function for the onready event depending on the browser.    \nfunction readyHandler(callback) {\n  var ret ;\n  \n  // opera - wait until all the stylesheets are made visible\n  if (browser.opera) {\n    ret = function() {\n      if (isReady) return;\n      \n      for (var i = 0; i < document.styleSheets.length; i++) {\n        if (document.styleSheets[i].disabled) {\n          setTimeout(ret, 0);\n          return;\n        }\n      }\n      \n      // and execute any waiting functions\n      isReady = true;\n      callback();\n    };\n    \n  // msie - wait until the doScroll event stops complaining..\n  } else if (browser.msie) {\n    ret = function() {\n      if (isReady) return;\n      try {\n        // If IE is used, use the trick by Diego Perini\n        // http://javascript.nwbox.com/IEContentLoaded/\n        document.documentElement.doScroll(\"left\");\n      } catch( error ) {\n        setTimeout(ret, 0);\n        return;\n      }\n\n      // and execute any waiting functions\n      isReady = true;\n      callback();\n    };\n    \n  // everyone else - just call\n  } else {\n    ret = function() {\n      console.log('ready!');\n      if (isReady) return ;\n      isReady = true;\n      callback();\n    };\n  }\n  \n  return ret ;\n  \n}\n\n/** \n  Invoke the  callback when the browser is ready to handle app code. \n  Throws an exception if it is called more than once.  Uses a built-in \n  listener.\n  \n  @param {Function} callback\n  @returns {void}\n*/\nready = function(callback) {\n  if (readyCalled) throw(\"Cannot call platform.ready() more than once\");\n  readyCalled = true;\n  \n  var handler = readyHandler(callback);\n  \n  // Mozilla, Opera (see further below for it) and webkit nightlies \n  // currently support this event.  Use the handy event callback\n  if (document.addEventListener) {\n    document.addEventListener( \"DOMContentLoaded\", handler, NO );\n  \n  // If IE is used and is not in a frame\n  // Continually check to see if the document is ready\n  } else if (browser.msie && (window === top)) handler();\n\n  // A fallback to window.onload, that will always work\n  add(window, 'load', handler);\n};\n\n\nfunction unloadHandler(callback) {\n  return function() {\n    if (isUnloaded) return ;\n    isUnloaded = true;\n    callback();\n  }; \n}\n\n/**\n  Invoke the callback just before the browser unloads the page.  Throws an \n  error if called more than once.\n  \n  @param {Function} callback\n  @returns {void}\n*/\nunload = function(callback) {\n  if (unloadCalled) throw(\"Cannot call platform.unload() more than once\");\n  unloadCalled = true;\n  add(window, 'unload', unloadHandler(callback));\n};\n\n// ..........................................................\n// EVENT LISTENERS\n// \n\n/**\n  Names of event types natively supported by this library.  Platforms without\n  native event support can return an empty hash.\n*/\nNATIVE_EVENTS = {};\n\n// TODO: make this correct per-browser\n// TODO: add touch events\nvar names = 'mousedown mouseup click dblclick mouseover mouseout selectstart keypress keydown keyup blur focus deactivate change select submit contextmenu dragstart error hashchange help load losecapture readystatechange resize scroll unload'.split(' '), loc = names.length;\nwhile(--loc>=0) NATIVE_EVENTS[names[loc]] = names[loc];\n\n\n// convert 'foo' => 'onfoo' using cache to avoid malloc\nfunction onStr(str) {\n    var ret = ecache[str];\n    if (!ret) ret = ecache[str] = ('on' + str); // avoid mallocs\n    return ret ;\n}\n\n/**\n  Adds a listener for the event.  No need to do any special buffering; just\n  add the listener in a platform-specific way.\n  \n  @param {Object} elem the target element if any.  otherwise use document\n  @param {String} eventType click, mousedown, etc\n  @param {Function} callback function to invoke\n  @returns {void}\n*/\nadd = function(elem, eventType, callback) {\n  if (!NATIVE_EVENTS[eventType]) return ; // ignore for native events\n  if (!elem) elem = require.env.document;\n  if (elem.addEventListener) elem.addEventListener(eventType, callback, NO);\n  else if (elem.attachEvent) elem.attachEvent(onStr(eventType), callback);      \n  else throw(\"cannot add listener to element: \" + elem);\n};\n\n/**\n  Removes a listener for the event.  No need to do any special buffering; just\n  remove the listener in a platform-specific way\n  \n  @param {Object} elem the target element if any. otherwise use document\n  @param {String} eventType click, mousedown, etc\n  @param {Function} func function to invoke\n  @returns {void}\n*/\nremove = function(elem, eventType, func) {\n  if (!NATIVE_EVENTS[eventType]) return ;\n  if (!elem) elem = require.env.document;\n  if (elem.removeEventListener) elem.removeEventListener(eventType, func, NO);\n  else if (elem.detachEvent) elem.detachEvent(onStr(eventType), func);\n  else throw(\"cannot remove listener from element: \" + elem);\n};\n\n// make this API visible as the events property on package\nevent = exports;\n;exports.add = add;\nexports.remove = remove;\nexports.event = event;\nexports.ready = ready;\nexports.unload = unload;\nexports.NATIVE_EVENTS = NATIVE_EVENTS;\n");
tiki.module("tiki/platform/classic:lib/info","var browser,userAgent,info;// ==========================================================================\n// Project:   Tiki\n// Copyright: \u00a92009 Apple Inc.\n// ==========================================================================\n/*globals browser userAgent info exports */\n\n\"export browser userAgent\";\n\"export package info\";\n\n/**\n  @file\n\n  Export constants in this module that describe the capabilities of the target\n  platform.  The most important property you can define here is HTML\n*/\n\n\n// ..........................................................\n// BROWSER DESCRIPTION\n// \n\nuserAgent = navigator.userAgent.toLowerCase();\n\nvar version = (userAgent.match( /.+(?:rv|it|ra|ie)[\\/: ]([\\d.]+)/ ) || [])[1];\n\nbrowser = {\n  \n  /** The current browser version */\n  version: version,\n  \n  /** non-zero if webkit-based browser */\n  safari: (/webkit/).test( userAgent ) ? version : 0,\n  \n  /** non-zero if this is an opera-based browser */\n  opera: (/opera/).test( userAgent ) ? version : 0,\n  \n  /** non-zero if this is IE */\n  msie: (/msie/).test( userAgent ) && !(/opera/).test( userAgent ) ? version : 0,\n  \n  /** non-zero if this is a miozilla based browser */\n  mozilla: (/mozilla/).test( userAgent ) && !(/(compatible|webkit)/).test( userAgent ) ? version : 0,\n  \n  /** non-zero if this is mobile safari */\n  mobileSafari: (/apple.*mobile.*safari/).test(userAgent) ? version : 0,\n  \n  /** non-zero if we are on windows */\n  windows: !!(/(windows)/).test(userAgent),\n  \n  /** non-zero if we are on a mac */\n  mac: !!((/(macintosh)/).test(userAgent) || (/(mac os x)/).test(userAgent)),\n  \n  language: (navigator.language || navigator.browserLanguage).split('-', 1)[0]\n};\n\nbrowser.isOpera = !!browser.opera;\nbrowser.isIe = browser.msie;\nbrowser.isIE = browser.msie;\nbrowser.isSafari = browser.safari;\nbrowser.isMobileSafari = browser.mobileSafari;\nbrowser.isMozilla = browser.mozilla;\nbrowser.isWindows = browser.windows;\nbrowser.isMac = browser.mac;\n\n/**\n  The current browser name.  This is useful for switch statements. \n*/\nbrowser.current = \n  browser.msie ? 'msie' : \n  browser.mozilla ? 'mozilla' : \n  browser.safari ? 'safari' : \n  browser.opera ? 'opera' : 'unknown' ;\n\n\n// make this module visible as \"info\"\ninfo = exports ;\n;exports.browser = browser;\nexports.userAgent = userAgent;\nexports.info = info;\n");
tiki.module("tiki/platform/classic:lib/timer",function(a,b){b.schedule=function(c,e,g){var d;d=setTimeout(g?function(){e.call(g,d)}:e,c);e=null;return d};b.repeat=function(c,e,g){var d;d=setInterval(g?function(){e.call(g,d)}:e,c);e=null;return d};b.cancel=function(c,e){if(e===undefined){clearTimeout(c);clearInterval(c)}else e?clearInterval(c):clearTimeout(c)};b.timer=b});
tiki.module("tiki/platform/classic:index",function(a,b){var c;c=a("tiki/platform/classic:lib/console");b.console=c.console;c=a("tiki/platform/classic:lib/event");b.event=c.event;b.ready=c.ready;b.unload=c.unload;b.NATIVE_EVENTS=c.NATIVE_EVENTS;c=a("tiki/platform/classic:lib/info");b.info=c.info;c=a("tiki/platform/classic:lib/timer");b.timer=c.timer});tiki.script("tiki/platform/classic:en/ded01fe6fcc484028c695eebd4c5274b4f895508/javascript.js");
tiki.register("tiki/platform",{scripts:[{url:"/static/tiki/platform/en/da39a3ee5e6b4b0d3255bfef95601890afd80709/javascript.js",id:"tiki/platform:en/da39a3ee5e6b4b0d3255bfef95601890afd80709/javascript.js"}]});tiki.global("tiki/platform");tiki.script("tiki/platform:en/da39a3ee5e6b4b0d3255bfef95601890afd80709/javascript.js");
tiki.register("tiki/system",{packages:{"tiki/platform/classic":{scripts:[{url:"/static/tiki/platform/classic/en/ded01fe6fcc484028c695eebd4c5274b4f895508/javascript.js",id:"tiki/platform/classic:en/ded01fe6fcc484028c695eebd4c5274b4f895508/javascript.js"}]},tiki:{scripts:[{url:"/static/tiki/en/1fd621c214115da84f497cbcf3691b42074a4261/javascript.js",id:"tiki:en/1fd621c214115da84f497cbcf3691b42074a4261/javascript.js"}]}},depends:["tiki","tiki/platform/classic"],scripts:[{url:"/static/tiki/system/en/d957ea8a3f571914826aca7f16e15f122ab3ce87/javascript.js",
id:"tiki/system:en/d957ea8a3f571914826aca7f16e15f122ab3ce87/javascript.js"}]});tiki.module("tiki/system:core","var T_ERROR,T_OBJECT,T_NULL,T_CLASS,T_HASH,T_FUNCTION,T_UNDEFINED,T_NUMBER,T_BOOL,T_ARRAY,T_STRING,T_BOOLEAN,YES,NO,isArray,typeOf,A,generateGuid,guidFor,mixin,setupDisplayNames;// ==========================================================================\n// Project:   SproutCore System Package\n// Copyright: \u00a92009 Apple Inc.\n// ==========================================================================\n/*globals T_ERROR T_OBJECT T_NULL T_CLASS T_HASH T_FUNCTION T_NUMBER T_BOOL T_ARRAY T_UNDEFINED T_STRING YES NO isArray typeOf A generateGuid guidFor */\n\n\"export T_ERROR T_OBJECT T_NULL T_CLASS T_HASH T_FUNCTION T_UNDEFINED T_NUMBER T_BOOL T_ARRAY T_STRING T_BOOLEAN\";\n\"export YES NO isArray typeOf A generateGuid guidFor mixin setupDisplayNames\";\n\n// define standard type constants\nT_ERROR     = 'error';\nT_OBJECT    = 'object';\nT_NULL      = 'null';\nT_CLASS     = 'class';\nT_HASH      = 'hash';\nT_FUNCTION  = 'function';\nT_UNDEFINED = 'undefined';\nT_NUMBER    = 'number';\nT_BOOL      = 'boolean';\nT_ARRAY     = 'array';\nT_STRING    = 'string';\nT_BOOLEAN   = 'boolean';\n\nYES         = true;\nNO          = false; \n\n/**\n  Returns true if the passed item is an array.  Works regardless of source\n  of array.\n*/\nisArray = function(obj) {\n  if (obj && obj.isArray) return true; // fast path\n  if (!obj) return false;\n  if (T_UNDEFINED !== typeof obj.length) {\n    if ((typeof obj !== T_FUNCTION) && (typeof obj !== T_STRING) && (obj.constructor !== String)) return true;\n  }\n  // TODO: add proper check that works across windows...\n  return false ;  \n};\n\nArray.prototype.isArray = true ;\n  \n/**\n  Returns a consistant type for the passed item.\n\n  Use this instead of the built-in typeOf() to get the type of an item. \n  It will return the same result across all browsers and includes a bit \n  more detail.  Here is what will be returned:\n\n  | Return Value Constant | Meaning |\n  | SC.T_STRING | String primitive |\n  | SC.T_NUMBER | Number primitive |\n  | SC.T_BOOLEAN | Boolean primitive |\n  | SC.T_NULL | Null value |\n  | SC.T_UNDEFINED | Undefined value |\n  | SC.T_FUNCTION | A function |\n  | SC.T_ARRAY | An instance of Array |\n  | SC.T_CLASS | A SproutCore class (created using SC.Object.extend()) |\n  | SC.T_OBJECT | A SproutCore object instance |\n  | SC.T_HASH | A JavaScript object not inheriting from SC.Object |\n\n  @param item {Object} the item to check\n  @returns {String} the type\n*/  \ntypeOf = function typeOf(item) {\n  if (item === undefined) return T_UNDEFINED ;\n  if (item === null) return T_NULL ; \n  \n  var ret = typeof(item) ;\n  if (ret == \"object\") {\n    if (isArray(item)) ret = T_ARRAY ;\n    else if (item instanceof Function) {\n      ret = item.isClass ? T_CLASS : T_FUNCTION ;\n    } else if ((item instanceof Error) || item.isError) ret = T_ERROR;\n    else if (item.isObject) ret = T_OBJECT ;\n    else if (item.isClass) ret = T_CLASS;\n    else if (item.constructor === Object) ret = T_HASH;\n    else if (item.constructor === Number) ret = T_NUMBER;\n    else if (item.constructor === String) ret = T_STRING;\n    else ret = T_OBJECT;\n\n  } else if (ret === T_FUNCTION) ret = item.isClass ? T_CLASS : T_FUNCTION;\n  \n  return ret ;\n};\n  \n/**\n  Converts the passed object to an Array.  If the object appears to be \n  array-like, a new array will be cloned from it.  Otherwise, a new array\n  will be created with the item itself as the only item in the array.\n  \n  @param object {Object} any enumerable or array-like object.\n  @returns {Array} Array of items\n*/\nA = function A(obj) {\n  // null or undefined -- fast path\n  if ((obj === null) || (obj === undefined)) return [] ;\n  \n  // primitive -- fast path\n  if (obj.slice instanceof Function) {\n    // do we have a string?\n    if (typeof(obj) === 'string') return [obj] ;\n    else return obj.slice() ;\n  }\n  \n  // enumerable -- fast path\n  if (obj.toArray) return obj.toArray() ;\n  \n  // if not array-like, then just wrap in array.\n  if (!isArray(obj)) return [obj];\n  \n  // when all else fails, do a manual convert...\n  var ret = [], len = obj.length;\n  while(--len >= 0) ret[len] = obj[len];\n  return ret ;\n};\n  \nvar guidKey = \"_sc_guid_\" + new Date().getTime();\nvar _nextGUID = 0, _numberGuids = [], _stringGuids = [];\n\n/**\n  Generates a new guid, optionally saving the guid to the object that you\n  pass in.  You will rarely need to use this method.  Instead you should\n  call SC.guidFor(obj), which return an existing guid if available.\n\n  @param {Object} obj the object to assign the guid to\n  @returns {String} the guid\n*/\ngenerateGuid = function generateGuid(obj) { \n  var ret = (\"sc\" + (_nextGUID++)); \n  if (obj) obj[guidKey] = ret ;\n  return ret ;\n};\n\n/**\n  Returns a unique GUID for the object.  If the object does not yet have\n  a guid, one will be assigned to it.  You can call this on any object,\n  SC.Object-based or not, but be aware that it will add a _guid property.\n\n  You can also use this method on DOM Element objects.\n\n  @param obj {Object} any object, string, number, Element, or primitive\n  @returns {String} the unique guid for this instance.\n*/\nguidFor = function guidFor(obj) {\n  \n  // special cases where we don't want to add a key to object\n  if (obj === undefined) return \"(undefined)\" ;\n  if (obj === null) return '(null)' ;\n  if (obj === Object) return '(Object)';\n  if (obj === Array) return '(Array)';\n  \n  if (obj[guidKey]) return obj[guidKey] ;\n\n  switch(typeof obj) {\n    case T_NUMBER:\n      return (_numberGuids[obj] = _numberGuids[obj] || (\"nu\" + obj));\n    case T_STRING:\n      return (_stringGuids[obj] = _stringGuids[obj] || (\"st\" + obj));\n    case T_BOOL:\n      return obj ? \"(true)\" : \"(false)\" ;\n    default:\n      return generateGuid(obj);\n  }\n};\n\n/**\n  Mixin the passed properties onto the first parameter.  This is a convenient\n  way to add properties to an object.\n  \n  @param {Hash} t the target object to mixin to\n  @param {Hash..} one or more hashes to mix in\n  @returns {Hash} the first parameter\n*/\nmixin = function mixin(t) {\n  \n  // copy reference to target object\n  var len    = arguments.length,\n      target = arguments[0] || {},\n      idx, options, key, src, copy;\n\n  for (idx=1; idx < len; idx++ ) {\n    if (!(options = arguments[idx])) continue ;\n    for(key in options) {\n      if (!options.hasOwnProperty(key)) continue ;\n\n      src  = target[key];\n      copy = options[key] ;\n      if (target===copy) continue ; // prevent never-ending loop\n      if (copy !== undefined) target[key] = copy ;\n    }\n  }\n  \n  return target;\n};\n\nvar TMP_ARY = [];\n\n/**\n  Iterate over a property, setting display names on functions as needed. \n*/\nsetupDisplayNames = function setupDisplayNames(obj, root) {\n  var a = TMP_ARY;\n  a[0] = root;\n  \n  var k,v;\n  for(k in obj) {\n    if (!obj.hasOwnProperty(k)) continue ;\n    v = obj[k];\n    if ('function' === typeof v) {\n      a[1] = k;\n      v.displayName = a.join('.');\n    }\n  }\n  \n  a.length = 0;\n  return obj;\n};;exports.T_ERROR = T_ERROR;\nexports.T_OBJECT = T_OBJECT;\nexports.T_NULL = T_NULL;\nexports.T_CLASS = T_CLASS;\nexports.T_HASH = T_HASH;\nexports.T_FUNCTION = T_FUNCTION;\nexports.T_UNDEFINED = T_UNDEFINED;\nexports.T_NUMBER = T_NUMBER;\nexports.T_BOOL = T_BOOL;\nexports.T_ARRAY = T_ARRAY;\nexports.T_STRING = T_STRING;\nexports.T_BOOLEAN = T_BOOLEAN;\nexports.YES = YES;\nexports.NO = NO;\nexports.isArray = isArray;\nexports.typeOf = typeOf;\nexports.A = A;\nexports.generateGuid = generateGuid;\nexports.guidFor = guidFor;\nexports.mixin = mixin;\nexports.setupDisplayNames = setupDisplayNames;\n");
tiki.module("tiki/system:lib/event",'var $m__ = require(\'tiki/system:core\'), T_ERROR=$m__.T_ERROR,T_OBJECT=$m__.T_OBJECT,T_NULL=$m__.T_NULL,T_CLASS=$m__.T_CLASS,T_HASH=$m__.T_HASH,T_FUNCTION=$m__.T_FUNCTION,T_UNDEFINED=$m__.T_UNDEFINED,T_NUMBER=$m__.T_NUMBER,T_BOOL=$m__.T_BOOL,T_ARRAY=$m__.T_ARRAY,T_STRING=$m__.T_STRING,T_BOOLEAN=$m__.T_BOOLEAN,YES=$m__.YES,NO=$m__.NO,isArray=$m__.isArray,typeOf=$m__.typeOf,A=$m__.A,generateGuid=$m__.generateGuid,guidFor=$m__.guidFor,mixin=$m__.mixin,setupDisplayNames=$m__.setupDisplayNames;var $m__ = require(\'tiki/system:lib/invocation\'), Invocation=$m__.Invocation;var $m__ = require(\'tiki/system:lib/platform\'), PLATFORM=$m__.PLATFORM,PLATFORM_PACKAGE=$m__.PLATFORM_PACKAGE,info=$m__.info,env=$m__.env;var ready,unload;// ==========================================================================\n// Project:   Tiki\n// Copyright: \u00a92009 Apple Inc.\n// ==========================================================================\n/*globals ready unload Invocation */\n\n"import core";\n"import lib/invocation";\n"import lib/platform";\n"export package ready unload";\n\nvar platform = require(PLATFORM_PACKAGE);\n\n// ..........................................................\n// READY HANDLER\n// \n\n// called when the document becomes ready.  work through the queue...\nfunction _ready() {\n  var queue = ready.queue, \n      mainQ = ready.mainQ,\n      len   = queue.length,\n      inv, idx;\n\n  ready.isReady = ready.scheduled = YES ;\n  ready.queue = []; // ok to alloc since it is usually only called once\n  ready.mainQ = [];\n  \n  for(idx=0;idx<len;idx++) {\n    inv = queue[idx];\n    inv.invoke();\n    inv.release(); // return to pool\n  }\n\n  // after calling ready handlers, invoke any main functions to start the app\n  len = mainQ.length;\n  for(idx=0;idx<len;idx++) {\n    inv = mainQ[idx];\n    inv.invoke();\n    inv.release(); // return to pool\n  }\n};\n\n/**\n  Call to register methods you want run when the system is ready for the app\n  to run.\n*/\nready = function(target, method, args) {\n  if (ready.isReady) {\n    Invocation.invoke(target, method, arguments, 2);\n    \n  } else {\n    if (!ready.scheduled && platform) platform.ready(_ready);\n    ready.scheduled = YES ;\n    ready.queue.push(Invocation.create(target, method, arguments, 2));\n  }\n  \n  return this ;\n};\n\nready.isReady = NO ;\nready.queue   = [] ;\nready.scheduled = NO ;\nready.mainQ   = [] ; // invocations for main. called after ready\n\nready.main = function(target, method, args) {\n  if (ready.isReady) {\n    Invocation.invoke(target, method, arguments, 2);\n    \n  } else {\n    if (!ready.scheduled && platform) platform.ready(_ready);\n    ready.scheduled = YES ;\n    ready.mainQ.push(Invocation.create(target, method, arguments, 2));\n  }\n  \n  return this ;\n};\n\n// ..........................................................\n// UNLOAD HANDLER\n// \n\nfunction _unload() {\n  var queue = unload.queue, \n      len   = queue.length,\n      inv, idx;\n\n  unload.isUnloaded = unload.scheduled = YES ;\n  unload.queue = [];\n  \n  for(idx=0;idx<len;idx++) {\n    inv = queue[idx];\n    inv.invoke();\n    inv.release(); // return to pool\n  }\n}\n\n/**\n  Call to register methods you want run when the system is about to unload.\n*/\nunload = function(target, method, args) {\n  if (unload.isUnloaded) {\n    Invocation.invoke(target, method, arguments, 2);\n    \n  } else {\n    if (!unload.scheduled && platform) platform.unload(_unload);\n    unload.scheduled = YES;\n    unload.queue.push(Invocation.create(target, method, arguments, 2));\n  }\n  \n  return this ;\n};\n\nunload.isUnloaded = NO;\nunload.queue      = [];\nunload.scheduled  = NO;\n;exports.ready = ready;\nexports.unload = unload;\n');
tiki.module("tiki/system:lib/global",'var global,reset;// ==========================================================================\n// Project:   Tiki\n// Copyright: \u00a92009 Apple Inc.\n// ==========================================================================\n\n"export package global";\n"export reset";\n\n// exports a global object representing the current global.  you can reset \n// the global by importing this module directly.\n\n// if you have env.global, use that\nreset = function() {\n  global = require.env.global || {} ;\n};\n\nreset();\n;exports.global = global;\nexports.reset = reset;\n');
tiki.module("tiki/system:lib/invocation",'var $m__ = require(\'tiki/system:core\'), T_ERROR=$m__.T_ERROR,T_OBJECT=$m__.T_OBJECT,T_NULL=$m__.T_NULL,T_CLASS=$m__.T_CLASS,T_HASH=$m__.T_HASH,T_FUNCTION=$m__.T_FUNCTION,T_UNDEFINED=$m__.T_UNDEFINED,T_NUMBER=$m__.T_NUMBER,T_BOOL=$m__.T_BOOL,T_ARRAY=$m__.T_ARRAY,T_STRING=$m__.T_STRING,T_BOOLEAN=$m__.T_BOOLEAN,YES=$m__.YES,NO=$m__.NO,isArray=$m__.isArray,typeOf=$m__.typeOf,A=$m__.A,generateGuid=$m__.generateGuid,guidFor=$m__.guidFor,mixin=$m__.mixin,setupDisplayNames=$m__.setupDisplayNames;var $m__ = require(\'tiki/system:mixins/retainable\'), Retainable=$m__.Retainable;var Invocation;// ==========================================================================\n// Project:   Tiki\n// Copyright: \u00a92009 Apple Inc.\n// ==========================================================================\n/*globals Invocation */\n\n"import core";\n"import mixins/retainable";\n"export package Invocation";\n\n/**\n  An Invocation captures a target, method and zero or more arguments to be \n  called at a later time.  Invocations are retainable so you can control when\n  they are destroyed.\n  \n  Note that if you pass a string to the method param, this string will not \n  be resolved to a function until you actually invoke it.  This means you can\n  potentially swap out the method between invocations.\n  \n  @since SproutCore 1.1\n*/\nInvocation = function Invocation(target, method, args) {\n  return this.init(target, method, args);\n};\n\nmixin(Invocation.prototype, Retainable, {\n  \n  constructor: Invocation,\n  \n  /**\n    Initializes the invocation.  This is called when you first create the \n    invocation.\n  */\n  init: function(target, method, args, ignore) {\n    if (args && (ignore !== undefined)) {\n      if (args.length>ignore) args = Array.prototype.slice.call(args, ignore);\n      else args = null; // nothing to curry\n    }\n    \n    this.inPool = NO; // for debug\n    this.target = target;\n    this.method = method;\n    this.args   = args;\n    return this ;\n  },\n  \n  /**\n    Destroys the invocation.  Called when the retain count hits zero.  This\n    will return the invocation to the pool.\n  */\n  destroy: function() {\n    // reset retainable\n    this.isDestroyed = NO;\n    this.retainCount = 1;\n    this.inPool      = YES;\n    this.target = this.method = this.args = null;\n    pool.push(this); // add back to pool\n    \n    return this ;\n  },\n  \n  /**\n    Invokes the method.  Any passed arguments will be curried onto existing\n    arguments.\n    \n    @returns {Object} return value of invoked method.\n  */\n  invoke: function() {\n    return Invocation.invoke(this.target, this.method, this.args, undefined, arguments);\n  }\n  \n});\n\nvar pool = [];\n\n/**\n  Creates a new invocation.  This method will use a memory pool if possible to\n  avoid allocing memory.\n  \n  @param {Object} target target to invoke\n  @param {Function|String} method function or name of method to invoke\n  @param {Array} args zero or more arguments.  optional\n  @param {Number} ignore if passed, ignores this many items from the args\n  @returns {Invocation} new instance\n*/\nInvocation.create = function(target, method, args, ignore) {\n  if (pool.length>0) return pool.pop().init(target,method,args,ignore);\n  else return new Invocation(target, method, args, ignore);\n};\n\n/**\n  Invokes the passed target, method, and arguments.  This is an optimized \n  version that may not actually create an invocation.\n*/\n/**\n  Invokes the invocation.  Return value of invocation is returned.  Any \n  additional arguments will be curried onto the end of any existing args.\n*/\nInvocation.invoke = function(target, method, args, ignore, extra) {\n\n  // normalize method\n  if (typeOf(method) === T_STRING) method = target[method];\n  if (!method) throw("Invocation: method " + this.method + " not defined");\n  \n  // normalize arguments - also curry any extra arguments\n  if ((ignore !== undefined) && args) {\n    if (args.length>ignore) args = Array.prototype.slice.call(args, ignore);\n    else args = null;\n  }\n  if (extra && extra.length>0) args = args ? args.concat(extra) : extra;\n  \n  // and finally invoke\n  return args ? method.apply(target, args) : method.call(target);\n};\n\n;exports.Invocation = Invocation;\n');
tiki.module("tiki/system:lib/logger","var core = require('tiki/system:core');var $m__ = require('tiki/system:lib/platform'), PLATFORM=$m__.PLATFORM,PLATFORM_PACKAGE=$m__.PLATFORM_PACKAGE,info=$m__.info,env=$m__.env;var Logger,console;// ==========================================================================\n// Project:   Tiki\n// Copyright: \u00a92009 Apple Inc.\n// ==========================================================================\n/*globals Logger console core */\n\n\"import core as core\";\n\"import lib/platform\";\n\"export package Logger console\";\n\n/** \n  @file\n\n  Module defines generic functions that can be used to log output into a \n  string or file.\n  \n  The Logger class defined in this module implements the generic Logger API,\n  which includes warn(), info(), error(), debug() and log().  \n  \n  The console object logs this to a system-provided console (on browsers this\n  is equivalent to the system-provided console).\n\n  @since Tiki 1.0\n*/\n\n// get the platform console\nvar pconsole = require(PLATFORM_PACKAGE).console;\n\n/**\n  Logger class defines a standard logger.  If you attach a console, then the\n  logger will record its own results AND forward any output to the console \n  itself.  \n  \n  A default logger is usually created and exported as \"console\" that will \n  attach to the platform console.  You can create a new logger if you want as \n  well.\n\n  @since Tiki 1.0\n*/\nLogger = function Logger(id, console) {\n  this.id = id ;\n  this.console = console;\n  return this ;\n};\n\nvar COLON = ': ', NEWLINE = \"\\n\", TILDA = ' ~ ';\n\nLogger.prototype = {\n  \n  /**\n    Emits count number of lines (or 100 lines if not specified) as a single\n    string.\n    \n    @property {Number} count number of lines to display. optional\n    @returns {String} logged output\n  */\n  tail: function(count) {\n    var lines = this._lines,\n        len   = lines ? lines.length : 0,\n        idx, ret;\n\n    if (len===0) return '';\n\n    if (count === undefined) count = 100;\n    ret = [];\n    for(idx = Math.max(0, len - count); idx < len; idx++) {\n      \n      if (this.id) {\n        ret.push(this.id);\n        ret.push(TILDA);\n      }\n      if (lines[idx].kind) {\n        ret.push(lines[idx].kind);\n        ret.push(COLON);\n      }\n      ret.push(lines[idx].message);\n      ret.push(NEWLINE);      \n    }\n    \n    return ret.join(\"\");\n  },\n  \n  /**\n    Clears the log contents\n    \n    @returns {Logger} reciever\n  */\n  clear: function() {\n    this._lines = null;\n    return this ;\n  },\n  \n  /**\n    Adds a line to the log.  Pass the log type and message.\n    \n    @param {String} kind kind of log message.  should be WARN, DBEUG, or null\n    @param {String} message message to log\n    @returns {Logger} reciever\n  */\n  push: function(kind, message) {\n    var lines = this._lines;\n    if (!lines) lines = this._lines = [];\n    lines.push({ kind: kind, message: message });\n  },\n  \n  /**\n    Logs a debug statement.\n    \n    @param {String} msg one or more items to log\n    @returns {void} \n  */\n  debug: function(msg) {\n    this.push('DEBUG', core.A(arguments));\n    \n    var console = this.console;\n    if (console && console.debug) console.debug.apply(console, arguments);\n  },\n  \n  /**\n    Logs an info statement.\n    \n    @param {String} msg one or more items to log\n    @returns {void}\n  */\n  info: function(msg) {\n    this.push('INFO', core.A(arguments));\n    \n    var console = this.console;\n    if (console && console.info) console.info.apply(console, arguments);\n  },\n  \n  /**\n    Logs a warning\n    \n    @param {String} msg one or more items to log\n    @returns {void}\n  */\n  warn: function(msg) {\n    this.push('WARN', core.A(arguments));\n    \n    var console = this.console;\n    if (console && console.warn) console.warn.apply(console, arguments);\n  },\n  \n  /**\n    Logs an error.\n    \n    @param {String} msg one or mroe items to log\n    @returns {void}\n  */\n  error: function(msg) {\n    this.push('ERROR', core.A(arguments));\n    \n    var console = this.console;\n    if (console && console.error) console.error.apply(console, arguments);\n  },\n  \n  /**\n    Begins a group stack.\n  */\n  group: function(groupName) {\n    this.push('GROUP', groupName);\n    \n    var console = this.console;\n    if (console && console.group) console.group(groupName);\n  },\n  \n  /**\n    Ends a group stack\n  */\n  groupEnd: function(groupName) {\n    this.push('','');\n    \n    var console = this.console;\n    if (console && console.groupEnd) console.groupEnd(groupName);\n  },\n  \n  toString: function() {\n    var len = this._lines ? this._lines.length : 0;\n    return \"Logger<id=\" + this.id + \" size=\" + len + \">\";\n  }\n    \n};\nLogger.prototype.log = Logger.prototype.info;\n\nconsole = new Logger('console', pconsole);\n;exports.Logger = Logger;\nexports.console = console;\n");
tiki.module("tiki/system:lib/platform",function(a,b){var c,e,g;e=null;c=platform="unknown";if(g=a.env){platform=c=g.PLATFORM||g.platform;e=g.PLATFORM_PACKAGE||g.platformPackage;if(!e&&platform)e="platform/"+platform}a=a(e).info;b.PLATFORM=c;b.PLATFORM_PACKAGE=e;b.info=a;b.env=g});tiki.module("tiki/system:lib/reactor","var $m__ = require('tiki/system:core'), T_ERROR=$m__.T_ERROR,T_OBJECT=$m__.T_OBJECT,T_NULL=$m__.T_NULL,T_CLASS=$m__.T_CLASS,T_HASH=$m__.T_HASH,T_FUNCTION=$m__.T_FUNCTION,T_UNDEFINED=$m__.T_UNDEFINED,T_NUMBER=$m__.T_NUMBER,T_BOOL=$m__.T_BOOL,T_ARRAY=$m__.T_ARRAY,T_STRING=$m__.T_STRING,T_BOOLEAN=$m__.T_BOOLEAN,YES=$m__.YES,NO=$m__.NO,isArray=$m__.isArray,typeOf=$m__.typeOf,A=$m__.A,generateGuid=$m__.generateGuid,guidFor=$m__.guidFor,mixin=$m__.mixin,setupDisplayNames=$m__.setupDisplayNames;var $m__ = require('tiki/system:lib/platform'), PLATFORM=$m__.PLATFORM,PLATFORM_PACKAGE=$m__.PLATFORM_PACKAGE,info=$m__.info,env=$m__.env;var $m__ = require('tiki/system:lib/invocation'), Invocation=$m__.Invocation;var schedule,cancel,reactor;// ==========================================================================\n// Project:   Tiki\n// Copyright: \u00a92009 Apple Inc.\n// ==========================================================================\n/*globals reactor PLATFORM_PACKAGE schedule reactor cancel Invocation exports */\n\n\"import core lib/platform lib/invocation\";\n\"export schedule cancel\";\n\"export package reactor\";\n\nvar platform = require(PLATFORM_PACKAGE);\n\n// internal method fires and invocation and cleans up\nfunction _invoke() {\n  this.invoke();\n  this._timer = this._repeats = null;\n  this.release();\n}\n\n/**\n  Schedules the passed invocation to execute after the specified amount of \n  time.  Returns an invocation object you can use to cancel.\n*/\nschedule = function(after, target, method, args) {\n  if (!(target instanceof Invocation)) {\n    target = Invocation.create(target, method, arguments, 3);\n  } else target.retain();\n\n  target._timer = platform.timer.schedule(after, target, _invoke);\n  target._repeats = false;\n  return target;\n};\n\n/**\n  Cancels a scheduled invocation.\n*/\ncancel = function(inv) {\n  if (inv._timer) platform.timer.cancel(inv._timer, inv._repeats);\n  inv._timer = inv._repeats = null;\n  return inv;\n};\n\n\nreactor = exports;\n\n;exports.schedule = schedule;\nexports.cancel = cancel;\nexports.reactor = reactor;\n");
tiki.module("tiki/system:mixins/retainable",'var Retainable;// ==========================================================================\n// Project:   Tiki\n// Copyright: \u00a92009 Apple Inc.\n// ==========================================================================\n/*globals Retainable */\n\n\n"export package Retainable";\n\n/**\n  Makes an object retainable.  Retainable objects have a retain count you can\n  increment and decrement.  When the retain count reaches zero, the object is\n  destroyed (by calling destroy).  \n  \n  Use this mixin for objects that need to have their memory carefully \n  controlled (such as events).  This also allows you to write objects that\n  are pooled.\n  \n  @since SproutCore 1.1\n*/\nRetainable = {\n  \n  /**\n    Number of objects retaining this object.  When this reaches zero, the\n    object will be destroyed.\n  */\n  retainCount: 1,\n  \n  /**\n    Becomes true when the object is destroyed.\n  */\n  isDestroyed: false,\n  \n  /**\n    Call to retain the object\n    \n    @returns {Object} receiver\n  */\n  retain: function() {\n    this.retainCount++;\n    return this ;\n  },\n  \n  /** \n    Call to release the object.  May cause it to be destroyed.\n    \n    @returns {Object} receiver\n  */\n  release: function() {\n    if (--this.retainCount <= 0) this.__destroy();\n    return this;\n  },\n  \n  __destroy: function() {\n    if (!this.isDestroyed) {\n      this.isDestroyed = true;\n      if (this.destroy) this.destroy();\n    }\n  }\n  \n};\n\n\n;exports.Retainable = Retainable;\n');
tiki.module("tiki/system:index",function(a,b){var c;c=a("tiki/system:lib/event");b.ready=c.ready;b.unload=c.unload;c=a("tiki/system:lib/global");b.global=c.global;c=a("tiki/system:lib/invocation");b.Invocation=c.Invocation;c=a("tiki/system:lib/logger");b.Logger=c.Logger;b.console=c.console;c=a("tiki/system:lib/platform");b.PLATFORM=c.PLATFORM;b.PLATFORM_PACKAGE=c.PLATFORM_PACKAGE;b.info=c.info;b.env=c.env;c=a("tiki/system:lib/reactor");b.reactor=c.reactor;c=a("tiki/system:mixins/retainable");b.Retainable=
c.Retainable});tiki.script("tiki/system:en/d957ea8a3f571914826aca7f16e15f122ab3ce87/javascript.js");tiki.register("sproutcore/runtime",{packages:{"tiki/system":{scripts:[{url:"/static/tiki/system/en/d957ea8a3f571914826aca7f16e15f122ab3ce87/javascript.js",id:"tiki/system:en/d957ea8a3f571914826aca7f16e15f122ab3ce87/javascript.js"}]}},depends:["tiki/system"],scripts:[{url:"/static/sproutcore/runtime/en/cfe6f8a7557f916515999a065d70bfa71bd13986/javascript.js",id:"sproutcore/runtime:en/cfe6f8a7557f916515999a065d70bfa71bd13986/javascript.js"}]});
tiki.module("sproutcore/runtime:core",function(a,b){var c=a("tiki/system:index"),e;if("undefined"===typeof console)console=c.console;if("undefined"===typeof sc_require)sc_require=function(){};if("undefined"===typeof sc_resource)sc_resource=function(){};e=a={};e.global=function(g,d){c.global[g]=d;return e};e.global.remove=function(g){delete c.global[g];return e};e.global("SC",e);e.mixin=function(){var g=arguments[0]||{},d=1,f=arguments.length,h;if(f===1){g=this||{};d=0}for(;d<f;d++)if(h=arguments[d])for(var i in h)if(h.hasOwnProperty(i)){var j=
h[i];if(g!==j)if(j!==undefined)g[i]=j}return g};e.supplement=function(){var g=arguments[0]||{},d=1,f=arguments.length,h;if(f===1){g=this||{};d=0}for(;d<f;d++)if(h=arguments[d])for(var i in h)if(h.hasOwnProperty(i)){var j=g[i],k=h[i];if(g!==k)if(k!==undefined&&j===undefined)g[i]=k}return g};e.extend=e.mixin;e.mixin({T_ERROR:"error",T_OBJECT:"object",T_NULL:"null",T_CLASS:"class",T_HASH:"hash",T_FUNCTION:"function",T_UNDEFINED:"undefined",T_NUMBER:"number",T_BOOL:"boolean",T_ARRAY:"array",T_STRING:"string",
typeOf:function(g){if(g===undefined)return e.T_UNDEFINED;if(g===null)return e.T_NULL;var d=typeof g;if(d=="object")d=g instanceof Array?e.T_ARRAY:g instanceof Function?g.isClass?e.T_CLASS:e.T_FUNCTION:e.Error&&g instanceof e.Error?e.T_ERROR:g.isObject===true?e.T_OBJECT:e.T_HASH;else if(d===e.T_FUNCTION)d=g.isClass?e.T_CLASS:e.T_FUNCTION;return d},none:function(g){return g===null||g===undefined},empty:function(g){return g===null||g===undefined||g===""},isArray:function(g){if(g&&g.objectAt)return true;
var d=g?g.length:null,f=e.typeOf(g);return!(e.none(d)||f===e.T_FUNCTION||f===e.T_STRING||g.setInterval)},makeArray:function(g){return e.isArray(g)?g:e.A(g)},A:function(g){if(e.none(g))return[];if(g.slice instanceof Function)return typeof g==="string"?[g]:g.slice();if(g.toArray)return g.toArray();if(!e.isArray(g))return[g];for(var d=[],f=g.length;--f>=0;)d[f]=g[f];return d},guidKey:"_sc_guid_"+(new Date).getTime(),_nextGUID:0,_numberGuids:[],_stringGuids:{},_keyCache:{},guidFor:function(g){if(g===
undefined)return"(undefined)";if(g===null)return"(null)";if(g===Object)return"(Object)";if(g===Array)return"(Array)";var d=this.guidKey;if(g[d])return g[d];switch(typeof g){case e.T_NUMBER:return this._numberGuids[g]=this._numberGuids[g]||"nu"+g;case e.T_STRING:return this._stringGuids[g]=this._stringGuids[g]||"st"+g;case e.T_BOOL:return g?"(true)":"(false)";default:return e.generateGuid(g)}},keyFor:function(g,d){var f,h=this._keyCache[g];h||(h=this._keyCache[g]={});(f=h[d])||(f=h[d]=g+"_"+d);return f},
generateGuid:function(g){var d="sc"+this._nextGUID++;if(g)g[this.guidKey]=d;return d},hashFor:function(g){return g&&g.hash&&typeof g.hash===e.T_FUNCTION?g.hash():this.guidFor(g)},isEqual:function(g,d){return g===null?d===null:g===undefined?d===undefined:this.hashFor(g)===this.hashFor(d)},compare:function(g,d){var f=e.typeOf(g),h=e.typeOf(d),i=e.ORDER_DEFINITION.indexOf(f);h=e.ORDER_DEFINITION.indexOf(h);if(i<h)return-1;if(i>h)return 1;switch(f){case e.T_BOOL:case e.T_NUMBER:if(g<d)return-1;if(g>d)return 1;
return 0;case e.T_STRING:if(g.localeCompare(d)<0)return-1;if(g.localeCompare(d)>0)return 1;return 0;case e.T_ARRAY:f=Math.min(g.length,d.length);for(h=i=0;i===0&&h<f;){i=arguments.callee(g[h],d[h]);if(i!==0)return i;h++}if(g.length<d.length)return-1;if(g.length>d.length)return 1;return 0;case e.T_OBJECT:if(g.constructor.isComparable===true)return g.constructor.compare(g,d);return 0;default:return 0}},K:function(){return this},EMPTY_ARRAY:[],EMPTY_HASH:{},EMPTY_RANGE:{start:0,length:0},beget:function(g){if(e.none(g))return null;
var d=e.K;d.prototype=g;var f=new d;d.prototype=null;if(e.typeOf(g.didBeget)===e.T_FUNCTION)f=g.didBeget(f);return f},copy:function(g){var d=g;if(g&&g.isCopyable)return g.copy();switch(e.typeOf(g)){case e.T_ARRAY:d=g.clone&&e.typeOf(g.clone)===e.T_FUNCTION?g.clone():g.slice();break;case e.T_HASH:case e.T_OBJECT:if(g.clone&&e.typeOf(g.clone)===e.T_FUNCTION)d=g.clone();else{d={};for(var f in g)d[f]=g[f]}}return d},merge:function(){var g={},d=arguments.length,f;for(f=0;f<d;f++)e.mixin(g,arguments[f]);
return g},keys:function(g){var d=[];for(var f in g)d.push(f);return d},inspect:function(g){var d,f=[];for(var h in g){d=g[h];if(d!=="toString"){if(e.typeOf(d)===e.T_FUNCTION)d="function() { ... }";f.push(h+": "+d)}}return"{"+f.join(" , ")+"}"},tupleForPropertyPath:function(g,d){if(e.typeOf(g)===e.T_ARRAY)return g;var f,h=g.indexOf("*");if(h<0)h=g.lastIndexOf(".");f=h>=0?g.slice(h+1):g;return(g=this.objectForPropertyPath(g,d,h))&&f?[g,f]:null},objectForPropertyPath:function(g,d,f){var h,i,j;if(!d)d=
c.global;if(e.typeOf(g)===e.T_STRING){if(f===undefined)f=g.length;for(h=0;d&&h<f;){i=g.indexOf(".",h);if(i<0||i>f)i=f;j=g.slice(h,i);d=d.get?d.get(j):d[j];h=i+1}if(h<f)d=undefined}else{h=0;for(f=g.length;h<f&&d;)if(j=g[h++])d=d.get?d.get(j):d[j];if(h<f)d=undefined}return d},STRINGS:{},stringsFor:function(g,d){e.mixin(e.STRINGS,d);return this}});e.clone=e.copy;e.$A=e.A;e.didLoad=e.K;e.ORDER_DEFINITION=[e.T_ERROR,e.T_UNDEFINED,e.T_NULL,e.T_BOOL,e.T_NUMBER,e.T_STRING,e.T_ARRAY,e.T_HASH,e.T_OBJECT,e.T_FUNCTION,
e.T_CLASS];e.mixin(Function.prototype,{property:function(){this.dependentKeys=e.$A(arguments);var g=e.guidFor(this);this.cacheKey="__cache__"+g;this.lastSetValueKey="__lastValue__"+g;this.isProperty=true;return this},cacheable:function(g){this.isProperty=true;if(!this.dependentKeys)this.dependentKeys=[];this.isCacheable=g===undefined?true:g;return this},idempotent:function(g){this.isProperty=true;if(!this.dependentKeys)this.dependentKeys=[];this.isVolatile=g===undefined?true:g;return this},observes:function(){for(var g=
arguments.length,d=null,f=null;--g>=0;){var h=arguments[g];if(h.indexOf(".")<0&&h.indexOf("*")<0){if(!d)d=this.localPropertyPaths=[];d.push(h)}else{if(!f)f=this.propertyPaths=[];f.push(h)}}return this}});String.prototype.fmt=function(){var g=arguments,d=0;return this.replace(/%@([0-9]+)?/g,function(f,h){h=h?parseInt(h,0)-1:d++;f=g[h];return(f===null?"(null)":f===undefined?"":f).toString()})};String.prototype.loc=function(){var g=e.STRINGS[this]||this;return g.fmt.apply(g,arguments)};String.prototype.w=
function(){for(var g=[],d=this.split(" "),f=d.length,h=0;h<f;++h){var i=d[h];i.length!==0&&g.push(i)}return g};b.SC=e;b.SproutCore=a;b.YES=true;b.NO=false});
tiki.module("sproutcore/runtime:mixins/array",function(a){var b=a("sproutcore/runtime:core"),c=b.SC,e=b.YES,g=b.NO;a("sproutcore/runtime:mixins/observable");a("sproutcore/runtime:mixins/enumerable");a("sproutcore/runtime:system/range_observer");c.OUT_OF_RANGE_EXCEPTION="Index out of range";c.Array={isSCArray:e,replace:function(){throw"replace() must be implemented to support SC.Array";},objectAt:function(d){if(!(d<0))if(!(d>=this.get("length")))return this.get(d)},"[]":function(d,f){f!==undefined&&
this.replace(0,this.get("length"),f);return this}.property(),insertAt:function(d,f){if(d>this.get("length"))throw c.OUT_OF_RANGE_EXCEPTION;this.replace(d,0,[f]);return this},removeAt:function(d,f){var h=0,i=[];if(typeof d===c.T_NUMBER){if(d<0||d>=this.get("length"))throw c.OUT_OF_RANGE_EXCEPTION;if(f===undefined){this.replace(d,1,i);return this}else d=c.IndexSet.create(d,f)}this.beginPropertyChanges();d.forEachRange(function(j,k){j-=h;h+=k;this.replace(j,k,i)},this);this.endPropertyChanges();return this},
removeObject:function(d){for(var f=this.get("length")||0;--f>=0;)this.objectAt(f)==d&&this.removeAt(f);return this},removeObjects:function(d){this.beginPropertyChanges();d.forEach(function(f){this.removeObject(f)},this);this.endPropertyChanges();return this},pushObject:function(d){this.insertAt(this.get("length"),d);return d},pushObjects:function(d){this.beginPropertyChanges();d.forEach(function(f){this.pushObject(f)},this);this.endPropertyChanges();return this},popObject:function(){var d=this.get("length");
if(d!==0){var f=this.objectAt(d-1);this.removeAt(d-1);return f}},shiftObject:function(){if(this.get("length")!==0){var d=this.objectAt(0);this.removeAt(0);return d}},unshiftObject:function(d){this.insertAt(0,d);return d},unshiftObjects:function(d){this.beginPropertyChanges();d.forEach(function(f){this.unshiftObject(f)},this);this.endPropertyChanges();return this},isEqual:function(d){if(!d)return false;if(d==this)return true;var f=d.get("length");if(f!=this.get("length"))return false;for(;--f>=0;)if(!c.isEqual(d.objectAt(f),
this.objectAt(f)))return false;return true},compact:function(){return this.without(null)},without:function(d){if(this.indexOf(d)<0)return this;var f=[];this.forEach(function(h){if(h!==d)f[f.length]=h});return f},uniq:function(){var d=[];this.forEach(function(f){if(d.indexOf(f)<0)d[d.length]=f});return d},rangeObserverClass:c.RangeObserver,addRangeObserver:function(d,f,h,i){var j=this._array_rangeObservers;if(!j)j=this._array_rangeObservers=c.CoreSet.create();if(this._array_oldLength===undefined)this._array_oldLength=
this.get("length");d=this.rangeObserverClass.create(this,d,f,h,i,g);j.add(d);if(!this._array_isNotifyingRangeObservers){this._array_isNotifyingRangeObservers=e;this.addObserver("[]",this,this._array_notifyRangeObservers)}return d},updateRangeObserver:function(d,f){return d.update(this,f)},removeRangeObserver:function(d){var f=d.destroy(this),h=this._array_rangeObservers;h&&h.remove(d);return f},enumerableContentDidChange:function(d,f,h){var i=this._array_rangeObservers,j=this._array_oldLength;this.beginPropertyChanges();
this.notifyPropertyChange("length");if(i&&i.length>0){if(j===undefined)j=0;this._array_oldLength=i=this.get("length");if(d===undefined)d=0;if(h===undefined)h=i-j;if(h!==0||f===undefined){f=i-d;if(h<0)f-=h}else f=f;h=this._array_rangeChanges;if(!h)h=this._array_rangeChanges=c.IndexSet.create();h.add(d,f)}this.notifyPropertyChange("[]");this.endPropertyChanges();return this},_array_notifyRangeObservers:function(){var d=this._array_rangeObservers,f=this._array_rangeChanges,h=d?d.length:0,i;if(h>0&&f&&
f.length>0){for(i=0;i<h;i++)d[i].rangeDidChange(f);f.clear()}}};c.mixin(Array.prototype,c.Array);c.Array=c.mixin({},c.Enumerable,c.Array);c.Array.slice=function(d,f){var h=[],i=this.get("length");if(c.none(d))d=0;if(c.none(f)||f>i)f=i;for(;d<f;)h[h.length]=this.objectAt(d++);return h};c.Array.indexOf=function(d,f){var h=this.get("length");f=f===undefined?0:f<0?Math.ceil(f):Math.floor(f);if(f<0)f+=h;for(f=f;f<h;f++)if(this.objectAt(f)===d)return f;return-1};if(!Array.prototype.indexOf)Array.prototype.indexOf=
c.Array.indexOf;c.Array.lastIndexOf=function(d,f){var h=this.get("length");f=f===undefined?h-1:f<0?Math.ceil(f):Math.floor(f);if(f<0)f+=h;for(f=f;f>=0;f--)if(this.objectAt(f)===d)return f;return-1};if(!Array.prototype.lastIndexOf)Array.prototype.lastIndexOf=c.Array.lastIndexOf;(function(){c.mixin(Array.prototype,{replace:function(f,h,i){if(this.isFrozen)throw c.FROZEN_ERROR;!i||i.length===0?this.splice(f,h):this.splice.apply(this,[f,h].concat(i));i=i?i.get?i.get("length"):i.length:0;this.enumerableContentDidChange(f,
h,i-h);return this},unknownProperty:function(f,h){var i=this.reducedProperty(f,h);if(h!==undefined&&i===undefined)i=this[f]=h;return i}});var d=Array.prototype.indexOf;if(!d||d===c.Array.indexOf)Array.prototype.indexOf=function(f,h){var i=this.length;h=h===undefined?0:h<0?Math.ceil(h):Math.floor(h);if(h<0)h+=i;for(h=h;h<i;h++)if(this[h]===f)return h;return-1};d=Array.prototype.lastIndexOf;if(!d||d===c.Array.lastIndexOf)Array.prototype.lastIndexOf=function(f,h){var i=this.length;h=h===undefined?i-
1:h<0?Math.ceil(h):Math.floor(h);if(h<0)h+=i;for(h=h;h>=0;h--)if(this[h]===f)return h;return-1}})()});tiki.module("sproutcore/runtime:mixins/comparable",function(a){a=a("sproutcore/runtime:core");a.SC.Comparable={isComparable:a.YES,compare:function(){throw"%@.compare() is not implemented".fmt(this.toString());}}});
tiki.module("sproutcore/runtime:mixins/copyable",function(a){a=a("sproutcore/runtime:core");var b=a.SC,c=a.YES;b.Copyable={isCopyable:c,copy:function(){throw"%@.copy() is not implemented";},frozenCopy:function(){var e=this.get?this.get("isFrozen"):this.isFrozen;if(e===c)return this;else if(e===undefined)throw"%@ does not support freezing".fmt(this);else return this.copy().freeze()}};b.mixin(Array.prototype,b.Copyable);Array.prototype.copy=Array.prototype.slice});
tiki.module("sproutcore/runtime:mixins/delegate_support",function(a){var b=a("sproutcore/runtime:core").SC;b.DelegateSupport={delegateFor:function(c){for(var e=1,g=arguments.length,d;e<g;){if((d=arguments[e])&&d[c]!==undefined)return d;e++}return this[c]!==undefined?this:null},invokeDelegateMethod:function(c,e,g){g=b.A(arguments);g=g.slice(2,g.length);if(!c||!c[e])c=this;var d=c[e];return d?d.apply(c,g):null},getDelegateProperty:function(c){for(var e=1,g=arguments.length,d;e<g;)if((d=arguments[e++])&&
d[c]!==undefined)return d.get?d.get(c):d[c];return this[c]!==undefined?this.get(c):undefined}}});
tiki.module("sproutcore/runtime:mixins/enumerable",function(a){var b=a("sproutcore/runtime:core"),c=b.SC,e=b.YES,g=b.NO;a("sproutcore/runtime:system/enumerator");c.Enumerable={isEnumerable:e,nextObject:function(d){return this.objectAt?this.objectAt(d):this[d]},firstObject:function(){if(this.get("length")!==0){if(this.objectAt)return this.objectAt(0);var d=c.Enumerator._popContext(),f;f=this.nextObject(0,null,d);c.Enumerator._pushContext(d);return f}}.property(),enumerator:function(){return c.Enumerator.create(this)},
forEach:function(d,f){if(typeof d!=="function")throw new TypeError;var h=this.get?this.get("length"):this.length;if(f===undefined)f=null;for(var i=null,j=c.Enumerator._popContext(),k=0;k<h;k++){i=this.nextObject(k,i,j);d.call(f,i,k,this);i=i}c.Enumerator._pushContext(j);return this},getEach:function(d){return this.map(function(f){return f?f.get?f.get(d):f[d]:null},this)},setEach:function(d,f){this.forEach(function(h){if(h)if(h.set)h.set(d,f);else h[d]=f},this);return this},map:function(d,f){if(typeof d!==
"function")throw new TypeError;var h=this.get?this.get("length"):this.length;if(f===undefined)f=null;for(var i=[],j=null,k=c.Enumerator._popContext(),l=0;l<h;l++){j=this.nextObject(l,j,k);i[l]=d.call(f,j,l,this);j=j}c.Enumerator._pushContext(k);return i},mapProperty:function(d){return this.map(function(f){return f?f.get?f.get(d):f[d]:null})},filter:function(d,f){if(typeof d!=="function")throw new TypeError;var h=this.get?this.get("length"):this.length;if(f===undefined)f=null;for(var i=[],j=null,k=
c.Enumerator._popContext(),l=0;l<h;l++){j=this.nextObject(l,j,k);d.call(f,j,l,this)&&i.push(j);j=j}c.Enumerator._pushContext(k);return i},sortProperty:function(d){var f=typeof d===c.T_STRING?arguments:d,h=f.length,i;if(this instanceof Array)i=this;else{i=[];this.forEach(function(j){i.push(j)})}if(!i)return[];return i.sort(function(j,k){var l,o,n;for(l=n=0;n===0&&l<h;l++){o=f[l];n=j?j.get?j.get(o):j[o]:null;o=k?k.get?k.get(o):k[o]:null;n=c.compare(n,o)}return n})},filterProperty:function(d,f){for(var h=
this.get?this.get("length"):this.length,i=[],j=null,k=c.Enumerator._popContext(),l=0;l<h;l++){var o=(j=this.nextObject(l,j,k))?j.get?j.get(d):j[d]:null;if(f===undefined?!!o:c.isEqual(o,f))i.push(j);j=j}c.Enumerator._pushContext(k);return i},find:function(d,f){if(typeof d!=="function")throw new TypeError;var h=this.get?this.get("length"):this.length;if(f===undefined)f=null;for(var i=null,j=g,k=null,l=c.Enumerator._popContext(),o=0;o<h&&!j;o++){i=this.nextObject(o,i,l);if(j=d.call(f,i,o,this))k=i;i=
i}c.Enumerator._pushContext(l);return k},findProperty:function(d,f){for(var h=this.get?this.get("length"):this.length,i=g,j=null,k=null,l=c.Enumerator._popContext(),o=0;o<h&&!i;o++){i=(k=this.nextObject(o,k,l))?k.get?k.get(d):k[d]:null;if(i=f===undefined?!!i:c.isEqual(i,f))j=k;k=k}c.Enumerator._pushContext(l);return j},every:function(d,f){if(typeof d!=="function")throw new TypeError;var h=this.get?this.get("length"):this.length;if(f===undefined)f=null;for(var i=e,j=null,k=c.Enumerator._popContext(),
l=0;i&&l<h;l++){j=this.nextObject(l,j,k);d.call(f,j,l,this)||(i=g);j=j}c.Enumerator._pushContext(k);return i},everyProperty:function(d,f){for(var h=this.get?this.get("length"):this.length,i=e,j=null,k=c.Enumerator._popContext(),l=0;i&&l<h;l++){i=(j=this.nextObject(l,j,k))?j.get?j.get(d):j[d]:null;i=f===undefined?!!i:c.isEqual(i,f);j=j}c.Enumerator._pushContext(k);return i},some:function(d,f){if(typeof d!=="function")throw new TypeError;var h=this.get?this.get("length"):this.length;if(f===undefined)f=
null;for(var i=g,j=null,k=c.Enumerator._popContext(),l=0;!i&&l<h;l++){j=this.nextObject(l,j,k);if(d.call(f,j,l,this))i=e;j=j}c.Enumerator._pushContext(k);return i},someProperty:function(d,f){for(var h=this.get?this.get("length"):this.length,i=g,j=null,k=c.Enumerator._popContext(),l=0;!i&&l<h;l++){i=(j=this.nextObject(l,j,k))?j.get?j.get(d):j[d]:null;i=f===undefined?!!i:c.isEqual(i,f);j=j}c.Enumerator._pushContext(k);return i},reduce:function(d,f,h){if(typeof d!=="function")throw new TypeError;var i=
this.get?this.get("length"):this.length;if(i===0&&f===undefined)throw new TypeError;f=f;for(var j=null,k=c.Enumerator._popContext(),l=0;l<i;l++){j=this.nextObject(l,j,k);if(j!==null)f=f===undefined?j:d.call(null,f,j,l,this,h);j=j}c.Enumerator._pushContext(k);if(f===undefined)throw new TypeError;return f},invoke:function(d){var f=this.get?this.get("length"):this.length;if(f<=0)return[];var h,i=[],j=arguments.length;if(j>1)for(h=1;h<j;h++)i.push(arguments[h]);j=[];var k=null,l=c.Enumerator._popContext();
for(h=0;h<f;h++){var o=(k=this.nextObject(h,k,l))?k[d]:null;if(o)j[h]=o.apply(k,i);k=k}c.Enumerator._pushContext(l);return j},invokeWhile:function(d,f){var h=this.get?this.get("length"):this.length;if(h<=0)return null;var i,j=[],k=arguments.length;if(k>2)for(i=2;i<k;i++)j.push(arguments[i]);k=d;var l=null,o=c.Enumerator._popContext();for(i=0;k===d&&i<h;i++){var n=(l=this.nextObject(i,l,o))?l[f]:null;if(n)k=n.apply(l,j);l=l}c.Enumerator._pushContext(o);return k},toArray:function(){var d=[];this.forEach(function(f){d.push(f)},
this);return d}};c._buildReducerFor=function(d,f){return function(h,i){var j=this[d];return c.typeOf(j)!==c.T_FUNCTION?this.unknownProperty?this.unknownProperty(h,i):null:c.Enumerable.reduce.call(this,j,null,f)}.property("[]")};c.Reducers={"[]":function(){return this}.property(),enumerableContentDidChange:function(){this.notifyPropertyChange("[]");return this},reducedProperty:function(d,f,h){if(!(!d||d.charAt(0)!=="@")){f=d.match(/^@([^(]*)(\(([^)]*)\))?$/);if(!(!f||f.length<2)){var i=f[1];f=f[3];
i="reduce"+i.slice(0,1).toUpperCase()+i.slice(1);var j=this[i];if(c.typeOf(j)===c.T_FUNCTION){if(h===g)return c.Enumerable.reduce.call(this,j,null,f);i=c._buildReducerFor(i,f);if(h=this.constructor.prototype){h[d]=i;i=h._properties||[];i.push(d);h._properties=i;this.registerDependentKey(d,"[]")}return c.Enumerable.reduce.call(this,j,null,f)}}}},reduceMax:function(d,f,h,i,j){if(j&&f)f=f.get?f.get(j):f[j];if(d===null)return f;return f>d?f:d},reduceMaxObject:function(d,f,h,i,j){h=d;i=f;if(j){if(f)i=
f.get?f.get(j):f[j];if(d)h=d.get?d.get(j):d[j]}if(h===null)return f;return i>h?f:d},reduceMin:function(d,f,h,i,j){if(j&&f)f=f.get?f.get(j):f[j];if(d===null)return f;return f<d?f:d},reduceMinObject:function(d,f,h,i,j){h=d;i=f;if(j){if(f)i=f.get?f.get(j):f[j];if(d)h=d.get?d.get(j):d[j]}if(h===null)return f;return i<h?f:d},reduceAverage:function(d,f,h,i,j){if(j&&f)f=f.get?f.get(j):f[j];d=(d||0)+f;i=i.get?i.get("length"):i.length;if(h>=i-1)d/=i;return d},reduceSum:function(d,f,h,i,j){if(j&&f)f=f.get?
f.get(j):f[j];return d===null?f:d+f}};c.mixin(c.Enumerable,c.Reducers);c.mixin(Array.prototype,c.Reducers);Array.prototype.isEnumerable=e;(function(){var d={nextObject:c.Enumerable.nextObject,enumerator:c.Enumerable.enumerator,firstObject:c.Enumerable.firstObject,sortProperty:c.Enumerable.sortProperty,mapProperty:function(i){for(var j=this.length,k=[],l=0;l<j;l++){var o=this[l];k[l]=o?o.get?o.get(i):o[i]:null}return k},filterProperty:function(i,j){for(var k=this.length,l=[],o=0;o<k;o++){var n=this[o],
r=n?n.get?n.get(i):n[i]:null;if(j===undefined?!!r:c.isEqual(r,j))l.push(n)}return l},find:function(i,j){if(typeof i!=="function")throw new TypeError;var k=this.length;if(j===undefined)j=null;for(var l,o=null,n=g,r=0;r<k&&!n;r++){l=this[r];if(n=i.call(j,l,r,this))o=l}return o},findProperty:function(i,j){var k=this.length,l,o;o=g;for(var n=null,r=0;r<k&&!o;r++){o=(l=this[r])?l.get?l.get(i):l[i]:null;if(o=j===undefined?!!o:c.isEqual(o,j))n=l}return n},everyProperty:function(i,j){for(var k=this.length,
l=e,o=0;l&&o<k;o++){l=(l=this[o])?l.get?l.get(i):l[i]:null;l=j===undefined?!!l:c.isEqual(l,j)}return l},someProperty:function(i,j){for(var k=this.length,l=g,o=0;!l&&o<k;o++){l=(l=this[o])?l.get?l.get(i):l[i]:null;l=j===undefined?!!l:c.isEqual(l,j)}return l},invoke:function(i){var j=this.length;if(j<=0)return[];var k,l=[],o=arguments.length;if(o>1)for(k=1;k<o;k++)l.push(arguments[k]);o=[];for(k=0;k<j;k++){var n=this[k],r=n?n[i]:null;if(r)o[k]=r.apply(n,l)}return o},invokeWhile:function(i,j){var k=
this.length;if(k<=0)return null;var l,o=[],n=arguments.length;if(n>2)for(l=2;l<n;l++)o.push(arguments[l]);n=i;for(l=0;n===i&&l<k;l++){var r=this[l],p=r?r[j]:null;if(p)n=p.apply(r,o)}return n},toArray:function(){var i=this.length;if(i<=0)return[];for(var j=[],k=0;k<i;k++)j.push(this[k]);return j},getEach:function(i){for(var j=[],k=this.length,l=0;l<k;l++){var o=this[l];j[l]=o?o.get?o.get(i):o[i]:null}return j},setEach:function(i,j){for(var k=this.length,l=0;l<k;l++){var o=this[l];if(o)if(o.set)o.set(i,
j);else o[i]=j}return this}},f={forEach:function(i,j){if(typeof i!=="function")throw new TypeError;var k=this.length;if(j===undefined)j=null;for(var l=0;l<k;l++)i.call(j,this[l],l,this);return this},map:function(i,j){if(typeof i!=="function")throw new TypeError;var k=this.length;if(j===undefined)j=null;for(var l=[],o=0;o<k;o++)l[o]=i.call(j,this[o],o,this);return l},filter:function(i,j){if(typeof i!=="function")throw new TypeError;var k=this.length;if(j===undefined)j=null;for(var l=[],o=0;o<k;o++){var n=
this[o];i.call(j,n,o,this)&&l.push(n)}return l},every:function(i,j){if(typeof i!=="function")throw new TypeError;var k=this.length;if(j===undefined)j=null;for(var l=e,o=0;l&&o<k;o++)i.call(j,this[o],o,this)||(l=g);return l},some:function(i,j){if(typeof i!=="function")throw new TypeError;var k=this.length;if(j===undefined)j=null;for(var l=g,o=0;!l&&o<k;o++)if(i.call(j,this[o],o,this))l=e;return l},reduce:function(i,j,k){if(typeof i!=="function")throw new TypeError;var l=this.length;if(l===0&&j===undefined)throw new TypeError;
j=j;for(var o=0;o<l;o++){var n=this[o];if(n!==null)j=j===undefined?n:i.call(null,j,n,o,this,k)}if(j===undefined)throw new TypeError;return j}};for(var h in f)if(f.hasOwnProperty(h))if(!Array.prototype[h]||typeof Prototype==="object"&&Prototype.Version.match(/^1\.6/))Array.prototype[h]=f[h];c.mixin(Array.prototype,d)})()});
tiki.module("sproutcore/runtime:mixins/freezable",function(a){var b=a("sproutcore/runtime:core");a=b.SC;var c=b.YES;b=b.NO;a.FROZEN_ERROR=new Error("Cannot modify a frozen object");a.Freezable={isFreezable:c,isFrozen:b,freeze:function(){if(this.set)this.set("isFrozen",c);else this.isFrozen=c;return this}};a.mixin(Array.prototype,a.Freezable)});
tiki.module("sproutcore/runtime:mixins/observable",function(a){var b=a("sproutcore/runtime:core"),c=b.SC,e=b.YES,g=b.NO;a("sproutcore/runtime:private/observer_set");a("sproutcore/runtime:private/chain_observer");var d=false;c.LOG_OBSERVERS=g;c.Observable={isObservable:e,automaticallyNotifiesObserversFor:function(){return e},get:function(f){var h=this[f],i;if(h===undefined)return this.unknownProperty(f);else if(h&&h.isProperty)if(h.isCacheable){i=this._kvo_cache;if(!i)i=this._kvo_cache={};return i[h.cacheKey]!==
undefined?i[h.cacheKey]:(i[h.cacheKey]=h.call(this,f))}else return h.call(this,f);else return h},set:function(f,h){var i=this[f],j=this.automaticallyNotifiesObserversFor(f),k=h,l,o,n,r;if(this._kvo_cacheable&&(o=this._kvo_cache)){l=this._kvo_cachedep;if(!l||(l=l[f])===undefined)l=this._kvo_computeCachedDependentsFor(f);if(l)for(n=l.length;--n>=0;){r=l[n];o[r.cacheKey]=o[r.lastSetValueKey]=undefined}}if(i&&i.isProperty){o=this._kvo_cache;if(i.isVolatile||!o||o[i.lastSetValueKey]!==h){if(!o)o=this._kvo_cache=
{};o[i.lastSetValueKey]=h;j&&this.propertyWillChange(f);k=i.call(this,f,h);if(i.isCacheable)o[i.cacheKey]=k;j&&this.propertyDidChange(f,k,e)}}else if(i===undefined){j&&this.propertyWillChange(f);this.unknownProperty(f,h);j&&this.propertyDidChange(f,k)}else if(this[f]!==h){j&&this.propertyWillChange(f);k=this[f]=h;j&&this.propertyDidChange(f,k)}return this},unknownProperty:function(f,h){if(h!==undefined)this[f]=h;return h},beginPropertyChanges:function(){this._kvo_changeLevel=(this._kvo_changeLevel||
0)+1;return this},endPropertyChanges:function(){this._kvo_changeLevel=(this._kvo_changeLevel||1)-1;var f=this._kvo_changes;this._kvo_changeLevel<=0&&f&&f.length>0&&!c.Observers.isObservingSuspended&&this._notifyPropertyObservers();return this},propertyWillChange:function(){return this},propertyDidChange:function(f,h,i){this._kvo_revision=(this._kvo_revision||0)+1;var j=this._kvo_changeLevel||0,k,l,o;h=c.LOG_OBSERVERS&&this.LOG_OBSERVING!==g;if(this._kvo_cacheable&&(o=this._kvo_cache)){if(!i)if((i=
this[f])&&i.isProperty)o[i.cacheKey]=o[i.lastSetValueKey]=undefined;i=this._kvo_cachedep;if(!i||(i=i[f])===undefined)i=this._kvo_computeCachedDependentsFor(f);if(i)for(k=i.length;--k>=0;){l=i[k];o[l.cacheKey]=o[l.lastSetValueKey]=undefined}}o=c.Observers.isObservingSuspended;if(j>0||o){j=this._kvo_changes;if(!j)j=this._kvo_changes=c.CoreSet.create();j.add(f);if(o){h&&console.log("%@%@: will not notify observers because observing is suspended".fmt(c.KVO_SPACES,this));c.Observers.objectHasPendingChanges(this)}}else this._notifyPropertyObservers(f);
return this},registerDependentKey:function(f,h){var i=this._kvo_dependents,j,k,l,o,n;if(c.typeOf(h)===c.T_ARRAY){j=h;l=0}else{j=arguments;l=1}k=j.length;if(!i)this._kvo_dependents=i={};for(;--k>=l;){o=j[k];(n=i[o])||(n=i[o]=[]);n.push(f)}},_kvo_addCachedDependents:function(f,h,i,j){for(var k=h.length,l,o,n;--k>=0;){o=h[k];j.add(o);if((l=this[o])&&l instanceof Function&&l.isProperty){l.isCacheable&&f.push(l);if((n=i[o])&&n.length>0)this._kvo_addCachedDependents(f,n,i,j)}}},_kvo_computeCachedDependentsFor:function(f){var h=
this._kvo_cachedep,i=this._kvo_dependents,j=i?i[f]:null,k,l;if(!h)h=this._kvo_cachedep={};if(!j||j.length===0)return h[f]=null;k=h[f]=[];l=c._TMP_SEEN_SET=c._TMP_SEEN_SET||c.CoreSet.create();l.add(f);this._kvo_addCachedDependents(k,j,i,l);l.clear();if(k.length===0)k=h[f]=null;return k},_kvo_for:function(f,h){var i=this[f];if(!this._kvo_cloned)this._kvo_cloned={};if(i){if(!this._kvo_cloned[f]){i=this[f]=i.copy();this._kvo_cloned[f]=e}}else{i=this[f]=h===undefined?[]:h.create();this._kvo_cloned[f]=
e}return i},addObserver:function(f,h,i,j){var k;if(i===undefined){i=h;h=this}h||(h=this);if(c.typeOf(i)===c.T_STRING)i=h[i];if(!i)throw"You must pass a method to addObserver()";f=f.toString();if(f.indexOf(".")>=0){j=c._ChainObserver.createChain(this,f,h,i,j);j.masterTarget=h;j.masterMethod=i;this._kvo_for(c.keyFor("_kvo_chains",f)).push(j)}else{this[f]===undefined&&f.indexOf("@")===0&&this.get(f);if(h===this)h=null;k=c.keyFor("_kvo_observers",f);this._kvo_for(k,c.ObserverSet).add(h,i,j);this._kvo_for("_kvo_observed_keys",
c.CoreSet).add(f)}this.didAddObserver&&this.didAddObserver(f,h,i);return this},removeObserver:function(f,h,i){var j,k,l;if(i===undefined){i=h;h=this}h||(h=this);if(c.typeOf(i)===c.T_STRING)i=h[i];if(!i)throw"You must pass a method to addObserver()";f=f.toString();if(f.indexOf(".")>=0){j=c.keyFor("_kvo_chains",f);if(this[j]){j=this._kvo_for(j);for(l=j.length;--l>=0;)if((k=j[l])&&k.masterTarget===h&&k.masterMethod===i)j[l]=k.destroyChain()}}else{if(h===this)h=null;j=c.keyFor("_kvo_observers",f);if(this[j]){j=
this._kvo_for(j);j.remove(h,i);j.targets<=0&&this._kvo_for("_kvo_observed_keys",c.CoreSet).remove(f)}}this.didRemoveObserver&&this.didRemoveObserver(f,h,i);return this},hasObserverFor:function(f){c.Observers.flush(this);var h=this[c.keyFor("_kvo_observers",f)];if((f=this[c.keyFor("_kvo_local",f)])&&f.length>0)return e;if(h&&h.getMembers().length>0)return e;return g},initObservable:function(){if(!this._observableInited){this._observableInited=e;if(!d){d=e;a("sproutcore/runtime:system/binding");a("sproutcore/runtime:private/observer_queue")}var f,
h,i,j,k,l;if(h=this._observers){j=h.length;for(f=0;f<j;f++){i=h[f];i=this[i];l=(k=i.propertyPaths)?k.length:0;for(var o=0;o<l;o++){var n=k[o],r=n.indexOf(".");if(r<0)this.addObserver(n,this,i);else if(n.indexOf("*")===0)this.addObserver(n.slice(1),this,i);else{var p=null;if(r===0){p=this;n=n.slice(1)}else if(r===4&&n.slice(0,5)==="this."){p=this;n=n.slice(5)}else if(r<0&&n.length===4&&n==="this"){p=this;n=""}c.Observers.addObserver(n,this,i,p)}}}}this.bindings=[];if(h=this._bindings)for(f=0;f<h.length;f++){i=
h[f];j=this[i];k=i.slice(0,-7);this[i]=this.bind(k,j)}if(h=this._properties)for(f=0;f<h.length;f++){i=h[f];if(j=this[i]){if(j.isCacheable)this._kvo_cacheable=e;j.dependentKeys&&j.dependentKeys.length>0&&this.registerDependentKey(i,j.dependentKeys)}}}},observersForKey:function(f){return this._kvo_for("_kvo_observers",f).getMembers()||[]},_notifyPropertyObservers:function(f){this._observableInited||this.initObservable();c.Observers.flush(this);var h=c.LOG_OBSERVERS&&this.LOG_OBSERVING!==g,i,j,k,l,o,
n,r,p,m,q,s,t;if(h){t=c.KVO_SPACES=(c.KVO_SPACES||"")+"  ";console.log('%@%@: notifying observers after change to key "%@"'.fmt(t,this,f))}k=this["_kvo_observers_*"];for(this._kvo_changeLevel=(this._kvo_changeLevel||0)+1;(j=this._kvo_changes)&&j.length>0||f;){n=++this.propertyRevision;j||(j=c.CoreSet.create());this._kvo_changes=null;if(f==="*"){j.add("*");j.addEach(this._kvo_for("_kvo_observed_keys",c.CoreSet))}else f&&j.add(f);if(i=this._kvo_dependents)for(l=0;l<j.length;l++){f=j[l];if((o=i[f])&&
(q=o.length)){h&&console.log("%@...including dependent keys for %@: %@".fmt(t,f,o));r=this._kvo_cache;if(!r)r=this._kvo_cache={};for(;--q>=0;){j.add(f=o[q]);if(f=this[f]){this[f.cacheKey]=undefined;r[f.cacheKey]=r[f.lastSetValueKey]=undefined}}}}for(;j.length>0;){f=j.pop();if(i=this[c.keyFor("_kvo_observers",f)]){i=i.getMembers();l=i.length;for(r=0;r<l;r++){o=i[r];if(o[3]!==n){p=o[0]||this;m=o[1];s=o[2];o[3]=n;h&&console.log('%@...firing observer on %@ for key "%@"'.fmt(t,p,f));s!==undefined?m.call(p,
this,f,null,s,n):m.call(p,this,f,null,n)}}}if(i=this[c.keyFor("_kvo_local",f)]){l=i.length;for(r=0;r<l;r++){o=i[r];if(m=this[o]){h&&console.log('%@...firing local observer %@.%@ for key "%@"'.fmt(t,this,o,f));m.call(this,this,f,null,n)}}}if(k&&f!=="*"){i=k.getMembers();l=i.length;for(r=0;r<l;r++){o=i[r];p=o[0]||this;m=o[1];s=o[2];h&&console.log('%@...firing * observer on %@ for key "%@"'.fmt(t,p,f));s!==undefined?m.call(p,this,f,null,s,n):m.call(p,this,f,null,n)}}if(this.propertyObserver){h&&console.log('%@...firing %@.propertyObserver for key "%@"'.fmt(t,
this,f));this.propertyObserver(this,f,null,n)}}j&&j.destroy();f=null}this._kvo_changeLevel=(this._kvo_changeLevel||1)-1;if(h)c.KVO_SPACES=t.slice(0,-2);return e},bind:function(f,h,i){if(i!==undefined)h=[h,i];i=c.typeOf(h);if(i===c.T_STRING||i===c.T_ARRAY){i=this[f+"BindingDefault"]||c.Binding;i=i.beget().from(h)}else i=h;i=i.to(f,this).connect();this.bindings.push(i);return i},didChangeFor:function(f){f=c.hashFor(f);var h=this._kvo_didChange_valueCache;if(!h)h=this._kvo_didChange_valueCache={};var i=
this._kvo_didChange_revisionCache;if(!i)i=this._kvo_didChange_revisionCache={};for(var j=h[f]||{},k=i[f]||{},l=false,o=this._kvo_revision||0,n=arguments.length;--n>=1;){var r=arguments[n];if(k[r]!=o){var p=this.get(r);if(j[r]!==p){l=true;j[r]=p}}k[r]=o}h[f]=j;i[f]=k;return l},setIfChanged:function(f,h){return this.get(f)!==h?this.set(f,h):this},getPath:function(f){f=c.tupleForPropertyPath(f,this);if(!(f===null||f[0]===null))return f[0].get(f[1])},setPath:function(f,h){if(f.indexOf(".")>=0){f=c.tupleForPropertyPath(f,
this);if(!f||!f[0])return null;f[0].set(f[1],h)}else this.set(f,h);return this},setPathIfChanged:function(f,h){if(f.indexOf(".")>=0){f=c.tupleForPropertyPath(f,this);if(!f||!f[0])return null;f[0].get(f[1])!==h&&f[0].set(f[1],h)}else this.setIfChanged(f,h);return this},getEach:function(){for(var f=c.A(arguments),h=[],i=0;i<f.length;i++)h[h.length]=this.getPath(f[i]);return h},incrementProperty:function(f){this.set(f,(this.get(f)||0)+1);return this.get(f)},decrementProperty:function(f){this.set(f,(this.get(f)||
0)-1);return this.get(f)},toggleProperty:function(f,h,i){if(h===undefined)h=true;if(i===undefined)i=false;h=this.get(f)==h?i:h;this.set(f,h);return this.get(f)},notifyPropertyChange:function(f,h){this.propertyWillChange(f);this.propertyDidChange(f,h);return this},allPropertiesDidChange:function(){this._kvo_cache=null;this._notifyPropertyObservers("*");return this},addProbe:function(f){this.addObserver(f,c.logChange)},removeProbe:function(f){this.removeObserver(f,c.logChange)},logProperty:function(){for(var f=
c.$A(arguments),h=0;h<f.length;h++){var i=f[h];console.log("%@:%@: ".fmt(c.guidFor(this),i),this.get(i))}},propertyRevision:1};c.logChange=function(f,h){console.log("CHANGE: %@[%@] => %@".fmt(f,h,f.get(h)))};c.mixin(Array.prototype,c.Observable)});
tiki.module("sproutcore/runtime:private/chain_observer",function(a){var b=a("sproutcore/runtime:core").SC;b._ChainObserver=function(c){this.property=c};b._ChainObserver.createChain=function(c,e,g,d,f){e=e.split(".");for(var h=new b._ChainObserver(e[0]),i=h,j=e.length,k=1;k<j;k++)i=i.next=new b._ChainObserver(e[k]);h.objectDidChange(c);i.target=g;i.method=d;i.context=f;return h};b._ChainObserver.prototype={isChainObserver:true,object:null,property:null,next:null,target:null,method:null,objectDidChange:function(c){if(c!==
this.object){this.object&&this.object.removeObserver&&this.object.removeObserver(this.property,this,this.propertyDidChange);(this.object=c)&&this.object.addObserver&&this.object.addObserver(this.property,this,this.propertyDidChange);this.propertyDidChange()}},propertyDidChange:function(){var c=this.object,e=this.property,g=c&&c.get?c.get(e):null;this.next&&this.next.objectDidChange(g);var d=this.target,f=this.method,h=this.context;if(d&&f){var i=c?c.propertyRevision:null;h?f.call(d,c,e,g,h,i):f.call(d,
c,e,g,i)}},destroyChain:function(){var c=this.object;c&&c.removeObserver&&c.removeObserver(this.property,this,this.propertyDidChange);this.next&&this.next.destroyChain();return this.next=this.target=this.method=this.object=this.context=null}}});
tiki.module("sproutcore/runtime:private/observer_queue",function(a){var b=a("sproutcore/runtime:core"),c=b.SC,e=b.NO;a("sproutcore/runtime:system/set");c.Observers={queue:[],addObserver:function(g,d,f,h){var i;(i=c.typeOf(g)===c.T_STRING?c.tupleForPropertyPath(g,h):g)?i[0].addObserver(i[1],d,f):this.queue.push([g,d,f,h])},removeObserver:function(g,d,f,h){var i,j,k;(i=c.tupleForPropertyPath(g,h))&&i[0].removeObserver(i[1],d,f);i=this.queue.length;for(j=this.queue;--i>=0;){k=j[i];if(k[0]===g&&k[1]===
d&&k[2]==f&&k[3]===h)j[i]=null}},addPendingRangeObserver:function(g){var d=this.rangeObservers;if(!d)d=this.rangeObservers=c.CoreSet.create();d.add(g);return this},_TMP_OUT:[],flush:function(g){var d=this.queue;if(d&&d.length>0)for(var f=this.queue=[],h=d.length;--h>=0;){var i=d[h];if(i){var j=c.tupleForPropertyPath(i[0],i[3]);j?j[0].addObserver(j[1],i[1],i[2]):f.push(i)}}if(g._kvo_needsRangeObserver){f=(d=this.rangeObservers)?d.get("length"):0;i=this._TMP_OUT;for(h=0;h<f;h++){j=d[h];j.setupPending(g)&&
i.push(j)}i.length>0&&d.removeEach(i);i.length=0;g._kvo_needsRangeObserver=e}},isObservingSuspended:0,_pending:c.CoreSet.create(),objectHasPendingChanges:function(g){this._pending.add(g)},suspendPropertyObserving:function(){this.isObservingSuspended++},resumePropertyObserving:function(){var g;if(--this.isObservingSuspended<=0){g=this._pending;this._pending=c.CoreSet.create();var d,f=g.length;for(d=0;d<f;d++)g[d]._notifyPropertyObservers();g.clear()}}}});
tiki.module("sproutcore/runtime:private/observer_set",function(a){a=a("sproutcore/runtime:core");var b=a.SC,c=a.YES,e=a.NO;b.ObserverSet={targets:0,_membersCacheIsValid:e,add:function(g,d,f){var h=g?b.guidFor(g):"__this__",i=this[h];if(!i){i=this[h]=b.CoreSet.create();i.target=g;i.isTargetSet=c;this.targets++}i.add(d);if(f!==undefined){g=i.contexts;f||(g={});g[b.guidFor(d)]=f}this._membersCacheIsValid=e},remove:function(g,d){g=g?b.guidFor(g):"__this__";var f=this[g];if(!f)return e;f.remove(d);if(f.length<=
0){f.target=null;f.isTargetSet=e;f.contexts=null;delete this[g];this.targets--}else f.contexts&&delete f.contexts[b.guidFor(d)];this._membersCacheIsValid=e;return c},invokeMethods:function(){for(var g in this)if(this.hasOwnProperty(g)){var d=this[g];if(d&&d.isTargetSet)for(var f=d.length,h=d.target;--f>=0;)d[f].call(h)}},getMembers:function(){if(this._membersCacheIsValid)return this._members;if(this._members)this._members.length=0;else this._members=[];var g=this._members;for(var d in this)if(this.hasOwnProperty(d)){var f=
this[d];if(f&&f.isTargetSet){var h=f.length,i=f.target,j=f.contexts;if(j)for(;--h>=0;){var k=f[h];g.push([i,k,j[b.guidFor(k)]])}else for(;--h>=0;)g.push([i,f[h]])}}this._membersCacheIsValid=c;return g},clone:function(){var g,d,f,h=b.ObserverSet.create();for(f in this)if(this.hasOwnProperty(f))if((g=this[f])&&g.isTargetSet){d=g.clone();d.target=g.target;if(g.contexts)d.contexts=b.clone(g.contexts);h[f]=d}h.targets=this.targets;h._membersCacheIsValid=e;return h},create:function(){return b.beget(this)}};
b.ObserverSet.slice=b.ObserverSet.clone});
tiki.module("sproutcore/runtime:system/binding",function(a){var b=a("sproutcore/runtime:core"),c=b.SC,e=b.YES,g=b.NO;a("sproutcore/runtime:system/set");c.LOG_BINDINGS=g;c.BENCHMARK_BINDING_NOTIFICATIONS=g;c.BENCHMARK_BINDING_SETUP=g;c.MULTIPLE_PLACEHOLDER="@@MULT@@";c.NULL_PLACEHOLDER="@@NULL@@";c.EMPTY_PLACEHOLDER="@@EMPTY@@";c.Binding={beget:function(d){var f=c.beget(this);f.parentBinding=this;if(d!==undefined)f=f.from(d);return f},builder:function(){var d=this,f=function(h){return d.beget().from(h)};
f.beget=function(){return d.beget()};return f},from:function(d,f){if(!d)return this;var h=this===c.Binding?this.beget():this;h._fromPropertyPath=d;h._fromRoot=f;h._fromTuple=null;return h},to:function(d,f){var h=this===c.Binding?this.beget():this;h._toPropertyPath=d;h._toRoot=f;h._toTuple=null;return h},connect:function(){if(this.isConnected)return this;this._syncOnConnect=this._connectionPending=this.isConnected=e;c.Binding._connectQueue.add(this);return this},_connect:function(){if(this._connectionPending){this._connectionPending=
g;var d,f,h=c.BENCHMARK_BINDING_SETUP;h&&c.Benchmark.start("SC.Binding.connect()");d=this._fromPropertyPath;f=this._fromRoot;if(c.typeOf(d)===c.T_STRING)if(d.indexOf(".")===0){d=d.slice(1);if(!f)f=this._toRoot}else if(d.indexOf("*")===0){d=[this._fromRoot||this._toRoot,d.slice(1)];f=null}c.Observers.addObserver(d,this,this.fromPropertyDidChange,f);if(!this._oneWay){d=this._toPropertyPath;f=this._toRoot;c.Observers.addObserver(d,this,this.toPropertyDidChange,f)}h&&c.Benchmark.end("SC.Binding.connect()");
if(this._syncOnConnect){this._syncOnConnect=g;h&&c.Benchmark.start("SC.Binding.connect().sync");this.sync();h&&c.Benchmark.end("SC.Binding.connect().sync")}}},disconnect:function(){if(!this.isConnected)return this;if(this._connectionPending)this._connectionPending=g;else{c.Observers.removeObserver(this._fromPropertyPath,this,this.fromPropertyDidChange,this._fromRoot);this._oneWay||c.Observers.removeObserver(this._toPropertyPath,this,this.toPropertyDidChange,this._toRoot)}this.isConnected=g;return this},
fromPropertyDidChange:function(d,f){if((d?d.get(f):null)!==this._bindingValue){this._setBindingValue(d,f);this._changePending=e;c.Binding._changeQueue.add(this)}},toPropertyDidChange:function(d,f){if(!this._oneWay)if(d.get(f)!==this._transformedBindingValue){this._setBindingValue(d,f);this._changePending=e;c.Binding._changeQueue.add(this)}},_setBindingValue:function(d,f){this._bindingSource=d;this._bindingKey=f},_computeBindingValue:function(){var d=this._bindingSource;if(d){this._bindingValue=d=
d.getPath(this._bindingKey);var f=this._transforms;if(f)for(var h=f.length,i=0;i<h;i++)d=f[i](d,this);if(this._noError&&c.typeOf(d)===c.T_ERROR)d=null;this._transformedBindingValue=d}},_connectQueue:c.CoreSet.create(),_alternateConnectQueue:c.CoreSet.create(),_changeQueue:c.CoreSet.create(),_alternateChangeQueue:c.CoreSet.create(),_changePending:g,flushPendingChanges:function(){if(this._isFlushing)return g;this._isFlushing=e;c.Observers.suspendPropertyObserving();for(var d=g,f=c.LOG_BINDINGS,h,i;(h=
this._connectQueue).length>0;){this._connectQueue=this._alternateConnectQueue;for(this._alternateConnectQueue=h;i=h.pop();)i._connect()}for(;(h=this._changeQueue).length>0;){f&&console.log("Begin: Trigger changed bindings");d=e;this._changeQueue=this._alternateChangeQueue;for(this._alternateChangeQueue=h;i=h.pop();)i.applyBindingValue();f&&console.log("End: Trigger changed bindings")}this._isFlushing=g;c.Observers.resumePropertyObserving();return d},applyBindingValue:function(){this._changePending=
g;this._computeBindingTargets();this._computeBindingValue();var d=this._bindingValue,f=this._transformedBindingValue,h=c.BENCHMARK_BINDING_NOTIFICATIONS,i=c.LOG_BINDINGS;if(!this._oneWay&&this._fromTarget){i&&console.log("%@: %@ -> %@".fmt(this,d,f));h&&c.Benchmark.start(this.toString()+"->");this._fromTarget.setPathIfChanged(this._fromPropertyKey,d);h&&c.Benchmark.end(this.toString()+"->")}if(this._toTarget){i&&console.log("%@: %@ <- %@".fmt(this,d,f));h&&c.Benchmark.start(this.toString()+"<-");
this._toTarget.setPathIfChanged(this._toPropertyKey,f);h&&c.Benchmark.start(this.toString()+"<-")}},sync:function(){if(!this.isConnected)return this;if(this._connectionPending)this._syncOnConnect=e;else{this._computeBindingTargets();var d=this._fromTarget,f=this._fromPropertyKey;if(!d||!f)return this;if(d.getPath(f)!==this._bindingValue){this._setBindingValue(d,f);this._changePending=e;c.Binding._changeQueue.add(this)}}return this},_syncOnConnect:g,_computeBindingTargets:function(){if(!this._fromTarget){var d,
f;d=this._fromPropertyPath;f=this._fromRoot;if(c.typeOf(d)===c.T_STRING)if(d.indexOf(".")===0){d=d.slice(1);if(!f)f=this._toRoot}else if(d.indexOf("*")===0){d=[f||this._toRoot,d.slice(1)];f=null}if(d=c.tupleForPropertyPath(d,f)){this._fromTarget=d[0];this._fromPropertyKey=d[1]}}if(!this._toTarget){d=this._toPropertyPath;f=this._toRoot;if(d=c.tupleForPropertyPath(d,f)){this._toTarget=d[0];this._toPropertyKey=d[1]}}},oneWay:function(d,f){if(f===undefined&&c.typeOf(d)===c.T_BOOL){f=d;d=null}d=this.from(d);
if(d===c.Binding)d=d.beget();d._oneWay=f===undefined?e:f;return d},transform:function(d){var f=this===c.Binding?this.beget():this,h=f._transforms;if(h&&h===f.parentBinding._transform)h=f._transforms=h.slice();if(!h)h=f._transforms=[];h.push(d);return f},resetTransforms:function(){var d=this===c.Binding?this.beget():this;d._transforms=null;return d},noError:function(d,f){if(f===undefined&&c.typeOf(d)===c.T_BOOL){f=d;d=null}d=this.from(d);if(d===c.Binding)d=d.beget();d._noError=f===undefined?e:f;return d},
single:function(d,f){if(f===undefined)f=c.MULTIPLE_PLACEHOLDER;return this.from(d).transform(function(h){if(h&&h.isEnumerable){var i=h.get("length");h=i>1?f:i<=0?null:h.firstObject()}return h})},notEmpty:function(d,f){if(f===undefined)f=c.EMPTY_PLACEHOLDER;return this.from(d).transform(function(h){if(c.none(h)||h===""||c.isArray(h)&&h.length===0)h=f;return h})},notNull:function(d,f){if(f===undefined)f=c.EMPTY_PLACEHOLDER;return this.from(d).transform(function(h){if(c.none(h))h=f;return h})},multiple:function(d){return this.from(d).transform(function(f){c.isArray(f)||
(f=f==null?[]:[f]);return f})},bool:function(d){return this.from(d).transform(function(f){var h=c.typeOf(f);if(h===c.T_ERROR)return f;return h==c.T_ARRAY?f.length>0:f===""?g:!!f})},not:function(d){return this.from(d).transform(function(f){var h=c.typeOf(f);if(h===c.T_ERROR)return f;return!(h==c.T_ARRAY?f.length>0:f===""?g:!!f)})},isNull:function(d){return this.from(d).transform(function(f){return c.typeOf(f)===c.T_ERROR?f:c.none(f)})},toString:function(){var d=this._fromRoot?"<%@>:%@".fmt(this._fromRoot,
this._fromPropertyPath):this._fromPropertyPath,f=this._toRoot?"<%@>:%@".fmt(this._toRoot,this._toPropertyPath):this._toPropertyPath,h=this._oneWay?"[oneWay]":"";return"SC.Binding%@(%@ -> %@)%@".fmt(c.guidFor(this),d,f,h)}};c.binding=function(d,f){return c.Binding.from(d,f)}});
tiki.module("sproutcore/runtime:system/cookie",function(a){var b=a("sproutcore/runtime:core"),c=b.SC,e=b.YES;b=b.NO;a("sproutcore/runtime:system/object");c.Cookie=c.Object.extend({name:null,value:"",expires:null,path:null,domain:null,secure:b,isCookie:e,destroy:function(){this.set("expires",-1);this.write();arguments.callee.base.apply(this,arguments)},write:function(){var g=this.get("name"),d=this.get("value"),f=this.get("expires"),h=this.get("path"),i=this.get("domain"),j=this.get("secure"),k="";
if(f&&(c.typeOf(f)===c.T_NUMBER||c.DateTime&&f.get&&f.get("milliseconds")||c.typeOf(f.toUTCString)===c.T_FUNCTION)){var l;if(c.typeOf(f)===c.T_NUMBER){l=new Date;l.setTime(l.getTime()+f*24*60*60*1E3)}else if(c.DateTime&&f.get&&f.get("milliseconds"))l=new Date(f.get("milliseconds"));else if(c.typeOf(f.toUTCString)===c.T_FUNCTION)l=f;if(l)k="; expires="+l.toUTCString()}f=h?"; path="+h:"";i=i?"; domain="+i:"";j=j?"; secure":"";document.cookie=[g,"=",encodeURIComponent(d),k,f,i,j].join("");return this}});
c.Cookie.mixin({find:function(g){if(document.cookie&&document.cookie!="")for(var d=document.cookie.split(";"),f=0;f<d.length;f++){var h=String(d[f]).trim();if(h.substring(0,g.length+1)===g+"=")return c.Cookie.create({name:g,value:decodeURIComponent(h.substring(g.length+1))})}return null}})});
tiki.module("sproutcore/runtime:system/enumerator",function(a){var b=a("sproutcore/runtime:core").SC;b.Enumerator=function(c){this.enumerable=c;this.reset();return this};b.Enumerator.prototype={nextObject:function(){var c=this._index,e=this._length;if(!(c>=e)){var g=this.enumerable.nextObject(c,this._previousObject,this._context);this._previousObject=g;this._index=c+1;if(c>=e)this._context=b.Enumerator._pushContext(this._context);return g}},reset:function(){var c=this.enumerable;if(!c)throw b.$error("Enumerator has been destroyed");
c=this._length=c.get?c.get("length"):c.length;this._index=0;this._previousObject=null;this._context=c>0?b.Enumerator._popContext():null},destroy:function(){this.enumerable=this._length=this._index=this._previousObject=this._context=null}};b.Enumerator.create=function(c){return new b.Enumerator(c)};b.Enumerator._popContext=function(){return(this._contextCache?this._contextCache.pop():null)||{}};b.Enumerator._pushContext=function(c){this._contextCache=this._contextCache||[];this._contextCache.push(c);
return null}});
tiki.module("sproutcore/runtime:system/error",function(a){a=a("sproutcore/runtime:core");var b=a.SC;a=a.YES;b.Error=b.Object.extend({code:-1,message:"",errorValue:null,errorObject:function(){return this}.property().cacheable(),label:null,toString:function(){return"SC.Error:%@:%@ (%@)".fmt(b.guidFor(this),this.get("message"),this.get("code"))},isError:a});b.Error.desc=function(c,e,g,d){c={message:c};if(e!==undefined)c.label=e;if(d!==undefined)c.code=d;if(g!==undefined)c.errorValue=g;return this.create(c)};
b.$error=function(c,e,g,d){return b.Error.desc(c,e,g,d)};b.ok=function(c){return c!==false&&!(c&&c.isError)};b.$ok=b.ok;b.val=function(c){return c&&c.isError?c.get?c.get("errorValue"):null:c};b.$val=b.val;b.Error.HAS_MULTIPLE_VALUES=-100});
tiki.module("sproutcore/runtime:system/index_set",function(a){var b=a("sproutcore/runtime:core"),c=b.SC,e=b.YES,g=b.NO;a("sproutcore/runtime:mixins/enumerable");a("sproutcore/runtime:mixins/observable");a("sproutcore/runtime:mixins/freezable");a("sproutcore/runtime:mixins/copyable");c.IndexSet=c.mixin({},c.Enumerable,c.Observable,c.Freezable,c.Copyable,{_sc_sliceContent:function(d){if(d.length<1E3)return d.slice();for(var f=0,h=[],i=d[0];i!==0;){h[f]=i;f=i<0?0-i:i;i=d[f]}h[f]=0;this._hint(0,f,h);
return h},create:function(d,f){var h=c.beget(this);h.initObservable();if(d&&d.isIndexSet){h._content=this._sc_sliceContent(d._content);h.max=d.max;h.length=d.length;h.source=d.source}else{h._content=[0];d!==undefined&&h.add(d,f)}return h},isIndexSet:e,HINT_SIZE:256,length:0,max:0,min:function(){var d=this._content[0];return d===0?-1:d>0?0:Math.abs(d)}.property("[]").cacheable(),firstObject:function(){return this.get("length")>0?this.get("min"):undefined}.property(),rangeStartForIndex:function(d){var f=
this._content,h=this.get("max"),i;if(d>=h)return h;if(Math.abs(f[d])>d)return d;i=d-d%c.IndexSet.HINT_SIZE;h=f[i];if(h<0||h>d)h=i;for(i=Math.abs(f[h]);i<d;){h=i;i=Math.abs(f[h])}return h},isEqual:function(d){if(d===this)return e;if(!d||!d.isIndexSet||d.max!==this.max||d.length!==this.length)return g;var f=this._content;d=d._content;var h=0,i=f[h];do{if(d[h]!==i)return g;h=Math.abs(i);i=f[h]}while(h!==0);return e},indexBefore:function(d){if(d===0)return-1;d--;var f=this._content,h=this.get("max"),
i=this.rangeStartForIndex(d);if(!f)return null;for(;i===h||f[i]<0;){if(i===0)return-1;d=i-1;i=this.rangeStartForIndex(d)}return d},indexAfter:function(d){var f=this._content,h=this.get("max");if(!f||d>=h)return-1;d++;h=this.rangeStartForIndex(d);for(h=f[h];h<0;){if(h===0)return-1;d=h=Math.abs(h);h=f[h]}return d},contains:function(d,f){var h,i;if(f===undefined){if(d===null||d===undefined)return g;if(typeof d===c.T_NUMBER)f=1;else if(d&&d.isIndexSet){if(d===this)return e;d=d._content;f=0;for(h=d[f];h!==
0;){if(h>0&&!this.contains(f,h-f))return g;f=Math.abs(h);h=d[f]}return e}else{f=d.length;d=d.start}}h=this.rangeStartForIndex(d);i=this._content[h];return i>0&&h<=d&&i>=d+f},intersects:function(d,f){var h,i,j;if(f===undefined)if(typeof d===c.T_NUMBER)f=1;else if(d&&d.isIndexSet){if(d===this)return e;h=d._content;i=0;for(j=h[i];j!==0;){if(j>0&&this.intersects(i,j-i))return e;i=Math.abs(j);j=h[i]}return g}else{f=d.length;d=d.start}i=this.rangeStartForIndex(d);h=this._content;j=h[i];for(f=d+f;i<f;){if(j===
0)return g;if(j>0&&j>d)return e;i=Math.abs(j);j=h[i]}return g},without:function(d,f){if(d===this)return c.IndexSet.create();return this.clone().remove(d,f)},replace:function(d,f){if(f===undefined)if(typeof d===c.T_NUMBER)f=1;else if(d&&d.isIndexSet){this._content=this._sc_sliceContent(d._content);this.beginPropertyChanges().set("max",d.max).set("length",d.length).set("source",d.source).enumerableContentDidChange().endPropertyChanges();return this}else{f=d.length;d=d.start}this._content.length=1;this.length=
this.max=this._content[0]=0;return this.add(d,f)},add:function(d,f){if(this.isFrozen)throw c.FROZEN_ERROR;var h,i,j;if(d&&d.isIndexSet){h=d._content;if(!h)return this;i=0;for(j=h[0];j!==0;){j>0&&this.add(i,j-i);i=j<0?0-j:j;j=h[i]}return this}else if(f===undefined)if(d===null||d===undefined)return this;else if(typeof d===c.T_NUMBER)f=1;else{f=d.length;d=d.start}else if(f===null)f=1;if(f<=0)return this;var k=this.get("max"),l=k,o;h=this._content;if(d===k){if(d>0){i=this.rangeStartForIndex(d-1);j=h[i];
if(j>0){delete h[k];h[i]=k=d+f;d=i}else h[k]=k=d+f}else h[d]=k=f;h[k]=0;this.set("max",k);this.set("length",this.length+f);f=k-d}else if(d>k){h[k]=0-d;h[d]=d+f;h[d+f]=0;this.set("max",d+f);this.set("length",this.length+f);f=d+f-k;d=k}else{i=this.rangeStartForIndex(d);j=h[i];k=d+f;o=0;if(d>0&&i===d&&j<=0){i=this.rangeStartForIndex(d-1);j=h[i]}if(j<0){h[i]=0-d;if(Math.abs(j)>k){h[d]=0-k;h[k]=j}else h[d]=j}else{d=i;if(j>k)k=j}for(i=d;i<k;){f=h[i];if(f===0){h[k]=0;j=k;o+=k-i}else{j=Math.abs(f);if(j>k){h[k]=
f;j=k}if(f<0)o+=j-i}delete h[i];i=j}if((i=h[k])>0){delete h[k];k=i}h[d]=k;k>l&&this.set("max",k);this.set("length",this.get("length")+o);f=k-d}this._hint(d,f);o!==0&&this.enumerableContentDidChange();return this},remove:function(d,f){if(this.isFrozen)throw c.FROZEN_ERROR;if(f===undefined)if(d===null||d===undefined)return this;else if(typeof d===c.T_NUMBER)f=1;else if(d.isIndexSet){d.forEachRange(this.remove,this);return this}else{f=d.length;d=d.start}if(f<=0)return this;var h=this.get("max"),i=this._content,
j,k,l;if(d>=h)return this;h=this.rangeStartForIndex(d);j=i[h];l=d+f;k=0;if(d>0&&h===d&&j>0){h=this.rangeStartForIndex(d-1);j=i[h]}if(j>0){i[h]=d;if(j>l){i[d]=l;i[l]=j}else i[d]=j}else{d=h;j=Math.abs(j);if(j>l)l=j}for(h=d;h<l;){f=i[h];if(f===0){i[l]=0;j=l}else{j=Math.abs(f);if(j>l){i[l]=f;j=l}if(f>0)k+=j-h}delete i[h];h=j}if((h=i[l])<0){delete i[l];l=Math.abs(h)}if(i[l]===0){delete i[l];i[d]=0;this.set("max",d)}else i[d]=0-l;this.set("length",this.get("length")-k);f=l-d;this._hint(d,f);k!==0&&this.enumerableContentDidChange();
return this},_hint:function(d,f,h){if(h===undefined)h=this._content;var i=c.IndexSet.HINT_SIZE,j=Math.abs(h[d]),k=d-d%i+i;for(f=d+f;k<f;){for(;j!==0&&j<=k;){d=j;j=Math.abs(h[d])}if(j===0)delete h[k];else if(k!==d)h[k]=d;k+=i}},clear:function(){if(this.isFrozen)throw c.FROZEN_ERROR;var d=this.length;this._content.length=1;this._content[0]=0;this.set("length",0).set("max",0);d>0&&this.enumerableContentDidChange()},addEach:function(d){if(this.isFrozen)throw c.FROZEN_ERROR;this.beginPropertyChanges();
var f=d.get("length");if(d.isSCArray)for(;--f>=0;)this.add(d.objectAt(f));else d.isEnumerable&&d.forEach(function(h){this.add(h)},this);this.endPropertyChanges();return this},removeEach:function(d){if(this.isFrozen)throw c.FROZEN_ERROR;this.beginPropertyChanges();var f=d.get("length");if(d.isSCArray)for(;--f>=0;)this.remove(d.objectAt(f));else d.isEnumerable&&d.forEach(function(h){this.remove(h)},this);this.endPropertyChanges();return this},clone:function(){return c.IndexSet.create(this)},inspect:function(){var d=
this._content,f=d.length,h=0,i=[],j;for(h=0;h<f;h++){j=d[h];j!==undefined&&i.push("%@:%@".fmt(h,j))}return"SC.IndexSet<%@>".fmt(i.join(" , "))},forEachRange:function(d,f){var h=this._content,i=0,j=h[i],k=this.source;if(f===undefined)f=null;for(;j!==0;){j>0&&d.call(f,i,j-i,this,k);i=Math.abs(j);j=h[i]}return this},forEachIn:function(d,f,h,i){var j=this._content,k=0,l=0;f=d+f;var o=this.source,n=j[k];if(i===undefined)i=null;for(;n!==0;){if(k<d)k=d;for(;k<n&&k<f;)h.call(i,k++,l++,this,o);if(k>=f)k=n=
0;else{k=Math.abs(n);n=j[k]}}return this},lengthIn:function(d,f){var h=0;if(f===undefined)if(d===null||d===undefined)return 0;else if(typeof d===c.T_NUMBER)f=1;else if(d.isIndexSet){d.forEachRange(function(l,o){h+=this.lengthIn(l,o)},this);return h}else{f=d.length;d=d.start}if(this.get("length")===0)return 0;var i=this._content,j=0,k=i[j];for(d=d+f;j<d&&k!==0;){if(k>0)h+=k>d?d-j:k-j;j=Math.abs(k);k=i[j]}return h},source:null,indexOf:function(d){var f=this.source;if(!f)throw"%@.indexOf() requires source".fmt(this);
var h=f.get("length"),i=this._content;for(i=i[0]<0?Math.abs(i[0]):0;i>=0&&i<h;){i=f.indexOf(d,i);if(i<0)return-1;if(this.contains(i))return i;i=i+1}return-1},lastIndexOf:function(d){var f=this.source;if(!f)throw"%@.lastIndexOf() requires source".fmt(this);var h=f.get("length"),i=this.max-1;if(i>=h)i=h-1;for(;i>=0;){h=f.lastIndexOf(d,i);if(h<0)return-1;if(this.contains(h))return h;i=h+1}return-1},forEachObject:function(d,f){var h=this.source;if(!h)throw"%@.forEachObject() requires source".fmt(this);
var i=this._content,j=0,k=i[j];if(f===undefined)f=null;for(;k!==0;){for(;j<k;){d.call(f,h.objectAt(j),j,h,this);j++}j=Math.abs(k);k=i[j]}return this},addObject:function(d,f){var h=this.source;if(!h)throw"%@.addObject() requires source".fmt(this);for(var i=h.get("length"),j=0;j>=0&&j<i;){j=h.indexOf(d,j);if(j>=0){this.add(j);if(f)return this;j=j++}else return this}return this},addObjects:function(d,f){d.forEach(function(h){this.addObject(h,f)},this);return this},removeObject:function(d,f){var h=this.source;
if(!h)throw"%@.removeObject() requires source".fmt(this);for(var i=h.get("length"),j=0;j>=0&&j<i;){j=h.indexOf(d,j);if(j>=0){this.remove(j);if(f)return this;j=j+1}else return this}return this},removeObjects:function(d,f){d.forEach(function(h){this.removeObject(h,f)},this);return this},LOG_OBSERVING:g,forEach:function(d,f){var h=this._content,i=0,j=0,k=this.source,l=h[i];if(f===undefined)f=null;for(;l!==0;){for(;i<l;)d.call(f,i++,j++,this,k);i=Math.abs(l);l=h[i]}return this},nextObject:function(d,
f,h){d=this._content;var i=h.next,j=this.get("max");if(f===null)f=i=0;else if(f>=j){delete h.next;return null}else f++;if(f===i){do{f=Math.abs(i);i=d[f]}while(i<0);h.next=i}return f},toString:function(){var d=[];this.forEachRange(function(f,h){d.push(h===1?f:"%@..%@".fmt(f,f+h-1))},this);return"SC.IndexSet<%@>".fmt(d.join(","))},max:0});c.IndexSet.slice=c.IndexSet.copy=c.IndexSet.clone;c.IndexSet.EMPTY=c.IndexSet.create().freeze()});
tiki.module("sproutcore/runtime:system/logger",function(a){var b=a("sproutcore/runtime:core"),c=b.SC,e=b.YES;b=b.NO;a("sproutcore/runtime:system/object");c.LOGGER_LOG_DELIMITER=", ";c.LOGGER_LOG_ERROR="ERROR: ";c.LOGGER_LOG_INFO="INFO: ";c.LOGGER_LOG_WARN="WARNING: ";c.Logger=c.Object.create({exists:function(){return typeof this.get("reporter")!=="undefined"&&this.get("reporter")!=null}.property("reporter").cacheable(),fallBackOnAlert:b,fallBackOnLog:e,format:e,reporter:console,log:function(){var g=
this.get("reporter");if(this.get("exists")&&typeof g.log==="function"){this.get("format")?g.log(this._argumentsToString.apply(this,arguments)):g.log.apply(g,arguments);return true}else if(this.fallBackOnAlert){var d=this.get("format")?this._argumentsToString.apply(this,arguments):arguments;this.get("exists")&&typeof g.alert==="function"?g.alert(d):alert(d);return true}return false},dir:function(){var g=this.get("reporter");if(this.get("exists")&&typeof g.dir==="function"){g.dir.apply(g,arguments);
return true}return this.fallBackOnLog?this.log.apply(this,arguments):false},dirxml:function(){var g=this.get("reporter");if(this.get("exists")&&typeof g.dirxml==="function"){g.dirxml.apply(g,arguments);return true}return this.fallBackOnLog?this.log.apply(this,arguments):false},error:function(){var g=this.get("reporter");if(this.get("exists")&&typeof g.error==="function"){g.error.apply(g,arguments);return true}else if(this.fallBackOnLog){g=this._argumentsToArray(arguments);typeof g.unshift==="function"&&
g.unshift(c.LOGGER_LOG_ERROR);return this.log.apply(this,g)}return false},group:function(g){var d=this.get("reporter");if(this.get("exists")&&typeof d.group==="function"){d.group(g);return true}return false},groupEnd:function(){var g=this.get("reporter");if(this.get("exists")&&typeof g.groupEnd==="function"){g.groupEnd();return true}return false},info:function(){var g=this.get("reporter");if(this.get("exists")&&typeof g.info==="function"){g.info.apply(g,arguments);return true}else if(this.fallBackOnLog){g=
this._argumentsToArray(arguments);typeof g.unshift==="function"&&g.unshift(c.LOGGER_LOG_INFO);return this.log.apply(this,g)}return false},profile:function(){var g=this.get("reporter");if(this.get("exists")&&typeof g.profile==="function"){g.profile();return true}return false},profileEnd:function(){var g=this.get("reporter");if(this.get("exists")&&typeof g.profileEnd==="function"){g.profileEnd();return true}return false},time:function(g){var d=this.get("reporter");if(this.get("exists")&&typeof d.time===
"function"){d.time(g);return true}return false},timeEnd:function(g){var d=this.get("reporter");if(this.get("exists")&&typeof d.timeEnd==="function"){d.timeEnd(g);return true}return false},trace:function(){var g=this.get("reporter");if(this.get("exists")&&typeof g.trace==="function"){g.trace();return true}return false},warn:function(){var g=this.get("reporter");if(this.get("exists")&&typeof g.warn==="function"){g.warn.apply(g,arguments);return true}else if(this.fallBackOnLog){g=this._argumentsToArray(arguments);
typeof g.unshift==="function"&&g.unshift(c.LOGGER_LOG_WARN);return this.log.apply(this,g)}return false},_argumentsToArray:function(g){if(!g)return[];for(var d=[],f=0;f<g.length;f++)d[f]=g[f];return d},_argumentsToString:function(){for(var g="",d=0;d<arguments.length-1;d++)g+=arguments[d]+c.LOGGER_LOG_DELIMITER;g+=arguments[arguments.length-1];return g}})});
tiki.module("sproutcore/runtime:system/object",function(a){function b(){if(!e._object_foundObjectClassNames){e._object_foundObjectClassNames=true;var f=[],h=function(i,j,k){k--;if(!(f.indexOf(j)>=0)){f.push(j);for(var l in j)if(l!="__scope__")if(l!="superclass")if(l.match(/^[A-Z0-9]/)){var o=i?[i,l].join("."):l,n=j[l];switch(e.typeOf(n)){case e.T_CLASS:if(!n._object_className)n._object_className=o;k>=0&&h(o,n,k);break;case e.T_OBJECT:k>=0&&h(o,n,k);break;case e.T_HASH:if((i||o==="SC")&&k>=0)h(o,n,
k);break;default:break}}}};h(null,a("system:index").global,2)}}var c=a("sproutcore/runtime:core"),e=c.SC,g=c.YES,d=c.NO;a("sproutcore/runtime:mixins/observable");a("sproutcore/runtime:system/set");e.BENCHMARK_OBJECTS=d;e._object_extend=function(f,h){if(!h)throw"SC.Object.extend expects a non-null value.  Did you forget to 'sc_require' something?  Or were you passing a Protocol to extend() as if it were a mixin?";f._kvo_cloned=null;var i,j,k,l=f.concatenatedProperties,o=e.K,n,r;j=l?l.length:0;for(var p=
j>0?{}:null;--j>=0;){i=l[j];n=f[i];r=h[i];if(n){n instanceof Array||(n=e.$A(n));p[i]=r?n.concat(r):r}else{r instanceof Array||(r=e.$A(r));p[i]=r}}j=f._bindings;l=d;n=f._observers;r=d;var m=f._properties,q=d,s,t,u,v=f.outlets,w=d;if(h.outlets){v=(v||e.EMPTY_ARRAY).concat(h.outlets);w=g}for(i in h)if(i!=="_kvo_cloned")if(h.hasOwnProperty(i)){var x=(p.hasOwnProperty(i)?p[i]:null)||h[i];if(i.slice(-7)==="Binding"){if(!l){j=(j||e.EMPTY_ARRAY).slice();l=g}if(j===null)j=(f._bindings||e.EMPTY_ARRAY).slice();
j[j.length]=i}else if(x&&x instanceof Function){if(!x.superclass&&x!==(k=f[i]))x.superclass=x.base=k||o;if(x.propertyPaths){if(!r){n=(n||e.EMPTY_ARRAY).slice();r=g}n[n.length]=i}else if(s=x.localPropertyPaths)for(t=s.length;--t>=0;){u=f._kvo_for(e.keyFor("_kvo_local",s[t]),e.Set);u.add(i);f._kvo_for("_kvo_observed_keys",e.CoreSet).add(s[t])}else if(x.dependentKeys){if(!q){m=(m||e.EMPTY_ARRAY).slice();q=g}m[m.length]=i}else if(x.autoconfiguredOutlet){if(!w){v=(v||e.EMPTY_ARRAY).slice();w=g}v[v.length]=
i}}f[i]=x}if(h.hasOwnProperty("toString")){i="toString";x=(p.hasOwnProperty(i)?p[i]:null)||h[i];if(!x.superclass&&x!==(k=f[i]))x.superclass=x.base=k||o;f[i]=x}f._bindings=j||[];f._observers=n||[];f._properties=m||[];f.outlets=v||[];return f};e.Object=function(f){return this._object_init(f)};e.mixin(e.Object,{mixin:function(){var f=arguments.length,h;for(h=0;h<f;h++)e.mixin(this,arguments[h]);return this},superclass:null,extend:function(){var f=e.BENCHMARK_OBJECTS;f&&e.Benchmark.start("SC.Object.extend");
var h,i=function(l){return this._object_init(l)};for(h in this)if(this.hasOwnProperty(h))i[h]=this[h];if(this.hasOwnProperty("toString"))i.toString=this.toString;i.superclass=this;e.generateGuid(i);i.subclasses=e.Set.create();this.subclasses.add(i);h=i.prototype=e.beget(this.prototype);var j,k=arguments.length;for(j=0;j<k;j++)e._object_extend(h,arguments[j]);h.constructor=i;f&&e.Benchmark.end("SC.Object.extend");return i},create:function(){return new this(arguments)},isClass:g,subclasses:e.Set.create(),
toString:function(){return e._object_className(this)},subclassOf:function(f){if(this===f)return d;for(var h=this;h=h.superclass;)if(h===f)return g;return d},hasSubclass:function(f){return f&&f.subclassOf?f.subclassOf(this):d},kindOf:function(f){return this===f||this.subclassOf(f)}});e.Object.prototype={_kvo_enabled:g,_object_init:function(f){var h,i=f?f.length:0;for(h=0;h<i;h++)e._object_extend(this,f[h]);e.generateGuid(this);this.init();i=(f=this.initMixin)?f.length:0;for(h=0;h<i;h++)f[h].call(this);
return this},mixin:function(){var f,h=arguments.length;for(f=0;f<h;f++)e.mixin(this,arguments[f]);for(f=0;f<h;f++){var i=arguments[f].initMixin;i&&i.call(this)}return this},init:function(){this.initObservable();return this},isDestroyed:d,destroy:function(){if(this.get("isDestroyed"))return this;this.set("isDestroyed",g);var f,h=this.destroyMixin,i=h?h.length:0;for(f=0;f<i;f++)h[f].call(this);return this},isObject:true,respondsTo:function(f){return e.typeOf(this[f])===e.T_FUNCTION},tryToPerform:function(f,
h,i){return this.respondsTo(f)&&this[f](h,i)!==d},superclass:function(){var f=arguments.callee.caller;if(!f)throw"superclass cannot determine the caller method";return f.superclass?f.superclass.apply(this,arguments):null},instanceOf:function(f){return this.constructor===f},kindOf:function(f){return this.constructor.kindOf(f)},toString:function(){if(!this._object_toString){var f=e._object_className(this.constructor),h="%@:%@".fmt(f,e.guidFor(this));if(f)this._object_toString=h;else return h}return this._object_toString},
awake:function(){this.outlets.forEach(function(f){this.get(f)},this);this.bindings.invoke("sync")},invokeOnce:function(f){e.RunLoop.currentRunLoop.invokeOnce(this,f);return this},invokeLast:function(f){e.RunLoop.currentRunLoop.invokeLast(this,f);return this},concatenatedProperties:["concatenatedProperties","initMixin","destroyMixin"]};e.Object.prototype.constructor=e.Object;e.mixin(e.Object.prototype,e.Observable);e.instanceOf=function(f,h){return!!(f&&f.constructor===h)};e.kindOf=function(f,h){if(f&&
!f.isClass)f=f.constructor;return!!(f&&f.kindOf&&f.kindOf(h))};e._object_className=function(f){if(!e.isReady)return"";f._object_className||b();if(f._object_className)return f._object_className;for(f=f;f&&!f._object_className;)f=f.superclass;return f&&f._object_className?f._object_className:"Anonymous"}});
tiki.module("sproutcore/runtime:system/range_observer",function(a){var b=a("sproutcore/runtime:core"),c=b.SC,e=b.YES,g=b.NO;a("sproutcore/runtime:private/observer_queue");a("sproutcore/runtime:system/index_set");c.RangeObserver={isRangeObserver:e,toString:function(){return(this.indexes?this.indexes.toString():"SC.IndexSet<..>").replace("IndexSet","RangeObserver(%@)".fmt(c.guidFor(this)))},create:function(d,f,h,i,j,k){var l=c.beget(this);l.source=d;l.indexes=f?f.frozenCopy():null;l.target=h;l.method=
i;l.context=j;l.isDeep=k||g;l.beginObserving();return l},extend:function(){var d=c.beget(this),f=arguments,h=f.length,i;for(i=0;i<h;i++)c.mixin(d,f[i]);return d},destroy:function(){this.endObserving();return this},update:function(d,f){if(this.indexes&&this.indexes.isEqual(f))return this;this.indexes=f?f.frozenCopy():null;this.endObserving().beginObserving();return this},beginObserving:function(){if(!this.isDeep)return this;var d=this.observing;if(!d)d=this.observing=c.CoreSet.create();var f=this._beginObservingForEach;
if(!f)f=this._beginObservingForEach=function(h){if((h=this.source.objectAt(h))&&h.addObserver){d.push(h);h._kvo_needsRangeObserver=e}};this.indexes.forEach(f,this);this.isObserving=g;c.Observers.addPendingRangeObserver(this);return this},setupPending:function(d){var f=this.observing;if(this.isObserving||!f||f.get("length")===0)return e;if(f.contains(d)){this.isObserving=e;d=this._setupPendingForEach;if(!d){var h=this.objectPropertyDidChange;d=this._setupPendingForEach=function(i){var j=this.source.objectAt(i),
k=c.guidFor(j);if(j&&j.addObserver){f.push(j);j.addObserver("*",this,h);j=this[k];if(j===undefined||j===null)this[k]=i;else if(j.isIndexSet)j.add(i);else this[k]=c.IndexSet.create(j).add(i)}}}this.indexes.forEach(d,this);return e}else return g},endObserving:function(){if(!this.isDeep)return this;var d=this.observing;if(this.isObserving){var f=this.objectPropertyDidChange,h,i,j;if(d){i=d.length;for(h=0;h<i;h++){j=d[h];j.removeObserver("*",this,f);this[c.guidFor(j)]=null}d.length=0}this.isObserving=
g}d&&d.clear();return this},rangeDidChange:function(d){var f=this.indexes;if(!d||!f||f.intersects(d)){this.endObserving();this.method.call(this.target,this.source,null,"[]",d,this.context);this.beginObserving()}return this},objectPropertyDidChange:function(d,f,h,i){h=this.context;var j=this.method,k=c.guidFor(d),l=this[k];if(l&&!l.isIndexSet)l=this[k]=c.IndexSet.create(l).freeze();h?j.call(this.target,this.source,d,f,l,h,i):j.call(this.target,this.source,d,f,l,i)}}});
tiki.module("sproutcore/runtime:system/run_loop",function(a){var b=a("sproutcore/runtime:core"),c=b.SC,e=b.YES,g=b.NO;a("sproutcore/runtime:private/observer_set");a("sproutcore/runtime:system/object");c.RunLoop=c.Object.extend({beginRunLoop:function(){this._start=(new Date).getTime();if(c.LOG_BINDINGS||c.LOG_OBSERVERS)console.log("-- SC.RunLoop.beginRunLoop at %@".fmt(this._start));return this},endRunLoop:function(){var d;if(c.LOG_BINDINGS||c.LOG_OBSERVERS)console.log("-- SC.RunLoop.endRunLoop ~ flushing application queues");
do(d=this.flushApplicationQueues())||(d=this._flushinvokeLastQueue());while(d);this._start=null;if(c.LOG_BINDINGS||c.LOG_OBSERVERS)console.log("-- SC.RunLoop.endRunLoop ~ End");return this},invokeOnce:function(d,f){if(f===undefined){f=d;d=this}if(c.typeOf(f)===c.T_STRING)f=d[f];if(!this._invokeQueue)this._invokeQueue=c.ObserverSet.create();this._invokeQueue.add(d,f);return this},invokeLast:function(d,f){if(f===undefined){f=d;d=this}if(c.typeOf(f)===c.T_STRING)f=d[f];if(!this._invokeLastQueue)this._invokeLastQueue=
c.ObserverSet.create();this._invokeLastQueue.add(d,f);return this},flushApplicationQueues:function(){var d=g,f=this._invokeQueue;if(f&&f.targets>0){this._invokeQueue=null;d=e;f.invokeMethods()}return c.Binding.flushPendingChanges()||d},_flushinvokeLastQueue:function(){var d=this._invokeLastQueue,f=g;if(d&&d.targets>0){this._invokeLastQueue=null;(f=e)&&d.invokeMethods()}return f}});c.RunLoop.currentRunLoop=null;c.RunLoop.runLoopClass=c.RunLoop;c.RunLoop.begin=function(){var d=this.currentRunLoop;if(!d)d=
this.currentRunLoop=this.runLoopClass.create();d.beginRunLoop();return this};c.RunLoop.end=function(){var d=this.currentRunLoop;if(!d)throw"SC.RunLoop.end() called outside of a runloop!";d.endRunLoop();return this};c.run=function(d,f){c.RunLoop.begin();d.call(f);c.RunLoop.end()}});
tiki.module("sproutcore/runtime:system/selection_set",function(a){var b=a("sproutcore/runtime:core"),c=b.SC,e=b.YES,g=b.NO;a("sproutcore/runtime:system/object");a("sproutcore/runtime:mixins/enumerable");a("sproutcore/runtime:mixins/copyable");a("sproutcore/runtime:mixins/freezable");a("sproutcore/runtime:system/set");a("sproutcore/runtime:system/index_set");c.SelectionSet=c.Object.extend(c.Enumerable,c.Freezable,c.Copyable,{isSelectionSet:e,length:function(){var d=0,f=this._sets,h=this._objects;if(h)d+=
h.get("length");f&&f.forEach(function(i){d+=i.get("length")});return d}.property().cacheable(),sources:function(){var d=[],f=this._sets,h=f?f.length:0,i,j;for(i=0;i<h;i++)(j=f[i])&&j.get("length")>0&&j.source&&d.push(j.source);return d}.property().cacheable(),indexSetForSource:function(d){if(!d||!d.isSCArray)return null;var f=this._indexSetCache,h=this._objects,i,j;if(!f)f=this._indexSetCache={};if((i=f[c.guidFor(d)])&&i._sourceRevision&&i._sourceRevision!==d.propertyRevision)i=null;if(!i){if((i=
this._indexSetForSource(d,g))&&i.get("length")===0)i=null;if(h){if(i)i=i.copy();h.forEach(function(k){if((j=d.indexOf(k))>=0){i||(i=c.IndexSet.create());i.add(j)}},this)}if(i){i=f[c.guidFor(d)]=i.frozenCopy();i._sourceRevision=d.propertyRevision}}return i},_indexSetForSource:function(d,f){if(f===undefined)f=e;var h=c.guidFor(d),i=this[h],j=this._sets,k=j?j.length:0,l=null;if(i>=k)i=null;if(c.none(i)){if(f&&!this.isFrozen){this.propertyWillChange("sources");if(!j)j=this._sets=[];l=j[k]=c.IndexSet.create();
l.source=d;this[h]=k;this.propertyDidChange("sources")}}else l=j?j[i]:null;return l},add:function(d,f,h){if(this.isFrozen)throw c.FROZEN_ERROR;var i,j,k;if(f===undefined&&h===undefined){if(!d)throw"Must pass params to SC.SelectionSet.add()";if(d.isIndexSet)return this.add(d.source,d);if(d.isSelectionSet){f=d._sets;j=d._objects;h=f?f.length:0;this.beginPropertyChanges();for(i=0;i<h;i++)(d=f[i])&&d.get("length")>0&&this.add(d.source,d);j&&this.addObjects(j);this.endPropertyChanges();return this}}d=
this._indexSetForSource(d,e);i=this.get("length");k=d.get("length");j=i-k;d.add(f,h);this._indexSetCache=null;j+=d.get("length");if(j!==i){this.propertyDidChange("length");this.enumerableContentDidChange();k===0&&this.notifyPropertyChange("sources")}return this},remove:function(d,f,h){if(this.isFrozen)throw c.FROZEN_ERROR;var i,j,k,l,o;if(f===undefined&&h===undefined){if(!d)throw"Must pass params to SC.SelectionSet.remove()";if(d.isIndexSet)return this.remove(d.source,d);if(d.isSelectionSet){i=d._sets;
o=d._objects;h=i?i.length:0;this.beginPropertyChanges();for(j=0;j<h;j++)(k=i[j])&&k.get("length")>0&&this.remove(k.source,k);o&&this.removeObjects(o);this.endPropertyChanges();return this}}k=this._indexSetForSource(d,e);i=this.get("length");l=i-k.get("length");if(k&&(o=this._objects)){if(h!==undefined){f=c.IndexSet.create(f,h);h=undefined}o.forEach(function(n){j=d.indexOf(n);if(f.contains(j)){o.remove(n);l--}},this)}k.remove(f,h);k=k.get("length");l+=k;this._indexSetCache=null;if(l!==i){this.propertyDidChange("length");
this.enumerableContentDidChange();k===0&&this.notifyPropertyChange("sources")}return this},contains:function(d,f,h){if(f===undefined&&h===undefined)return this.containsObject(d);d=this.indexSetForSource(d);if(!d)return g;return d.contains(f,h)},intersects:function(d,f,h){d=this.indexSetForSource(d,g);if(!d)return g;return d.intersects(f,h)},_TMP_ARY:[],addObject:function(d){var f=this._TMP_ARY;f[0]=d;d=this.addObjects(f);f.length=0;return d},addObjects:function(d){var f=this._objects,h;if(!f)f=this._objects=
c.CoreSet.create();h=f.get("length");f.addEach(d);d=f.get("length");this._indexSetCache=null;if(d!==h){this.propertyDidChange("length");this.enumerableContentDidChange()}return this},removeObject:function(d){var f=this._TMP_ARY;f[0]=d;d=this.removeObjects(f);f.length=0;return d},removeObjects:function(d){var f=this._objects,h,i;if(!f)return this;h=f.get("length");f.removeEach(d);i=f.get("length");if(f=this._sets)f.forEach(function(j){h+=j.get("length");j.removeObjects(d);i+=j.get("length")},this);
this._indexSetCache=null;if(i!==h){this.propertyDidChange("length");this.enumerableContentDidChange()}return this},containsObject:function(d){var f=this._objects;if(f&&f.contains(d))return e;var h=(f=this._sets)?f.length:0,i,j;for(i=0;i<h;i++)if((j=f[i])&&j.indexOf(d)>=0)return e;return g},constrain:function(d){var f,h,i;this.beginPropertyChanges();this.get("sources").forEach(function(j){if(j!==d)(j=this._indexSetForSource(d,g))&&this.remove(d,j)},this);if((f=this._indexSetForSource(d,g))&&(i=f.get("max"))>
(h=d.get("length")))this.remove(d,h,i-h);if(f=this._objects)f.forEach(function(j){d.indexOf(j)<0&&this.removeObject(j)},this);this.endPropertyChanges();return this},isEqual:function(d){var f,h,i,j;if(!d||!d.isSelectionSet)return g;if(d===this)return e;if(this._sets===d._sets&&this._objects===d._objects)return e;if(this.get("length")!==d.get("length"))return g;f=this._objects;h=d._objects;if(f||h){if((f?f.get("length"):0)!==(h?h.get("length"):0))return g;if(f&&!f.isEqual(h))return g}j=this.get("sources");
i=j.get("length");for(d=0;d<i;d++){h=j.objectAt(d);f=this._indexSetForSource(h,g);h=this._indexSetForSource(h,g);if(!!h!==!!f)return g;if(f&&!f.isEqual(h))return g}return e},clear:function(){if(this.isFrozen)throw c.FROZEN_ERROR;if(this._sets)this._sets.length=0;if(this._objects)this._objects=null;this._indexSetCache=null;this.propertyDidChange("length");this.enumerableContentDidChange();this.notifyPropertyChange("sources");return this},copy:function(){var d=this.constructor.create(),f=this._sets,
h=f?f.length:0,i,j;if(f&&h>0){f=d._sets=f.slice();for(i=0;i<h;i++)if(j=f[i]){j=f[i]=j.copy();d[c.guidFor(j.source)]=i}}if(this._objects)d._objects=this._objects.copy();return d},freeze:function(){if(this.isFrozen)return this;for(var d=this._sets,f=d?d.length:0,h;--f>=0;)if(h=d[f])h.freeze();this._objects&&this._objects.freeze();return arguments.callee.base.apply(this,arguments)},toString:function(){var d=this._sets||[];d=d.map(function(f){return f.toString().replace("SC.IndexSet",c.guidFor(f.source))},
this);this._objects&&d.push(this._objects.toString());return"SC.SelectionSet:%@<%@>".fmt(c.guidFor(this),d.join(","))},firstObject:function(){var d=this._sets,f=this._objects;if(d&&d.get("length")>0){var h=d?d[0]:null;d=h?h.source:null;h=h?h.firstObject():-1;if(d&&h>=0)return d.objectAt(h)}return f?f.firstObject():undefined}.property(),nextObject:function(d,f,h){var i;if(d===0){i=h.objects=[];this.forEach(function(j){i.push(j)},this);h.max=i.length}i=h.objects;f=i[d];if(d+1>=h.max)h.objects=h.max=
null;return f},forEach:function(d,f){var h=this._sets,i=this._objects,j=h?h.length:0,k,l;for(l=0;l<j;l++)(k=h[l])&&k.forEachObject(d,f);i&&i.forEach(d,f);return this}});c.SelectionSet.prototype.clone=c.SelectionSet.prototype.copy;c.SelectionSet.EMPTY=c.SelectionSet.create().freeze()});
tiki.module("sproutcore/runtime:system/set",function(a){var b=a("sproutcore/runtime:core"),c=b.SC,e=b.YES,g=b.NO;a("sproutcore/runtime:mixins/enumerable");a("sproutcore/runtime:mixins/copyable");a("sproutcore/runtime:mixins/freezable");a("sproutcore/runtime:mixins/observable");c.Set=c.mixin({},c.Enumerable,c.Observable,c.Freezable,{create:function(d){var f,h;h=c.Set._pool;var i=this.isObservable;if(!i&&d===undefined&&h.length>0)f=h.pop();else{f=c.beget(this);i&&f.initObservable();if(d&&d.isEnumerable&&
d.get("length")>0){f.isObservable=g;if(d.isSCArray)for(h=d.get?d.get("length"):d.length;--h>=0;)f.add(d.objectAt(h));else if(d.isSet)for(h=d.length;--h>=0;)f.add(d[h]);else d.forEach(function(j){f.add(j)},this);f.isObservable=i}}return f},isSet:e,length:0,firstObject:function(){return this.length>0?this[0]:undefined}.property(),clear:function(){if(this.isFrozen)throw c.FROZEN_ERROR;this.length=0;return this},contains:function(d){if(d===null)return g;var f=this[c.hashFor(d)];return!c.none(f)&&f<this.length&&
this[f]===d},isEqual:function(d){if(!d||!d.isSet||d.get("length")!==this.get("length"))return g;for(var f=this.get("length");--f>=0;)if(!d.contains(this[f]))return g;return e},add:function(d){if(this.isFrozen)throw c.FROZEN_ERROR;if(d===null||d===undefined)return this;var f=c.hashFor(d),h=this[f],i=this.length;if(h===null||h===undefined||h>=i||this[h]!==d){this[i]=d;this[f]=i;this.length=i+1}this.isObservable&&this.enumerableContentDidChange();return this},addEach:function(d){if(this.isFrozen)throw c.FROZEN_ERROR;
if(!d||!d.isEnumerable)throw"%@.addEach must pass enumerable".fmt(this);var f,h=this.isObservable;h&&this.beginPropertyChanges();if(d.isSCArray)for(f=d.get("length");--f>=0;)this.add(d.objectAt(f));else if(d.isSet)for(f=d.length;--f>=0;)this.add(d[f]);else d.forEach(function(i){this.add(i)},this);h&&this.endPropertyChanges();return this},remove:function(d){if(this.isFrozen)throw c.FROZEN_ERROR;if(c.none(d))return this;var f=c.hashFor(d),h=this[f],i=this.length;if(c.none(h)||h>=i||this[h]!==d)return this;
delete this[f];if(h<i-1){d=this[h]=this[i-1];this[c.hashFor(d)]=h}this.length=i-1;this.isObservable&&this.enumerableContentDidChange();return this},pop:function(){if(this.isFrozen)throw c.FROZEN_ERROR;var d=this.length>0?this[this.length-1]:null;d&&this.remove(d);return d},removeEach:function(d){if(this.isFrozen)throw c.FROZEN_ERROR;if(!d||!d.isEnumerable)throw"%@.addEach must pass enumerable".fmt(this);var f,h=this.isObservable;h&&this.beginPropertyChanges();if(d.isSCArray)for(f=d.get("length");--f>=
0;)this.remove(d.objectAt(f));else if(d.isSet)for(f=d.length;--f>=0;)this.remove(d[f]);else d.forEach(function(i){this.remove(i)},this);h&&this.endPropertyChanges();return this},copy:function(){return this.constructor.create(this)},destroy:function(){this.isFrozen=g;this.isObservable||c.Set._pool.push(this.clear());return this},forEach:function(d,f){var h=this.length;f||(f=this);for(var i=0;i<h;i++)d.call(f,this[i],i,this);return this},toString:function(){var d=this.length,f,h=[];for(f=0;f<d;f++)h[f]=
this[f];return"SC.Set<%@>".fmt(h.join(","))},_pool:[],isObservable:e});c.Set.constructor=c.Set;c.Set.clone=c.Set.copy;c.Set.push=c.Set.unshift=c.Set.add;c.Set.shift=c.Set.pop;c.Set.addObject=c.Set.add;c.Set.removeObject=c.Set.remove;c.Set._pool=[];c.CoreSet=c.beget(c.Set);c.CoreSet.isObservable=g;c.CoreSet.constructor=c.CoreSet});
tiki.module("sproutcore/runtime:system/sparse_array",function(a){var b=a("sproutcore/runtime:core"),c=b.SC,e=b.YES,g=b.NO;a("sproutcore/runtime:system/index_set");a("sproutcore/runtime:system/object");a("sproutcore/runtime:mixins/enumerable");a("sproutcore/runtime:mixins/array");a("sproutcore/runtime:mixins/delegate_support");c.SparseArray=c.Object.extend(c.Enumerable,c.Array,c.DelegateSupport,{_requestingLength:0,_requestingIndex:0,length:function(){var d=this.delegate;if(d&&c.none(this._length)&&
d.sparseArrayDidRequestLength){this._requestingLength++;d.sparseArrayDidRequestLength(this);this._requestingLength--}return this._length||0}.property().cacheable(),provideLength:function(d){if(c.none(d))this._sa_content=null;if(d!==this._length){this._length=d;this._requestingLength<=0&&this.enumerableContentDidChange()}return this},rangeWindowSize:1,requestedRangeIndex:[],objectAt:function(d){var f=this._sa_content,h;if(!f)f=this._sa_content=[];if((h=f[d])===undefined){this.requestIndex(d);h=f[d]}return h},
definedIndexes:function(d){var f=c.IndexSet.create(),h=this._sa_content,i;if(!h)return f.freeze();if(d)d.forEach(function(j){h[j]!==undefined&&f.add(j)});else{i=h.length;for(d=0;d<i;d++)h[d]!==undefined&&f.add(d)}return f.freeze()},_TMP_RANGE:{},requestIndex:function(d){var f=this.delegate;if(!f)return this;var h=this.get("rangeWindowSize");d=d;if(h>1)d-=Math.floor(d%h);if(h<1)h=1;this._requestingIndex++;if(f.sparseArrayDidRequestRange){var i=this._TMP_RANGE;if(this.wasRangeRequested(d)===-1){i.start=
d;i.length=h;f.sparseArrayDidRequestRange(this,i);this.requestedRangeIndex.push(d)}}else if(f.sparseArrayDidRequestIndex)for(;--h>=0;)f.sparseArrayDidRequestIndex(this,d+h);this._requestingIndex--;return this},wasRangeRequested:function(d){var f,h;f=0;for(h=this.requestedRangeIndex.length;f<h;f++)if(this.requestedRangeIndex[f]===d)return f;return-1},rangeRequestCompleted:function(d){d=this.wasRangeRequested(d);if(d>=0){this.requestedRangeIndex.removeAt(d,1);return e}return g},provideObjectsInRange:function(d,
f){var h=this._sa_content;if(!h)h=this._sa_content=[];var i=d.start;for(d=d.length;--d>=0;)h[i+d]=f[d];this._requestingIndex<=0&&this.enumerableContentDidChange();return this},_TMP_PROVIDE_ARRAY:[],_TMP_PROVIDE_RANGE:{length:1},provideObjectAtIndex:function(d,f){var h=this._TMP_PROVIDE_ARRAY,i=this._TMP_PROVIDE_RANGE;h[0]=f;i.start=d;return this.provideObjectsInRange(i,h)},objectsDidChangeInRange:function(d){var f=this._sa_content;if(f)if(d.start===0&&c.maxRange(d)>=f.length)this._sa_content=null;
else for(var h=d.start,i=Math.min(h+d.length,f.length);--i>=h;)f[i]=undefined;this.enumerableContentDidChange(d);return this},indexOf:function(d){var f=this.delegate;if(f&&f.sparseArrayDidRequestIndexOf)return f.sparseArrayDidRequestIndexOf(this,d);else{f=this._sa_content;if(!f)f=this._sa_content=[];return f.indexOf(d)}},replace:function(d,f,h){h=h||[];var i=this.delegate;if(i)if(!i.sparseArrayShouldReplace||!i.sparseArrayShouldReplace(this,d,f,h))return this;i=this._sa_content;if(!i)i=this._sa_content=
[];i.replace(d,f,h);h=(h?h.get?h.get("length"):h.length:0)-f;if(!c.none(this._length)){this.propertyWillChange("length");this._length+=h;this.propertyDidChange("length")}this.enumerableContentDidChange(d,f,h);return this},reset:function(){this._length=this._sa_content=null;this.enumerableContentDidChange();this.invokeDelegateMethod(this.delegate,"sparseArrayDidReset",this);return this}});c.SparseArray.array=function(d){return this.create({_length:d||0})}});
tiki.module("sproutcore/runtime:index",function(a,b){var c;c=a("sproutcore/runtime:core");b.SC=c.SC;b.SproutCore=c.SproutCore;b.YES=c.YES;b.NO=c.NO;a("sproutcore/runtime:mixins/array");a("sproutcore/runtime:mixins/comparable");a("sproutcore/runtime:mixins/copyable");a("sproutcore/runtime:mixins/delegate_support");a("sproutcore/runtime:mixins/enumerable");a("sproutcore/runtime:mixins/freezable");a("sproutcore/runtime:mixins/observable");a("sproutcore/runtime:system/binding");a("sproutcore/runtime:system/cookie");
a("sproutcore/runtime:system/enumerator");a("sproutcore/runtime:system/error");a("sproutcore/runtime:system/index_set");a("sproutcore/runtime:system/logger");a("sproutcore/runtime:system/object");a("sproutcore/runtime:system/range_observer");a("sproutcore/runtime:system/run_loop");a("sproutcore/runtime:system/selection_set");a("sproutcore/runtime:system/set");a("sproutcore/runtime:system/sparse_array")});tiki.script("sproutcore/runtime:en/cfe6f8a7557f916515999a065d70bfa71bd13986/javascript.js");
tiki.register("sproutcore/datastore",{packages:{"sproutcore/runtime":{scripts:[{url:"/static/sproutcore/runtime/en/cfe6f8a7557f916515999a065d70bfa71bd13986/javascript.js",id:"sproutcore/runtime:en/cfe6f8a7557f916515999a065d70bfa71bd13986/javascript.js"}]}},depends:["sproutcore/runtime"],scripts:[{url:"/static/sproutcore/datastore/en/334c3630f54926a13d0810d33b3686af21530ee7/javascript.js",id:"sproutcore/datastore:en/334c3630f54926a13d0810d33b3686af21530ee7/javascript.js"}]});
tiki.module("sproutcore/datastore:index",function(){});tiki.script("sproutcore/datastore:en/334c3630f54926a13d0810d33b3686af21530ee7/javascript.js");
tiki.register("sproutcore/foundation",{packages:{"sproutcore/runtime":{scripts:[{url:"/static/sproutcore/runtime/en/cfe6f8a7557f916515999a065d70bfa71bd13986/javascript.js",id:"sproutcore/runtime:en/cfe6f8a7557f916515999a065d70bfa71bd13986/javascript.js"}]}},stylesheets:[{url:"/static/sproutcore/foundation/en/d5356c4dc5eed765f3239fcaaa4b599b3de5c4b0/stylesheet.css",id:"sproutcore/foundation:en/d5356c4dc5eed765f3239fcaaa4b599b3de5c4b0/stylesheet.css"}],depends:["sproutcore/runtime"],scripts:[{url:"/static/sproutcore/foundation/en/d5356c4dc5eed765f3239fcaaa4b599b3de5c4b0/javascript.js",
id:"sproutcore/foundation:en/d5356c4dc5eed765f3239fcaaa4b599b3de5c4b0/javascript.js"}]});tiki.global("sproutcore/foundation");
SC.Locale=SC.Object.extend({init:function(){this.language||SC.Locale._assignLocales();if(!this.hasStrings){var a=this._deprecatedLanguageCodes||[];a.push(this.language);for(var b=a.length,c=null;!c&&--b>=0;)c=String[a[b]];if(c){this.hasStrings=YES;this.strings=c}}},hasStrings:NO,strings:{},toString:function(){this.language||SC.Locale._assignLocales();return"SC.Locale["+this.language+"]"+SC.guidFor(this)},locWithDefault:function(a,b){return this.strings[a]||b||a}});
SC.Locale.mixin({useAutodetectedLanguage:NO,preferredLanguage:null,createCurrentLocale:function(){var a=String.preferredLanguage!==undefined?String.preferredLanguage:this.preferredLanguage;a=((String.useAutodetectedLanguage!==undefined?String.useAutodetectedLanguage:this.useAutodetectedLanguage)?SC.browser.language:null)||a||SC.browser.language||"en";a=SC.Locale.normalizeLanguage(a);var b=this.localeClassFor(a);if(a!=this.currentLanguage){this.currentLanguage=a;this.currentLocale=b.create()}return this.currentLocale},
localeClassFor:function(a){a=SC.Locale.normalizeLanguage(a);var b,c=this.locales[a];if(!c&&(b=a.split("-")[0])!==a&&(c=this.locales[b]))c=this.locales[a]=c.extend();c||(c=this.locales[a]=this.locales.en.extend());return c},define:function(a,b){var c;if(b===undefined&&SC.typeOf(a)!==SC.T_STRING){c=this;b=a}else c=SC.Locale.localeClassFor(a);SC.mixin(c.prototype,b);return c},options:function(){return this.prototype},addStrings:function(a){var b=this.prototype.strings;if(b){if(!this.prototype.hasOwnProperty("strings"))this.prototype.strings=
SC.clone(b)}else b=this.prototype.strings={};if(a)this.prototype.strings=SC.mixin(b,a);this.prototype.hasStrings=YES;return this},_map:{english:"en",french:"fr",german:"de",japanese:"ja",jp:"ja",spanish:"es"},normalizeLanguage:function(a){if(!a)return"en";return SC.Locale._map[a.toLowerCase()]||a},_assignLocales:function(){for(var a in this.locales)this.locales[a].prototype.language=a},toString:function(){this.prototype.language||SC.Locale._assignLocales();return"SC.Locale["+this.prototype.language+
"]"},extend:function(){var a=SC.Object.extend.apply(this,arguments);a.addStrings=SC.Locale.addStrings;a.define=SC.Locale.define;a.options=SC.Locale.options;a.toString=SC.Locale.toString;return a}});SC.Locale.locales={en:SC.Locale.extend({_deprecatedLanguageCodes:["English"]}),fr:SC.Locale.extend({_deprecatedLanguageCodes:["French"]}),de:SC.Locale.extend({_deprecatedLanguageCodes:["German"]}),ja:SC.Locale.extend({_deprecatedLanguageCodes:["Japanese","jp"]}),es:SC.Locale.extend({_deprecatedLanguageCodes:["Spanish"]})};
SC.stringsFor=function(a,b){SC.Locale.localeClassFor(a).addStrings(b);return this};sc_require("system/locale");SC.stringsFor("English",{"_SC.DateTime.dayNames":"Sunday Monday Tuesday Wednesday Thursday Friday Saturday","_SC.DateTime.abbreviatedDayNames":"Sun Mon Tue Wed Thu Fri Sat","_SC.DateTime.monthNames":"January February March April May June July August September October November December","_SC.DateTime.abbreviatedMonthNames":"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"});SC.DROP_ON=1;
SC.DROP_BEFORE=2;SC.DROP_AFTER=4;SC.DROP_ANY=7;SC.mixin({data:function(a,b,c){a=a===window?"@window":a;a=SC.hashFor(a);var e=SC._data_cache;if(!e)SC._data_cache=e={};var g=e[a];if(b&&!g)e[a]=g={};if(g&&c!==undefined)g[b]=c;return b?g[b]:g},removeData:function(a,b){a=a===window?"@window":a;a=SC.hashFor(a);var c=SC._data_cache;if(c){var e=c[a];if(e){var g=b?e[b]:e;if(b)delete e[b];else delete c[a];return g}}}});
SC.mixin(Function.prototype,{invokeLater:function(a,b){if(b===undefined)b=1;var c=this;if(arguments.length>2){var e=SC.$A(arguments).slice(2,arguments.length);e.unshift(a);var g=this,d=c;c=function(){return d.apply(g,e.slice(1))}}return SC.Timer.schedule({target:a,action:c,interval:b})}});SC.Controller=SC.Object.extend({isEditable:YES});
SC.mixin(SC.Object.prototype,{invokeLater:function(a,b){if(b===undefined)b=1;var c=a,e,g;if(arguments.length>2){e=SC.$A(arguments).slice(2);if(SC.typeOf(c)===SC.T_STRING)c=this[a];g=c;c=function(){return g.apply(this,e)}}return SC.Timer.schedule({target:this,action:c,interval:b})},invokeWith:function(a,b,c){if(c===undefined){c=b;b=this}b||(b=this);if(SC.typeOf(c)===SC.T_STRING)c=b[c];a=this.getPath(a);c.call(b,a,this);return this}});
SC.RunLoop=SC.RunLoop.extend({startTime:function(){if(!this._start)this._start=Date.now();return this._start}.property(),endRunLoop:function(){this.fireExpiredTimers();var a=arguments.callee.base.apply(this,arguments);this.scheduleNextTimeout();return a},scheduleTimer:function(a,b){this._timerQueue=a.removeFromTimerQueue(this._timerQueue);this._timerQueue=a.scheduleInTimerQueue(this._timerQueue,b);return this},cancelTimer:function(a){this._timerQueue=a.removeFromTimerQueue(this._timerQueue);return this},
TIMER_ARRAY:[],fireExpiredTimers:function(){if(!this._timerQueue||this._firing)return NO;var a=this.get("startTime");this._firing=YES;var b=this.TIMER_ARRAY;this._timerQueue=this._timerQueue.collectExpiredTimers(b,a);var c=b.length;for(a=0;a<c;a++)b[a].fire();a=b.length>0;b.length=0;this._firing=NO;return a},scheduleNextTimeout:function(){var a=this._timerQueue,b=NO;if(a){a=a._timerQueueRunTime;if(this._timeoutAt!==a){this._timeout&&clearTimeout(this._timeout);b=Math.max(0,a-Date.now());this._timeout=
setTimeout(this._timeoutDidFire,b);this._timeoutAt=a}b=YES}else this._timeout&&clearTimeout(this._timeout);return b},_timeoutDidFire:function(){var a=SC.RunLoop.currentRunLoop;a._timeout=a._timeoutAt=null;SC.RunLoop.begin().end()}});SC.RunLoop.currentRunLoop=SC.RunLoop.create();
SC.Button={value:null,toggleOnValue:YES,toggleOffValue:NO,localize:NO,localizeBindingDefault:SC.Binding.bool(),title:"",contentTitleKey:null,icon:null,contentIconKey:null,needsEllipsis:YES,displayTitle:function(){var a=this.get("title");return a&&this.get("localize")?a.loc():a||""}.property("title","localize").cacheable(),keyEquivalent:null,renderTitle:function(a,b){var c=this.get("icon"),e="",g=this.get("displayTitle"),d=!SC.none(g)&&g.length>0;if(c){d=SC.BLANK_IMAGE_URL;e='<img src="%@1" alt="" class="%@2" />';
e=c.indexOf("/")>=0?e.fmt(c,"icon"):e.fmt(d,c);d=YES}c=this.$("label");if(b)this.get("needsEllipsis")?a.push('<label class="sc-button-label ellipsis">'+e+g+"</label>"):a.push('<label class="sc-button-label">'+e+g+"</label>");else if(b=c[0])if(d){this.get("needsEllipsis")?c.addClass("ellipsis"):c.removeClass("ellipsis");b.innerHTML=e+g}else b.innerHTML="";return a},contentPropertyDidChange:function(a,b){var c=this.get("displayDelegate");a=this.get("content");var e=this.getDelegateProperty("contentValueKey",
c);if(e&&(b===e||b==="*"))this.set("value",a?a.get(e):null);if((e=this.getDelegateProperty("contentTitleKey",c))&&(b===e||b==="*"))this.set("title",a?a.get(e):null);if((c=this.getDelegateProperty("contentIconKey",c))&&(b===c||b==="*"))this.set("icon",a?a.get(c):null);return this},_button_displayObserver:function(){this.displayDidChange()}.observes("title","icon","value"),performKeyEquivalent:function(a,b){if(!this.get("isEnabled"))return NO;var c=this.get("keyEquivalent");if(c){if(c===a)return this.triggerAction(b)}else if(this.get("isDefault")&&
a==="return"||this.get("isCancel")&&a==="escape")return this.triggerAction(b);return NO},triggerAction:function(){throw"SC.Button.triggerAction() is not defined in %@".fmt(this);},computeIsSelectedForValue:function(a){var b=this.get("toggleOnValue"),c,e;if(SC.typeOf(a)===SC.T_ARRAY)if(a.length===1)c=a[0]==b;else{c=null;a.find(function(g){e=g==b;if(c===null)c=e;else if(e!==c)c=SC.MIXED_STATE;return c===SC.MIXED_STATE})}else c=a==b;return c},initMixin:function(){SC.none(this.get("value"))||this._button_valueDidChange()},
_button_valueDidChange:function(){this.set("isSelected",this.computeIsSelectedForValue(this.get("value")))}.observes("value"),_button_isSelectedDidChange:function(){var a=this.get("isSelected"),b=this.computeIsSelectedForValue(this.get("value"));if(a!==SC.MIXED_STATE&&b!==a)this.set("value",this.get(a?"toggleOnValue":"toggleOffValue"))}.observes("isSelected")};SC.BRANCH_OPEN=17;SC.BRANCH_CLOSED=18;SC.LEAF_NODE=32;
SC.CollectionContent={isCollectionContent:YES,contentIndexIsSelected:function(a,b,c){return(a=a.get("selection"))?a.contains(b,c):NO},contentIndexIsEnabled:function(a){return a.get("isEnabled")},contentGroupIndexes:function(){return null},contentIndexIsGroup:function(){return NO},contentIndexOutlineLevel:function(){return-1},contentIndexDisclosureState:function(){return SC.LEAF_NODE},contentIndexExpand:function(a,b,c){console.log("contentIndexExpand(%@, %@, %@)".fmt(a,b,c))},contentIndexCollapse:function(a,
b,c){console.log("contentIndexCollapse(%@, %@, %@)".fmt(a,b,c))}};
SC.ContentDisplay={concatenatedProperties:"contentDisplayProperties",displayProperties:["content"],contentDisplayProperties:[],_display_contentDidChange:function(a,b,c){if((c=this.get("content"))!=this._display_content){a=this._display_contentPropertyDidChange;if(b=this._display_content)if(SC.isArray(b))b.invoke("removeObserver","*",this,a);else b.removeObserver&&b.removeObserver("*",this,a);if(b=this._display_content=c)if(SC.isArray(b))b.invoke("addObserver","*",this,a);else b.addObserver&&b.addObserver("*",
this,a);this.allPropertiesDidChange();this.endPropertyChanges()}}.observes("content"),_display_contentPropertyDidChange:function(a,b){if(b==="*")this.displayDidChange();else(a=this.get("contentDisplayProperties"))&&a.indexOf(b)>=0&&this.displayDidChange()}};sc_require("system/locale");SC.STRING_TITLEIZE_REGEXP=/([\s|\-|\_|\n])([^\s|\-|\_|\n]?)/g;
SC.String={loc:function(){SC.Locale.currentLocale||SC.Locale.createCurrentLocale();var a=SC.Locale.currentLocale.locWithDefault(this)||this;return a.fmt.apply(a,arguments)},locWithDefault:function(a){SC.Locale.currentLocale||SC.Locale.createCurrentLocale();var b=SC.Locale.currentLocale.locWithDefault(a)||this,c=SC.$A(arguments);c.shift();return b.fmt.apply(b,c)},capitalize:function(){return this.charAt(0).toUpperCase()+this.slice(1)},capitalizeEach:function(){return this.replace(SC.STRING_TITLEIZE_REGEXP,
function(a,b,c){return c?b+c.toUpperCase():b}).capitalize()},titleize:function(){return this.replace(/([a-z])([A-Z])/g,"$1_$2").replace(SC.STRING_TITLEIZE_REGEXP,function(a,b,c){return c?" "+c.toUpperCase():" "}).capitalize()},camelize:function(){var a=this.replace(SC.STRING_TITLEIZE_REGEXP,function(e,g,d){return d?d.toUpperCase():""}),b=a.charAt(0),c=b.toLowerCase();return b!==c?c+a.slice(1):a},classify:function(){var a=this.replace(SC.STRING_TITLEIZE_REGEXP,function(e,g,d){return d?d.toUpperCase():
""}),b=a.charAt(0),c=b.toUpperCase();return b!==c?c+a.slice(1):a},decamelize:function(){return this.replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase()},dasherize:function(){return this.decamelize().replace(/[ _]/g,"-")},humanize:function(){return this.decamelize().replace(/[\-_]/g," ")},removeDiacritics:function(){var a=SC.diacriticMappingTable;if(!a){SC.diacriticMappingTable={"\u00c0":"A","\u00c1":"A","\u00c2":"A","\u00c3":"A","\u00c4":"A","\u00c5":"A","\u0100":"A","\u0102":"A","\u0104":"A","\u01cd":"A",
"\u01de":"A","\u01e0":"A","\u01fa":"A","\u0200":"A","\u0202":"A","\u0226":"A","\u1e00":"A","\u1ea0":"A","\u1ea2":"A","\u1ea4":"A","\u1ea6":"A","\u1ea8":"A","\u1eaa":"A","\u1eac":"A","\u1eae":"A","\u1eb0":"A","\u1eb2":"A","\u1eb4":"A","\u1eb6":"A","\u212b":"A","\u1e02":"B","\u1e04":"B","\u1e06":"B","\u00c7":"C","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u1e08":"C","\u010e":"D","\u1e0a":"D","\u1e0c":"D","\u1e0e":"D","\u1e10":"D","\u1e12":"D","\u00c8":"E","\u00c9":"E","\u00ca":"E","\u00cb":"E",
"\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0204":"E","\u0206":"E","\u0228":"E","\u1e14":"E","\u1e16":"E","\u1e18":"E","\u1e1a":"E","\u1e1c":"E","\u1eb8":"E","\u1eba":"E","\u1ebc":"E","\u1ebe":"E","\u1ec0":"E","\u1ec2":"E","\u1ec4":"E","\u1ec6":"E","\u1e1e":"F","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u01e6":"G","\u01f4":"G","\u1e20":"G","\u0124":"H","\u021e":"H","\u1e22":"H","\u1e24":"H","\u1e26":"H","\u1e28":"H","\u1e2a":"H","\u00cc":"I","\u00cd":"I","\u00ce":"I",
"\u00cf":"I","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u01cf":"I","\u0208":"I","\u020a":"I","\u1e2c":"I","\u1e2e":"I","\u1ec8":"I","\u1eca":"I","\u0134":"J","\u0136":"K","\u01e8":"K","\u1e30":"K","\u1e32":"K","\u1e34":"K","\u0139":"L","\u013b":"L","\u013d":"L","\u1e36":"L","\u1e38":"L","\u1e3a":"L","\u1e3c":"L","\u1e3e":"M","\u1e40":"M","\u1e42":"M","\u00d1":"N","\u0143":"N","\u0145":"N","\u0147":"N","\u01f8":"N","\u1e44":"N","\u1e46":"N","\u1e48":"N","\u1e4a":"N","\u00d2":"O",
"\u00d3":"O","\u00d4":"O","\u00d5":"O","\u00d6":"O","\u014c":"O","\u014e":"O","\u0150":"O","\u01a0":"O","\u01d1":"O","\u01ea":"O","\u01ec":"O","\u020c":"O","\u020e":"O","\u022a":"O","\u022c":"O","\u022e":"O","\u0230":"O","\u1e4c":"O","\u1e4e":"O","\u1e50":"O","\u1e52":"O","\u1ecc":"O","\u1ece":"O","\u1ed0":"O","\u1ed2":"O","\u1ed4":"O","\u1ed6":"O","\u1ed8":"O","\u1eda":"O","\u1edc":"O","\u1ede":"O","\u1ee0":"O","\u1ee2":"O","\u1e54":"P","\u1e56":"P","\u0154":"R","\u0156":"R","\u0158":"R","\u0210":"R",
"\u0212":"R","\u1e58":"R","\u1e5a":"R","\u1e5c":"R","\u1e5e":"R","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u0218":"S","\u1e60":"S","\u1e62":"S","\u1e64":"S","\u1e66":"S","\u1e68":"S","\u0162":"T","\u0164":"T","\u021a":"T","\u1e6a":"T","\u1e6c":"T","\u1e6e":"T","\u1e70":"T","\u00d9":"U","\u00da":"U","\u00db":"U","\u00dc":"U","\u0168":"U","\u016a":"U","\u016c":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u01af":"U","\u01d3":"U","\u01d5":"U","\u01d7":"U","\u01d9":"U","\u01db":"U","\u0214":"U",
"\u0216":"U","\u1e72":"U","\u1e74":"U","\u1e76":"U","\u1e78":"U","\u1e7a":"U","\u1ee4":"U","\u1ee6":"U","\u1ee8":"U","\u1eea":"U","\u1eec":"U","\u1eee":"U","\u1ef0":"U","\u1e7c":"V","\u1e7e":"V","\u0174":"W","\u1e80":"W","\u1e82":"W","\u1e84":"W","\u1e86":"W","\u1e88":"W","\u1e8a":"X","\u1e8c":"X","\u00dd":"Y","\u0176":"Y","\u0178":"Y","\u0232":"Y","\u1e8e":"Y","\u1ef2":"Y","\u1ef4":"Y","\u1ef6":"Y","\u1ef8":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u1e90":"Z","\u1e92":"Z","\u1e94":"Z","\u1fef":"`",
"\u00e0":"a","\u00e1":"a","\u00e2":"a","\u00e3":"a","\u00e4":"a","\u00e5":"a","\u0101":"a","\u0103":"a","\u0105":"a","\u01ce":"a","\u01df":"a","\u01e1":"a","\u01fb":"a","\u0201":"a","\u0203":"a","\u0227":"a","\u1e01":"a","\u1ea1":"a","\u1ea3":"a","\u1ea5":"a","\u1ea7":"a","\u1ea9":"a","\u1eab":"a","\u1ead":"a","\u1eaf":"a","\u1eb1":"a","\u1eb3":"a","\u1eb5":"a","\u1eb7":"a","\u1e03":"b","\u1e05":"b","\u1e07":"b","\u00e7":"c","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u1e09":"c","\u010f":"d",
"\u1e0b":"d","\u1e0d":"d","\u1e0f":"d","\u1e11":"d","\u1e13":"d","\u00e8":"e","\u00e9":"e","\u00ea":"e","\u00eb":"e","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u0205":"e","\u0207":"e","\u0229":"e","\u1e15":"e","\u1e17":"e","\u1e19":"e","\u1e1b":"e","\u1e1d":"e","\u1eb9":"e","\u1ebb":"e","\u1ebd":"e","\u1ebf":"e","\u1ec1":"e","\u1ec3":"e","\u1ec5":"e","\u1ec7":"e","\u1e1f":"f","\u011d":"g","\u011f":"g","\u0121":"g","\u0123":"g","\u01e7":"g","\u01f5":"g","\u1e21":"g","\u0125":"h",
"\u021f":"h","\u1e23":"h","\u1e25":"h","\u1e27":"h","\u1e29":"h","\u1e2b":"h","\u1e96":"h","\u00ec":"i","\u00ed":"i","\u00ee":"i","\u00ef":"i","\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u01d0":"i","\u0209":"i","\u020b":"i","\u1e2d":"i","\u1e2f":"i","\u1ec9":"i","\u1ecb":"i","\u0135":"j","\u01f0":"j","\u0137":"k","\u01e9":"k","\u1e31":"k","\u1e33":"k","\u1e35":"k","\u013a":"l","\u013c":"l","\u013e":"l","\u1e37":"l","\u1e39":"l","\u1e3b":"l","\u1e3d":"l","\u1e3f":"m","\u1e41":"m","\u1e43":"m",
"\u00f1":"n","\u0144":"n","\u0146":"n","\u0148":"n","\u01f9":"n","\u1e45":"n","\u1e47":"n","\u1e49":"n","\u1e4b":"n","\u00f2":"o","\u00f3":"o","\u00f4":"o","\u00f5":"o","\u00f6":"o","\u014d":"o","\u014f":"o","\u0151":"o","\u01a1":"o","\u01d2":"o","\u01eb":"o","\u01ed":"o","\u020d":"o","\u020f":"o","\u022b":"o","\u022d":"o","\u022f":"o","\u0231":"o","\u1e4d":"o","\u1e4f":"o","\u1e51":"o","\u1e53":"o","\u1ecd":"o","\u1ecf":"o","\u1ed1":"o","\u1ed3":"o","\u1ed5":"o","\u1ed7":"o","\u1ed9":"o","\u1edb":"o",
"\u1edd":"o","\u1edf":"o","\u1ee1":"o","\u1ee3":"o","\u1e55":"p","\u1e57":"p","\u0155":"r","\u0157":"r","\u0159":"r","\u0211":"r","\u0213":"r","\u1e59":"r","\u1e5b":"r","\u1e5d":"r","\u1e5f":"r","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0219":"s","\u1e61":"s","\u1e63":"s","\u1e65":"s","\u1e67":"s","\u1e69":"s","\u0163":"t","\u0165":"t","\u021b":"t","\u1e6b":"t","\u1e6d":"t","\u1e6f":"t","\u1e71":"t","\u1e97":"t","\u00f9":"u","\u00fa":"u","\u00fb":"u","\u00fc":"u","\u0169":"u","\u016b":"u",
"\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u01b0":"u","\u01d4":"u","\u01d6":"u","\u01d8":"u","\u01da":"u","\u01dc":"u","\u0215":"u","\u0217":"u","\u1e73":"u","\u1e75":"u","\u1e77":"u","\u1e79":"u","\u1e7b":"u","\u1ee5":"u","\u1ee7":"u","\u1ee9":"u","\u1eeb":"u","\u1eed":"u","\u1eef":"u","\u1ef1":"u","\u1e7d":"v","\u1e7f":"v","\u0175":"w","\u1e81":"w","\u1e83":"w","\u1e85":"w","\u1e87":"w","\u1e89":"w","\u1e98":"w","\u1e8b":"x","\u1e8d":"x","\u00fd":"y","\u00ff":"y","\u0177":"y","\u0233":"y",
"\u1e8f":"y","\u1e99":"y","\u1ef3":"y","\u1ef5":"y","\u1ef7":"y","\u1ef9":"y","\u017a":"z","\u017c":"z","\u017e":"z","\u1e91":"z","\u1e93":"z","\u1e95":"z"};a=SC.diacriticMappingTable}for(var b,c,e="",g=this.length,d=0;d<=g;++d){b=this.charAt(d);c=a[b];e+=c?c:b}return e},trim:function(){return this.replace(/^\s+|\s+$/g,"")},trimLeft:function(){return this.replace(/^\s+/g,"")},trimRight:function(){return this.replace(/\s+$/g,"")}};SC.String.strip=SC.String.trim;SC.supplement(String.prototype,SC.String);
String.prototype.loc=SC.String.loc;SC.String.fmt=String.prototype.fmt;sc_require("mixins/string");SC.MIXED_STATE="__MIXED__";SC.HUGE_CONTROL_SIZE="sc-huge-size";SC.LARGE_CONTROL_SIZE="sc-large-size";SC.REGULAR_CONTROL_SIZE="sc-regular-size";SC.SMALL_CONTROL_SIZE="sc-small-size";SC.TINY_CONTROL_SIZE="sc-tiny-size";
SC.Control={initMixin:function(){this._control_contentDidChange()},isSelected:NO,isSelectedBindingDefault:SC.Binding.oneWay().bool(),isActive:NO,isActiveBindingDefault:SC.Binding.oneWay().bool(),value:null,content:null,contentValueKey:null,contentPropertyDidChange:function(a,b){return this.updatePropertyFromContent("value",b,"contentValueKey")},updatePropertyFromContent:function(a,b,c,e){var g=b==="*";if(c===undefined)c="content%@Key".fmt(a.capitalize());if(e===undefined)e=this.get("content");if((c=
this[c]?this.get(c):this.getDelegateProperty(c,this.displayDelegate))&&(g||b===c)){b=e?e.get?e.get(c):e[c]:null;this.set(a,b)}return this},updateContentWithValueObserver:function(){var a=this.contentValueKey?this.get("contentValueKey"):this.getDelegateProperty("contentValueKey",this.displayDelegate),b=this.get("content");if(a&&b){var c=this.get("value");if(typeof b.setIfChanged===SC.T_FUNCTION)b.setIfChanged(a,c);else if(b[a]!==c)b[a]=c}}.observes("value"),fieldKey:null,fieldLabel:null,errorLabel:function(){var a,
b;if(a=this.get("fieldLabel"))return a;a=this.get("fieldKey")||this.constructor.toString();b=(a||"").humanize().capitalize();return"ErrorLabel.%@".fmt(a).locWithDefault("FieldKey.%@".fmt(a).locWithDefault(b))}.property("fieldLabel","fieldKey").cacheable(),controlSize:SC.REGULAR_CONTROL_SIZE,displayProperties:"isEnabled isSelected isActive controlSize".w(),_CONTROL_TMP_CLASSNAMES:{},renderMixin:function(a,b){var c=this.get("isSelected"),e=!this.get("isEnabled"),g=this._CONTROL_TMP_CLASSNAMES;g.mixed=
c===SC.MIXED_STATE;g.sel=c&&c!==SC.MIXED_STATE;g.active=this.get("isActive");a.setClass(g).addClass(this.get("controlSize"));!b&&this.$input&&this.$input().attr("disabled",e)},_control_content:null,_control_contentDidChange:function(){var a=this.get("content");if(this._control_content!==a){var b=this.contentPropertyDidChange,c=this._control_content;c&&c.removeObserver&&c.removeObserver("*",this,b);(this._control_content=a)&&a.addObserver&&a.addObserver("*",this,b);this.contentPropertyDidChange(a,
"*")}}.observes("content")};SC.Editable={isEditable:NO,isEditing:NO,beginEditing:function(){if(!this.get("isEditable"))return NO;if(this.get("isEditing"))return YES;this.set("isEditing",YES);this.becomeFirstResponder();return YES},discardEditing:function(){return!this.get("isEditing")},commitEditing:function(){if(!this.get("isEditing"))return YES;this.set("isEditing",NO);this.resignFirstResponder();return YES}};
SC.browser=function(){var a=navigator.userAgent.toLowerCase(),b=(a.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1];a={version:b,safari:/webkit/.test(a)?b:0,opera:/opera/.test(a)?b:0,msie:/msie/.test(a)&&!/opera/.test(a)?b:0,mozilla:/mozilla/.test(a)&&!/(compatible|webkit)/.test(a)?b:0,mobileSafari:/apple.*mobile.*safari/.test(a)?b:0,windows:!!/(windows)/.test(a),mac:!!(/(macintosh)/.test(a)||/(mac os x)/.test(a)),language:(navigator.language||navigator.browserLanguage).split("-",1)[0]};SC.extend(a,
{isOpera:!!a.opera,isIe:!!a.msie,isIE:!!a.msie,isSafari:!!a.safari,isMobileSafari:!!a.mobileSafari,isMozilla:!!a.mozilla,isWindows:!!a.windows,isMac:!!a.mac,current:a.msie?"msie":a.mozilla?"mozilla":a.safari?"safari":a.opera?"opera":"unknown"});return a}();SC.Builder=function(a){return SC.Builder.create(a)};
SC.Builder.create=function(a){var b=SC.mixin(SC.beget(this.fn),a||{});if(a.hasOwnProperty("toString"))b.toString=a.toString;var c=function(){var e=SC.beget(b);e.defaultClass=this;e.constructor=c;return e.init.apply(e,arguments)};c.fn=c.prototype=b;c.extend=SC.Builder.create;c.mixin=SC.Builder.mixin;return c};SC.Builder.mixin=function(){var a=arguments.length,b;for(b=0;b<a;b++)SC.mixin(this,arguments[b]);return this};
SC.Builder.fn={init:function(a){if(a!==undefined)if(SC.typeOf(a)===SC.T_ARRAY){for(var b=a.length;--b>=0;)this[b]=a.objectAt?a.objectAt(b):a[b];this.length=a.length}else{this[0]=a;this.length=1}return this},size:function(){return this.length},pushStack:function(){var a=this.constructor.apply(this,arguments);a.prevObject=this;return a},end:function(){return this.prevObject||this.constructor()},toString:function(){return"%@$(%@)".fmt(this.defaultClass.toString(),SC.A(this).invoke("toString").join(","))},
mixin:SC.Builder.mixin};(function(){var a=SC.Enumerable,b=SC.Builder.fn,c,e;for(c in a)if(a.hasOwnProperty(c)){e=Array.prototype[c]||a[c];b[c]=e}})();sc_require("system/builder");
SC.CoreQuery=function(){function a(m,q){return m[0]&&parseInt(p.curCSS(m[0],q,true),10)||0}var b=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,c=/^.[^:#\[\.]*$/,e,g=SC.browser.msie?"styleFloat":"cssFloat",d=SC.browser.safari&&parseInt(SC.browser.version,0)<417?"(?:[\\w*_-]|\\\\.)":"(?:[\\w\u0128-\uffff*_-]|\\\\.)",f=new RegExp("^([#.]?)("+d+"*)"),h=new RegExp("([#.]?)("+d+"*)","g"),i=["Left","Right"],j=["Top","Bottom"],k={position:"absolute",visibility:"hidden",display:"block"},l=function(m,q,s){q=q=="width"?
m.offsetWidth:m.offsetHeight;for(var t=0,u=0,v=s.length,w;--v>=0;){w=s[v];t+=parseFloat(p.curCSS(m,"padding"+w,true))||0;u+=parseFloat(p.curCSS(m,"border"+w+"Width",true))||0}q-=Math.round(t+u);return q},o=/z-?index|font-?weight|opacity|zoom|line-?height/i,n=document.defaultView||{},r=function(m){if(!SC.browser.safari)return false;m=n.getComputedStyle(m,null);return!m||m.getPropertyValue("color")==""},p;p=d=SC.Builder.create({jquery:"SC.CoreQuery",init:function(m,q){m=m||document;if(m.nodeType){this[0]=
m;this.length=1;return this}else if(typeof m==="string"){var s=b.exec(m);if(s&&(s[1]||!q))if(s[1])m=p.clean([s[1]],q);else{if(q=document.getElementById(s[3])){if(q.id!=s[3])return p().find(m);return p(q)}m=[]}else return p(q).find(m)}else if(SC.typeOf(m)===SC.T_FUNCTION)return SC.ready(m);return this.setArray(p.makeArray(m))},size:function(){return this.length},get:function(m){return m===e?p.makeArray(this):this[m]},find:function(m){return this.pushStack(p.map(this,function(q){return p.find(m,q)}))},
filter:function(m){return this.pushStack(SC.typeOf(m)===SC.T_FUNCTION&&p.grep(this,function(q,s){return m.call(q,s)})||p.multiFilter(m,this))},not:function(m){if(typeof m==="string")if(c.test(m))return this.pushStack(p.multiFilter(m,this,true));else m=p.multiFilter(m,this);var q=m.length&&m[m.length-1]!==e&&!m.nodeType;return this.filter(function(){return q?p.inArray(this,m)<0:this!=m})},setArray:function(m){this.length=0;Array.prototype.push.apply(this,m);return this},map:function(m){return this.pushStack(p.map(this,
function(q,s){return m.call(q,s,q)}))},each:function(m,q){return p.each(this,m,q)},index:function(m){if(m&&m.jquery)m=m[0];return Array.prototype.indexOf.call(this,m)},eq:function(m){return this.slice(m,+m+1)},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments))},add:function(m){return this.pushStack(p.merge(this.get(),typeof m==="string"?p(m):p.makeArray(m)).uniq())},attr:function(m,q,s){var t=m;if(typeof m==="string")if(q===e)return this[0]&&p[s||"attr"](this[0],m);
else{t={};t[m]=q}return this.each(function(u){for(m in t)p.attr(s?this.style:this,m,p.prop(this,t[m],s,u,m))})},html:function(m){return m===e?this[0]?this[0].innerHTML.replace(/ CQ\d+="(?:\d+|null)"/g,""):null:this.empty().append(m)},andSelf:function(){return this.add(this.prevObject)},is:function(m){return!!m&&p.multiFilter(m,this).length>0},hasClass:function(m){return Array.prototype.every.call(this,function(q){return q.nodeType!=1||p.className.has(q,m)})},val:function(m){if(m===e){var q=this[0];
if(q){if(p.nodeName(q,"option"))return(q.attributes.value||{}).specified?q.value:q.text;if(p.nodeName(q,"select")){var s=q.selectedIndex,t=[],u=q.options;q=q.type=="select-one";if(s<0)return null;var v=q?s+1:u.length;for(s=q?s:0;s<v;s++){var w=u[s];if(w.selected){m=p(w).val();if(q)return m;t.push(m)}}return t}return(q.value||"").replace(/\r/g,"")}return e}else{if(typeof m==="number")m+="";this.each(function(){if(this.nodeType==1)if(SC.typeOf(m)===SC.T_ARRAY&&/radio|checkbox/.test(this.type))this.checked=
p.inArray(this.value,m)>=0||p.inArray(this.name,m)>=0;else if(p.nodeName(this,"select")){var x=p.makeArray(m);p("option",this).each(function(){this.selected=p.inArray(this.value,x)>=0||p.inArray(this.text,x)>=0});if(!x.length)this.selectedIndex=-1}else this.value=m})}return this},clone:function(){var m=this.map(function(){if(SC.browser.msie&&!p.isXMLDoc(this)){var q=this.cloneNode(true),s=document.createElement("div");s.appendChild(q);return p.clean([s.innerHTML])[0]}else return this.cloneNode(true)});
m.find("*").andSelf().each(function(){if(this[SC.guidKey]!==e)this[SC.guidKey]=null});return m},css:function(m,q){if((m=="width"||m=="height")&&parseFloat(q,0)<0)q=e;return this.attr(m,q,"curCSS")},text:function(m){if(typeof m!=="object"&&m!=null)return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(m));var q="";p.each(m||this,function(){p.each(this.childNodes,function(){if(this.nodeType!=8)q+=this.nodeType!=1?this.nodeValue:p.fn.text([this])})});return q},show:function(){var m=
SC.$.isVisible;this.each(function(){if(!m(this)){this.style.display=this.oldblock||"";if(p.css(this,"display")=="none"){var q=p("<"+this.tagName+"/>");p("body").append(q);this.style.display=q.css("display");if(this.style.display==="none")this.style.display="block";q.remove()}}});return this},hide:function(){var m=SC.$.isVisible;this.each(function(){if(m(this)){this.oldblock=this.oldblock||p.css(this,"display");this.style.display="none"}});return this},domManip:function(m,q,s,t){var u=this.length>
1,v;return this.each(function(){if(!v){v=p.clean(m,this.ownerDocument);s&&v.reverse()}var w=this;if(q&&p.nodeName(this,"table")&&p.nodeName(v[0],"tr"))w=this.getElementsByTagName("tbody")[0]||this.appendChild(this.ownerDocument.createElement("tbody"));p.each(v,function(){var x=u?p(this).clone(true)[0]:this;t.call(w,x)})})},append:function(){return this.domManip(arguments,true,false,function(m){this.nodeType==1&&this.appendChild(m)})},prepend:function(){return this.domManip(arguments,true,true,function(m){this.nodeType==
1&&this.insertBefore(m,this.firstChild)})},before:function(){return this.domManip(arguments,false,false,function(m){this.parentNode.insertBefore(m,this)})},after:function(){return this.domManip(arguments,false,true,function(m){this.parentNode.insertBefore(m,this.nextSibling)})},replaceWith:function(m){return this.after(m).remove()},removeData:function(m){return this.each(function(){SC.removeData(this,m)})}});d.mixin({nodeName:function(m,q){return m.nodeName&&m.nodeName.toUpperCase()==q.toUpperCase()},
map:function(m,q){for(var s=[],t=0,u=m.length;t<u;t++){var v=q(m[t],t);if(v!=null)s[s.length]=v}return s.concat.apply([],s)},each:function(m,q,s){var t,u=0,v=m.length;if(s)if(v===e)for(t in m){if(q.apply(m[t],s)===false)break}else for(;u<v;){if(q.apply(m[u++],s)===false)break}else if(v===e)for(t in m){if(q.call(m[t],t,m[t])===false)break}else for(s=m[0];u<v&&q.call(s,u,s)!==false;s=m[++u]);return m},isXMLDoc:function(m){return m.documentElement&&!m.body||m.tagName&&m.ownerDocument&&!m.ownerDocument.body},
clean:function(m,q){var s=[];q=q||document;if(typeof q.createElement=="undefined")q=q.ownerDocument||q[0]&&q[0].ownerDocument||document;p.each(m,function(t,u){if(typeof u==="number")u+="";if(u){if(typeof u==="string"){u=u.replace(/(<(\w+)[^>]*?)\/>/g,function(x,A,y){return y.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?x:A+"></"+y+">"});var v=u.replace(/^\s+/,"").substring(0,10).toLowerCase();t=q.createElement("div");var w=!v.indexOf("<opt")&&[1,"<select multiple='multiple'>",
"</select>"]||!v.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||v.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!v.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!v.indexOf("<td")||!v.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!v.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||SC.browser.msie&&[1,"div<div>","</div>"]||[0,"",""];for(t.innerHTML=w[1]+u+w[2];w[0]--;)t=t.lastChild;if(SC.browser.msie){v=!v.indexOf("<table")&&
v.indexOf("<tbody")<0?t.firstChild&&t.firstChild.childNodes:w[1]=="<table>"&&v.indexOf("<tbody")<0?t.childNodes:[];for(w=v.length-1;w>=0;--w)p.nodeName(v[w],"tbody")&&!v[w].childNodes.length&&v[w].parentNode.removeChild(v[w]);/^\s/.test(u)&&t.insertBefore(q.createTextNode(u.match(/^\s*/)[0]),t.firstChild)}u=p.makeArray(t.childNodes)}if(!(u.length===0&&!p.nodeName(u,"form")&&!p.nodeName(u,"select")))if(u[0]===e||p.nodeName(u,"form")||u.options)s.push(u);else s=p.merge(s,u)}});return s},find:function(m,
q){if(typeof m!="string")return[m];if(m.indexOf(",")>=0){var s=m.split(",").map(function(C){return p.find(C,q)});return s.concat.apply([],s).uniq()}if(q&&q.nodeType!=1&&q.nodeType!=9)return[];q=q||document;s=[q];for(var t=YES,u=m.match(h),v=u.length,w=0;w<v;w++){m=u[w];if(m===" "||m==="")t=YES;else if(t){m=f.exec(m);if(m[1]===""&&w<v-1&&u[w+1].charAt(0)==="#"){m=u[w+1];u[w+1]=u[w];m=f.exec(m)}t=[];var x=s.length,A,y,B=m[2],z;for(A=0;A<x;A++){y=s[A];switch(m[1]){case "":B||(B="*");if(B=="*"&&y.nodeName.toLowerCase()==
"object")B="param";t=p.merge(t,y.getElementsByTagName(B));break;case "#":if(y===document){z=document.getElementById(B);if(SC.browser.msie&&z&&z.getAttribute("id")!==B)z=NO;else{z&&t.push(z);z=YES}}else z=NO;if(!z){z=y.getElementsByTagName("*");(z=Array.prototype.find.call(z,function(C){return C.getAttribute&&C.getAttribute("id")===B}))&&t.push(z)}break;case ".":t=y.getElementsByClassName?p.merge(t,y.getElementsByClassName(B)):p.merge(t,p.classFilter(y.getElementsByTagName("*"),B));break;default:}}delete s;
s=t;t=NO}else s=p.filter(m,s)}s&&s[0]==q&&s.shift();return s.uniq()},classFilter:function(m,q,s){q=" "+q+" ";for(var t=[],u=0;m[u];u++){var v=(" "+m[u].className+" ").indexOf(q)>=0;if(!s&&v||s&&!v)t.push(m[u])}return t},filter:function(m,q,s){m=f.exec(m);var t=m[2];m=m[1];if(m===".")return p.classFilter(p.makeArray(q),t,s);else{m=m==="#"?function(u){u=u&&u.getAttribute&&u.getAttribute("id")===t;return s?!u:u}:function(u){u=p.nodeName(u,t);return s?!u:u};return Array.prototype.filter.call(p.makeArray(q),
m)}},multiFilter:function(m,q,s){m=m.indexOf(",")?m.split(","):[m];for(var t=m.length,u,v=[];--t>=0;){u=p.filter(m[t].trim(),q,s);v=s?(q=u):p.merge(u,v)}return v},merge:function(m,q){var s=0,t,u=m.length;if(SC.browser.msie)for(;t=q[s++];){if(t.nodeType!=8)m[u++]=t}else for(;t=q[s++];)m[u++]=t;return m},makeArray:function(m){var q=[];if(m!=null){var s=m.length;if(s==null||typeof m==="string"||m.setInterval)q[0]=m;else for(;s;)q[--s]=m[s]}return q},inArray:function(m,q){return q.indexOf?q.indexOf(m):
Array.prototype.indexOf.call(q,m)},boxModel:!SC.browser.msie||document.compatMode=="CSS1Compat",props:{"for":"htmlFor","class":"className","float":g,cssFloat:g,styleFloat:g,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan"},prop:function(m,q,s,t,u){if(SC.typeOf(q)===SC.T_FUNCTION)q=q.call(m,t);return q&&typeof q==="number"&&s=="curCSS"&&!o.test(u)?q+"px":q},grep:function(m,q,s){for(var t=[],u=0,v=m.length;u<v;u++)!s!=!q(m[u],u)&&t.push(m[u]);return t},className:{add:function(m,
q){var s=p.className.has;p.each((q||"").split(/\s+/),function(t,u){if(m.nodeType==1&&!s(m.className,u))m.className+=(m.className?" ":"")+u})},remove:function(m,q){if(m.nodeType==1)m.className=q!==e?p.grep(m.className.split(/\s+/),function(s){return!p.className.has(q,s)}).join(" "):""},has:function(m,q){return m&&p.inArray(q,(m.className||m).toString().split(/\s+/))>-1}},swap:function(m,q,s,t,u){var v={};for(var w in q){v[w]=m.style[w];m.style[w]=q[w]}s=s(m,t,u);for(w in q)m.style[w]=v[w];return s},
css:function(m,q,s){if(q=="width"||q=="height"){s=q=="width"?i:j;m=SC.$.isVisible(m)?l(m,q,s):p.swap(m,k,l,q,s);return Math.max(0,m)}return p.curCSS(m,q,s)},curCSS:function(m,q,s){var t,u=m.style;if(q=="opacity"&&SC.browser.msie){t=p.attr(u,"opacity");return t==""?"1":t}if(SC.browser.opera&&q==="display"){var v=u.outline;u.outline="0 solid black";u.outline=v}if(v=q.match(/float/i))q=g;if(!s&&u&&u[q])t=u[q];else if(n.getComputedStyle){if(v)q="float";q=q.replace(/([A-Z])/g,"-$1").toLowerCase();if((t=
n.getComputedStyle(m,null))&&!r(m,n))t=t.getPropertyValue(q);else{u=[];s=[];v=m;for(m=0;v&&r(v);v=v.parentNode)s.unshift(v);for(v=s.length;m<v;m++)if(r(s[m])){u[m]=s[m].style.display;s[m].style.display="block"}t=q=="display"&&u[s.length-1]!=null?"none":t&&t.getPropertyValue(q)||"";m=0;for(v=u.length;m<v;m++)if(u[m]!=null)s[m].style.display=u[m]}if(q=="opacity"&&t=="")t="1"}else if(m.currentStyle){t=m.currentStyle[q]||m.currentStyle[q.camelize()];if(!/^\d+(px)?$/i.test(t)&&/^\d/.test(t)){q=u.left;
s=m.runtimeStyle.left;m.runtimeStyle.left=m.currentStyle.left;u.left=t||0;t=u.pixelLeft+"px";u.left=q;m.runtimeStyle.left=s}}return t},dir:function(m,q){var s=[];for(m=m[q];m&&m!=document;){m.nodeType==1&&s.push(m);m=m[q]}return s},nth:function(m,q,s){q=q||1;for(var t=0;m;m=m[s])if(m.nodeType==1&&++t==q)break;return m},sibling:function(m,q){for(var s=[];m;m=m.nextSibling)m.nodeType==1&&m!=q&&s.push(m);return s},attr:function(m,q,s){if(!m||m.nodeType==3||m.nodeType==8)return e;var t=!p.isXMLDoc(m),
u=s!==e,v=SC.browser.msie;q=t&&p.props[q]||q;if(m.tagName){var w=/href|src|style/.test(q);if(q in m&&t&&!w){if(u){if(q=="type"&&p.nodeName(m,"input")&&m.parentNode)throw"type property can't be changed";m[q]=s}if(p.nodeName(m,"form")&&m.getAttributeNode(q))return m.getAttributeNode(q).nodeValue;if(q=="tabIndex")return(q=m.getAttributeNode("tabIndex"))&&q.specified?q.value:m.nodeName.match(/(button|input|object|select|textarea)/i)?0:m.nodeName.match(/^(a|area)$/i)&&m.href?0:e;return m[q]}if(v&&t&&q===
"style")return p.attr(m.style,"cssText",s);u&&m.setAttribute(q,""+s);m=v&&t&&w?m.getAttribute(q,2):m.getAttribute(q);return m===null?e:m}if(v&&q=="opacity"){if(u){m.zoom=1;m.filter=(m.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(s,0)+""=="NaN"?"":"alpha(opacity="+s*100+")")}return m.filter&&m.filter.indexOf("opacity=")>=0?parseFloat(m.filter.match(/opacity=([^)]*)/)[1])/100+"":""}q=q.camelize();if(u)m[q]=s;return m[q]}});p.fn.init.prototype=p.fn;p.each({parent:function(m){return m.parentNode},
parents:function(m){return p.dir(m,"parentNode")},next:function(m){return p.nth(m,2,"nextSibling")},prev:function(m){return p.nth(m,2,"previousSibling")},nextAll:function(m){return p.dir(m,"nextSibling")},prevAll:function(m){return p.dir(m,"previousSibling")},siblings:function(m){return p.sibling(m.parentNode.firstChild,m)},children:function(m){return p.sibling(m.firstChild)},contents:function(m){return p.nodeName(m,"iframe")?m.contentDocument||m.contentWindow.document:p.makeArray(m.childNodes)}},
function(m,q){p.fn[m]=function(s){var t=p.map(this,q);if(s&&typeof s=="string")t=p.multiFilter(s,t);return this.pushStack(t.uniq())}});p.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(m,q){p.fn[m]=function(){var s=arguments;return this.each(function(){for(var t=0,u=s.length;t<u;t++)p(s[t])[q](this)})}});p.each({removeAttr:function(m){p.attr(this,m,"");this.nodeType==1&&this.removeAttribute(m)},addClass:function(m){p.className.add(this,
m)},removeClass:function(m){p.className.remove(this,m)},toggleClass:function(m){p.className[p.className.has(this,m)?"remove":"add"](this,m)},remove:function(m){if(!m||p.filter(m,[this]).length)this.parentNode&&this.parentNode.removeChild(this)},empty:function(){for(;this.firstChild;)this.removeChild(this.firstChild)}},function(m,q){p.fn[m]=function(){return this.each(q,arguments)}});p.each(["Height","Width"],function(m,q){var s=q.toLowerCase();p.fn[s]=function(v){if(this[0]===window)ret=SC.browser.opera?
document.body["client"+q]:SC.browser.safari?window["inner"+q]:document.compatMode?documentElement["client"+q]:document.body["client"+q];else if(this[0]===document)ret=Math.max(Math.max(document.body["scroll"+q],document.documentElement["scroll"+q]),Math.max(document.body["offset"+q],document.documentElement["offset"+q]));else return v==e?this.length?p.css(this[0],s):null:this.css(s,typeof v==="string"?v:v+"px");return ret};var t=m?"Left":"Top",u=m?"Right":"Bottom";p.fn["inner"+q]=function(){return this[q.toLowerCase()]()+
a(this,"padding"+t)+a(this,"padding"+u)};p.fn["outer"+q]=function(v){return this["inner"+q]()+a(this,"border"+t+"Width")+a(this,"border"+u+"Width")+(v?a(this,"margin"+t)+a(this,"margin"+u):0)}});d.fn.offset=function(){function m(D){q(p.curCSS(D,"borderLeftWidth",true),p.curCSS(D,"borderTopWidth",true))}function q(D,E){s+=parseInt(D,10)||0;t+=parseInt(E,10)||0}var s=0,t=0,u=this[0],v=SC.browser;if(!u)return e;var w=u.parentNode,x=u,A=u.offsetParent,y=u.ownerDocument,B=v.safari&&parseInt(v.version,
0)<522&&!/adobeair/i.test(v.userAgent),z=p.curCSS,C=p.css(u,"position")=="fixed";if(!(v.mozilla&&u==document.body)&&u.getBoundingClientRect){u=u.getBoundingClientRect();q(u.left+Math.max(y.documentElement.scrollLeft,y.body.scrollLeft),u.top+Math.max(y.documentElement.scrollTop,y.body.scrollTop));q(-y.documentElement.clientLeft,-y.documentElement.clientTop)}else{for(q(u.offsetLeft,u.offsetTop);A;){q(A.offsetLeft,A.offsetTop);if(v.mozilla&&!/^t(able|d|h)$/i.test(A.tagName)||v.safari&&!B)m(A);if(!C&&
z(A,"position")=="fixed")C=true;x=/^body$/i.test(A.tagName)?x:A;A=A.offsetParent}for(;w&&w.tagName&&!/^body|html$/i.test(w.tagName);){/^inline|table.*$/i.test(z(w,"display"))||q(-w.scrollLeft,-w.scrollTop);v.mozilla&&z(w,"overflow")!="visible"&&m(w);w=w.parentNode}if(B&&(C||z(x,"position")=="absolute")||v.mozilla&&z(x,"position")!="absolute")q(-y.body.offsetLeft,-y.body.offsetTop);C&&q(Math.max(y.documentElement.scrollLeft,y.body.scrollLeft),Math.max(y.documentElement.scrollTop,y.body.scrollTop))}return{top:t,
left:s}};d.fn.mixin({position:function(){var m;if(this[0]){m=this.offsetParent();var q=this.offset(),s=/^body|html$/i.test(m[0].tagName)?{top:0,left:0}:m.offset();q.top-=a(this,"marginTop");q.left-=a(this,"marginLeft");s.top+=a(m,"borderTopWidth");s.left+=a(m,"borderLeftWidth");m={top:q.top-s.top,left:q.left-s.left}}return m},offsetParent:function(){for(var m=this[0].offsetParent||document.body;m&&!/^body|html$/i.test(m.tagName)&&p.css(m,"position")=="static";)m=m.offsetParent;return p(m)}});p.each(["Left",
"Top"],function(m,q){var s="scroll"+q;p.fn[s]=function(t){if(this[0])return t!=e?this.each(function(){this==window||this==document?window.scrollTo(!m?t:p(window).scrollLeft(),m?t:p(window).scrollTop()):(this[s]=t)}):this[0]==window||this[0]==document?self[m?"pageYOffset":"pageXOffset"]||p.boxModel&&document.documentElement[s]||document.body[s]:this[0][s]}});return d}();SC.$=typeof jQuery=="undefined"?SC.CoreQuery:jQuery;
SC.mixin(SC.$.fn,{isCoreQuery:YES,toString:function(){var a=[],b=this.length,c=0;for(c=0;c<b;c++)a[c]="%@: %@".fmt(c,this[c]?this[c].toString():"(null)");return"<$:%@>(%@)".fmt(SC.guidFor(this),a.join(" , "))},isVisible:function(){return Array.prototype.every.call(this,function(a){return SC.$.isVisible(a)})},first:function(){return this.pushStack([this[0]])},last:function(){return this.pushStack([this[this.length-1]])},view:function(){return this.map(function(){for(var a=null,b=this,c;!a&&b&&b!==
document;){if(c=b.getAttribute("id"))a=SC.View.views[c];b=b.parentNode}return a})},setClass:function(a,b){if(SC.none(a))return this;var c=SC.typeOf(a)!==SC.T_STRING,e=this._fixupClass;this.each(function(){if(this.nodeType===1){var g=this.className.split(/\s+/),d=NO;if(c)for(var f in a){if(a.hasOwnProperty(f))d=e(g,f,a[f])||d}else d=e(g,a,b);if(d)this.className=g.join(" ")}});return this},_fixupClass:function(a,b,c){var e=a.indexOf(b);if(c){if(e<0){a.push(b);return YES}}else if(e>=0){a[e]=null;return YES}return NO},
within:function(a){a=SC.$(a);for(var b,c,e,g=a.length,d=this.length;!b&&--d>=0;){c=this[d];for(e=0;!b&&e<g;e++){for(b=a[e];b&&b!==c;)b=b.parentNode;b=b===c}}return b}});
(function(){var a={},b={find:function(f,h){return h!==undefined?SC.Enumerable.find.call(this,f,h):a.find.call(this,f)},filter:function(f,h){return h!==undefined?this.pushStack(SC.Enumerable.filter.call(this,f,h)):a.filter.call(this,f)},filterProperty:function(f,h){return this.pushStack(SC.Enumerable.filterProperty.call(this,f,h))},indexOf:SC.$.index,map:function(f,h){return h!==undefined?SC.Enumerable.map.call(this,f,h):a.map.call(this,f)}},c=SC.$.fn,e=SC.$.jquery==="SC.CoreQuery"?b:SC.Enumerable;
for(var g in e)if(e.hasOwnProperty(g)){var d=e[g];if(g in b){a[g]=c[g];d=b[g]}c[g]=d}})();SC.mixin(SC.$,{isVisible:function(a){var b=SC.$;return"hidden"!=a.type&&b.css(a,"display")!="none"&&b.css(a,"visibility")!="hidden"}});sc_require("system/core_query");
SC.Event=function(a){if(a){this.originalEvent=a;for(var b=SC.Event._props,c=b.length,e;--c>=0;){e=b[c];this[e]=a[e]}}this.timeStamp=this.timeStamp||Date.now();if(!this.target)this.target=this.srcElement||document;if(this.target.nodeType===3)this.target=this.target.parentNode;if(!this.relatedTarget&&this.fromElement)this.relatedTarget=this.fromElement===this.target?this.toElement:this.fromElement;if(SC.none(this.pageX)&&!SC.none(this.clientX)){b=document.documentElement;c=document.body;this.pageX=
this.clientX+(b&&b.scrollLeft||c&&c.scrollLeft||0)-(b.clientLeft||0);this.pageY=this.clientY+(b&&b.scrollTop||c&&c.scrollTop||0)-(b.clientTop||0)}if(!this.which&&(this.charCode||a.charCode===0?this.charCode:this.keyCode))this.which=this.charCode||this.keyCode;if(!this.metaKey&&this.ctrlKey)this.metaKey=this.ctrlKey;if(!this.which&&this.button)this.which=this.button&1?1:this.button&2?3:this.button&4?2:0;if(SC.browser.safari&&a.wheelDelta!==undefined){this.wheelDelta=this.wheelDeltaY=0-(a.wheelDeltaY||
a.wheelDelta);this.wheelDeltaX=0-(a.wheelDeltaX||0)}else if(SC.none(a.detail)){this.wheelDelta=this.wheelDeltaY=SC.browser.msie?0-a.wheelDelta:a.wheelDelta;this.wheelDeltaX=0}else{b=Math.floor(a.detail*2);if(a.axis&&a.axis===a.HORIZONTAL_AXIS){this.wheelDeltaX=b;this.wheelDeltaY=this.wheelDelta=0}else{this.wheelDeltaY=this.wheelDelta=b;this.wheelDeltaX=0}}return this};
SC.mixin(SC.Event,{create:function(a){return new SC.Event(a)},add:function(a,b,c,e,g){if(a&&a.isCoreQuery)if(a.length>0){a.forEach(function(h){this.add(h,b,c,e,g)},this);return this}else a=a.get(0);if(!a)return this;if(a.nodeType==3||a.nodeType==8)return SC.Event;if(SC.browser.msie&&a.setInterval)a=window;if(SC.typeOf(c)===SC.T_FUNCTION){g=e;e=c;c=null}else if(c&&SC.typeOf(e)===SC.T_STRING)e=c[e];var d=SC.data(a,"events")||SC.data(a,"events",{}),f=d[b];if(!f){f=d[b]={};this._addEventListener(a,b)}f[SC.guidFor(e)]=
[c,e,g];SC.Event._global[b]=YES;a=d=f=null;return this},remove:function(a,b,c,e){if(a&&a.isCoreQuery)if(a.length>0){a.forEach(function(i){this.remove(i,b,c,e)},this);return this}else a=a.get(0);if(!a)return this;if(a.nodeType==3||a.nodeType==8)return SC.Event;if(SC.browser.msie&&a.setInterval)a=window;var g,d,f=SC.data(a,"events");if(!f)return this;if(b===undefined)for(b in f)this.remove(a,b);else if(g=f[b]){var h=NO;if(c||e){if(SC.typeOf(c)===SC.T_FUNCTION){e=c;c=null}else if(SC.typeOf(e)===SC.T_STRING)e=
c[e];delete g[SC.guidFor(e)];d=null;for(d in g)break;if(d===null)h=YES}else h=YES;if(h){delete f[b];this._removeEventListener(a,b)}d=null;for(d in f)break;if(!d){SC.removeData(a,"events");delete this._elements[SC.guidFor(a)]}}a=f=g=null;return this},NO_BUBBLE:["blur","focus","change"],simulateEvent:function(a,b,c){a=SC.Event.create({type:b,target:a,preventDefault:function(){this.cancelled=YES},stopPropagation:function(){this.bubbles=NO},allowDefault:function(){this.hasCustomEventHandling=YES},timeStamp:Date.now(),
bubbles:this.NO_BUBBLE.indexOf(b)<0,cancelled:NO,normalized:YES});c&&SC.mixin(a,c);return a},trigger:function(a,b,c,e){if(a&&a.isCoreQuery)if(a.length>0){a.forEach(function(j){this.trigger(j,b,c,e)},this);return this}else a=a.get(0);if(!a)return this;if(!(a.nodeType==3||a.nodeType==8)){c=SC.A(c);var g,d=SC.typeOf(a[b]||null)===SC.T_FUNCTION,f,h;f=c[0];if(!f||!f.preventDefault){f=this.simulateEvent(a,b);c.unshift(f)}f.type=b;h=a;do{g=SC.Event.handle.apply(h,c);h=h===document?null:h.parentNode||document}while(!g&&
f.bubbles&&h);h=null;f=a["on"+b];isClick=SC.CoreQuery.nodeName(a,"a")&&b==="click";if((!d||isClick)&&f&&f.apply(a,c)===NO)g=NO;if(d&&e!==NO&&g!==NO&&!isClick){this.triggered=YES;try{a[b]()}catch(i){}}this.triggered=NO;return g}},handle:function(a){if(typeof SC==="undefined"||SC.Event.triggered)return YES;var b,c,e,g,d,f;g=SC.A(arguments);g[0]=a=SC.Event.normalizeEvent(a||window.event);e=(SC.data(this,"events")||{})[a.type];if(!e)return NO;for(d in e){f=e[d];c=f[1];a.handler=c;a.data=a.context=f[2];
f=f[0]||this;c=c.apply(f,g);if(b!==NO)b=c;if(c===NO){a.preventDefault();a.stopPropagation()}}return b},unload:function(){var a,b=this._elements;for(a in b)this.remove(b[a]);for(a in b)delete b[a];delete this._elements},special:{ready:{setup:function(){SC._bindReady()},teardown:function(){}},mouseenter:{setup:function(){if(SC.browser.msie)return NO;SC.Event.add(this,"mouseover",SC.Event.special.mouseover.handler);return YES},teardown:function(){if(SC.browser.msie)return NO;SC.Event.remove(this,"mouseover",
SC.Event.special.mouseover.handler);return YES},handler:function(a){if(SC.Event._withinElement(a,this))return YES;a.type="mouseenter";return SC.Event.handle.apply(this,arguments)}},mouseleave:{setup:function(){if(SC.browser.msie)return NO;SC.Event.add(this,"mouseout",SC.Event.special.mouseleave.handler);return YES},teardown:function(){if(SC.browser.msie)return NO;SC.Event.remove(this,"mouseout",SC.Event.special.mouseleave.handler);return YES},handler:function(a){if(SC.Event._withinElement(a,this))return YES;
a.type="mouseleave";return SC.Event.handle.apply(this,arguments)}}},KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,KEY_INSERT:45,_withinElement:function(a,b){for(a=a.relatedTarget;a&&a!=b;)try{a=a.parentNode}catch(c){a=b}return a===b},_addEventListener:function(a,b){var c;c=this.special[b];if(!c||c.setup.call(a)===NO){var e=SC.guidFor(a);this._elements[e]=a;c=SC.data(a,"listener")||
SC.data(a,"listener",function(){return SC.Event.handle.apply(SC.Event._elements[e],arguments)});if(a.addEventListener)a.addEventListener(b,c,NO);else a.attachEvent&&a.attachEvent("on"+b,c)}a=c=c=null},_removeEventListener:function(a,b){var c;c=SC.Event.special[b];if(!c||c.teardown.call(a)===NO)if(c=SC.data(a,"listener"))if(a.removeEventListener)a.removeEventListener(b,c,NO);else a.detachEvent&&a.detachEvent("on"+b,c)},_elements:{},normalizeEvent:function(a){return a==window.event?SC.Event.create(a):
a.normalized?a:SC.Event.create(a)},_global:{},_props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view which touches targetTouches changedTouches".split(" ")});
SC.Event.prototype={hasCustomEventHandling:NO,allowDefault:function(){this.hasCustomEventHandling=YES;return this},preventDefault:function(){var a=this.originalEvent;if(a){a.preventDefault&&a.preventDefault();a.returnValue=NO}this.hasCustomEventHandling=YES;return this},stopPropagation:function(){var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=YES}this.hasCustomEventHandling=YES;return this},stop:function(){return this.preventDefault().stopPropagation()},normalized:YES,
getCharString:function(){return this.charCode>0?String.fromCharCode(this.which):null},commandCodes:function(){var a=this.keyCode,b=null,c=null,e="";if(a){b=SC.FUNCTION_KEYS[a];if(!b&&(this.altKey||this.ctrlKey||this.metaKey))b=SC.PRINTABLE_KEYS[a];if(b){if(this.altKey)e+="alt_";if(this.ctrlKey||this.metaKey)e+="ctrl_";if(this.shiftKey)e+="shift_"}}if(!b){a=this.which;c=b=String.fromCharCode(a);a=b.toLowerCase();if(this.metaKey){e="meta_";b=a}else b=null}if(b)b=e+b;return[b,c]}};SC.Event.observe=SC.Event.add;
SC.Event.stopObserving=SC.Event.remove;SC.Event.fire=SC.Event.trigger;SC.Event.add(window,"unload",SC.Event.prototype,SC.Event.unload);SC.MODIFIER_KEYS={16:"shift",17:"ctrl",18:"alt"};SC.FUNCTION_KEYS={8:"backspace",9:"tab",13:"return",19:"pause",27:"escape",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",44:"printscreen",45:"insert",46:"delete",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scrolllock"};
SC.PRINTABLE_KEYS={32:" ",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",61:"=",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",107:"+",109:"-",110:".",188:",",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:'"'};SC.SYSTEM_CURSOR="default";SC.AUTO_CURSOR=SC.DEFAULT_CURSOR="auto";SC.CROSSHAIR_CURSOR="crosshair";
SC.HAND_CURSOR=SC.POINTER_CURSOR="pointer";SC.MOVE_CURSOR="move";SC.E_RESIZE_CURSOR="e-resize";SC.NE_RESIZE_CURSOR="ne-resize";SC.NW_RESIZE_CURSOR="nw-resize";SC.N_RESIZE_CURSOR="n-resize";SC.SE_RESIZE_CURSOR="se-resize";SC.SW_RESIZE_CURSOR="sw-resize";SC.S_RESIZE_CURSOR="s-resize";SC.W_RESIZE_CURSOR="w-resize";SC.IBEAM_CURSOR=SC.TEXT_CURSOR="text";SC.WAIT_CURSOR="wait";SC.HELP_CURSOR="help";
SC.Cursor=SC.Object.extend({init:function(){arguments.callee.base.apply(this,arguments);var a=this.get("cursorStyle")||SC.DEFAULT_CURSOR,b=this.constructor.sharedStyleSheet();if(b.insertRule)b.insertRule(".%@ {cursor: %@;}".fmt(SC.guidFor(this),a),b.cssRules?b.cssRules.length:0);else b.addRule&&b.addRule("."+SC.guidFor(this),"cursor: "+a);this.cursorStyle=a;this.className=SC.guidFor(this);return this},className:null,cursorStyle:SC.DEFAULT_CURSOR,cursorStyleDidChange:function(){var a,b,c,e,g,d;a=this.get("cursorStyle")||
SC.DEFAULT_CURSOR;if(b=this._rule)b.style.cursor=a;else{c="."+this.get("className");b=this.constructor.sharedStyleSheet();e=(b.cssRules?b.cssRules:b.rules)||[];g=0;for(d=e.length;g<d;++g){b=e[g];if(b.selectorText===c){this._rule=b;b.style.cursor=a;break}}}}.observes("cursorStyle")});
SC.Cursor.sharedStyleSheet=function(){var a,b=this._styleSheet;if(!b){b=document.createElement("style");b.type="text/css";a=document.getElementsByTagName("head")[0];if(!a)a=document.documentElement;a.appendChild(b);this._styleSheet=b=document.styleSheets[document.styleSheets.length-1]}return b};
SC.Responder=SC.Object.extend({isResponder:YES,pane:null,responderContext:null,nextResponder:null,isFirstResponder:NO,hasFirstResponder:NO,acceptsFirstResponder:YES,becomeFirstResponder:function(){var a=this.get("pane")||this.get("responderContext")||this.pane();a&&this.get("acceptsFirstResponder")&&a.get("firstResponder")!==this&&a.makeFirstResponder(this);return this},resignFirstResponder:function(){var a=this.get("pane")||this.get("responderContext");a&&a.get("firstResponder")===this&&a.makeFirstResponder(null);
return YES},willLoseFirstResponder:function(){},didBecomeFirstResponder:function(){}});sc_require("system/browser");sc_require("system/event");sc_require("system/cursor");sc_require("system/responder");sc_require("mixins/string");SC.viewKey=SC.guidKey+"_view";SC.LAYOUT_HORIZONTAL="sc-layout-horizontal";SC.LAYOUT_VERTICAL="sc-layout-vertical";SC._VIEW_DEFAULT_DIMS="marginTop marginLeft".w();SC.ANCHOR_TOP={top:0};SC.ANCHOR_LEFT={left:0};SC.ANCHOR_TOP_LEFT={top:0,left:0};SC.ANCHOR_BOTTOM={bottom:0};
SC.ANCHOR_RIGHT={right:0};SC.ANCHOR_BOTTOM_RIGHT={bottom:0,right:0};SC.FULL_WIDTH={left:0,right:0};SC.FULL_HEIGHT={top:0,bottom:0};SC.ANCHOR_CENTER={centerX:0,centerY:0};SC.LAYOUT_AUTO="auto";SC.EMPTY_CHILD_VIEWS_ARRAY=[];SC.EMPTY_CHILD_VIEWS_ARRAY.needsClone=YES;
SC.View=SC.Responder.extend(SC.DelegateSupport,{concatenatedProperties:"outlets displayProperties layoutProperties classNames renderMixin didCreateLayerMixin willDestroyLayerMixin".w(),pane:function(){for(var a=this;a&&!a.isPane;)a=a.get("parentView");return a}.property("parentView").cacheable(),page:null,splitView:function(){for(var a=this;a&&!a.isSplitView;)a=a.get("parentView");return a}.property("parentView").cacheable(),parentView:null,backgroundColor:null,isEnabled:YES,isEnabledBindingDefault:SC.Binding.oneWay().bool(),
isEnabledInPane:function(){var a=this.get("isEnabled"),b;if(a&&(b=this.get("parentView")))a=b.get("isEnabledInPane");return a}.property("parentView","isEnabled"),isVisible:YES,isVisibleBindingDefault:SC.Binding.bool(),isVisibleInWindow:NO,recomputeIsVisibleInWindow:function(a){var b=this.get("isVisibleInWindow"),c=this.get("isVisible"),e;if(c)c=a===undefined?(e=this.get("parentView"))?e.get("isVisibleInWindow"):NO:a;if(b!==c){this.set("isVisibleInWindow",c);this._needsVisibiltyChange=YES;a=this.get("childViews");
b=a.length;for(e=0;e<b;e++)a[e].recomputeIsVisibleInWindow(c);if(c){this.parentViewDidResize&&this.parentViewDidResize();this.get("childViewsNeedLayout")&&this.invokeOnce(this.layoutChildViewsIfNeeded)}this.set("layerNeedsUpdate",YES);!c&&this.get("isFirstResponder")&&this.resignFirstResponder()}return this}.observes("isVisible"),childViews:SC.EMPTY_CHILD_VIEWS_ARRAY,insertBefore:function(a,b){a.beginPropertyChanges();a.get("parentView")&&a.removeFromParent();this.willAddChild&&this.willAddChild(a,
b);a.willAddToParent&&a.willAddToParent(this,b);a.set("parentView",this);var c,e=this.get("childViews");if(e.needsClone)this.set(e=[]);c=b?e.indexOf(b):e.length;if(c<0)c=e.length;e.insertAt(c,a);a.parentViewDidChange();a.layoutDidChange();this.didAddChild&&this.didAddChild(a,b);a.didAddToParent&&a.didAddToParent(this,b);a.endPropertyChanges();return this},removeChild:function(a){if(!a)return this;if(a.parentView!==this)throw"%@.removeChild(%@) must belong to parent".fmt(this,a);a.willRemoveFromParent&&
a.willRemoveFromParent();this.willRemoveChild&&this.willRemoveChild(a);a.set("parentView",null);var b=this.get("childViews"),c=b.indexOf(a);c>=0&&b.removeAt(c);a.parentViewDidChange();this.didRemoveChild&&this.didRemoveChild(a);a.didRemoveFromParent&&a.didRemoveFromParent(this);return this},removeAllChildren:function(){for(var a=this.get("childViews"),b;b=a.objectAt(a.get("length")-1);)this.removeChild(b);return this},removeFromParent:function(){var a=this.get("parentView");a&&a.removeChild(this);
return this},replaceChild:function(a,b){a.beginPropertyChanges();b.beginPropertyChanges();this.beginPropertyChanges();this.insertBefore(a,b).removeChild(b);this.endPropertyChanges();b.endPropertyChanges();a.endPropertyChanges();return this},replaceAllChildren:function(a){var b=a.get("length"),c;this.beginPropertyChanges();this.destroyLayer().removeAllChildren();for(c=0;c<b;c++)this.appendChild(a.objectAt(c));this.replaceLayer();this.endPropertyChanges();return this},appendChild:function(a){return this.insertBefore(a,
null)},parentViewDidChange:function(){this.recomputeIsVisibleInWindow();this.set("layerLocationNeedsUpdate",YES);this.invokeOnce(this.updateLayerLocationIfNeeded);this._invalidatePaneCacheForSelfAndAllChildViews();return this}.observes("isVisible"),_invalidatePaneCacheForSelfAndAllChildViews:function(){this.notifyPropertyChange("pane");for(var a=this.get("childViews"),b=a.length,c=0;c<b;++c){var e=a[c];e._invalidatePaneCacheForSelfAndAllChildViews&&e._invalidatePaneCacheForSelfAndAllChildViews()}},
layer:function(a,b){if(b!==undefined)this._view_layer=b;else{b=this._view_layer;if(!b){if(a=this.get("parentView"))a=a.get("layer");if(a)this._view_layer=b=this.findLayerInParentLayer(a)}}return b}.property("isVisibleInWindow").cacheable(),$:function(a){var b=this.get("layer");return!b?SC.$([]):a===undefined?SC.$(b):SC.$(a,b)},containerLayer:function(){return this.get("layer")}.property("layer").cacheable(),layerId:function(){return SC.guidFor(this)}.property().cacheable(),findLayerInParentLayer:function(a){var b=
this.get("layerId"),c,e,g,d;d=a.getElementById?a.getElementById(b):document.getElementById(b);if(SC.browser.msie&&d&&d.id!==b)d=null;if(!d){d=a.firstChild;var f=[];for(f.push(a);f.length!==0;){a=f[0];f.shift();if(a.id===b){g=true;d=a;break}c=0;for(e=a.childNodes.length;c<e;c++)f.push(a.childNodes[c])}g||(d=null)}return d},displayDidChange:function(){this.set("layerNeedsUpdate",YES);return this},layerNeedsUpdate:NO,_view_layerNeedsUpdateDidChange:function(){this.get("layerNeedsUpdate")&&this.invokeOnce(this.updateLayerIfNeeded)}.observes("layerNeedsUpdate"),
updateLayerIfNeeded:function(){if((this.get("isVisibleInWindow")||this._needsVisibiltyChange)&&this.get("layerNeedsUpdate")){this._needsVisibiltyChange=NO;if(this.get("layer")){this.beginPropertyChanges();this.set("layerNeedsUpdate",NO);this.updateLayer();this.endPropertyChanges()}}else this.set("layerNeedsUpdate",NO);return this},updateLayer:function(){var a=this.renderContext(this.get("layer"));this.prepareContext(a,NO);a.update();this.didUpdateLayer&&this.didUpdateLayer();this.designer&&this.designer.viewDidUpdateLayer&&
this.designer.viewDidUpdateLayer();return this},renderContext:function(a){return SC.RenderContext(a)},createLayer:function(){if(this.get("layer"))return this;var a=this.renderContext(this.get("tagName"));this.prepareContext(a,YES);this.set("layer",a.element());this._notifyDidCreateLayer();return this},_notifyDidCreateLayer:function(){this.didCreateLayer&&this.didCreateLayer();var a=this.didCreateLayerMixin,b,c;if(a){b=a.length;for(c=0;c<b;++c)a[c].call(this)}a=this.get("childViews");b=a.length;for(c=
0;c<b;++c)a[c]&&a[c]._notifyDidCreateLayer()},destroyLayer:function(){var a=this.get("layer");if(a){this._notifyWillDestroyLayer();a.parentNode&&a.parentNode.removeChild(a)}return this},replaceLayer:function(){this.destroyLayer();this.set("layerLocationNeedsUpdate",YES);this.invokeOnce(this.updateLayerLocationIfNeeded)},_notifyWillDestroyLayer:function(){this.willDestroyLayer&&this.willDestroyLayer();var a=this.willDestroyLayerMixin,b,c;if(a){b=a.length;for(c=0;c<b;++c)a[c].call(this)}a=this.get("childViews");
b=a.length;for(c=0;c<b;++c)a[c]._notifyWillDestroyLayer();this.set("layer",null)},prepareContext:function(a,b){var c,e,g;if(b){c=this.layerId?this.get("layerId"):SC.guidFor(this);a.id(c).classNames(this.get("classNames"),YES);this.renderLayout(a,b)}else{a.resetClassNames();a.classNames(this.get("classNames"),YES)}this.get("isTextSelectable")&&a.addClass("allow-select");this.get("isEnabled")||a.addClass("disabled");this.get("isVisible")||a.addClass("hidden");this.get("isFirstResponder")&&a.addClass("focus");
(c=this.get("backgroundColor"))&&a.addStyle("backgroundColor",c);(c=this.get("cursor"))&&a.addClass(c.get("className"));this.beginPropertyChanges();this.set("layerNeedsUpdate",NO);this.render(a,b);if(c=this.renderMixin){e=c.length;for(g=0;g<e;++g)c[g].call(this,a,b)}this.endPropertyChanges()},renderChildViews:function(a,b){var c=this.get("childViews"),e=c.length,g,d;for(g=0;g<e;++g)if(d=c[g]){a=a.begin(d.get("tagName"));d.prepareContext(a,b);a=a.end()}return a},render:function(a,b){b&&this.renderChildViews(a,
b)},tagName:"div",classNames:["sc-view"],toolTip:null,isTextSelectable:NO,displayProperties:["isFirstResponder","isVisible"],cursor:null,layerLocationNeedsUpdate:NO,updateLayerLocationIfNeeded:function(){if(this.get("layerLocationNeedsUpdate")){this.set("layerLocationNeedsUpdate",NO);this.updateLayerLocation()}return this},updateLayerLocation:function(){var a=this.get("layer"),b=this.get("parentView"),c=b?b.get("containerLayer"):null;a&&a.parentNode&&a.parentNode!==c&&a.parentNode.removeChild(a);
if(b)if(c){if(!a){this.createLayer();a=this.get("layer")}b=b.get("childViews");var e=(b=b.objectAt(b.indexOf(this)+1))?b.get("layer"):null;if(b&&(!e||e.parentNode!==c)){b.updateLayerLocationIfNeeded();e=b.get("layer")}if(a.parentNode!==c||a.nextSibling!==e){c.insertBefore(a,e);this.parentViewDidResize&&this.parentViewDidResize()}}else{if(a){a.parentNode&&a.parentNode.removeChild(a);this.destroyLayer()}}else a&&a.parentNode&&a.parentNode.removeChild(a);return this},nextResponder:function(){return this.get("parentView")}.property("parentView").cacheable(),
acceptsFirstResponder:NO,isKeyResponder:NO,willLoseKeyResponderTo:function(){},willBecomeKeyResponderFrom:function(){},didLoseKeyResponderTo:function(){},didBecomeKeyResponderFrom:function(){},interpretKeyEvents:function(a){var b=a.commandCodes(),c=b[0];b=b[1];if(!c&&!b)return null;if(c)if(c=SC.MODIFIED_KEY_BINDINGS[c]||SC.BASE_KEY_BINDINGS[c.match(/[^_]+$/)[0]]){b=this;for(var e=this.get("pane"),g=null;b&&!(g=b.tryToPerform(c,a));)b=b===e?null:b.get("nextResponder");return g}if(b&&this.respondsTo("insertText"))return(a=
this.insertText(b,a))?a===YES?this:a:null;return null},insertText:function(){return NO},performKeyEquivalent:function(a,b){for(var c=NO,e=this.get("childViews"),g=e.length,d=-1;!c&&++d<g;)c=e[d].performKeyEquivalent(a,b);return c},nextKeyView:null,nextValidKeyView:function(){var a=SC.CoreSet.create(),b=this._computeNextValidKeyView(a);a.destroy();return b}.property("nextKeyView"),_computeNextValidKeyView:function(a){var b=this.get("nextKeyView"),c;a.add(this);if(!b){c=(b=(b=this.get("parentView"))?
b.get("childViews"):null)?b.indexOf(this):-1;b=c<0?null:c+1>=b.get("length")?b.objectAt(0):b.objectAt(c+1)}if(b&&!b.get("acceptsFirstResponder"))b=a.contains(b)?null:b._computeNextValidKeyView(a);return b},previousKeyView:null,previousValidKeyView:function(){var a=SC.CoreSet.create(),b=this._computePreviousValidKeyView(a);a.destroy();return b}.property("previousKeyView"),_computePreviousValidKeyView:function(a){var b=this.get("previousKeyView"),c;a.add(this);if(!b){c=(b=(b=this.get("parentView"))?
b.get("childViews"):null)?b.indexOf(this):-1;b=c<0?null:c>0?b.objectAt(c-1):b.objectAt(b.get("length")-1)}if(b&&!b.get("acceptsFirstResponder"))b=a.contains(b)?null:b._computePreviousValidKeyView(a);return b},init:function(){var a,b;arguments.callee.base.apply(this,arguments);this.get("isMaterialized")||(SC.View.views[this.get("layerId")]=this);this.childViews=(a=this.get("childViews"))?a.slice():[];this.createChildViews();b=this.get("displayProperties");for(a=b.length;--a>=0;)this.addObserver(b[a],
this,this.displayDidChange);this.get("isDropTarget")&&SC.Drag.addDropTarget(this);this.get("isScrollable")&&SC.Drag.addScrollableView(this)},awake:function(){arguments.callee.base.apply(this,arguments);var a=this.get("childViews"),b=a.length,c;for(c=0;c<b;++c)a[c]&&a[c].awake()},destroy:function(){if(this.get("isDestroyed"))return this;arguments.callee.base.apply(this,arguments);this.removeFromParent();this._destroy();this.get("isDropTarget")&&SC.Drag.removeDropTarget(this);this.get("isScrollable")&&
SC.Drag.removeScrollableView(this);return this},_destroy:function(){if(this.get("isDestroyed"))return this;this.destroyLayer();var a=this.get("childViews"),b=a.length,c;if(b){a=a.slice();for(c=0;c<b;++c)a[c]._destroy()}delete SC.View.views[this.get("layerId")];delete this._CQ;delete this.page;this.set("isDestroyed",YES);return this},createChildViews:function(){var a=this.get("childViews"),b=a.length,c,e,g;this.beginPropertyChanges();for(c=0;c<b;++c){if(e=g=a[c]){if(typeof e===SC.T_STRING)g=this[e];
else e=null;if(!g){console.error("No view with name "+e+" has been found in "+this.toString());continue}if(g.isClass){g=this.createChildView(g);if(e)this[e]=g}}a[c]=g}this.endPropertyChanges();return this},createChildView:function(a,b){b||(b={});b.owner=b.parentView=this;b.isVisibleInWindow=this.get("isVisibleInWindow");if(!b.page)b.page=this.page;return a=a.create(b)},adjust:function(a,b){var c=SC.clone(this.get("layout")),e=NO,g;if(a===undefined)return this;if(SC.typeOf(a)===SC.T_STRING){g=c[a];
if(SC.none(b)){if(g!==undefined)e=YES;delete c[a]}else{if(g!==b)e=YES;c[a]=b}}else{var d=a;for(a in d)if(d.hasOwnProperty(a)){b=d[a];g=c[a];if(b===null){if(g!==undefined)e=YES;delete c[a]}else if(b!==undefined){if(g!==b)e=YES;c[a]=b}}}e&&this.set("layout",c);return this},layout:{top:0,left:0,bottom:0,right:0},convertFrameToView:function(a,b){var c=0,e=0,g=0,d=0,f=this,h;if(this.get("useStaticLayout"))throw"convertFrameToView is not available with static layout";for(;f;){h=f.get("frame");c+=h.x;e+=
h.y;f=f.get("layoutView")}if(b)for(f=b;f;){h=f.get("frame");g+=h.x;d+=h.y;f=f.get("layoutView")}c=a.x+c-g;e=a.y+e-d;return{x:c,y:e,width:a.width,height:a.height}},convertFrameFromView:function(a,b){var c=0,e=0,g=0,d=0,f=this,h;if(this.get("useStaticLayout"))throw"convertFrameToView is not available with static layout";for(;f&&f.get("frame");){h=f.get("frame");c+=h.x;e+=h.y;f=f.get("parentView")}if(b)for(f=b;f;){h=f.get("frame");g+=h.x;d+=h.y;f=f.get("parentView")}c=a.x-c+g;e=a.y-e+d;return{x:c,y:e,
width:a.width,height:a.height}},scrollToVisible:function(){for(var a=this.get("parentView");a&&!a.get("isScrollable");)a=a.get("parentView");if(a){a.scrollToVisible();return a.scrollToVisible(this)}else return NO},frame:function(){return this.computeFrameWithParentFrame(null)}.property("layout","useStaticLayout").cacheable(),computeFrameWithParentFrame:function(a){var b=this.get("layout"),c={},e=SC.LAYOUT_AUTO,g=this.get("useStaticLayout");if(b.width!==undefined&&b.width===SC.LAYOUT_AUTO&&g!==undefined&&
!g){b=SC.Error.desc("%@.layout() you cannot use width:auto if staticLayout is disabled".fmt(this),"%@".fmt(this),-1);console.error(b.toString());throw b;}if(b.height!==undefined&&b.height===SC.LAYOUT_AUTO&&g!==undefined&&!g){b=SC.Error.desc("%@.layout() you cannot use height:auto if staticLayout is disabled".fmt(this),"%@".fmt(this),-1);console.error(b.toString());throw b;}if(g)return null;if(SC.none(b.left))if(SC.none(b.right))if(SC.none(b.centerX)){c.x=0;if(SC.none(b.width)){a||(a=this.computeParentDimensions(b));
c.width=Math.floor(a.width)}else c.width=b.width===e?e:Math.floor(b.width||0)}else{a||(a=this.computeParentDimensions(b));c.width=b.width===e?e:Math.floor(b.width||0);c.x=Math.floor((a.width-c.width)/2+b.centerX)}else{a||(a=this.computeParentDimensions(b));if(SC.none(b.width)){c.width=a.width-b.right;c.x=0}else{c.width=b.width===e?e:Math.floor(b.width||0);c.x=Math.floor(a.width-b.right-c.width)}}else{c.x=Math.floor(b.left);if(b.width!==undefined)c.width=b.width===e?e:Math.floor(b.width);else{a||(a=
this.computeParentDimensions(b));c.width=Math.floor(a.width-c.x-(b.right||0))}}if(SC.none(b.top))if(SC.none(b.bottom))if(SC.none(b.centerY)){c.y=0;if(SC.none(b.height)){a||(a=this.computeParentDimensions(b));c.height=Math.floor(a.height)}else c.height=b.height===e?e:Math.floor(b.height||0)}else{a||(a=this.computeParentDimensions(b));c.height=b.height===e?e:Math.floor(b.height||0);c.y=Math.floor((a.height-c.height)/2+b.centerY)}else{a||(a=this.computeParentDimensions(b));if(SC.none(b.height)){c.height=
a.height-b.bottom;c.y=0}else{c.height=b.height===e?e:Math.floor(b.height||0);c.y=Math.floor(a.height-b.bottom-c.height)}}else{c.y=Math.floor(b.top);if(b.height!==undefined)c.height=b.height===e?e:Math.floor(b.height);else{a||(a=this.computeParentDimensions(b));c.height=Math.floor(a.height-c.y-(b.bottom||0))}}if(c.height===e||c.width===e){a=this.get("layer");if(c.height===e)c.height=a?a.clientHeight:0;if(c.width===e)c.width=a?a.clientWidth:0}if(!SC.none(b.maxHeight)&&c.height>b.maxHeight)c.height=
b.maxHeight;if(!SC.none(b.minHeight)&&c.height<b.minHeight)c.height=b.minHeight;if(!SC.none(b.maxWidth)&&c.width>b.maxWidth)c.width=b.maxWidth;if(!SC.none(b.minWidth)&&c.width<b.minWidth)c.width=b.minWidth;if(c.height<0)c.height=0;if(c.width<0)c.width=0;return c},computeParentDimensions:function(a){var b=this.get("parentView");return(b=b?b.get("frame"):null)?{width:b.width,height:b.height}:{width:(a.left||0)+(a.width||0)+(a.right||0),height:(a.top||0)+(a.height||0)+(a.bottom||0)}},clippingFrame:function(){var a=
this.get("parentView"),b=this.get("frame"),c=b;if(a){a=a.get("clippingFrame");c=SC.intersectRects(a,b)}c.x-=b.x;c.y-=b.y;return c}.property("parentView","frame").cacheable(),_sc_view_clippingFrameDidChange:function(){var a=this.get("childViews"),b=a.length,c,e;for(c=0;c<b;++c){e=a[c];e.hasStaticLayout||e.notifyPropertyChange("clippingFrame")}}.observes("clippingFrame"),parentViewDidResize:function(){var a=this.get("layout");if(!(a.left!==undefined&&a.top!==undefined&&a.width!==undefined&&a.height!==
undefined)){this.notifyPropertyChange("frame");this.viewDidResize()}},viewDidResize:function(){var a=this.childViews,b=a.length,c,e;for(c=0;c<b;++c){e=a[c];e.parentViewDidResize&&e.parentViewDidResize()}}.observes("layout"),beginLiveResize:function(){this.willBeginLiveResize&&this.willBeginLiveResize();var a=this.get("childViews"),b=a.length,c,e;for(c=0;c<b;++c){e=a[c];e.beginLiveResize&&e.beginLiveResize()}return this},endLiveResize:function(){var a=this.get("childViews"),b,c;for(b=a.length-1;b>=
0;--b){c=a[b];c.endLiveResize&&c.endLiveResize()}this.didEndLiveResize&&this.didEndLiveResize();return this},layoutStyle:function(){var a=this.get("layout"),b={},c=this.get("useStaticLayout");if(a.width!==undefined&&a.width===SC.LAYOUT_AUTO&&!c){b=SC.Error.desc("%@.layout() you cannot use width:auto if  staticLayout is disabled".fmt(this),"%@".fmt(this),-1);console.error(b.toString());throw b;}if(a.height!==undefined&&a.height===SC.LAYOUT_AUTO&&!c){b=SC.Error.desc("%@.layout() you cannot use height:auto if  staticLayout is disabled".fmt(this),
"%@".fmt(this),-1);console.error(b.toString());throw b;}if(SC.none(a.left))if(SC.none(a.right))if(SC.none(a.centerX)){if(SC.none(a.width)){b.left=0;b.right=0;b.width=null}else{b.left=0;b.right=null;b.width=a.width===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:Math.floor(a.width)}b.marginLeft=0}else{b.left="50%";b.width=Math.floor(a.width||0);b.marginLeft=Math.floor(a.centerX-b.width/2);b.right=null}else{b.right=Math.floor(a.right);b.marginLeft=0;if(SC.none(a.width)){b.left=0;b.width=null}else{b.left=null;b.width=
a.width===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:Math.floor(a.width||0)}}else{b.left=Math.floor(a.left);if(a.width!==undefined){b.width=a.width===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:Math.floor(a.width);b.right=null}else{b.width=null;b.right=Math.floor(a.right||0)}b.marginLeft=0}b.minWidth=a.minWidth===undefined?null:a.minWidth;b.maxWidth=a.maxWidth===undefined?null:a.maxWidth;if(SC.none(a.top))if(SC.none(a.bottom))if(SC.none(a.centerY)){if(SC.none(a.height)){b.top=0;b.bottom=0;b.height=null}else{b.top=0;b.bottom=
null;b.height=a.height===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:Math.floor(a.height||0)}b.marginTop=0}else{b.top="50%";b.height=Math.floor(a.height||0);b.marginTop=Math.floor(a.centerY-b.height/2);b.bottom=null}else{b.marginTop=0;b.bottom=Math.floor(a.bottom);if(SC.none(a.height)){b.top=0;b.height=null}else{b.top=null;b.height=a.height===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:Math.floor(a.height||0)}}else{b.top=Math.floor(a.top);if(a.height!==undefined){b.height=a.height===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:Math.floor(a.height);
b.bottom=null}else{b.height=null;b.bottom=Math.floor(a.bottom||0)}b.marginTop=0}b.minHeight=a.minHeight===undefined?null:a.minHeight;b.maxHeight=a.maxHeight===undefined?null:a.maxHeight;b.zIndex=SC.none(a.zIndex)?null:a.zIndex.toString();b.backgroundPosition=SC.none(a.backgroundPosition)?null:a.backgroundPosition.toString();a=SC._VIEW_DEFAULT_DIMS;c=a.length;for(var e;--c>=0;){e=a[c];if(b[e]===0)b[e]=null}for(var g in b){a=b[g];if(typeof a===SC.T_NUMBER)b[g]=a+"px"}return b}.property().cacheable(),
layoutView:function(){return this.get("parentView")}.property("parentView").cacheable(),layoutDidChange:function(){this.beginPropertyChanges();this.frame&&this.notifyPropertyChange("frame");this.notifyPropertyChange("layoutStyle");this.endPropertyChanges();var a=this.get("layoutView");if(a){a.set("childViewsNeedLayout",YES);a.layoutDidChangeFor(this);a.get("childViewsNeedLayout")&&a.invokeOnce(a.layoutChildViewsIfNeeded)}return this}.observes("layout"),childViewsNeedLayout:NO,layoutDidChangeFor:function(a){var b=
this._needLayoutViews;if(!b)b=this._needLayoutViews=SC.CoreSet.create();b.add(a)},layoutChildViewsIfNeeded:function(a){a||(a=this.get("isVisibleInWindow"));if(a&&this.get("childViewsNeedLayout")){this.set("childViewsNeedLayout",NO);this.layoutChildViews()}return this},layoutChildViews:function(){var a=this._needLayoutViews,b=a?a.length:0,c,e;for(c=0;c<b;c++){e=a[c];e.updateLayout()}a.clear()},updateLayout:function(){var a=this.get("layer");if(a){a=this.renderContext(a);this.renderLayout(a);a.update()}return this},
renderLayout:function(a){a.addStyle(this.get("layoutStyle"))},isView:YES,selectStart:function(){return this.get("isTextSelectable")}});
SC.View.mixin({isViewClass:YES,design:function(){if(this.isDesign)return this;var a=this.extend.apply(this,arguments);a.isDesign=YES;SC.ViewDesigner&&SC.ViewDesigner.didLoadDesign(a,this,SC.A(arguments));return a},layout:function(a){this.prototype.layout=a;return this},convertLayoutToAnchoredLayout:function(a,b){var c={top:0,left:0,width:b.width,height:b.height};if(SC.none(a.left))if(SC.none(a.right))if(SC.none(a.centerX))if(SC.none(a.width)){c.left=0;c.width=0}else{c.left=0;c.width=a.width===SC.LAYOUT_AUTO?
SC.LAYOUT_AUTO:Math.floor(a.width)}else{c.width=Math.floor(a.width||0);c.left=Math.floor((b.width-c.width)/2)+a.centerX}else if(SC.none(a.width)){c.left=0;c.width=b.width-Math.floor(a.right||0)}else if(a.width===SC.LAYOUT_AUTO)c.width=SC.LAYOUT_AUTO;else{c.width=a.width;c.left=b.width-(a.width+a.right)}else{c.left=Math.floor(a.left);c.width=a.width!==undefined?a.width===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:Math.floor(a.width):b.width-c.left-Math.floor(a.right||0)}if(a.minWidth!==undefined)c.minWidth=a.minWidth;
if(a.maxWidth!==undefined)c.maxWidth=a.maxWidth;if(SC.none(a.top))if(SC.none(a.bottom))if(SC.none(a.centerY))if(SC.none(a.height)){c.top=0;c.height=0}else{c.top=0;c.height=a.height===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:Math.floor(a.height)}else{c.height=Math.floor(a.height||0);c.top=Math.floor((b.height-c.height)/2)+a.centerY}else if(SC.none(a.height)){c.top=0;c.height=b.height-Math.floor(a.bottom||0)}else if(a.height===SC.LAYOUT_AUTO)c.height=SC.LAYOUT_AUTO;else{c.height=a.height;c.top=b.height-(a.height+
a.bottom)}else{c.top=Math.floor(a.top);c.height=a.height!==undefined?a.height===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:Math.floor(a.height):b.height-c.top-Math.floor(a.bottom||0)}if(a.minHeight!==undefined)c.minHeight=a.minHeight;if(a.maxHeight!==undefined)c.maxHeight=a.maxHeight;return c},convertLayoutToCustomLayout:function(){},classNames:function(a){a=(this.prototype.classNames||[]).concat(a);this.prototype.classNames=a;return this},tagName:function(a){this.prototype.tagName=a;return this},childView:function(a){var b=
this.prototype.childViews||[];if(b===this.superclass.prototype.childViews)b=b.slice();b.push(a);this.prototype.childViews=b;return this},bind:function(a,b){var c=this.prototype,e=this.superclass.prototype,g=c._bindings;if(!g||g===e._bindings)g=c._bindings=(g||[]).slice();a+="Binding";c[a]=b;g.push(a);return this},prop:function(a,b){this.prototype[a]=b;return this},localization:function(a,b){if(b)a.rootElement=SC.$(b).get(0);return a},viewFor:function(a){var b=SC.$A(arguments);if(SC.none(a))b.shift();
else b[0]={rootElement:SC.$(a).get(0)};var c=this.create.apply(this,arguments);b[0]=null;return c},create:function(){var a=new this(arguments);SC.ViewDesigner&&SC.ViewDesigner.didCreateView(a,SC.$A(arguments));return a},loc:function(a){var b=a.childViews;delete a.childViews;this.applyLocalizedAttributes(a);SC.ViewDesigner&&SC.ViewDesigner.didLoadLocalization(this,SC.$A(arguments));for(var c=this.prototype.childViews,e=c.length;--e>=0;){var g=c[e];(a=b[e])&&g&&g.loc&&g.loc(a)}return this},applyLocalizedAttributes:function(a){SC.mixin(this.prototype,
a)},views:{}});SC.outlet=function(a){return function(b){return this[b]=SC.objectForPropertyPath(a,this)}.property()};SC.View.unload=function(){var a=SC.View.views;if(a)for(var b in a)a.hasOwnProperty(b)&&delete a[b]};SC.Event.add(window,"unload",SC.View,SC.View.unload);
SC.Validatable={initMixin:function(){this._validatable_validatorDidChange()},validator:null,errorLabel:null,isValid:function(){return SC.typeOf(this.get("value"))!==SC.T_ERROR}.property("value"),ownerForm:null,performValidate:function(a){var b=SC.VALIDATE_OK;if(this._validator){var c=this.get("ownerForm");if(a){b=this._validator.validatePartial(c,this);if(b==SC.VALIDATE_NO_CHANGE&&this._validator.validateChange(c,this)==SC.VALIDATE_OK)b=SC.VALIDATE_OK}else b=this._validator.validateChange(c,this)}return b},
performValidateSubmit:function(){return this._validator?this._validator.validateSubmit(this.get("ownerForm"),this):SC.VALIDATE_OK},performValidateKeyDown:function(a){a=a.getCharString();if(!a)return YES;return this._validator?this._validator.validateKeyDown(this.get("ownerForm"),this,a):YES},validatorObject:function(){return this._validator}.property(),validateSubmit:function(){return this.performValidateSubmit()},objectForFieldValue:function(a){return this._validator?this._validator.objectForFieldValue(a,
this.get("ownerForm"),this):a},fieldValueForObject:function(a){return this._validator?this._validator.fieldValueForObject(a,this.get("ownerForm"),this):a},_validatable_displayObserver:function(){this.displayDidChange()}.observes("isValid"),updateLayerMixin:function(a){a.setClass("invalid",!this.get("isValid"))},_validatable_validatorDidChange:function(){var a=this.get("ownerForm"),b=SC.Validator.findFor(a,this,this.get("validator"));if(b!=this._validator){this.propertyWillChange("validatorObject");
this._validator&&this._validator.detachFrom(a,this);(this._validator=b)&&this._validator.attachTo(a,this);this.propertyDidChange("validatorObject")}}.observes("validator","ownerForm")};sc_require("views/view");sc_require("mixins/control");sc_require("mixins/validatable");
SC.FieldView=SC.View.extend(SC.Control,SC.Validatable,{isTextArea:NO,followSafariTabFocusBehavior:NO,_field_isMouseDown:NO,fieldValue:function(){var a=this.get("value");if(SC.typeOf(a)===SC.T_ERROR)a=a.get("value");return this.fieldValueForObject(a)}.property("value","validator").cacheable(),$input:function(){return this.get("isTextArea")?this.$("textarea").andSelf().filter("textarea"):this.$("input").andSelf().filter("input")},setFieldValue:function(a){if(SC.none(a))a="";var b=this.$input();b.val()!==
a&&b.val(a);return this},getFieldValue:function(){return this.$input().val()},_field_fieldValueDidChange:function(){SC.RunLoop.begin();this.fieldValueDidChange(NO);SC.RunLoop.end()},fieldValueDidChange:function(a){this.setIfChanged("value",this.objectForFieldValue(this.getFieldValue(),a))},_field_valueDidChange:function(){this.setFieldValue(this.get("fieldValue"))}.observes("value"),didCreateLayer:function(){this.setFieldValue(this.get("fieldValue"));SC.Event.add(this.$input(),"change",this,this._field_fieldValueDidChange)},
willDestroyLayer:function(){SC.Event.remove(this.$input(),"change",this,this._field_fieldValueDidChange)},updateLayer:function(){arguments.callee.base.apply(this,arguments)},mouseDown:function(a){this._field_isMouseDown=YES;a.allowDefault();return YES},mouseOut:function(a){this._field_isMouseDown&&this.set("isActive",NO);a.allowDefault();return YES},mouseOver:function(a){this.set("isActive",this._field_isMouseDown);a.allowDefault();return YES},mouseUp:function(a){this._field_isMouseDown&&this.set("isActive",
NO);this._field_isMouseDown=NO;a.allowDefault();return YES},keyDown:function(a){if(a.which===9){(a.shiftKey?this.get("previousValidKeyView"):this.get("nextValidKeyView")).becomeFirstResponder();return YES}if(this.performValidateKeyDown(a)){this._isKeyDown=YES;a.allowDefault()}else a.stop();return YES},acceptsFirstResponder:function(){if(!this.get("followSafariTabFocusBehavior"))return this.get("isEnabled");return NO}.property("isEnabled"),willBecomeKeyResponderFrom:function(){if(!this._isFocused){this._isFocused=
YES;this.becomeFirstResponder();this.get("isVisibleInWindow")&&this.$input().get(0).focus()}},willLoseKeyResponderTo:function(){if(this._isFocused)this._isFocused=NO},_field_setFieldValue:function(a){this.propertyWillChange("fieldValue");if(this.fieldValueForObject)a=this.fieldValueForObject(a);a=this.setFieldValue(a);this.propertyDidChange("fieldValue");return a},_field_getFieldValue:function(){var a=this.getFieldValue();if(this.objectForFieldValue)a=this.objectForFieldValue(a);return a}});
SC.TextSelection=SC.Object.extend(SC.Copyable,SC.Freezable,{start:-1,end:-1,length:function(){var a=this.get("start"),b=this.get("end");return a===-1||b===-1?-1:b-a}.property("start","end").cacheable(),init:function(){arguments.callee.base.apply(this,arguments);this.freeze()},copy:function(){return SC.TextSelection.create({start:this.get("start"),end:this.get("end")})},toString:function(){var a=this.get("length");return a&&a>0?a===1?"[%@ character selected: {%@, %@}]".fmt(a,this.get("start"),this.get("end")):
"[%@ characters selected: {%@, %@}]".fmt(a,this.get("start"),this.get("end")):"[no text selected; caret at %@]".fmt(this.get("start"))}});SC.StaticLayout={hasStaticLayout:YES,useStaticLayout:NO,renderMixin:function(a){a.setClass("sc-static-layout",this.get("useStaticLayout"))},clippingFrame:null,parentViewDidResize:null,beginLiveResize:null,endLiveResize:null,viewDidResize:null};sc_require("views/field");sc_require("system/text_selection");sc_require("mixins/static_layout");
SC.TextFieldView=SC.FieldView.extend(SC.StaticLayout,SC.Editable,{tagName:"label",classNames:["sc-text-field-view"],isPassword:NO,isTextArea:NO,hint:null,isEditing:NO,leftAccessoryView:null,rightAccessoryView:null,_isFocused:NO,isEditable:function(){return this.get("isEnabled")}.property("isEnabled").cacheable(),selection:function(a,b){a=this.$input().get(0);var c,e;if(b===undefined)if(a){b=e=null;if(a.value){if("selectionStart"in a)e=a.selectionStart;if("selectionEnd"in a)b=a.selectionEnd;if(e===
null||b===null)if(c=document.selection){var g=c.type;if(g&&(g==="None"||g==="Text")){c=c.createRange();if(this.get("isTextArea")){e=c.duplicate();e.moveToElementText(a);e.setEndPoint("EndToStart",c);e=e.text.length;b=e+c.text.length}else{b=c.text.length;e=Math.abs(c.moveStart("character",0-(a.value.length+1)));b=e+b}}}}else e=b=0;return SC.TextSelection.create({start:e,end:b})}else return null;else{if(!b||!b.kindOf||!b.kindOf(SC.TextSelection))throw"When setting the selection, you must specify an SC.TextSelection instance.";
if(a){if("selectionStart"in a){a.selectionStart=b.get("start");e=YES}if("selectionEnd"in a){a.selectionEnd=b.get("end");c=YES}if(!e||!c){c=a.createTextRange();e=b.get("start");c.move("character",e);c.moveEnd("character",b.get("end")-e);c.select()}}}}.property("fieldValue").cacheable(),displayProperties:"hint fieldValue isEditing leftAccessoryView rightAccessoryView isTextArea".w(),createChildViews:function(){this.accessoryViewObserver()},accessoryViewObserver:function(){for(var a,b=["leftAccessoryView",
"rightAccessoryView"],c=b.length,e=0;e<c;e++){var g=b[e],d=this["_"+g],f=this.get(g);if(!(d&&f&&d===f)){if(d){a=d.get("classNames");a=a.without("sc-text-field-accessory-view");d.set("classNames",a);this.removeChild(d);this["_"+g]=null}if(f){if(f.isClass)f=f.create({layoutView:this});a=f.get("classNames");a.indexOf("sc-text-field-accessory-view")<0&&a.push("sc-text-field-accessory-view");this.appendChild(f);this["_"+g]=f}}}}.observes("leftAccessoryView","rightAccessoryView"),layoutChildViewsIfNeeded:function(a){a||
(a=this.get("isVisibleInWindow"));if(a&&this.get("childViewsNeedLayout")){var b=this.get("rightAccessoryView");if(b&&b.get){var c=b.get("layout");if(c){c.left=null;if(!c.right)c.right=0;b.adjust({layout:c})}}}arguments.callee.base.apply(this,arguments)},render:function(a,b){arguments.callee.base.apply(this,arguments);this.get("isEnabled");SC.guidFor(this);this.get("isPassword");this.get("isTextArea")&&a.addClass("text-area");var c=this.get("fieldValue");if(SC.none(c))c="";a.setClass("not-empty",c.length>
0);var e=this._getAccessoryViewWidths(),g=e.left;e=e.right;if(g)g+="px";if(e)e+="px";this._renderField(a,b,c,g,e);SC.browser.mozilla&&this.invokeLast(this._applyFirefoxCursorFix)},_forceRenderFirstTime:NO,_renderFieldLikeFirstTime:function(){this.set("_forceRenderFirstTime",YES)}.observes("isTextArea"),_renderField:function(a,b,c,e,g){var d=this.get("hint");if(b||this._forceRenderFirstTime){this._forceRenderFirstTime=NO;b=this.get("isEnabled")?"":'disabled="disabled"';var f=this.get("layerId");a.push('<span class="border"></span>');
var h="";if(e||g){h='style="';if(e)h+="left: "+e+"; ";if(g)h+="right: "+g+";";h+='"'}a.push('<span class="padding" %@>'.fmt(h));a.push('<span class="sc-hint">',d,"</span>");if(this.get("isTextArea"))a.push('<textarea name="%@" %@>%@</textarea></span>'.fmt(f,b,c));else{e=this.get("isPassword")?"password":"text";a.push('<input type="%@" name="%@" %@ value="%@"/></span>'.fmt(e,f,b,c))}}else{a=this.$(".sc-hint");if(d!==this._textField_currentHint){this._textField_currentHint=d;a.text(d)}if(a=this.$input()[0]){a.disabled=
this.get("isEnabled")?null:"true";a=a.parentNode;if(e){if(a.style.left!==e)a.style.left=e}else a.style.left=null;if(g){if(a.style.right!==g)a.style.right=g}else a.style.right=null}}},_getAccessoryViewWidths:function(){for(var a={},b=["left","right"],c=b.length,e=0;e<c;e++){var g=b[e],d=this.get(g+"AccessoryView");if(d&&d.get){var f=d.get("frame");if(f)if(f=f.width){if(d=d.get("layout"))f+=d[g];a[g]=f}}}return a},didCreateLayer:function(){arguments.callee.base.apply(this,arguments);var a=this.$input();
SC.Event.add(a,"focus",this,this._textField_fieldDidFocus);SC.Event.add(a,"blur",this,this._textField_fieldDidBlur);SC.Event.add(a,"select",this,this._textField_selectionDidChange);if(SC.browser.mozilla){this._cacheInputElement=this.$input();this._cachePaddingElement=this.$(".padding")}},willDestroyLayer:function(){arguments.callee.base.apply(this,arguments);var a=this.$input();SC.Event.remove(a,"focus",this,this._textField_fieldDidFocus);SC.Event.remove(a,"blur",this,this._textField_fieldDidBlur);
SC.Event.remove(a,"select",this,this._textField_selectionDidChange)},_textField_fieldDidFocus:function(){SC.RunLoop.begin();this.fieldDidFocus();SC.RunLoop.end()},_textField_fieldDidBlur:function(){SC.RunLoop.begin();this.fieldDidBlur();SC.RunLoop.end()},fieldDidFocus:function(){this.beginEditing()},fieldDidBlur:function(){this.commitEditing()},_topOffsetForFirefoxCursorFix:3,_applyFirefoxCursorFix:function(){if(SC.browser.mozilla){var a,b,c,e,g;g=this._cacheInputElement;if((a=this._cachePaddingElement)&&
a[0]){e=a[0];b=SC.$(e).offset();a=g[0].tagName.toLowerCase()==="input"?b.top+this._topOffsetForFirefoxCursorFix:b.top;b=b.left;c=e.offsetWidth;e=e.offsetHeight;a="position: fixed; top: %@px; left: %@px; width: %@px; height: %@px;".fmt(a,b,c,e);if(!this._prevStyle||this._prevStyle!=a)g.attr("style",a);this._prevStyle=a}}return this},_textField_selectionDidChange:function(){this.notifyPropertyChange("selection")},willBecomeKeyResponderFrom:function(){if(this.get("isVisibleInWindow")){this.$input()[0].focus();
if(!this._txtFieldMouseDown)if(SC.browser.mozilla)this.invokeOnce(this._selectRootElement);else SC.browser.safari?this.invokeLater(this._selectRootElement,1):this._selectRootElement()}},willLoseKeyResponderTo:function(){},_selectRootElement:function(){this.$input()[0].select()},didLoseKeyResponderTo:function(){this.$input()[0].blur()},parentViewDidResize:function(){SC.browser.mozilla&&this.invokeLast(this._applyFirefoxCursorFix);arguments.callee.base.apply(this,arguments)},keyDown:function(a){if(a.which===
13&&!this.get("isTextArea"))return NO;if(a.which===27)return NO;if(a.which===9&&!this.get("isTextArea")){(a.shiftKey?this.get("previousValidKeyView"):this.get("nextValidKeyView")).becomeFirstResponder();return YES}if(a.which===8)a.dontForceDeleteKey=YES;if(this.performValidateKeyDown(a)){this._isKeyDown=YES;a.allowDefault()}else a.stop();return YES},keyUp:function(a){this.notifyPropertyChange("selection");this._isKeyDown&&this.invokeLater(this.fieldValueDidChange,1,YES);this._isKeyDown=NO;a.allowDefault();
return YES},mouseDown:function(a){this._txtFieldMouseDown=YES;if(this.get("isEnabled"))if(this.value&&this.value.length===0||!this.value)return YES;else{SC.browser.mozilla&&this.$input()[0].focus();return arguments.callee.base.apply(this,arguments)}else{a.stop();return YES}},mouseUp:function(a){this._txtFieldMouseDown=NO;this.notifyPropertyChange("selection");if(this.get("isEnabled"))if(this.value&&this.value.length===0||!this.value){this.$input()[0].focus();return YES}else return arguments.callee.base.apply(this,
arguments);else{a.stop();return YES}},selectStart:function(){return YES}});sc_require("views/text_field");
SC.InlineTextFieldView=SC.TextFieldView.extend(SC.DelegateSupport,{_topOffsetForFirefoxCursorFix:0,beginEditing:function(a){if(a){var b={},c,e;this.beginPropertyChanges();if(this.get("isEditing")&&!this.blurEditor()){this.endPropertyChanges();return NO}this._optframe=a.frame;this._optIsCollection=a.isCollection;this._exampleElement=a.exampleElement;this._delegate=a.delegate;if(!this._optframe||!this._delegate)throw"At least frame and delegate options are required for inline editor";this._originalValue=
a.value||"";(this._multiline=a.multiline!==undefined?a.multiline:NO)?this.set("isTextArea",YES):this.set("isTextArea",NO);this._commitOnBlur=a.commitOnBlur!==undefined?a.commitOnBlur:YES;this.set("validator",a.validator);this.set("value",this._originalValue);this.set("isEditing",YES);a=this._delegate.pane();b.height=this._optframe.height;b.width=this._optframe.width;c=this._delegate.get("layout");e=a.$()[0];b.left=this._optIsCollection&&c.left?this._optframe.x-c.left-e.offsetLeft-1:this._optframe.x-
e.offsetLeft-1;SC.browser.msie==7&&b.left--;b.top=this._optIsCollection&&c.top?this._optframe.y-c.top-e.offsetTop:this._optframe.y-e.offsetTop;if(SC.browser.msie==7)b.top-=2;this.set("layout",b);this.set("parentNode",a);a.appendChild(this);SC.RunLoop.begin().end();b=this._delegate;(this._className=this.getDelegateProperty(b,"inlineEditorClassName"))&&!this.hasClassName(this._className)&&this.setClassName(this._className,true);this.invokeDelegateMethod(b,"inlineEditorWillBeginEditing",this);this._previousFirstResponder=
a?a.get("firstResponder"):null;this.endPropertyChanges();this.invokeDelegateMethod(b,"inlineEditorDidBeginEditing",this);this.invokeLast(this.becomeFirstResponder)}},commitEditing:function(){if(!SC.$ok(this.validateSubmit()))return NO;return this._endEditing(this.get("value"))},discardEditing:function(){return this._endEditing(this._originalValue)},blurEditor:function(){if(!this.get("isEditing"))return YES;return this._commitOnBlur?this.commitEditing():this.discardEditing()},_endEditing:function(a){if(!this.get("isEditing"))return YES;
var b=this._delegate;if(!this.invokeDelegateMethod(b,"inlineEditorShouldEndEditing",this,a))return NO;this.invokeDelegateMethod(b,"inlineEditorDidEndEditing",this,a);this._className&&this.setClassName(this._className,false);this._originalValue=this._delegate=this._exampleElement=this._optframe=this._className=null;this.set("isEditing",NO);if(this.get("isFirstResponder"))(a=this.get("pane"))&&this._previousFirstResponder?a.makeFirstResponder(this._previousFirstResponder):this.resignFirstResponder();
this._previousFirstResponder=null;this.get("parentNode")&&this.removeFromParent();return YES},isEditing:NO,mouseDown:function(a){arguments.callee.base.call(this,a);return this.get("isEditing")},keyDown:function(a){a=this.interpretKeyEvents(a);this.fieldValueDidChange(true);return!a?NO:a},insertText:null,willRemoveFromParent:function(){this.$input()[0].blur()},willLoseFirstResponder:function(a){if(a===this){this._previousFirstResponder=null;this.$input()[0].blur();return this.blurEditor()}},cancel:function(){this.discardEditing();
return YES},fieldValueDidChange:function(a){arguments.callee.base.call(this,a)},insertNewline:function(a){if(this._multiline){a.allowDefault();return arguments.callee.base.call(this,a)}else{this.get("value")!=this.$input().val()&&this.set("value",this.$input().val());this.commitEditing();return YES}},insertTab:function(){this.resignFirstResponder();this.commitEditing();var a=this._delegate.nextValidKeyView();a&&a.beginEditing();return YES},insertBacktab:function(){var a=this._delegate.previousValidKeyView();
this.commitEditing();a&&a.beginEditing();return YES},deleteForward:function(a){a.allowDefault();return YES},deleteBackward:function(a){a.allowDefault();return YES}});
SC.InlineTextFieldView.mixin({beginEditing:function(a){this._exampleElement=a.exampleElement;var b=a.exampleInlineTextFieldView?a.exampleInlineTextFieldView:this,c=a.delegate.get("layout"),e=this.updateViewStyle(),g=this.updateViewPaddingStyle(),d=".inline-editor input{"+e+"} ";d=d+".inline-editor textarea{"+e+"} .inline-editor .padding{"+g+"}";e=document.getElementsByTagName("head")[0];g=document.createElement("style");g.type="text/css";g.media="screen";if(g.styleSheet)g.styleSheet.cssText=d;else g.appendChild(document.createTextNode(d));
e.appendChild(g);this.editor=b.create({classNames:"inline-editor",layout:c});return this.editor.beginEditing(a)},commitEditing:function(){return this.editor?this.editor.commitEditing():YES},discardEditing:function(){return this.editor?this.editor.discardEditing():YES},updateViewStyle:function(){var a=this._exampleElement[0],b="",c=SC.getStyle(a,"font-size");if(c&&c.length>0)b=b+"font-size: "+c+" !important; ";if((c=SC.getStyle(a,"font-family"))&&c.length>0)b=b+"font-family: "+c+" !important; ";if((c=
SC.getStyle(a,"font-weight"))&&c.length>0)b=b+"font-weight: "+c+" !important; ";if((c=SC.getStyle(a,"z-index"))&&c.length>0)b=b+"z-index: "+c+" !important; ";if((c=SC.getStyle(a,"line-height"))&&c.length>0)b=b+"line-height: "+c+" !important; ";if((c=SC.getStyle(a,"text-align"))&&c.length>0)b=b+"text-align: "+c+" !important; ";if((c=SC.getStyle(a,"top-margin"))&&c.length>0)b=b+"top-margin: "+c+" !important; ";if((c=SC.getStyle(a,"bottom-margin"))&&c.length>0)b=b+"bottom-margin: "+c+" !important; ";
if((c=SC.getStyle(a,"left-margin"))&&c.length>0)b=b+"left-margin: "+c+" !important; ";if((c=SC.getStyle(a,"right-margin"))&&c.length>0)b=b+"right-margin: "+c+" !important; ";return b},updateViewPaddingStyle:function(){var a=this._exampleElement[0],b="",c=SC.getStyle(a,"padding-top");if(c&&c.length>0)b=b+"top: "+c+" !important; ";if((c=SC.getStyle(a,"padding-bottom"))&&c.length>0)b=b+"bottom: "+c+" !important; ";if((c=SC.getStyle(a,"padding-left"))&&c.length>0)b=b+"left: "+c+" !important; ";if((c=
SC.getStyle(a,"padding-right"))&&c.length>0)b=b+"right: "+c+" !important; ";return b},editor:null});
SC.SelectionSupport={hasSelectionSupport:YES,allowsSelection:YES,allowsMultipleSelection:YES,allowsEmptySelection:YES,firstSelectableObject:function(){return this.get("firstObject")}.property(),selection:function(a,b){var c=(a=this._scsel_selection)?a.get("length"):0,e;if(b===undefined||!this.get("allowsSelection"))b=a;e=b&&b.isEnumerable?b.get("length"):0;if(e>1&&!this.get("allowsMultipleSelection"))if(c>1){b=SC.SelectionSet.create().addObject(a.get("firstObject")).freeze();e=1}else{b=a;e=c}if(e===
0&&!this.get("allowsEmptySelection"))if(c===0){b=(b=this.get("firstSelectableObject"))?SC.SelectionSet.create().addObject(b).freeze():SC.SelectionSet.EMPTY;e=b.get("length")}else{b=a;e=c}if(e===0)b=SC.SelectionSet.EMPTY;return this._scsel_selection=b=b.frozenCopy()}.property("arrangedObjects","allowsEmptySelection","allowsMultipleSelection","allowsSelection").cacheable(),hasSelection:function(){var a=this.get("selection");return!!a&&a.get("length")>0}.property("selection").cacheable(),selectObjects:function(a,
b){if(!a||a.get("length")===0){b||this.set("selection",SC.SelectionSet.EMPTY);return this}var c=this.get("selection");c=b&&c?c.copy():SC.SelectionSet.create();c.addObjects(a).freeze();this.set("selection",c);return this},selectObject:function(a,b){if(a===null){b||this.set("selection",null);return this}else return this.selectObjects([a],b)},deselectObjects:function(a){if(!a||a.get("length")===0)return this;var b=this.get("selection");if(!b||b.get("length")===0)return this;b=b.copy().removeObjects(a).freeze();
this.set("selection",b.freeze());return this},deselectObject:function(a){return a?this.deselectObjects([a]):this},updateSelectionAfterContentChange:function(){var a=this.get("arrangedObjects"),b=this.get("selection"),c=b,e,g;if(c&&a&&c.get("sources").indexOf(a)>=0){e=c.indexSetForSource(a);g=a.get("length");e=e?e.get("max"):0;if(e>g){c=c.copy().remove(a,g,e-g).freeze();this.set("selection",c)}}if(c===b){g=b?b.get("length"):0;e=a?a.get("length"):0;g===0&&!this.get("allowsEmptySelection")&&e>0&&this.notifyPropertyChange("selection")}return this}};
SC.TreeItemContent={isTreeItemContent:YES,treeItemChildren:null,treeItemIsExpanded:YES,treeItemIsGrouped:NO,treeItemDisclosureState:function(){return this.get("treeItemIsExpanded")?SC.BRANCH_OPEN:SC.BRANCH_CLOSED},treeItemCollapse:function(){this.setIfChanged("treeItemIsExpanded",NO)},treeItemExpand:function(){this.setIfChanged("treeItemIsExpanded",YES)},treeItemBranchIndexes:function(){var a=this.get("treeItemChildren"),b,c,e,g;if(!a)return null;b=SC.IndexSet.create();c=a.get("length");for(e=0;e<
c;e++)if(g=a.objectAt(e))g.get("treeItemChildren")&&g.treeItemDisclosureState(this,e)!==SC.LEAF_NODE&&b.add(e);return b.get("length")>0?b:null}};sc_require("views/view");
SC.Pane=SC.View.extend({isPane:YES,page:null,rootResponder:null,currentWindowSize:null,computeParentDimensions:function(){var a=this.get("currentWindowSize"),b={x:0,y:0,width:1E3,height:1E3};if(a){b.width=a.width;b.height=a.height}else if(SC.RootResponder.responder){if(a=SC.RootResponder.responder.get("currentWindowSize")){b.width=a.width;b.height=a.height}}else{if(window.innerHeight){b.width=window.innerWidth;b.height=window.innerHeight}else if(document.documentElement&&document.documentElement.clientHeight){b.width=
document.documentElement.clientWidth;b.height=document.documentElement.clientHeight}else if(document.body){b.width=document.body.clientWidth;b.height=document.body.clientHeight}this.windowSizeDidChange(null,b)}return b},frame:function(){return this.computeFrameWithParentFrame(null)}.property(),windowSizeDidChange:function(a,b){this.set("currentWindowSize",b);this.parentViewDidResize();return this},sendEvent:function(a,b,c){for(c||(c=this.get("firstResponder"));c&&!c.tryToPerform(a,b);)c=c===this?
null:c.get("nextResponder");if(!c&&(c=this.get("defaultResponder"))){if(typeof c===SC.T_STRING)c=SC.objectForPropertyPath(c);c=c?c.isResponderContext?c.sendAction(a,this,b):c.tryToPerform(a,b)?c:null:null}return b.mouseHandler||c},performKeyEquivalent:function(a,b){var c=arguments.callee.base.apply(this,arguments);if(!c){var e=this.get("defaultResponder");if(e){if(e.performKeyEquivalent)c=e.performKeyEquivalent(a,b);c||(c=e.tryToPerform(a,b))}}return c},defaultResponder:null,nextResponder:function(){return null}.property().cacheable(),
firstResponder:null,acceptsKeyPane:YES,isKeyPane:NO,becomeKeyPane:function(){if(this.get("isKeyPane"))return this;this.rootResponder&&this.rootResponder.makeKeyPane(this);return this},resignKeyPane:function(){if(!this.get("isKeyPane"))return this;this.rootResponder&&this.rootResponder.makeKeyPane(null);return this},makeFirstResponder:function(a){var b=this.get("firstResponder"),c=this.get("isKeyPane");if(b===a)return this;b&&b.willLoseFirstResponder(b);if(c){b&&b.willLoseKeyResponderTo(a);a&&a.willBecomeKeyResponderFrom(b)}b&&
b.beginPropertyChanges().set("isFirstResponder",NO).set("isKeyResponder",NO).endPropertyChanges();this.set("firstResponder",a);a&&a.beginPropertyChanges().set("isFirstResponder",YES).set("isKeyResponder",c).endPropertyChanges();if(c){a&&a.didBecomeKeyResponderFrom(b);b&&b.didLoseKeyResponderTo(a)}a&&a.didBecomeFirstResponder(a);return this},_forwardKeyChange:function(a,b,c,e){var g;if(a&&(g=this.get("firstResponder"))){c=c?c.get("firstResponder"):null;(a=this.get("firstResponder"))&&a[b](c);e!==undefined&&
g&&g.set("isKeyResponder",e)}},willLoseKeyPaneTo:function(a){this._forwardKeyChange(this.get("isKeyPane"),"willLoseKeyResponderTo",a,NO);return this},willBecomeKeyPaneFrom:function(a){this._forwardKeyChange(!this.get("isKeyPane"),"willBecomeKeyResponderFrom",a,YES);return this},didLoseKeyPaneTo:function(a){var b=this.get("isKeyPane");this.set("isKeyPane",NO);this._forwardKeyChange(b,"didLoseKeyResponderTo",a);return this},didBecomeKeyPaneFrom:function(a){var b=this.get("isKeyPane");this.set("isKeyPane",
YES);this._forwardKeyChange(!b,"didBecomeKeyResponderFrom",a,YES);return this},isMainPane:NO,focusFrom:function(){},blurTo:function(){},blurMainTo:function(){this.set("isMainPane",NO)},focusMainFrom:function(){this.set("isMainPane",YES)},append:function(){return this.appendTo(document.body)},remove:function(){if(!this.get("isVisibleInWindow"))return this;if(!this.get("isPaneAttached"))return this;var a=this.get("layer");a.parentNode&&a.parentNode.removeChild(a);this.resignKeyPane();a=this.rootResponder;
this.get("isMainPane")&&a.makeMainPane(null);a.panes.remove(this);this.rootResponder=null;this.set("isPaneAttached",NO);this.parentViewDidChange();return this},appendTo:function(a){var b=this.get("layer");b||(b=this.createLayer().get("layer"));if(this.get("isPaneAttached")&&b.parentNode===a)return this;a.insertBefore(b,null);return this.paneDidAttach()},prependTo:function(a){if(this.get("isPaneAttached"))return this;var b=this.get("layer");b||(b=this.createLayer().get("layer"));if(this.get("isPaneAttached")&&
b.parentNode===a)return this;a.insertBefore(b,a.firstChild);return this.paneDidAttach()},before:function(a){if(this.get("isPaneAttached"))return this;var b=this.get("layer");b||(b=this.createLayer().get("layer"));var c=a.parentNode;if(this.get("isPaneAttached")&&b.parentNode===c)return this;c.insertBefore(b,a);return this.paneDidAttach()},after:function(a){var b=this.get("layer");b||(b=this.createLayer().get("layer"));var c=a.parentNode;if(this.get("isPaneAttached")&&b.parentNode===c)return this;
c.insertBefore(b,a.nextSibling);return this.paneDidAttach()},removeFromParent:function(){},paneDidAttach:function(){var a=this.rootResponder=SC.RootResponder.responder;a.panes.add(this);this.set("currentWindowSize",a.computeWindowSize());this.set("isPaneAttached",YES);this.parentViewDidChange();return this},isPaneAttached:NO,recomputeIsVisibleInWindow:function(){var a=this.get("isVisibleInWindow"),b=this.get("isPaneAttached")&&this.get("isVisible");if(a!==b){this.set("isVisibleInWindow",b);b&&this.get("layerNeedsUpdate")&&
this.updateLayerIfNeeded();b&&this.get("childViewsNeedLayout")&&this.layoutChildViewsIfNeeded();a=this.get("childViews");var c=a.length,e;for(e=0;e<c;e++)a[e].recomputeIsVisibleInWindow(b);!b&&this.get("isFirstResponder")&&this.resignFirstResponder()}if(b){this.parentViewDidResize&&this.parentViewDidResize();this.get("childViewsNeedLayout")&&this.invokeOnce(this.layoutChildViewsIfNeeded)}return this},updateLayerLocation:function(){return this},init:function(){var a=!!this.get("layer");arguments.callee.base.apply(this,
arguments);a&&this.paneDidAttach()},classNames:"sc-pane".w()});sc_require("mixins/tree_item_content");sc_require("mixins/collection_content");
SC.TreeItemObserver=SC.Object.extend(SC.Array,SC.CollectionContent,{item:null,delegate:null,parentObserver:null,parentItem:function(){var a=this.get("parentObserver");return a?a.get("item"):null}.property("parentObserver").cacheable(),index:null,outlineLevel:0,children:null,disclosureState:SC.BRANCH_OPEN,branchIndexes:function(){var a=this.get("item"),b,c,e,g,d;if(a)if(a.isTreeItemContent){c=this.get("parentItem");e=this.get("index");return a.treeItemBranchIndexes(c,e)}else{g=this.get("children");
if(!g)return null;d=SC.IndexSet.create();b=g.get("length");c=a;for(e=0;e<b;e++)if(a=g.objectAt(e))this._computeChildren(a,c,e)&&this._computeDisclosureState(a,c,e)!==SC.LEAF_NODE&&d.add(e);return d.get("length")>0?d:null}else return SC.IndexSet.EMPTY}.property("children").cacheable(),isHeaderVisible:function(){return!!this.get("parentObserver")}.property("parentObserver").cacheable(),length:0,objectAt:function(a){var b=this.get("length"),c=this.get("item"),e=this._objectAtCache,g=a,d;if(!(a>=b)){if(this.get("isHeaderVisible"))if(a===
0)return c;else g--;c=null;if(!e)e=this._objectAtCache=[];if((c=e[a])!==undefined)return c;if(d=this.get("children")){if(b=this.get("branchIndexes"))b.forEach(function(f){if(!(c||f>g)){var h=this.branchObserverAt(f),i;if(h){i=h.get("length");if(f+i>g){c=h.objectAt(g-f);g=-1}else g-=i-1}}},this);if(g>=0)c=d.objectAt(g);return e[a]=c}}},replace:function(a,b,c,e){var g=a,d=null,f,h;if(e===undefined)e=SC.DROP_BEFORE;this.get("isHeaderVisible")&&g--;if(g<0)throw"Tree Item cannot replace itself";if(a=this.get("branchIndexes"))a.forEach(function(i){if(!(d||
i>=g))if(d=this.branchObserverAt(i)){f=d.get("length");if(i+f===g&&e===SC.DROP_AFTER)g-=i;else if(i+f>g)g-=i;else{g-=f-1;d=null}}},this);if(d){d.replace(g,b,c,e);return this}h=g+b;b>1&&a&&a.forEachIn(g,a.get("max")-g,function(i){if(!(i>h))if(d=this.branchObserverAt(i)){f=d.get("length");h-=f-1}},this);b=h-g;a=this.get("children");if(!a)throw"cannot replace() tree item with no children";if(b<0||h>a.get("length"))throw"replace() range must lie within a single tree item";a.replace(g,b,c,e);return this},
observerContentDidChange:function(a,b,c){this.invalidateBranchObserversAt(a);this._disclosureStateCache=this._objectAtCache=this._outlineLevelCache=null;this._contentGroupIndexes=NO;this.notifyPropertyChange("branchIndexes");var e=this.get("length"),g=this._computeLength();c=this.get("parentObserver");e!==g&&this.set("length",g);if(!this._notifyParent)return this;if(c){a=SC.IndexSet.create(this.get("index"));c._childrenRangeDidChange(c.get("children"),null,"[]",a)}else{if(e===g){b=this.expandChildIndex(a+
b);a=this.expandChildIndex(a);b-=a;c=0}else{a=this.expandChildIndex(a);b=g-a;c=g-e}this.enumerableContentDidChange(a,b,c)}},expandChildIndex:function(a){var b=a;this.get("isHeaderVisible")&&a++;var c=this.get("branchIndexes");if(!c||c.get("length")===0)return b;c.forEachIn(0,a,function(e){b+=this.branchObserverAt(e).get("length")-1},this);return b},_contentGroupIndexes:NO,contentGroupIndexes:function(a,b){if(b!==this)return null;var c=this._contentGroupIndexes;if(c!==NO)return c;if(this.get("parentObserver"))return null;
a=this.get("item");var e,g;if(a&&a.isTreeItemContent?a.get("treeItemIsGrouped"):!!this.delegate.get("treeItemIsGrouped")){c=SC.IndexSet.create();a=this.get("branchIndexes");b=(b=this.get("children"))?b.get("length"):0;e=g=0;a&&a.forEach(function(d){c.add(e,d+1-g);e+=d+1-g;g=d+1;if(d=this.branchObserverAt(d))e+=d.get("length")-1},this);g<b&&c.add(e,b-g)}else c=null;return this._contentGroupIndexes=c},contentIndexIsGroup:function(a,b,c){return(a=this.contentGroupIndexes(a,b))?a.contains(c):NO},contentIndexOutlineLevel:function(a,
b,c){if(b!==this)return-1;if((b=this._outlineLevelCache)&&b[c]!==undefined)return b[c];if(!b)b=this._outlineLevelCache=[];var e=this.get("length"),g=c,d=null;if(c>=e)return-1;if(this.get("isHeaderVisible"))if(c===0)return b[0]=this.get("outlineLevel")-1;else g--;if(e=this.get("branchIndexes"))e.forEach(function(f){if(!(d!==null||f>g)){var h=this.branchObserverAt(f),i;if(h){i=h.get("length");if(f+i>g){d=h.contentIndexOutlineLevel(a,h,g-f);g=-1}else g-=i-1}}},this);if(g>=0)d=this.get("outlineLevel");
return b[c]=d},contentIndexDisclosureState:function(a,b,c){if(b!==this)return-1;if((b=this._disclosureStateCache)&&b[c]!==undefined)return b[c];if(!b)b=this._disclosureStateCache=[];var e=this.get("length"),g=c,d=null;if(c>=e)return SC.LEAF_NODE;if(this.get("isHeaderVisible"))if(c===0)return b[0]=this.get("disclosureState");else g--;if(e=this.get("branchIndexes"))e.forEach(function(f){if(!(d!==null||f>g)){var h=this.branchObserverAt(f),i;if(h){i=h.get("length");if(f+i>g){d=h.contentIndexDisclosureState(a,
h,g-f);g=-1}else g-=i-1}}},this);if(g>=0)d=SC.LEAF_NODE;return b[c]=d},contentIndexExpand:function(a,b,c){var e=c;if(b===this){if(this.get("isHeaderVisible"))if(c===0){this._expand(this.get("item"));return}else e--;if(b=this.get("branchIndexes"))b.forEach(function(g){if(!(g>=e)){var d=this.branchObserverAt(g),f;if(d){f=d.get("length");if(g+f>e){d.contentIndexExpand(a,d,e-g);e=-1}else e-=f-1}}},this);if(e>=0)(b=(b=this.get("children"))?b.objectAt(e):null)&&this._expand(b,this.get("item"),e)}},contentIndexCollapse:function(a,
b,c){var e=c;if(b===this){if(this.get("isHeaderVisible"))if(c===0){this._collapse(this.get("item"));return}else e--;if(b=this.get("branchIndexes"))b.forEach(function(g){if(!(g>=e)){var d=this.branchObserverAt(g),f;if(d){f=d.get("length");if(g+f>e){d.contentIndexCollapse(a,d,e-g);e=-1}else e-=f-1}}},this);if(e>=0)(b=(b=this.get("children"))?b.objectAt(e):null)&&this._collapse(b,this.get("item"),e)}},branchObserverAt:function(a){var b=this._branchObserversByIndex,c=this._branchObserverIndexes,e;if(!b)b=
this._branchObserversByIndex=[];if(!c)c=this._branchObserverIndexes=SC.IndexSet.create();if(e=b[a])return e;e=(e=this.get("children"))?e.objectAt(a):null;if(!e)return null;b[a]=e=SC.TreeItemObserver.create({item:e,delegate:this.get("delegate"),parentObserver:this,index:a,outlineLevel:this.get("outlineLevel")+1});c.add(a);return e},invalidateBranchObserversAt:function(a){var b=this._branchObserversByIndex,c=this._branchObserverIndexes;if(!b||b.length<=a)return this;if(a<0)a=0;c.forEachIn(a,c.get("max")-
a,function(e){(e=b[e])&&e.destroy()},this);b.length=a;return this},init:function(){arguments.callee.base.apply(this,arguments);var a=this.get("item");if(!a)throw"SC.TreeItemObserver.item cannot be null";a.addObserver("*",this,this._itemPropertyDidChange);this._itemPropertyDidChange(a,"*");this._notifyParent=YES},destroy:function(){this.invalidateBranchObserversAt(0);this._objectAtCache=null;var a=this.get("item");a&&a.removeObserver("*",this,this._itemPropertyDidChange);a=this._children;var b=this._childrenRangeObserver;
a&&b&&a.removeRangeObserver(b);arguments.callee.base.apply(this,arguments)},_itemPropertyDidChange:function(){var a=this.get("children"),b=this.get("disclosureState"),c=this.get("item"),e;this.beginPropertyChanges();e=this._computeDisclosureState(c);b!==e&&this.set("disclosureState",e);e=this._computeChildren(c);a!==e&&this.set("children",e);this.endPropertyChanges()},_childrenDidChange:function(){var a=this.get("disclosureState")===SC.BRANCH_OPEN?this.get("children"):null,b=this._children,c=this._childrenRangeObserver;
if(b===a)return this;c&&b.removeRangeObserver(c);this._childrenRangeObserver=a?a.addRangeObserver(null,this,this._childrenRangeDidChange):null;this._children=a;this._childrenRangeDidChange(a,null,"[]",null)}.observes("children","disclosureState"),_childrenRangeDidChange:function(a,b,c,e){a=(a=this.get("children"))?a.get("length"):0;b=e?e.get("min"):0;e=e?e.get("max"):a;c=this._childrenLen||0;this._childrenLen=a;this.observerContentDidChange(b,e-b,a-c)},_computeDisclosureState:function(a,b,c){if(!a||
!this._computeChildren(a))return SC.LEAF_NODE;else if(a.isTreeItemContent){if(b===undefined)b=this.get("parentItem");if(c===undefined)c=this.get("index");return a.treeItemDisclosureState(b,c)}else{b=this._treeItemIsExpandedKey;if(!b)this._treeItemIsExpandedKey=b=(b=this.get("delegate"))?b.get("treeItemIsExpandedKey"):"treeItemIsExpanded";return a.get(b)?SC.BRANCH_OPEN:SC.BRANCH_CLOSED}},_collapse:function(a,b,c){if(!a||!this._computeChildren(a))return this;else if(a.isTreeItemContent){if(b===undefined)b=
this.get("parentItem");if(c===undefined)c=this.get("index");a.treeItemCollapse(b,c)}else{b=this._treeItemIsExpandedKey;if(!b)this._treeItemIsExpandedKey=b=(b=this.get("delegate"))?b.get("treeItemIsExpandedKey"):"treeItemIsExpanded";a.setIfChanged(b,NO)}return this},_expand:function(a,b,c){if(!a||!this._computeChildren(a))return this;else if(a.isTreeItemContent){if(b===undefined)b=this.get("parentItem");if(c===undefined)c=this.get("index");a.treeItemExpand(b,c)}else{b=this._treeItemIsExpandedKey;if(!b)this._treeItemIsExpandedKey=
b=(b=this.get("delegate"))?b.get("treeItemIsExpandedKey"):"treeItemIsExpanded";a.setIfChanged(b,YES)}return this},_computeChildren:function(a){var b;if(a)if(a.isTreeItemContent)return a.get("treeItemChildren");else{b=this._treeItemChildrenKey;if(!b)this._treeItemChildrenKey=b=(b=this.get("delegate"))?b.get("treeItemChildrenKey"):"treeItemChildren";return a.get(b)}else return null},_computeLength:function(){var a=this.get("isHeaderVisible")?1:0,b=this.get("disclosureState"),c=this.get("children");
if(b===SC.BRANCH_OPEN&&c){a+=c.get("length");if(b=this.get("branchIndexes"))b.forEach(function(e){e=this.branchObserverAt(e);a+=e.get("length")-1},this)}return a}});sc_require("system/responder");
SC.ResponderContext=SC.Responder.extend({isResponderContext:YES,trace:NO,defaultResponder:null,nextResponder:function(){return this.get("defaultResponder")}.property("defaultResponder").cacheable(),firstResponder:null,nextResponderFor:function(a){var b=a.get("nextResponder");if(typeof b===SC.T_STRING)b=SC.objectForPropertyPath(b,this);else if(!b&&a!==this)b=this;return b},responderNameFor:function(a){if(a){if(a._scrc_name)return a._scrc_name}else return"(No Responder)";this._findResponderNamesFor(this,
3,this.NAMESPACE?[this.NAMESPACE]:[]);return a._scrc_name||a.toString()},_findResponderNamesFor:function(a,b,c){var e,g;for(e in a)if(e!=="nextResponder")if((g=a[e])&&g.isResponder)if(!g._scrc_name){c.push(e);g._scrc_name=c.join(".");b>0&&this._findResponderNamesFor(g,b-1,c);c.pop()}},makeFirstResponder:function(a){var b=this.get("firstResponder"),c=this.get("nextResponder"),e=this.get("trace");if(this._locked){e&&console.log("%@: AFTER ACTION: makeFirstResponder => %@".fmt(this,this.responderNameFor(a)));
this._pendingResponder=a}else{e&&console.log("%@: makeFirstResponder => %@".fmt(this,this.responderNameFor(a)));this._locked=YES;this._pendingResponder=null;for(e=a?this.nextResponderFor(a):null;e;){if(e.get("hasFirstResponder"))break;e=e===c?null:this.nextResponderFor(e)}e||(e=c);this._notifyWillLoseFirstResponder(b,b,e);b&&b.set("isFirstResponder",NO);this.set("firstResponder",a);a&&a.set("isFirstResponder",YES);this._notifyDidBecomeFirstResponder(a,a,e);this._locked=NO;if(this._pendingResponder){this.makeFirstResponder(this._pendingResponder);
this._pendingResponder=null}return this}},_notifyWillLoseFirstResponder:function(a,b,c){if(b!==c){b.willLoseFirstResponder(a);b.set("hasFirstResponder",NO);(b=this.nextResponderFor(b))&&this._notifyWillLoseFirstResponder(a,b,c)}},_notifyDidBecomeFirstResponder:function(a,b,c){if(b!==c){var e=this.nextResponderFor(b);e&&this._notifyDidBecomeFirstResponder(a,e,c);b.set("hasFirstResponder",YES);b.didBecomeFirstResponder(a)}},sendAction:function(a,b,c){var e=this.get("firstResponder"),g=this.get("nextResponder"),
d=this.get("trace"),f=NO;this._locked=YES;for(d&&console.log("%@: begin action '%@' (%@, %@)".fmt(this,a,b,c));!f&&e;){if(e.tryToPerform)f=e.tryToPerform(a,b,c);f||(e=e===g?null:this.nextResponderFor(e))}if(d)f?console.log("%@: action '%@' handled by %@".fmt(this,a,this.responderNameFor(e))):console.log("%@:  action '%@' NOT HANDLED".fmt(this,a));this._locked=NO;if(a=this._pendingResponder){this._pendingResponder=null;this.makeFirstResponder(a)}return e}});sc_require("system/responder_context");
SC.Application=SC.ResponderContext.extend({});sc_require("core");
SC.Benchmark={verbose:NO,enabled:YES,stats:{},globalStartTime:null,start:function(a,b,c,e){if(this.enabled){c=c||Date.now();b=b?this._subStatFor(a,b):this._statFor(a);e&&b._starts.length>0?b._starts.push("ignore"):b._starts.push(c);b._times.push({start:c,_subStats:{}});return a}},end:function(a,b,c){if(this.enabled){b=b?this._subStatFor(a,b):this._statFor(a);var e=b._starts.pop();if(e){if(e!="ignore"){c=c||Date.now();e=c-e;b._times[b._times.length-1].end=c;b._times[b._times.length-1].dur=e;b.amt+=
e;b.runs++;this.verbose&&this.log(a)}}else console.log('SC.Benchmark "%@" ended without a matching start.  No information was saved.'.fmt(a))}},setGlobalStartTime:function(a){this.globalStartTime=a},bench:function(a,b,c){b||(b="bench%@".fmt(this._benchCount++));c||(c=1);for(var e;--c>=0;){var g=SC.Benchmark.start(b);e=a();SC.Benchmark.end(g)}return e},install:function(a,b,c){a["b__"+b]=a[b];var e=a["b__"+b];a[b]=function(){var g="%@(%@)".fmt(b,$A(arguments).join(", "));SC.Benchmark.start(g,c);var d=
e.apply(this,arguments);SC.Benchmark.end(g);return d}},restore:function(a,b){a[b]=a["b__"+b]},report:function(a){if(a)return this._genReport(a);a=[];for(var b in this.stats)this.stats.hasOwnProperty(b)&&a.push(this._genReport(b));return a.join("\n")},timelineReport:function(a){a=a?"SproutCore Application":a;a=[a,"User-Agent: %@".fmt(navigator.userAgent),"Report Generated: %@ (%@)".fmt((new Date).toString(),Date.now()),""];for(var b=this._compileChartData(true),c=0;c<b.length;c++)b[c][4]?a.push(this._timelineGenSubReport(b[c])):
a.push(this._timelineGenReport(b[c]));return a.join("\n")},timelineChart:function(a){var b=0;this.hideChart();var c=this._compileChartData(false),e=c.length;if(e!==0){var g=this.globalStartTime?this.globalStartTime:c[0][1];b=c[e-1][2]-g;var d=50+e*30,f=Math.ceil(b/200)+1,h=f*50,i=document.createElement("div");i.className="sc-benchmark-graph";document.body.appendChild(i);var j=document.createElement("div");j.innerHTML=(a?a:"SproutCore Application")+(" - Total Captured Time: "+b+" ms - Points Captured: "+
e)+' [<a href="javascript:SC.Benchmark.hideChart();">Hide Chart</a>]';j.className="sc-benchmark-title";i.appendChild(j);b=document.createElement("div");b.className="sc-benchmark-top";b.style.width=h+"px";i.appendChild(b);for(b=0;b<f;b++){a=document.createElement("div");a.className="sc-benchmark-tick";a.style.left=b*50+"px";a.style.height=d+"px";j=document.createElement("div");j.className="sc-benchmark-tick-label";j.style.left=b*50+"px";j.innerHTML=b*200+" ms";i.appendChild(a);i.appendChild(j)}for(b=
0;b<e;b++){d=document.createElement("div");d.style.top=75+b*30+"px";d.style.width=h+"px";d.className=b%2===0?"sc-benchmark-row even":"sc-benchmark-row";i.appendChild(d);d=document.createElement("div");f=c[b][1];a=c[b][2];j=c[b][3];d.innerHTML="&nbsp;"+(c[b][0]+" <span class='sc-benchmark-emphasis'>"+j+"ms</span>");d.className="sc-benchmark-bar";d.style.cssText="left:"+(f-g)/4+"px; width: "+j/4+"px; top: "+(53+b*30)+"px;";d.title="start: "+(f-g)+" ms, end: "+(a-g)+" ms, duration: "+j+" ms";i.appendChild(d)}this._graph=
i}},hideChart:function(){if(this._graph)try{document.body.removeChild(this._graph)}catch(a){}},log:function(a){console.log(this.report(a))},startProfile:function(a){this.enabled&&console&&console.profile&&console.profile(a)},endProfile:function(a){this.enabled&&console&&console.profileEnd&&console.profileEnd(a)},_compileChartData:function(a){var b=[],c;for(var e in this.stats)for(var g=this.stats[e],d=0;d<g._times.length;d++){var f=g._times[d];c=g._times.length>1?d+1+" - "+e:e;b.push([c,f.start,f.end,
f.dur,false]);if(a){f=f._subStats;for(var h in f)for(var i=f[h],j=0;j<i._times.length;j++){var k=i._times[j];c=i._times.length>1?j+1+" - "+h:h;b.push([c,k.start,k.end,k.dur,true])}}}b.sort(function(l,o){if(l[1]<o[1])return-1;else if(l[1]==o[1]){if(l[3]&&!o[3])return-1;if(!l[3]&&o[3])return 1;return 0}return 1});return b},_genReport:function(a){var b=this._statFor(a);return"BENCH %@ msec: %@ (%@x)".fmt(b.runs>0?Math.floor(b.amt*1E3/b.runs)/1E3:0,b.name||a,b.runs)},_timelineGenReport:function(a){return this.globalStartTime?
"BENCH start: %@ msec, duration: %@ msec,  %@".fmt(a[1]-this.globalStartTime,a[3],a[0]):"BENCH duration: %@ msec, %@".fmt(a[3],a[0])},_timelineGenSubReport:function(a){return this.globalStartTime?"   CHECKPOINT BENCH start: %@ msec, duration: %@ msec,  %@".fmt(a[1]-this.globalStartTime,a[3],a[0]):"   CHECKPOINT BENCH duration: %@ msec, %@".fmt(a[3],a[0])},_subStatFor:function(a,b){if(this.stats[b]._times.length!==0){b=this.stats[b]._times[this.stats[b]._times.length-1]._subStats;var c=b[a];if(!c){b[a]=
{runs:0,amt:0,name:a,_starts:[],_times:[]};c=b[a]}return c}},_statFor:function(a){var b=this.stats[a];if(!b){this.stats[a]={runs:0,amt:0,name:a,_starts:[],_times:[]};b=this.stats[a]}return b},reset:function(){this.stats={}},_bench:function(a,b){SC.Benchmark.bench(a,b,1)},_benchCount:1};SC.Benchmark=SC.Benchmark;
SC.mixin({logBundleLoading:NO,bundleIsLoaded:function(a){return(a=SC.BUNDLE_INFO[a])?!!a.loaded:NO},_scb_bundleDidLoad:function(a,b,c,e){var g=c,d=b;if(SC.typeOf(b)===SC.T_STRING)d=SC.objectForPropertyPath(b);if(SC.typeOf(c)===SC.T_STRING)g=SC.objectForPropertyPath(c,d);if(!g)if(SC.LAZY_INSTANTIATION[a]){var f=SC.LAZY_INSTANTIATION[a];SC.logBundleLoading&&console.log("SC.loadBundle(): Bundle '%@' is marked for lazy instantiation, instantiating it now\u2026".fmt(a));for(var h=0,i=f.length;h<i;h++)try{f[h]()}catch(j){console.log("SC.loadBundle(): Failted to lazily instatiate entry for  '%@'".fmt(a))}delete SC.LAZY_INSTANTIATION[a];
if(SC.typeOf(b)===SC.T_STRING)d=SC.objectForPropertyPath(b);if(SC.typeOf(c)===SC.T_STRING)g=SC.objectForPropertyPath(c,d);if(!c)throw"SC.loadBundle(): could not find callback for lazily instantiated bundle '%@'".fmt(a);}else throw"SC.loadBundle(): could not find callback for '%@'".fmt(a);e||(e=[]);e.push(a);(a=!!SC.RunLoop.currentRunLoop)&&SC.RunLoop.begin();g.apply(d,e);a&&SC.RunLoop.end()},tryToLoadBundle:function(a,b,c){var e,g;if(SC.typeOf(b)===SC.T_STRING)g=SC.objectForPropertyPath(b);if(SC.typeOf(c)===
SC.T_STRING)e=SC.objectForPropertyPath(c,g);if(e||SC.LAZY_INSTANTIATION[a]){SC.logBundleLoading&&console.log("SC.loadBundle(): Bundle '%@' found through other means, will attempt to load\u2026".fmt(a));SC.BUNDLE_INFO[a]={loaded:YES};return SC.BUNDLE_INFO[a]}return NO},loadBundle:function(a,b,c){var e,g;if(c===undefined&&SC.typeOf(b)===SC.T_FUNCTION){c=b;b=null}var d=SC.BUNDLE_INFO[a],f=SC.A(arguments).slice(3);SC.logBundleLoading&&console.log("SC.loadBundle(): Attempting to load '%@'".fmt(a));if(!d){SC.logBundleLoading&&
console.log("SC.loadBundle(): Attemping to load %@ without SC.BUNDLE_INFO entry\u2026 could be loaded through other means.".fmt(a));d=this.tryToLoadBundle(a,b,c,f)}if(d)if(d.loaded){SC.logBundleLoading&&console.log("SC.loadBundle(): Bundle '%@' already loaded, skipping.".fmt(a));if(c)SC.isReady?SC._scb_bundleDidLoad(a,b,c,f):SC.ready(SC,function(){SC._scb_bundleDidLoad(a,b,c,f)})}else{SC.logBundleLoading&&console.log("SC.loadBundle(): Bundle '%@' is not loaded, loading now.".fmt(a));e=d.callbacks||
[];if(c){e.push(function(){SC._scb_bundleDidLoad(a,b,c,f)});d.callbacks=e}if(!d.loading){var h=d.requires||[],i=YES;e=0;for(g=h.length;e<g;++e){var j=h[e],k=SC.BUNDLE_INFO[j];if(k)if(k.loading){i=NO;break}else{if(!k.loaded){i=NO;e=k.dependents;if(!e)k.dependents=e=[];e.push(a);SC.logBundleLoading&&console.log("SC.loadBundle(): '%@' depends on '%@', loading dependency\u2026".fmt(a,j));SC.loadBundle(j);break}}else throw"SC.loadBundle(): could not find required bundle '%@' for bundle '%@'".fmt(j,a);
}if(i){h=document.getElementsByTagName("head")[0];if(!h)h=document.documentElement;j=d.styles||[];e=0;for(g=j.length;e<g;++e){i=j[e];if(i.length>0){k=document.createElement("link");k.setAttribute("href",i);k.setAttribute("rel","stylesheet");k.setAttribute("type","text/css");h.appendChild(k)}}e=this._jsBundleLoadQueue;if(!e)this._jsBundleLoadQueue=e={};e[a]=[];k=e[a];j=d.scripts||[];e=0;for(g=j.length;e<g;++e){i=j[e];i.length>0&&k.push(i)}d.loading=YES;this.scriptDidLoad(a)}}}else throw"SC.loadBundle(): could not find bundle '%@'".fmt(a);
},scriptDidLoad:function(a){var b=this._jsBundleLoadQueue;if(b)if(b=b[a]){b=b.shift();SC.logBundleLoading&&console.log("SC.scriptDidLoad(): Loading next file in '%@' -> '%@'".fmt(a,b));a=document.createElement("script");a.setAttribute("type","text/javascript");a.setAttribute("src",b);document.body.appendChild(a)}},bundleDidLoad:function(a){var b=SC.BUNDLE_INFO[a];if(b)if(b.loaded&&SC.logBundleLoading)console.log("SC.bundleDidLoad() called more than once for bundle '%@'. Skipping.".fmt(a));else{delete b.loading;
b.loaded=YES;SC.isReady?SC._invokeCallbacksForBundle(a):SC.ready(SC,function(){SC._invokeCallbacksForBundle(a)});b=b.dependents||[];for(var c=0,e=b.length;c<e;++c){SC.logBundleLoading&&console.log("SC.loadBundle(): Bundle '%@' has completed loading, loading '%@' that depended on it.".fmt(a,b[c]));SC.loadBundle(b[c])}}else b=SC.BUNDLE_INFO[a]={loaded:YES}},_invokeCallbacksForBundle:function(a){var b=SC.BUNDLE_INFO[a];if(b){SC.logBundleLoading&&console.log("SC.loadBundle(): Bundle '%@' has completed loading, invoking callbacks.".fmt(a));
a=b.callbacks||[];SC.RunLoop.begin();b=0;for(var c=a.length;b<c;++b)a[b]();SC.RunLoop.end()}}});sc_require("system/locale");SC.IMAGE_ABORTED_ERROR=SC.$error("SC.Image.AbortedError","Image",-100);SC.IMAGE_FAILED_ERROR=SC.$error("SC.Image.FailedError","Image",-101);
SC.imageCache=SC.Object.create({loadLimit:4,activeRequests:0,loadImage:function(a,b,c,e){SC.typeOf(b);if(SC.none(c)&&SC.typeOf(b)===SC.T_FUNCTION)c=b=null;if(SC.typeOf(c)===SC.T_STRING)c=b[c];if(SC.none(e))e=SC.none(b)&&SC.none(c);a=this._imageEntryFor(a);if(a.status===this.IMAGE_LOADED){if(c)c.call(b||a.image,a.url,a.image)}else{if(b||c)this._addCallback(a,b,c);a.retainCount++;this._scheduleImageEntry(a,e)}},releaseImage:function(a,b,c){a=this._imageEntryFor(a,NO);if(!a)return this;if(--a.retainCount<=
0)this._deleteEntry(a);else if(b||c){SC.typeOf(b);if(SC.none(c)&&SC.typeOf(b)===SC.T_FUNCTION)c=b=null;if(SC.typeOf(c)===SC.T_STRING)c=b[c];this._removeCallback(a,b,c)}},reloadImage:function(a){if((a=this._imageEntryFor(a,NO))&&a.status===this.IMAGE_LOADED)a.status=this.IMAGE_WAITING},loadNextImage:function(){var a=null,b;if(!(this.get("activeRequests")>=this.get("loadLimit"))){for(b=this._foregroundQueue;b.length>0&&!a;)a=b.shift();if(!a)for(b=this._backgroundQueue;b.length>0&&!a;)a=b.shift();this.set("isLoading",
!!a);if(a){b=a.image;b.onabort=this._imageDidAbort;b.onerror=this._imageDidError;b.onload=this._imageDidLoad;b.src=a.url;this._loading.push(a);this.incrementProperty("activeRequests");this.loadNextImage()}}},_imageEntryFor:function(a,b){if(b===undefined)b=YES;var c=this._images[a];if(!c&&b){b=new Image;c=this._images[a]={url:a,status:this.IMAGE_WAITING,callbacks:[],retainCount:0,image:b};b.entry=c}return c},_deleteEntry:function(a){this._unscheduleEntry(a);delete this._images[a.url]},_addCallback:function(a,
b,c){a=a.callbacks;a.find(function(e){return e[0]===b&&e[1]===c},this)||a.push([b,c]);a=null;return this},_removeCallback:function(a,b,c){var e=a.callbacks;e.forEach(function(g,d){if(g[0]===b&&g[1]===c)e[d]=null},this);e=null;return this},_scheduleImageEntry:function(a,b){var c=this._backgroundQueue,e=this._foregroundQueue;if(a.status===this.IMAGE_LOADED)return this;if(a.status===this.IMAGE_QUEUE&&!b&&a.isBackground){c[c.indexOf(a)]=null;a.status=this.IMAGE_WAITING}if(a.status!==this.IMAGE_QUEUE){(b?
c:e).push(a);a.status=this.IMAGE_QUEUE;a.isBackground=b}this.isLoading||this.invokeLater(this.loadNextImage,100);this.set("isLoading",YES);return this},_unscheduleImageEntry:function(a){if(a.status!==this.IMAGE_QUEUE)return this;var b=a.isBackground?this._backgroundQueue:this._foregroundQueue;b[b.indexOf(a)]=null;if(this._loading.indexOf(a)>=0){b.image.abort();this.imageStatusDidChange(a,this.ABORTED)}return this},_imageDidAbort:function(){SC.imageCache.imageStatusDidChange(this.entry,SC.imageCache.ABORTED)},
_imageDidError:function(){SC.imageCache.imageStatusDidChange(this.entry,SC.imageCache.ERROR)},_imageDidLoad:function(){SC.imageCache.imageStatusDidChange(this.entry,SC.imageCache.LOADED)},imageStatusDidChange:function(a,b){if(a){var c=a.url,e;switch(b){case this.LOADED:e=a.image;break;case this.ABORTED:e=SC.IMAGE_ABORTED_ERROR;break;case this.ERROR:e=SC.IMAGE_FAILED_ERROR;break;default:e=SC.IMAGE_FAILED_ERROR;break}a.callbacks.forEach(function(d){d[1].call(d[0],c,e)},this);a.callbacks=[];a.status=
b===this.LOADED?this.IMAGE_LOADED:this.IMAGE_WAITING;var g=a.image;if(g){g.onload=g.onerror=g.onabort=null;if(b!==this.LOADED)a.image=null}this._loading[this._loading.indexOf(a)]=null;if(this._loading.length>this.loadLimit*2)this._loading=this._loading.compact();this.decrementProperty("activeRequests");this.loadNextImage()}},init:function(){arguments.callee.base.apply(this,arguments);this._images={};this._loading=[];this._foregroundQueue=[];this._backgroundQueue=[]},IMAGE_LOADED:"loaded",IMAGE_QUEUED:"queued",
IMAGE_WAITING:"waiting",ABORTED:"aborted",ERROR:"error",LOADED:"loaded"});
SC.Page=SC.Object.extend({owner:null,get:function(a){var b=this[a];if(b&&b.isClass){this[a]=b=b.create({page:this});this.get("inDesignMode")||b.awake();return b}else return arguments.callee.base.apply(this,arguments)},awake:function(){for(var a in this)if(this.hasOwnProperty(a)){var b=this[a];if(b&&b.isViewClass)this[a]=b.create({page:this})}return this},getIfConfigured:function(a){var b=this[a];return b&&b.isViewClass?null:this.get(a)},loc:function(a){for(var b in a)if(a.hasOwnProperty(b)){var c=
this[b];c&&c.isViewClass&&c.loc(a[b])}return this}});SC.Page.design=SC.Page.create;SC.Page.localization=function(a){return a};sc_require("system/event");
SC.mixin({_isReadyBound:NO,_bindReady:function(){if(!this._isReadyBound){this._isReadyBound=YES;tiki.require("system").ready(this,this._didBecomeReady)}},_readyQueue:[],_afterReadyQueue:[],isReady:NO,_didBecomeReady:function(){if(!SC.isReady){typeof SC.mapDisplayNames===SC.T_FUNCTION&&SC.mapDisplayNames();SC.Locale.createCurrentLocale();if(document&&document.getElementsByTagName){var a=document.getElementsByTagName("body")[0];if(a){var b=a.className,c=SC.Locale.currentLanguage.toLowerCase();a.className=
b&&b.length>0?[b,c].join(" "):c}}SC.Benchmark.start("ready");SC.RunLoop.begin();var e;do{a=SC._readyQueue;SC._readyQueue=[];b=0;for(c=a.length;b<c;b++){e=a[b];var g=e[0]||document;(e=e[1])&&e.call(g)}}while(SC._readyQueue.length>0);SC.isReady=YES;SC._readyQueue=null;SC.Event.trigger("ready",null,document,NO);SC.removeLoading&&SC.$("#loading").remove();SC.mode===SC.APP_MODE&&typeof main!="undefined"&&main instanceof Function&&!SC.suppressMain&&main();SC.routes&&SC.routes.ping&&SC.routes.ping();SC.RunLoop.end();
SC.Benchmark.end("ready");SC.Benchmark.log()}},ready:function(a,b){var c=this._readyQueue;if(b===undefined){b=a;a=null}else if(SC.typeOf(b)===SC.T_STRING)b=a[b];if(!b)return this;if(this.isReady)return b.call(a||document);c.push([a,b]);return this}});SC._bindReady();SC.removeLoading=YES;SC.APP_MODE="APP_MODE";SC.TEST_MODE="TEST_MODE";SC.mode=SC.APP_MODE;sc_require("system/builder");SC.MODE_REPLACE="replace";SC.MODE_APPEND="append";SC.MODE_PREPEND="prepend";
SC.RenderContext=SC.Builder.create({SELF_CLOSING:SC.CoreSet.create().addEach("area base basefront br hr input img link meta".w()),init:function(a,b){if(a===undefined)a="div";if(b){this.prevObject=b;this.strings=b.strings;this.offset=b.length+b.offset}if(!this.strings)this.strings=[];this.needsContent=YES;if(SC.typeOf(a)===SC.T_STRING){this._tagName=a.toLowerCase();this._needsTag=YES;for(a=this;a;){a.length++;a=a.prevObject}this.strings.push(null);this._selfClosing=this.SELF_CLOSING.contains(this._tagName)}else{this._elem=
a;this._needsTag=NO;this.length=0;this.needsContent=NO}return this},strings:null,offset:0,length:0,updateMode:SC.MODE_REPLACE,needsContent:NO,get:function(a){var b=this.strings||[];return a===undefined?b.slice(this.offset,this.length):b[a+this.offset]},push:function(a){var b=this.strings,c=arguments.length;if(!b)this.strings=b=[];c>1?b.push.apply(b,arguments):b.push(a);for(b=this;b;){b.length+=c;b=b.prevObject}this.needsContent=YES;return this},text:function(){var a=arguments.length,b=0;for(b=0;b<
a;b++)this.push(SC.RenderContext.escapeHTML(arguments[b]));return this},join:function(a){this._needsTag&&this.end();var b=this.strings;return b?b.join(a||""):""},begin:function(a){return SC.RenderContext(a,this)},element:function(){if(this._elem)return this._elem;var a;if(!SC.RenderContext.factory)SC.RenderContext.factory=document.createElement("div");SC.RenderContext.factory.innerHTML=this.join();if(SC.RenderContext.factory.innerHTML.length>0){a=SC.RenderContext.factory.firstChild.cloneNode(true);
SC.RenderContext.factory.innerHTML=""}else a=null;return a},remove:function(a){if(a){var b=this._elem;if(b&&b.removeChild)(a=document.getElementById(a))&&b.removeChild(a)}},update:function(){var a=this._elem,b=this.updateMode,c,e,g,d;if(a){if(this.length>0)if(b===SC.MODE_REPLACE)a.innerHTML=this.join();else{b=a.cloneNode(false);b.innerHTML=this.join();for(b=b.firstChild;b;){d=b.nextSibling;a.insertBefore(b,d);b=d}}if(this._attrsDidChange&&(e=this._attrs))for(c in e)if(e.hasOwnProperty(c))e[c]===null?
a.removeAttribute(c):SC.$(a).attr(c,e[c]);if(this._classNamesDidChange&&(e=this._classNames))SC.$(a).attr("class",e.join(" "));if(this._idDidChange&&(e=this._id))SC.$(a).attr("id",e);if(this._stylesDidChange&&(g=this._styles)){b=this._STYLE_PAIR_ARRAY;d=this._JOIN_ARRAY;for(c in g)if(g.hasOwnProperty(c)){e=g[c];if(e!==null){if(typeof e===SC.T_NUMBER)e=e.toString()+"px";b[0]=c.dasherize();b[1]=e;d.push(b.join(": "))}}SC.$(a).attr("style",d.join("; "));d.length=0}this._elem=null;return this.prevObject||
this}},_DEFAULT_ATTRS:{},_TAG_ARRAY:[],_JOIN_ARRAY:[],_STYLE_PAIR_ARRAY:[],end:function(){var a=this._TAG_ARRAY,b,c,e,g=this._attrs;b=this._classNames;c=this._id;var d=this._styles;a[0]="<";a[1]=this._tagName;if(g||b||d||c){if(!g)g=this._DEFAULT_ATTRS;if(c)g.id=c;if(b)g["class"]=b.join(" ");if(d){c=this._JOIN_ARRAY;b=this._STYLE_PAIR_ARRAY;for(e in d)if(d.hasOwnProperty(e)){b[0]=e.dasherize();b[1]=d[e];if(b[1]!==null){if(typeof b[1]===SC.T_NUMBER)b[1]="%@px".fmt(b[1]);c.push(b.join(": "))}}g.style=
c.join("; ");c.length=0}a.push(" ");for(e in g)if(g.hasOwnProperty(e))if(g[e]!==null){a.push(e);a.push('="');a.push(g[e]);a.push('" ')}if(g===this._DEFAULT_ATTRS){delete g.style;delete g["class"];delete g.id}}e=this.strings;g=this._selfClosing===NO?NO:this.length===1;a.push(g?" />":">");e[this.offset]=a.join("");a.length=0;if(!g){a[0]="</";a[1]=this._tagName;a[2]=">";e.push(a.join(""));for(e=this;e;){e.length++;e=e.prevObject}a.length=0}this._elem=null;return this.prevObject||this},tag:function(a,
b){return this.begin(a,b).end()},tagName:function(a){if(a===undefined){if(!this._tagName&&this._elem)this._tagName=this._elem.tagName;return this._tagName}else{this._tagName=a;this._tagNameDidChange=YES;return this}},id:function(a){if(a===undefined){if(!this._id&&this._elem)this._id=this._elem.id;return this._id}else{this._id=a;this._idDidChange=YES;return this}},classNames:function(a,b){if(a===undefined){if(!this._classNames&&this._elem)this._classNames=(SC.$(this._elem).attr("class")||"").split(" ");
if(this._cloneClassNames){this._classNames=(this._classNames||[]).slice();this._cloneClassNames=NO}if(!this._classNames)this._classNames=[];return this._classNames}else{this._classNames=a;this._cloneClassNames=b||NO;this._classNamesDidChange=YES;return this}},hasClass:function(a){return this.classNames().indexOf(a)>=0},addClass:function(a){var b=this.classNames();if(b.indexOf(a)<0){b.push(a);this._classNamesDidChange=YES}return this},removeClass:function(a){var b=this._classNames,c;if(!b&&this._elem)b=
this._classNames=(SC.$(this._elem).attr("class")||"").split(" ");if(b&&(c=b.indexOf(a))>=0){if(this._cloneClassNames){b=this._classNames=b.slice();this._cloneClassNames=NO}b[c]=null;this._classNamesDidChange=YES}return this},resetClassNames:function(){this._classNames=[];this._classNamesDidChange=YES;return this},setClass:function(a,b){var c,e,g;if(b!==undefined)return b?this.addClass(a):this.removeClass(a);else{b=this._classNames;if(!b&&this._elem)b=this._classNames=(SC.$(this._elem).attr("class")||
"").split(" ");if(!b)b=this._classNames=[];if(this._cloneClassNames){b=this._classNames=b.slice();this._cloneClassNames=NO}g=NO;for(e in a)if(a.hasOwnProperty(e)){c=b.indexOf(e);if(a[e]){if(c<0){b.push(e);g=YES}}else if(c>=0){b[c]=null;g=YES}}if(g)this._classNamesDidChange=YES}return this},_STYLE_REGEX:/\s*([^:\s]+)\s*:\s*([^;]+)\s*;?/g,styles:function(a,b){var c,e;if(a===undefined){if(!this._styles&&this._elem)if((b=SC.$(this._elem).attr("style"))&&(b=b.toString()).length>0){if(SC.browser.msie)b=
b.toLowerCase();a={};c=this._STYLE_REGEX;for(c.lastIndex=0;e=c.exec(b);)a[e[1].camelize()]=e[2];this._styles=a;this._cloneStyles=NO}else this._styles={};else if(this._styles){if(this._cloneStyles){this._styles=SC.beget(this._styles);this._cloneStyles=NO}}else this._styles={};return this._styles}else{this._styles=a;this._cloneStyles=b||NO;this._stylesDidChange=YES;return this}},addStyle:function(a,b){var c,e=NO,g=this.styles();if(typeof a===SC.T_STRING)if(b===undefined)return g[a];else{if(g[a]!==b){g[a]=
b;this._stylesDidChange=YES}}else{for(c in a)if(a.hasOwnProperty(c)){b=a[c];if(g[c]!==b){g[c]=b;e=YES}}if(e)this._stylesDidChange=YES}return this},removeStyle:function(a){if(!this._styles&&!this._elem)return this;var b=this.styles();if(b[a]){b[a]=null;this._stylesDidChange=YES}},attr:function(a,b){var c,e=this._attrs,g=NO;if(!e)this._attrs=e={};if(typeof a===SC.T_STRING)if(b===undefined)return e[a];else{if(e[a]!==b){e[a]=b;this._attrsDidChange=YES}}else{for(c in a)if(a.hasOwnProperty(c)){b=a[c];if(e[c]!==
b){e[c]=b;g=YES}}if(g)this._attrsDidChange=YES}return this}});SC.RenderContext.fn.html=SC.RenderContext.fn.push;SC.RenderContext.fn.css=SC.RenderContext.fn.addStyle;if(!SC.browser.isSafari||parseInt(SC.browser.version,10)<526)SC.RenderContext._safari3=YES;
SC.RenderContext.escapeHTML=function(a){var b,c;if(SC.none(a))return a;b=this.escapeHTMLElement;if(!b)b=this.escapeHTMLElement=document.createElement("div");c=this.escapeTextNode;if(!c){c=this.escapeTextNode=document.createTextNode("");b.appendChild(c)}c.data=a;a=b.innerHTML;if(SC.RenderContext._safari3)a=a.replace(/>/g,"&gt;");return a};
SC.Response=SC.Object.extend({isError:NO,errorValue:function(){return this}.property().cacheable(),errorObject:null,request:null,originalRequest:function(){for(var a=this.get("request");a.get("source");)a=a.get("source");return a}.property("request").cacheable(),type:function(){return this.getPath("request.type")}.property("request").cacheable(),address:function(){return this.getPath("request.address")}.property("request").cacheable(),isJSON:function(){return this.getPath("request.isJSON")||NO}.property("request").cacheable(),
isXML:function(){return this.getPath("request.isXML")||NO}.property("request").cacheable(),listeners:function(){return this.getPath("request.listeners")}.property("request").cacheable(),status:-100,headers:null,encodedBody:null,body:function(){var a=this.get("encodedBody");if(a&&this.get("isJSON"))try{a=SC.json.decode(a)}catch(b){return SC.Error.create({message:b.name+": "+b.message,label:"Response",errorValue:this})}return a}.property("encodedBody").cacheable(),response:function(){return this.get("body")}.property("body").cacheable(),
isCancelled:NO,fire:function(){var a=this.get("request"),b=a?a.get("source"):null;b&&b.willSend&&b.willSend(a,this);a.freeze();this.get("isCancelled")||this.invokeTransport();!this.get("isCancelled")&&b&&b.didSend&&b.didSend(a,this)},invokeTransport:function(){this.receive(function(){this.set("status",200)},this)},receive:function(a,b){var c=this.get("request"),e=c?c.get("source"):null;e&&e.willReceive&&e.willReceive(c,this);a.call(b,!this.get("isCancelled"));!this.get("isCancelled")&&e&&e.didReceive&&
e.didReceive(c,this);this.get("isCancelled")||this.notify();SC.Request.manager.transportDidClose(this);return this},cancel:function(){if(!this.get("isCancelled")){this.set("isCancelled",YES);this.cancelTransport();SC.Request.manager.transportDidClose(this)}},cancelTransport:function(){},_notifyListener:function(a,b){var c=a[b];if(!c)return NO;a=(c.params||[]).copy();a.unshift(this);b=c.target;c=c.action;if(SC.typeOf(c)===SC.T_STRING)c=b[c];return c.apply(b,a)},notify:function(){var a=this.get("listeners"),
b=this.get("status"),c=Math.floor(b/100)*100,e=NO;if(!a)return this;SC.RunLoop.begin();(e=this._notifyListener(a,b))||(e=this._notifyListener(a,c));e||this._notifyListener(a,0);SC.RunLoop.end();return this},toString:function(){return"%@<%@ %@, status=%@".fmt(arguments.callee.base.apply(this,arguments),this.get("type"),this.get("address"),this.get("status"))}});
SC.XHRResponse=SC.Response.extend({headers:function(){var a=this.get("rawRequest");a=a?a.getAllResponseHeaders():null;var b={};if(!a)return b;a.split("\n").forEach(function(c){var e=c.indexOf(":"),g;if(e>=0){g=c.slice(0,e);c=c.slice(e+1).trim();b[g]=c}},this);return b}.property("status").cacheable(),header:function(a){var b=this.get("rawRequest");return b?b.getResponseHeader(a):null},encodedBody:function(){var a=this.get("rawRequest");return a?this.get("isXML")?a.responseXML:a.responseText:null}.property("status").cacheable(),
cancelTransport:function(){var a=this.get("rawRequest");a&&a.abort();this.set("rawRequest",null)},invokeTransport:function(){function a(){for(var f=0;f<arguments.length;f++)try{return arguments[f]()}catch(h){}return NO}var b,c,e,g;b=a(function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")});this.set("rawRequest",b);if(g=!!this.getPath("request.isAsynchronous"))if(SC.browser.msie){c=this;e=function(){if(!c)return null;
var f=c.finishRequest();if(f)c=null;return f};b.onreadystatechange=e}else SC.Event.add(b,"readystatechange",this,this.finishRequest,b);b.open(this.get("type"),this.get("address"),g);e=this.getPath("request.headers");for(var d in e)b.setRequestHeader(d,e[d]);b.send(this.getPath("request.encodedBody"));g||this.finishRequest();return b},finishRequest:function(){var a=this.get("rawRequest"),b,c,e;if(a.readyState===4){this.receive(function(g){if(g){c=-1;try{c=a.status||0}catch(d){}if(c<200||c>=300){e=
a.statusText;b=SC.$error(e||"HTTP Request failed","Request",c);b.set("errorValue",this);this.set("isError",YES);this.set("errorObject",b)}this.set("status",c)}},this);a.onreadystatechange=function(){};return YES}return NO}});sc_require("system/response");
SC.Request=SC.Object.extend(SC.Copyable,SC.Freezable,{isAsynchronous:YES,isJSON:NO,isXML:NO,headers:function(){var a=this._headers;if(!a)a=this._headers={};return a}.property().cacheable(),responseClass:SC.XHRResponse,source:null,address:null,type:"GET",body:null,encodedBody:function(){var a=this.get("body");if(a&&this.get("isJSON"))a=SC.json.encode(a);return a}.property("isJSON","isXML","body").cacheable(),willSend:function(){},didSend:function(){},willReceive:function(){},didReceive:function(){},
COPY_KEYS:"isAsynchronous isJSON isXML address type body responseClass willSend didSend willReceive didReceive".w(),copy:function(){for(var a={},b=this.COPY_KEYS,c=b.length,e;--c>=0;){e=b[c];if(this.hasOwnProperty(e))a[e]=this.get(e)}if(this.hasOwnProperty("listeners"))a.listeners=SC.copy(this.get("listeners"));if(this.hasOwnProperty("_headers"))a._headers=SC.copy(this._headers);a.source=this.get("source")||this;return this.constructor.create(a)},header:function(a,b){var c;if(SC.typeOf(a)===SC.T_STRING){c=
this._headers;if(arguments.length===1)return c?c[a]:null;else{this.propertyWillChange("headers");if(!c)c=this._headers={};c[a]=b;this.propertyDidChange("headers");return this}}else if(b===undefined){c=a;this.beginPropertyChanges();for(a in c)c.hasOwnProperty(a)&&this.header(a,c[a]);this.endPropertyChanges();return this}return this},json:function(a){if(a===undefined)a=YES;a&&this.set("isXML",NO);return this.set("isJSON",a)},xml:function(a){if(a===undefined)a=YES;a&&this.set("isJSON",NO);return this.set("isXML",
a)},_prep:function(){var a=!!this.header("Content-Type");if(this.get("isJSON")&&!a)this.header("Content-Type","application/json");else this.get("isXML")&&!a&&this.header("Content-Type","text/xml");return this},send:function(a){a&&this.set("body",a);return SC.Request.manager.sendRequest(this.copy()._prep())},resend:function(){var a=this.get("source")?this:this.copy()._prep();return SC.Request.manager.sendRequest(a)},notify:function(a,b,c,e){if(SC.typeOf(a)!==SC.T_NUMBER){e=SC.A(arguments).slice(2);
c=b;b=a;a=0}else e=SC.A(arguments).slice(3);var g=this.get("listeners");g||this.set("listeners",g={});g[a]={target:b,action:c,params:e};return this}});
SC.Request.mixin({getUrl:function(a){return this.create().set("address",a).set("type","GET")},postUrl:function(a,b){a=this.create().set("address",a).set("type","POST");b&&a.set("body",b);return a},deleteUrl:function(a){return this.create().set("address",a).set("type","DELETE")},putUrl:function(a,b){a=this.create().set("address",a).set("type","PUT");b&&a.set("body",b);return a}});
SC.Request.manager=SC.Object.create(SC.DelegateSupport,{maxRequests:6,inflight:[],pending:[],sendRequest:function(a){if(!a)return null;a=a.get("responseClass").create({request:a});this.get("pending").pushObject(a);this.fireRequestIfNeeded();return a},cancel:function(a){var b=this.get("pending"),c=this.get("inflight");if(b.indexOf(a)>=0){this.propertyWillChange("pending");b.removeObject(a);this.propertyDidChange("pending");return YES}else if(c.indexOf(a)>=0){a.cancel();c.removeObject(a);this.fireRequestIfNeeded();
return YES}else return NO},cancelAll:function(){if(this.get("pending").length||this.get("inflight").length){this.set("pending",[]);this.get("inflight").forEach(function(a){a.cancel()});this.set("inflight",[]);return YES}else return NO},fireRequestIfNeeded:function(){var a=this.get("pending"),b=this.get("inflight"),c=this.get("maxRequests");if(a.length>0&&b.length<c){a=a.shiftObject();b.pushObject(a);a.fire()}},transportDidClose:function(a){this.get("inflight").removeObject(a);this.fireRequestIfNeeded()}});
sc_require("system/ready");
SC.RootResponder=SC.Object.extend({panes:null,init:function(){arguments.callee.base.apply(this,arguments);this.panes=SC.Set.create()},mainPane:null,makeMainPane:function(a){var b=this.get("mainPane");if(b===a)return this;this.beginPropertyChanges();this.get("keyPane")===b&&this.makeKeyPane(a);this.set("mainPane",a);b&&b.blurMainTo(a);a&&a.focusMainFrom(b);this.endPropertyChanges();return this},keyPane:null,previousKeyPanes:[],makeKeyPane:function(a){var b,c;if(a)if(a.get("acceptsKeyPane")){b=this.get("keyPane");
if(b===a)return this;else{if(b){c=this.get("previousKeyPanes");c.push(b)}a=a}}else return this;else{b=this.get("keyPane");c=this.get("previousKeyPanes");for(a=null;c.length>0;){var e=c.pop();if(e.get("isPaneAttached")&&e.get("acceptsKeyPane")){a=e;break}}}if(!a)if((c=this.get("mainPane"))&&c.get("acceptsKeyPane"))a=c;b&&b.willLoseKeyPaneTo(a);a&&a.willBecomeKeyPaneFrom(b);this.set("keyPane",a);a&&a.didBecomeKeyPaneFrom(b);b&&b.didLoseKeyPaneTo(a);return this},computeWindowSize:function(){return{width:640,
height:480}},defaultResponder:null,sendAction:function(a,b,c,e,g){return(b=this.targetForAction(a,b,c,e))&&b.isResponderContext?!!b.sendAction(a,c,g):b&&b.tryToPerform(a,c)},_responderFor:function(a,b){var c=a?a.get("defaultResponder"):null;if(a){a=a.get("firstResponder")||a;do if(a.respondsTo(b))return a;while(a=a.get("nextResponder"))}if(typeof c===SC.T_STRING)c=SC.objectForPropertyPath(c);return c?c.isResponderContext?c:c.respondsTo(b)?c:null:null},targetForAction:function(a,b,c,e){if(!a||SC.typeOf(a)!==
SC.T_STRING)return null;if(b){if(SC.typeOf(b)===SC.T_STRING)b=SC.objectForPropertyPath(b);if(b)if(b.respondsTo&&!b.respondsTo(a))b=null;else if(SC.typeOf(b[a])!==SC.T_FUNCTION)b=null;return b}if(e)return this._responderFor(e,a);c=this.get("keyPane");var g=this.get("mainPane");if(c&&c!==e)b=this._responderFor(c,a);if(!b&&g&&g!==c)b=this._responderFor(g,a);if(!b&&(b=this.get("defaultResponder"))){if(SC.typeOf(b)===SC.T_STRING)(b=SC.objectForPropertyPath(b))&&this.set("defaultResponder",b);if(b)if(b.respondsTo&&
!b.respondsTo(a))b=null;else if(SC.typeOf(b[a])!==SC.T_FUNCTION)b=null}return b},targetViewForEvent:function(a){return a.target?SC.$(a.target).view()[0]:null},sendEvent:function(a,b,c){var e;SC.RunLoop.begin();a=(e=c?c.get("pane"):this.get("keyPane")||this.get("mainPane"))?e.sendEvent(a,b,c):null;SC.RunLoop.end();return a},listenFor:function(a,b){a.forEach(function(c){var e=this[c];e&&SC.Event.add(b,c,this,e)},this);b=null;return this},setup:function(){}});
SC.ready(SC.RootResponder,SC.RootResponder.ready=function(){(SC.RootResponder.responder=SC.RootResponder.create()).setup()});
SC.routes=SC.Object.create({location:function(a,b){if(b!==undefined){if(b===null)b="";if(typeof b=="object"){var c=b.route?b.route.split("&"):[""],e=c.shift(),g={};c.forEach(function(d){d=d.split("=");g[d[0]]=d[1]});for(a in b)if(b.hasOwnProperty(a))if(a!="route")g[a]=encodeURIComponent(""+b[a]);c=[e];for(a in g)g.hasOwnProperty(a)&&c.push([a,g[a]].join("="));b=c.join("&")}if(this._location!=b){this._location=b;this._setWindowLocation(b)}}return this._location}.property(),ping:function(){if(!this._didSetupHistory){this._didSetupHistory=
true;this._setupHistory()}this._checkWindowLocation()},add:function(a,b,c){if(c===undefined&&SC.typeOf(b)===SC.T_FUNCTION){c=b;b=null}else if(SC.typeOf(c)===SC.T_STRING)c=b[c];a=a.split("/");if(!this._routes)this._routes=SC.routes._Route.create();this._routes.addRoute(a,b,c);return this},gotoRoute:function(a){var b={},c;this._lastRoute=a;if((c=a.split("&"))&&c.length>0){a=c.shift();c.forEach(function(e){if((e=e.split("="))&&e.length>1)b[e[0]]=decodeURIComponent(e[1])})}else a="";c=a.split("/");if(!this._routes)this._routes=
SC.routes._Route.create();if(c=this._routes.functionForRoute(c,b)){a=c._target;(c=c._method)&&c.call(a,b)}},init:function(){arguments.callee.base.call(this);if(SC.browser.isSafari&&parseInt(SC.browser.version,0)<417)SC.mixin(this,this.browserFuncs.safari);else if(SC.browser.isIE)SC.mixin(this,this.browserFuncs.ie);else SC.browser.isMozilla&&SC.mixin(this,this.browserFuncs.firefox);this._didSetupHistory=false},invokeCheckWindowLocation:function(a){var b=this.__checkWindowLocation,c=this;if(!b)b=this.__checkWindowLocation=
function(){c._checkWindowLocation()};setTimeout(b,a)},browserFuncs:{safari:{_setupHistory:function(){var a=location.hash;this._cloc=a=a&&a.length>0?a.slice(1,a.length):"";this._backStack=[];this._backStack.length=history.length;this._backStack.push(a);this._forwardStack=[];this.invokeCheckWindowLocation(1E3)},_checkWindowLocation:function(){var a=history.length-this._lastLength!==0,b=a?history.length-this._backStack.length:0;this._lastLength=history.length;a&&console.log("historyDidChange");if(b)if(b<
0){this._forwardStack.push(this._cloc);for(a=0;a<Math.abs(b+1);a++)this._forwardStack.push(this._backStack.pop());this._cloc=this._backStack.pop()}else{this._backStack.push(this._cloc);for(a=0;a<b-1;a++)this._backStack.push(this._forwardStack.pop());this._cloc=this._forwardStack.pop()}else if(a&&this._locationDidChange){this.gotoRoute(this._cloc);this._locationDidChange=false}b=this._cloc;a=this.get("location");if(b!=a){this.set("location",b?b:"");this.gotoRoute(b)}this.invokeCheckWindowLocation(50)},
_setWindowLocation:function(a){if(this._cloc!=a){this._backStack.push(this._cloc);this._forwardStack.length=0;this._cloc=a;location.hash=a&&a.length>0?a:"";this._locationDidChange=true}}},ie:{_setupHistory:function(){this.invokeCheckWindowLocation(1E3)},_checkWindowLocation:function(){var a=this.get("location"),b=location.hash;b=b&&b.length>0?b.slice(1,b.length):"";if(b!=a)this.set("location",b?b:"");this.invokeCheckWindowLocation(100)},_setWindowLocation:function(a){var b=location.hash;b=b&&b.length>
0?b.slice(1,b.length):"";if(b!=a)location.hash=a&&a.length>0?a:"#";this.gotoRoute(a)}},firefox:{_checkWindowLocation:function(){var a=this.get("location"),b=location.hash;b=b&&b.length>0?b.slice(1,b.length):"";if(b!=a){SC.RunLoop.begin();this.set("location",b?b:"");SC.RunLoop.end()}this.invokeCheckWindowLocation(150)},_setWindowLocation:function(a){var b=location.hash;b=b&&b.length>0?b.slice(1,b.length):"";if(b!=a)location.hash=a&&a.length>0?a:"#";this.gotoRoute(a)}}},_setupHistory:function(){this.invokeCheckWindowLocation(1E3)},
_checkWindowLocation:function(){var a=this.get("location"),b=decodeURI(location.hash);b=b&&b.length>0?b.slice(1,b.length):"";if(b!==a){SC.RunLoop.begin();this.set("location",b?b:"");SC.RunLoop.end()}this.invokeCheckWindowLocation(150)},_setWindowLocation:function(a){var b=location.hash;b=b&&b.length>0?b.slice(1,b.length):"";if(b!=a)location.hash=a&&a.length>0?encodeURI(a):"#";this.gotoRoute(a)},_routes:null,_Route:SC.Object.extend({_target:null,_method:null,_static:null,_dynamic:null,_wildcard:null,
addRoute:function(a,b,c){if(!a||a.length===0){this._target=b;this._method=c}else{var e=a.shift(),g=null;switch(e.slice(0,1)){case ":":e=e.slice(1,e.length);var d=this._dynamic[e]||[];g=SC.routes._Route.create();d.push(g);this._dynamic[e]=d;break;case "*":this._wildcard=e=e.slice(1,e.length);this._target=b;this._method=c;break;default:d=this._static[e]||[];g=SC.routes._Route.create();d.push(g);this._static[e]=d}g&&g.addRoute(a,b,c)}},functionForRoute:function(a,b){if(!a||a.length===0)return this;else{var c=
a.shift(),e=null,g,d,f;if(g=this._static[c]){d=0;for(f=g.length;d<f&&e===null;d++){e=a.slice();e=g[d].functionForRoute(e,b)}}if(e===null)for(var h in this._dynamic){if(g=this._dynamic[h]){d=0;for(f=g.length;d<f&&e===null;d++){e=a.slice();if((e=g[d].functionForRoute(e,b))&&b)b[h]=c}}if(e)break}if(e===null&&this._wildcard){a.unshift(c);if(b)b[this._wildcard]=a.join("/");e=this}return e}},init:function(){arguments.callee.base.call(this);this._static={};this._dynamic={}}})});
SC.time=function(){var a=SC.beget(fn);a.value=timeOffset;return a};(function(){var a=new Date;SC.mixin(SC.time,{month:function(b,c){a.setTime(b);if(c===undefined)return a.getMonth();a.setMonth(c);return a.getTime()},utc:function(b){a.setTime(b);return b+a.getTimezoneOffset()*60*1E3},local:function(b){a.setTime(b);return b-a.getTimezoneOffset()*60*1E3},parse:function(){},format:function(){}})})();SC.time.fmt=SC.time.format;SC.time.fn={done:function(){return this.value}};
"month day year".split(" ").forEach(function(a){SC.time.fn[a]=function(b){if(b===undefined)return SC.time[a](this.value);else{this.value=SC.time[a](this.value,b);return this}}});
var MONTH_NAMES=new Array("January","February","March","April","May","June","July","August","September","October","November","December","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),DAY_NAMES=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sun","Mon","Tue","Wed","Thu","Fri","Sat");function LZ(a){return(a<0||a>9?"":"0")+a}
SC.Locale.define("en",{longMonthNames:"January February March April May".split(" "),shortMonthNames:[],shortDateFormat:"dd/mm/yy",longDateFormat:""});
SC.mixin(Date,{now:function(){return(new Date).getTime()},isDate:function(a,b){if(Date.getDateFromFormat(a,b)==0)return false;return true},compareDates:function(a,b,c,e){a=Date.getDateFromFormat(a,b);c=Date.getDateFromFormat(c,e);if(a==0||c==0)return-1;else if(a>c)return 1;return 0},getDateFromFormat:function(a,b){a+="";b+="";var c=0,e=0,g="",d="",f,h,i=new Date,j=i.getFullYear(),k=i.getMonth()+1,l=1,o=i.getHours(),n=i.getMinutes();i=i.getSeconds();for(var r="";e<b.length;){g=b.charAt(e);for(d="";b.charAt(e)==
g&&e<b.length;)d+=b.charAt(e++);if(d=="yyyy"||d=="yy"||d=="y"){if(d=="yyyy")h=f=4;if(d=="yy")h=f=2;if(d=="y"){f=2;h=4}j=Date._getInt(a,c,f,h);if(j==null)return 0;c+=j.length;if(j.length==2)j=j>70?1900+(j-0):2E3+(j-0)}else if(d=="MMM"||d=="NNN"){for(g=k=0;g<MONTH_NAMES.length;g++){var p=MONTH_NAMES[g];if(a.substring(c,c+p.length).toLowerCase()==p.toLowerCase())if(d=="MMM"||d=="NNN"&&g>11){k=g+1;if(k>12)k-=12;c+=p.length;break}}if(k<1||k>12)return 0}else if(d=="EE"||d=="E")for(g=0;g<DAY_NAMES.length;g++){d=
DAY_NAMES[g];if(a.substring(c,c+d.length).toLowerCase()==d.toLowerCase()){c+=d.length;break}}else if(d=="MM"||d=="M"){k=Date._getInt(a,c,d.length,2);if(k==null||k<1||k>12)return 0;c+=k.length}else if(d=="dd"||d=="d"){l=Date._getInt(a,c,d.length,2);if(l==null||l<1||l>31)return 0;c+=l.length}else if(d=="hh"||d=="h"){o=Date._getInt(a,c,d.length,2);if(o==null||o<1||o>12)return 0;c+=o.length}else if(d=="HH"||d=="H"){o=Date._getInt(a,c,d.length,2);if(o==null||o<0||o>23)return 0;c+=o.length}else if(d=="KK"||
d=="K"){o=Date._getInt(a,c,d.length,2);if(o==null||o<0||o>11)return 0;c+=o.length}else if(d=="kk"||d=="k"){o=Date._getInt(a,c,d.length,2);if(o==null||o<1||o>24)return 0;c+=o.length;o--}else if(d=="mm"||d=="m"){n=Date._getInt(a,c,d.length,2);if(n==null||n<0||n>59)return 0;c+=n.length}else if(d=="ss"||d=="s"){i=Date._getInt(a,c,d.length,2);if(i==null||i<0||i>59)return 0;c+=i.length}else if(d=="a"){if(a.substring(c,c+2).toLowerCase()=="am")r="AM";else if(a.substring(c,c+2).toLowerCase()=="pm")r="PM";
else return 0;c+=2}else if(a.substring(c,c+d.length)!=d)return 0;else c+=d.length}if(c!=a.length)return 0;if(k==2)if(j%4==0&&j%100!=0||j%400==0){if(l>29)return 0}else if(l>28)return 0;if(k==4||k==6||k==9||k==11)if(l>30)return 0;if(o<12&&r=="PM")o=o-0+12;else if(o>11&&r=="AM")o-=12;return(new Date(j,k-1,l,o,n,i)).getTime()},parseDate:function(a){var b=arguments.length==2?arguments[1]:false;generalFormats=new Array("E NNN dd HH:mm:ss UTC yyyy","y-M-d","y-M-d","MMM d, y","MMM d,y","y-MMM-d","d-MMM-y",
"MMM d","d MMM y","d.MMM.y","y MMM d","y.MMM.d");monthFirst=new Array("M/d/y","M-d-y","M.d.y","MMM-d","M/d","M-d");dateFirst=new Array("d/M/y","d-M-y","d.M.y","d-MMM","d/M","d-M");b=new Array("generalFormats",b?"dateFirst":"monthFirst",b?"monthFirst":"dateFirst");var c=null;c=0;var e=(new Date).getTime();switch(a.toLowerCase()){case "yesterday".loc():c=e-864E5;break;case "today".loc():case "now".loc():c=e;break;case "tomorrow".loc():c=e+864E5;break}if(c>0)return new Date(c);for(e=0;e<b.length;e++)for(var g=
window[b[e]],d=0;d<g.length;d++){c=Date.getDateFromFormat(a,g[d]);if(c==0)c=Date.getDateFromFormat(a,g[d]+" H:m:s");if(c==0)c=Date.getDateFromFormat(a,g[d]+" h:m:s a");if(c!=0)return new Date(c)}return null},_isInteger:function(a){for(var b=0;b<a.length;b++)if("1234567890".indexOf(a.charAt(b))==-1)return false;return true},_getInt:function(a,b,c,e){for(e=e;e>=c;e--){var g=a.substring(b,b+e);if(g.length<c)return null;if(Date._isInteger(g))return g}return null}});
SC.mixin(Date.prototype,{format:function(a){a+="";var b=this,c="",e=0,g="",d="";g=b.getFullYear()+"";d=b.getMonth()+1;var f=b.getDate(),h=b.getDay(),i=b.getHours(),j=b.getMinutes(),k=b.getSeconds();b={};if(g.length<4)g=""+(g-0+1900);b.y=""+g;b.yyyy=g;b.yy=g.substring(2,4);b.M=d;b.MM=LZ(d);b.MMM=MONTH_NAMES[d-1];b.NNN=MONTH_NAMES[d+11];b.d=f;b.dd=LZ(f);b.E=DAY_NAMES[h+7];b.EE=DAY_NAMES[h];b.H=i;b.HH=LZ(i);b.h=i==0?12:i>12?i-12:i;b.hh=LZ(b.h);b.K=i>11?i-12:i;b.k=i+1;b.KK=LZ(b.K);b.kk=LZ(b.k);b.a=i>
11?"PM":"AM";b.m=j;b.mm=LZ(j);b.s=k;for(b.ss=LZ(k);e<a.length;){g=a.charAt(e);for(d="";a.charAt(e)==g&&e<a.length;)d+=a.charAt(e++);c+=b[d]!=null?b[d]:d}return c},utcFormat:function(){return(new Date(this.getTime()+this.getTimezoneOffset()*60*1E3)).format("E NNN dd HH:mm:ss UTC yyyy")}});
SC.Timer=SC.Object.extend({target:null,action:null,isPooled:NO,interval:0,startTime:null,repeats:NO,until:null,isPaused:NO,isScheduled:NO,isValid:YES,lastFireTime:0,fireTime:function(){if(!this.get("isValid"))return-1;var a=this.get("startTime");if(!a||a===0)return-1;var b=this.get("interval"),c=this.get("lastFireTime");if(c<a)c=a;a=this.get("repeats")?b===0?c:a+(Math.floor((c-a)/b)+1)*b:a+b;if((b=this.get("until"))&&b>0&&a>b)a=b;return a}.property("interval","startTime","repeats","until","isValid",
"lastFireTime").cacheable(),schedule:function(){if(!this.get("isValid"))return this;this.beginPropertyChanges();this.startTime||this.set("startTime",SC.RunLoop.currentRunLoop.get("startTime"));var a=this.get("fireTime"),b=this.get("lastFireTime");if(a>=b){this.set("isScheduled",YES);SC.RunLoop.currentRunLoop.scheduleTimer(this,a)}this.endPropertyChanges();return this},invalidate:function(){this.beginPropertyChanges();this.set("isValid",NO);SC.RunLoop.currentRunLoop.cancelTimer(this);this.action=this.target=
null;this.endPropertyChanges();this.get("isPooled")&&SC.Timer.returnTimerToPool(this);return this},fire:function(){var a=Date.now();this.set("lastFireTime",a);var b=this.get("fireTime");this.get("isPaused")||this.performAction();b>a?this.schedule():this.invalidate()},performAction:function(){var a=SC.typeOf(this.action);if(a==SC.T_FUNCTION)this.action.call(this.target||this,this);else if(a===SC.T_STRING)if(this.action.indexOf(".")>=0){var b=this.action.split(".");a=b.pop();b=SC.objectForPropertyPath(b,
window);if((a=b.get?b.get(a):b[a])&&SC.typeOf(a)==SC.T_FUNCTION)a.call(b,this);else throw"%@: Timer could not find a function at %@".fmt(this,this.action);}else SC.RootResponder.responder.sendAction(this.action,this.target,this)},init:function(){arguments.callee.base.apply(this,arguments);if(this.startTime instanceof Date)this.startTime=this.startTime.getTime();if(this.until instanceof Date)this.until=this.until.getTime()},RESET_DEFAULTS:{target:null,action:null,isPooled:NO,isPaused:NO,isScheduled:NO,
isValid:YES,interval:0,repeats:NO,until:null,startTime:null,lastFireTime:0},reset:function(a){if(!a)a=SC.EMPTY_HASH;this.propertyWillChange("fireTime");var b=this.RESET_DEFAULTS;for(var c in b)if(b.hasOwnProperty(c))this[c]=SC.none(a[c])?b[c]:a[c];this.propertyDidChange("fireTime");return this},removeFromTimerQueue:function(a){var b=this._timerQueuePrevious,c=this._timerQueueNext;if(!b&&!c&&a!==this)return a;if(b)b._timerQueueNext=c;if(c)c._timerQueuePrevious=b;this._timerQueuePrevious=this._timerQueueNext=
null;return a===this?c:a},scheduleInTimerQueue:function(a,b){this._timerQueueRunTime=b;for(var c=a,e=null;c&&c._timerQueueRunTime<b;){e=c;c=c._timerQueueNext}if(e){e._timerQueueNext=this;this._timerQueuePrevious=e}if(c){c._timerQueuePrevious=this;this._timerQueueNext=c}return c===a?this:a},collectExpiredTimers:function(a,b){if(this._timerQueueRunTime>b)return this;a.push(this);var c=this._timerQueueNext;this._timerQueueNext=null;if(c)c._timerQueuePrevious=null;return c?c.collectExpiredTimers(a,b):
null}});SC.Timer.schedule=function(a){return(!a||SC.none(a.isPooled)||a.isPooled?this.timerFromPool(a):this.create(a)).schedule()};SC.Timer.timerFromPool=function(a){var b=this._timerPool;if(!b)b=this._timerPool=[];(b=b.pop())||(b=this.create());return b.reset(a)};SC.Timer.returnTimerToPool=function(a){if(!this._timerPool)this._timerPool=[];this._timerPool.push(a);return this};
SC.UserDefaults=SC.Object.extend({userDomain:null,appDomain:null,_defaults:null,defaults:function(a){this._defaults=a;this.allPropertiesDidChange()},readDefault:function(a){var b=undefined;a=this._normalizeKeyName(a);var c=this._userKeyName(a);if(this._written)b=this._written[c];var e=window.localStorage;if(!e&&window.globalStorage)e=window.globalStorage[window.location.hostname];if(e){b=e[["SC.UserDefaults",c].join("@")];if(SC.none(b))b=undefined;else try{b=SC.json.decode(b)}catch(g){b=undefined}}if((e=
this.delegate)&&e.userDefaultsNeedsDefault)b=e.userDefaultsNeedsDefault(this,a,c);if(b===undefined&&this._defaults)b=this._defaults[c]||this._defaults[a];return b},writeDefault:function(a,b){a=this._normalizeKeyName(a);var c=this._userKeyName(a),e=this._written;if(!e)e=this._written={};e[c]=b;e=window.localStorage;if(!e&&window.globalStorage)e=window.globalStorage[window.location.hostname];if(e)e[["SC.UserDefaults",c].join("@")]=SC.json.encode(b);(e=this.delegate)&&e.userDefaultsDidChange&&e.userDefaultsDidChange(this,
a,b,c);return this},resetDefault:function(a){var b=this._normalizeKeyName(a),c=this._userKeyName(b);this.propertyWillChange(a);this.propertyWillChange(b);var e=this._written;e&&delete e[c];e=window.localStorage;if(!e&&window.globalStorage)e=window.globalStorage[window.location.hostname];e&&delete e[["SC.UserDefaults",c].join("@")];this.propertyDidChange(a);this.propertyDidChange(b);return this},unknownProperty:function(a,b){if(b===undefined)return this.readDefault(a);else{this.writeDefault(a,b);return b}},
_normalizeKeyName:function(a){if(a.indexOf(":")<0)a=[this.get("appDomain")||"app",a].join(":");return a},_userKeyName:function(a){return[this.get("userDomain")||"(anonymous)",a].join("@")},_domainDidChange:function(){var a=NO;if(this.get("userDomain")!==this._scud_userDomain){this._scud_userDomain=this.get("userDomain");a=YES}if(this.get("appDomain")!==this._scud_appDomain){this._scud_appDomain=this.get("appDomain");a=YES}a&&this.allPropertiesDidChange()}.observes("userDomain","appDomain"),init:function(){arguments.callee.base.apply(this,
arguments);this._scud_userDomain=this.get("userDomain");this._scud_appDomain=this.get("appDomain")}});SC.userDefaults=SC.UserDefaults.create();sc_require("system/browser");
SC.mixin({_downloadFrames:0,_copy_computed_props:["maxWidth","maxHeight","paddingLeft","paddingRight","paddingTop","paddingBottom","fontFamily","fontSize","fontStyle","fontWeight","fontVariant","lineHeight","whiteSpace"],download:function(a){var b=document.createElement("iframe"),c="DownloadFrame_"+this._downloadFrames;SC.$(b).attr("id",c);b.style.border="10px";b.style.width="0px";b.style.height="0px";b.style.position="absolute";b.style.top="-10000px";b.style.left="-10000px";SC.browser.isSafari||
SC.$(b).attr("src",a);document.getElementsByTagName("body")[0].appendChild(b);SC.browser.isSafari&&SC.$(b).attr("src",a);this._downloadFrames+=1;SC.browser.isSafari||function(){document.body.removeChild(document.getElementById(c));c=null}.invokeLater(null,2E3);b=null},normalizeURL:function(a){if(a.slice(0,1)=="/")a=window.location.protocol+"//"+window.location.host+a;else a.slice(0,5)=="http:"||a.slice(0,6)=="https:"||(a=window.location.href+"/"+a);return a},minX:function(a){return a.x||0},maxX:function(a){return(a.x||
0)+(a.width||0)},midX:function(a){return(a.x||0)+(a.width||0)/2},minY:function(a){return a.y||0},maxY:function(a){return(a.y||0)+(a.height||0)},midY:function(a){return(a.y||0)+(a.height||0)/2},centerX:function(a,b){return(b.width-a.width)/2},centerY:function(a,b){return(b.height-a.height)/2},pointInRect:function(a,b){return a.x>=SC.minX(b)&&a.y>=SC.minY(b)&&a.x<=SC.maxX(b)&&a.y<=SC.maxY(b)},rectsEqual:function(a,b,c){if(!a||!b)return a==b;if(!c&&c!==0)c=0.1;if(a.y!=b.y&&Math.abs(a.y-b.y)>c)return NO;
if(a.x!=b.x&&Math.abs(a.x-b.x)>c)return NO;if(a.width!=b.width&&Math.abs(a.width-b.width)>c)return NO;if(a.height!=b.height&&Math.abs(a.height-b.height)>c)return NO;return YES},intersectRects:function(a,b){a={x:Math.max(SC.minX(a),SC.minX(b)),y:Math.max(SC.minY(a),SC.minY(b)),width:Math.min(SC.maxX(a),SC.maxX(b)),height:Math.min(SC.maxY(a),SC.maxY(b))};a.width=Math.max(0,a.width-a.x);a.height=Math.max(0,a.height-a.y);return a},unionRects:function(a,b){a={x:Math.min(SC.minX(a),SC.minX(b)),y:Math.min(SC.minY(a),
SC.minY(b)),width:Math.max(SC.maxX(a),SC.maxX(b)),height:Math.max(SC.maxY(a),SC.maxX(b))};a.width=Math.max(0,a.width-a.x);a.height=Math.max(0,a.height-a.y);return a},cloneRect:function(a){return{x:a.x,y:a.y,width:a.width,height:a.height}},stringFromRect:function(a){return"{%@, %@, %@, %@}".fmt(a.x,a.y,a.width,a.height)},stringFromLayout:function(a){for(var b=["maxHeight","maxWidth","minHeight","minWidth","centerY","centerX","width","height","bottom","right","top","left"],c=[],e=b.length;--e>=0;){var g=
b[e];a.hasOwnProperty(g)&&c.push(g+":"+a[g])}return"{"+c.join(", ")+"}"},heightForString:function(a,b,c,e){var g=this._heightCalcElement;e=e&&SC.typeOf(e)===SC.T_ARRAY?e.join(" "):"";b||(b=100);if(!g){g=this._heightCalcElement=document.createElement("div");document.body.insertBefore(g,null)}c="%@; width: %@px; left: %@px; position: absolute".fmt(c,b,-1*b);SC.$(g).attr("style",c);e!==""&&SC.$(g).attr("class",e);g.innerHTML=a;return g.clientHeight},metricsForString:function(a,b,c){var e=this._metricsCalculationElement;
c=SC.A(c).join(" ");if(!e){e=this._metricsCalculationElement=document.createElement("div");document.body.insertBefore(e,null)}if(SC.typeOf(b)!=SC.T_STRING){var g=null;g=document.defaultView&&document.defaultView.getComputedStyle?document.defaultView.getComputedStyle(b,null):b.currentStyle;b=g.cssText;if(!b||b.trim()===""){b=this._copy_computed_props;for(var d=0;d<b.length;d++){var f=b[d];e.style[f]=g[f]}g=e.style;if(g.font===""){b="";if(g.fontStyle)b+=g.fontStyle+" ";if(g.fontVariant)b+=g.fontVariant+
" ";if(g.fontWeight)b+=g.fontWeight+" ";b+=g.fontSize?g.fontSize:"10px";if(g.lineHeight)b+="/"+g.lineHeight;b+=" ";if(g.fontFamily)b+=g.fontFamily;e.style.font=b}SC.mixin(e.style,{left:"0px",top:"0px",position:"absolute",bottom:"auto",right:"auto",width:"auto",height:"auto"})}else e.setAttribute("style",b+"; position:absolute; left: 0px; top: 0px; bottom: auto; right: auto; width: auto; height: auto;")}else{b=b;e.setAttribute("style",b+"; position:absolute; left: 0px; top: 0px; bottom: auto; right: auto; width: auto; height: auto;")}if(typeof e.innerText!=
"undefined")e.innerText=a;else e.textContent=a;e.className=c;a={width:e.clientWidth,height:e.clientHeight};e.innerHTML="";e.className="";e.setAttribute("style","");return a},viewportOffset:function(a){if(a.getBoundingClientRect){a=a.getBoundingClientRect();return{x:a.left,y:a.top}}for(var b=0,c=0,e=a,g=SC.browser.mozilla>=3;e;){c+=e.offsetTop||0;if(!g||e!==a)c+=e.clientTop||0;b+=e.offsetLeft||0;if(!g||e!==a)b+=e.clientLeft||0;if(SC.browser.mozilla){if(SC.$(e).attr("overflow")!=="visible"){var d=parseInt(SC.$(e).attr("borderLeftWidth"),
0)||0,f=parseInt(SC.$(e).attr("borderTopWidth"),0)||0;if(a!==e){d*=2;f*=2}b+=d;c+=f}d=e.offsetParent;if(SC.browser.mozilla>=3&&d){c-=d.clientTop;b-=d.clientLeft}}if(e.offsetParent==document.body&&SC.$(e).attr("position")=="absolute")break;e=e.offsetParent}for(e=a;e;){if(!SC.browser.isOpera||e.tagName=="BODY"){c-=e.scrollTop||0;b-=e.scrollLeft||0}e=e.parentNode}return{x:b,y:c}},ZERO_POINT:{x:0,y:0},ZERO_RANGE:{start:0,length:0},RANGE_NOT_FOUND:{start:0,length:-1},valueInRange:function(a,b){return a>=
0&&a>=b.start&&a<b.start+b.length},minRange:function(a){return a.start},maxRange:function(a){return a.length<0?-1:a.start+a.length},unionRanges:function(a,b){if(a==null||a.length<0)return b;if(b==null||b.length<0)return a;var c=Math.min(a.start,b.start);a=Math.max(SC.maxRange(a),SC.maxRange(b));return{start:c,length:a-c}},intersectRanges:function(a,b){if(a==null||b==null)return SC.RANGE_NOT_FOUND;if(a.length<0||b.length<0)return SC.RANGE_NOT_FOUND;var c=Math.max(SC.minRange(a),SC.minRange(b));a=Math.min(SC.maxRange(a),
SC.maxRange(b));if(a<c)return SC.RANGE_NOT_FOUND;return{start:c,length:a-c}},subtractRanges:function(a,b){if(a==null||b==null)return SC.RANGE_NOT_FOUND;if(a.length<0||b.length<0)return SC.RANGE_NOT_FOUND;var c=Math.max(SC.minRange(a),SC.minRange(b));a=Math.min(SC.maxRange(a),SC.maxRange(b));if(c<a)return SC.RANGE_NOT_FOUND;return{start:a,length:c-a}},cloneRange:function(a){return{start:a.start,length:a.length}},rangesEqual:function(a,b){if(a===b)return true;if(a==null)return b.length<0;if(b==null)return a.length<
0;return a.start==b.start&&a.length==b.length},convertHsvToHex:function(a,b,c){var e=0,g=0,d=0;if(c>0){d=a==1?0:Math.floor(a*6);a=a==1?0:a*6-d;e=c*(1-b);g=c*(1-b*a);b=c*(1-b*(1-a));c=[[c,b,e],[g,c,e],[e,c,b],[e,g,c],[b,e,c],[c,e,g]];e=Math.round(255*c[d][0]);g=Math.round(255*c[d][1]);d=Math.round(255*c[d][2])}return this.parseColor("rgb("+e+","+g+","+d+")")},convertHexToHsv:function(a){var b=this.expandColor(a);a=Math.max(Math.max(b[0],b[1]),b[2]);var c=Math.min(Math.min(b[0],b[1]),b[2]);b=a==c?0:
a==b[0]?(b[1]-b[2])/(a-c)/6:a==b[1]?(b[2]-b[0])/(a-c)/6+1/3:(b[0]-b[1])/(a-c)/6+2/3;b=b<0?b+1:b>1?b-1:b;return[b,a==0?0:1-c/a,a/255]},PARSE_COLOR_RGBRE:/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i,PARSE_COLOR_HEXRE:/^\#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,expandColor:function(a){var b,c;if(b=this.parseColor(a)){a=parseInt(b.slice(1,3),16);c=parseInt(b.slice(3,5),16);b=parseInt(b.slice(5,7),16);return[a,c,b]}},parseColor:function(a){var b=0,c="#",e;if(e=this.PARSE_COLOR_RGBRE.exec(a)){for(b=1;b<=3;b++){a=
Math.max(0,Math.min(255,parseInt(e[b],0)));c+=this.toColorPart(a)}return c}if(e=this.PARSE_COLOR_HEXRE.exec(a)){if(e[1].length==3){for(b=0;b<3;b++)c+=e[1].charAt(b)+e[1].charAt(b);return c}return"#"+e[1]}return false},toColorPart:function(a){if(a>255)a=255;var b=a.toString(16);if(a<16)return"0"+b;return b},getStyle:function(a,b){var c="";if(document.defaultView&&document.defaultView.getComputedStyle)c=document.defaultView.getComputedStyle(a,"").getPropertyValue(b);else if(a.currentStyle){b=b.replace(/\-(\w)/g,
function(e,g){return g.toUpperCase()});c=a.currentStyle[b]}return c}});SC.VALIDATE_OK=YES;SC.VALIDATE_NO_CHANGE=NO;
SC.Validator=SC.Object.extend({fieldValueForObject:function(a){return a},objectForFieldValue:function(a){return a},validate:function(){return true},validateError:function(a,b){return SC.$error("Invalid.General(%@)".loc(b.get("fieldValue")),b.get("fieldKey"))},validateChange:function(a,b){return this.validate(a,b)?SC.VALIDATE_OK:this.validateError(a,b)},validateSubmit:function(a,b){return this.validate(a,b)?SC.VALIDATE_OK:this.validateError(a,b)},validatePartial:function(a,b){return b.get("isValid")?
SC.VALIDATE_NO_CHANGE:this.validate(a,b)?SC.VALIDATE_OK:this.validateError(a,b)},validateKeyDown:function(){return true},attachTo:function(){},detachFrom:function(){}});
SC.Validator.mixin({OK:true,NO_CHANGE:false,findFor:function(a,b,c){var e;if(c){if(c instanceof SC.Validator)e=c;else if(c.isClass)e=c.create();else if(SC.typeOf(c)===SC.T_STRING){var g=null;if(e=c.match(/^(.+)\[(.*)\]/)){c=e[1];g=e[2]}c=c.classify();var d=SC.Validator[c];if(SC.none(d))throw"validator %@ not found for %@".fmt(c,b);else if(g){if(!a)throw"named validator (%@) could not be found for field %@ because the field does not belong to a form".fmt(g,b);if(!a._validatorHash)a._validatorHash=
{};(e=g?a._validatorHash[g]:null)||(e=d.create());if(g)a._validatorHash[g]=e}else e=d.create()}return e}},fieldValueForObject:function(a,b,c){return this.prototype&&this.prototype.fieldValueForObject?this.prototype.fieldValueForObject(a,b,c):null},objectForFieldValue:function(a,b,c){return this.prototype&&this.prototype.objectForFieldValue?this.prototype.objectForFieldValue(a,b,c):null}});sc_require("validators/validator");
SC.Validator.CreditCard=SC.Validator.extend({fieldValueForObject:function(a){if(typeof a=="string"&&a.length==16)a=[a.slice(0,4),a.slice(4,8),a.slice(8,12),a.slice(12,16)].join(" ");return a},objectForFieldValue:function(a){return a.replace(/[\s-\.\:]/g,"")},validate:function(a,b){return this.checkNumber(b.get("fieldValue"))},validateError:function(a,b){a=b.get("errorLabel")||"Field";return SC.$error("Invalid.CreditCard(%@)".loc(a),a)},validateKeyDown:function(a,b,c){return!!c.match(/[0-9\- ]/)},
checkNumber:function(a){if(!a||a.length===0)return YES;a=a.replace(/[^0-9]/g,"");var b=a.length,c=parseInt(a,0),e=a.toString();e=e.replace(/^\s+|\s+$/g,"");a=0;for(var g=true,d=false,f,h=0;h<b;h++){f=""+e.substring(h,h+1);if("0123456789".indexOf(f)=="-1")g=false}g||(d=false);if(b===0&&d)d=false;else if(b>=15){for(e=b;e>0;e--){b=parseInt(c,0)%10;b=parseInt(b,0);a+=b;e--;c/=10;b=parseInt(c,0)%10;b*=2;switch(b){case 10:b=1;break;case 12:b=3;break;case 14:b=5;break;case 16:b=7;break;case 18:b=9;break;
default:b=b}c/=10;a+=b}d=a%10===0?true:false}return d}});sc_require("validators/validator");SC.Validator.Date=SC.Validator.extend({format:"NNN d, yyyy h:mm:ss a",fieldValueForObject:function(a){var b;if(typeof a==="number")b=new Date(a);else if(a instanceof Date)b=a;if(b)a=b.format(this.get("format"));return a},objectForFieldValue:function(a){if(a)a=(a=Date.parseDate(a))?a.getTime():null;return a}});sc_require("validators/validator");
SC.Validator.Email=SC.Validator.extend({validate:function(a,b){return(b.get("fieldValue")||"").match(/.+@.+\...+/)},validateError:function(a,b){a=b.get("errorLabel")||"Field";return SC.$error("Invalid.Email(%@)".loc(a),a)}});SC.Validator.EmailOrEmpty=SC.Validator.Email.extend({validate:function(a,b){return(a=b.get("fieldValue"))&&a.length>0?a.match(/.+@.+\...+/):true}});sc_require("validators/validator");
SC.Validator.NotEmpty=SC.Validator.extend({validate:function(a,b){a=b.get("fieldValue");if((b=!!a)&&a.length)b=a.length>0;return b},validateError:function(a,b){a=b.get("errorLabel")||"Field";return SC.$error("Invalid.NotEmpty(%@)".loc(a.capitalize()),b.get("errorLabel"))}});sc_require("validators/validator");
SC.Validator.Number=SC.Validator.extend({places:0,fieldValueForObject:function(a){switch(SC.typeOf(a)){case SC.T_NUMBER:a=a.toFixed(this.get("places"));break;case SC.T_NULL:case SC.T_UNDEFINED:a="";break}return a},objectForFieldValue:function(a){a=a.replace(/,/g,"");switch(SC.typeOf(a)){case SC.T_STRING:a=a.length==""?null:this.get("places")>0?parseFloat(a):parseInt(a,0);break;case SC.T_NULL:case SC.T_UNDEFINED:a=null;break}return a},validate:function(a,b){a=b.get("fieldValue");return a==""||!(isNaN(a)||
isNaN(parseFloat(a)))},validateError:function(a,b){a=b.get("errorLabel")||"Field";return SC.$error("Invalid.Number(%@)".loc(a),a)},validateKeyDown:function(a,b,c){return!!c.match(/[0-9\.,\-]/)}});sc_require("validators/validator");
SC.Validator.Password=SC.Validator.extend({attachTo:function(a,b){arguments.callee.base.apply(this,arguments);if(!this.fields)this.fields=[];this.fields.push(b)},validate:function(a){if(!this.fields||this.fields.length===0)return true;var b=false,c=false,e=true,g=this.fields[0].get("fieldValue");this.fields.forEach(function(d){d=d.get("fieldValue");if(d!=g)e=false;if(!d||d.length===0)b=true;if(d&&d.length>0)c=true});return a?c===false?false:e:b===true?true:e},updateFields:function(a,b){if(!this.fields||
this.fields.length===0)return true;var c="Invalid.Password".loc(),e=this._field;this.fields.forEach(function(g){a.setErrorFor(g,b?null:g==e?c:"")});return b?SC.VALIDATE_OK:c},validateChange:function(a){return this.updateFields(a,this.validate(false))},validateSubmit:function(a){return this.updateFields(a,this.validate(true))},validatePartial:function(a){return this._field.get("isValid")?SC.VALIDATE_NO_CHANGE:this.updateFields(a,this.validate(false))}});sc_require("views/view");
SC.ContainerView=SC.View.extend({classNames:["sc-container-view"],nowShowing:null,contentView:null,contentViewBindingDefault:SC.Binding.single(),replaceContent:function(a){this.removeAllChildren();a&&this.appendChild(a)},createChildViews:function(){var a=this.get("contentView");if(a){a=this.contentView=this.createChildView(a);this.childViews=[a]}},awake:function(){arguments.callee.base.apply(this,arguments);var a=this.get("nowShowing");a&&a.length>0&&this.nowShowingDidChange()},nowShowingDidChange:function(){var a=
this.get("nowShowing"),b=null;if(SC.typeOf(a)===SC.T_STRING){if(a===SC.CONTENT_SET_DIRECTLY)return;if(a&&a.length>0)b=a.indexOf(".")>0?SC.objectForPropertyPath(a,null):SC.objectForPropertyPath(a,this.get("page"))}else b=a;if(b&&!(b instanceof SC.View))b=null;this.set("contentView",b)}.observes("nowShowing"),contentViewDidChange:function(){this.replaceContent(this.get("contentView"))}.observes("contentView")});sc_require("views/view");sc_require("mixins/control");SC.IMAGE_STATE_NONE="none";
SC.IMAGE_STATE_LOADING="loading";SC.IMAGE_STATE_LOADED="loaded";SC.IMAGE_STATE_FAILED="failed";SC.IMAGE_STATE_SPRITE="sprite";SC.BLANK_IMAGE_DATAURL="data:image/gif;base64,R0lGODlhAQABAJAAAP///wAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw==";SC.BLANK_IMAGE_URL=SC.browser.msie&&SC.browser.msie<8?"/static/sproutcore/foundation/en/d5356c4dc5eed765f3239fcaaa4b599b3de5c4b0/blank.gif":SC.BLANK_IMAGE_DATAURL;
SC.ImageView=SC.View.extend(SC.Control,{classNames:"sc-image-view",tagName:"img",status:SC.IMAGE_STATE_NONE,value:null,useImageCache:YES,canLoadInBackground:NO,localize:YES,displayProperties:"status toolTip".w(),render:function(a){var b=this.get("status"),c=this.get("value");b===SC.IMAGE_STATE_NONE&&c&&this._image_valueDidChange();b=this.get("status");var e=b===SC.IMAGE_STATE_LOADED?c:SC.BLANK_IMAGE_URL;b===SC.IMAGE_STATE_SPRITE&&a.addClass(c);a.attr("src",e);b=this.get("toolTip");if(SC.typeOf(b)===
SC.T_STRING){if(this.get("localize"))b=b.loc();a.attr("title",b);a.attr("alt",b)}},_image_valueDidChange:function(){var a=this.get("value"),b;if(a&&a.isEnumerable)a=a.firstObject();if((b=SC.ImageView.valueIsUrl(a))&&this.get("useImageCache")){b=this.get("isVisibleInWindow")||this.get("canLoadInBackground");this._loadingUrl=a;SC.imageCache.loadImage(a,this,this.imageDidLoad,b);this._loadingUrl&&this.set("status",SC.IMAGE_STATE_LOADING)}else{this._loadingUrl=null;this.set("status",b?SC.IMAGE_STATE_LOADED:
SC.IMAGE_STATE_SPRITE);this.displayDidChange()}}.observes("value"),imageDidLoad:function(a,b){if(a===this._loadingUrl)this._loadingUrl=null;if(this.get("value")===a){this.set("status",SC.$ok(b)?SC.IMAGE_STATE_LOADED:SC.IMAGE_STATE_FAILED);this.displayDidChange()}}});SC.ImageView.valueIsUrl=function(a){return a?a.indexOf("/")>=0:NO};sc_require("views/view");sc_require("mixins/control");SC.ALIGN_LEFT="left";SC.ALIGN_RIGHT="right";SC.ALIGN_CENTER="center";SC.REGULAR_WEIGHT="normal";SC.BOLD_WEIGHT="bold";
SC.LabelView=SC.View.extend(SC.Control,{classNames:["sc-label-view"],fontWeight:SC.REGULAR_WEIGHT,escapeHTML:true,escapeHTMLBindingDefault:SC.Binding.oneWay().bool(),localize:false,localizeBindingDefault:SC.Binding.oneWay().bool(),formatter:null,value:"",hint:null,exampleInlineTextFieldView:SC.InlineTextFieldView,icon:null,textAlign:SC.ALIGN_LEFT,isInlineEditorMultiline:NO,displayValue:function(){var a=this.get("value"),b=this.getDelegateProperty("formatter",this.displayDelegate);if(b){b=SC.typeOf(b)===
SC.T_FUNCTION?b(a,this):b.fieldValueForObject(a,this);SC.none(b)||(a=b)}if(SC.typeOf(a)===SC.T_ARRAY){b=[];for(var c=0;c<a.get("length");c++){var e=a.objectAt(c);if(!SC.none(e)&&e.toString)e=e.toString();b.push(e)}a=b.join(",")}if(!SC.none(a)&&a.toString)a=a.toString();if(a&&this.getDelegateProperty("localize",this.displayDelegate))a=a.loc();if(this.get("escapeHTML"))a=SC.RenderContext.escapeHTML(a);return a}.property("value","localize","formatter","escapeHTML").cacheable(),isEditable:NO,isEditableBindingDefault:SC.Binding.bool(),
isEditing:NO,validator:null,doubleClick:function(){return this.beginEditing()},beginEditing:function(){if(this.get("isEditing"))return YES;if(!this.get("isEditable"))return NO;var a=this.$(),b=this.get("value")||"",c=SC.viewportOffset(a[0]),e=this.convertFrameFromView(this.get("frame"),null);c.width=e.width;c.height=e.height;SC.InlineTextFieldView.beginEditing({frame:c,delegate:this,exampleElement:a,value:b,multiline:this.get("isInlineEditorMultiline"),isCollection:NO,validator:this.get("validator"),
exampleInlineTextFieldView:this.get("exampleInlineTextFieldView")})},discardEditing:function(){if(!this.get("isEditing"))return YES;return SC.InlineTextFieldView.discardEditing()},commitEditing:function(){if(!this.get("isEditing"))return YES;return SC.InlineTextFieldView.commitEditing()},inlineEditorWillBeginEditing:function(){this.set("isEditing",YES)},inlineEditorDidBeginEditing:function(){this._oldOpacity=this.$().css("opacity");this.$().css("opacity",0)},inlineEditorShouldEndEditing:function(){return YES},
inlineEditorDidEndEditing:function(a,b){this.setIfChanged("value",b);this.$().css("opacity",this._oldOpacity);this._oldOpacity=null;this.set("isEditing",NO)},displayProperties:"displayValue textAlign fontWeight icon".w(),_TEMPORARY_CLASS_HASH:{},render:function(a){var b=this.get("displayValue"),c=this.get("icon"),e=this.get("hint");if(c){var g=c.indexOf("/")>=0?c:SC.BLANK_IMAGE_URL;c='<img src="%@" alt="" class="icon %@" />'.fmt(g,g===c?"":c);a.push(c)}e&&(!b||b==="")?a.push('<span class="sc-hint">',
e,"</span>"):a.push(b);a.addStyle("text-align",this.get("textAlign")).addStyle("font-weight",this.get("fontWeight"));b=this._TEMPORARY_CLASS_HASH;b.icon=!!this.get("icon");a.setClass(b);this.get("isEditing")&&a.addStyle("opacity",0)}});sc_require("panes/pane");
SC.MainPane=SC.Pane.extend({layout:{left:0,right:0,top:0,bottom:0},paneDidAttach:function(){var a=arguments.callee.base.apply(this,arguments),b=this.rootResponder;b.makeMainPane(this);b.get("keyRootView")||b.makeKeyPane(this);return a},acceptsKeyPane:YES,classNames:["sc-main"]});tiki.script("sproutcore/foundation:en/d5356c4dc5eed765f3239fcaaa4b599b3de5c4b0/javascript.js");
tiki.register("sproutcore/desktop",{packages:{"sproutcore/runtime":{scripts:[{url:"/static/sproutcore/runtime/en/cfe6f8a7557f916515999a065d70bfa71bd13986/javascript.js",id:"sproutcore/runtime:en/cfe6f8a7557f916515999a065d70bfa71bd13986/javascript.js"}]},"sproutcore/datastore":{scripts:[{url:"/static/sproutcore/datastore/en/334c3630f54926a13d0810d33b3686af21530ee7/javascript.js",id:"sproutcore/datastore:en/334c3630f54926a13d0810d33b3686af21530ee7/javascript.js"}]},"sproutcore/foundation":{stylesheets:[{url:"/static/sproutcore/foundation/en/d5356c4dc5eed765f3239fcaaa4b599b3de5c4b0/stylesheet.css",
id:"sproutcore/foundation:en/d5356c4dc5eed765f3239fcaaa4b599b3de5c4b0/stylesheet.css"}],scripts:[{url:"/static/sproutcore/foundation/en/d5356c4dc5eed765f3239fcaaa4b599b3de5c4b0/javascript.js",id:"sproutcore/foundation:en/d5356c4dc5eed765f3239fcaaa4b599b3de5c4b0/javascript.js"}]}},stylesheets:[{url:"/static/sproutcore/desktop/en/57a37cf8f2abf4dfdcfdbc5bcf79f41605b5ca83/stylesheet.css",id:"sproutcore/desktop:en/57a37cf8f2abf4dfdcfdbc5bcf79f41605b5ca83/stylesheet.css"}],depends:["sproutcore/runtime",
"sproutcore/datastore","sproutcore/foundation"],scripts:[{url:"/static/sproutcore/desktop/en/57a37cf8f2abf4dfdcfdbc5bcf79f41605b5ca83/javascript.js",id:"sproutcore/desktop:en/57a37cf8f2abf4dfdcfdbc5bcf79f41605b5ca83/javascript.js"}]});tiki.global("sproutcore/desktop");
SC.stringsFor("English",{"Invalid.CreditCard(%@)":"%@ is not a valid credit card number","Invalid.Email(%@)":"%@ is not a valid email address","Invalid.NotEmpty(%@)":"%@ must not be empty","Invalid.Password":"Your passwords do not match.  Please try typing them again.","Invalid.General(%@)":"%@ is invalid.  Please try again.","Invalid.Number(%@)":"%@ is not a number."});SC.allowsBackspaceToPreviousPage=NO;SC.BORDER_BEZEL="sc-bezel-border";SC.BORDER_BLACK="sc-black-border";SC.BORDER_GRAY="sc-gray-border";
SC.BORDER_TOP="sc-top-border";SC.BORDER_BOTTOM="sc-bottom-border";SC.BORDER_NONE=null;SC.Border={borderStyle:SC.BORDER_GRAY,_BORDER_REGEXP:/-border$/,renderMixin:function(a){var b=this.get("borderStyle");if(b)this._BORDER_REGEXP.exec(b)?a.addClass(b):content.addStyle("border","1px %@ solid".fmt(b))}};SC.CollectionGroup={classNames:["sc-collection-group"]};SC.CollectionRowDelegate={isCollectionRowDelegate:YES,rowHeight:18,customRowHeightIndexes:null,contentIndexRowHeight:function(){return this.get("rowHeight")}};
SC.CollectionViewDelegate={isCollectionViewDelegate:YES,collectionViewSelectionForProposedSelection:function(a,b){return b},collectionViewShouldSelectIndexes:function(a,b){return b},collectionViewShouldDeselectIndexes:function(a,b){return b},collectionViewShouldDeleteIndexes:function(a,b){return b},collectionViewDeleteContent:function(a,b,c){if(!b)return NO;if(SC.typeOf(b.destroyAt)===SC.T_FUNCTION){b.destroyAt(c);a.selectPreviousItem(NO,1);return YES}else if(SC.typeOf(b.removeAt)===SC.T_FUNCTION){b.removeAt(c);
a.selectPreviousItem(NO,1);return YES}else return NO},collectionViewShouldBeginDrag:function(){return YES},collectionViewDragDataTypes:function(){return[]},collectionViewDragDataForType:function(){return null},collectionViewComputeDragOperations:function(a,b,c){return c},collectionViewValidateDragOperation:function(a,b,c,e,g){return g&SC.DROP_ON?SC.DRAG_NONE:c},collectionViewPerformDragOperation:function(){return SC.DRAG_NONE},collectionViewDragViewFor:function(){return null},ghostActsLikeCursor:NO};
SC.Scrollable={isScrollable:true,verticalLineScroll:20,horizontalLineScroll:20,verticalPageScroll:function(){return this.get("innerFrame").height}.property("innerFrame"),horizontalPageScroll:function(){return this.get("innerFrame").width}.property("innerFrame"),hasVerticalScroller:function(){return this.get("scrollFrame").height>this.get("innerFrame").height}.property("scrollFrame"),hasHorizontalScroller:function(){return this.get("scrollFrame").width>this.get("innerFrame").width}.property("scrollFrame"),
scrollBy:function(a){var b=this.get("scrollFrame"),c=this.get("innerFrame");if(!this.get("hasVerticalScroller"))a.y=0;if(b.height<=c.height)a.y=0;if(!this.get("hasHorizontalScroller"))a.x=0;if(b.width<=c.width)a.x=0;a={x:b.x-(a.x||0),y:b.y-(a.y||0)};this.set("scrollFrame",a);a=this.get("scrollFrame");return{x:a.x-b.x,y:a.y-b.y}},scrollTo:function(a,b){this.set("scrollFrame",{x:0-a,y:0-b})},scrollToVisible:function(a){var b=this.get("innerFrame"),c=this.get("scrollFrame");a=this.convertFrameFromView(a.get("frame"),
a);a.x-=b.x+c.x;a.y-=b.y+c.y;b={x:0-c.x,y:0-c.y,width:b.width,height:b.height};b.y-=Math.max(0,SC.minY(b)-SC.minY(a));b.x-=Math.max(0,SC.minX(b)-SC.minX(a));b.y+=Math.max(0,SC.maxY(a)-SC.maxY(b));b.x+=Math.max(0,SC.maxX(a)-SC.maxX(b));this.scrollTo(b.x,b.y)},scrollDownLine:function(a){if(a===undefined)a=1;return this.scrollBy({y:this.get("verticalLineScroll")*a}).y},scrollUpLine:function(a){if(a===undefined)a=1;return 0-this.scrollBy({y:0-this.get("verticalLineScroll")*a}).y},scrollRightLine:function(a){if(a===
undefined)a=1;return this.scrollTo({y:this.get("horizontalLineScroll")*a}).x},scrollLeftLine:function(a){if(a===undefined)a=1;return 0-this.scrollTo({y:0-this.get("horizontalLineScroll")*a}).x},scrollDownPage:function(a){if(a===undefined)a=1;return this.scrollBy({y:this.get("verticalPageScroll")*a}).y},scrollUpPage:function(a){if(a===undefined)a=1;return 0-this.scrollBy({y:0-this.get("verticalPageScroll")*a}).y},scrollRightPage:function(a){if(a===undefined)a=1;return this.scrollTo({y:this.get("horizontalPageScroll")*
a}).x},scrollLeftPage:function(a){if(a===undefined)a=1;return 0-this.scrollTo({y:0-this.get("horizontalPageScroll")*a}).x}};
SC.ModalPane=SC.Pane.extend({classNames:"sc-modal",layout:{top:0,left:0,bottom:0,right:0},_openPaneCount:0,paneWillAppend:function(){this._openPaneCount++;this.get("isVisibleInWindow")||this.append();return this},paneDidRemove:function(){this._openPaneCount--;if(this._openPaneCount<=0){this._openPaneCount=0;this.get("isVisibleInWindow")&&this.remove()}},mouseDown:function(a){var b=this.get("owner");b&&b.modalPaneDidClick&&b.modalPaneDidClick(a)}});sc_require("panes/modal");
SC.PanelPane=SC.Pane.extend({layout:{left:0,right:0,top:0,bottom:0},classNames:["sc-panel"],acceptsKeyPane:YES,isModal:YES,modalPane:SC.ModalPane.extend({classNames:"for-sc-panel"}),contentView:null,contentViewBindingDefault:SC.Binding.single(),render:function(a,b){if(a.needsContent){this.renderChildViews(a,b);a.push("<div class='top-left-edge'></div>","<div class='top-edge'></div>","<div class='top-right-edge'></div>","<div class='right-edge'></div>","<div class='bottom-right-edge'></div>","<div class='bottom-edge'></div>",
"<div class='bottom-left-edge'></div>","<div class='left-edge'></div>")}},replaceContent:function(a){this.removeAllChildren();a&&this.appendChild(a)},createChildViews:function(){var a=this.contentView;if(a){a=this.contentView=this.createChildView(a);this.childViews=[a]}},contentViewDidChange:function(){this.replaceContent(this.get("contentView"))}.observes("contentView"),_modalPane:function(){var a=this.get("modalPane");if(a&&a.isClass){a=a.create({owner:this});this.set("modalPane",a)}return a},appendTo:function(){var a;
if(!this.get("isVisibleInWindow")&&this.get("isModal")&&(a=this._modalPane())){this._isShowingModal=YES;a.paneWillAppend(this)}return arguments.callee.base.apply(this,arguments)},remove:function(){var a,b=arguments.callee.base.apply(this,arguments);if(this._isShowingModal){this._isShowingModal=NO;if(a=this._modalPane())a.paneDidRemove(this)}return b},_isModalDidChange:function(){var a;if(this.get("isModal")){if(!this._isShowingModal&&this.get("isVisibleInWindow")&&(a=this._modalPane())){this._isShowingModal=
YES;a.paneWillAppend(this)}}else if(this._isShowingModal&&(a=this._modalPane())){this._isShowingModal=NO;a.paneDidRemove(this)}}.observes("isModal"),paneDidAttach:function(){var a=arguments.callee.base.apply(this,arguments);this.becomeKeyPane();return a},mouseDown:function(){return YES}});SC.TOGGLE_BEHAVIOR="toggle";SC.PUSH_BEHAVIOR="push";SC.TOGGLE_ON_BEHAVIOR="on";SC.TOGGLE_OFF_BEHAVIOR="off";
SC.ButtonView=SC.View.extend(SC.Control,SC.Button,SC.StaticLayout,{tagName:"a",classNames:["sc-button-view"],theme:"square",buttonBehavior:SC.PUSH_BEHAVIOR,isDefault:NO,isDefaultBindingDefault:SC.Binding.oneWay().bool(),isCancel:NO,isCancelBindingDefault:SC.Binding.oneWay().bool(),href:"",action:null,target:null,triggerAction:function(a){if(!this.get("isEnabled"))return NO;this.set("isActive",YES);this._action(a);this.didTriggerAction();this.invokeLater("set",200,"isActive",NO);return true},didTriggerAction:function(){},
titleMinWidth:80,init:function(){arguments.callee.base.apply(this,arguments);if(this.get("keyEquivalent"))this._defaultKeyEquivalent=this.get("keyEquivalent")},_TEMPORARY_CLASS_HASH:{},displayProperties:["href","icon","title","value","toolTip"],render:function(a,b){var c;if(this.get("tagName")==="a"){c=this.get("href");if(!c||c.length===0)c="javascript:;";a.attr("href",c)}c=this.get("toolTip");if(SC.typeOf(c)===SC.T_STRING){if(this.get("localize"))c=c.loc();a.attr("title",c);a.attr("alt",c)}c=this._TEMPORARY_CLASS_HASH;
c.def=this.get("isDefault");c.cancel=this.get("isCancel");c.icon=!!this.get("icon");a.attr("role","button").setClass(c).addClass(this.get("theme"));if(b){a=a.push("<span class='sc-button-inner' style = 'min-width:%@px'>".fmt(this.get("titleMinWidth")));this.renderTitle(a,b);a.push("</span>")}else this.renderTitle(a,b)},_defaultKeyEquivalent:null,_isDefaultOrCancelDidChange:function(){var a=!!this.get("isDefault"),b=!a&&this.get("isCancel");if(this.didChangeFor("defaultCancelChanged","isDefault","isCancel")){this.displayDidChange();
if(a)this.set("keyEquivalent","return");else b?this.setIfChanged("keyEquivalent","escape"):this.set("keyEquivalent",this._defaultKeyEquivalent)}}.observes("isDefault","isCancel"),isMouseDown:false,mouseDown:function(){if(!this.get("isEnabled"))return YES;this.set("isActive",YES);this._isMouseDown=YES;if(!this._isFocused&&this.get("buttonBehavior")!==SC.PUSH_BEHAVIOR){this._isFocused=YES;this.becomeFirstResponder();this.get("isVisibleInWindow")&&this.$()[0].focus()}return YES},mouseExited:function(){this._isMouseDown&&
this.set("isActive",NO);return YES},mouseEntered:function(){this.set("isActive",this._isMouseDown);return YES},mouseUp:function(a){this._isMouseDown&&this.set("isActive",NO);this._isMouseDown=false;this.$().within(a.target)&&this.get("isEnabled")&&this._action(a);return true},keyDown:function(a){if(a.which===9){(a.shiftKey?this.get("previousValidKeyView"):this.get("nextValidKeyView")).becomeFirstResponder();return YES}if(a.which===13){this.triggerAction(a);return YES}return YES},_action:function(a){switch(this.get("buttonBehavior")){case SC.TOGGLE_BEHAVIOR:this.get("isSelected")?
this.set("value",this.get("toggleOffValue")):this.set("value",this.get("toggleOnValue"));break;case SC.TOGGLE_ON_BEHAVIOR:this.set("value",this.get("toggleOnValue"));break;case SC.TOGGLE_OFF_BEHAVIOR:this.set("value",this.get("toggleOffValue"));break;default:var b=this.get("action"),c=this.get("target")||null;if(b)this._hasLegacyActionHandler()?this._triggerLegacyActionHandler(a):this.getPath("pane.rootResponder").sendAction(b,c,this,this.get("pane"))}},_hasLegacyActionHandler:function(){var a=this.get("action");
if(a&&SC.typeOf(a)==SC.T_FUNCTION)return true;if(a&&SC.typeOf(a)==SC.T_STRING&&a.indexOf(".")!=-1)return true;return false},_triggerLegacyActionHandler:function(a){if(!this._hasLegacyActionHandler())return false;var b=this.get("action");SC.typeOf(b)==SC.T_FUNCTION&&this.action(a);if(SC.typeOf(b)==SC.T_STRING){eval("this.action = function(e) { return "+b+"(this, e); };");this.action(a)}},acceptsFirstResponder:function(){return this.get("isEnabled")}.property("isEnabled"),willBecomeKeyResponderFrom:function(){if(!this._isFocused){this._isFocused=
YES;this.becomeFirstResponder();this.get("isVisibleInWindow")&&this.$()[0].focus()}},willLoseKeyResponderTo:function(){if(this._isFocused)this._isFocused=NO},didCreateLayer:function(){if(SC.browser.msie<8){var a=this.$(".sc-button-inner")[0];if(a){a=a.style.marginLeft;this.$(".sc-button-label")[0].style.minWidth=this.get("titleMinWidth")-a}}}});sc_require("panes/panel");sc_require("views/button");SC.BUTTON1_STATUS="button1";SC.BUTTON2_STATUS="button2";SC.BUTTON3_STATUS="button3";
SC.AlertPane=SC.PanelPane.extend({classNames:"sc-alert",delegate:null,icon:"sc-icon-alert-48",message:"",description:"",displayDescription:function(){var a=this.get("description");if(!a||a.length===0)return a;a=SC.RenderContext.escapeHTML(a);return'<p class="description">'+a.split("\n").join('</p><p class="description">')+"</p>"}.property("description").cacheable(),caption:"",displayCaption:function(){var a=this.get("caption");if(!a||a.length===0)return a;a=SC.RenderContext.escapeHTML(a);return'<p class="caption">'+
a.split("\n").join('</p><p class="caption">')+"</p>"}.property("caption").cacheable(),buttonOne:SC.outlet("contentView.childViews.1.childViews.1"),buttonTwo:SC.outlet("contentView.childViews.1.childViews.0"),buttonThree:SC.outlet("contentView.childViews.2.childViews.0"),buttonThreeWrapper:SC.outlet("contentView.childViews.2"),layout:{centerX:0,width:500,top:55},contentView:SC.View.extend({useStaticLayout:YES,layout:{left:0,right:0,top:0,height:"auto"},childViews:[SC.View.extend(SC.StaticLayout,{classNames:["info"],
render:function(a){var b=this.get("pane"),c=SC.BLANK_IMAGE_URL;b.get("icon")=="blank"&&a.addClass("plain");a.push('<img src="%@" class="icon %@" />'.fmt(c,b.get("icon")));a.begin("h1").text(b.get("message")||"").end();a.push(b.get("displayDescription")||"");a.push(b.get("displayCaption")||"");a.push('<div class="separator"></div>')}}),SC.View.extend({layout:{bottom:13,height:24,right:18,width:466},childViews:["cancelButton","okButton"],classNames:["textAlignRight"],cancelButton:SC.ButtonView.extend({useStaticLayout:YES,
actionKey:SC.BUTTON2_STATUS,localize:YES,titleMinWidth:64,layout:{right:5,height:"auto",width:"auto",bottom:0},theme:"capsule",title:"Cancel",action:"dismiss",isVisible:NO}),okButton:SC.ButtonView.extend({useStaticLayout:YES,actionKey:SC.BUTTON1_STATUS,localize:YES,titleMinWidth:64,layout:{left:0,height:"auto",width:"auto",bottom:0},theme:"capsule",title:"OK",isDefault:YES,action:"dismiss"})}),SC.View.extend({layout:{bottom:13,height:24,left:18,width:150},isVisible:NO,childViews:[SC.ButtonView.extend({useStaticLayout:YES,
actionKey:SC.BUTTON3_STATUS,localize:YES,titleMinWidth:64,layout:{left:0,height:"auto",width:"auto",bottom:0},theme:"capsule",title:"Extra",action:"dismiss",isVisible:NO})]})]}),dismiss:function(a){var b=this.delegate;b&&b.alertPaneDidDismiss&&b.alertPaneDidDismiss(this,a.get("actionKey"));this.remove()},alertInfoDidChange:function(){var a=this.getPath("contentView.childViews.0");a&&a.displayDidChange()}.observes("icon","message","displayDescription","displayCaption")});
SC.AlertPane._normalizeArguments=function(a){a=SC.A(a);var b=a.length,c=a[b-1];if(SC.typeOf(c)!==SC.T_STRING)a[b-1]=null;else c=null;a[7]=c;return a};
SC.AlertPane.show=function(){for(var a=this._normalizeArguments(arguments),b=this.create({message:a[0]||"",description:a[1]||null,caption:a[2]||null,icon:a[6]||"sc-icon-alert-48",delegate:a[7]}),c="buttonOne buttonTwo buttonThree".w(),e,g,d=0;d<3;d++){e=b.get(c[d]);if(g=a[d+3]){e.set("title",g).set("isVisible",YES);d==2&&b.get("buttonThreeWrapper").set("isVisible",YES)}}a=b.append();b.adjust("height",b.childViews[0].$().height());b.updateLayout();return a};
SC.AlertPane.warn=function(){var a=this._normalizeArguments(arguments);a[6]="sc-icon-alert-48";return this.show.apply(this,a)};SC.AlertPane.info=function(){var a=this._normalizeArguments(arguments);a[6]="sc-icon-info-48";return this.show.apply(this,a)};SC.AlertPane.error=function(){var a=this._normalizeArguments(arguments);a[6]="sc-icon-error-48";return this.show.apply(this,a)};SC.AlertPane.plain=function(){var a=this._normalizeArguments(arguments);a[6]="blank";return this.show.apply(this,a)};sc_require("panes/panel");
SC.PalettePane=SC.PanelPane.extend({classNames:"sc-palette",isModal:NO,modalPane:SC.ModalPane,isAnchored:NO,_mouseOffsetX:null,_mouseOffsetY:null,mouseDown:function(a){var b=this.get("frame");this._mouseOffsetX=b?b.x-a.pageX:0;this._mouseOffsetY=b?b.y-a.pageY:0;return YES},mouseDragged:function(a){if(!this.isAnchored){this.set("layout",{width:this.layout.width,height:this.layout.height,left:this._mouseOffsetX+a.pageX,top:this._mouseOffsetY+a.pageY});this.updateLayout()}return YES}});sc_require("panes/palette");
SC.PICKER_MENU="menu";SC.PICKER_FIXED="fixed";SC.PICKER_POINTER="pointer";SC.POINTER_LAYOUT=["perfectRight","perfectLeft","perfectTop","perfectBottom"];
SC.PickerPane=SC.PalettePane.extend({classNames:"sc-picker",isAnchored:YES,isModal:YES,pointerPos:"perfectRight",pointerPosX:0,pointerPosY:0,anchorElement:null,preferType:null,preferMatrix:null,popup:function(a,b,c){a=a.isView?a.get("layer"):a;this.beginPropertyChanges();this.set("anchorElement",a);b&&this.set("preferType",b);c&&this.set("preferMatrix",c);this.endPropertyChanges();this.positionPane();this.append()},positionPane:function(){var a=this.get("anchorElement"),b=this.get("preferType"),c=
this.get("preferMatrix"),e=this.get("layout");if(a){a=this.computeAnchorRect(a);e=SC.cloneRect(a);if(b)switch(b){case SC.PICKER_MENU:case SC.PICKER_FIXED:if(!c||c.length!=3)this.set("preferMatrix",[1,4,3]);e.x+=(this.preferMatrix[2]===0?e.width:0)+this.preferMatrix[0];e.y+=(this.preferMatrix[2]===3?e.height:0)+this.preferMatrix[1];break;default:e.y+=e.height;break}else e.y+=e.height;e=this.fitPositionToScreen(e,this.get("frame"),a);e={width:e.width,height:e.height,left:e.x,top:e.y}}else e={width:e.width,
height:e.height,centerX:0,centerY:0};this.set("layout",e).updateLayout();return this},computeAnchorRect:function(a){var b=SC.viewportOffset(a);a=SC.$(a);b.width=a.outerWidth();b.height=a.outerHeight();return b},fitPositionToScreen:function(a,b,c){var e=this.get("currentWindowSize")||SC.RootResponder.responder.computeWindowSize();e={x:0,y:0,width:e.width,height:e.height};b.x=a.x;b.y=a.y;if(this.preferType)switch(this.preferType){case SC.PICKER_MENU:b=this.fitPositionToScreenDefault(e,b,c);b=this.fitPositionToScreenMenu(e,
b);break;case SC.PICKER_POINTER:b=this.fitPositionToScreenPointer(e,b,c);break;case SC.PICKER_FIXED:break;default:break}else b=this.fitPositionToScreenDefault(e,b,c);this.displayDidChange();return b},fitPositionToScreenDefault:function(a,b,c){if(SC.maxX(b)>a.width){var e=Math.max(SC.maxX(c),b.width);b.x=Math.min(e,a.width)-b.width}if(SC.minX(b)<0){b.x=SC.minX(Math.max(c,0));if(SC.maxX(b)>a.width)b.x=Math.max(0,a.width-b.width)}if(SC.maxY(b)>a.height){e=Math.max(c.y-b.height,0);b.y=e>a.height?Math.max(0,
a.height-b.height):e}if(SC.minY(b)<0){e=Math.min(SC.maxY(c),a.height-c.height);b.y=Math.max(e,0)}return b},fitPositionToScreenMenu:function(a,b){if(b.x+b.width>a.width-9)b.x=a.width-b.width-9;if(b.x<7)b.x=7;if(b.height>a.height){b.y=15;b.height=a.height-35}return b},fitPositionToScreenPointer:function(a,b,c){var e=c.height>12?0:1,g=c.height>12?0:3,d=[[c.x+c.width+(7+e),c.y+parseInt(c.height/2,0)-40],[c.x-b.width-(7+e),c.y+parseInt(c.height/2,0)-40],[c.x+parseInt(c.width/2,0)-parseInt(b.width/2,0),
c.y-b.height-(17+g)],[c.x+parseInt(c.width/2,0)-parseInt(b.width/2,0),c.y+c.height+(17+g)]];e=[[c.x+c.width+b.width+(7+e),c.y+parseInt(c.height/2,0)+b.height-24],[c.x-(7+e),c.y+parseInt(c.height/2,0)+b.height-24],[c.x+parseInt(c.width/2,0)-parseInt(b.width/2,0)+b.width,c.y-(17+g)],[c.x+parseInt(c.width/2,0)-parseInt(b.width/2,0)+b.width,c.y+c.height+b.height+(17+g)]];a=[[d[0][1]>0?0:0-d[0][1],e[0][0]<a.width?0:e[0][0]-a.width,e[0][1]<a.height?0:e[0][1]-a.height,d[0][0]>0?0:0-d[0][0]],[d[1][1]>0?0:
0-d[1][1],e[1][0]<a.width?0:e[1][0]-a.width,e[1][1]<a.height?0:e[1][1]-a.height,d[1][0]>0?0:0-d[1][0]],[d[2][1]>0?0:0-d[2][1],e[2][0]<a.width?0:e[2][0]-a.width,e[2][1]<a.height?0:e[2][1]-a.height,d[2][0]>0?0:0-d[2][0]],[d[3][1]>0?0:0-d[3][1],e[3][0]<a.width?0:e[3][0]-a.width,e[3][1]<a.height?0:e[3][1]-a.height,d[3][0]>0?0:0-d[3][0]]];if(!this.preferMatrix||this.preferMatrix.length!=5)this.set("preferMatrix",[0,1,2,3,2]);e=this.preferMatrix;if(e[4]===-1){b.x=c.x+parseInt(c.width/2,0);b.y=c.y+parseInt(c.height/
2,0)-parseInt(b.height/2,0);this.set("pointerPos",SC.POINTER_LAYOUT[0]+" fallback");this.set("pointerPosY",parseInt(b.height/2,0)-40)}else{b.x=d[e[4]][0];b.y=d[e[4]][1];this.set("pointerPos",SC.POINTER_LAYOUT[e[4]]);this.set("pointerPosY",0)}this.set("pointerPosX",0);for(c=0;c<SC.POINTER_LAYOUT.length;c++)if(a[e[c]][0]===0&&a[e[c]][1]===0&&a[e[c]][2]===0&&a[e[c]][3]===0){if(e[4]!=e[c]){b.x=d[e[c]][0];b.y=d[e[c]][1];this.set("pointerPosY",0);this.set("pointerPos",SC.POINTER_LAYOUT[e[c]])}c=SC.POINTER_LAYOUT.length}else if((e[c]===
0||e[c]===1)&&a[e[c]][0]===0&&a[e[c]][1]===0&&a[e[c]][2]<b.height-91&&a[e[c]][3]===0){if(e[4]!=e[c]){b.x=d[e[c]][0];this.set("pointerPos",SC.POINTER_LAYOUT[e[c]])}b.y=d[e[c]][1]-a[e[c]][2];this.set("pointerPosY",a[e[c]][2]);c=SC.POINTER_LAYOUT.length}else if((e[c]===0||e[c]===1)&&a[e[c]][0]===0&&a[e[c]][1]===0&&a[e[c]][2]<=b.height-57&&a[e[c]][3]===0){if(e[4]!=e[c])b.x=d[e[c]][0];b.y=d[e[c]][1]-(b.height-57);this.set("pointerPosY",b.height-59);this.set("pointerPos",SC.POINTER_LAYOUT[e[c]]+" extra-low");
c=SC.POINTER_LAYOUT.length}return b},displayProperties:["pointerPosY"],render:function(a){var b=arguments.callee.base.apply(this,arguments);if(a.needsContent)this.get("preferType")==SC.PICKER_POINTER&&a.push('<div class="sc-pointer %@" style="margin-top: %@px"></div>'.fmt(this.get("pointerPos"),this.get("pointerPosY")));else{var c=this.$(".sc-pointer");c.attr("class","sc-pointer %@".fmt(this.get("pointerPos")));c.attr("style","margin-top: %@px".fmt(this.get("pointerPosY")))}return b},modalPaneDidClick:function(a){this.clickInside(this.get("frame"),
a)||this.remove();return YES},mouseDown:function(a){return this.modalPaneDidClick(a)},clickInside:function(a,b){return SC.pointInRect({x:b.pageX,y:b.pageY},a)},windowSizeDidChange:function(){arguments.callee.base.apply(this,arguments);this.positionPane()}});SC.SeparatorView=SC.View.extend({classNames:["sc-separator-view"],tagName:"span",layoutDirection:SC.LAYOUT_HORIZONTAL,render:function(a,b){b&&a.push("<span></span>");a.addClass(this.get("layoutDirection"))}});sc_require("views/button");sc_require("views/separator");
SC.BENCHMARK_MENU_ITEM_RENDER=YES;
SC.MenuItemView=SC.ButtonView.extend(SC.ContentDisplay,{classNames:["sc-menu-item"],tagName:"div",parentPane:null,acceptsFirstResponder:YES,content:null,isSubMenuViewVisible:null,isSeparator:NO,contentValueKey:null,contentIsBranchKey:null,shortCutKey:null,contentIconKey:null,contentCheckboxKey:"checkbox",contentActionKey:null,itemWidth:100,itemHeight:20,subMenu:null,hasMouseExited:NO,anchor:null,displayProperties:["contentValueKey","contentIconKey","shortCutKey","contentIsBranchKey","itemHeight",
"subMenu","isEnabled","content"],contentDisplayProperties:"title value icon separator action checkbox shortcut branchItem subMenu".w(),render:function(a){var b;if(SC.BENCHMARK_MENU_ITEM_RENDER){b="%@.render".fmt(this);SC.Benchmark.start(b)}var c=this.get("content"),e=this.displayDelegate,g,d;d=this.parentMenu();d=this.get("itemWidth")||d.layout.width;g=this.get("itemHeight")||20;this.set("itemWidth",d);this.set("itemHeight",g);this.get("isEnabled")||a.addClass("disabled");d=a.begin("a").attr("href",
"javascript: ;");if(g=(g=this.getDelegateProperty("isSeparatorKey",e))&&c?c.get?c.get(g):c[g]:null){d.push("<span class='separator'></span>");a.addClass("disabled")}else{if(g=this.getDelegateProperty("contentCheckboxKey",e))(g=c?c.get?c.get(g):c[g]:NO)&&d.begin("div").addClass("checkbox").end();if((g=(g=this.getDelegateProperty("contentIconKey",e))&&c?c.get?c.get(g):c[g]:null)&&SC.typeOf(g)!==SC.T_STRING)g=g.toString();if(g){this.renderImage(d,g);d.addClass("hasIcon")}if((g=(g=this.getDelegateProperty("contentValueKey",
e))&&c?c.get?c.get(g):c[g]:c)&&SC.typeOf(g)!==SC.T_STRING)g=g.toString();this.renderLabel(d,g||"");if(g=(g=this.getDelegateProperty("contentIsBranchKey",e))&&c?c.get?c.get(g):c[g]:NO){this.renderBranch(d,g);d.addClass("has-branch")}else{(g=(g=this.getDelegateProperty("action",e))&&c?c.get?c.get(g):c[g]:null)&&isNaN(g)&&this.set("action",g);(g=(g=this.getDelegateProperty("target",e))&&c?c.get?c.get(g):c[g]:null)&&isNaN(g)&&this.set("target",g);if(this.getDelegateProperty("shortCutKey",e))if(g=(g=this.getDelegateProperty("shortCutKey",
e))&&c?c.get?c.get(g):c[g]:null){this.renderShortcut(d,g);d.addClass("shortcutkey")}}}d.end();SC.BENCHMARK_MENU_ITEM_RENDER&&SC.Benchmark.end(b)},renderImage:function(a,b){var c;if(b&&SC.ImageView.valueIsUrl(b)){b=b;c=""}else{c=b;b=SC.BLANK_IMAGE_URL}a.begin("img").addClass("image").addClass(c).attr("src",b).end()},renderLabel:function(a,b){a.push("<span class='value ellipsis'>"+b+"</span>")},renderBranch:function(a){a.push('<span class= "hasBranch">></span>')},renderShortcut:function(a,b){a.push('<span class = "shortcut">'+
b+"</span>")},getAnchor:function(){var a=this.get("anchor");if(a&&a.kindOf&&a.kindOf(SC.MenuItemView))return a;return null},isCurrent:NO,isSeparator:function(){var a=this.get("content"),b=this.getDelegateProperty("isSeparatorKey",this.displayDelegate);if(b&&a?a.get?a.get(b):a[b]:null)return YES;return NO},isSubMenuAMenuPane:function(){var a=this.get("content").get("subMenu");if(a&&a.kindOf(SC.MenuPane))return a;return NO},branching:function(){this.get("hasMouseExited")?this.set("hasMouseExited",NO):
this.createSubMenu()},loseFocus:function(){if(!this.isSubMenuAMenuPane()){this.set("hasMouseExited",YES);this.$().removeClass("focus")}},createSubMenu:function(){var a=this.isSubMenuAMenuPane();if(a){a.set("anchor",this);a.popup(this,[0,0,0]);var b=SC.RenderContext(this);b=b.begin(a.get("tagName"));a.prepareContext(b,YES);b.end();(b=a.get("menuItemViews"))&&b.length>0&&a.becomeKeyPane()}},parentMenu:function(){return this.get("parentPane")},isAnchorMouseDown:NO,mouseUp:function(a){var b=this.parentMenu();
if(b)if((b=b.get("currentSelectedMenuItem"))&&this!==b)return b.tryToPerform("mouseUp",a);if(!this.get("isEnabled")){this.set("hasMouseExited",NO);return YES}this.set("hasMouseExited",NO);b=this.get("contentCheckboxKey");var c=this.get("content");if(b){if(c&&c.get(b))c.set(b,NO);else c.get(b)!==undefined&&c.set(b,YES);this.displayDidChange()}this._action(a);(b=this.getAnchor())?b.mouseUp(a):this.resignFirstResponder();this.closeParent();return YES},mouseDown:function(){return YES},mouseEntered:function(){var a=
this.parentMenu();this.set("hasMouseExited",NO);if(a){a.becomeKeyPane();if(a.get("anchor")._isMouseDown){this.set("isAnchorMouseDown",a.getPath("anchor._isMouseDown"));this.get("isAnchorMouseDown")&&SC.Event.trigger(this.get("layer"),"mousedown")}}if(!this.get("isEnabled")&&!this.isSeparator())return YES;if(a=this.get("contentIsBranchKey")){var b=this.get("content");if(a&&b?b.get?b.get(a):b[a]:NO)this.invokeLater(this.branching(),100)}this.becomeFirstResponder();return YES},mouseExited:function(){this.loseFocus();
var a=this.parentMenu();a&&a.set("previousSelectedMenuItem",this);return YES},moveUp:function(){var a=this.parentMenu();a&&a.moveUp(this);return YES},moveDown:function(){var a=this.parentMenu();a&&a.moveDown(this);return YES},moveRight:function(){this.createSubMenu();return YES},keyDown:function(a){return this.interpretKeyEvents(a)},keyUp:function(){return YES},cancel:function(){this.loseFocus();var a=this.parentMenu();a&&a.remove();(a=a.getPath("anchor.pane"))&&a.becomeKeyPane();return YES},didBecomeFirstResponder:function(a){if(a===
this){this.isSeparator()||this.$().addClass("focus");(a=this.parentMenu())&&a.set("currentSelectedMenuItem",this)}},willLoseFirstResponder:function(a){if(a===this){this.$().removeClass("focus");if(a=this.parentMenu()){a.set("currentSelectedMenuItem",null);a.set("previousSelectedMenuItem",this)}}},insertNewline:function(a,b){this.mouseUp(b)},closeParent:function(){this.$().removeClass("focus");var a=this.parentMenu();a&&a.remove()},clickInside:function(a,b){return SC.pointInRect({x:b.pageX,y:b.pageY},
a)}});sc_require("panes/picker");sc_require("views/menu_item");SC.BENCHMARK_MENU_PANE_RENDER=YES;
SC.MenuPane=SC.PickerPane.extend({menuItemKeys:"itemTitleKey itemValueKey itemIsEnabledKey itemIconKey itemSeparatorKey itemActionKey itemCheckboxKey itemShortCutKey itemBranchKey itemHeightKey subMenuKey itemKeyEquivalentKey itemTargetKey".w(),classNames:["sc-menu"],tagName:"div",isModal:YES,itemIsEnabledKey:"isEnabled",itemTitleKey:"title",items:[],itemValueKey:"value",itemIconKey:"icon",itemWidth:null,itemHeight:20,menuHeight:null,itemHeightKey:"height",subMenuKey:"subMenu",localize:YES,itemSeparatorKey:"separator",
itemActionKey:"action",itemCheckboxKey:"checkbox",itemBranchKey:"branchItem",itemShortCutKey:"shortcut",itemKeyEquivalentKey:"keyEquivalent",itemTargetKey:"target",preferType:SC.PICKER_MENU,currentSelectedMenuItem:null,previousSelectedMenuItem:null,anchor:null,displayItemsArray:null,menuItemViews:[],exampleView:SC.MenuItemView,controlSize:SC.REGULAR_CONTROL_SIZE,menuHeightPadding:0,createChildViews:function(){var a,b;a=SC.MenuScrollView;b=this.get("menuItemViews");b=SC.View.design({layout:{top:0,
left:0,minHeight:this.get("menuHeight")},classNames:"menuContainer",childViews:b});this.set("itemWidth",this.get("layout").width||100);a=this.createChildView(a,{borderStyle:SC.BORDER_NONE,contentView:b});this.childViews=[a]},popup:function(a,b){var c=a.isView?a.get("layer"):a;this.beginPropertyChanges();this.get("displayItems");this.set("anchorElement",c);this.set("anchor",a);this.set("preferType",SC.PICKER_MENU);b&&this.set("preferMatrix",b);this.endPropertyChanges();this.positionPane();this.append()},
displayItems:function(){var a=this.get("items"),b=this.get("localize"),c=null,e,g=[],d,f=a.get("length"),h,i,j=SC._menu_fetchKeys,k=SC._menu_fetchItem,l=this.get("menuHeightPadding");for(h=0;h<f;++h){i=a.objectAt(h);if(!SC.none(i)){e=SC.typeOf(i);d=g.length;if(e===SC.T_STRING){g[d]=SC.Object.create({title:i.humanize().titleize(),value:i,isEnabled:YES,icon:null,isSeparator:null,action:null,isCheckbox:NO,menuItemNumber:h,isShortCut:NO,isBranch:NO,itemHeight:this.get("itemHeight"),subMenu:null,keyEquivalent:null,
target:null});l+=this.get("itemHeight")}else if(e!==SC.T_ARRAY){if(c===null)c=this.menuItemKeys.map(j,this);e=c.map(k,i);e[e.length]=h;if(!c[0]&&i.toString)e[0]=i.toString();c[1]||(e[1]=i);c[2]||(e[2]=YES);e[9]||(e[9]=this.get("itemHeight"));if(e[4])e[9]=9;l+=e[9];if(b&&e[0])e[0]=e[0].loc();g[d]=SC.Object.create({title:e[0],value:e[1],isEnabled:e[2],icon:e[3],isSeparator:e[4]||NO,action:e[5],isCheckbox:e[6],isShortCut:e[7],menuItemNumber:h,isBranch:e[8],itemHeight:e[9],subMenu:e[10],keyEquivalent:e[11],
target:e[12]})}}}this.set("menuHeight",l);this.set("displayItemsArray",g);this.generateMenuItems(g);return g}.property("items").cacheable(),itemsDidChange:function(){this._items&&this._items.removeObserver("[]",this,this.itemContentDidChange);(this._items=this.get("items"))&&this._items.addObserver("[]",this,this.itemContentDidChange);this.itemContentDidChange()}.observes("items"),itemContentDidChange:function(){this.notifyPropertyChange("displayItems")},displayProperties:["displayItems","value",
"controlSize"],render:function(a,b){if(SC.BENCHMARK_MENU_PANE_RENDER){var c="%@.render".fmt(this);SC.Benchmark.start(c)}arguments.callee.base.apply(this,arguments);if(b){if(!this.get("isEnabled"))return;a.addStyle("text-align","center")}SC.BENCHMARK_MENU_PANE_RENDER&&SC.Benchmark.end(c)},menuHeightObserver:function(){var a=this.layout.height,b=this.get("menuHeight");a!==b&&this.adjust("height",b).updateLayout()}.observes("menuHeight"),generateMenuItems:function(a){if(this.get("isEnabled")){var b,
c,e,g,d,f,h=[],i,j;i=a.length;SC.makeArray(a);for(j=0;j<i;++j){b=a[j];c=b.get("action");e=b.get("menuItemNumber");d=b.get("itemHeight");f=this.get("itemWidth");g=this.createChildView(this.exampleView,{owner:g,displayDelegate:g,parentPane:this,anchor:this.get("anchor"),isVisible:YES,contentValueKey:"title",contentIconKey:"icon",contentCheckboxKey:this.itemCheckboxKey,contentIsBranchKey:"branchItem",isSeparatorKey:"separator",shortCutKey:"shortCut",action:c,target:b.get("target"),layout:{top:0,left:0,
width:f,height:d},isEnabled:b.get("isEnabled"),itemHeight:d,itemWidth:f,keyEquivalent:b.get("keyEquivalent"),controlSize:this.get("controlSize"),content:SC.Object.create({title:b.get("title"),value:b.get("value"),icon:b.get("icon"),separator:b.get("isSeparator"),action:c,checkbox:b.get("isCheckbox"),shortCut:b.get("isShortCut"),branchItem:b.get("isBranch"),subMenu:b.get("subMenu")}),rootElementPath:[e]});h.push(g)}a=this.childViews[0].contentView;a.replaceAllChildren(h);a.adjust("minHeight",this.get("menuHeight"));
this.set("menuItemViews",h)}},previousSelectedMenuItemObserver:function(){var a=this.get("previousSelectedMenuItem");if(a)(a=a.isSubMenuAMenuPane())&&a.remove()}.observes("previousSelectedMenuItem"),isAnchorMenuItemType:function(){var a=this.get("anchor");return a&&a.kindOf&&a.kindOf(SC.MenuItemView)},performKeyEquivalent:function(a){var b,c,e,g,d,f,h;if(!this.get("isEnabled"))return NO;this.displayItems();b=this.get("displayItemsArray");if(!b)return NO;if(a==="escape"){this.remove();(c=this.getPath("anchor.pane"))&&
c.becomeKeyPane()}c=b.length;for(h=0;h<c;++h){e=b[h];g=e.get("keyEquivalent");d=e.get("action");f=e.get("isEnabled");e=e.get("target")||this;if(g==a&&f){a=SC.RootResponder.responder.sendAction(d,e);this.remove();return a}}return NO},mouseDown:function(){return YES},mouseUp:function(a){this.remove();var b=this.get("anchor");this.isAnchorMenuItemType()&&this.sendEvent("mouseUp",a,b);return YES},moveDown:function(a){var b=this.getNextEnabledMenuItem(a);a&&a.resignFirstResponder();b.becomeFirstResponder()},
moveUp:function(a){var b=this.getPreviousEnabledMenuItem(a);a&&a.resignFirstResponder();b.becomeFirstResponder();return YES},getPreviousEnabledMenuItem:function(a){var b,c=this.get("menuItemViews");if(c){for(var e=c.length,g=c.indexOf(a)===-1?e:c.indexOf(a),d=g,f=NO,h=NO;(!f||h)&&--g!==d;){if(g===-1)g=e-1;b=c[g];f=b.get("isEnabled");if(a=b.get("content"))h=a.get(b.get("isSeparatorKey"))}return c[g]}},getNextEnabledMenuItem:function(a){var b,c=this.get("menuItemViews");if(c){for(var e=c.length,g=c.indexOf(a)===
-1?0:c.indexOf(a),d=g,f=NO,h=NO;(!f||h)&&++g!==d;){if(g===e)g=0;b=c[g];f=b.get("isEnabled");if(a=b.get("content"))h=a.get(b.get("isSeparatorKey"))}return c[g]}},modalPaneDidClick:function(a){var b,c=this.get("frame");if(b=this.get("currentSelectedMenuItem"))if(b=b.getAnchor()){b=b.parentMenu();b.kindOf(SC.MenuPane)&&b.modalPaneDidClick(a)}this.clickInside(c,a)||this.remove();return YES},getMenuItem:function(a,b){var c,e;c=this.get("displayItemsArray");e=this.get("menuItemViews");if(c&&e){a=c.get(a).indexOf(b);
return a!==-1?e[a]:null}else return null}});SC._menu_fetchKeys=function(a){return this.get(a)};SC._menu_fetchItem=function(a){if(!a)return null;return this.get?this.get(a):this[a]};sc_require("views/button");
SC.SelectButtonView=SC.ButtonView.extend({objects:[],objectsBindingDefault:SC.Binding.multiple(),nameKey:null,sortKey:null,valueKey:null,iconKey:null,localize:YES,disableSort:YES,classNames:["select-button"],itemList:[],currentSelItem:null,itemIdx:null,value:null,checkboxEnabled:YES,separatorPostion:null,_defaultVal:null,_defaultTitle:null,_defaultIcon:null,theme:"popup",displayProperties:["icon","value","controlSize","objects"],preferMatrix:null,SELECT_BUTTON_SPRITE_WIDTH:28,CUSTOM_MENU_ITEM_HEIGHT:20,
isSelectedBinding:"*menu.isVisibleInWindow",isDefaultPosition:NO,lastMenuWidth:null,customView:null,needsEllipsis:YES,menuPaneHeightPadding:0,leftAlign:function(){var a=0,b=this.get("controlSize");if(b===SC.SMALL_CONTROL_SIZE)a=-14;if(b===SC.REGULAR_CONTROL_SIZE)a=-16;return a}.property("controlSize"),sortObjects:function(a){if(!this.get("disableSort")){var b=this.get("sortKey")||this.get("nameKey");a=a.sort(function(c,e){if(b){c=c.get?c.get(b):c[b];e=e.get?e.get(b):e[b]}return c<e?-1:c>e?1:0})}return a},
render:function(a,b){arguments.callee.base.apply(this,arguments);var c=this.layout.width;b&&c&&this.adjust({width:c-this.SELECT_BUTTON_SPRITE_WIDTH});c=this.get("objects");c=this.sortObjects(c);var e=c.length,g=this.get("nameKey"),d=this.get("iconKey"),f=this.get("valueKey"),h=this.get("checkboxEnabled"),i=this.get("value"),j=this.get("localize"),k=this.get("separatorPostion"),l=[],o=YES,n=0;c.forEach(function(r){if(r){var p=g?r.get?r.get(g):r[g]:r.toString();p=j?p.loc():p;var m=d?r.get?r.get(d):
r[d]:null;if(SC.none(r[d]))m=null;r=f?r.get?r.get(f):r[f]:r;if(!SC.none(i)&&!SC.none(r))if(i===r){this.set("title",p);this.set("icon",m)}if(r===this.get("value")){this.set("itemIdx",n);o=!h?NO:YES}else o=NO;if(n===0){this._defaultVal=r;this._defaultTitle=p;this._defaultIcon=m}p=SC.Object.create({title:p,icon:m,value:r,isEnabled:YES,checkbox:o,action:this.displaySelectedItem});l.push(p)}n+=1;if(k&&n===e-k){p=SC.Object.create({separator:YES});l.push(p)}this.set("itemList",l)},this);if(b){c=this.get("value");
if(SC.none(c)){this.set("value",this._defaultVal);this.set("title",this._defaultTitle);this.set("icon",this._defaultIcon)}}this.changeSelectButtonPreferMatrix(this.itemIdx)},_action:function(){var a=this.$(".sc-button-label")[0],b=this.get("layer").offsetWidth,c=a.scrollWidth,e=this.get("lastMenuWidth");if(c){a=a.offsetWidth;if(c&&a)b=b+c-a}if(!e||b>e)e=b;b=this.get("itemList");var g,d;for(c=0;c<b.length;++c){g=b.objectAt(c);a=document.createElement("div");a.style.cssText="top:-10000px; left: -10000px;  position: absolute;";
a.className="sc-view sc-pane sc-panel sc-palette sc-picker sc-menu select-button sc-scroll-view sc-menu-scroll-view sc-container-view menuContainer sc-button-view sc-menu-item sc-regular-size";a.innerHTML=g.title;document.body.appendChild(a);g=a.offsetWidth;if(!d||g>d)d=g;document.body.removeChild(a)}e=d>e?d:e;this.set("lastMenuWidth",e);d=this.get("currentSelItem");b=this.get("itemList");c=this.get("controlSize");a=this.get("menuPaneHeightPadding");g=this.get("customView");e=SC.MenuPane.create({classNames:["select-button"],
items:b,exampleView:g?g:SC.MenuItemView,isEnabled:YES,menuHeightPadding:a,preferType:SC.PICKER_MENU,itemHeightKey:"height",layout:{width:e},controlSize:c,itemWidth:e,contentView:SC.View.extend({})});if(!e)return NO;e.popup(this,this.preferMatrix);e.set("currentSelectedMenuItem",d);return YES},displaySelectedItem:function(){var a=this.parentMenu(),b=a.get("currentSelectedMenuItem"),c=a.menuItemViews,e,g=0;if(b&&c)g=c.indexOf(b);c=a.get("anchor");for(var d=a.get("items"),f=d.length,h=null;!h&&--f>=
0;){a=!SC.none(d[f].title)?d[f].title:d.toString();e=!SC.none(d[f].value)?d[f].value:a;if(a===this.get("value")&&g===f){h=d;c.set("value",e);c.set("title",a)}}c.set("icon",this.get("icon")).set("currentSelItem",b).set("itemIdx",g)},changeSelectButtonPreferMatrix:function(){var a=0,b=this.get("itemIdx"),c=this.get("leftAlign");if(this.get("isDefaultPosition")){a=[c,4,3];this.set("preferMatrix",a)}else{if(b)a=b*this.CUSTOM_MENU_ITEM_HEIGHT;a=[c,-a,2];this.set("preferMatrix",a)}},mouseDown:function(){if(!this.get("isEnabled"))return YES;
this.set("isActive",YES);this._isMouseDown=YES;this.becomeFirstResponder();this._action();return YES},keyDown:function(a){if(this.interpretKeyEvents(a))return YES;else arguments.callee.base.apply(this,arguments)},interpretKeyEvents:function(a){if(a)if(a.keyCode===38||a.keyCode===40)this._action();else a.keyCode===27&&this.resignFirstResponder();return arguments.callee.base.apply(this,arguments)}});sc_require("panes/panel");
SC.SheetPane=SC.PanelPane.extend({classNames:"sc-sheet",transitionDuration:200,_state:"NO_VIEW",_openLayout:{top:0,left:0,bottom:0,right:0},_anchoredLayout:{top:0,left:0,width:0,height:0},NO_VIEW:"NO_VIEW",ANIMATING:"ANIMATING",READY:"READY",SLIDE_DOWN:"SLIDEDOWN",SLIDE_UP:"SLIDEUP",BLIND_DOWN:"BLINDDOWN",BLIND_UP:"BLINDUP",STANDARD_LAYOUT:{top:0,left:0,bottom:0,right:0},OFFSCREEN_LAYOUT:{top:0,height:0},init:function(){arguments.callee.base.apply(this,arguments);this._openLayout=this.get("layout");
var a=this.computeParentDimensions();this._anchoredLayout=SC.View.convertLayoutToAnchoredLayout(this._openLayout,a);this.set("layout",SC.merge(this._anchoredLayout,this.OFFSCREEN_LAYOUT))},replaceContent:function(){arguments.callee.base.apply(this,arguments);this._anchoredLayout=SC.View.convertLayoutToAnchoredLayout(this._openLayout,this.computeParentDimensions());this.set("layout",SC.merge(this._anchoredLayout,this.OFFSCREEN_LAYOUT));this.slideDown()},slideDown:function(){this.append();this._start=
Date.now();this._end=this._start+this.get("transitionDuration");this._state=this.ANIMATING;this._direction=this.SLIDE_DOWN;this.tick()},slideUp:function(){this._start=Date.now();this._end=this._start+this.get("transitionDuration");this._state=this.ANIMATING;this._direction=this.SLIDE_UP;this.tick()},blindDown:function(){this.append();this._start=Date.now();this._end=this._start+this.get("transitionDuration");this._state=this.ANIMATING;this._direction=this.BLIND_DOWN;this.tick()},blindUp:function(){this._start=
Date.now();this._end=this._start+this.get("transitionDuration");this._state=this.ANIMATING;this._direction=this.BLIND_UP;this.tick()},blurTo:function(){this.setFirstResponder("")},tick:function(){this._timer=null;var a=this,b=(Date.now()-this._start)/(this._end-this._start),c=this._direction,e;if(b<0)b=0;if(!this.get("isVisibleInWindow")){e=SC.View.convertLayoutToAnchoredLayout(this._openLayout,this.computeParentDimensions());a.adjust(SC.merge(e,this.OFFSCREEN_LAYOUT));this.updateLayout()}if(b>=1){if(c===
this.SLIDE_DOWN||c==this.BLIND_DOWN){a.adjust(this._openLayout);this.awake()}else{e=SC.View.convertLayoutToAnchoredLayout(this._openLayout,this.computeParentDimensions());a.adjust(SC.merge(e,this.OFFSCREEN_LAYOUT));this.remove()}this._state=this.READY;this.updateLayout();return this}e=SC.clone(this.get("layout"));b=Math.floor(this._anchoredLayout.height*b);var g=YES;if(c==this.SLIDE_DOWN){e.height=this._anchoredLayout.height;e.top=0-(e.height-b);a.adjust(e)}else if(c==this.SLIDE_UP){e.height=this._anchoredLayout.height;
e.top=0-b;a.adjust(e)}else if(c==this.BLIND_DOWN){e.top=this._anchoredLayout.top;e.height=b;a.adjust(e)}else if(c==this.BLIND_UP){e.top=this._anchoredLayout.top;e.height=this._anchoredLayout.height-b;a.adjust(e)}else{a.adjust(this._openlayout);g=NO}this.updateLayout();this._timer=g?this.invokeLater(this.tick,20):null;return this}});SC.DRAG_LINK=4;SC.DRAG_COPY=1;SC.DRAG_MOVE=2;SC.DRAG_NONE=0;SC.DRAG_ANY=7;SC.DRAG_AUTOSCROLL_ZONE_THICKNESS=20;
SC.Drag=SC.Object.extend({source:null,ghostView:null,ghostActsLikeCursor:NO,dragView:null,ghost:YES,slideBack:YES,mouseDownEvent:null,ghostOffset:{x:0,y:0},location:{},dataTypes:function(){if(this.dataSource)return this.dataSource.get("dragDataTypes")||[];var a=this.data;if(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b}if((a=this.get("source"))&&a.dragDataTypes)return a.get("dragDataTypes")||[];return[]}.property().cacheable(),hasDataType:function(a){return this.get("dataTypes").indexOf(a)>=
0},dataForType:function(a){if(this.dataSource)return this.dataSource.dragDataForType(this,a);else if(this.data)return this.data[a];else{var b=this.get("source");return b&&SC.typeOf(b.dragDataForType)==SC.T_FUNCTION?b.dragDataForType(this,a):null}},dataSource:null,data:null,allowedDragOperations:SC.DRAG_ANY,_dragInProgress:YES,startDrag:function(){this._createGhostView();var a=this.event,b={x:a.pageX,y:a.pageY};this.set("location",b);var c=this.dragView,e=c.get("pane"),g=c.get("parentView");c.get("clippingFrame");
g=g?g.convertFrameToView(c.get("frame"),null):c.get("frame");e=e?e.get("frame"):{x:0,y:0};c.adjust({top:g.y+e.y,left:g.x+e.x,width:g.width,height:g.height});c.get("frame");this.ghostOffset=this.ghostActsLikeCursor?{x:14,y:14}:{x:b.x-g.x,y:b.y-g.y};this._ghostViewHidden||this._positionGhostView(a);this.ghostView.rootResponder.dragDidStart(this);(c=this.source)&&c.dragDidBegin&&c.dragDidBegin(this,b);b=this._dropTargets();c=0;for(e=b.length;c<e;c++)b[c].tryToPerform("dragStarted",this,a)},mouseDragged:function(a){var b=
this._autoscroll(a),c=this.get("location");if(!(!b&&a.pageX==c.x&&a.pageY==c.y)){c={x:a.pageX,y:a.pageY};this.set("location",c);b=this.source;for(var e=this._lastTarget,g=this._findDropTarget(a),d=SC.DRAG_NONE;g&&g!=e&&d==SC.DRAG_NONE;){d=g&&b&&b.dragSourceOperationMaskFor?b.dragSourceOperationMaskFor(this,g):SC.DRAG_ANY;if(d!=SC.DRAG_NONE&&g&&g.computeDragOperations)d&=g.computeDragOperations(this,a,d);else d=SC.DRAG_NONE;this.allowedDragOperations=d;if(d==SC.DRAG_NONE)g=this._findNextDropTarget(g)}if(g!=
e){e&&e.dragExited&&e.dragExited(this,a);if(g){g.dragEntered&&g.dragEntered(this,a);g.dragUpdated&&g.dragUpdated(this,a)}this._lastTarget=g}else g&&g.dragUpdated&&g.dragUpdated(this,a);b&&b.dragDidMove&&b.dragDidMove(this,c);this._ghostViewHidden||this._positionGhostView(a)}},mouseUp:function(a){var b={x:a.pageX,y:a.pageY},c=this._lastTarget,e=this.allowedDragOperations;this.set("location",b);try{e=c&&c.acceptDragOperation&&c.acceptDragOperation(this,e)?c.performDragOperation?c.performDragOperation(this,
e):SC.DRAG_NONE:SC.DRAG_NONE}catch(g){console.error("Exception in SC.Drag.mouseUp(acceptDragOperation|performDragOperation): %@".fmt(g))}try{c&&c.dragExited&&c.dragExited(this,a)}catch(d){console.error("Exception in SC.Drag.mouseUp(target.dragExited): %@".fmt(d))}c=this._dropTargets();for(var f=0,h=c.length;f<h;f++)try{c[f].tryToPerform("dragEnded",this,a)}catch(i){console.error("Exception in SC.Drag.mouseUp(dragEnded on %@): %@".fmt(c[f],i))}this._destroyGhostView();(a=this.source)&&a.dragDidEnd&&
a.dragDidEnd(this,b,e);this._lastTarget=null;this._dragInProgress=NO},_createGhostView:function(){var a=this,b=this.dragView.get("frame");(this.ghostView=SC.Pane.create({classNames:["sc-ghost-view"],layout:{top:b.y,left:b.x,width:b.width,height:b.height},owner:this,didCreateLayer:function(){if(a.dragView){var c=a.dragView.get("layer");c&&this.get("layer").appendChild(c.cloneNode(true))}}})).append()},_positionGhostView:function(){var a=this.get("location");a.x-=this.ghostOffset.x;a.y-=this.ghostOffset.y;
var b=this.ghostView;if(b){b.adjust({top:a.y,left:a.x});b.invokeOnce("updateLayout")}},_ghostViewHidden:NO,hideGhostView:function(){if(this.ghostView&&!this._ghostViewHidden){this.ghostView.remove();this._ghostViewHidden=YES}},unhideGhostView:function(){if(this._ghostViewHidden){this._ghostViewHidden=NO;this._createGhostView()}},_destroyGhostView:function(){if(this.ghostView){this.ghostView.remove();this.ghostView=null;this._ghostViewHidden=NO}},_dropTargets:function(){if(this._cachedDropTargets)return this._cachedDropTargets;
var a=[],b=SC.Drag._dropTargets;for(var c in b)b.hasOwnProperty(c)&&a.push(b[c]);var e={},g=SC.Drag._dropTargets,d=function(f){if(!f)return 0;var h=SC.guidFor(f),i=e[h];if(!i){for(i=1;f=f.get("parentView");)g[SC.guidFor(f)]!==undefined&&i++;e[h]=i}return i};a.sort(function(f,h){if(f===h)return 0;f=d(f);h=d(h);return f>h?-1:1});return this._cachedDropTargets=a},_findDropTarget:function(a){a={x:a.pageX,y:a.pageY};for(var b,c,e=this._dropTargets(),g=0,d=e.length;g<d;g++){b=e[g];if(b.get("isVisibleInWindow")){c=
b.convertFrameToView(b.get("clippingFrame"),null);if(SC.pointInRect(a,c))return b}}return null},_findNextDropTarget:function(a){for(var b=SC.Drag._dropTargets;a=a.get("parentView");)if(b[SC.guidFor(a)])return a;return null},_autoscroll:function(a){if(!a)a=this._lastAutoscrollEvent;if(!this._dragInProgress)return NO;for(var b=a?{x:a.pageX,y:a.pageY}:this.get("location"),c=this._findScrollableView(b),e=null,g,d,f,h,i;c&&!e;){g=c.get("canScrollVertical")?1:0;d=c.get("canScrollHorizontal")?1:0;if(g||
d)if(f=c.get("containerView"))i=c.convertFrameToView(f.get("frame"),null);else g=d=0;if(g){h=SC.maxY(i);f=h-SC.DRAG_AUTOSCROLL_ZONE_THICKNESS;if(b.y>=f&&b.y<=h)g=1;else{f=SC.minY(i);h=f+SC.DRAG_AUTOSCROLL_ZONE_THICKNESS;g=b.y>=f&&b.y<=h?-1:0}}if(d){h=SC.maxX(i);f=h-SC.DRAG_AUTOSCROLL_ZONE_THICKNESS;if(b.x>=f&&b.x<=h)d=1;else{f=SC.minX(i);h=f+SC.DRAG_AUTOSCROLL_ZONE_THICKNESS;d=b.x>=f&&b.x<=h?-1:0}}if(g||d)e=c;else c=this._findNextScrollableView(c)}if(e&&this._lastScrollableView===e){if(Date.now()-
this._hotzoneStartTime>100){this._horizontalScrollAmount*=1.05;this._verticalScrollAmount*=1.05}}else{this._lastScrollableView=e;this._verticalScrollAmount=this._horizontalScrollAmount=15;this._hotzoneStartTime=e?Date.now():null;d=g=0}if(e&&(d||g))e.scrollBy({x:d*this._horizontalScrollAmount,y:g*this._verticalScrollAmount});if(e){if(a)this._lastAutoscrollEvent={pageX:a.pageX,pageY:a.pageY};this.invokeLater(this._autoscroll,100,null);return YES}else{this._lastAutoscrollEvent=null;return NO}},_scrollableViews:function(){if(this._cachedScrollableView)return this._cachedScrollableView;
var a=[],b=SC.Drag._scrollableViews;for(var c in b)b.hasOwnProperty(c)&&a.push(b[c]);return this._cachedScrollableView=a=a.sort(function(e,g){for(e=e;e=e.get("parentView");)if(g==e)return-1;return 1})},_findScrollableView:function(a){var b=this._scrollableViews(),c=b?b.length:0,e,g,d;for(d=0;d<c;d++){e=b[d];if(e.get("isVisibleInWindow")){g=e.convertFrameToView(e.get("clippingFrame"),null);if(SC.pointInRect(a,g))return e}}return null},_findNextScrollableView:function(a){for(var b=SC.Drag._scrollableViews;a=
a.get("parentView");)if(b[SC.guidFor(a)])return a;return null}});SC.Drag.mixin({start:function(a){a=this.create(a);a.startDrag();return a},_dropTargets:{},_scrollableViews:{},addDropTarget:function(a){this._dropTargets[SC.guidFor(a)]=a},removeDropTarget:function(a){delete this._dropTargets[SC.guidFor(a)]},addScrollableView:function(a){this._scrollableViews[SC.guidFor(a)]=a},removeScrollableView:function(a){delete this._scrollableViews[SC.guidFor(a)]}});
SC.MODIFIED_KEY_BINDINGS={"ctrl_.":"cancel",shift_tab:"insertBacktab",shift_left:"moveLeftAndModifySelection",shift_right:"moveRightAndModifySelection",shift_up:"moveUpAndModifySelection",shift_down:"moveDownAndModifySelection",alt_left:"moveLeftAndModifySelection",alt_right:"moveRightAndModifySelection",alt_up:"moveUpAndModifySelection",alt_down:"moveDownAndModifySelection",ctrl_a:"selectAll"};
SC.BASE_KEY_BINDINGS={escape:"cancel",backspace:"deleteBackward","delete":"deleteForward","return":"insertNewline",tab:"insertTab",left:"moveLeft",right:"moveRight",up:"moveUp",down:"moveDown",home:"moveToBeginningOfDocument",end:"moveToEndOfDocument",pagedown:"pageDown",pageup:"pageUp"};SC.CAPTURE_BACKSPACE_KEY=NO;SC.PANEL_ORDER_LAYER=4096;SC.PALETTE_ORDER_LAYER=8192;SC.POPUP_ORDER_LAYER=12288;
SC.RootResponder=SC.RootResponder.extend({platform:"desktop",focusedPane:function(){var a=this.get("orderedPanes");return a[a.length-1]}.property("orderedPanes"),orderedPanes:null,orderBefore:function(a,b){var c=this.get("focusedPane"),e=this.get("orderedPanes").without(a),g,d,f,h=a.get("orderLayer");if(b){g=e.length;d=e.indexOf(b);f=b.get("orderLayer");if(f<h){for(;b.get("orderLayer")<h&&++d<g;)b=e[d];if(d>=g)b=null}else if(f>h){for(;b.get("orderLayer")>h&&--d>=0;)b=e[d];b=d<0?e[0]:e[d+1]}}else{for(d=
e.length;--d>=0&&!b;){b=e[d];if(b.get("orderLayer")>h)b=null}b=d<0?e[0]:e[d+1]}if(b){d=e.indexOf(b);e.insertAt(d,a)}else e.push(a);this.set("orderedPanes",e);a=this.get("focusedPane");if(a!==c){c&&c.blurTo(a);a&&a.focusFrom(c)}return this},orderOut:function(a){var b=this.get("focusedPane"),c=this.get("keyPane");this.set("orderedPanes",this.get("orderedPanes").without(a));if(b===a){var e=this.get("focusedPane");b&&b.blurTo(e);e&&e.focusFrom(b);c===a&&this.makeKeyPane(e)}else c===a&&this.makeKeyPane(null);
return this},init:function(){arguments.callee.base.apply(this,arguments);this.orderedPanes=[]},setup:function(){this.listenFor("keydown keyup mousedown mouseup click dblclick mouseout mouseover mousemove selectstart".w(),document).listenFor("resize focus blur".w(),window);if(this.keypress)if(SC.CAPTURE_BACKSPACE_KEY&&SC.browser.mozilla){var a=this;document.onkeypress=function(b){b=SC.Event.normalizeEvent(b);return a.keypress.call(a,b)};SC.Event.add(window,"unload",this,function(){document.onkeypress=
null})}else SC.Event.add(document,"keypress",this,this.keypress);"drag selectstart".w().forEach(function(b){var c=this[b];if(c)if(SC.browser.msie){var e=this;document.body["on"+b]=function(){return c.call(e,SC.Event.normalizeEvent(event||window.event))};SC.Event.add(window,"unload",this,function(){document.body["on"+b]=null})}else SC.Event.add(document,b,this,c)},this);SC.Event.add(document,SC.browser.mozilla?"DOMMouseScroll":"mousewheel",this,this.mousewheel);this.set("currentWindowSize",this.computeWindowSize());
this.focus()},attemptKeyEquivalent:function(a){var b=null,c=a.commandCodes()[0];if(!c)return NO;var e=this.get("keyPane"),g=this.get("mainPane"),d=this.get("mainMenu");if(e)b=e.performKeyEquivalent(c,a);if(!b&&g&&g!==e)b=g.performKeyEquivalent(c,a);if(!b&&d)b=d.performKeyEquivalent(c,a);return b},currentWindowSize:null,computeWindowSize:function(){var a;if(window.innerHeight)a={width:window.innerWidth,height:window.innerHeight};else if(document.documentElement&&document.documentElement.clientHeight)a=
{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight};else if(document.body)a={width:document.body.clientWidth,height:document.body.clientHeight};return a},resize:function(){this._resize();return YES},_resize:function(){var a=this.computeWindowSize(),b=this.get("currentWindowSize");this.set("currentWindowSize",a);if(!SC.rectsEqual(a,b))if(this.panes){SC.RunLoop.begin();this.panes.invoke("windowSizeDidChange",b,a);SC.RunLoop.end()}},hasFocus:NO,focus:function(){if(!this.get("hasFocus")){SC.$("body").addClass("sc-focus").removeClass("sc-blur");
SC.RunLoop.begin();this.set("hasFocus",YES);SC.RunLoop.end()}return YES},blur:function(){if(this.get("hasFocus")){SC.$("body").addClass("sc-blur").removeClass("sc-focus");SC.RunLoop.begin();this.set("hasFocus",NO);SC.RunLoop.end()}return YES},dragDidStart:function(a){this._drag=this._mouseDownView=a},_lastModifiers:null,_handleModifierChanges:function(a){var b;b=this._lastModifiers=this._lastModifiers||{alt:false,ctrl:false,shift:false};var c=false;if(a.altKey!==b.alt){b.alt=a.altKey;c=true}if(a.ctrlKey!==
b.ctrl){b.ctrl=a.ctrlKey;c=true}if(a.shiftKey!==b.shift){b.shift=a.shiftKey;c=true}a.modifiers=b;return c?this.sendEvent("flagsChanged",a)?a.hasCustomEventHandling:YES:YES},_isFunctionOrNonPrintableKey:function(a){return!!(a.altKey||a.ctrlKey||a.metaKey||a.charCode!==a.which&&SC.FUNCTION_KEYS[a.which])},_isModifierKey:function(a){return!!SC.MODIFIER_KEYS[a.charCode]},keydown:function(a){if(a.kindOf)a=this._ffevt;else this._ffevt=null;if(SC.none(a))return YES;if(SC.browser.mozilla&&a.which===8)return true;
var b=this._handleModifierChanges(a),c=a.target||a.srcElement;c=a.which===8&&!SC.allowsBackspaceToPreviousPage&&c===document.body;if(this._isModifierKey(a))return c?NO:b;b=YES;if(this._isFunctionOrNonPrintableKey(a)){if(SC.browser.mozilla&&a.keyCode>=37&&a.keyCode<=40){this._ffevt=a;SC.RunLoop.begin();this.invokeLater(this.keydown,100);SC.RunLoop.end()}if(b=this.sendEvent("keyDown",a)){if(b=a.hasCustomEventHandling)c=NO}else b=!this.attemptKeyEquivalent(a)}return c?NO:b},keypress:function(a){var b;
if(SC.browser.mozilla&&a.which===8)return(b=this.sendEvent("keyDown",a))?SC.allowsBackspaceToPreviousPage||a.hasCustomEventHandling:YES;else{if(a.charCode!==undefined&&a.charCode===0)return YES;return this.sendEvent("keyDown",a)?a.hasCustomEventHandling:YES}},keyup:function(a){if(this._ffevt)this._ffevt=null;var b=this._handleModifierChanges(a);if(this._isModifierKey(a))return b;return this.sendEvent("keyUp",a)?a.hasCustomEventHandling:YES},mousedown:function(a){try{this.focus();if(SC.browser.msie){this._lastMouseDownX=
a.clientX;this._lastMouseDownY=a.clientY}this._clickCount+=1;if(!this._lastMouseUpAt||Date.now()-this._lastMouseUpAt>200)this._clickCount=1;a.clickCount=this._clickCount;var b,c=this.targetViewForEvent(a);if(c)b=c.get("pane").get("firstResponder");b&&b.kindOf(SC.InlineTextFieldView)&&b!==c&&b.resignFirstResponder();if((c=this._mouseDownView=this.sendEvent("mouseDown",a,c))&&c.respondsTo("mouseDragged"))this._mouseCanDrag=YES}catch(e){console.warn("Exception during mousedown: %@".fmt(e));this._mouseDownView=
null;this._mouseCanDrag=NO;throw e;}return c?a.hasCustomEventHandling:YES},mouseup:function(a){try{if(this._drag){this._drag.tryToPerform("mouseUp",a);this._drag=null}var b=null,c=this._mouseDownView;this._lastMouseUpAt=Date.now();a.clickCount=this._clickCount;if(c){b=this.sendEvent("mouseUp",a,c);if(!b&&this._clickCount===2)b=this.sendEvent("doubleClick",a,c);b||(b=this.sendEvent("click",a,c))}if(!b){c=this.targetViewForEvent(a);if(this._clickCount===2)b=this.sendEvent("doubleClick",a,c);b||(b=this.sendEvent("click",
a,c))}this._mouseCanDrag=NO;this._mouseDownView=null}catch(e){this._drag=null;this._mouseCanDrag=NO;this._mouseDownView=null;throw e;}return b?a.hasCustomEventHandling:YES},dblclick:function(a){if(SC.browser.isIE){this._clickCount=2;this.mouseup(a)}},mousewheel:function(a){try{var b=this.targetViewForEvent(a),c=this.sendEvent("mouseWheel",a,b)}catch(e){throw e;}return c?a.hasCustomEventHandling:YES},_lastHovered:null,mousemove:function(a){if(SC.browser.msie)if(this._lastMoveX===a.clientX&&this._lastMoveY===
a.clientY)return;else{this._lastMoveX=a.clientX;this._lastMoveY=a.clientY}SC.RunLoop.begin();try{this.focus();if(this._drag)if(SC.browser.msie)this._lastMouseDownX!==a.clientX&&this._lastMouseDownY!==a.clientY&&this._drag.tryToPerform("mouseDragged",a);else this._drag.tryToPerform("mouseDragged",a);else{for(var b=this._lastHovered||[],c=[],e,g,d,f=this.targetViewForEvent(a);f&&f!==this;){b.indexOf(f)!==-1?f.tryToPerform("mouseMoved",a):f.tryToPerform("mouseEntered",a);c.push(f);f=f.get("nextResponder")}g=
0;for(d=b.length;g<d;g++){f=b[g];(e=f.respondsTo("mouseExited"))&&c.indexOf(f)===-1&&f.tryToPerform("mouseExited",a)}this._lastHovered=c;if(this._mouseDownView)if(SC.browser.msie)this._lastMouseDownX!==a.clientX&&this._lastMouseDownY!==a.clientY&&this._mouseDownView.tryToPerform("mouseDragged",a);else this._mouseDownView.tryToPerform("mouseDragged",a)}}catch(h){throw h;}SC.RunLoop.end()},_mouseCanDrag:YES,selectstart:function(a){return(this.sendEvent("selectStart",a,this.targetViewForEvent(a))!==
null?YES:NO)&&(this._mouseCanDrag?NO:YES)},drag:function(){return false}});sc_require("core");
SC.UndoManager=SC.Object.extend({undoActionName:function(){return this.undoStack?this.undoStack.name:null}.property("undoStack"),redoActionName:function(){return this.redoStack?this.redoStack.name:null}.property("redoStack"),canUndo:function(){return this.undoStack!=null}.property("undoStack"),canRedo:function(){return this.redoStack!=null}.property("redoStack"),undo:function(){this._undoOrRedo("undoStack","isUndoing")},redo:function(){this._undoOrRedo("redoStack","isRedoing")},isUndoing:false,isRedoing:false,
groupingLevel:0,registerUndo:function(a,b){this.beginUndoGroup(b);this._activeGroup.actions.push(a);this.endUndoGroup(b)},beginUndoGroup:function(a){if(this._activeGroup)this.groupingLevel++;else{var b=this.isUndoing?"redoStack":"undoStack";this._activeGroup={name:a,actions:[],prev:this.get(b)};this.set(b,this._activeGroup);this.groupingLevel=1}},endUndoGroup:function(){this._activeGroup||raise("endUndoGroup() called outside group.");if(this.groupingLevel>1)this.groupingLevel--;else{this._activeGroup=
null;this.groupingLevel=0}this.propertyDidChange(this.isUndoing?"redoStack":"undoStack")},setActionName:function(a){this._activeGroup||raise("setActionName() called outside group.");this._activeGroup.name=a},_activeGroup:null,undoStack:null,redoStack:null,_undoOrRedo:function(a,b){if(this._activeGroup)return false;if(this.get(a)==null)return true;this.set(b,true);var c=this.get(a);this.set(a,c.prev);var e=c.actions.length>1;for(e&&this.beginUndoGroup(c.name);a=c.actions.pop();)a();e&&this.endUndoGroup(c.name);
this.set(b,false)}});
SC.CheckboxView=SC.FieldView.extend(SC.StaticLayout,SC.Button,{classNames:["sc-checkbox-view"],tagName:"label",needsEllipsis:NO,render:function(a,b){if(b){b=this._field_currentDisplayTitle=this.get("displayTitle");var c=this.get("isEnabled")?"":'disabled="disabled"';SC.browser.msie&&a.attr("for",SC.guidFor(this));a.push('<span class="button" ></span>');a.push('<input type="checkbox" id="%@" name="%@" %@ />'.fmt(SC.guidFor(this),SC.guidFor(this),c));this.get("needsEllipsis")?a.push('<span class="label ellipsis">',b,
"</span>"):a.push('<span class="label">',b,"</span>");a.attr("name",SC.guidFor(this))}else{if(a=this.$input()[0])a.disabled=this.get("isEnabled")?NO:YES;b=this.get("displayTitle");if(b!==this._field_currentDisplayTitle){this._field_currentDisplayTitle=b;this.$("span.label").text(b)}}},$input:function(){return this.$("input")},getFieldValue:function(){var a=this.$input().attr("checked");if(a)this._lastFieldValue=null;else if(this._lastFieldValue===SC.MIXED_STATE)a=SC.MIXED_STATE;return a},setFieldValue:function(a){this._lastFieldValue=
a;this.$input().attr("checked",a===SC.MIXED_STATE?NO:!!a)},fieldValueForObject:function(a){return this.computeIsSelectedForValue(a)},objectForFieldValue:function(a){return a===SC.MIXED_STATE?this.get("value"):a?this.get("toggleOnValue"):this.get("toggleOffValue")},didCreateLayer:function(){this.setFieldValue(this.get("fieldValue"));SC.Event.add(this.$input()[0],"click",this,this._field_fieldValueDidChange)},willDestroyLayer:function(){SC.Event.remove(this.$input()[0],"click",this,this._field_fieldValueDidChange)},
mouseDown:function(){this.set("isActive",YES);return this._field_isMouseDown=YES}});SC.LIST_ITEM_ACTION_CANCEL="sc-list-item-cancel-action";SC.LIST_ITEM_ACTION_REFRESH="sc-list-item-cancel-refresh";SC.LIST_ITEM_ACTION_EJECT="sc-list-item-cancel-eject";
SC.ListItemView=SC.View.extend(SC.StaticLayout,SC.Control,{classNames:["sc-list-item-view"],content:null,hasContentIcon:NO,hasContentRightIcon:NO,hasContentBranch:NO,contentCheckboxKey:null,contentIconKey:null,contentRightIconKey:null,contentValueKey:null,escapeHTML:YES,contentUnreadCountKey:null,contentIsBranchKey:null,isEditing:NO,outlineIndent:16,outlineLevel:0,disclosureState:SC.LEAF_NODE,contentPropertyDidChange:function(){this.get("contentIsEditable")!==this.contentIsEditable()&&this.notifyPropertyChange("contentIsEditable");
this.displayDidChange()},contentIsEditable:function(){var a=this.get("content");return a&&(a.get?a.get("isEditable")!==NO:NO)}.property("content").cacheable(),render:function(a){var b=this.get("content"),c=this.displayDelegate,e=this.get("outlineLevel"),g=this.get("outlineIndent"),d;a.addClass(this.get("contentIndex")%2===0?"even":"odd");a.setClass("disabled",!this.get("isEnabled"));d=a.begin("div").addClass("sc-outline");e>=0&&g>0&&d.addStyle("left",g*(e+1));e=this.get("disclosureState");if(e!==
SC.LEAF_NODE){this.renderDisclosure(d,e);a.addClass("has-disclosure")}if(e=this.getDelegateProperty("contentCheckboxKey",c)){e=b?b.get?b.get(e):b[e]:NO;this.renderCheckbox(d,e);a.addClass("has-checkbox")}if(this.getDelegateProperty("hasContentIcon",c)){e=(e=this.getDelegateProperty("contentIconKey",c))&&b?b.get?b.get(e):b[e]:null;this.renderIcon(d,e);a.addClass("has-icon")}if((e=(e=this.getDelegateProperty("contentValueKey",c))&&b?b.get?b.get(e):b[e]:b)&&SC.typeOf(e)!==SC.T_STRING)e=e.toString();
if(this.get("escapeHTML"))e=SC.RenderContext.escapeHTML(e);this.renderLabel(d,e);if(this.getDelegateProperty("hasContentRightIcon",c)){e=(e=this.getDelegateProperty("contentRightIconKey",c))&&b?b.get?b.get(e):b[e]:null;this.renderRightIcon(d,e);a.addClass("has-right-icon")}e=(e=this.getDelegateProperty("contentUnreadCountKey",c))&&b?b.get?b.get(e):b[e]:null;if(!SC.none(e)&&e!==0){this.renderCount(d,e);g=["zero","one","two","three","four","five"];e=e.toString().length<g.length?g[e.toString().length]:
g[g.length-1];a.addClass("has-count %@-digit".fmt(e))}if(e=(e=this.getDelegateProperty("listItemActionProperty",c))&&b?b.get?b.get(e):b[e]:null){this.renderAction(d,e);a.addClass("has-action")}if(this.getDelegateProperty("hasContentBranch",c)){e=(e=this.getDelegateProperty("contentIsBranchKey",c))&&b?b.get?b.get(e):b[e]:NO;this.renderBranch(d,e);a.addClass("has-branch")}d.end()},renderDisclosure:function(a,b){b=b===SC.BRANCH_OPEN?"open":"closed";var c=this._scli_disclosureHtml,e;if(!c)c=this.constructor.prototype._scli_disclosureHtml=
{};(e=c[b])||(e=c[b]='<img src="%@" class="disclosure button %@" />'.fmt(SC.BLANK_IMAGE_URL,b));a.push(e)},renderCheckbox:function(a,b){var c=b===SC.MIXED_STATE?"mixed":b?"sel":"nosel",e=this._scli_checkboxHtml,g=this.get("contentIsEditable")&&this.get("isEnabled"),d;g||(c=SC.keyFor("disabled",c));if(!e)e=this.constructor.prototype._scli_checkboxHtml={};d=e[c];if(!d){d=SC.RenderContext("a").attr("href","javascript:;").classNames(SC.CheckboxView.prototype.classNames);b===SC.MIXED_STATE?d.addClass("mixed"):
d.setClass("sel",b);d.setClass("disabled",!g);d.push('<span class="button"></span>');d=e[c]=d.join()}a.push(d)},renderIcon:function(a,b){var c=null,e=null;if(b&&SC.ImageView.valueIsUrl(b)){c=b;e=""}else{e=b;c=SC.BLANK_IMAGE_URL}a.begin("img").addClass("icon").addClass(e).attr("src",c).end()},renderLabel:function(a,b){a.push("<label>",b||"","</label>")},$label:function(){return this.$("label")},renderRightIcon:function(a,b){var c=null,e=null;if(b&&SC.ImageView.valueIsUrl(b)){c=b;e=""}else{e=b;c=SC.BLANK_IMAGE_URL}a.begin("img").addClass("right-icon").addClass(e).attr("src",
c).end()},renderCount:function(a,b){a.push('<span class="count"><span class="inner">').push(b.toString()).push("</span></span>")},renderAction:function(a){a.push('<img src="',SC.BLANK_IMAGE_URL,'" class="action" />')},renderBranch:function(a,b){a.begin("span").addClass("branch").addClass(b?"branch-visible":"branch-hidden").push("&nbsp;").end()},_isInsideElementWithClassName:function(a,b){var c=this.get("layer");if(!c)return NO;b=SC.$(b.target);for(var e=NO;!e&&b.length>0&&b.get(0)!==c;){if(b.hasClass(a))e=
YES;b=b.parent()}return e},_isInsideCheckbox:function(a){return this.getDelegateProperty("contentCheckboxKey",this.displayDelegate)&&this._isInsideElementWithClassName("sc-checkbox-view",a)},_isInsideDisclosure:function(a){if(this.get("disclosureState")===SC.LEAF_NODE)return NO;return this._isInsideElementWithClassName("disclosure",a)},mouseDown:function(a){if(!this.get("contentIsEditable"))return NO;if(this._isInsideCheckbox(a)){this._addCheckboxActiveState();return this._isMouseInsideCheckbox=this._isMouseDownOnCheckbox=
YES}else if(this._isInsideDisclosure(a)){this._addDisclosureActiveState();return this._isMouseInsideDisclosure=this._isMouseDownOnDisclosure=YES}return NO},mouseUp:function(a){var b=NO,c;if(this._isMouseDownOnCheckbox){if(this._isInsideCheckbox(a)){b=this.displayDelegate;a=this.getDelegateProperty("contentCheckboxKey",b);if((b=this.get("content"))&&b.get){c=b.get(a);c=c===SC.MIXED_STATE?YES:!c;b.set(a,c);this.displayDidChange()}}this._removeCheckboxActiveState();b=YES}else if(this._isMouseDownOnDisclosure){if(this._isInsideDisclosure(a)){a=
this.get("disclosureState");b=this.get("contentIndex");c=!SC.none(b)?SC.IndexSet.create(b):null;b=this.get("displayDelegate");if(a===SC.BRANCH_OPEN){c&&b&&b.collapse?b.collapse(c):this.set("disclosureState",SC.BRANCH_CLOSED);this.displayDidChange()}else if(a===SC.BRANCH_CLOSED){c&&b&&b.expand?b.expand(c):this.set("disclosureState",SC.BRANCH_OPEN);this.displayDidChange()}}this._removeDisclosureActiveState();b=YES}this._isMouseDownOnDisclosure=this._isMouseInsideDisclosure=this._isMouseInsideCheckbox=
this._isMouseDownOnCheckbox=NO;return b},mouseExited:function(){if(this._isMouseDownOnCheckbox){this._removeCheckboxActiveState();this._isMouseInsideCheckbox=NO}else if(this._isMouseDownOnDisclosure){this._removeDisclosureActiveState();this._isMouseInsideDisclosure=NO}return NO},mouseEntered:function(){if(this._isMouseDownOnCheckbox){this._addCheckboxActiveState();this._isMouseInsideCheckbox=YES}else if(this._isMouseDownOnDisclosure){this._addDisclosureActiveState();this._isMouseInsideDisclosure=
YES}return NO},_addCheckboxActiveState:function(){var a=this.get("isEnabled");this.$(".sc-checkbox-view").setClass("active",a)},_removeCheckboxActiveState:function(){this.$(".sc-checkbox-view").removeClass("active")},_addDisclosureActiveState:function(){var a=this.get("isEnabled");this.$("img.disclosure").setClass("active",a)},_removeDisclosureActiveState:function(){this.$("img.disclosure").removeClass("active")},contentHitTest:function(a){if(!this.getDelegateProperty("contentValueKey",this.displayDelegate))return NO;
var b=this.$label().get(0);if(!b)return NO;a=a.target;for(var c=this.get("layer");a&&a!==c&&a!==window;){if(a===b)return YES;a=a.parentNode}return NO},beginEditing:function(){if(this.get("isEditing"))return YES;return this._beginEditing(YES)},_beginEditing:function(a){var b=this.get("content"),c=this.getDelegateProperty("contentValueKey",this.get("displayDelegate")),e=this.get("parentView");e&&e.get("frame");var g=this.$label(),d,f,h,i;if(a&&this.scrollToVisible()){var j=this.get("owner"),k=this.get("contentIndex");
this.invokeLater(function(){var l=j.itemViewForContentIndex(k);l&&l._beginEditing&&l._beginEditing(NO)});return YES}if(!e||!g||g.get("length")===0)return NO;c=c&&b&&b.get?b.get(c):null;b=this.computeFrameWithParentFrame(null);e=SC.viewportOffset(g[0]);a=g.css("lineHeight");d=g.css("fontSize");f=(f=this.$().css("top"))?parseInt(f.substring(0,f.length-2),0):0;h=a;i=0;if(d&&h){d=d*1.5;if(d<h){g.css({lineHeight:"1.5"});i=(h-d)/2}else a=null}b.x=e.x;b.y=e.y+f+i;b.height=g[0].offsetHeight;b.width=g[0].offsetWidth;
b=SC.InlineTextFieldView.beginEditing({frame:b,exampleElement:g,delegate:this,value:c,multiline:NO,isCollection:YES});a&&g.css({lineHeight:a});return b},commitEditing:function(){if(!this.get("isEditing"))return YES;return SC.InlineTextFieldView.commitEditing()},discardEditing:function(){if(!this.get("isEditing"))return YES;return SC.InlineTextFieldView.discardEditing()},inlineEditorWillBeginEditing:function(){this.set("isEditing",YES)},inlineEditorDidBeginEditing:function(){var a=this.$label();this._oldOpacity=
a.css("opacity");a.css("opacity",0)},inlineEditorShouldEndEditing:function(){return YES},inlineEditorDidEndEditing:function(a,b){this.set("isEditing",NO);a=this.get("content");var c=this.getDelegateProperty("contentValueKey",this.displayDelegate);c&&a&&a.set&&a.set(c,b);this.displayDidChange()}});sc_require("mixins/collection_view_delegate");sc_require("views/list_item");SC.DRAG_REORDER=16;SC.HORIZONTAL_ORIENTATION="horizontal";SC.VERTICAL_ORIENTATION="vertical";SC.BENCHMARK_RELOAD=NO;
SC.CollectionView=SC.View.extend(SC.CollectionViewDelegate,SC.CollectionContent,{classNames:["sc-collection-view"],ACTION_DELAY:200,content:null,contentBindingDefault:SC.Binding.multiple(),length:0,nowShowing:function(){return this.computeNowShowing()}.property("length","clippingFrame").cacheable(),selection:null,isSelectable:YES,isSelectableBindingDefault:SC.Binding.bool(),isEnabled:YES,isEnabledBindingDefault:SC.Binding.bool(),isEditable:YES,isEditableBindingDefault:SC.Binding.bool(),canReorderContent:NO,
canReorderContentBindingDefault:SC.Binding.bool(),canDeleteContent:NO,canDeleteContentBindingDefault:SC.Binding.bool(),canEditContent:NO,canEditContentBindingDefault:SC.Binding.bool(),isDropTarget:NO,useToggleSelection:NO,actOnSelect:NO,selectOnMouseDown:YES,exampleView:SC.ListItemView,contentExampleViewKey:null,groupExampleView:null,contentGroupExampleViewKey:null,action:null,target:null,contentValueKey:null,acceptsFirstResponder:NO,isActive:NO,calculatedHeight:0,calculatedWidth:0,computeLayout:function(){return null},
layoutForContentIndex:function(){return null},allContentIndexes:function(){return SC.IndexSet.create(0,this.get("length")).freeze()}.property("length").cacheable(),contentIndexesInRect:function(){return null},computeNowShowing:function(){var a=this.contentIndexesInRect(this.get("clippingFrame"));if(a){var b=this.get("length"),c=a.get("max");if(c>b)a=a.copy().remove(b,c-b).freeze()}else a=this.get("allContentIndexes");return a},showInsertionPoint:function(){},hideInsertionPoint:function(){},delegate:null,
selectionDelegate:function(){var a=this.get("delegate"),b=this.get("content");return this.delegateFor("isCollectionViewDelegate",a,b)}.property("delegate","content").cacheable(),contentDelegate:function(){var a=this.get("delegate"),b=this.get("content");return this.delegateFor("isCollectionContent",a,b)}.property("delegate","content").cacheable(),contentRangeDidChange:function(a,b,c,e){!b&&c==="[]"?this.reload(e):this.contentPropertyDidChange(b,c,e)},contentPropertyDidChange:function(){},updateContentRangeObserver:function(){var a=
this.get("nowShowing"),b=this._cv_contentRangeObserver,c=this.get("content");if(c)if(b)c.updateRangeObserver(b,a);else this._cv_contentRangeObserver=b=c.addRangeObserver(a,this,this.contentRangeDidChange,null)},removeContentRangeObserver:function(){var a=this.get("content"),b=this._cv_contentRangeObserver;if(b){a&&a.removeRangeObserver(b);this._cv_contentRangeObserver=null}},contentLengthDidChange:function(){var a=this.get("content");this.set("length",a?a.get("length"):0)},_cv_contentDidChange:function(){var a=
this.get("content"),b=this.contentLengthDidChange;if(a===this._content)return this;this.removeContentRangeObserver();this._content&&this._content.removeObserver("length",this,b);(this._content=a)&&a.addObserver("length",this,b);this.contentLengthDidChange();this.contentRangeDidChange(a,null,"[]",null)}.observes("content"),_invalidIndexes:NO,reload:function(a){var b=this._invalidIndexes;if(a&&b!==YES)if(b)b.add(a);else this._invalidIndexes=a.clone();else this._invalidIndexes=YES;this.get("isVisibleInWindow")&&
this.invokeOnce(this.reloadIfNeeded);return this},reloadIfNeeded:function(){var a=this._invalidIndexes;if(!a||!this.get("isVisibleInWindow"))return this;this._invalidIndexes=NO;var b=this.get("content");b&&b.get("length");b=this.computeLayout();var c=SC.BENCHMARK_RELOAD,e=this.get("nowShowing"),g=this._sc_itemViews,d=this.get("containerView")||this,f,h,i,j;if(a.isIndexSet&&a.contains(e))a=YES;if(this.willReload)this.willReload(a===YES?null:a);if(a.isIndexSet){i=d.get("childViews");i.get("length");
if(c)SC.Benchmark.start(c="%@#reloadIfNeeded (Partial)".fmt(this),YES);a.forEach(function(k){var l=g?g[k]:null;if(e.contains(k)){h=this.itemViewForContentIndex(k,YES);if(l&&l.parentView===d){(j=l.get("layer"))&&j.parentNode&&j.parentNode.removeChild(j);j=null;d.replaceChild(h,l)}else d.appendChild(h)}else if(l&&l.parentView===d){delete g[k];(j=l.get("layer"))&&j.parentNode&&j.parentNode.removeChild(j);j=null;d.removeChild(l)}},this)}else{if(c)SC.Benchmark.start(c="%@#reloadIfNeeded (Full)".fmt(this),
YES);if(g)g.length=0;f=[];e.forEach(function(k){f.push(this.itemViewForContentIndex(k,YES))},this);d.beginPropertyChanges();d.destroyLayer().removeAllChildren();d.set("childViews",f);d.replaceLayer();d.endPropertyChanges()}c&&SC.Benchmark.end(c);b&&this.adjust(b);if(this.didReload)this.didReload(a===YES?null:a);return this},displayProperties:"isFirstResponder isEnabled isActive".w(),render:function(a){a.setClass("focus",this.get("isFirstResponder"));a.setClass("disabled",!this.get("isEnabled"));a.setClass("active",
this.get("isActive"));return arguments.callee.base.apply(this,arguments)},_TMP_ATTRS:{},_COLLECTION_CLASS_NAMES:"sc-collection-item".w(),_GROUP_COLLECTION_CLASS_NAMES:"sc-collection-item sc-group-item".w(),itemViewForContentIndex:function(a,b){var c=this.get("content"),e=this._sc_itemViews,g=c.objectAt(a),d=this.get("contentDelegate"),f=d.contentGroupIndexes(this,c),h=NO,i,j;if(!e)e=this._sc_itemViews=[];if(!b&&(i=e[a]))return i;if(h=f&&f.contains(a))h=d.contentIndexIsGroup(this,c,a);if(h){if((b=
this.get("contentGroupExampleViewKey"))&&g)j=g.get(b);j||(j=this.get("groupExampleView")||this.get("exampleView"))}else{if((b=this.get("contentExampleViewKey"))&&g)j=g.get(b);j||(j=this.get("exampleView"))}b=this._TMP_ATTRS;b.contentIndex=a;b.content=g;b.owner=b.displayDelegate=this;b.parentView=this.get("containerView")||this;b.page=this.page;b.layerId=this.layerIdFor(a,g);b.isEnabled=d.contentIndexIsEnabled(this,c,a);b.isSelected=d.contentIndexIsSelected(this,c,a);b.outlineLevel=d.contentIndexOutlineLevel(this,
c,a);b.disclosureState=d.contentIndexDisclosureState(this,c,a);b.isGroupView=h;b.isVisibleInWindow=this.isVisibleInWindow;b.classNames=h?this._GROUP_COLLECTION_CLASS_NAMES:this._COLLECTION_CLASS_NAMES;if(c=this.layoutForContentIndex(a))b.layout=c;else delete b.layout;i=this.createItemView(j,a,b);return e[a]=i},itemViewForContentObject:function(a){return this.itemViewForContentIndex(this.get("content").indexOf(a))},_TMP_LAYERID:[],createItemView:function(a,b,c){return a.create(c)},layerIdFor:function(a){var b=
this._TMP_LAYERID;b[0]=SC.guidFor(this);b[1]=a;return b.join("-")},contentIndexForLayerId:function(a){if(!a||!(a=a.toString()))return null;var b=this._baseLayerId;if(!b)b=this._baseLayerId=SC.guidFor(this)+"-";if(a.length<=b.length||a.indexOf(b)!==0)return null;a=Number(a.slice(a.lastIndexOf("-")+1));return isNaN(a)?null:a},itemViewForEvent:function(a){if(!this.getPath("pane.rootResponder"))return null;SC.guidFor(this);a=a.target;for(var b=this.get("layer"),c=null,e;a&&a!==document&&a!==b;){if((e=
a?SC.$(a).attr("id"):null)&&(c=this.contentIndexForLayerId(e))!==null)break;a=a.parentNode}if(c===null||a===b)return null;if(c>=this.get("length"))throw"layout for item view %@ was found when item view does not exist (%@)".fmt(e,this);return this.itemViewForContentIndex(c)},expand:function(a){if(!a)return this;var b=this.get("contentDelegate"),c=this.get("content");a.forEach(function(e){b.contentIndexDisclosureState(this,c,e)===SC.BRANCH_CLOSED&&b.contentIndexExpand(this,c,e)},this);return this},
collapse:function(a){if(!a)return this;var b=this.get("contentDelegate"),c=this.get("content");a.forEach(function(e){b.contentIndexDisclosureState(this,c,e)===SC.BRANCH_OPEN&&b.contentIndexCollapse(this,c,e)},this);return this},_cv_selectionDidChange:function(){var a=this.get("selection"),b=this._cv_selection,c=this._cv_selectionContentDidChange;if(a===b)return this;b&&b.removeObserver("[]",this,c);a&&a.addObserver("[]",this,c);this._cv_selection=a;this._cv_selectionContentDidChange()}.observes("selection"),
_cv_selectionContentDidChange:function(){var a=this.get("selection"),b=this._cv_selindexes,c=this.get("content");this._cv_selindexes=a?a.frozenCopy():null;if(b)b=b.indexSetForSource(c);if(a)a=a.indexSetForSource(c);(a=a&&b?a.without(b).add(b.without(a)):a||b)&&a.get("length")>0&&this.reloadSelectionIndexes(a)},_invalidSelection:NO,reloadSelectionIndexes:function(a){var b=this._invalidSelection;if(a&&b!==YES)if(b)b.add(a);else this._invalidSelection=a.copy();else this._invalidSelection=YES;this.get("isVisibleInWindow")&&
this.invokeOnce(this.reloadSelectionIndexesIfNeeded);return this},reloadSelectionIndexesIfNeeded:function(){var a=this._invalidSelection;if(!a||!this.get("isVisibleInWindow"))return this;var b=this.get("nowShowing"),c=this._invalidIndexes,e=this.get("content"),g=this.get("selection");this._invalidSelection=NO;if(c===YES||!b)return this;if(a===YES)a=b;if(c&&c.isIndexSet)a=a.without(c);a.forEach(function(d){if(b.contains(d)){var f=this.itemViewForContentIndex(d,NO);if(f)f.set("isSelected",g?g.contains(e,
d):NO)}},this);return this},select:function(a,b){var c=this.get("content"),e=this.get("selectionDelegate"),g=this.get("contentDelegate").contentGroupIndexes(this,c),d;if(!this.get("isSelectable"))return this;if(SC.typeOf(a)===SC.T_NUMBER)a=SC.IndexSet.create(a,1);if(a&&a.get("length")>0){if(g&&g.get("length")>0)a=a.copy().remove(g);a=e.collectionViewShouldSelectIndexes(this,a,b);if(!a||a.get("length")===0)return this}else a=null;d=b&&(d=this.get("selection"))?d.copy():SC.SelectionSet.create();if(a&&
a.get("length")>0)a.get("length")===1?d.addObject(c.objectAt(a.get("firstObject"))):d.add(c,a);(d=e.collectionViewSelectionForProposedSelection(this,d))||(d=SC.SelectionSet.create());this._selectionAnchor=null;this.set("selection",d.freeze());return this},deselect:function(a){var b=this.get("selection"),c=this.get("content"),e=this.get("selectionDelegate");if(!this.get("isSelectable"))return this;if(!b||b.get("length")===0)return this;if(SC.typeOf(a)===SC.T_NUMBER)a=SC.IndexSet.create(a,1);a=e.collectionViewShouldDeselectIndexes(this,
a);if(!a||a.get("length")===0)return this;b=b.copy().remove(c,a);(b=e.collectionViewSelectionForProposedSelection(this,b))||(b=SC.SelectionSet.create());this.set("selection",b.freeze());return this},_findNextSelectableItemFromIndex:function(a,b){var c=this.get("length"),e=SC.IndexSet.create(),g=this.get("content"),d=this.get("selectionDelegate");g=this.get("contentDelegate").contentGroupIndexes(this,g);var f;if(!g&&d.collectionViewShouldSelectIndexes===this.collectionViewShouldSelectIndexes)return a;
for(;a<c;){if(!g||!g.contains(a)){e.add(a);if((f=d.collectionViewShouldSelectIndexes(this,e))&&f.get("length")>=1)return a;e.remove(a)}a++}if(b===undefined)b=(a=this.get("selection"))?a.get("max"):-1;return b},_findPreviousSelectableItemFromIndex:function(a,b){var c=SC.IndexSet.create(),e=this.get("content"),g=this.get("selectionDelegate");e=this.get("contentDelegate").contentGroupIndexes(this,e);var d;if(SC.none(a))a=-1;if(!e&&g.collectionViewShouldSelectIndexes===this.collectionViewShouldSelectIndexes)return a;
for(;a>=0;){if(!e||!e.contains(a)){c.add(a);if((d=g.collectionViewShouldSelectIndexes(this,c))&&d.get("length")>=1)return a;c.remove(a)}a--}if(b===undefined)b=(a=this.get("selection"))?a.get("min"):-1;if(SC.none(b))b=-1;return b},selectPreviousItem:function(a,b){if(SC.none(b))b=1;if(SC.none(a))a=false;var c=this.get("selection"),e=this.get("content");if(c)c=c.indexSetForSource(e);e=c?c.get("min"):-1;c=c?c.get("max")-1:-1;var g=this._selectionAnchor;if(SC.none(g))g=e;if(a){if(c>g)c-=b;else e=this._findPreviousSelectableItemFromIndex(e-
b);if(SC.none(e)||e<0)e=0;if(c<e)c=e}else{e=this._findPreviousSelectableItemFromIndex(e-b);if(SC.none(e)||e<0)e=0;c=e;g=null}a=e;c=SC.IndexSet.create(e,c+1-e);this.scrollToContentIndex(a);this.select(c);this._selectionAnchor=g;return this},selectNextItem:function(a,b){if(SC.none(b))b=1;if(SC.none(a))a=false;var c=this.get("selection"),e=this.get("content");if(c)c=c.indexSetForSource(e);e=c?c.get("min"):-1;c=c?c.get("max")-1:-1;var g=this._selectionAnchor,d=this.get("length");if(SC.none(g))g=e;if(a){if(e<
g)e+=b;else c=this._findNextSelectableItemFromIndex(c+b,c);if(c>=d)c=d-1;if(e>c)e=c}else{c=this._findNextSelectableItemFromIndex(c+b,c);if(c>=d)c=d-1;e=c;g=null}a=c;c=SC.IndexSet.create(e,c-e+1);this.scrollToContentIndex(a);this.select(c);this._selectionAnchor=g;return this},deleteSelection:function(){if(!this.get("canDeleteContent"))return NO;var a=this.get("selection"),b=this.get("content"),c=this.get("selectionDelegate");a=a&&b?a.indexSetForSource(b):null;if(!b||!a||a.get("length")===0)return NO;
a=c.collectionViewShouldDeleteIndexes(this,a);if(!a||a.get("length")===0)return NO;c.collectionViewDeleteContent(this,this.get("content"),a);return YES},scrollToContentIndex:function(a){(a=this.itemViewForContentIndex(a))&&this.scrollToItemView(a);return this},scrollToItemView:function(a){a&&a.scrollToVisible();return this},keyDown:function(a){a=this.interpretKeyEvents(a);return!a?NO:a},keyUp:function(){return true},insertText:function(a,b){if(a===" "){(a=this.get("selection"))&&a.get("length")>0&&
this.invokeLater(this._cv_action,0,null,b);return YES}else return NO},selectAll:function(){var a=this.get("content");this.select(a?SC.IndexSet.create(0,a.get("length")):null,NO);return YES},deleteBackward:function(){return this.deleteSelection()},deleteForward:function(){return this.deleteSelection()},moveDown:function(a,b){this.selectNextItem(false,this.get("itemsPerRow")||1);this._cv_performSelectAction(null,b,this.ACTION_DELAY);return true},moveUp:function(a,b){this.selectPreviousItem(false,this.get("itemsPerRow")||
1);this._cv_performSelectAction(null,b,this.ACTION_DELAY);return true},moveLeft:function(a,b){if((this.get("itemsPerRow")||1)>1){this.selectPreviousItem(false,1);this._cv_performSelectAction(null,b,this.ACTION_DELAY)}else{b=this.get("selection");a=this.get("content");var c=b?b.indexSetForSource(a):null;if(c){b=undefined;var e=false,g=undefined;if(c.get("length")===1){g=c.get("firstObject");b=this.get("contentDelegate");if(b.contentIndexDisclosureState(this,a,g)!==SC.BRANCH_OPEN)e=true}if(e){c=b.contentIndexOutlineLevel(this,
a,g)-1;if(c>=0){for(e=-1;e<0;){var d=this._findPreviousSelectableItemFromIndex(g-1);if(d<0)return false;g=d;if(b.contentIndexOutlineLevel(this,a,g)===c)e=d}e!==-1&&this.select(g)}}else this.collapse(c)}}return true},moveRight:function(a,b){if((this.get("itemsPerRow")||1)>1){this.selectNextItem(false,1);this._cv_performSelectAction(null,b,this.ACTION_DELAY)}else{a=this.get("selection");b=this.get("content");(a=a?a.indexSetForSource(b):null)&&this.expand(a)}return true},moveDownAndModifySelection:function(a,
b){this.selectNextItem(true,this.get("itemsPerRow")||1);this._cv_performSelectAction(null,b,this.ACTION_DELAY);return true},moveUpAndModifySelection:function(a,b){this.selectPreviousItem(true,this.get("itemsPerRow")||1);this._cv_performSelectAction(null,b,this.ACTION_DELAY);return true},moveLeftAndModifySelection:function(a,b){if((this.get("itemsPerRow")||1)>1){this.selectPreviousItem(true,1);this._cv_performSelectAction(null,b,this.ACTION_DELAY)}return true},moveRightAndModifySelection:function(a,
b){if((this.get("itemsPerRow")||1)>1){this.selectNextItem(true,1);this._cv_performSelectAction(null,b,this.ACTION_DELAY)}return true},insertNewline:function(){var a=this.get("isEditable")&&this.get("canEditContent"),b,c,e,g;if(a){b=this.get("selection");c=this.get("content");if(b&&b.get("length")===1){e=(a=b.indexSetForSource(c))?a.get("min"):-1;a=e>=0}}if(a)a=(g=this.itemViewForContentIndex(e))&&SC.typeOf(g.beginEditing)===SC.T_FUNCTION;if(a){this.scrollToContentIndex(e);g=this.itemViewForContentIndex(e);
g.beginEditing()}else this.invokeLater(this._cv_action,0,g,null);return YES},mouseDown:function(a){if(this.get("useToggleSelection"))return true;var b=this.itemViewForEvent(a),c=this.get("content"),e=b?b.get("contentIndex"):-1,g;g=this.mouseDownInfo={event:a,itemView:b,contentIndex:e,at:Date.now()};this.becomeFirstResponder();if(!b){this.get("allowDeselectAll")&&this.select(null,false);return YES}b=this.get("selection");var d;if(b)b=b.indexSetForSource(c);c=b?b.contains(e):NO;if((g.modifierKeyPressed=
d=a.ctrlKey||a.metaKey)&&c)g.shouldDeselect=e>=0;else if(a.shiftKey&&b&&b.get("length")>0){b=this._findSelectionExtendedByShift(b,e);a=this._selectionAnchor;this.select(b);this._selectionAnchor=a}else if(!d&&c)g.shouldReselect=e>=0;else if(this.get("selectOnMouseDown"))this.select(e,d);else g.shouldSelect=e>=0;g.previousContentIndex=e;return YES},mouseUp:function(a){var b=this.itemViewForEvent(a),c=this.mouseDownInfo,e,g;if(this.get("useToggleSelection")){if(!b)return;c=this.get("selection");e=b?
b.get("contentIndex"):-1;(c=c&&c.include(e))?this.deselect(e):this.select(e,YES)}else if(c){e=c.contentIndex;b&&b.get("contentIndex");c.shouldSelect&&this.select(e,c.modifierKeyPressed);c.shouldDeselect&&this.deselect(e);if(c.shouldReselect){if(c=this.get("isEditable")&&this.get("canEditContent"))c=(c=this.get("selection"))&&c.get("length")===1;if(c)c=(c=(g=this.itemViewForContentIndex(e))&&(!g.contentHitTest||g.contentHitTest(a)))&&g.beginEditing?g.beginEditing():NO;if(!c){this._cv_reselectTimer&&
this._cv_reselectTimer.invalidate();this._cv_reselectTimer=this.invokeLater(this.select,300,e,false)}}this._cleanupMouseDown()}this._cv_performSelectAction(b,a,0,a.clickCount);return NO},_cleanupMouseDown:function(){var a=this.mouseDownInfo,b;if(a)for(b in a)a.hasOwnProperty(b)&&delete a[b];this.mouseDownInfo=null},mouseMoved:function(a){var b=this.itemViewForEvent(a),c=this._lastHoveredItem;if(b!==c){c&&c.mouseOut&&c.mouseOut(a);b&&b.mouseOver&&b.mouseOver(a)}(this._lastHoveredItem=b)&&b.mouseMoved&&
b.mouseMoved(a);return YES},mouseOut:function(a){var b=this._lastHoveredItem;this._lastHoveredItem=null;b&&b.mouseOut&&b.mouseOut(a);return YES},_findSelectionExtendedByShift:function(a,b){if(!a||a.get("length")===0)return SC.IndexSet.create(b);this.get("content").get("length");var c=a.get("min");a=a.get("max")-1;var e=this._selectionAnchor;if(SC.none(e))e=-1;if(b<c){c=b;if(e<0)this._selectionAnchor=a}else if(b>a){a=b;if(e<0)this._selectionAnchor=c}else if(b>=c&&b<=a){if(e<0)this._selectionAnchor=
e=c;if(b===e)c=a=b;else if(b>e){c=e;a=b}else if(b<e){c=b;a=e}}return SC.IndexSet.create(c,a-c+1)},reorderDataType:function(){return"SC.CollectionView.Reorder.%@".fmt(SC.guidFor(this))}.property().cacheable(),dragContent:null,proposedInsertionIndex:null,proposedDropOperation:null,mouseDragged:function(){var a=this.get("selectionDelegate"),b=this.get("content"),c=this.get("selection"),e=this.mouseDownInfo,g=this.get("contentDelegate").contentGroupIndexes(this,b);if(!e||e.contentIndex<0)return YES;if(Date.now()-
e.at<123)return YES;if(a.collectionViewShouldBeginDrag(this)){if((c=this.get("selectOnMouseDown")?c?c.indexSetForSource(b):null:SC.IndexSet.create(e.contentIndex))&&g&&g.get("length")>0){c=c.copy().remove(g);if(c.get("length")===0)c=null;else c.freeze()}if(c)c=c.frozenCopy();else return YES;c={content:b,indexes:c};this.set("dragContent",c);if((b=this.get("dragDataTypes"))&&b.get("length")>0){(b=a.collectionViewDragViewFor(this,c.indexes))||(b=this._cv_dragViewFor(c.indexes));b.createLayer();SC.Drag.start({event:e.event,
source:this,dragView:b,ghost:NO,ghostActsLikeCursor:a.ghostActsLikeCursor,slideBack:YES,dataSource:this});this._cleanupMouseDown();this._lastInsertionIndex=null}else this.set("dragContent",null);return YES}},_cv_dragViewFor:function(a){a=this.get("nowShowing").without(a);a=this.get("nowShowing").without(a);var b=this.get("layer").cloneNode(false),c=SC.View.create({layer:b,parentView:this});SC.$(b).css("backgroundColor","transparent").css("border","none").css("top",0).css("left",0);a.forEach(function(e){e=
this.itemViewForContentIndex(e);var g,d;if(e){g=e.get("isSelected");e.set("isSelected",NO);e.updateLayerIfNeeded();if(d=e.get("layer"))d=d.cloneNode(true);e.set("isSelected",g);e.updateLayerIfNeeded()}d&&b.appendChild(d)},this);b=null;return c},dragDataTypes:function(){var a=this.get("selectionDelegate").collectionViewDragDataTypes(this),b;if(this.get("canReorderContent")){a=a?a.copy():[];b=this.get("reorderDataType");a.indexOf(b)<0&&a.push(b)}return a?a:[]}.property(),dragDataForType:function(a,
b){if(this.get("canReorderContent"))if(b===this.get("reorderDataType"))return this.get("dragContent");return this.get("selectionDelegate").collectionViewDragDataForType(this,a,b)},computeDragOperations:function(a){var b=SC.DRAG_NONE,c=this.get("selectionDelegate");if(this.get("canReorderContent"))if(a.get("dataTypes").indexOf(this.get("reorderDataType"))>=0)b=SC.DRAG_REORDER;b=c.collectionViewComputeDragOperations(this,a,b);if(b&SC.DRAG_REORDER)b=SC.DRAG_MOVE;return b},_computeDropOperationState:function(a,
b,c){var e=this.convertFrameFromView(a.get("location"),null);b=SC.DROP_BEFORE;var g=this.get("selectionDelegate"),d=this.get("canReorderContent"),f,h,i=this.insertionIndexForLocation(e,SC.DROP_ON);if(SC.typeOf(i)===SC.T_ARRAY){b=i[1];i=i[0]}if(b===SC.DROP_ON){this.set("proposedInsertionIndex",i);this.set("proposedDropOperation",b);f=g.collectionViewValidateDragOperation(this,a,c,i,b);i=this.get("proposedInsertionIndex");b=this.get("proposedDropOperation");this._dropInsertionIndex=this._dropOperation=
null;if(f!==SC.DRAG_NONE)return[i,b,f];else{b=SC.DROP_BEFORE;i=this.insertionIndexForLocation(e,SC.DROP_BEFORE);if(SC.typeOf(i)===SC.T_ARRAY){b=i[1];i=i[0]}}}if(i>=0&&d&&b!==SC.DROP_ON)if(e=a.dataForType(this.get("reorderDataType"))){d=this.get("content");if(b===SC.DROP_BEFORE){f=e.indexes.contains(i-1);h=e.indexes.contains(i)}else{f=e.indexes.contains(i);h=e.indexes.contains(i-1)}if(f&&h)if(SC.none(this._lastInsertionIndex))if(b===SC.DROP_BEFORE)for(;i>=0&&e.indexes.contains(i);)i--;else for(d=d?
d.get("length"):0;i<d&&e.indexes.contains(i);)i++;else i=this._lastInsertionIndex;if(i>=0)c=SC.DRAG_REORDER}this.set("proposedInsertionIndex",i);this.set("proposedDropOperation",b);c=g.collectionViewValidateDragOperation(this,a,c,i,b);i=this.get("proposedInsertionIndex");b=this.get("proposedDropOperation");this._dropInsertionIndex=this._dropOperation=null;return[i,b,c]},dragUpdated:function(a,b){var c=a.get("allowedDragOperations");c=this._computeDropOperationState(a,b,c);a=c[0];b=c[1];c=c[2];if(c!==
SC.DRAG_NONE){if(this._lastInsertionIndex!==a||this._lastDropOperation!==b)this.showInsertionPoint(this.itemViewForContentIndex(a),b);this._lastInsertionIndex=a;this._lastDropOperation=b}else{this.hideInsertionPoint();this._lastInsertionIndex=this._lastDropOperation=null}return c&SC.DRAG_REORDER?SC.DRAG_MOVE:c},dragExited:function(){this.hideInsertionPoint();this._lastInsertionIndex=this._lastDropOperation=null},acceptDragOperation:function(){return YES},performDragOperation:function(a,b){var c=this._computeDropOperationState(a,
null,b),e=c[0],g=c[1];c=c[2];var d=this.get("selectionDelegate"),f,h,i;if(c&SC.DRAG_REORDER)b=b&SC.DRAG_MOVE?SC.DRAG_REORDER:SC.DRAG_NONE;else b&=c;if(b===SC.DRAG_NONE)return b;if(d.collectionViewPerformDragOperation(this,a,b,e,g)===SC.DRAG_NONE&&b&SC.DRAG_REORDER){a=a.dataForType(this.get("reorderDataType"));if(!a)return SC.DRAG_NONE;h=this.get("content");b=a.indexes;if(b.get("length")===1)if((g===SC.DROP_BEFORE||g===SC.DROP_AFTER)&&b.get("min")===e)return SC.DRAG_MOVE;h.beginPropertyChanges();f=
[];i=0;a.indexes.forEach(function(j){f.push(h.objectAt(j-i));h.removeAt(j-i);i++;j<e&&e--},this);g===SC.DROP_AFTER&&e++;h.replace(e,0,f,g);this.select(SC.IndexSet.create(e,f.length));h.endPropertyChanges();b=SC.DRAG_MOVE}return b},collectionViewShouldBeginDrag:function(){return this.get("canReorderContent")},insertionIndexForLocation:function(){return-1},_cv_isVisibleInWindowDidChange:function(){if(this.get("isVisibleInWindow")){this._invalidIndexes&&this.invokeOnce(this.reloadIfNeeded);this._invalidSelection&&
this.invokeOnce(this.reloadSelectionIndexesIfNeeded)}}.observes("isVisibleInWindow"),collectionViewShouldSelectItem:function(){return this.get("isSelectable")},_TMP_DIFF1:SC.IndexSet.create(),_TMP_DIFF2:SC.IndexSet.create(),_cv_nowShowingDidChange:function(){var a=this.get("nowShowing"),b=this._sccv_lastNowShowing,c,e,g;if(b!==a)if(b&&a){e=this._TMP_DIFF1.add(b).remove(a);g=this._TMP_DIFF2.add(a).remove(b);c=e.add(g)}else c=b||a;if(c&&c.get("length")>0){this._sccv_lastNowShowing=a?a.frozenCopy():
null;this.updateContentRangeObserver();this.reload(c)}e&&e.clear();g&&g.clear()}.observes("nowShowing"),init:function(){arguments.callee.base.apply(this,arguments);this.get("canReorderContent")&&this._cv_canReorderContentDidChange();this._sccv_lastNowShowing=this.get("nowShowing").clone();this.content&&this._cv_contentDidChange();this.selection&&this._cv_selectionDidChange()},_cv_canReorderContentDidChange:function(){if(this.get("canReorderContent")){this.get("isDropTarget")||this.set("isDropTarget",
YES);SC.Drag.addDropTarget(this)}}.observes("canReorderContent"),_cv_performSelectAction:function(a,b,c,e){if(c===undefined)c=0;if(e===undefined)e=1;if(e>1||this.get("actOnSelect")){this._cv_reselectTimer&&this._cv_reselectTimer.invalidate();e=(e=this.get("selection"))?e.toArray():[];this._cv_actionTimer&&this._cv_actionTimer.invalidate();this._cv_actionTimer=this.invokeLater(this._cv_action,c,a,b,e)}},_cv_action:function(a,b,c){var e=this.get("action"),g=this.get("target")||null;this._cv_actionTimer=
null;if(e){if(SC.typeOf(e)===SC.T_FUNCTION)return this.action(a,b);(a=this.get("pane"))&&a.rootResponder.sendAction(e,g,this,a,c)}else if(a)if(SC.typeOf(a._action)==SC.T_FUNCTION)return a._action(b);else if(SC.typeOf(a.action)==SC.T_FUNCTION)return a.action(b)}});
SC.DisclosureView=SC.ButtonView.extend({classNames:["sc-disclosure-view"],theme:"disclosure",buttonBehavior:SC.TOGGLE_BEHAVIOR,toggleOnValue:YES,toggleOffValue:NO,valueBindingDefault:SC.Binding.bool(),render:function(a){a.push('<img src="',SC.BLANK_IMAGE_URL,'" class="button" alt="" />');this.get("needsEllipsis")?a.push('<label class="ellipsis">',this.get("displayTitle"),"</label>"):a.push("<label>",this.get("displayTitle"),"</label>")},keyDown:function(a){if(a.which===37||a.which===38){this.set("value",
this.get("toggleOffValue"));return YES}if(a.which===39||a.which===40){this.set("value",this.get("toggleOnValue"));return YES}arguments.callee.base.apply(this,arguments)}});sc_require("views/collection");sc_require("mixins/collection_row_delegate");
SC.ListView=SC.CollectionView.extend(SC.CollectionRowDelegate,{classNames:["sc-list-view"],acceptsFirstResponder:YES,showAlternatingRows:NO,render:function(a){a.setClass("alternating",this.get("showAlternatingRows"));return arguments.callee.base.apply(this,arguments)},rowDelegate:function(){var a=this.delegate,b=this.get("content");return this.delegateFor("isCollectionRowDelegate",a,b)}.property("delegate","content").cacheable(),_sclv_rowDelegateDidChange:function(){var a=this._sclv_rowDelegate,b=
this.get("rowDelegate"),c=this._sclv_rowHeightDidChange,e=this._sclv_customRowHeightIndexesDidChange;if(a===b)return this;this._sclv_rowDelegate=b;if(a){a.removeObserver("rowHeight",this,c);a.removeObserver("customRowHeightIndexes",this,e)}if(!b)throw"Internal Inconsistancy: ListView must always have CollectionRowDelegate";b.addObserver("rowHeight",this,c);b.addObserver("customRowHeightIndexes",this,e);this._sclv_rowHeightDidChange()._sclv_customRowHeightIndexesDidChange();return this}.observes("rowDelegate"),
_sclv_rowHeightDidChange:function(){var a=this.get("rowDelegate").get("rowHeight");if(a===this._sclv_rowHeight)return this;this._sclv_rowHeight=a;this.rowHeightDidChangeForIndexes(SC.IndexSet.create(0,this.get("length")));return this},_sclv_customRowHeightIndexesDidChange:function(){var a=this.get("rowDelegate").get("customRowHeightIndexes"),b=this._sclv_customRowHeightIndexes,c=this._sclv_customRowHeightIndexesContentDidChange;if(a===b||b&&b.isEqual(a))return this;b&&this._sclv_isObservingCustomRowHeightIndexes&&
b.removeObserver("[]",this,c);if(this._sclv_isObservingCustomRowHeightIndexes=a&&!a.get("isFrozen"))a.addObserver("[]",this,c);this._sclv_customRowHeightIndexesContentDidChange();return this},_sclv_customRowHeightIndexesContentDidChange:function(){var a=this.get("rowDelegate").get("customRowHeightIndexes"),b=this._sclv_customRowHeightIndexes;b=a&&b?a.copy().add(b):a||b;this._sclv_customRowHeightIndexes=a?a.frozenCopy():null;this.rowHeightDidChangeForIndexes(b);return this},rowOffsetForContentIndex:function(a){if(a===
0)return 0;var b=this.get("rowDelegate"),c=b.get("rowHeight"),e,g,d,f,h;e=a*c;if(this.get("rowSpacing"))e+=a*this.get("rowSpacing");if(b.customRowHeightIndexes&&(g=b.get("customRowHeightIndexes"))){d=this._sclv_offsetCache;if(!d){d=this._sclv_offsetCache=[];f=h=0;g.forEach(function(i){f+=this.rowHeightForContentIndex(i)-c;d[i+1]=f;h=i},this);this._sclv_max=h+1}f=d[a];if(f===undefined){f=d[a]=d[a-1];if(f===undefined){h=this._sclv_max;if(a<h)h=g.indexBefore(a)+1;f=d[a]=d[h]||0}}e+=f}return e},rowHeightForContentIndex:function(a){var b=
this.get("rowDelegate"),c,e,g;if(b.customRowHeightIndexes&&(g=b.get("customRowHeightIndexes"))){c=this._sclv_heightCache;if(!c){c=this._sclv_heightCache=[];e=this.get("content");g.forEach(function(d){c[d]=b.contentIndexRowHeight(this,e,d)},this)}a=c[a];if(a===undefined)a=b.get("rowHeight")}else a=b.get("rowHeight");return a},rowHeightDidChangeForIndexes:function(a){var b=this.get("length");this._sclv_heightCache=this._sclv_offsetCache=null;if(a&&a.isIndexSet)a=a.get("min");this.reload(SC.IndexSet.create(a,
b-a));return this},computeLayout:function(){var a=this._sclv_layout;if(!a)a=this._sclv_layout={};a.minHeight=this.rowOffsetForContentIndex(this.get("length"))+4;this.calculatedHeight=a.minHeight;return a},layoutForContentIndex:function(a){return{top:this.rowOffsetForContentIndex(a),height:this.rowHeightForContentIndex(a),left:0,right:0}},contentIndexesInRect:function(a){var b=this.get("rowDelegate").get("rowHeight"),c=SC.minY(a),e=SC.maxY(a),g=a.height||0;a=this.get("length");var d,f;f=(c-c%b)/b;
for(d=this.rowOffsetForContentIndex(f);f>0&&d>=c;){f--;d-=this.rowHeightForContentIndex(f)}for(d+=this.rowHeightForContentIndex(f);f<a&&d<c;){d+=this.rowHeightForContentIndex(f);f++}if(f<0)f=0;if(f>=a)f=a;b=f+(g-g%b)/b;if(b>a)b=a;for(d=this.rowOffsetForContentIndex(b);b>=f&&d>=e;){b--;d-=this.rowHeightForContentIndex(b)}for(d+=this.rowHeightForContentIndex(b);b<a&&d<=e;){d+=this.rowHeightForContentIndex(b);b++}b++;if(b<f)b=f;if(b>a)b=a;return SC.IndexSet.create(f,b-f)},insertionPointView:SC.View.extend({classNames:"sc-list-insertion-point",
render:function(a,b){b&&a.push('<div class="anchor"></div>')}}),showInsertionPoint:function(a,b){var c=this._insertionPointView;if(!c)c=this._insertionPointView=this.get("insertionPointView").create();var e=a.get("contentIndex"),g=this.get("length"),d=SC.clone(a.get("layout")),f=a.get("outlineLevel"),h=a.get("outlineIndent")||0;if(e>=g&&e>0){e=this.itemViewForContentIndex(g-1);if(e.get("isGroupView")){f=1;h=e.get("outlineIndent")}}if(SC.none(f))f=-1;if(b&SC.DROP_ON){this.hideInsertionPoint();a.set("isSelected",
YES);this._lastDropOnView=a}else{if(this._lastDropOnView){this._lastDropOnView.set("isSelected",NO);this._lastDropOnView=null}if(b&SC.DROP_AFTER)d.top+=d.height;d.height=2;d.right=0;d.left=(f+1)*h+12;delete d.width;c.set("layout",d);this.appendChild(c)}},hideInsertionPoint:function(){if(this._lastDropOnView){this._lastDropOnView.set("isSelected",NO);this._lastDropOnView=null}var a=this._insertionPointView;a&&a.removeFromParent().destroy();this._insertionPointView=null},insertionIndexForLocation:function(a,
b){var c=this.contentIndexesInRect(a).get("min"),e=this.get("length"),g,d,f;if(SC.none(c)||c<0)if(e===0||a.y<=this.rowOffsetForContentIndex(0))c=0;else if(a.y>=this.rowOffsetForContentIndex(e))c=e;g=this.rowOffsetForContentIndex(c);d=g+this.rowHeightForContentIndex(c);if(b==SC.DROP_ON){f=this.get("isEditable")?Math.min(Math.floor((d-g)*0.2),5):0;if(a.y>=g+f||a.y<=d+f)return[c,SC.DROP_ON]}c<e&&a.y>=d-10&&c++;if(c>0){d=((f=this.itemViewForContentIndex(c-1))?f.get("outlineIndent"):0)||0;g=f?f.get("outlineLevel"):
0;if(c<e){a=(f=this.itemViewForContentIndex(c))?f.get("outlineLevel"):0;f=(f?f.get("outlineIndent"):0)||0;f*=a}else{a=f.get("isGroupView")?1:0;f=d*a}d*=g;if(a!==g&&f!==d)if(d>f){c--;b=SC.DROP_AFTER}}if(b===SC.DROP_BEFORE){f=c<e?this.itemViewForContentIndex(c):null;if(!f||f.get("isGroupView"))if(c>0){f=this.itemViewForContentIndex(c-1);if(!f.get("isGroupView")||f.get("disclosureState")===SC.BRANCH_OPEN){c-=1;b=SC.DROP_AFTER}else c=-1}else c=-1;if(c<0)b=SC.DRAG_NONE}return[c,b]},init:function(){arguments.callee.base.apply(this,
arguments);this._sclv_rowDelegateDidChange()}});sc_require("views/list");
SC.GridView=SC.ListView.extend({classNames:["sc-grid-view"],layout:{left:0,right:0,top:0,bottom:0},rowHeight:48,columnWidth:64,exampleView:SC.LabelView,insertionOrientation:SC.HORIZONTAL_ORIENTATION,itemsPerRow:function(){var a=this.get("frame"),b=this.get("columnWidth")||0;return b<=0?1:Math.floor(a.width/b)}.property("clippingFrame","columnWidth").cacheable(),contentIndexesInRect:function(a){var b=this.get("rowHeight")||48,c=this.get("itemsPerRow"),e=Math.floor(SC.minY(a)/b)*c;a=Math.ceil(SC.maxY(a)/
b)*c;return SC.IndexSet.create(e,a-e)},layoutForContentIndex:function(a){var b=this.get("rowHeight")||48,c=this.get("clippingFrame").width,e=this.get("itemsPerRow");c=Math.floor(c/e);var g=Math.floor(a/e);return{left:(a-e*g)*c,top:g*b,height:b,width:c}},computeLayout:function(){var a=this.get("content"),b=a?a.get("length"):0;a=this.get("rowHeight")||48;var c=this.get("itemsPerRow");b=Math.ceil(b/c);c=this._cachedLayoutHash;if(!c)c=this._cachedLayoutHash={};c.minHeight=b*a;this.calculatedHeight=c.minHeight;
return c},insertionPointClass:SC.View.extend({classNames:["grid-insertion-point"],render:function(a,b){b&&a.push('<span class="anchor"></span>')}}),showInsertionPoint:function(a,b){if(a)if(b===SC.DROP_ON){if(a!==this._dropOnInsertionPoint){this.hideInsertionPoint();a.addClassName("drop-target");this._dropOnInsertionPoint=a}}else{if(this._dropOnInsertionPoint){this._dropOnInsertionPoint.removeClassName("drop-target");this._dropOnInsertionPoint=null}if(!this._insertionPointView)this._insertionPointView=
this.insertionPointClass.create();b=this._insertionPointView;var c=a.get("frame");c={height:c.height-6,x:c.x,y:c.y+6,width:0};SC.rectsEqual(b.get("frame"),c)||b.set("frame",c);b.parentNode!=a.parentNode&&a.parentNode.appendChild(b)}},hideInsertionPoint:function(){var a=this._insertionPointView;a&&a.removeFromParent();if(this._dropOnInsertionPoint){this._dropOnInsertionPoint.removeClassName("drop-target");this._dropOnInsertionPoint=null}},insertionIndexForLocation:function(a,b){var c=this.get("frame"),
e=this.get("scrollFrame"),g=this.get("itemsPerRow"),d=Math.floor(c.width/g),f=Math.floor((a.y-c.y-e.y)/this.get("rowHeight")),h=SC.DROP_BEFORE;c=a.x-c.x-e.x;a=Math.floor(c/d);d=c/d-a;if(b===SC.DROP_ON){d>0.8&&a++;if(d>=0.2&&d<=0.8)h=SC.DROP_ON}else d>0.45&&a++;return[f*g+a,h]},_gv_clippingFrameDidChange:function(){var a=this.get("nowShowing"),b,c;this.notifyPropertyChange("itemsPerRow");c=a.get("length");for(b=0;b<c;b++){a=this.itemViewForContentIndex(b);a.adjust(this.layoutForContentIndex(b))}}.observes("clippingFrame")});
SC.NATURAL_SCROLLER_THICKNESS=16;
SC.ScrollerView=SC.View.extend({classNames:["sc-scroller-view"],scrollerThickness:SC.NATURAL_SCROLLER_THICKNESS,value:function(a,b){if(b!==undefined){if(b>=0)this._value=b}else return Math.min(this._value||0,this.get("maximum"))}.property("maximum").cacheable(),maximum:0,isEnabled:YES,layoutDirection:SC.LAYOUT_VERTICAL,ownerScrollValueKey:function(){var a=null;switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:a="verticalScrollOffset";break;case SC.LAYOUT_HORIZONTAL:a="horizontalScrollOffset";
break;default:a=null}return a}.property("layoutDirection").cacheable(),displayProperties:"maximum isEnabled layoutDirection".w(),render:function(a,b){var c=this.get("maximum");switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:a.addClass("sc-vertical");if(b)a.push('<div class="sc-inner" style="height: %@px;">&nbsp;</div>'.fmt(c));else this.$("div")[0].style.height=c+"px";break;case SC.LAYOUT_HORIZONTAL:a.addClass("sc-horizontal");if(b)a.push('<div class="sc-inner" style="width: %@px;">&nbsp;</div>'.fmt(c));
else this.$("div")[0].style.width=c+"px";break;default:throw"You must set a layoutDirection for your scroller class.";}a.setClass("disabled",!this.get("isEnabled"))},didCreateLayer:function(){var a=this._sc_scroller_scrollDidChange;SC.Event.add(this.$(),"scroll",this,a);a=this.get("value");var b=this.get("layer");switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:b.scrollTop=a;break;case SC.LAYOUT_HORIZONTAL:b.scrollLeft=a;break}},willDestroyLayer:function(){var a=this._sc_scroller_scrollDidChange;
SC.Event.remove(this.$(),"scroll",this,a)},_sc_scroller_armScrollTimer:function(){if(!this._sc_scrollTimer){SC.RunLoop.begin();this._sc_scrollTimer=this.invokeLater(this._sc_scroller_scrollDidChange,50);SC.RunLoop.end()}},_sc_scroller_scrollDidChange:function(){var a=Date.now(),b=this._sc_lastScroll;if(b&&a-b<50)return this._sc_scroller_armScrollTimer();this._sc_scrollTimer=null;this._sc_lastScroll=a;SC.RunLoop.begin();if(this.get("isEnabled")){a=this.get("layer");b=0;switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:this._sc_scrollValue=
b=a.scrollTop;break;case SC.LAYOUT_HORIZONTAL:this._sc_scrollValue=b=a.scrollLeft;break}this.set("value",b);SC.RunLoop.end()}},_sc_scroller_valueDidChange:function(){var a=this.get("value");if(a!==this._sc_scrollValue){var b=this.get("layer");if(b)switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:b.scrollTop=a;break;case SC.LAYOUT_HORIZONTAL:b.scrollLeft=a;break}}}.observes("value")});sc_require("views/scroller");sc_require("mixins/border");
SC.ScrollView=SC.View.extend(SC.Border,{classNames:["sc-scroll-view"],isScrollable:YES,contentView:null,horizontalScrollOffset:0,verticalScrollOffset:0,maximumHorizontalScrollOffset:function(){if(!this.get("canScrollHorizontal"))return 0;var a=this.get("contentView"),b=a?a.get("frame").width:0;if(a.calculatedWidth&&a.calculatedWidth!==0)b=a.calculatedWidth;a=this.get("containerView").get("frame").width;return Math.max(0,b-a)}.property(),maximumVerticalScrollOffset:function(){if(!this.get("canScrollVertical"))return 0;
var a=this.get("contentView"),b=a&&a.get("frame")?a.get("frame").height:0;if(a.calculatedHeight&&a.calculatedHeight!==0)b=a.calculatedHeight;a=this.get("containerView").get("frame").height;return Math.max(0,b-a)}.property(),verticalLineScroll:20,horizontalLineScroll:20,verticalPageScroll:function(){return this.get("frame").height}.property("frame"),horizontalPageScroll:function(){return this.get("frame").width}.property("frame"),hasHorizontalScroller:YES,horizontalScrollerView:SC.ScrollerView,isHorizontalScrollerVisible:YES,
canScrollHorizontal:function(){return!!(this.get("hasHorizontalScroller")&&this.get("horizontalScrollerView")&&this.get("isHorizontalScrollerVisible"))}.property("isHorizontalScrollerVisible").cacheable(),autohidesHorizontalScroller:YES,hasVerticalScroller:YES,verticalScrollerView:SC.ScrollerView,isVerticalScrollerVisible:YES,canScrollVertical:function(){return!!(this.get("hasVerticalScroller")&&this.get("verticalScrollerView")&&this.get("isVerticalScrollerVisible"))}.property("isVerticalScrollerVisible").cacheable(),
autohidesVerticalScroller:YES,verticalScrollerBottom:0,containerView:SC.ContainerView,scrollTo:function(a,b){if(b===undefined&&SC.typeOf(a)===SC.T_HASH){b=a.y;a=a.x}if(!SC.none(a)){a=Math.max(0,Math.min(this.get("maximumHorizontalScrollOffset"),a));this.set("horizontalScrollOffset",a)}if(!SC.none(b)){b=Math.max(0,Math.min(this.get("maximumVerticalScrollOffset"),b));this.set("verticalScrollOffset",b)}return this},scrollBy:function(a,b){if(b===undefined&&SC.typeOf(a)===SC.T_HASH){b=a.y;a=a.x}a=a?this.get("horizontalScrollOffset")+
a:null;b=b?this.get("verticalScrollOffset")+b:null;return this.scrollTo(a,b)},scrollToVisible:function(a){if(arguments.length===0)return arguments.callee.base.apply(this,arguments);var b=this.get("contentView");if(!b)return NO;var c=a.get("frame");if(!c)return NO;c=b.convertFrameFromView(c,a.get("parentView"));b=SC.cloneRect(this.get("containerView").get("frame"));b.x=this.get("horizontalScrollOffset");b.y=this.get("verticalScrollOffset");var e=b.x,g=b.y;b.y-=Math.max(0,SC.minY(b)-SC.minY(c));b.x-=
Math.max(0,SC.minX(b)-SC.minX(c));b.y+=Math.max(0,SC.maxY(c)-SC.maxY(b));b.x+=Math.max(0,SC.maxX(c)-SC.maxX(b));if(e!==b.x||g!==b.y){this.scrollTo(b.x,b.y);return YES}else return NO},scrollDownLine:function(a){if(a===undefined)a=1;return this.scrollBy(null,this.get("verticalLineScroll")*a)},scrollUpLine:function(a){if(a===undefined)a=1;return this.scrollBy(null,0-this.get("verticalLineScroll")*a)},scrollRightLine:function(a){if(a===undefined)a=1;return this.scrollTo(this.get("horizontalLineScroll")*
a,null)},scrollLeftLine:function(a){if(a===undefined)a=1;return this.scrollTo(0-this.get("horizontalLineScroll")*a,null)},scrollDownPage:function(a){if(a===undefined)a=1;return this.scrollBy(null,this.get("verticalPageScroll")*a)},scrollUpPage:function(a){if(a===undefined)a=1;return this.scrollBy(null,0-this.get("verticalPageScroll")*a)},scrollRightPage:function(a){if(a===undefined)a=1;return this.scrollBy(this.get("horizontalPageScroll")*a,null)},scrollLeftPage:function(a){if(a===undefined)a=1;return this.scrollBy(0-
this.get("horizontalPageScroll")*a,null)},tile:function(){var a=this.get("hasHorizontalScroller")?this.get("horizontalScrollerView"):null,b=a&&this.get("isHorizontalScrollerVisible"),c=this.get("hasVerticalScroller")?this.get("verticalScrollerView"):null,e=c&&this.get("isVerticalScrollerVisible"),g=this.get("containerView"),d={left:0,top:0},f=b?a.get("scrollerThickness"):0,h=e?c.get("scrollerThickness"):0;if(b){a.set("layout",{left:0,bottom:0,right:h-1,height:f});d.bottom=f-1}else d.bottom=0;a&&a.set("isVisible",
b);if(e){f+=this.get("verticalScrollerBottom");c.set("layout",{top:0,bottom:f,right:0,width:h});d.right=h-1}else d.right=0;c&&c.set("isVisible",e);g.set("layout",d)},scrollerVisibilityDidChange:function(){this.tile()}.observes("isVerticalScrollerVisible","isHorizontalScrollerVisible"),_scroll_wheelDeltaX:0,_scroll_wheelDeltaY:0,mouseWheel:function(a){this._scroll_wheelDeltaX+=a.wheelDeltaX;this._scroll_wheelDeltaY+=a.wheelDeltaY;this.invokeLater(this._scroll_mouseWheel,10);return this.get("canScrollHorizontal")||
this.get("canScrollVertical")},_scroll_mouseWheel:function(){this.scrollBy(this._scroll_wheelDeltaX,this._scroll_wheelDeltaY);this._scroll_wheelDeltaX=this._scroll_wheelDeltaY=0},createChildViews:function(){var a=[],b;if(SC.none(b=this.containerView))b=SC.ContainerView;a.push(this.containerView=this.createChildView(b,{contentView:this.contentView}));this.contentView=this.containerView.get("contentView");if(b=this.horizontalScrollerView)if(this.get("hasHorizontalScroller")){b=this.horizontalScrollerView=
this.createChildView(b,{layoutDirection:SC.LAYOUT_HORIZONTAL,valueBinding:"*owner.horizontalScrollOffset"});a.push(b)}else this.horizontalScrollerView=null;if(b=this.verticalScrollerView)if(this.get("hasVerticalScroller")){b=this.verticalScrollerView=this.createChildView(b,{layoutDirection:SC.LAYOUT_VERTICAL,valueBinding:"*owner.verticalScrollOffset"});a.push(b)}else this.verticalScrollerView=null;this.childViews=a;this.contentViewDidChange();this.tile()},init:function(){arguments.callee.base.apply(this,
arguments);var a=this._scroll_contentView=this.get("contentView");a&&a.addObserver("frame",this,this.contentViewFrameDidChange);this.get("isVisibleInWindow")&&this._scsv_registerAutoscroll()},_scsv_registerAutoscroll:function(){this.get("isVisibleInWindow")?SC.Drag.addScrollableView(this):SC.Drag.removeScrollableView(this)}.observes("isVisibleInWindow"),contentViewDidChange:function(){var a=this.get("contentView"),b=this._scroll_contentView,c=this.contentViewFrameDidChange;if(a!==b){b&&b.removeObserver("frame",
this,c);(this._scroll_contentView=a)&&a.addObserver("frame",this,c);this.containerView.set("contentView",a);this.contentViewFrameDidChange()}}.observes("contentView"),oldMaxHOffset:0,oldMaxVOffset:0,contentViewFrameDidChange:function(){var a=this.get("contentView"),b=a?a.get("frame"):null,c=b?b.width:0;b=b?b.height:0;var e=this.get("frame");this._scroll_contentWidth=c;this._scroll_contentHeight=b;if(this.get("hasHorizontalScroller")&&(a=this.get("horizontalScrollerView"))){c-=1;this.get("autohidesHorizontalScroller")&&
this.set("isHorizontalScrollerVisible",c>e.width);a.setIfChanged("maximum",c)}if(this.get("hasVerticalScroller")&&(a=this.get("verticalScrollerView"))){b-=1;this.get("autohidesVerticalScroller")&&this.set("isVerticalScrollerVisible",b>e.height);b-=this.get("verticalScrollerBottom");a.setIfChanged("maximum",b)}!this.get("isVerticalScrollerVisible")&&this.get("verticalScrollOffset")!==0&&this.get("autohidesVerticalScroller")&&this.set("verticalScrollOffset",0);!this.get("isHorizontalScrollerVisible")&&
this.get("horizontalScrollOffset")!==0&&this.get("autohidesHorizontalScroller")&&this.set("horizontalScrollOffset",0);e=this.get("maximumVerticalScrollOffset");a=this.get("verticalScrollOffset");b=this.get("maximumHorizontalScrollOffset");c=this.get("horizontalScrollOffset");e=e<a;b=b<c;if(e||b)this.forceDimensionsRecalculation(b,e,a,c)},_scroll_horizontalScrollOffsetDidChange:function(){var a=this.get("horizontalScrollOffset");a=Math.max(0,Math.min(this.get("maximumHorizontalScrollOffset"),a));var b=
this.get("contentView");b&&b.adjust("left",0-a)}.observes("horizontalScrollOffset"),_scroll_verticalScrollOffsetDidChange:function(){var a=this.get("verticalScrollOffset");a=Math.max(0,Math.min(this.get("maximumVerticalScrollOffset"),a));var b=this.get("contentView");this.get("containerView");b&&b.adjust("top",0-a)}.observes("verticalScrollOffset"),forceDimensionsRecalculation:function(a,b,c,e){this.scrollTo(0,0);a&&b&&this.scrollTo(this.get("maximumHorizontalScrollOffset"),this.get("maximumVerticalScrollOffset"));
a&&!b&&this.scrollTo(this.get("maximumHorizontalScrollOffset"),c);!a&&b&&this.scrollTo(e,this.get("maximumVerticalScrollOffset"))}});sc_require("views/scroll");
SC.MenuScrollerView=SC.ScrollerView.extend({classNames:["sc-menu-scroller-view"],scrollDown:NO,value:function(a,b){if(b!==undefined)this._value=b;else return Math.min(this._value||0,this.get("maximum"))}.property("maximum").cacheable(),maximum:0,isEnabled:YES,layoutDirection:SC.LAYOUT_VERTICAL,verticalLineScroll:20,ownerScrollValueKey:function(){return"verticalScrollOffset"}.property("layoutDirection").cacheable(),render:function(a,b){a.addClass("sc-vertical");if(b)this.get("scrollDown")?a.push('<span class="arrowDown">&nbsp;</span>'):
a.push('<span class="arrowUp">&nbsp;</span>');a.setClass("disabled",!this.get("isEnabled"))},didCreateLayer:function(){var a;a=this._sc_scroller_scrollDidChange;SC.Event.add(this.$(),"scroll",this,a);a=this.get("value");this.get("layer").scrollTop=a},willDestroyLayer:function(){var a=this._sc_scroller_scrollDidChange;SC.Event.remove(this.$(),"scroll",this,a)},mouseEntered:function(){this.set("isMouseOver",YES);this._invokeScrollOnMouseOver()},mouseExited:function(){this.set("isMouseOver",NO)},_sc_scroller_valueDidChange:function(){}.observes("value"),
_sc_scroller_armScrollTimer:function(){if(!this._sc_scrollTimer){SC.RunLoop.begin();this._sc_scrollTimer=this.invokeLater(this._sc_scroller_scrollDidChange,50);SC.RunLoop.end()}},_sc_scroller_scrollDidChange:function(){var a=Date.now(),b=this._sc_lastScroll,c=this.get("layer"),e=0;if(b&&a-b<50)return this._sc_scroller_armScrollTimer();this._sc_scrollTimer=null;this._sc_lastScroll=a;SC.RunLoop.begin();if(this.get("isEnabled")){this._sc_scrollValue=e=c.scrollTop;this.set("value",e);SC.RunLoop.end()}},
_scrollMenu:function(){var a=this.get("value"),b;if(this.get("scrollDown")){b=a+this.verticalLineScroll;b<=this.get("maximum")&&this.set("value",b)}else{b=a-this.verticalLineScroll;if(b>=0)this.set("value",b);else a<=this.verticalLineScroll&&a>0&&this.set("value",0)}return YES},_invokeScrollOnMouseOver:function(){this._scrollMenu();this.get("isMouseOver")&&this.invokeLater(this._invokeScrollOnMouseOver,50)}});
SC.MenuScrollView=SC.ScrollView.extend({classNames:["sc-menu-scroll-view"],maximumHorizontalScrollOffset:function(){}.property(),hasHorizontalScroller:NO,horizontalScrollerView:SC.MenuScrollerView,isHorizontalScrollerVisible:NO,canScrollHorizontal:function(){return false}.property("isHorizontalScrollerVisible").cacheable(),autohidesHorizontalScroller:NO,hasVerticalScroller:YES,verticalScrollerView:SC.MenuScrollerView,verticalScrollerView2:SC.MenuScrollerView,isVerticalScrollerVisible:YES,canScrollVertical:function(){return YES}.property("isVerticalScrollerVisible").cacheable(),
autohidesVerticalScroller:YES,verticalScrollerBottom:0,containerView:SC.ContainerView,tile:function(){var a,b,c,e,g,d;b=(a=this.get("hasVerticalScroller"))?this.get("verticalScrollerView"):null;a=a?this.get("verticalScrollerView2"):null;c=b&&this.get("isVerticalScrollerVisible");e=this.get("containerView");g={left:0,top:0};if(c){d=0;var f=this.get("contentView");f=(f=f?f.get("frame"):null)?f.height:0;var h=this.containerView.$()[0],i=this.get("verticalScrollOffset"),j={height:0,top:0,right:0,left:0},
k={height:this.verticalLineScroll,top:0,right:0,left:0},l={height:this.verticalLineScroll,bottom:0,right:0,left:0},o={height:0,bottom:0,right:0,left:0};if(h)d=h.offsetHeight;if(i===0){g.top=0;g.bottom=this.verticalLineScroll;b.set("layout",j);a.set("layout",l)}else if(i>=f-d-this.verticalLineScroll){g.top=this.verticalLineScroll;g.bottom=0;b.set("layout",k);a.set("layout",o)}else{g.top=this.verticalLineScroll;g.bottom=this.verticalLineScroll;b.set("layout",k);a.set("layout",l)}}if(b){b.set("isVisible",
c);a.set("isVisible",c)}e.set("layout",g)},scrollerVisibilityDidChange:function(){this.tile()}.observes("isVerticalScrollerVisible","isHorizontalScrollerVisible","verticalScrollOffset"),createChildViews:function(){var a=[],b,c;if(SC.none(b=this.containerView))b=SC.ContainerView;a.push(this.containerView=this.createChildView(b,{contentView:this.contentView}));this.contentView=this.containerView.get("contentView");if((b=this.verticalScrollerView)&&(c=this.verticalScrollerView2))if(this.get("hasVerticalScroller")){b=
this.verticalScrollerView=this.createChildView(b,{layout:{top:0,left:0,right:0,height:this.verticalLineScroll},valueBinding:"*owner.verticalScrollOffset"});a.push(b);c=this.verticalScrollerView2=this.createChildView(c,{scrollDown:YES,layout:{bottom:0,left:0,right:0,height:this.verticalLineScroll},valueBinding:"*owner.verticalScrollOffset"});a.push(c)}else this.verticalScrollerView2=this.verticalScrollerView=null;this.childViews=a;this.contentViewFrameDidChange();this.tile()},init:function(){arguments.callee.base.apply(this,
arguments);var a=this._scroll_contentView=this.get("contentView");a&&a.addObserver("frame",this,this.contentViewFrameDidChange);this.get("isVisibleInWindow")&&this._scsv_registerAutoscroll()},_scsv_registerAutoscroll:function(){this.get("isVisibleInWindow")?SC.Drag.addScrollableView(this):SC.Drag.removeScrollableView(this)}.observes("isVisibleInWindow"),contentViewDidChange:function(){var a=this.get("contentView"),b=this._scroll_contentView,c=this.contentViewFrameDidChange;if(a!==b){b&&b.removeObserver("frame",
this,c);(this._scroll_contentView=a)&&a.addObserver("frame",this,c);this.containerView.set("content",a);this.contentViewFrameDidChange()}}.observes("contentView"),contentViewFrameDidChange:function(){var a=this.get("contentView"),b,c=a?a.get("frame"):null,e=c?c.width:0;c=c?c.height:0;var g=this.get("frame");this._scroll_contentWidth=e;this._scroll_contentHeight=c;if(this.get("hasVerticalScroller")&&(a=this.get("verticalScrollerView"))&&(b=this.get("verticalScrollerView2"))){c-=1;this.get("autohidesVerticalScroller")&&
this.set("isVerticalScrollerVisible",c>g.height);c-=this.get("verticalScrollerBottom");e=0;if(g=this.containerView.$()[0])e=g.offsetHeight;c-=e;a.setIfChanged("maximum",c);b.setIfChanged("maximum",c)}},_scroll_horizontalScrollOffsetDidChange:function(){}.observes("horizontalScrollOffset"),_scroll_verticalScrollOffsetDidChange:function(){var a=this.get("verticalScrollOffset"),b=this.get("contentView");b&&b.adjust("top",0-a)}.observes("verticalScrollOffset")});sc_require("views/button");
SC.PopupButtonView=SC.ButtonView.extend({keyEquivalent:null,classNames:["sc-popup-button"],preferMatrix:null,acceptsFirstResponder:YES,isSelected:NO,performKeyEquivalent:function(a,b){if(!this.get("isEnabled"))return NO;var c=this.get("menu");return!!c&&c.performKeyEquivalent(a,b)},menu:null,isSelectedBinding:"*menu.isVisibleInWindow",action:function(){var a=this.get("menu");if(!a)return NO;a.popup(this,this.preferMatrix);return YES},mouseDown:function(){if(!this.get("isEnabled"))return YES;this.set("isActive",
YES);this._isMouseDown=YES;this._action();return YES}});
SC.ProgressView=SC.View.extend(SC.Control,{value:0.5,valueBindingDefault:SC.Binding.single().notEmpty(),minimum:0,minimumBindingDefault:SC.Binding.single().notEmpty(),contentMinimumKey:null,maximum:1,maximumBindingDefault:SC.Binding.single().notEmpty(),offsetRange:24,contentMaximumKey:null,isIndeterminate:NO,isIndeterminateBindingDefault:SC.Binding.bool(),isRunning:NO,isRunningBindingDefault:SC.Binding.bool(),animatedBackgroundMatrix:[],contentIsIndeterminateKey:null,classNames:"sc-progress-view",
_backgroundOffset:0,_currentBackground:1,_nextBackground:1,init:function(){arguments.callee.base.apply(this,arguments);this.animateProgressBar()},animateProgressBar:function(){this.get("isRunning")&&this.get("isVisibleInWindow")&&this._animateProgressBar(500)}.observes("isRunning","isVisibleInWindow"),_animateProgressBar:function(a){if(a===0)a=1E3/30;if(this.get("isRunning")&&this.get("isVisibleInWindow")){this.displayDidChange();this.invokeLater(this._animateProgressBar,a,0)}},displayProperties:"value minimum maximum isIndeterminate".w(),
render:function(a,b){var c=this.get("isIndeterminate"),e=this.get("isRunning"),g=this.get("isEnabled"),d=this.get("offsetRange");e=c&&e?Math.floor(Date.now()/75)%d-d:0;if(g)if(c)g="120%";else{d=this.get("minimum")||0;var f=this.get("maximum")||1;g=this.get("value")||0;g=(g-d)/(f-d);if(g>1)g=1;if(isNaN(g))g=0;if(g<d)g=0;if(g>f)g=1;g=g*100+"%"}else g="0%";c={"sc-indeterminate":c,"sc-empty":g<=0,"sc-complete":g>=100};if(b){b=this._createClassNameString(c);a.push('<div class="sc-inner ',b,'" style="width: ',
g,";left: ",e,'">');a.push('<div class="sc-inner-head"></div><div class="sc-inner-tail"></div></div><div class="sc-outer-head"></div><div class="sc-outer-tail"></div>')}else{a.setClass(c);a=this.$(".sc-inner");b=this.get("animatedBackgroundMatrix");a.css("width",g).css("left",e);if(b.length===3){a.css("backgroundPosition","0px -"+(b[0]+b[1]*this._currentBackground)+"px");if(this._currentBackground===b[2]-1||this._currentBackground===0)this._nextBackground*=-1;this._currentBackground+=this._nextBackground}}},
contentPropertyDidChange:function(a,b){a=this.get("content");this.beginPropertyChanges().updatePropertyFromContent("value",b,"contentValueKey",a).updatePropertyFromContent("minimum",b,"contentMinimumKey",a).updatePropertyFromContent("maximum",b,"contentMaximumKey",a).updatePropertyFromContent("isIndeterminate",b,"contentIsIndeterminateKey",a).endPropertyChanges()},_createClassNameString:function(a){var b=[],c;for(c in a)a.hasOwnProperty(c)&&a[c]&&b.push(c);return b.join(" ")}});
SC.RadioView=SC.FieldView.extend({classNames:["sc-radio-view"],value:null,layoutDirection:SC.LAYOUT_VERTICAL,escapeHTML:YES,items:[],itemTitleKey:null,itemValueKey:null,itemIsEnabledKey:null,itemIconKey:null,displayItems:function(){var a=this.get("items"),b=this.get("localize"),c=this.get("itemTitleKey"),e=this.get("itemValueKey"),g=this.get("itemIsEnabledKey"),d=this.get("itemIconKey"),f=[],h=a?a.get("length"):0,i,j,k,l,o,n;for(l=0;l<h;l++){i=a.objectAt(l);if(SC.typeOf(i)===SC.T_ARRAY){j=i[0];k=
i[1]}else if(i){j=c?i.get?i.get(c):i[c]:i.toString?i.toString():null;k=e?i.get?i.get(e):i[e]:i;o=g?i.get?i.get(g):i[g]:YES;n=d?i.get?i.get(d):i[d]:null}else{j=k=n=null;o=NO}if(b)j=j.loc();f.push([j,k,o,n])}return f}.property("items","itemTitleKey","itemValueKey","itemIsEnabledKey","localize","itemIconKey").cacheable(),itemsDidChange:function(){this._items&&this._items.removeObserver("[]",this,this.itemContentDidChange);(this._items=this.get("items"))&&this._items.addObserver("[]",this,this.itemContentDidChange);
this.itemContentDidChange()}.observes("items"),itemContentDidChange:function(){this.notifyPropertyChange("displayItems")},$input:function(){return this.$("input")},displayProperties:["value","displayItems"],render:function(a,b){var c,e,g,d,f,h,i,j,k=this.get("displayItems"),l=this.get("value"),o=SC.isArray(l);a.addClass(this.get("layoutDirection"));if(o&&l.length<=0){l=l[0];o=NO}if(b){b=SC.guidFor(this);d=k.length;for(e=0;e<d;e++){c=k[e];if(g=c[3]){f=g.indexOf("/")>=0?g:SC.BLANK_IMAGE_URL;g=f===g?
"":g;g='<img src="%@" class="icon %@" alt="" />'.fmt(f,g)}else g="";j=this._getSelectionState(c,l,o,false);f=!c[2]||!this.get("isEnabled")?'disabled="disabled" ':"";h=this.escapeHTML?SC.RenderContext.escapeHTML(c[0]):c[0];a.push('<label class="sc-radio-button ',j,'">');a.push('<input type="radio" value="',e,'" name="',b,'" ',f,"/>");a.push('<span class="button"></span>');a.push('<span class="sc-button-label">',g,h,"</span></label>")}this._field_setFieldValue(this.get("value"))}else this.$input().forEach(function(n){n=
this.$(n);e=parseInt(n.val(),0);c=e>=0?k[e]:null;n.attr("disabled",!c[2]?"disabled":null);i=this._getSelectionState(c,l,o,true);n.parent().setClass(i);e=i=null},this)},_getSelectionState:function(a,b,c,e){var g;b=a?c?b.indexOf(a[1])>=0:b===a[1]:NO;a={sel:b&&!c,mixed:b&&c,disabled:!a[2]};if(e)return a;else{e=[];for(g in a)a.hasOwnProperty(g)&&a[g]&&e.push(g);return e.join(" ")}},getFieldValue:function(){var a=this.$input().filter(function(){return this.checked}).val();return(a=this.get("displayItems")[parseInt(a,
0)])?a[1]:this._mixedValue},setFieldValue:function(a){if(SC.isArray(a))if(a.get("length")>1){this._mixedValue=a;a=undefined}else a=a.objectAt(0);var b,c;if(a===undefined)c=-1;else{b=this.get("displayItems");c=b.indexOf(b.find(function(e){return e[1]===a}))}this.$input().forEach(function(e){e=SC.$(e);e.attr("checked",parseInt(e.val(),0)===c)});return this},didCreateLayer:function(){this.setFieldValue(this.get("fieldValue"));for(var a=this.$input(),b=0,c=a.length;b<c;b++)SC.Event.add(a[b],"click",this,
this._field_fieldValueDidChange)},willDestroyLayer:function(){for(var a=0,b=this.$input().length;a<b;a++)SC.Event.remove(this.$input()[a],"click",this,this._field_fieldValueDidChange)},mouseDown:function(){this.set("isActive",YES);return this._field_isMouseDown=YES}});
SC.SceneView=SC.ContainerView.extend({scenes:["master","detail"],nowShowing:null,transitionDuration:200,_state:"NO_VIEW",replaceContent:function(a){a&&this._state===this.READY?this.animateScene(a):this.replaceScene(a);return this},replaceScene:function(a){var b=this._targetView,c=this.STANDARD_LAYOUT,e=this.get("scenes");e=e?e.indexOf(this.get("nowShowing")):-1;this._targetView=a;this._targetIndex=e;this._timer&&this._timer.invalidate();this._timer=this._leftView=this._rightView=this._start=this._end=
null;this.removeAllChildren();b&&b.set("layout",c);a&&a.set("layout",c);a&&this.appendChild(a);this._state=a?this.READY:this.NO_VIEW},animateScene:function(a){var b=this._targetView,c=this._targetIndex,e=this.get("scenes");e=e?e.indexOf(this.get("nowShowing")):-1;if(c<0||e<0||c===e)return this.replaceScene(a);this._targetView=a;this._targetIndex=e;if(e>c){this._leftView=b;this._rightView=a;this._target=-1}else{this._leftView=a;this._rightView=b;this._target=1}this.removeAllChildren();b&&this.appendChild(b);
a&&this.appendChild(a);this._start=Date.now();this._end=this._start+this.get("transitionDuration");this._state=this.ANIMATING;this.tick()},tick:function(){this._timer=null;var a=(Date.now()-this._start)/(this._end-this._start),b=this._target,c=this._leftView,e=this._rightView,g;if(a<0)a=0;if(!this.get("isVisibleInWindow")||a>=1)return this.replaceScene(this._targetView);g=SC.clone(this.get("frame"));a=Math.floor(g.width*a);if(b>0){g.left=0-(g.width-a);c.set("layout",g);g=SC.clone(g);g.left=a}else{g.left=
0-a;c.set("layout",g);g=SC.clone(g);g.left=g.width-a}e.set("layout",g);this._timer=this.invokeLater(this.tick,20);return this},NO_VIEW:"NO_VIEW",ANIMATING:"ANIMATING",READY:"READY",STANDARD_LAYOUT:{top:0,left:0,bottom:0,right:0}});
SC.SegmentedView=SC.View.extend(SC.Control,{classNames:["sc-segmented-view"],value:null,isEnabled:YES,allowsEmptySelection:NO,allowsMultipleSelection:NO,localize:YES,layoutDirection:SC.LAYOUT_HORIZONTAL,items:[],itemTitleKey:null,itemValueKey:null,itemIsEnabledKey:null,itemIconKey:null,itemWidthKey:null,itemActionKey:null,itemTargetKey:null,itemKeyEquivalentKey:null,itemKeys:"itemTitleKey itemValueKey itemIsEnabledKey itemIconKey itemWidthKey itemToolTipKey".w(),displayItems:function(){var a=this.get("items"),
b=this.get("localize"),c=null,e,g,d=[],f=a.get("length"),h,i,j=SC._segmented_fetchKeys,k=SC._segmented_fetchItem;for(h=0;h<f;h++){i=a.objectAt(h);if(!SC.none(i)){e=SC.typeOf(i);if(e===SC.T_STRING)g=[i.humanize().titleize(),i,YES,null,null,null,h];else if(e!==SC.T_ARRAY){if(c===null)c=this.itemKeys.map(j,this);g=c.map(k,i);g[g.length]=h;if(!c[0]&&i.toString)g[0]=i.toString();c[1]||(g[1]=i);c[2]||(g[2]=YES)}if(b&&g[0])g[0]=g[0].loc();if(b&&g[5]&&SC.typeOf(g[5])===SC.T_STRING)g[5]=g[5].loc();d[d.length]=
g}}return d}.property("items","itemTitleKey","itemValueKey","itemIsEnabledKey","localize","itemIconKey","itemWidthKey","itemToolTipKey").cacheable(),itemsDidChange:function(){this._items&&this._items.removeObserver("[]",this,this.itemContentDidChange);(this._items=this.get("items"))&&this._items.addObserver("[]",this,this.itemContentDidChange);this.itemContentDidChange()}.observes("items"),itemContentDidChange:function(){this.notifyPropertyChange("displayItems")},init:function(){arguments.callee.base.apply(this,
arguments);this.itemsDidChange()},displayProperties:["displayItems","value","activeIndex"],render:function(a,b){var c=this.get("displayItems"),e=this._seg_displayItems;if(b||c!==e){this._seg_displayItems=c;this.renderDisplayItems(a,c);a.addStyle("text-align","center")}else{a=this.get("activeIndex");b=this.get("value");if((e=SC.isArray(b))&&b.get("length")===1){b=b.objectAt(0);e=NO}for(var g={},d=c.length,f=this.$("a.sc-segment"),h;--d>=0;){h=c[d];g.sel=e?b.indexOf(h[1])>=0:h[1]===b;g.active=a===d;
SC.$(f.get(d)).setClass(g)}}},renderDisplayItems:function(a,b){var c=this.get("value"),e=SC.isArray(c),g=this.get("activeIndex"),d=b.length,f,h,i,j,k,l;for(l=0;l<d;l++){j=a.begin("a").attr("href","javascript:;");k=b[l];f=k[0];h=k[3];i=k[5];j.addStyle("display","inline-block");j.addClass("sc-segment");k[2]||j.addClass("disabled");l===0&&j.addClass("sc-first-segment");l===d-1&&j.addClass("sc-last-segment");l!==0&&l!==d-1&&j.addClass("sc-middle-segment");if(e?c.indexOf(k[1])>=0:k[1]===c)j.addClass("sel");
g===l&&j.addClass("active");if(k[4]){k=k[4];j.addStyle("width",k+"px")}i&&j.attr("title",i);if(h){i=h.indexOf("/")>=0?h:SC.BLANK_IMAGE_URL;h=i===h?"":h;h='<img src="'+i+'" alt="" class="icon '+h+'" />'}else h="";j.push('<span class="sc-button-inner"><label class="sc-button-label">');j.push(h+f);j.push("</label></span>");j.end()}},displayItemIndexForEvent:function(a){a=SC.$(a.target);if(!a||a===document)return-1;for(var b=this.$(),c=null;!c&&a.length>0&&a.get(0)!==b.get(0);)if(a.hasClass("sc-segment")&&
a.attr("tagName")==="A")c=a;else a=a.parent();return c?this.$("a.sc-segment").index(c):-1},keyDown:function(a){var b,c,e,g,d;if(a.which===9){(a.shiftKey?this.get("previousValidKeyView"):this.get("nextValidKeyView")).becomeFirstResponder();return YES}if(!this.get("allowsMultipleSelection")&&!this.get("allowsEmptySelection")){c=this.get("displayItems");e=c.length;g=this.get("value");d=SC.isArray(g);if(a.which===39||a.which===40){for(a=0;a<e-1;a++){b=c[a];if(d?g.indexOf(b[1])>=0:b[1]===g)this.triggerItemAtIndex(a+
1)}return YES}else if(a.which===37||a.which===38){for(a=1;a<e;a++){b=c[a];if(d?g.indexOf(b[1])>=0:b[1]===g)this.triggerItemAtIndex(a-1)}return YES}}return YES},mouseDown:function(a){if(!this.get("isEnabled"))return YES;a=this.displayItemIndexForEvent(a);if(a>=0){this._isMouseDown=YES;this.set("activeIndex",a)}return YES},mouseUp:function(a){a=this.displayItemIndexForEvent(a);this._isMouseDown&&a>=0&&this.triggerItemAtIndex(a);this._isMouseDown=NO;this.set("activeIndex",-1);return YES},mouseMoved:function(a){a=
this.displayItemIndexForEvent(a);this._isMouseDown&&this.set("activeIndex",a);return YES},mouseOver:function(a){a=this.displayItemIndexForEvent(a);this._isMouseDown&&this.set("activeIndex",a);return YES},mouseOut:function(){this._isMouseDown&&this.set("activeIndex",-1);return YES},triggerItemAtIndex:function(a){a=this.get("displayItems").objectAt(a);var b,c,e,g,d;if(!a[2])return this;g=this.get("allowsEmptySelection");d=this.get("allowsMultipleSelection");b=a[1];c=e=this.get("value");SC.isArray(c)||
(c=[c]);if(d)if(c.indexOf(b)>=0){if(c.get("length")>1||c.objectAt(0)!==b||g)c=c.without(b)}else c=c.concat([b]);else c=g&&c.get("length")===1&&c.objectAt(0)===b?[]:[b];switch(c.get("length")){case 0:c=null;break;case 1:c=c.objectAt(0);break;default:break}b=this.get("itemActionKey");g=this.get("itemTargetKey");var f;d=null;var h=this.getPath("pane.rootResponder");if(b&&(a=this.get("items").objectAt(a[6]))){f=a.get?a.get(b):a[b];if(g)d=a.get?a.get(g):a[g];h&&h.sendAction(f,d,this,this.get("pane"))}!f&&
e!==undefined&&this.set("value",c);(f=this.get("action"))&&h&&h.sendAction(f,this.get("target"),this,this.get("pane"))},acceptsFirstResponder:function(){return this.get("isEnabled")}.property("isEnabled"),willBecomeKeyResponderFrom:function(){if(!this._isFocused){this._isFocused=YES;this.becomeFirstResponder();this.get("isVisibleInWindow")&&this.$()[0].focus()}},willLoseKeyResponderTo:function(){if(this._isFocused)this._isFocused=NO}});SC._segmented_fetchKeys=function(a){return this.get(a)};
SC._segmented_fetchItem=function(a){if(!a)return null;return this.get?this.get(a):this[a]};
SC.SelectFieldView=SC.FieldView.extend({tagName:"select",classNames:["sc-select-field-view"],objects:[],objectsBindingDefault:SC.Binding.multiple(),nameKey:null,sortKey:null,valueKey:null,emptyName:null,localize:false,cpDidChange:YES,disableSort:NO,validateMenuItem:function(){return true},sortObjects:function(a){if(!this.get("disableSort")){var b=this.get("sortKey")||this.get("nameKey");a=a.sort(function(c,e){if(b){c=c.get?c.get(b):c[b];e=e.get?e.get(b):e[b]}return c<e?-1:c>e?1:0})}return a},render:function(a,
b){if(this.get("cpDidChange")){this.set("cpDidChange",NO);var c=this.get("nameKey"),e=this.get("valueKey"),g=this.get("objects"),d=this.get("value"),f,h,i=this.get("localize");if(!e&&d)d=SC.guidFor(d);if(d===null||d==="")d="***";if(g){g=this.sortObjects(g);if(!b){h=this.$input()[0];h.innerHTML=""}var j=this.get("emptyName");if(j){if(i)j=j.loc();if(b){a.push('<option value="***">%@</option>'.fmt(j));a.push('<option disabled="disabled"></option>')}else{f=document.createElement("option");f.value="***";
f.innerHTML=j;h.appendChild(f);f=document.createElement("option");f.disabled="disabled";h.appendChild(f)}}g.forEach(function(k){if(k){var l=c?k.get?k.get(c):k[c]:k.toString();if(i)l=l.loc();if(k=e?k.get?k.get(e):k[e]:k)k=SC.guidFor(k)?SC.guidFor(k):k.toString();var o=this.validateMenuItem&&this.validateMenuItem(k,l)?"":'disabled="disabled" ';if(b)a.push('<option %@value="%@">%@</option>'.fmt(o,k,l));else{f=document.createElement("option");f.value=k;f.innerHTML=l;if(o.length>0)f.disable="disabled";
h.appendChild(f)}}else if(b)a.push('<option disabled="disabled"></option>');else{f=document.createElement("option");f.disabled="disabled";h.appendChild(f)}},this);this.setFieldValue(d)}else this.set("value",null)}},displayProperties:["objects","nameKey","valueKey"],_objectsObserver:function(){this.set("cpDidChange",YES)}.observes("objects"),_nameKeyObserver:function(){this.set("cpDidChange",YES)}.observes("nameKey"),_valueKeyObserver:function(){this.set("cpDidChange",YES)}.observes("valueKey"),$input:function(){return this.$()},
mouseDown:function(a){if(this.get("isEnabled"))return arguments.callee.base.apply(this,arguments);else{a.stop();return YES}},getFieldValue:function(){var a=arguments.callee.base.apply(this,arguments),b=this.get("valueKey"),c=this.get("objects"),e,g;if(a=="***")a=null;else if(a&&c){var d=SC.typeOf(c.length)===SC.T_FUNCTION?c.length():c.length;for(e=null;!e&&--d>=0;){g=c.objectAt?c.objectAt(d):c[d];if(b)g=g.get?g.get(b):g[b];var f=g?SC.guidFor(g)?SC.guidFor(g):g.toString():null;if(a==f)e=g}}return b||
e?e:a},setFieldValue:function(a){a=SC.none(a)?"":a?SC.guidFor(a)?SC.guidFor(a):a.toString():null;this.$input().val(a);return this},fieldDidFocus:function(){this.get("isFocused")||this.set("isFocused",true)},fieldDidBlur:function(){this.get("isFocused")&&this.set("isFocused",false)},_isFocusedObserver:function(){this.$().setClass("focus",this.get("isFocused"))}.observes("isFocused"),didCreateLayer:function(){var a=this.$input();SC.Event.add(a,"blur",this,this.fieldDidBlur);SC.Event.add(a,"focus",this,
this.fieldDidFocus);return arguments.callee.base.apply(this,arguments)},willDestroyLayer:function(){var a=this.$input();SC.Event.remove(a,"focus",this,this.fieldDidFocus);SC.Event.remove(a,"blur",this,this.fieldDidBlur);return arguments.callee.base.apply(this,arguments)}});
SC.SliderView=SC.View.extend(SC.Control,{classNames:"sc-slider-view",handleSelector:"img.sc-handle",value:0.5,valueBindingDefault:SC.Binding.single().notEmpty(),minimum:0,minimumBindingDefault:SC.Binding.single().notEmpty(),contentMinimumKey:null,maximum:1,maximumBindingDefault:SC.Binding.single().notEmpty(),contentMaximumKey:null,step:0.1,displayProperties:"value minimum maximum".w(),render:function(a,b){arguments.callee.base.apply(this,arguments);var c=this.get("minimum"),e=this.get("maximum"),
g=this.get("value");g=Math.min(Math.max(g,c),e);var d=this.get("step");if(!SC.none(d)&&d!==0)g=Math.round(g/d)*d;g=Math.floor((g-c)/(e-c)*100);if(b){c=SC.BLANK_IMAGE_URL;a.push('<span class="sc-inner">');a.push('<span class="sc-leftcap"></span>');a.push('<span class="sc-rightcap"></span>');a.push('<img src="',c,'" class="sc-handle" style="left: ',g,'%" />');a.push("</span>")}else this.$(this.get("handleSelector")).css("left",g+"%")},_isMouseDown:NO,mouseDown:function(a){if(!this.get("isEnabled"))return YES;
this.set("isActive",YES);this._isMouseDown=YES;return this._triggerHandle(a)},mouseDragged:function(a){return this._isMouseDown?this._triggerHandle(a):YES},mouseUp:function(a){this._isMouseDown&&this.set("isActive",NO);a=this._isMouseDown?this._triggerHandle(a):YES;this._isMouseDown=NO;return a},_triggerHandle:function(a){a=this.convertFrameFromView({x:a.pageX}).x;var b=this.get("frame").width;a=Math.max(Math.min(a,b-8),8)-8;b-=16;a/=b;b=this.get("minimum");var c=this.get("maximum"),e=this.get("step"),
g=this.get("value");a=b+(c-b)*a;if(e!==0)a=Math.round(a/e)*e;Math.abs(g-a)>=0.01&&this.set("value",a);return YES},acceptsFirstResponder:function(){return this.get("isEnabled")}.property("isEnabled"),willBecomeKeyResponderFrom:function(){if(!this._isFocused){this._isFocused=YES;this.becomeFirstResponder();this.get("isVisibleInWindow")&&this.$()[0].focus()}},willLoseKeyResponderTo:function(){if(this._isFocused)this._isFocused=NO},keyDown:function(a){if(a.which===9){(a.shiftKey?this.get("previousValidKeyView"):
this.get("nextValidKeyView")).becomeFirstResponder();return YES}if(a.which===37||a.which===38||a.which===39||a.which===40){var b=this.get("minimum"),c=this.get("maximum"),e=this.get("step"),g=c-b,d=0;if(a.which===37||a.which===38)if(e===0)if(g<100)d=this.get("value")-1;else{Math.abs(g/100);d=this.get("value")-Math.abs(g/100)}else d=this.get("value")-e;if(a.which===39||a.which===40)if(e===0)if(g<100)d=this.get("value")+2;else{a=Math.abs(g/100);if(a<2)a=2;d=this.get("value")+a}else d=this.get("value")+
e;d>=b&&d<=c&&this.set("value",d)}SC.RunLoop.begin().end();return YES},contentPropertyDidChange:function(a,b){a=this.get("content");this.beginPropertyChanges().updatePropertyFromContent("value",b,"contentValueKey",a).updatePropertyFromContent("minimum",b,"contentMinimumKey",a).updatePropertyFromContent("maximum",b,"contentMaximumKey",a).updatePropertyFromContent("isIndeterminate",b,"contentIsIndeterminateKey",a).endPropertyChanges()}});sc_require("mixins/collection_group");sc_require("views/disclosure");
SC.SourceListGroupView=SC.View.extend(SC.Control,SC.CollectionGroup,{classNames:["sc-source-list-group"],content:null,isGroupVisible:YES,hasGroupTitle:YES,groupTitleKey:null,groupVisibleKey:null,render:function(a){a.push('<a href="javascript:;" class="sc-source-list-label sc-disclosure-view sc-button-view button disclosure no-disclosure">');a.push('<img src="%@" class="button" />'.fmt(SC.BLANK_IMAGE_URL));a.push('<span class="label"></span></a>')},createChildViews:function(){},contentPropertyDidChange:function(a,
b){var c=this.get("content");a=this.outlet("labelView");if(c===null){a.setIfChanged("isVisible",NO);this.setIfChanged("hasGroupTitle",NO)}else{a.setIfChanged("isVisible",YES);this.setIfChanged("hasGroupTitle",YES);var e=this.getDelegateProperty("groupTitleKey",this.displayDelegate);if(b=="*"||e&&b==e){e=c&&c.get&&e?c.get(e):c;if(e!=this._title){if(this._title=e)e=e.capitalize();a.set("title",e)}}e=this.getDelegateProperty("groupVisibleKey",this.displayDelegate);if(b=="*"||e&&b==e)if(e){a.removeClassName("no-disclosure");
b=c&&c.get?!!c.get(e):YES;if(b!=this.get("isGroupVisible")){this.set("isGroupVisible",b);a.set("value",b)}}else a.addClassName("no-disclosure")}},disclosureValueDidChange:function(a){if(a!=this.get("isGroupVisible")){var b=this.get("content"),c=this.getDelegateProperty("groupVisibleKey",this.displayDelegate);b&&b.set&&c&&b.set(c,a);this.set("isGroupVisible",a);this.owner&&this.owner.updateChildren&&this.owner.updateChildren(true)}},labelView:SC.DisclosureView.extend({value:YES,_valueObserver:function(){this.owner&&
this.owner.disclosureValueDidChange(this.get("value"))}.observes("value")})});sc_require("views/list");sc_require("views/source_list_group");SC.BENCHMARK_SOURCE_LIST_VIEW=YES;SC.SourceListView=SC.ListView.extend({classNames:["sc-source-list"],rowHeight:32,selectOnMouseDown:NO,actOnSelect:YES});sc_require("views/split");
SC.SplitDividerView=SC.View.extend({classNames:["sc-split-divider-view"],prepareContext:function(){var a=this.get("splitView");a&&this.set("cursor",a.get("thumbViewCursor"));return arguments.callee.base.apply(this,arguments)},mouseDown:function(a){var b=this.get("splitView");return b?b.mouseDownInThumbView(a,this):arguments.callee.base.apply(this,arguments)},doubleClick:function(a){console.log("doubleClick in split divider");var b=this.get("splitView");return b?b.doubleClickInThumbView(a,this):arguments.callee.base.apply(this,
arguments)}});sc_require("views/split_divider");SC.RESIZE_BOTH="resize-both";SC.RESIZE_TOP_LEFT="resize-top-left";SC.RESIZE_BOTTOM_RIGHT="resize-bottom-right";
SC.SplitView=SC.View.extend({classNames:["sc-split-view"],childLayoutProperties:"layoutDirection dividerThickness autoresizeBehavior".w(),displayProperties:["layoutDirection"],delegate:null,layoutDirection:SC.LAYOUT_HORIZONTAL,canCollapseViews:YES,autoresizeBehavior:SC.RESIZE_BOTTOM_RIGHT,defaultThickness:0.5,isSplitView:YES,topLeftView:SC.View,dividerView:SC.SplitDividerView,bottomRightView:SC.View,topLeftThickness:function(){var a=this.get("topLeftView");return a?this.thicknessForView(a):0}.property("topLeftView").cacheable(),
bottomRightThickness:function(){var a=this.get("bottomRightView");return a?this.thicknessForView(a):0}.property("bottomRightView").cacheable(),thumbViewCursor:null,canCollapseView:function(a){return this.invokeDelegateMethod(this.delegate,"splitViewCanCollapse",this,a)},thicknessForView:function(a){var b=this.get("layoutDirection");a=a.get("frame");return b===SC.LAYOUT_HORIZONTAL?a.width:a.height},createChildViews:function(){var a=[],b=["topLeftView","dividerView","bottomRightView"],c,e,g;e=0;for(g=
b.length;e<g;++e)if(c=this.get(b[e])){c=this[b[e]]=this.createChildView(c,{layoutView:this,rootElementPath:[e]});a.push(c)}this.set("childViews",a);return this},updateChildLayout:function(){var a=this.get("topLeftView"),b=this.get("bottomRightView"),c=this.get("dividerView"),e=this.get("layoutDirection"),g=this._desiredTopLeftThickness,d=this.get("dividerThickness")||7,f=(e==SC.LAYOUT_HORIZONTAL?this.get("frame").width:this.get("frame").height)-d-g,h=this.get("autoresizeBehavior"),i;i=a.get("isCollapsed")||
NO;a.setIfChanged("isVisible",!i);i=SC.clone(a.get("layout"));if(e==SC.LAYOUT_HORIZONTAL){i.top=0;i.left=0;i.bottom=0;switch(h){case SC.RESIZE_BOTH:throw"SC.RESIZE_BOTH is currently unsupported.";case SC.RESIZE_TOP_LEFT:i.right=f+d;delete i.width;break;case SC.RESIZE_BOTTOM_RIGHT:delete i.right;delete i.height;i.width=g;break}}else{i.top=0;i.left=0;i.right=0;switch(h){case SC.RESIZE_BOTH:throw"SC.RESIZE_BOTH is currently unsupported.";case SC.RESIZE_TOP_LEFT:i.bottom=f+d;delete i.height;break;case SC.RESIZE_BOTTOM_RIGHT:delete i.bottom;
delete i.width;i.height=g;break}}a.set("layout",i);if(c){i=SC.clone(c.get("layout"));if(e==SC.LAYOUT_HORIZONTAL){i.width=d;delete i.height;i.top=0;i.bottom=0;switch(h){case SC.RESIZE_BOTH:throw"SC.RESIZE_BOTH is currently unsupported.";case SC.RESIZE_TOP_LEFT:delete i.left;i.right=f;delete i.centerX;delete i.centerY;break;case SC.RESIZE_BOTTOM_RIGHT:i.left=g;delete i.right;delete i.centerX;delete i.centerY;break}}else{delete i.width;i.height=d;i.left=0;i.right=0;switch(h){case SC.RESIZE_BOTH:throw"SC.RESIZE_BOTH is currently unsupported.";
case SC.RESIZE_TOP_LEFT:delete i.top;i.bottom=f;delete i.centerX;delete i.centerY;break;case SC.RESIZE_BOTTOM_RIGHT:i.top=g;delete i.bottom;delete i.centerX;delete i.centerY;break}}c.set("layout",i)}i=b.get("isCollapsed")||NO;b.setIfChanged("isVisible",!i);i=SC.clone(b.get("layout"));if(e==SC.LAYOUT_HORIZONTAL){i.top=0;i.bottom=0;i.right=0;switch(h){case SC.RESIZE_BOTH:throw"SC.RESIZE_BOTH is currently unsupported.";case SC.RESIZE_BOTTOM_RIGHT:i.left=g+d;delete i.width;break;case SC.RESIZE_TOP_LEFT:delete i.left;
i.width=f;break}}else{i.left=0;i.right=0;i.bottom=0;switch(h){case SC.RESIZE_BOTH:throw"SC.RESIZE_BOTH is currently unsupported.";case SC.RESIZE_BOTTOM_RIGHT:i.top=g+d;delete i.height;break;case SC.RESIZE_TOP_LEFT:delete i.top;i.height=f;break}}b.set("layout",i);this.notifyPropertyChange("topLeftThickness").notifyPropertyChange("bottomRightThickness")},renderLayout:function(a,b){if(b||this._recalculateDivider){this.get("thumbViewCursor")||this.set("thumbViewCursor",SC.Cursor.create());var c=this.get("layoutDirection"),
e=this.get("frame"),g=this.$(),d=this.get("dividerThickness")||7,f=this.get("defaultThickness"),h=this.get("autoresizeBehavior");if(this._recalculateDivider===undefined&&f<1)this._recalculateDivider=YES;else if(this._recalculateDivider)this._recalculateDivider=NO;c=g[0]?c==SC.LAYOUT_HORIZONTAL?g[0].offsetWidth:g[0].offsetHeight:c==SC.LAYOUT_HORIZONTAL?e.width:e.height;if(SC.none(f)||f>0&&f<1)f=Math.floor((c-d)*(f||0.5));this._desiredTopLeftThickness=h===SC.RESIZE_BOTTOM_RIGHT?f:c-d-f;this._topLeftView=
this.get("topLeftView");this._bottomRightView=this.get("bottomRightView");this._topLeftViewThickness=this.thicknessForView(this.get("topLeftView"));this._bottomRightThickness=this.thicknessForView(this.get("bottomRightView"));this._dividerThickness=this.get("dividerThickness");this._layoutDirection=this.get("layoutDirection");this._updateTopLeftThickness(0);this._setCursorStyle();this.updateChildLayout()}arguments.callee.base.apply(this,arguments)},render:function(a,b){arguments.callee.base.apply(this,
arguments);this._inLiveResize&&this._setCursorStyle();if(b)this.get("layoutDirection")===SC.LAYOUT_HORIZONTAL?a.addClass("sc-horizontal"):a.addClass("sc-vertical")},mouseDownInThumbView:function(a,b){var c=this.getPath("pane.rootResponder");if(!c)return NO;c.dragDidStart(this);this._mouseDownX=a.pageX;this._mouseDownY=a.pageY;this._thumbView=b;this._topLeftView=this.get("topLeftView");this._bottomRightView=this.get("bottomRightView");this._topLeftViewThickness=this.thicknessForView(this.get("topLeftView"));
this._bottomRightThickness=this.thicknessForView(this.get("bottomRightView"));this._dividerThickness=this.get("dividerThickness");this._layoutDirection=this.get("layoutDirection");this.beginLiveResize();return this._inLiveResize=YES},mouseDragged:function(a){this._updateTopLeftThickness(this._layoutDirection==SC.LAYOUT_HORIZONTAL?a.pageX-this._mouseDownX:a.pageY-this._mouseDownY);return YES},mouseUp:function(){if(this._inLiveResize===YES){this._thumbView=null;this._inLiveResize=NO;this.endLiveResize();
return YES}return NO},doubleClickInThumbView:function(){var a=this._topLeftView,b=a.get("isCollapsed")||NO;if(!b&&!this.canCollapseView(a)){a=this._bottomRightView;b=a.get("isCollapsed")||NO;if(!b&&!this.canCollapseView(a))return NO}if(b){if(a===this._topLeftView)this._topLeftViewThickness=this._uncollapsedThickness;else this._bottomRightViewThickness=this._uncollapsedThickness;a._uncollapsedThickness=null}else{this._uncollapsedThickness=this.getThicknessForView(a);if(a===this._topLeftView)this._topLeftViewThickness=
0;else this._bottomRightViewThickness=0;if(!a.get("isCollapsed"))this._uncollapsedThickness=null}this._setCursorStyle();return true},_updateTopLeftThickness:function(a){var b=this._topLeftView,c=this._bottomRightView,e=this.thicknessForView(b),g=this.thicknessForView(c),d=this._dividerThickness,f=0;b.get("isCollapsed")||(f+=e);c.get("isCollapsed")||(f+=g);a=this._topLeftViewThickness+a;this.canCollapseView(c);e=a;g=this.get("topLeftMaxThickness");var h=this.get("topLeftMinThickness");SC.none(g)||
(e=Math.min(g,e));SC.none(h)||(e=Math.max(h,e));g=this.get("bottomRightMaxThickness");h=this.get("bottomRightMinThickness");e=f-e;SC.none(g)||(e=Math.min(g,e));SC.none(h)||(e=Math.max(h,e));e=f-e;e=this.invokeDelegateMethod(this.delegate,"splitViewConstrainThickness",this,b,e);e=Math.min(e,f);e=Math.max(0,e);(g=b.get("collapseAtThickness"))||(g=0);h=c.get("collapseAtThickness");h=SC.none(h)?f:f-h;if(a<=g&&this.canCollapseView(b)){g=c.get("maxThickness");if(!g||d+f<=g)e=0}else if(a>=h&&this.canCollapseView(c)){g=
b.get("maxThickness");if(!g||d+f<=g)e=f}if(e!=this.thicknessForView(b)){this._desiredTopLeftThickness=e;b.set("isCollapsed",e===0);c.set("isCollapsed",e>=f);this.updateChildLayout();this.displayDidChange()}},_setCursorStyle:function(){var a=this._topLeftView,b=this._bottomRightView,c=this.get("thumbViewCursor");this._layoutDirection=this.get("layoutDirection");var e=this.thicknessForView(a),g=this.thicknessForView(b);if(a.get("isCollapsed")||e==this.get("topLeftMinThickness")||g==this.get("bottomRightMaxThickness"))c.set("cursorStyle",
this._layoutDirection==SC.LAYOUT_HORIZONTAL?"e-resize":"s-resize");else b.get("isCollapsed")||e==this.get("topLeftMaxThickness")||g==this.get("bottomRightMinThickness")?c.set("cursorStyle",this._layoutDirection==SC.LAYOUT_HORIZONTAL?"w-resize":"n-resize"):c.set("cursorStyle",this._layoutDirection==SC.LAYOUT_HORIZONTAL?"ew-resize":"ns-resize")}.observes("layoutDirection"),splitViewCanCollapse:function(a,b){if(a.get("canCollapseViews")===NO)return NO;if(b.get("canCollapse")===NO)return NO;return YES},
splitViewConstrainThickness:function(a,b,c){return c},_forceSplitCalculation:function(){this.updateLayout()}.observes("*pane.isPaneAttached")});sc_require("views/collection");
SC.StackedView=SC.CollectionView.extend({classNames:["sc-stacked-view"],layout:{top:0,left:0,right:0,height:1},computeNowShowing:function(){return this.get("allContentIndexes")},updateHeight:function(a){a?this._updateHeight():this.invokeLast(this._updateHeight);return this},_updateHeight:function(){var a=this.get("childViews"),b=a.get("length");if(b===0)a=1;else a=(a=(a=a.objectAt(b-1))?a.get("layer"):null)?a.offsetTop+a.offsetHeight:1;this.adjust("height",a)},didReload:function(){return this.updateHeight()},
didCreateLayer:function(){return this.updateHeight()}});sc_require("views/segmented");SC.TOP_LOCATION="top";SC.BOTTOM_LOCATION="bottom";
SC.TabView=SC.View.extend({classNames:["sc-tab-view"],displayProperties:["nowShowing"],nowShowing:null,items:[],isEnabled:YES,itemTitleKey:null,itemValueKey:null,itemIsEnabledKey:null,itemIconKey:null,itemWidthKey:null,itemToolTipKey:null,tabLocation:SC.TOP_LOCATION,userDefaultKey:null,_tab_nowShowingDidChange:function(){var a=this.get("nowShowing");this.get("containerView").set("nowShowing",a);this.get("segmentedView").set("value",a);return this}.observes("nowShowing"),_tab_saveUserDefault:function(){var a=
this.get("nowShowing"),b=this.get("userDefaultKey");b&&SC.userDefaults.set([b,"nowShowing"].join(":"),a)}.observes("nowShowing"),_tab_itemsDidChange:function(){this.get("segmentedView").set("items",this.get("items"));return this}.observes("items"),init:function(){arguments.callee.base.apply(this,arguments);this._tab_nowShowingDidChange()._tab_itemsDidChange()},awake:function(){arguments.callee.base.apply(this,arguments);var a=this.get("userDefaultKey");if(a){a=[a,"nowShowing"].join(":");a=SC.userDefaults.get(a);
SC.none(a)||this.set("nowShowing",a)}},createChildViews:function(){var a=[],b;b=this.containerView=this.createChildView(this.get("tabLocation")===SC.TOP_LOCATION?this.containerView.extend({layout:{top:12,left:0,right:0,bottom:0}}):this.containerView.extend({layout:{top:0,left:0,right:0,bottom:12}}));a.push(b);b=this.segmentedView=this.createChildView(this.segmentedView);a.push(b);this.set("childViews",a);return this},containerView:SC.ContainerView,segmentedView:SC.SegmentedView.extend({layout:{left:0,
right:0,height:24},_sc_tab_segmented_valueDidChange:function(){var a=this.get("parentView");a&&a.set("nowShowing",this.get("value"));this.set("layerNeedsUpdate",YES);this.invokeOnce(this.updateLayerIfNeeded)}.observes("value"),render:function(a){arguments.callee.base.apply(this,arguments);var b=this.get("parentView");(b?b.get("tabLocation"):SC.TOP_LOCATION)===SC.TOP_LOCATION?a.addStyle("top","0px"):a.addStyle("bottom","0px")},init:function(){var a=this.get("parentView");a&&SC._TAB_ITEM_KEYS.forEach(function(b){this[b]=
a.get(b)},this);return arguments.callee.base.apply(this,arguments)}})});SC._TAB_ITEM_KEYS="itemTitleKey itemValueKey itemIsEnabledKey itemIconKey itemWidthKey itemToolTipKey".w();
SC.ThumbView=SC.View.extend({classNames:["sc-thumb-view"],isEnabled:YES,isEnabledBindingDefault:SC.Binding.bool(),prepareContext:function(){var a=this.get("splitView");a&&this.set("cursor",a.get("thumbViewCursor"));return arguments.callee.base.apply(this,arguments)},mouseDown:function(a){if(!this.get("isEnabled"))return NO;var b=this.get("splitView");return b?b.mouseDownInThumbView(a,this):arguments.callee.base.apply(this,arguments)}});
SC.ToolbarView=SC.View.extend({classNames:["sc-toolbar-view"],anchorLocation:null,layout:{left:0,height:32,right:0},init:function(){if(this.anchorLocation)this.layout=SC.merge(this.layout,this.anchorLocation);arguments.callee.base.apply(this,arguments)}});
SC.WebView=SC.View.extend(SC.Control,{classNames:"sc-web-view",displayProperties:["value","shouldAutoResize"],shouldAutoResize:NO,render:function(a,b){var c=this.get("value");if(b)a.push('<iframe src="'+c+'" style="position: absolute; width: 100%; height: 100%; border: 0px; margin: 0px; padding: 0p;"></iframe>');else{a=this.$("iframe");a.attr("src","javascript:;");a.attr("src",c)}},didCreateLayer:function(){var a=this.$("iframe");SC.Event.add(a,"load",this,this.iframeDidLoad)},iframeDidLoad:function(){if(this.get("shouldAutoResize")===
YES){var a;if((a=this.$("iframe")[0])&&a.contentWindow)if((a=a.contentWindow)&&a.document&&a.document.documentElement){a=a.document.documentElement;if(SC.browser.isIE){this.$().width(a.scrollWidth+12);this.$().height(a.scrollHeight+5)}else{this.$().width(a.scrollWidth);this.$().height(a.scrollHeight)}}}}});
SC.WellView=SC.ContainerView.extend({classNames:"sc-well-view",contentLayout:{top:10,bottom:10,left:10,right:10},createChildViews:function(){var a=this.get("contentView");if(a){a=this.contentView=this.createChildView(a);a.set("layout",this.contentLayout);this.childViews=[a]}},render:function(a,b){arguments.callee.base.apply(this,arguments);b&&a.push("<div class='top-left-edge'></div>","<div class='top-edge'></div>","<div class='top-right-edge'></div>","<div class='right-edge'></div>","<div class='bottom-right-edge'></div>",
"<div class='bottom-edge'></div>","<div class='bottom-left-edge'></div>","<div class='left-edge'></div>","<div class='content-background'></div>")},contentViewDidChange:function(){var a=this.get("contentView");a.set("layout",this.contentLayout);this.replaceContent(a)}.observes("contentView")});tiki.script("sproutcore/desktop:en/57a37cf8f2abf4dfdcfdbc5bcf79f41605b5ca83/javascript.js");
tiki.register("sproutcore/core_tools",{packages:{"sproutcore/desktop":{stylesheets:[{url:"/static/sproutcore/desktop/en/57a37cf8f2abf4dfdcfdbc5bcf79f41605b5ca83/stylesheet.css",id:"sproutcore/desktop:en/57a37cf8f2abf4dfdcfdbc5bcf79f41605b5ca83/stylesheet.css"}],scripts:[{url:"/static/sproutcore/desktop/en/57a37cf8f2abf4dfdcfdbc5bcf79f41605b5ca83/javascript.js",id:"sproutcore/desktop:en/57a37cf8f2abf4dfdcfdbc5bcf79f41605b5ca83/javascript.js"}]}},depends:["sproutcore/desktop"],scripts:[{url:"/static/sproutcore/core_tools/en/21a3b019085a887ba1a5de96aa8bdd91cc4aae36/javascript.js",
id:"sproutcore/core_tools:en/21a3b019085a887ba1a5de96aa8bdd91cc4aae36/javascript.js"}]});tiki.global("sproutcore/core_tools");tiki.script("sproutcore/core_tools:en/21a3b019085a887ba1a5de96aa8bdd91cc4aae36/javascript.js");tiki.register("sproutcore/datejs",{scripts:[{url:"/static/sproutcore/datejs/en/3a43b520525add286092c549c8d5e417de93a4ba/javascript.js",id:"sproutcore/datejs:en/3a43b520525add286092c549c8d5e417de93a4ba/javascript.js"}]});tiki.global("sproutcore/datejs");tiki.script("sproutcore/datejs:en/3a43b520525add286092c549c8d5e417de93a4ba/javascript.js");
tiki.register("sproutcore/debug",{scripts:[{url:"/static/sproutcore/debug/en/13200b9fa685f043535bda49964adb32feb44530/javascript.js",id:"sproutcore/debug:en/13200b9fa685f043535bda49964adb32feb44530/javascript.js"}]});tiki.global("sproutcore/debug");SC=SC||{};SC._mapDisplayNamesUseHashForSeenTypes=["object","number","boolean","array","string","function","class","undefined","error"];
SC.mapDisplayNames=function(a,b,c,e,g){if(SC.browser.safari){if(!SC._mapDisplayNamesUseHashForSeenTypesHash){for(var d=SC._mapDisplayNamesUseHashForSeenTypes,f={},h=d.length,i=0;i<h;++i)f[d[i]]=true;SC._mapDisplayNamesUseHashForSeenTypesHash=f}if(a===undefined)a=window;if(b===undefined)b=0;if(c===undefined)c=[];if(e===undefined)e={};if(g===undefined)g=[];if(!(b>5)){d=!!SC._mapDisplayNamesUseHashForSeenTypesHash[SC.typeOf(a)];var j;if(d){j=SC.hashFor(a);f=e[j]}else f=g;if(!(f&&f.indexOf(a)!==-1)){if(f)f.push(a);
else if(d)e[j]=[a];j=c.length;c[j]="";for(var k in a)if(!(a.hasOwnProperty&&!a.hasOwnProperty(k)))if(isNaN(Number(k)))if(k!=="constructor")if(k!=="superclass")if(k!=="document"){d=a[k];if(k==="SproutCore")k="SC";f=SC.typeOf(d);if(f===SC.T_FUNCTION){if(!d.displayName){c[j]=k;f=c.join(".").replace(".prototype.","#");d.displayName=f}if(d.prototype){c.push("prototype");SC.mapDisplayNames(d.prototype,b+1,c,e,g);c.pop()}}else if(f===SC.T_CLASS){c[j]=k;SC.mapDisplayNames(d,b+1,c,e,g)}else if(k.indexOf("_")!==
0&&(f===SC.T_OBJECT||f===SC.T_HASH)){c[j]=k;SC.mapDisplayNames(d,b+1,c,e,g)}}c.pop()}}}};tiki.script("sproutcore/debug:en/13200b9fa685f043535bda49964adb32feb44530/javascript.js");
tiki.register("sproutcore/designer",{packages:{"sproutcore/runtime":{scripts:[{url:"/static/sproutcore/runtime/en/cfe6f8a7557f916515999a065d70bfa71bd13986/javascript.js",id:"sproutcore/runtime:en/cfe6f8a7557f916515999a065d70bfa71bd13986/javascript.js"}]},"sproutcore/foundation":{stylesheets:[{url:"/static/sproutcore/foundation/en/d5356c4dc5eed765f3239fcaaa4b599b3de5c4b0/stylesheet.css",id:"sproutcore/foundation:en/d5356c4dc5eed765f3239fcaaa4b599b3de5c4b0/stylesheet.css"}],scripts:[{url:"/static/sproutcore/foundation/en/d5356c4dc5eed765f3239fcaaa4b599b3de5c4b0/javascript.js",
id:"sproutcore/foundation:en/d5356c4dc5eed765f3239fcaaa4b599b3de5c4b0/javascript.js"}]}},stylesheets:[{url:"/static/sproutcore/designer/en/3080eb96d6f0ac8d0e9236af215ac0647848d08b/stylesheet.css",id:"sproutcore/designer:en/3080eb96d6f0ac8d0e9236af215ac0647848d08b/stylesheet.css"}],depends:["sproutcore/runtime","sproutcore/foundation"],scripts:[{url:"/static/sproutcore/designer/en/3080eb96d6f0ac8d0e9236af215ac0647848d08b/javascript.js",id:"sproutcore/designer:en/3080eb96d6f0ac8d0e9236af215ac0647848d08b/javascript.js"}]});
tiki.global("sproutcore/designer");tiki.script("sproutcore/designer:en/3080eb96d6f0ac8d0e9236af215ac0647848d08b/javascript.js");tiki.register("sproutcore/empty_theme",{scripts:[{url:"/static/sproutcore/empty_theme/en/21c3b7b16d7ef39d60d2651975590828812f3ad9/javascript.js",id:"sproutcore/empty_theme:en/21c3b7b16d7ef39d60d2651975590828812f3ad9/javascript.js"}]});tiki.global("sproutcore/empty_theme");tiki.script("sproutcore/empty_theme:en/21c3b7b16d7ef39d60d2651975590828812f3ad9/javascript.js");
tiki.register("sproutcore",{packages:{"sproutcore/desktop":{stylesheets:[{url:"/static/sproutcore/desktop/en/57a37cf8f2abf4dfdcfdbc5bcf79f41605b5ca83/stylesheet.css",id:"sproutcore/desktop:en/57a37cf8f2abf4dfdcfdbc5bcf79f41605b5ca83/stylesheet.css"}],scripts:[{url:"/static/sproutcore/desktop/en/57a37cf8f2abf4dfdcfdbc5bcf79f41605b5ca83/javascript.js",id:"sproutcore/desktop:en/57a37cf8f2abf4dfdcfdbc5bcf79f41605b5ca83/javascript.js"}]}},depends:["sproutcore/desktop"],scripts:[{url:"/static/sproutcore/en/d1f17166d729847603796d2e6df2d6d9cb197021/javascript.js",
id:"sproutcore:en/d1f17166d729847603796d2e6df2d6d9cb197021/javascript.js"}]});tiki.global("sproutcore");tiki.script("sproutcore:en/d1f17166d729847603796d2e6df2d6d9cb197021/javascript.js");
tiki.register("sproutcore/mini",{packages:{"sproutcore/runtime":{scripts:[{url:"/static/sproutcore/runtime/en/cfe6f8a7557f916515999a065d70bfa71bd13986/javascript.js",id:"sproutcore/runtime:en/cfe6f8a7557f916515999a065d70bfa71bd13986/javascript.js"}]},"sproutcore/datastore":{scripts:[{url:"/static/sproutcore/datastore/en/334c3630f54926a13d0810d33b3686af21530ee7/javascript.js",id:"sproutcore/datastore:en/334c3630f54926a13d0810d33b3686af21530ee7/javascript.js"}]}},depends:["sproutcore/runtime","sproutcore/datastore"],
scripts:[{url:"/static/sproutcore/mini/en/33133db781fd6d264936fd2c81d828875be42b87/javascript.js",id:"sproutcore/mini:en/33133db781fd6d264936fd2c81d828875be42b87/javascript.js"}]});tiki.global("sproutcore/mini");tiki.script("sproutcore/mini:en/33133db781fd6d264936fd2c81d828875be42b87/javascript.js");
tiki.register("sproutcore/standard_theme",{packages:{"sproutcore/empty_theme":{scripts:[{url:"/static/sproutcore/empty_theme/en/21c3b7b16d7ef39d60d2651975590828812f3ad9/javascript.js",id:"sproutcore/empty_theme:en/21c3b7b16d7ef39d60d2651975590828812f3ad9/javascript.js"}]}},stylesheets:[{url:"/static/sproutcore/standard_theme/en/4448cf3c8117a1e50376695dc8ea12138b0f9099/stylesheet.css",id:"sproutcore/standard_theme:en/4448cf3c8117a1e50376695dc8ea12138b0f9099/stylesheet.css"}],depends:["sproutcore/empty_theme"],
scripts:[{url:"/static/sproutcore/standard_theme/en/4448cf3c8117a1e50376695dc8ea12138b0f9099/javascript.js",id:"sproutcore/standard_theme:en/4448cf3c8117a1e50376695dc8ea12138b0f9099/javascript.js"}]});tiki.global("sproutcore/standard_theme");tiki.script("sproutcore/standard_theme:en/4448cf3c8117a1e50376695dc8ea12138b0f9099/javascript.js");
tiki.register("sproutcore/testing",{stylesheets:[{url:"/static/sproutcore/testing/en/1e0d6dc675d3d9adb05a01b524dd7fc8fb2ad475/stylesheet.css",id:"sproutcore/testing:en/1e0d6dc675d3d9adb05a01b524dd7fc8fb2ad475/stylesheet.css"}],scripts:[{url:"/static/sproutcore/testing/en/1e0d6dc675d3d9adb05a01b524dd7fc8fb2ad475/javascript.js",id:"sproutcore/testing:en/1e0d6dc675d3d9adb05a01b524dd7fc8fb2ad475/javascript.js"}]});tiki.global("sproutcore/testing");tiki.script("sproutcore/testing:en/1e0d6dc675d3d9adb05a01b524dd7fc8fb2ad475/javascript.js");
tiki.register("bespin",{});
tiki.module("bespin:builtins",function(a,b){b.metadata={bespin:{provides:[{ep:"extensionpoint",name:"extensionpoint",description:"Use the 'extensionpoint' extension point to define new extension points. You can provide an 'indexOn' property to name a property of extensions through which you'd like to be able to easily look up the extension. You can also provide a 'register' and 'unregister' properties which are pointers to functions that are called whenever a new extension is discovered or removed, respectively. 'register' and 'unregister' should be used sparingly, because your plugin will be loaded whenever a matching plugin is available."},{ep:"extensionpoint",
name:"extensionhandler",description:"extensionhandlers are able to have 'register' and 'unregister' pointers to functions that are called with each extension as it is discovered or unregistered. Use 'register' sparingly as your plugin will be loaded automatically if there is a matching extension (and not just when your extension's functionality is required)."},{ep:"extensionpoint",name:"startup",description:"A function that should be called at startup. This should be used sparingly, as these plugins will be eagerly loaded at the beginning. All that's needed for this extension point is a pointer to a function that takes no arguments.",
register:"plugins#startupHandler"},{ep:"extensionpoint",name:"factory",description:"Provides a factory for singleton components. Each extension needs to provide a name, a pointer and an action. The action can be 'call' (if the pointer refers to a function), 'create' (if the pointer refers to an SC.Object), 'new' (if the pointer refers to a traditional JS object) or 'value' (if the pointer refers to the object itself that is the component).",indexOn:"name"},{ep:"factory",name:"hub",action:"create",
pointer:"util/hub#Hub"},{ep:"extensionpoint",name:"command",description:"Editor commands/actions. TODO: list parameters here."}]}}});
tiki.module("bespin:editor/mixins/textinput",function(a,b){var c=a("sproutcore/runtime").SC;b.TextInput={_TextInput_composing:false,_TextInput_ignore:false,_TextInput_textFieldId:undefined,_TextInput_textFieldDom:undefined,_isChrome:!!parseFloat(navigator.userAgent.split("Chrome/")[1]),_TextInput_textFieldChanged:function(){if(!(this._TextInput_composing||this._TextInput_ignore)){var e=this._TextInput_textFieldDom,g=e.value;if(g!=""){e.value="";this._TextInput_textInserted(g)}}},_TextInput_copy:function(){var e=
false;if(this.respondsTo("copy")){c.RunLoop.begin();e=this.copy();c.RunLoop.end()}return e},_TextInput_cut:function(){var e=false;if(this.respondsTo("cut")){c.RunLoop.begin();e=this.cut();c.RunLoop.end()}return e},_TextInput_textInserted:function(e){if(this.respondsTo("textInserted")){c.RunLoop.begin();this.textInserted(e);c.RunLoop.end()}},_TextInput_setValueAndSelect:function(e){var g=this._TextInput_textFieldDom;g.value=e;g.select()},focusTextInput:function(){this._TextInput_textFieldDom.focus()},
unfocusTextInput:function(){this._TextInput_textFieldDom.blur()},render:function(e,g){arguments.callee.base.apply(this,arguments);if(g){var d=this.get("frame"),f=e.begin("textarea");this._TextInput_textFieldId=c.guidFor(f);f.id(this._TextInput_textFieldId);f.attr("style","position: absolute; z-index: -99999; top: 0px; left: 0px; width: %@px; height: %@px".fmt(d.width,d.height));f.end()}},didCreateLayer:function(){arguments.callee.base.apply(this,arguments);var e=this.$("#"+this._TextInput_textFieldId)[0];
this._TextInput_textFieldDom=e;var g=this;if(c.browser.safari){this._isChrome||e.addEventListener("compositionend",function(i){g._TextInput_textInserted(i.data)},false);e.addEventListener("textInput",function(i){g._TextInput_textInserted(i.data)},false);e.addEventListener("paste",function(i){g._TextInput_textInserted(i.clipboardData.getData("text/plain"))},false)}else{var d=function(){g._TextInput_textFieldChanged()};e.addEventListener("keypress",d,false);e.addEventListener("keyup",d,false);e.addEventListener("compositionstart",
function(){g._TextInput_composing=true},false);e.addEventListener("compositionend",function(){g._TextInput_composing=false;g._TextInput_textFieldChanged()},false);e.addEventListener("paste",function(){g._TextInput_setValueAndSelect("");window.setTimeout(function(){g._TextInput_textFieldChanged()},0)},false)}var f=function(i){i=i.type.indexOf("copy")!=-1?g._TextInput_copy():g._TextInput_cut();g._TextInput_setValueAndSelect(i)};if(c.browser.isSafari&&!this._isChrome&&c.browser.isMac){var h=(new Date).getTime();
d=function(i){var j=i.type.indexOf("cut")!=-1;if(!(j&&(new Date).getTime()-h<10)){f(i);if(j)h=(new Date).getTime()}};e.addEventListener("beforecopy",d,false);e.addEventListener("beforecut",d,false)}else{d=false;if(c.browser.isMozilla)d=function(i){f(i);if(c.browser.isMozilla){g._TextInput_ignore=true;window.setTimeout(function(){g._TextInput_setValueAndSelect("");g._TextInput_ignore=false},0)}};e.addEventListener("copy",d||f,false);e.addEventListener("cut",d||f,false)}e.addEventListener("blur",function(){g.resignFirstResponder()},
false)},mouseDown:function(){arguments.callee.base.apply(this,arguments);this.get("pane").makeFirstResponder(this)},willBecomeKeyResponderFrom:function(){arguments.callee.base.apply(this,arguments);this.focusTextInput()},willLoseKeyResponderTo:function(){arguments.callee.base.apply(this,arguments);this.unfocusTextInput()}}});
tiki.module("bespin:globals",function(a){var b=a("sproutcore/runtime").SC;(function(){if(!Array.isArray)Array.isArray=function(c){return c&&Object.prototype.toString.call(c)=="[object Array]"};if(!Function.prototype.bind)Function.prototype.bind=function(){var c=Array.prototype.slice.call(arguments),e=this,g=function(){return e.call.apply(e,c.concat(Array.prototype.slice.call(arguments)))};g.name=this.name;g.displayName=this.displayName;g.length=this.length;g.unbound=e;return g};b.Object.prototype.sc_super=
function c(){c.caller.base.apply(this,c.caller.arguments)};b.objectForPropertyPathOriginal=b.objectForPropertyPath;b.objectForPropertyPath=function(c,e,g){g=g==undefined?c.length:g;var d=c.split("#");if(d.length==1)return b.objectForPropertyPathOriginal(c,e,g);c=a(d[0]);if(c!==undefined){g-=d[0].length;return b.objectForPropertyPathOriginal(d[1],c,g)}}})()});
tiki.module("bespin:plugins",function(a,b){var c=a("sproutcore/runtime").SC;a("globals");var e=a("builtins"),g=Object.keys;g||(g=function(j){var k,l=[];for(k in j)j.hasOwnProperty(k)&&l.push(k);return l});var d=function(j,k){if(k){k=k.split("#");return{modName:k[0]?j+":"+k[0]:j,objName:k[1]}}},f=function(j){var k=a(j.modName);if(j.objName)return k[j.objName];return k};b.Extension=c.Object.extend({_getPointer:function(j){j=j||"pointer";return d(this._pluginName,this.get(j))},init:function(){this._observers=
[]},load:function(j,k){var l=this._getPointer(k);if(l)tiki.async(this._pluginName).then(function(){c.run(function(){var o=a(l.modName);if(j)l.objName?j(o[l.objName]):j(o)})});else{console.error("Extension cannot be loaded because it has no poitner");console.log(this)}},observe:function(j,k,l){this._observers.push({plugin:j,callback:k,property:l});this.load(k,l)},_getLoaded:function(j){j=this._getPointer(j);return f(j)}});b.ExtensionPoint=c.Object.extend({init:function(){this.extensions=[];this.handlers=
[]},addExtension:function(j){this.extensions.push(j);this.register(j)},getByKey:function(j){var k=this.get("indexOn");if(k)for(var l=0;l<this.extensions.length;l++)if(this.extensions[l][k]==j)return this.extensions[l]},register:function(j){this.handlers.forEach(function(k){k.register&&k.load(function(l){l(j)},"register")})},unregister:function(j){this.handlers.forEach(function(k){k.unregister&&k.load(function(l){l(j)},"unregister")})}});b.Plugin=c.Object.extend({register:function(){self=this;this.provides.forEach(function(j){self.get("catalog").getExtensionPoint(j.ep).register(j)})},
unregister:function(){self=this;this.provides.forEach(function(j){self.get("catalog").getExtensionPoint(j.ep).unregister(j)})},_getObservers:function(){var j={};this.provides.forEach(function(k){console.log("ep: ",k.ep);console.log(k._observers);j[k.ep]=k._observers});return j},_findDependents:function(j,k){var l=this.name,o=this;j.forEach(function(n){if(n!=l){var r=o.catalog.plugins[n];r&&r.depends&&r.depends.forEach(function(p){if(p==l&&!k[n]){k[n]=true;r._findDependents(j,k)}})}})},reload:function(j){if(this.get("reloadURL")){var k=
this.name,l=this.get("reloadPointer");if(l){l=d(k,l);if(l=f(l))l();else{console.error("Reload function could not be loaded. Aborting reload.");return}}var o={},n=this;this._findDependents(g(this.catalog.plugins),o);this.unregister();for(var r in o)this.catalog.plugins[r].unregister();l=new RegExp("^"+k+":");h(l,tiki.scripts);h(l,tiki.modules,function(v){delete tiki._factories[v]});h(l,tiki.stylesheets);h(new RegExp("^"+k+"$"),tiki.packages);var p=tiki._promises;delete p.catalog[k];delete p.loads[k];
i(l,p.modules);i(l,p.scripts);i(l,p.stylesheets);delete tiki._catalog[k];p=[];var m=tiki.sandbox,q=m.modules.length,s=[];for(r in o)s.push(new RegExp("^"+r+":"));for(;--q>=0;){var t=m.modules[q];if(l.exec(t))p.push(t);else for(var u=s.length;--u>=0;)if(s[u].exec(t)){p.push(t);break}}m.clear.apply(m,p);this.catalog.loadMetadata(this.reloadURL,function(){tiki.async(k).then(function(){for(r in o)n.catalog.plugins[r].register();j&&j()})})}}});b.Catalog=c.Object.extend({init:function(){this.points={};
this.plugins={};this.getExtensionPoint("extensionpoint").set("indexOn","name");this.load(e.metadata)},getObject:function(j){j=this.getExtensionByKey("factory",j);if(j!==undefined){var k=j.get("instance");if(k)return k;k=j._getLoaded();var l=j.action;if(l=="call")k=k();else if(l=="create")k=k.create();else if(l=="new")k=new k;else if(l=="value")k=k;else throw"Create action must be call|create|new|value. Found"+l;j.set("instance",k);return k}},getExtensionPoint:function(j){if(this.points[j]===undefined)this.points[j]=
b.ExtensionPoint.create({name:j,catalog:this});return this.points[j]},getExtensions:function(j){j=this.getExtensionPoint(j);if(j===undefined)return[];return j.extensions},getExtensionByKey:function(j,k){j=this.getExtensionPoint(j);if(j!==undefined)return j.getByKey(k)},_registerExtensionPoint:function(j){var k=this.getExtensionPoint(j.name);k.handlers.push(j);j.indexOn&&k.set("indexOn",j.indexOn)},_registerExtensionHandler:function(j){var k=this.getExtensionPoint(j.name);k.handlers.push(j);j.register&&
j.load(function(l){if(!l)throw j.name+" is not ready";k.extensions.forEach(function(o){l(o)})},"register")},load:function(j){for(var k in j){var l=j[k];l.catalog=this;if(l.provides)for(var o=l.provides,n=0;n<o.length;n++){var r=b.Extension.create(o[n]);r._pluginName=k;o[n]=r;var p=r.ep;if(p=="extensionpoint")this._registerExtensionPoint(r);else p=="extensionhandler"&&this._registerExtensionHandler(r);this.getExtensionPoint(r.ep).addExtension(r)}else l.provides=[];l.name=k;l=b.Plugin.create(l);this.plugins[k]=
l}},loadPlugin:function(j,k){j=tiki.async(j);k&&j.then(k,function(l){console.error("Plugin loading canceled: ",l)})},loadMetadata:function(j,k){c.Request.create({address:j}).notify(0,this,this._metadataFinishedLoading,{callback:k}).send("")},getResourceURL:function(j){j=this.plugins[j];if(j!=undefined)return j.resourceURL},_metadataFinishedLoading:function(j,k){if(!j.isError){var l=j.body();l=JSON.parse(l);for(var o in l)if(l[o].errors){console.error("Plugin ",o," has errors:");l[o].errors.forEach(function(n){console.error(n)});
delete l[o]}else tiki.register(o,l[o]);this.load(l)}k.callback&&k.callback(this,j)}});var h=function(j,k,l){for(var o=0;o<k.length;)if(j.exec(k[o])){var n=k.splice(o,1);l&&l(n)}else o++},i=function(j,k){for(var l=g(k),o=l.length;--o>0;)j.exec(l[o])&&delete k[l[o]]};b.catalog=b.Catalog.create();b.startupHandler=function(j){j.load(function(k){k()})}});
tiki.module("bespin:theme",function(a,b){a=a("sproutcore/runtime").SC;b.coffee={backgroundStyle:"#2A211C",gutterStyle:"#4c4a41",lineNumberColor:"#e5c138",lineNumberFont:"10pt Monaco, Lucida Console, monospace",lineMarkerErrorColor:"#CC4444",lineMarkerWarningColor:"#B8860B",lineMarkerMessageColor:"green",zebraStripeColor:"#2A211C",highlightCurrentLineColor:"#3a312b",editorTextFont:"10pt Monaco, Lucida Console, monospace",editorTextColor:"rgb(230, 230, 230)",editorSelectedTextColor:"rgb(240, 240, 240)",
editorSelectedTextBackground:"#526DA5",cursorStyle:"#879aff",cursorType:"ibeam",unfocusedCursorStrokeStyle:"#FF0033",unfocusedCursorFillStyle:"#73171E",partialNibStyle:"rgba(100, 100, 100, 0.3)",partialNibArrowStyle:"rgba(255, 255, 255, 0.3)",partialNibStrokeStyle:"rgba(150, 150, 150, 0.3)",fullNibStyle:"rgb(100, 100, 100)",fullNibArrowStyle:"rgb(255, 255, 255)",fullNibStrokeStyle:"rgb(150, 150, 150)",scrollTrackFillStyle:"rgba(50, 50, 50, 0.8)",scrollTrackStrokeStyle:"rgb(150, 150, 150)",scrollBarFillStyle:"rgba(0, 0, 0, %a)",
scrollBarFillGradientTopStart:"rgba(90, 90, 90, %a)",scrollBarFillGradientTopStop:"rgba(40, 40, 40, %a)",scrollBarFillGradientBottomStart:"rgba(22, 22, 22, %a)",scrollBarFillGradientBottomStop:"rgba(44, 44, 44, %a)",tabSpace:"#392A25",searchHighlight:"#B55C00",searchHighlightSelected:"#FF9A00",plain:"#bdae9d",keyword:"#42a8ed",string:"#039a0a",comment:"#666666","c-comment":"#666666",punctuation:"#888888",attribute:"#BF9464",test:"rgb(255,0,0)",cdata:"#bdae9d","attribute-value":"#039a0a",tag:"#46a8ed",
color:"#c4646b","tag-name":"#46a8ed",value:"#039a0a",important:"#990000",sizes:"#990000",cssclass:"#BF9464",cssid:"#46a8ed",atom:"#aa4444",variable:"#00cccc",variabledef:"#4422cc",localvariable:"#cc2277",property:"#66bb33",operator:"#88bbff",error:"#FF0000",processing:"#999999",entity:"#AA2222",text:"#00BB00","compile-time-constant":"#776088","predefined-constant":"#33CC33","reserved-language-construct":"#00FF00","predefined-function":"#22FF22","predefined-class":"#22FF22",literal:"#DD4411",identifier:"#22FF22",
func:"#2200FF",type:"#8822FF",decorator:"#2222FF"};b.coffeezebra={};a.mixin(b.coffeezebra,b.coffee);b.coffeezebra.zebraStripeColor="#FFFFFF";b["default"]=b.coffee});
tiki.module("bespin:util/cookie",function(a,b){var c=function(e,g){return e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,function(d){if(g&&g.indexOf(d)!=-1)return d;return"\\"+d})};b.get=function(e){e=new RegExp("(?:^|; )"+c(e)+"=([^;]*)");return(e=document.cookie.match(e))?decodeURIComponent(e[1]):undefined};b.set=function(e,g,d){d=d||{};if(typeof d.expires=="number"){var f=new Date;f.setTime(f.getTime()+d.expires*24*60*60*1E3);d.expires=f}if(d.expires&&d.expires.toUTCString)d.expires=d.expires.toUTCString();
g=encodeURIComponent(g);e=e+"="+g;var h;for(h in d){e+="; "+h;g=d[h];if(g!==true)e+="="+g}document.cookie=e};b.remove=function(e){b.set(e,"",{expires:-1})};b.isSupported=function(){if(!("cookieEnabled"in navigator)){b.set("__djCookieTest__","CookiesAllowed");navigator.cookieEnabled=b.get("__djCookieTest__")=="CookiesAllowed";navigator.cookieEnabled&&b.remove("__djCookieTest__")}return navigator.cookieEnabled}});
tiki.module("bespin:util/path",function(a,b){b.combine=function(){var c=Array.prototype.slice.call(arguments).join("/");c=c.replace(/\/\/+/g,"/");return c=c.replace(/^\s+|\s+$/g,"")};b.directory=function(c){var e=c.split("/");return e.length==1?"":e.length==2&&e[e.length-1]==""?c:e.slice(0,e.length-1).join("/")};b.makeDirectory=function(c){/\/$/.test(c)||(c+="/");return c};b.combineAsDirectory=function(){return this.makeDirectory(this.combine.apply(this,arguments))};b.escape=function(){return escape(this.combine.apply(this,
arguments))};b.trimLeadingSlash=function(c){if(c.indexOf("/")==0)c=c.substring(1,c.length);return c};b.fileType=function(c){if(c.indexOf(".")>=0){c=c.split(".");if(c.length>1)return c[c.length-1]}}});
tiki.module("bespin:util/scratchcanvas",function(a,b){var c=a("sproutcore/runtime").SC,e=c.Object.extend({getContext:function(){return document.getElementById("bespin-scratch-canvas").getContext("2d")},init:function(){if(c.none(document.getElementById("bespin-scratch-canvas"))){var d=document.createElement("canvas");d.id="bespin-scratch-canvas";d.width=400;d.height=300;d.style.position="absolute";d.style.top="-10000px";d.style.left="-10000px";document.body.appendChild(d)}},measureStringWidth:function(d,
f){if(c.none(f))f="M";var h=this.getContext();h.save();h.font=d;d=h.measureText(f).width;h.restore();return d}}),g=null;b.get=function(){if(g===null)g=e.create();return g}});
tiki.module("bespin:util/util",function(a,b){b.queryToObject=function(f,h){var i={};f=f.split(h||"&");var j=decodeURIComponent;f.forEach(function(k){if(k.length){var l=k.split("=");k=j(l.shift());l=j(l.join("="));if(b.isString(i[k]))i[k]=[i[k]];if(Array.isArray(i[k]))i[k].push(l);else i[k]=l}});return i};b.objectToQuery=function(f){var h=encodeURIComponent,i=[],j={};for(var k in f){var l=f[k];if(l!=j[k]){var o=h(k)+"=";if(_d.isArray(l))for(var n=0;n<l.length;n++)i.push(o+h(l[n]));else i.push(o+h(l))}}return i.join("&")};
var c=0,e={};b.rateLimit=function(f,h,i){if(f){var j=c++;return function(){e[j]&&clearTimeout(e[j]);e[j]=setTimeout(function(){i.apply(h,arguments);delete e[j]},f)}}};b.isString=function(f){return typeof f=="string"||f instanceof String};b.isObject=function(f){return f!==undefined&&(f===null||typeof f=="object"||Array.isArray(f)||b.isFunction(f))};b.isFunction=function(){var f=function(h){var i=typeof h;return h&&(i=="function"||h instanceof Function)&&!h.nodeType};return b.isSafari?function(h){if(typeof h==
"function"&&h=="[object NodeList]")return false;return f(h)}:f}();b.endsWith=function(f,h){return f.match(new RegExp(h+"$"))};b.include=function(f,h){return f.indexOf(h)>-1};b.indexOfProperty=function(f,h,i){for(var j=0;j<f.length;j++)if(f[j][h]==i)return j;return null};b.last=function(f){if(Array.isArray(f))return f[f.length-1]};b.shrinkArray=function(f){var h=[],i=true;f.reverse().forEach(function(j){if(!(i&&j===undefined)){i=false;h.push(j)}});return h.reverse()};b.makeArray=function(f,h){if(f<
1)return[];h||(h=" ");for(var i=[],j=0;j<f;j++)i.push(h);return i};b.repeatString=function(f,h){for(var i="",j=0;j<h;j++)i+=f;return i};b.leadingSpaces=function(f){for(var h=0,i=0;i<f.length;i++)if(f[i]==" "||f[i]==""||f[i]===undefined)h++;else return h;return h};b.leadingTabs=function(f){for(var h=0,i=0;i<f.length;i++)if(f[i]=="\t"||f[i]==""||f[i]===undefined)h++;else return h;return h};b.leadingWhitespace=function(f){for(var h=[],i=0;i<f.length;i++)if(f[i]==" "||f[i]=="\t"||f[i]==""||f[i]===undefined)h.push(f[i]);
else return h;return h};b.englishFromCamel=function(f){f.replace(/([A-Z])/g,function(h){return" "+h.toLowerCase()}).trim()};b.OS={LINUX:"LINUX",MAC:"MAC",WINDOWS:"WINDOWS"};a=navigator.userAgent;var g=navigator.appVersion;b.isLinux=g.indexOf("Linux")>=0;b.isWindows=g.indexOf("Win")>=0;b.isWebKit=parseFloat(a.split("WebKit/")[1])||undefined;b.isChrome=parseFloat(a.split("Chrome/")[1])||undefined;b.isMac=g.indexOf("Macintosh")>=0;if(a.indexOf("AdobeAIR")>=0)b.isAIR=1;var d=Math.max(g.indexOf("WebKit"),
g.indexOf("Safari"),0);if(d&&!b.isChrome){b.isSafari=parseFloat(g.split("Version/")[1]);if(!b.isSafari||parseFloat(g.substr(d+7))<=419.3)b.isSafari=2}if(a.indexOf("Gecko")>=0&&!b.isWebKit)b.isMozilla=parseFloat(g);b.getOS=function(){return b.isMac?b.OS.MAC:b.isLinux?b.OS.LINUX:b.OS.WINDOWS};b.contains=document.compareDocumentPosition?function(f,h){return f.compareDocumentPosition(h)&16}:function(f,h){return f!==h&&(f.contains?f.contains(h):true)};b.stopEvent=function(f){f.preventDefault();f.stopPropagation()};
b.randomPassword=function(f){f=f||16;for(var h="",i=0;i<f;i++){var j=Math.floor(Math.random()*62);h+="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".charAt(j)}return h};b.isEmpty=function(f){for(var h in f)if(f.hasOwnProperty(h))return false;return true};b.isMyProject=function(f){return f.indexOf("+")==-1};b.formatDate=function(f){if(!f)return"Unknown";return f.getDate()+" "+b.formatDate.shortMonths[f.getMonth()]+" "+f.getFullYear()};b.formatDate.shortMonths=["Jan","Feb","Mar","Apr",
"May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});
tiki.module("bespin:views/dock",function(a,b){var c=a("sproutcore/runtime").SC;b.DOCK_BOTTOM="bottom";b.DockView=c.View.extend({classNames:["bespin-dock-view"],centerView:c.View,dockedViews:[],addDockedView:function(e,g){var d=this.get("dockedViews");if(c.none(g))g=d.length;var f=this;e=this.createChildView(e,{layoutView:this,rootElementPath:[g],_bespin_dockView_frameDidChange:function(){f._updateChildLayout()}.observes("frame")});return d[g]=e},createChildViews:function(){var e=this.createChildView(this.get("centerView"),
{layoutView:this});this.set("centerView",e);e=[e];for(var g=this.get("dockedViews"),d=0;d<g.length;d++)e.push(this.addDockedView(g[d],d));this.set("childViews",e);return this},_updateChildLayout:function(){var e={left:0,bottom:0,top:0,right:0};this.get("dockedViews").forEach(function(g){var d=g.get("frame");g=g.get("dock");switch(g){case b.DOCK_BOTTOM:e.bottom+=d.height;break;default:throw"invalid 'dock' property: "+g;}});this.get("centerView").adjust(e)},renderLayout:function(){this._updateChildLayout();
arguments.callee.base.apply(this,arguments)}})});tiki.module("bespin:index",function(){});tiki.register("AppSupport",{});
tiki.module("AppSupport:controllers/undomanager",function(a,b){a=a("sproutcore/runtime").SC;b.undoManager=a.Object.create({_redoStack:null,_undoStack:null,_undoOrRedo:function(c,e,g){if(e.length===0)return false;e=e.pop();if(!e.target[c](e.context)){this._redoStack=[];this._undoStack=[];return false}g.push(e);return true},init:function(){this._redoStack=[];this._undoStack=[]},redo:function(){return this._undoOrRedo("redo",this._redoStack,this._undoStack)},registerUndo:function(c,e){this._redoStack=
[];this._undoStack.push({target:c,context:e})},undo:function(){return this._undoOrRedo("undo",this._undoStack,this._redoStack)}});b.undoManagerCommand=function(c,e,g){b.undoManager[g.name]()}});tiki.module("AppSupport:views/keylistener",function(a,b){var c=a("sproutcore/runtime").SC,e=a("Canon:keyboard").keyboardManager;b.KeyListener=c.Responder.extend({performKeyEquivalent:function(g,d){e.processKeyEvent(d,this,{isApplication:true})}})});tiki.module("AppSupport:index",function(){});
tiki.register("Canon",{});tiki.module("Canon:arguments",function(a,b){var c=a("bespin:plugins").catalog;b.string={convert:function(e){return e.toString()}};b.integer={convert:function(e){return parseInt(e,10)}};b.model={acceptsInput:false,getDefault:function(){return c.getObject("model")}};b.view={acceptsInput:false,getDefault:function(){return c.getObject("view")}}});
tiki.module("Canon:commands",function(a,b){var c=a("Canon:directory").rootCanon,e=a("bespin:util/util");a=a("plugins").catalog;var g=a.getObject("files"),d=a.getObject("editor"),f=a.getObject("editSession"),h=a.getObject("server");b.loadCommand=function(i,j){j?g.loadContents(g.userSettingsProject,"commands/"+j+".js",function(k){try{var l=eval(k.content);c.addCommand(l)}catch(o){i.addErrorOutput("Something is wrong about the command:<br><br>"+o)}},true):i.addUsageOutput(this)};b.editCommand=function(i,
j){j?d.openFile(g.userSettingsProject,"commands/"+j+".js",{content:"{\n    name: '"+j+"',\n    takes: [YOUR_ARGUMENTS_HERE],\n    preview: 'execute any editor action',\n    execute: function(self, args) {\n\n    }\n}",force:true}):i.addUsageOutput(this)};b.listCommand=function(i){h.list(g.userSettingsProject,"commands/",function(j){if(!j||j.length<1)i.addOutput("You haven't installed any custom commands.<br>Want to <a href='https://wiki.mozilla.org/Labs/Bespin/Roadmap/Commands'>learn how?</a>");else{var k=
"<u>Your Custom Commands</u><br/><br/>";j=j.filter(function(l){return e.endsWith(l.name,"\\.js")});k+=j.map(function(l){return l.name.replace(/\.js$/,"")}).join("<br>");i.addOutput(k)}})};b.deleteCommand=function(i,j){if(j){var k=g.userSettingsProject,l="commands/"+j+".js",o=i.link(function(){f.checkSameFile(k,l)&&d.model.clear();i.addOutput("Removed command: "+j)}),n=i.link(function(r){i.addOutput("Wasn't able to remove the command <b>"+j+"</b><br/><em>Error</em> (probably doesn't exist): "+r.responseText)});
g.removeFile(k,l,o,n)}else i.addUsageOutput(this)}});
tiki.module("Canon:directory",function(a,b){var c=a("sproutcore/runtime").SC,e=a("bespin:plugins").catalog;b.newCommandHandler=function(d){b.rootCanon.addCommand(d)};b.Command=c.Object.extend({extension:null,init:function(){this.set("takesArgs",this.get("takes")!=undefined);this._normalizeTakes()},load:function(d){this.get("extension").load(d)},execute:function(){var d=arguments,f=this;this.load(function(h){h.apply(f,d)})},_normalizeTakes:function(){var d=[],f=this;this._noInputList=[];var h=this.get("takes");
h&&h.forEach(function(i){if(typeof i=="string")d.push(i);else{var j=i.type||"string",k=e.getExtensionByKey("argumentType",j);if(k)if(k.noInput)f._noInputList.push(k);else i.name?d.push(i.name):d.push(j);else console.error("Command ",i.name," requires an argument of type ",j," which is undefined")}});this._paramList=d.join(" ")},getArgs:function(d,f){if(this.get("takes")){var h=d.join(" ");d=g.create({input:h,options:{params:this._paramList}});d.rawinput=h;this.convertArguments(d,f)}else f(undefined)},
convertArguments:function(d,f){var h=0,i=false,j=this.get("takes").length;this.get("takes").forEach(function(k){if(typeof k=="string")h++;else{var l=k.name||k.type,o=e.getExtensionByKey("argumentType",k.type||"string");if(o)o.load(function(n){h++;if(d[l]!=undefined){if(n.convert)d[l]=n.convert(d[l])}else if(k["default"])d[l]=k["default"];else if(n.getDefault)d[l]=n.getDefault();if(h==j){f(d);i=true}});else h++}});h==j&&!i&&f(d)},getFullCommandName:function(){var d=this.get("name");if(this.get("parent"))d=
this.parent.getFullCommandName()+" "+d;return d.trim()},findCompletions:function(d,f){d.hint=this.completeText;f(d)}});b.Canon=c.Object.extend({commands:{},aliases:{},command:null,parent:null,init:function(){if(this.parent){this.containerCommand=this.command;this.command.takes=["*"];this.command.subcommands=this;this.parent.addCommand(this.command)}},addCommand:function(d){if(d){var f=b.Command.create(d);f.set("parent",this);f.set("extension",d);this.commands[f.get("name")]=f;f.aliases&&f.aliases.forEach(function(h){this.aliases[h]=
f.name},this)}},removeCommand:function(d){d&&delete this.commands[d.name]},getFullCommandName:function(){var d=this.containerCommand?this.containerCommand.name:"";if(this.parent)d=this.parent.getFullCommandName()+" "+d;return d.trim()},filterOptionsByPrefix:function(d,f){return d.filter(function(h){return h.substr(0,f.length)===f})},findCommand:function(d){d=d.trim().split(/\s+/);var f=d.shift();f=this.commands[f]||this.commands[this.aliases[f]];if(!f)return d.length>0?null:this;return f.subcommands?
f.subcommands.findCommand(d.join(" ")):f},findCompletions:function(d,f){if(d.action.length>1)d.error="No matches";else{var h=d.action[0];if(!(h.length===0&&this.parent)){var i=[];for(var j in this.commands)j.indexOf(h)===0&&i.push(j);for(var k in this.aliases)k.indexOf(h)===0&&i.push(k);if(i.length==1){h=i[0];j=this.commands[h]||this.commands[this.aliases[h]];if(j.get("takesArgs"))h+=" ";d.autofill=d.prefix+h;d.hint=j.preview}else if(i.length===0)d.error="No matches";else{i.sort(function(l,o){return l.localeCompare(o)});
d.options=i}}}f(d)},getHelp:function(d,f){var h=[],i,j;if(this.commands[d]){i=this.commands[d];h.push(i.description?i.description:i.preview)}else{var k=false;if(d){if(d=="hidden"){d="";k=true}h.push("<h2>Commands starting with '"+d+"':</h2>")}else h.push("<h2>Available Commands:</h2>");i=[];for(j in this.commands)i.push(j);var l=i.sort();h.push("<table>");for(var o=0;o<l.length;o++){j=l[o];i=this.commands[j];if(!(!k&&i.hidden))if(i.preview!==undefined)if(!(d&&j.indexOf(d)!==0)){var n=i.takes?" ["+
i._paramList.split(" ").join("] [")+"]":"";h.push("<tr>");h.push("<th>"+j+"</th>");h.push("<td>"+i.preview+"</td>");h.push("<td>"+n+"</td>");h.push("</tr>")}}h.push("</table>")}d=h.join("");if(f&&f.prefix)d=f.prefix+d;if(f&&f.suffix)d+=f.suffix;return d}});b.rootCanon=new b.Canon;var g=c.Object.extend({input:null,options:{},init:function(){this._splitterRegex=new RegExp(this.options.splitBy||"\\s+");this.pieces=this.tokenize(this.input.split(this._splitterRegex));if(this.options.params){this._nametoindex=
{};for(var d=this.options.params.split(" "),f=0;f<d.length;f++){this._nametoindex[d[f]]=f;this.options.noshortcutvalues||(this[d[f]]=this.pieces[f])}}this.sc_super()},tokenize:function(d){for(var f=[],h;h=d.shift();)if(h[0]=='"'||h[0]=="'"){h=[h.substring(1,h.length)];for(var i;i=d.shift();)if(i[i.length-1]=='"'||i[i.length-1]=="'"){h.push(i.substring(0,i.length-1));break}else h.push(i);f.push(h.join(" "))}else f.push(h);return f},param:function(d){return typeof d=="number"?this.pieces[d]:this.pieces[this._nametoindex[d]]},
length:function(){return this.pieces.length}})});
tiki.module("Canon:instruction",function(a,b){a=a("sproutcore/runtime").SC;b.Instruction=a.Object.extend({output:"",_outstanding:0,_callbacks:[],completed:false,historical:false,init:function(){if(this.historical)this.completed=true;else this.start=new Date},exec:function(){try{this._parseError?this.addErrorOutput(this._parseError):this.command.execute(this,this.args,this.command)}catch(c){c instanceof TypeError&&console.error(c);this.addErrorOutput(c)}finally{if(this._outstanding==0){this.completed=
true;this._callbacks.forEach(function(e){e()})}}},link:function(c,e){this._outstanding++;return function(){try{c.apply(e||window,arguments)}finally{this._outstanding--;if(this._outstanding===0){this.completed=true;this._callbacks.forEach(function(g){g()})}}}.bind(this)},unlink:function(){this._outstanding=0;this.completed=true;this._callbacks.forEach(function(c){c()})},toString:function(){return JSON.stringify({output:this.output,start:this.start?this.start.getTime():-1,end:this.end?this.end.getTime():
-1})},addOutput:function(c){if(c&&c!==""){if(this.output!=="")this.output+="<br/>";this.output+=c}this.element=null;this.hideOutput=false;this.end=new Date;this._callbacks.forEach(function(e){e(c)})},addErrorOutput:function(c){this.error=true;this.addOutput(c)},addUsageOutput:function(c){this.error=true;this.addOutput("Usage: "+c.name+" "+(c.usage||"no usage information found for "+c.name))},onOutput:function(c){c.call(null,this.output);this._callbacks.push(c)},setElement:function(c){this.element=
c;this.end=new Date;this.error=this.hideOutput=false;this._callbacks.forEach(function(e){e()})}})});
tiki.module("Canon:keyboard",function(a,b){var c=a("sproutcore/runtime").SC,e=a("instruction").Instruction,g=a("directory").rootCanon;a=c.Object.extend({_commandMatches:function(d,f,h){var i=d.key;if(!i)return false;if(typeof i=="string"){if(i!=f)return false;return true}if(!i.isArray){i=[i];d.key=i}for(d=0;d<i.length;d++){var j=i[d];if(typeof j=="string"){if(j==f)return true}else if(j.key==f){f=j.predicates;if(!f)return true;for(var k in f)if(!h||h[k]!=f[k])return false;return true}}return false},
processKeyEvent:function(d,f,h){d=d.commandCodes()[0];f=g.get("commands");for(var i in f){var j=f[i];if(this._commandMatches(j,d,h)){j.getArgs([],function(k){e.create({command:j,args:k}).exec()});return true}}return false}});b.keyboardManager=a.create()});tiki.module("Canon:index",function(){});tiki.register("Editor",{});
tiki.module("Editor:commands/editor",function(a,b){var c=a("bespin:util/util"),e=a("bespin:plugins").catalog.getObject("settings");b.gotoCommand=function(g,d){if(d){g=parseInt(d,10);editor.moveAndCenter(g);editor.focus()}};b.replaceCommand=function(g,d){editor.replace(d)};b.sortCommand=function(g,d){g=editor.getDocument().split(/\n/);g.sort();d&&/^desc/.test(d.toLowerCase())&&g.reverse();editor.insertDocument(g.join("\n"))};b.entabCommand=function(g,d){if(!d)d=e.values.tabsize;editor.replace({search:" {"+
d+"}",replace:"\t"})};b.detabCommand=function(g,d){if(!d)d=e.values.tabsize;editor.replace({search:"\t",replace:c.repeatString(" ",d)})};b.trimCommand=function(g,d){d||(d="right");g={replace:""};if(c.include(["left","both"],d)){g.search="^\\s+";editor.replace(g)}if(c.include(["right","both"],d)){g.search="\\s+$";editor.replace(g)}};b.ucCommand=function(){editor.selectionChangeCase({stringCase:"u"})};b.lcCommand=function(){editor.selectionChangeCase({stringCase:"l"})}});
tiki.module("Editor:controllers/layoutmanager",function(a,b){var c=a("sproutcore/runtime").SC,e=a("mixins/multidelegate").MultiDelegateSupport,g=a("utils/range"),d=a("models/textstorage").TextStorage;a=a("bespin:plugins").catalog;b.LayoutManager=c.Object.extend(e,{_characterWidth:8,_layoutAnnotations:null,_lineHeight:20,_maximumWidth:0,margin:{left:5,bottom:6,top:0,right:12},pluginCatalog:a,textLines:null,textStorage:d,theme:{editorTextColor:"rgb(230, 230, 230)"},_computeInvalidRects:function(f,h){var i=
this.characterRectForPosition(f.start),j={x:i.x,y:i.y,width:Number.MAX_VALUE,height:i.height};return f.end.row===h.end.row?[j]:[j,{x:0,y:i.y+this._lineHeight,width:Number.MAX_VALUE,height:Number.MAX_VALUE}]},_lastCharacterPosition:function(){return{row:this.get("textLines").length-1,column:this._maximumWidth}},_recalculateMaximumWidth:function(){var f=0;this.get("textLines").forEach(function(h){h=h.characters.length;if(f<h)f=h});this._maximumWidth=f},_recomputeEntireLayout:function(){var f=this.get("textStorage").range();
this._recomputeLayoutForRanges(f,f)},_recomputeLayoutForRanges:function(f,h){var i=this.get("theme"),j=f.start.row;this.textLines.replace(j,f.end.row-j+1,this.getPath("textStorage.lines").slice(j,h.end.row+1).map(function(k){return{characters:k,colors:[{start:0,end:k.length,color:i.editorTextColor}]}}));this._recalculateMaximumWidth();this._runAnnotations(g.unionRanges(f,h));this.notifyDelegates("layoutManagerInvalidatedRects",this._computeInvalidRects(f,h))},_runAnnotations:function(f){var h=this.get("textLines");
this._layoutAnnotations.forEach(function(i){f=i.annotateLayout(h,f)});return f},boundingRect:function(){return this.rectsForRange({start:{row:0,column:0},end:{row:this.get("textLines").length-1,column:this._maximumWidth}})[0]},characterAtPoint:function(f){var h=this.get("margin"),i=f.x-h.left,j=f.y-h.top;f=this._characterWidth;h=this.get("textStorage");j=h.clampPosition({row:Math.floor(j/this._lineHeight),column:Math.floor(i/f)});h=h.get("lines")[j.row].length;return c.mixin(j,{partialFraction:i<
0||j.column===h?0:i%f/f})},characterRangeForBoundingRect:function(f){var h=this._lineHeight,i=this._characterWidth,j=this.get("margin"),k=f.x-j.left;j=f.y-j.top;return{start:{row:Math.max(Math.floor(j/h),0),column:Math.max(Math.floor(k/i),0)},end:{row:Math.floor((j+f.height-1)/h),column:Math.floor((k+f.width-1)/i)+1}}},characterRectForPosition:function(f){return this.rectsForRange({start:f,end:{row:f.row,column:f.column+1}})[0]},createTextStorage:function(){this.set("textStorage",this.get("textStorage").create())},
init:function(){this._layoutAnnotations=[];this.set("textLines",[{characters:"",colors:[{start:0,end:0,color:this.get("theme").editorTextColor}]}]);this.createTextStorage();this.get("textStorage").addDelegate(this);var f=this;this.get("pluginCatalog").getExtensions("layoutannotations").forEach(function(h){h.load(function(i){f._layoutAnnotations.push(i);f._recomputeEntireLayout()},"layoutannotation")});this._recomputeEntireLayout()},lineRectForRow:function(f){return this.rectsForRange({start:{row:f,
column:0},end:{row:f,column:this._maximumWidth}})[0]},rectForPosition:function(f){var h=this.get("margin"),i=this._characterWidth,j=this._lineHeight;return{x:h.left+i*f.column,y:h.top+j*f.row,width:i,height:j}},rectsForRange:function(f){var h=this._characterWidth,i=this._lineHeight,j=this._maximumWidth,k=this.get("margin"),l=f.start,o=f.end;f=l.row;var n=l.column;l=o.row;o=o.column;if(f===l)return[{x:k.left+h*n,y:k.top+i*f,width:h*(o-n),height:i}];var r=[],p;if(n===0)p=f;else{p=f+1;r.push({x:k.left+
h*n,y:k.top+i*f,width:h*(j-n),height:i})}if(o===0)f=l-1;else if(o===j)f=l;else{f=l-1;r.push({x:k.left,y:k.top+i*l,width:h*o,height:i})}r.push({x:k.left,y:k.top+i*p,width:h*j,height:i*(f-p+1)});return r},textStorageEdited:function(f,h,i){this._recomputeLayoutForRanges(h,i)}})});
tiki.module("Editor:controllers/undo",function(a,b){var c=a("sproutcore/runtime").SC,e=a("AppSupport:controllers/undomanager").undoManager;b.EditorUndoController=c.Object.extend({_inTransaction:false,_record:null,textView:null,_beginTransaction:function(){if(this._inTransaction){console.trace();throw"UndoController._beginTransaction() called with a transaction already in place";}this._inTransaction=true;this._record={patches:[]}},_endTransaction:function(){if(!this._inTransaction)throw"UndoController._endTransaction() called without a transaction in place";
e.registerUndo(this,this._record);this._record=null;this._inTransaction=false},_tryApplyingPatches:function(g){var d=this.getPath("textView.layoutManager.textStorage");g.forEach(function(f){d.replaceCharacters(f.oldRange,f.newCharacters)});return true},_undoOrRedo:function(g,d){if(this._inTransaction)throw"UndoController._undoOrRedo() called while in a transaction";if(!this._tryApplyingPatches(g))return false;this.get("textView").setSelection(d);return true},init:function(){this._redoStack=[];this._undoStack=
[];this.get("textView").addDelegate(this)},redo:function(g){return this._undoOrRedo(g.patches,g.selectionAfter)},textViewBeganChangeGroup:function(g,d){this._beginTransaction();this._record.selectionBefore=d},textViewEndedChangeGroup:function(g,d){this._record.selectionAfter=d;this._endTransaction()},textViewReplacedCharacters:function(g,d,f){if(!this._inTransaction)throw"UndoController.textViewReplacedCharacters() called outside a transaction";this._record.patches.push({oldCharacters:this._deletedCharacters,
oldRange:d,newCharacters:f,newRange:this.getPath("textView.layoutManager.textStorage").resultingRangeForReplacement(d,f.split("\n"))});this._deletedCharacters=null},textViewWillReplaceRange:function(g,d){if(!this._inTransaction)throw"UndoController.textViewWillReplaceRange() called outside a transaction";this._deletedCharacters=this.getPath("textView.layoutManager.textStorage").getCharacters(d)},undo:function(g){return this._undoOrRedo(g.patches.map(function(d){return{oldCharacters:d.newCharacters,
oldRange:d.newRange,newCharacters:d.oldCharacters,newRange:d.oldRange}}),g.selectionBefore)}})});tiki.module("Editor:mixins/multidelegate",function(a,b){a("sproutcore/runtime");b.MultiDelegateSupport={delegates:[],addDelegate:function(c){this.set("delegates",this.get("delegates").concat(c))},notifyDelegates:function(c){for(var e=[this],g=1;g<arguments.length;g++)e.push(arguments[g]);this.get("delegates").forEach(function(d){d.respondsTo(c)&&d[c].apply(d,e)})}}});
tiki.module("Editor:mixins/textbuffer",function(a,b){a("sproutcore/runtime");b.TextBuffer={deleteCharacters:function(c){this.replaceCharacters(c,"")},insertCharacters:function(c,e){this.replaceCharacters({start:c,end:c},e)},resultingRangeForReplacement:function(c,e){var g=e.length;c=c.start;return{start:c,end:{row:c.row+g-1,column:(g===1?c.column:0)+e[g-1].length}}}}});
tiki.module("Editor:models/textstorage",function(a,b){var c=a("sproutcore/runtime").SC,e=a("mixins/multidelegate").MultiDelegateSupport;a=a("mixins/textbuffer").TextBuffer;b.TextStorage=c.Object.extend(e,a,{lines:null,value:function(g,d){d!==undefined&&this.replaceCharacters(this.range(),d);return this.get("lines").join("\n")}.property("lines.[]"),clampPosition:function(g){var d=this.get("lines"),f=g.row;if(f<0)return{row:0,column:0};else if(f>=d.length)return this.range().end;return{row:f,column:Math.max(0,
Math.min(g.column,d[f].length))}},displacePosition:function(g,d){var f=g.row,h=g.column;switch(d){case -1:if(f===0&&h==0)return g;return h===0?{row:f-1,column:this.get("lines")[f-1].length}:{row:f,column:h-1};case 1:d=this.get("lines");var i=d[f].length;if(f===d.length-1&&h===i)return g;return h===i?{row:f+1,column:0}:{row:f,column:h+1};default:throw"TextStorage.displacePosition(): count must be 1 or -1";}},getCharacters:function(g){var d=this.get("lines"),f=g.start,h=g.end;g=f.row;var i=h.row;f=
f.column;h=h.column;if(g===i)return d[g].substring(f,h);return[d[g].substring(f)].concat(d.slice(g+1,i),d[i].substring(0,h)).join("\n")},init:function(){this.superclass();this.set("delegates",[]);this.set("lines",[""])},range:function(){var g=this.get("lines");return{start:{row:0,column:0},end:{row:g.length-1,column:g[g.length-1].length}}},replaceCharacters:function(g,d){d=d.split("\n");var f=d.length,h=this.resultingRangeForReplacement(g,d),i=g.start,j=g.end,k=i.row,l=j.row;i=i.column;var o=this.get("lines");
d[0]=o[k].substring(0,i)+d[0];d[f-1]+=o[l].substring(j.column);o.replace(k,l-k+1,d);this.notifyDelegates("textStorageEdited",g,h)}})});
tiki.module("Editor:utils/range",function(a,b){var c=a("sproutcore/runtime").SC;b.addPositions=function(e,g){return{row:e.row+g.row,column:e.column+g.column}};b.comparePositions=function(e,g){var d=e.row-g.row;return d===0?e.column-g.column:d};b.extendRange=function(e,g){var d=e.end;return{start:e.start,end:{row:d.row+g.row,column:d.column+g.column}}};b.intersectRangeSets=function(e,g){e=c.clone(e);g=c.clone(g);for(var d=[];e.length>0&&g.length>0;){var f=e.shift(),h=g.shift(),i=b.comparePositions(f.start,
h.start),j=b.comparePositions(f.end,h.end);if(b.comparePositions(f.end,h.start)<0){d.push(f);g.unshift(h)}else if(b.comparePositions(h.end,f.start)<0){d.push(h);e.unshift(f)}else if(i<0){d.push({start:f.start,end:h.start});e.unshift({start:h.start,end:f.end});g.unshift(h)}else if(i===0)if(j<0)g.unshift({start:f.end,end:h.end});else j>0&&e.unshift({start:h.end,end:f.end});else if(i>0){d.push({start:h.start,end:f.start});e.unshift(f);g.unshift({start:f.start,end:h.end})}}return d.concat(e,g)};b.isZeroLength=
function(e){return e.start.row===e.end.row&&e.start.column===e.end.column};b.maxPosition=function(e,g){return b.comparePositions(e,g)>0?e:g};b.normalizeRange=function(e){return this.comparePositions(e.start,e.end)<0?e:{start:e.end,end:e.start}};b.rangeSetBoundaries=function(e){return{start:e[0].start,end:e[e.length-1].end}};b.toString=function(e){var g=e.start;e=e.end;return"[ %@,%@ %@,%@ ]".fmt(g.row,g.column,e.row,e.column)};b.unionRanges=function(e,g){return{start:e.start.row<g.start.row||e.start.row===
g.start.row&&e.start.column<g.start.column?e.start:g.start,end:e.end.row>g.end.row||e.end.row===g.end.row&&e.end.column>g.end.column?e.end:g.end}}});
tiki.module("Editor:utils/rect",function(a,b){var c=a("sproutcore/runtime").SC;b._distanceFromBounds=function(e,g,d){if(e<g)return e-g;if(e>=d)return e-d;return 0};b.addRectToSet=function(e,g){e=e.concat(g);do{g=false;for(var d=[],f=0;f<e.length;f++){var h=e[f];d.push(h);for(var i=f+1;i<e.length;i++){var j=e[i];if(b.rectsIntersect(h,j)){e.removeAt(i,1);d[d.length-1]=c.unionRects(h,j);g=true;break}}}e=d}while(g);return e};b.offsetFromRect=function(e,g){return{x:b._distanceFromBounds(g.x,e.x,c.maxX(e)),
y:b._distanceFromBounds(g.y,e.y,c.maxY(e))}};b.rectsIntersect=function(e,g){e=c.intersectRects(e,g);return e.width!==0&&e.height!==0}});
tiki.module("Editor:views/canvas",function(a,b){var c=a("sproutcore/runtime").SC,e=a("utils/rect");b.CanvasView=c.View.extend({_canvasDom:null,_canvasId:null,_invalidRects:null,_lastRedrawTime:null,_previousClippingFrame:null,_redrawTimer:null,_clippingFrameChanged:function(){var g=this._previousClippingFrame,d=this.get("clippingFrame");if(g===null||!c.rectsEqual(d,g)){this._previousClippingFrame=d;this.setNeedsDisplay()}}.observes("clippingFrame"),_isVisibleInWindowChanged:function(){this.get("isVisibleInWindow")&&
this.redraw()}.observes("isVisibleInWindow"),_layoutChanged:function(){this._resizeToFit()}.observes("layout"),_parentViewFrameChanged:function(){this._resizeToFit()},_resizeToFit:function(){var g=this.getPath("parentView.frame"),d=this.get("frame"),f=d.width,h=d.height,i=g.width;g=g.height;f>=i&&h>=g||this.set("layout",{left:d.x,top:d.y,width:Math.max(f,i),height:Math.max(h,g)})},canvasContext2D:function(){return this.get("_canvasDom").getContext("2d")}.property("_canvasDom").cacheable(),layoutStyle:{left:"0px",
top:"0px"},minimumRedrawDelay:1E3/30,init:function(){arguments.callee.base.apply(this,arguments);this._invalidRects=[];this.get("parentView").addObserver("frame",this,this._parentViewFrameChanged)},redraw:function(){if(!this.get("isVisibleInWindow"))return false;var g=this.get("frame");g.x<0&&this.computeFrameWithParentFrame(null);var d=this.get("canvasContext2D");d.save();d.translate(g.x,g.y);var f=this.get("clippingFrame");this._invalidRects.forEach(function(h){d.save();h=c.intersectRects(h,f);
if(h.width!==0&&h.height!==0){var i=h.x,j=h.y,k=h.width,l=h.height;d.beginPath();d.moveTo(i,j);d.lineTo(i+k,j);d.lineTo(i+k,j+l);d.lineTo(i,j+l);d.closePath();d.clip();this.drawRect(h,d)}d.restore()},this);d.restore();this._invalidRects=[];this._lastRedrawTime=(new Date).getTime();return true},renderLayout:function(g,d){arguments.callee.base.apply(this,arguments);var f=this.getPath("parentView.frame");if(d){g.attr("width",f.width);g.attr("height",f.height)}else{var h=this._canvasDom,i=h.width!==f.width,
j=h.height!==f.height;if(i)h.width=f.width;if(j)h.height=f.height;if(i||j)this.setNeedsDisplay()}},drawRect:function(){},didCreateLayer:function(){arguments.callee.base.apply(this,arguments);this.set("_canvasDom",this.$("#"+this._canvasId)[0])},render:function(g,d){arguments.callee.base.apply(this,arguments);if(d){var f=this.getPath("parentView.frame"),h=g.begin("canvas");this._canvasId=c.guidFor(h);h.id(this._canvasId);h.attr("width",""+f.width);h.attr("height",""+f.height);h.push("canvas tag not supported by your browser");
h.end()}else c.RunLoop.currentRunLoop.invokeLast(this,this.tryRedraw)},setNeedsDisplay:function(){var g=this.get("frame");this._invalidRects=[{x:0,y:0,width:g.width,height:g.height}];this.set("layerNeedsUpdate",true)},setNeedsDisplayInRect:function(g){this._invalidRects=e.addRectToSet(this._invalidRects,g);this.set("layerNeedsUpdate",true)},tryRedraw:function(){var g=(new Date).getTime(),d=this._lastRedrawTime,f=this.get("minimumRedrawDelay");if(d===null||g-d>=f)this.redraw();else{g=this._redrawTimer;
if(!(g!==null&&g.get("isValid")))this._redrawTimer=c.Timer.schedule({target:this,action:this.redraw,interval:f,repeats:false})}}})});
tiki.module("Editor:views/editor",function(a,b){var c=a("sproutcore/runtime").SC,e=a("views/gutter").GutterView,g=a("controllers/layoutmanager").LayoutManager,d=a("views/scroll").ScrollView,f=a("views/text").TextView;a=a("controllers/undo").EditorUndoController;b.EditorView=c.View.extend(c.Border,{borderStyle:c.BORDER_GRAY,gutterView:e,layoutManager:g,scrollView:d,textView:f,undoController:a,_gutterViewFrameChanged:function(){this.get("scrollView").adjust({left:this.getPath("gutterView.frame").width})},
_scrollViewVerticalScrollOffsetChanged:function(){this.setPath("gutterView.verticalScrollOffset",this.getPath("scrollView.verticalScrollOffset"))},createChildViews:function(){var h=this.get("layoutManager"),i=this.get("scrollView"),j=this.createChildView(this.get("gutterView"),{layoutManager:h});this.set("gutterView",j);j.addObserver("frame",this,this._gutterViewFrameChanged);var k=this.get("textView");h=this.createChildView(i,{contentView:k.extend({layoutManager:h,undoController:this.get("undoController")}),
layout:{left:j.get("frame").width,bottom:0,top:0,right:0}});this.set("scrollView",h);h.addObserver("verticalScrollOffset",this,this._scrollViewVerticalScrollOffsetChanged);i=h.get("contentView");this.set("textView",i);this.set("undoController",this.get("undoController").create({textView:i}));this.set("childViews",[j,h])},init:function(){this.set("layoutManager",this.get("layoutManager").create());return arguments.callee.base.apply(this,arguments)}})});
tiki.module("Editor:views/gutter",function(a,b){var c=a("sproutcore/runtime").SC,e=a("views/canvas").CanvasView;a("bespin:util/scratchcanvas");var g=e.extend({_lineAscent:16,theme:{gutterStyle:"#4c4a41",lineNumberColor:"#e5c138",lineNumberFont:"10pt Monaco, Lucida Console, monospace",editorTextFont:"10pt Monaco, Lucida Console, monospace"},_frameChanged:function(){this.setNeedsDisplay()}.observes("frame"),drawRect:function(d,f){var h=this.get("theme");f.fillStyle=h.gutterStyle;f.fillRect(d.x,d.y,
d.width,d.height);f.save();var i=this.get("parentView"),j=i.get("padding");f.translate(j.left,0);f.fillStyle=h.lineNumberColor;f.font=h.lineNumberFont;h=i.get("layoutManager");j=h.characterRangeForBoundingRect(d);d=Math.min(j.end.row,h.get("textLines").length-1);i=this._lineAscent;for(j=j.start.row;j<=d;j++)f.fillText(""+(j+1),-0.5,h.lineRectForRow(j).y+i-0.5);f.restore()}});b.GutterView=c.View.extend({_interiorView:null,layout:{left:0,top:0,bottom:0,width:32},layoutManager:null,padding:{bottom:30,
left:5,right:10},verticalScrollOffset:0,_recomputeLayout:function(){var d=this.get("layoutManager"),f=this.get("padding");this.set("layout",c.mixin(c.clone(this.get("layout")),{width:32}));this._interiorView.set("layout",{left:0,top:-this.get("verticalScrollOffset"),width:this.get("frame").width,height:d.boundingRect().height+f.bottom})},_verticalScrollOffsetChanged:function(){this._recomputeLayout()}.observes("verticalScrollOffset"),createChildViews:function(){var d=this.createChildView(g);this._interiorView=
d;this.get("frame");this._recomputeLayout();this.set("childViews",[d])},init:function(){arguments.callee.base.apply(this,arguments);this.get("layoutManager").addDelegate(this)},layoutManagerInvalidatedRects:function(){this._recomputeLayout()}})});
tiki.module("Editor:views/scroll",function(a,b){var c=a("sproutcore/runtime").SC;a=a("views/scroller").BespinScrollerView;b.ScrollView=c.ScrollView.extend({_containerViewLaidOut:false,autohidesHorizontalScroller:false,autohidesVerticalScroller:false,borderStyle:c.BORDER_NONE,hasHorizontalScroller:true,hasVerticalScroller:true,horizontalScrollerThickness:24,horizontalScrollerView:a,verticalScrollerThickness:24,verticalScrollerView:a,tile:function(){if(!this._containerViewLaidOut){var e=this.get("containerView");
e.adjust({left:0,bottom:0,top:0,right:0});e.updateLayout();this._containerViewLaidOut=true}var g=this.get("horizontalScrollerView"),d=this.get("verticalScrollerView");g=this.get("isHorizontalScrollerVisible");d=this.get("isVerticalScrollerVisible");e=this.get("horizontalScrollerThickness");var f=this.get("verticalScrollerThickness");if(g){g=this.get("horizontalScrollerView");g.set("scrollerThickness",e);g.set("padding",{top:0,bottom:6,left:6,right:6+f});g.set("layout",{left:0,bottom:0,right:0,height:e})}if(d){d=
this.get("verticalScrollerView");d.set("scrollerThickness",f);d.set("padding",{left:0,right:6,top:6,bottom:6+e});d.set("layout",{top:0,right:0,bottom:0,width:f})}this.get("contentView").get("hasPadding")===true&&this.get("contentView").set("padding",{bottom:e+6,right:f+6})}})});
tiki.module("Editor:views/scroller",function(a,b){var c=a("sproutcore/runtime").SC,e=a("views/canvas").CanvasView.extend({classNames:["bespin-scroller-view"],_mouseDownScreenPoint:null,_mouseDownValue:null,_isMouseOver:false,theme:{backgroundStyle:"#2A211C",partialNibStyle:"rgba(100, 100, 100, 0.3)",partialNibArrowStyle:"rgba(255, 255, 255, 0.3)",partialNibStrokeStyle:"rgba(150, 150, 150, 0.3)",fullNibStyle:"rgb(100, 100, 100)",fullNibArrowStyle:"rgb(255, 255, 255)",fullNibStrokeStyle:"rgb(150, 150, 150)",
scrollTrackFillStyle:"rgba(50, 50, 50, 0.8)",scrollTrackStrokeStyle:"rgb(150, 150, 150)",scrollBarFillStyle:"rgba(0, 0, 0, %a)",scrollBarFillGradientTopStart:"rgba(90, 90, 90, %a)",scrollBarFillGradientTopStop:"rgba(40, 40, 40, %a)",scrollBarFillGradientBottomStart:"rgba(22, 22, 22, %a)",scrollBarFillGradientBottomStop:"rgba(44, 44, 44, %a)"},_drawNib:function(g){var d=this.get("theme"),f,h;if(this._isMouseOver){f=d.fullNibStyle;h=d.fullNibArrowStyle;d=d.fullNibStrokeStyle}else{f=d.partialNibStyle;
h=d.partialNibArrowStyle;d=d.partialNibStrokeStyle}var i=Math.floor(7.5);g.fillStyle=f;g.beginPath();g.arc(0,0,Math.floor(7.5),0,Math.PI*2,true);g.closePath();g.fill();g.strokeStyle=d;g.stroke();g.fillStyle=h;g.beginPath();g.moveTo(0,-i+3);g.lineTo(-i+3,i-5);g.lineTo(i-3,i-5);g.closePath();g.fill()},_drawNibs:function(g){var d=this._isMouseOver,f=this._getClientThickness(),h=this.getPath("parentView.value");if(d||h!==0){g.save();g.translate(8,f/2);g.rotate(Math.PI*1.5);g.moveTo(0,0);this._drawNib(g);
g.restore()}if(d||h!==this.getMaximumValue()){g.save();g.translate(this._getClientLength()-8,f/2);g.rotate(Math.PI*0.5);g.moveTo(0,0);this._drawNib(g);g.restore()}},_getClientFrame:function(){var g=this.get("frame"),d=this.getPath("parentView.padding");return{x:d.left,y:d.top,width:g.width-(d.left+d.right),height:g.height-(d.top+d.bottom)}},_getClientLength:function(){var g=this._getClientFrame();switch(this.getPath("parentView.layoutDirection")){case c.LAYOUT_HORIZONTAL:return g.width;case c.LAYOUT_VERTICAL:return g.height;
default:console.assert(false,"unknown layout direction");return null}},_getClientThickness:function(){var g=this.get("parentView"),d=g.get("padding"),f=g.get("scrollerThickness");switch(g.get("layoutDirection")){case c.LAYOUT_VERTICAL:return f-(d.left+d.right);case c.LAYOUT_HORIZONTAL:return f-(d.top+d.bottom);default:console.assert(false,"unknown layout direction");return null}}.property(),_getFrameLength:function(){var g=this.get("frame");switch(this.getPath("parentView.layoutDirection")){case c.LAYOUT_HORIZONTAL:return g.width;
case c.LAYOUT_VERTICAL:return g.height;default:console.assert(false,"unknown layout direction");return null}},_getGutterFrame:function(){var g=this._getClientFrame(),d=this._getClientThickness();switch(this.getPath("parentView.layoutDirection")){case c.LAYOUT_VERTICAL:return{x:g.x,y:g.y+15,width:d,height:Math.max(0,g.height-30)};case c.LAYOUT_HORIZONTAL:return{x:g.x+15,y:g.y,width:Math.max(0,g.width-30),height:d};default:console.assert(false,"unknown layout direction");return null}},_getGutterLength:function(){var g=
this._getGutterFrame(),d;switch(this.getPath("parentView.layoutDirection")){case c.LAYOUT_HORIZONTAL:d=g.width;break;case c.LAYOUT_VERTICAL:d=g.height;break;default:console.assert(false,"unknown layout direction");break}return d},_getHandleFrame:function(){var g=this.get("parentView"),d=g.get("value"),f=g.get("maximum"),h=this.get("frame"),i=this._getClientFrame(),j=this._getGutterFrame(),k=this._getClientThickness();switch(g.get("layoutDirection")){case c.LAYOUT_VERTICAL:return{x:i.x,y:i.y+15+d*
j.height/f,width:k,height:Math.min(h.height,f)*j.height/f};case c.LAYOUT_HORIZONTAL:return{x:i.x+15+d*j.width/f,y:i.y,width:Math.min(h.width,f)*j.width/f,height:k};default:console.assert(false,"unknown layout direction");return null}},_segmentForMouseEvent:function(g){g=this.convertFrameFromView({x:g.pageX,y:g.pageY});var d=this._getClientFrame();if(!c.pointInRect(g,d))return null;var f=this.getPath("parentView.layoutDirection");switch(f){case c.LAYOUT_HORIZONTAL:if(g.x<15)return"nib-start";else if(g.x>=
d.width-15)return"nib-end";break;case c.LAYOUT_VERTICAL:if(g.y<15)return"nib-start";else if(g.y>=d.height-15)return"nib-end";break;default:console.assert(false,"unknown layout direction");break}var h=this._getHandleFrame();if(c.pointInRect(g,h))return"handle";switch(f){case c.LAYOUT_HORIZONTAL:if(g.x<h.x)return"gutter-before";else if(g.x>=h.x+h.width)return"gutter-after";break;case c.LAYOUT_VERTICAL:if(g.y<h.y)return"gutter-before";else if(g.y>=h.y+h.height)return"gutter-after";break;default:console.assert(false,
"unknown layout direction");break}console.assert(false,"_segmentForMouseEvent: point ",g," outside view with handle frame ",h," and client frame ",d);return null},adjustFrame:function(){var g=this.getPath("parentView.frame");this.set("layout",{left:0,top:0,width:g.width,height:g.height})},drawRect:function(g,d){g=d.globalAlpha?d.globalAlpha:1;var f=this.get("theme"),h=this.get("frame");d.clearRect(0,0,h.width,h.height);d.save();h=this.get("parentView");var i=h.get("padding");d.translate(i.left,i.top);
var j=this._getHandleFrame(),k=this._getGutterLength(),l=this._getClientThickness(),o=l/2,n,r;switch(h.get("layoutDirection")){case c.LAYOUT_VERTICAL:n=j.y-i.top;r=j.height;d.translate(l+1,0);d.rotate(Math.PI*0.5);break;case c.LAYOUT_HORIZONTAL:n=j.x-i.left;r=j.width;break;default:console.assert(false,"unknown layout direction");break}if(!(k<=r)){if(this._isMouseOver===false)d.globalAlpha=0.3;else{h=this._getClientLength();d.fillStyle=f.scrollTrackFillStyle;d.fillRect(8.5,0.5,h-16,l-1);d.strokeStyle=
f.scrollTrackStrokeStyle;d.strokeRect(8.5,0.5,h-16,l-1)}h=function(){d.beginPath();d.arc(n+o+0.5,o,o-0.5,Math.PI/2,3*Math.PI/2,false);d.arc(n+r-o-0.5,o,o-0.5,3*Math.PI/2,Math.PI/2,false);d.lineTo(n+o+0.5,l-0.5);d.closePath()};h();i=d.createLinearGradient(n,0,n,l);i.addColorStop(0,f.scrollBarFillGradientTopStart.replace(/%a/,g));i.addColorStop(0.4,f.scrollBarFillGradientTopStop.replace(/%a/,g));i.addColorStop(0.41,f.scrollBarFillStyle.replace(/%a/,g));i.addColorStop(0.8,f.scrollBarFillGradientBottomStart.replace(/%a/,
g));i.addColorStop(1,f.scrollBarFillGradientBottomStop.replace(/%a/,g));d.fillStyle=i;d.fill();d.save();d.clip();d.fillStyle=f.scrollBarFillStyle.replace(/%a/,g);d.beginPath();d.moveTo(n+o*0.4,o*0.6);d.lineTo(n+o*0.9,l*0.4);d.lineTo(n,l*0.4);d.closePath();d.fill();d.beginPath();d.moveTo(n+r-o*0.4,0+o*0.6);d.lineTo(n+r-o*0.9,0+l*0.4);d.lineTo(n+r,0+l*0.4);d.closePath();d.fill();d.restore();d.save();h();d.strokeStyle=f.scrollTrackStrokeStyle;d.stroke();d.restore();if(this._isMouseOver===false)d.globalAlpha=
1;this._drawNibs(d);d.restore()}},getMaximumValue:function(){return Math.max(this.getPath("parentView.maximum")-this._getFrameLength(),0)},mouseDown:function(g){var d=this.get("parentView"),f=d.get("value"),h=this._getGutterLength();switch(this._segmentForMouseEvent(g)){case "nib-start":d.set("value",f-this.get("lineHeight"));break;case "nib-end":d.set("value",f+this.get("lineHeight"));break;case "gutter-before":d.set("value",f-h);break;case "gutter-after":d.set("value",f+h);break;case "handle":switch(d.get("layoutDirection")){case c.LAYOUT_HORIZONTAL:this._mouseDownScreenPoint=
g.clientX;break;case c.LAYOUT_VERTICAL:this._mouseDownScreenPoint=g.clientY;break;default:console.assert(false,"unknown layout direction");break}default:console.assert("_segmentForMouseEvent returned an unknown value");break}},mouseDragged:function(g){var d=this.get("parentView"),f;switch(d.get("layoutDirection")){case c.LAYOUT_HORIZONTAL:f=g.clientX;break;case c.LAYOUT_VERTICAL:f=g.clientY;break;default:console.assert(false,"unknown layout direction");break}g=f-this._mouseDownScreenPoint;var h=d.get("maximum"),
i=this._getGutterLength(),j=d.get("value");d.set("value",j+g*h/i);if(d.get("value")!==j)this._mouseDownScreenPoint=f},mouseEntered:function(){this._isMouseOver=true;this.setNeedsDisplay()},mouseExited:function(){this._isMouseOver=false;this.setNeedsDisplay()},mouseUp:function(){this._mouseDownValue=this._mouseDownScreenPoint=null},mouseWheel:function(g){var d=this.get("parentView");switch(d.get("layoutDirection")){case c.LAYOUT_HORIZONTAL:g=g.wheelDeltaX;break;case c.LAYOUT_VERTICAL:g=g.wheelDeltaY;
break;default:console.assert(false,"unknown layout direction");return}d.set("value",d.get("value")+2*g)}});b.BespinScrollerView=c.View.extend({_scrollerCanvasView:null,_frameChanged:function(){this._scrollerCanvasView.adjustFrame()}.observes("frame"),_maximumChanged:function(){this._scrollerCanvasView.adjustFrame()}.observes("maximum"),_valueChanged:function(){var g=this._scrollerCanvasView,d=g.getMaximumValue(),f=this.get("value");if(f<0)this.set("value",0);else f>d&&this.set("value",d);g.setNeedsDisplay()}.observes("value"),
layoutDirection:c.LAYOUT_VERTICAL,maximum:0,padding:{left:0,bottom:0,top:0,right:0},scrollerThickness:c.NATURAL_SCROLLER_THICKNESS,value:0,createChildViews:function(){var g=this.createChildView(e);g.adjustFrame();this._scrollerCanvasView=g;this.set("childViews",[g])}})});
tiki.module("Editor:views/text",function(a,b){var c=a("sproutcore/runtime").SC,e=a("views/canvas").CanvasView;a("controllers/layoutmanager");var g=a("mixins/multidelegate").MultiDelegateSupport,d=a("utils/range"),f=a("utils/rect"),h=a("bespin:editor/mixins/textinput").TextInput,i=a("Canon:keyboard").keyboardManager;b.TextView=e.extend(g,h,{_dragPoint:null,_dragTimer:null,_inChangeGroup:false,_lineAscent:16,_selectedRange:null,_selectedRangeEndVirtual:null,_beginChangeGroup:function(){if(this._inChangeGroup)throw"TextView._beginChangeGroup() called while already in a change group";
this._inChangeGroup=true;this.notifyDelegates("textViewBeganChangeGroup",this._selectedRange)},_drag:function(){var j=this.convertFrameFromView(this._dragPoint),k=f.offsetFromRect(this.get("clippingFrame"),j);this._moveCursorTo(this._selectionPositionForPoint({x:j.x-k.x,y:j.y-k.y}),false,true);this.becomeFirstResponder()},_drawInsertionPoint:function(j,k){j=this._selectedRange;j=this.get("layoutManager").characterRectForPosition(j.start);k.save();k.strokeStyle=this.get("theme").cursorStyle;k.beginPath();
k.moveTo(j.x+0.5,j.y);k.lineTo(j.x+0.5,j.y+j.height);k.closePath();k.stroke();k.restore()},_drawLines:function(j,k){var l=this.get("layoutManager"),o=l.get("textLines"),n=this.get("theme"),r=this._lineAscent;k.save();k.font=n.editorTextFont;n=l.characterRangeForBoundingRect(j);j=n.start;n=n.end;for(var p=n.row,m=j.row;m<=p;m++){var q=o[m];if(!c.none(q)){var s=q.characters,t=s.length,u=Math.min(n.column,t),v=j.column;if(!(v>=t)){q=q.colors;for(t=0;v<q[t].start;)t++;for(v=v;v<u;){var w=q[t],x=w.end;
k.fillStyle=w.color;w=l.characterRectForPosition({row:m,column:v});k.fillText(s.substring(v,x),w.x,w.y+r);v=x;t++}}}}k.restore()},_drawSelectionHighlight:function(j,k){j=this.get("theme");j=this.get("isFirstResponder")?j.editorSelectedTextBackground:j.unfocusedCursorFillStyle;var l=this.get("layoutManager");k.save();var o=d.normalizeRange(this._selectedRange);k.fillStyle=j;l.rectsForRange(o).forEach(function(n){k.fillRect(n.x,n.y,n.width,n.height)});k.restore()},_drawSelection:function(j,k){this._rangeIsInsertionPoint(this._selectedRange)?
this._drawInsertionPoint(j,k):this._drawSelectionHighlight(j,k)},_endChangeGroup:function(){if(!this._inChangeGroup)throw"TextView._endChangeGroup() called while not in a change group";this._inChangeGroup=false;this.notifyDelegates("textViewEndedChangeGroup",this._selectedRange)},_getVirtualSelection:function(j){return{start:j&&this._selectedRangeEndVirtual?this._selectedRangeEndVirtual:this._selectedRange.start,end:this._selectedRangeEndVirtual||this._selectedRange.end}},_insertText:function(j){this._beginChangeGroup();
this.getPath("layoutManager.textStorage");var k=d.normalizeRange(this._selectedRange);this._replaceCharacters(k,j);var l=j.split("\n");this._moveCursorTo(l.length>1?{row:k.start.row+l.length-1,column:l[l.length-1].length}:d.addPositions(k.start,{row:0,column:j.length}));this._endChangeGroup()},_invalidateInsertionPointIfNecessary:function(j){if(this._rangeIsInsertionPoint(j)){j=this.get("layoutManager").characterRectForPosition(j.start);this.setNeedsDisplayInRect({x:j.x,y:j.y,width:1,height:j.height})}},
_isDelimiter:function(j){return["="," ","\t",">","<",".",",","(",")","{","}",":",'"',"'",";"].indexOf(j)>-1},_moveCursorTo:function(j,k,l){var o;o=this.getPath("layoutManager.textStorage").clampPosition(j);this.setSelection({start:l?this._selectedRange.start:o,end:o});this._selectedRangeEndVirtual=k?j:null;this._scrollToPosition(this._selectedRange.end)},_moveOrSelectEnd:function(j,k){var l=this.getPath("layoutManager.textStorage.lines");k=k?this._selectedRange.end.row:l.length-1;this._moveCursorTo({row:k,
column:l[k].length},false,j)},_moveOrSelectStart:function(j,k){var l=this._selectedRange;this._moveCursorTo({row:k?l.end.row:0,column:0},false,j)},_performBackspaceOrDelete:function(j){this._beginChangeGroup();var k=this.getPath("layoutManager.textStorage");k.get("lines");var l=d.normalizeRange(this._selectedRange);if(this._rangeIsInsertionPoint(l))l=j?{start:k.displacePosition(l.start,-1),end:l.end}:{start:l.start,end:k.displacePosition(l.end,1)};this._replaceCharacters(l,"");this._moveCursorTo(l.start);
this._endChangeGroup()},_performVerticalKeyboardSelection:function(j){this.getPath("layoutManager.textStorage");this._moveCursorTo(d.addPositions(this._selectedRangeEndVirtual!==null?this._selectedRangeEndVirtual:this._selectedRange.end,{row:j,column:0}),true,true)},_rangeIsInsertionPoint:function(j){return d.isZeroLength(j)},_replaceCharacters:function(j,k){if(!this._inChangeGroup)throw"TextView._replaceCharacters() called without a change group";j=d.normalizeRange(j);this.notifyDelegates("textViewWillReplaceRange",
j);this.getPath("layoutManager.textStorage").replaceCharacters(j,k);this.notifyDelegates("textViewReplacedCharacters",j,k)},_repositionSelection:function(){var j=this.getPath("layoutManager.textLines"),k=j.length,l=this._selectedRange,o=Math.min(l.start.row,k-1);k=Math.min(l.end.row,k-1);var n=j[k];this.setSelection({start:{row:o,column:Math.min(l.start.column,j[o].characters.length)},end:{row:k,column:Math.min(l.end.column,n.characters.length)}})},_resize:function(){var j=this.get("layoutManager").boundingRect(),
k=this.get("padding"),l=this.getPath("parentView.frame");this.set("layout",c.mixin(c.clone(this.get("layout")),{width:Math.max(l.width,j.width+k.right),height:Math.max(l.height,j.height+k.bottom)}))},_scrollPage:function(j){var k=this._scrollView(),l=this.get("clippingFrame");k.scrollTo(l.x,l.y+(l.height+this._lineAscent)*(j?-1:1))},_scrollToPosition:function(j){var k=this._scrollView();if(!c.none(k)){var l=this.get("layoutManager").characterRectForPosition(j);j=l.x;var o=l.y,n=l.width;l=l.height;
var r=this.get("clippingFrame"),p=r.x,m=r.y,q=this.get("padding"),s=r.width-q.right;r=r.height-q.bottom;k.scrollTo(j>=p&&j+n<p+s?p:j-s/2+n/2,o>=m&&o+l<m+r?m:o-r/2+l/2)}},_scrollView:function(){for(var j=this.get("parentView");!c.none(j)&&!j.get("isScrollable");)j=j.get("parentView");return j},_scrollWhileDragging:function(){var j=this._scrollView();if(!c.none(j)){var k=f.offsetFromRect(this.get("clippingFrame"),this.convertFrameFromView(this._dragPoint));if(!(k.x===0&&k.y===0)){j.scrollBy(k.x,k.y);
this._drag()}}},_selectionPositionForPoint:function(j){j=this.get("layoutManager").characterAtPoint(j);return j.partialFraction<0.5?j:d.addPositions(j,{row:0,column:1})},acceptsFirstResponder:true,hasPadding:true,layoutManager:null,padding:{bottom:0,right:0},theme:{backgroundStyle:"#2a211c",cursorStyle:"#879aff",editorTextFont:"10pt Monaco, Lucida Console, monospace",editorSelectedTextColor:"rgb(240, 240, 240)",editorSelectedTextBackground:"#526da5",unfocusedCursorStrokeStyle:"#ff0033",unfocusedCursorFillStyle:"#73171e"},
backspace:function(){this._performBackspaceOrDelete(true)},copy:function(){return this.getSelectedCharacters()},cut:function(){var j=this.getSelectedCharacters();j!=""&&this.deleteSelectionOrNextCharacter();return j},deleteSelectionOrNextCharacter:function(){this._performBackspaceOrDelete(false)},drawRect:function(j,k){k.fillStyle=this.get("theme").backgroundStyle;k.fillRect(j.x,j.y,j.width,j.height);this._drawSelection(j,k);this._drawLines(j,k)},getSelectedCharacters:function(){return this._rangeIsInsertionPoint(this._selectedRange)?
"":this.getPath("layoutManager.textStorage").getCharacters(d.normalizeRange(this._selectedRange))},init:function(){arguments.callee.base.apply(this,arguments);this._invalidRange=null;this._selectedRange={start:{row:0,column:0},end:{row:0,column:0}};this.set("padding",c.clone(this.get("padding")));this.get("layoutManager").addDelegate(this);this._resize()},keyDown:function(j){return j.charCode===0?i.processKeyEvent(j,this,{isTextView:true}):false},layoutManagerInvalidatedRects:function(j,k){k.forEach(this.setNeedsDisplayInRect,
this);this._repositionSelection();this._resize()},mouseDown:function(j){switch(j.clickCount){case 1:var k=this._selectionPositionForPoint(this.convertFrameFromView({x:j.clientX,y:j.clientY}));this._moveCursorTo(k,false,j.shiftKey);break;case 2:k=this._selectionPositionForPoint(this.convertFrameFromView({x:j.clientX,y:j.clientY}));var l=this.getPath("layoutManager.textStorage").lines[k.row];if(l.length===0)return;k.column-=k.column==l.length?1:0;var o=!this._isDelimiter(l[k.column]),n=this,r=function(m,
q){for(;m>-1&&m<l.length;m+=q)if(n._isDelimiter(l[m])===o)break;return m+(q==1?0:1)},p=r(k.column,-1);r=r(k.column,1);this._moveCursorTo({row:k.row,column:p});this._moveCursorTo({row:k.row,column:r},false,true);break;case 3:p=this.getPath("layoutManager.textStorage").lines;k=this._selectionPositionForPoint(this.convertFrameFromView({x:j.clientX,y:j.clientY}));this.setSelection({start:{row:k.row,column:0},end:{row:k.row,column:p[k.row].length}});break}this._dragPoint={x:j.clientX,y:j.clientY};this._dragTimer=
c.Timer.schedule({target:this,action:"_scrollWhileDragging",interval:100,repeats:true});this.becomeFirstResponder()},mouseDragged:function(j){this._dragPoint={x:j.clientX,y:j.clientY};this._drag()},mouseUp:function(){this._dragTimer!==null&&this._dragTimer.invalidate()},moveDocEnd:function(){this._moveOrSelectEnd(false,false)},moveDocStart:function(){this._moveOrSelectStart(false,false)},moveDown:function(){var j=this._getVirtualSelection();j=d.normalizeRange(j);j=this._rangeIsInsertionPoint(this._selectedRange)?
j.end:{row:j.end.row,column:j.start.column};j=d.addPositions(j,{row:1,column:0});this._moveCursorTo(j,true)},moveLeft:function(){var j=d.normalizeRange(this._selectedRange);this._rangeIsInsertionPoint(j)?this._moveCursorTo(this.getPath("layoutManager.textStorage").displacePosition(j.start,-1)):this._moveCursorTo(j.start)},moveLineEnd:function(){this._moveOrSelectEnd(false,true)},moveLineStart:function(){this._moveOrSelectStart(false,true)},moveRight:function(){var j=d.normalizeRange(this._selectedRange);
this._rangeIsInsertionPoint(j)?this._moveCursorTo(this.getPath("layoutManager.textStorage").displacePosition(j.end,1)):this._moveCursorTo(j.end)},moveUp:function(){var j=d.normalizeRange(this._getVirtualSelection(true));position=d.addPositions({row:j.start.row,column:this._getVirtualSelection().end.column},{row:-1,column:0});this._moveCursorTo(position,true)},selectDocEnd:function(){this._moveOrSelectEnd(true,false)},selectDocStart:function(){this._moveOrSelectStart(true,false)},selectLineEnd:function(){this._moveOrSelectEnd(true,
true)},selectLineStart:function(){this._moveOrSelectStart(true,true)},newline:function(){var j=this._selectedRange.start;this._insertText("\n"+/^\s*/.exec(this.getPath("layoutManager.textStorage.lines")[j.row].substring(0,j.column))[0])},scrollDocStart:function(){this._scrollToPosition({column:0,row:0})},scrollDocEnd:function(){this._scrollToPosition(this.getPath("layoutManager.textStorage").range().end)},scrollPageDown:function(){this._scrollPage(false)},scrollPageUp:function(){this._scrollPage(true)},
selectAll:function(){var j=this.getPath("layoutManager.textStorage.lines"),k=j.length-1;this.setSelection({start:{row:0,column:0},end:{row:k,column:j[k].length}})},selectDown:function(){this._performVerticalKeyboardSelection(1)},selectLeft:function(){this._moveCursorTo(this.getPath("layoutManager.textStorage").displacePosition(this._selectedRange.end,-1),false,true)},selectRight:function(){this._moveCursorTo(this.getPath("layoutManager.textStorage").displacePosition(this._selectedRange.end,1),false,
true)},selectUp:function(){this._performVerticalKeyboardSelection(-1)},setSelection:function(j){this.getPath("layoutManager.textStorage");var k=d.normalizeRange(this._selectedRange),l=d.normalizeRange(j);this._selectedRange=j;j=this.get("layoutManager");j.rectsForRange(k).forEach(this.setNeedsDisplayInRect,this);j.rectsForRange(l).forEach(this.setNeedsDisplayInRect,this);this._invalidateInsertionPointIfNecessary(k);this._invalidateInsertionPointIfNecessary(l)},tab:function(){this._insertText("        ".substring(0,
8-this._selectedRange.start.column%8))},textInserted:function(j){this._insertText(j)}});b.textViewCommand=function(j,k,l){k.view[l.name]()}});tiki.module("Editor:index",function(){});tiki.register("Embedded",{});
tiki.module("Embedded:index",function(a,b){var c=a("sproutcore/runtime").SC;a("bespin:index");var e=a("bespin:util/util"),g=a("Editor:views/editor").EditorView,d=a("AppSupport:views/keylistener").KeyListener,f=function(i,j){var k=i.get("layer"),l=function(){j.setFocus(true)},o=function(){j.setFocus(false)},n=function(r,p){for(;r!==null;){var m=p||r===k;r.addEventListener("mousedown",m?l:o,true);n(r.firstChild,m);r=r.nextSibling}};n(document.body,false)},h=function(i){for(var j={top:0,left:0,width:i.clientWidth,
height:i.clientHeight};!c.none(i);){j.top+=i.offsetTop+i.clientTop;j.left+=i.offsetLeft+i.clientLeft;i=i.offsetParent}return j};b.EmbeddedEditor=c.Object.extend({_focused:false,setContent:function(i){c.RunLoop.begin();this.setPath("editorPane.editorView.layoutManager.textStorage.value",i);c.RunLoop.end()},getContent:function(){return this.getPath("editorPane.editorView.layoutManager.textStorage.value")},setFocus:function(i){var j=this.get("editorPane");if(this._focused!==i)(this._focused=i)?j.becomeKeyPane():
j.resignKeyPane()},dimensionsChanged:function(){c.RunLoop.begin();var i=this.get("editorPane"),j=i.get("layout"),k=h(this.get("element"));if(!c.rectsEqual(j,k)){i.adjust(k);i.updateLayout()}c.RunLoop.end()},setLineNumber:function(i){c.RunLoop.begin();var j=this.getPath("editorPane.editorView.textView");i={row:i-1,column:0,partialFraction:0};j.setSelection([{start:i,end:i}]);c.RunLoop.end()}});b.useBespin=function(i,j){j=j||{};if(e.isString(i))i=document.getElementById(i);if(!i)throw new Error("useBespin requires a element parameter to attach to");
var k=i.innerHTML,l=c.Pane.create({childViews:"editorView".w(),defaultResponder:d.create(),editorView:g.design(),layout:h(i),layoutStyle:function(){var n=this.get("layout");return{width:""+n.width+"px",height:""+n.height+"px"}}.property("layout")}),o=b.EmbeddedEditor.create({editorPane:l,element:i});c.run(function(){c.$(i).css("position","relative");i.innerHTML="";o.get("editorPane").appendTo(i);b.view=l.getPath("editorView.textView");b.model=l.getPath("editorView.layoutManager.textStorage");if(j.initialContent)k=
j.initialContent;o.setContent(k);i.bespin=o;j.stealFocus&&o.setFocus(true);if(c.none(j.dontHookWindowResizeEvent)||!j.dontHookWindowResizeEvent){var n=function(){o.dimensionsChanged()};if(c.none(window.addEventListener))c.none(window.attachEvent)||window.addEventListener("onresize",n);else window.addEventListener("resize",n,false)}f(l,o)});return o}});
tiki.require("bespin:plugins").catalog.load({AppSupport:{depends:[],resourceURL:"resources/AppSupport/",provides:[{predicates:["isApplication",true],pointer:"controllers/undomanager#undoManagerCommand",ep:"command",key:["ctrl_shift_z","meta_shift_z"],name:"redo"},{predicates:["isApplication",true],pointer:"controllers/undomanager#undoManagerCommand",ep:"command",key:["ctrl_z","meta_z"],name:"undo"}]},Canon:{depends:[],resourceURL:"resources/Canon/",provides:[{indexOn:"name",description:"Commands can accept various arguments that the user enters or that are automatically supplied by the environment. Those arguments have types that define how they are supplied or completed. The pointer points to an object with methods convert(str value) and getDefault(). Both functions have `this` set to the command's `takes` parameter. If getDefault is not defined, the default on the command's `takes` is used, if there is one. The object can have a noInput property that is set to true to reflect that this type is provided directly by the system. getDefault must be defined in that case.",
ep:"extensionpoint",name:"argumentType"},{description:"Text that the user needs to enter.",pointer:"arguments#string",ep:"argumentType",name:"string"},{description:"An integer",pointer:"arguments#integer",ep:"argumentType",name:"int"},{noInput:true,description:"the editor model",pointer:"arguments#model",ep:"argumentType",name:"model"},{noInput:true,description:"the editor view",pointer:"arguments#view",ep:"argumentType",name:"view"},{register:"directory#newCommandHandler",ep:"extensionhandler",name:"command"}]},
Editor:{depends:["AppSupport","Canon"],resourceURL:"resources/Editor/",provides:[{takes:[{type:"view"}],key:"backspace",predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"backspace"},{takes:[{type:"view"}],key:"delete",predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"deleteSelectionOrNextCharacter"},{takes:[{type:"view"}],key:"down",predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"moveDown"},
{takes:[{type:"view"}],key:"left",predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"moveLeft"},{takes:[{type:"view"}],key:"right",predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"moveRight"},{takes:[{type:"view"}],key:"up",predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"moveUp"},{takes:[{type:"view"}],key:"ctrl_home",predicates:["isTextView",true],pointer:"views/text#textViewCommand",
ep:"command",name:"scrollDocStart"},{takes:[{type:"view"}],key:"ctrl_up",predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"moveDocStart"},{takes:[{type:"view"}],key:["ctrl_a","meta_a"],predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"selectAll"},{takes:[{type:"view"}],key:"ctrl_shift_up",predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"selectDocStart"},{takes:[{type:"view"}],key:"ctrl_end",
predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"scrollDocEnd"},{takes:[{type:"view"}],key:"ctrl_down",predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"moveDocEnd"},{takes:[{type:"view"}],key:"ctrl_shift_down",predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"selectDocEnd"},{takes:[{type:"view"}],key:["home","ctrl_left"],predicates:["isTextView",true],pointer:"views/text#textViewCommand",
ep:"command",name:"moveLineStart"},{takes:[{type:"view"}],key:["shift_home","ctrl_shift_left"],predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"selectLineStart"},{takes:[{type:"view"}],key:["end","ctrl_right"],predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"moveLineEnd"},{takes:[{type:"view"}],key:["shift_end","ctrl_shift_right"],predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"selectLineEnd"},
{takes:[{type:"view"}],key:"return",predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"newline"},{takes:[{type:"view"}],key:"pagedown",predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"scrollPageDown"},{takes:[{type:"view"}],key:"pageup",predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"scrollPageUp"},{takes:[{type:"view"}],key:"shift_down",predicates:["isTextView",true],pointer:"views/text#textViewCommand",
ep:"command",name:"selectDown"},{takes:[{type:"view"}],key:"shift_left",predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"selectLeft"},{takes:[{type:"view"}],key:"shift_right",predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"selectRight"},{takes:[{type:"view"}],key:"shift_up",predicates:["isTextView",true],pointer:"views/text#textViewCommand",ep:"command",name:"selectUp"},{takes:[{type:"view"}],key:"tab",predicates:["isTextView",
true],pointer:"views/text#textViewCommand",ep:"command",name:"tab"},{takes:["value"],completeText:"add the line number to move to in the file",preview:"move it! make the editor head to a line number.",pointer:"commands/editor#gotoCommand",ep:"command",name:"goto"},{takes:["search","replace"],completeText:"add the search regex, and then the replacement text",preview:"s/foo/bar/g",pointer:"commands/editor#replaceCommand",ep:"command",name:"replace"},{takes:["direction"],completeText:"optionally, sort descending",
preview:"sort the current buffer",pointer:"commands/editor#sortCommand",ep:"command",name:"sort"},{takes:["tabsize"],completeText:"Optionally, specify a tab size. (Defaults to setting.)",preview:"Convert spaces to tabs.",pointer:"commands/editor#entabCommand",ep:"command",name:"entab"},{takes:["tabsize"],completeText:"Optionally, specify a tab size. (Defaults to setting.)",preview:"Convert tabs to spaces.",pointer:"commands/editor#detabCommand",ep:"command",name:"detab"},{takes:["side"],completeText:"optionally, give a side of left, right, or both (defaults to right)",
preview:"trim trailing or leading whitespace",pointer:"commands/editor#trimCommand",ep:"command",name:"trim"},{withKey:"CMD SHIFT U",preview:"Change all selected text to uppercase",pointer:"commands/editor#ucCommand",ep:"command",name:"uc"},{withKey:"CMD SHIFT L",preview:"Change all selected text to lowercase",pointer:"commands/editor#lcCommand",ep:"command",name:"lc"}]},Embedded:{depends:["AppSupport","Editor"],resourceURL:"resources/Embedded/",provides:[{action:"value",pointer:"#view",ep:"factory",
name:"view"},{action:"value",pointer:"#model",ep:"factory",name:"model"}]}});SC.ready(function(){for(var a=tiki.require("Embedded"),b=document.querySelectorAll(".bespin"),c=0;c<b.length;c++){var e=b[c],g=e.getAttribute("data-bespinoptions");a.useBespin(e,JSON.parse(g))}window.onBespinLoad&&window.onBespinLoad()});document.addEventListener("DOMContentLoaded",SC.didLoad,false);window.tiki=tiki;
