/* 
 This file was generated by Dashcode and is covered by the 
 license.txt included in the project.  You may edit this file, 
 however it is recommended to first turn off the Dashcode 
 code generator otherwise the changes will be lost.
 */

var dashcodePartSupport = { "imageBgParts": {
    "formTypeBadge": ["Parts/Images/formTypeBadge.png", 5, 5],
    "titleBar1": ["Parts/Images/titleBar1.png", 1, 1]
} };
if(!window.dashcode){dashcode=new Object()}dashcode.setupParts=function(){if(dashcode.setupParts.called){return }dashcode.setupParts.called=true;var H=[];if(window.dashcodeDataSources&&!dashcode.inDesign){for(var C in dashcodeDataSources){var E=dashcodeDataSources[C];var A=dashcode.setupDataSource(C,E);if(A){A.registerWithName(C)}}}for(var C in dashcodePartSpecs){dashcode.preProcessBindings(dashcodePartSpecs[C])}if(!DC.Support.BorderImage){var G=dashcodePartSupport.imageBgParts;for(var B in G){var D=G[B];Element.set3PiecesBorderImage(document.getElementById(B),D[0],D[1],D[2])}}for(var C in dashcodePartSpecs){var E=dashcodePartSpecs[C];var F=dashcode.setupPart(C,E.creationFunction,E.view,E);if(F&&F.finishLoading){H[H.length]=F}}for(var I=0;I<H.length;I++){H[I].finishLoading()}};dashcode.setupPart=function(elementOrId,creationFunction,viewClass,specDict,relativeController){var object=null;var createFunc=window[creationFunction];var node=elementOrId;if(elementOrId.nodeType!=1){node=document.getElementById(elementOrId)}if(!node){return null}if(createFunc){object=createFunc(node,specDict)}else{var viewClass=null;object=DC.View.fromNode(node);if(object){return object}if(specDict.view){viewClass=eval(specDict.view)}if(dashcode.inDesign){dashcode.preProcessBindings(specDict)}if(!viewClass){viewClass=DC.View.viewClassForNode(node,specDict.hasBindings)||DC.View}object=new (viewClass)(node,relativeController,specDict.propertyValues,specDict);node.object=object}return object};dashcode.setupDataSource=function(identifier,specDict){var dsClass=null;var dataSource=null;try{dsClass=specDict.Class?eval(specDict.Class):null}catch(e){}if(!dsClass){console.error("Couldn't create data source "+identifier+". Invalid class specified.");return null}var propertyValues=specDict.propertyValues;dataSource=new dsClass(propertyValues);return dataSource};dashcode.getDataSource=function(A){return DC.dataModel.valueForKey(A)};dashcode.preProcessBindings=function(A){if(A&&A.propertyValues&&!A.hasBindings){for(p in A.propertyValues){if(-1!==p.search(/Binding$/)){A.hasBindings=true;if(dashcode.inDesign){delete A.propertyValues[p]}else{break}}}}};if(window.addEventListener){window.addEventListener("load",dashcode.setupParts,false)}else{if(window.attachEvent){window.attachEvent("load",dashcode.setupParts)}}dashcode.getLocalizedString=function(A){try{A=localizedStrings[A]||A}catch(B){}return A};dashcode.createInstancePreferenceKey=function(A){return widget.identifier+"-"+A};dashcode.getElementHeight=function(B){var A=B.offsetHeight;if(!A||A==0){A=dashcode.getElementSize(B).height}return A};dashcode.getElementWidth=function(B){var A=B.offsetWidth;if(!A||A==0){A=dashcode.getElementSize(B).width}return A};dashcode.getElementSize=function(B){var A=dashcode.getElementSizesWithAncestor([B],B);return A[0]};dashcode.getElementSizesWithAncestor=function(A,F){if(A.length<1){return[]}var B=new Array();var C=A[0].offsetWidth;if(!C||C==0){var G=F;while(G&&(G!=document)){var I=Element.getStyles(G,"display");var H=(I)?I:G.style.display;if((I&&H=="none")||(!I&&H!="block")){B.push({node:G,display:G.style.display});G.style.display="block"}G=G.parentNode}}var J=new Array();for(var E=0;E<A.length;E++){J.push({width:A[E].offsetWidth,height:A[E].offsetHeight})}for(var E=0;E<B.length;E++){var D=B[E].node;D.style.display=B[E].display;if(D.getAttribute("style")==""){D.removeAttribute("style")}}return J};dashcode.getElementDocumentOffset=function(B){var C=B.offsetParent;var D={x:B.offsetLeft,y:B.offsetTop};if(C){var A=dashcode.getElementDocumentOffset(C);D.x+=A.x;D.y+=A.y}return D};dashcode.pointInElement=function(A,E,D){var C=dashcode.getElementSize(D);var B=dashcode.getElementDocumentOffset(D);if(A>=B.x){if(A>B.x+C.width){return false}if(E>=B.y){if(E>B.y+C.height){return false}}else{return false}}else{return false}return true};dashcode.cloneTemplateElement=function(B,A,C){return DC.View.cloneViewsForTreeNode(B,C,null)};dashcode.processClonedTemplateElement=function(D,C,B,F,E,A){console.error("dashcode.processClonedTemplateElement is no longer available.")};var setupParts=dashcode.setupParts;var getLocalizedString=dashcode.getLocalizedString;var createInstancePreferenceKey=dashcode.createInstancePreferenceKey;var getElementHeight=dashcode.getElementHeight;var getElementWidth=dashcode.getElementWidth;var getElementSize=dashcode.getElementSize;if(!("querySelector" in document)){document.write('<script apple-no-regeneration="yes" type="text/javascript" src="../Parts/core/external/sizzle_c.js"><\/script>')};if("undefined"!==typeof (DC)){throw new Error("Library module (DC) already defined")}var DC={version:"@VERSION@",revision:"@REVISION@",generateUid:(function(){var A=0;return function(){return ++A}})()};DC.Browser={IE:!!(window.attachEvent&&!window.opera)&&(function(){var B=/MSIE (\d+)/;var A=B.exec(navigator.userAgent);return A&&parseInt(A[1],10)})(),Safari:navigator.userAgent.indexOf("AppleWebKit/")>-1,Safari2:(function(){var A=/AppleWebKit\/(\d+(?:\.\d+)?)/;var B=A.exec(navigator.userAgent);return(B&&parseInt(B[1],10)<420)})(),Mozilla:navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")==-1,MobileSafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/)};DC.Support={Properties:("__defineGetter__" in Object.prototype),QuerySelector:("querySelector" in document),Touches:!!document.createTouch,CSS3ColorModel:false,CSSTransitions:false,BorderImage:(function(){var A=document.createElement("div").style;A.cssText="-webkit-border-image: inherit; -moz-border-image: inherit;";return(A.WebkitBorderImage=="inherit")||(A.MozBorderImage=="inherit")})()};if(DC.Support.Properties){DC.Support.__defineGetter__("CSS3ColorModel",function(){delete this.CSS3ColorModel;var B=document.createElement("span");try{B.style.backgroundColor="rgba(100,100,100,0.5)";return this.CSS3ColorModel=(B.style.length===1)}catch(A){}return(this.CSS3ColorModel=false)});DC.Support.__defineGetter__("CSSTransitions",function(){delete this.CSSTransitions;var B=document.createElement("span");try{B.style.setProperty("-webkit-transition-duration","1ms","");return this.CSSTransitions=(B.style.length===1)}catch(A){}return(this.CSSTransitions=false)})}DC.typeOf=function(B){if(null===B){return"null"}var A=typeof (B);if("object"!==A&&"function"!==A){return A}return Object.prototype.toString.call(B).slice(8,-1).toLowerCase()};DC.compareValues=function(F,D){var C=DC.typeOf(F);if(C!==DC.typeOf(D)){var A=String(F);var E=String(D);return A.localeCompare(E)}switch(C){case"null":return 0;case"boolean":case"number":var B=(F-D);if(0===B){return B}return(B<0?-1:1);case"regexp":case"function":break;case"string":case"array":case"object":if(F.localeCompare){return F.localeCompare(D)}if(F.compare){return F.compare(D)}break;case"undefined":return true;default:throw new TypeError("Unknown type for comparison: "+C)}return String(F).localeCompare(String(D))};DC.defineError=function(B){function A(C){this.message=C;this.name=B}A.prototype=new Error;A.prototype.constructor=A;A.prototype.name=B;return A};var InvalidArgumentError=DC.defineError("InvalidArgumentError");if("undefined"==typeof (window.console)){window.console={}}if("undefined"==typeof (window.console.log)){window.console.log=function(){}}if("undefined"==typeof (window.console.error)){window.console.error=function(){}};if("undefined"!==typeof (window.Prototype)){(function(){var A=["indexOf","lastIndexOf","forEach","filter","map","some","every","reduce","reduceRight"];for(var B=0;B<A.length;++B){delete Array.prototype[A[B]]}})()}Array.prototype.distinct=function(){var B=this.length;var A=new Array(B);var C;var E;var D=0;for(C=0;C<B;++C){E=this[C];if(-1==A.indexOf(E)){A[D++]=E}}A.length=D;return A};Array.prototype.compare=function(B){var D=this.length-B.length;if(0!==D){return D}var E;var A;var C;for(E=0,A=this.length;E<A;++E){C=DC.compareValues(this[E],B[E]);if(0!==C){return C}}return 0};Array.from=function(A,B){return Array.prototype.slice.call(A,B||0)};if(!Array.prototype.reduce){Array.prototype.reduce=function(B){var A=this.length;if(typeof B!="function"){throw new TypeError()}if(0===A&&1===arguments.length){throw new TypeError()}var C=0;if(arguments.length>=2){var D=arguments[1]}else{do{if(C in this){D=this[C++];break}if(++C>=A){throw new TypeError()}}while(true)}for(;C<A;C++){if(C in this){D=B.call(null,D,this[C],C,this)}}return D}}if(!Array.prototype.reduceRight){Array.prototype.reduceRight=function(B){var A=this.length;if(typeof B!="function"){throw new TypeError()}if(0===A&&1===arguments.length){throw new TypeError()}var C=A-1;if(arguments.length>=2){var D=arguments[1]}else{do{if(C in this){D=this[C--];break}if(--C<0){throw new TypeError()}}while(true)}for(;C>=0;C--){if(C in this){D=B.call(null,D,this[C],C,this)}}return D}}if(!Array.indexOf){Array.indexOf=function(C,B,A){return Array.prototype.indexOf.call(C,B,A)}}if(!Array.lastIndexOf){Array.lastIndexOf=function(C,B,A){return Array.prototype.lastIndexOf.call(C,B,A)}}if(!Array.forEach){Array.forEach=function(C,A,B){return Array.prototype.forEach.call(C,A,B)}}if(!Array.filter){Array.filter=function(C,A,B){return Array.prototype.filter.call(C,A,B)}}if(!Array.map){Array.map=function(C,A,B){return Array.prototype.map.call(C,A,B)}}if(!Array.some){Array.some=function(C,A,B){return Array.prototype.some.call(C,A,B)}}if(!Array.every){Array.every=function(C,A,B){return Array.prototype.every.call(C,A,B)}}if(!Array.reduce){Array.reduce=function(B,A){if(arguments.length>2){return Array.prototype.reduce.apply(B,A,arguments[2])}else{return Array.prototype.reduce.apply(B,A)}}}if(!Array.reduceRight){Array.reduceRight=function(B,A){if(arguments.length>2){return Array.prototype.reduceRight.apply(B,A,arguments[2])}else{return Array.prototype.reduceRight.apply(B,A)}}};function Set(){var D=this;if(D.constructor!==Set){D=new Set()}var B=arguments;if(1==B.length&&B[0] instanceof Array){B=B[0]}var C;var A=B.length;for(C=0;C<A;++C){D[B[C]]=true}return D}Set.union=function(C,B){var A=Object.clone(C);if(!B){return A}var D;for(D in B){A[D]=true}return A};Set.intersect=function(C,B){var A=new Set();var D;for(D in C){if(D in B){A[D]=true}}return A};Set.add=function(B,A){B[A]=true;return B};Set.remove=function(B,A){delete B[A];return B};Set.toArray=function(C){var B;var A=[];for(B in C){A.push(B)}return A};Set.forEach=function(E,C,B){var D;var A=0;for(D in E){C.call(B,D,A++)}};Set.join=function(D,B){var C;var A=[];for(C in D){A.push(C)}return A.join(B||"")};var $S=Set;var Class=(function(){function D(I,L){var J;if(!I&&!L){return I}if(!I){J=function(){return L.apply(this,arguments)}}else{var K=/this\.base/.test(I);if(!K&&!L){return I}if(!K){J=function(){L.call(this);return I.apply(this,arguments)}}else{J=function(){var N=this.base;this.base=L||function(){};var M=I.apply(this,arguments);this.base=N;return M}}}J.valueOf=function(){return I};J.toString=function(){return String(I)};return J}function G(I,J){var K=I.prototype.__factory__.apply(I,J);if("function"!==typeof (K)){throw new Error("Factory function doesn't return a function")}K.__factoryFn__=true;return K}function F(K){if(K.__createFactoryObjects){K.__createFactoryObjects();return }var J;var I;for(J in K.__factories__){I=K[J];if(!I.__factoryFn__){continue}K[J]=I.call(K)}}function C(I,K){if(I&&!(I instanceof Function)){throw new Error("Invalid constructor")}if(K&&!(K instanceof Function)){throw new Error("Invalid superclass")}K=K?K.valueOf():null;I=D(I,K);var J;if(I){J=function(){if(!(this instanceof J)){return G(J,arguments)}this.__uid=this.__uid||DC.generateUid();var L=I.apply(this,arguments);if(L){return L}F(this);if(this.__postConstruct instanceof Function){this.__postConstruct()}return this}}else{J=function(){if(!(this instanceof J)){return G(J,arguments)}this.__uid=this.__uid||DC.generateUid();F(this);if(this.__postConstruct instanceof Function){this.__postConstruct()}return this}}J.valueOf=function(){return I};J.toString=function(){return String(I||J)};return J}function B(J){function I(){}I.prototype=J.prototype;return new I()}function E(L,J,K){if(!L||!/this\.base/.test(L)){return L}function I(){var N=this.base;this.base=K[J]||function(){};var M=L.apply(this,arguments);this.base=N;return M}I.valueOf=function(){return L};I.toString=function(){return String(L)};return I}function H(J,I,K,L){if(K instanceof Function&&L){var M=K.valueOf();K=E(K,I,L);K.name=I;if(M.__factoryFn__){J.__factories__[I]=K}}J[I]=K;return K}function A(J){var I;for(I=J.superclass;I;I=I.superclass){if("__subclassCreated__" in I){I.__subclassCreated__(J)}}}return{create:function(L,J){var I;var K={};switch(arguments.length){case 0:throw new TypeError("Missing superclass and declaration arguments");case 1:J=L;L=undefined;break;default:K=B(L);break}if("function"==typeof (J)){J=J();if(!J){throw new Error("Class declaration function did not return a prototype")}}if(J.hasOwnProperty("constructor")){I=J.constructor;delete J.constructor}I=C(I,L);I.prototype=K;I.prototype.constructor=I;I.superclass=L;if(L){K.__factories__=Object.clone(L.prototype.__factories__)}else{K.__factories__={}}I.__class_id__=DC.generateUid();K.__class_id__=DC.generateUid();this.extend(I,J);A(I);return I},findPropertyName:function(L,I){var J;for(var K in L){J=L[K];if(J===I||("function"===typeof (J)&&J.valueOf()===I)){return K}}return null},extend:(function(){if(DC.Support.Properties){return function(I,J){var N=I.prototype;var P=I.superclass&&I.superclass.prototype;var K;for(var O in J){var M=J.__lookupGetter__(O);var L=J.__lookupSetter__(O);if(M||L){M&&N.__defineGetter__(O,M);L&&N.__defineSetter__(O,L)}else{H(N,O,J[O],P)}}return I}}else{return function(I,J){var K=I.prototype;var M=I.superclass&&I.superclass.prototype;for(var L in J){H(K,L,J[L],M)}}}})()}})();if(!Function.prototype.bind){Function.prototype.bind=function(C){var A=this;if(!arguments.length){return A}if(1==arguments.length){return function(){return A.apply(C,arguments)}}var B=Array.from(arguments,1);return function(){return A.apply(C,B.concat(Array.from(arguments)))}}}if(!Function.prototype.bindAsEventListener){Function.prototype.bindAsEventListener=function(C){var A=this;if(1==arguments.length){return function(D){return A.call(C,D||window.event)}}var B=Array.from(arguments);B.shift();return function(D){return A.apply(C,[D||window.event].concat(B))}}}if(!Function.prototype.delay){Function.prototype.delay=function(D){var B=this;D=D||10;if(arguments.length<2){function A(){B()}return window.setTimeout(A,D)}var C=Array.from(arguments,1);function E(){B.apply(B,C)}return window.setTimeout(E,D)}}if(!Function.prototype.bindAndDelay){Function.prototype.bindAndDelay=function(F,D){var B=this;F=F||B;D=D||10;if(arguments.length<3){function A(){B.call(F)}return window.setTimeout(A,D)}var C=Array.from(arguments,2);function E(){B.apply(F,C)}return window.setTimeout(E,D)}}Function.prototype.sync=function(){var B=arguments.length?this.bind.apply(this,arguments):this;var A={};var C=false;B.stop=function(){C=true};B.waitFor=function(D){A[D]=true;return function(){A[D]=false;for(var E in A){if(A[E]){return }}if(C){return }B()}};return B};Object.clone=function(B){var A=(function(){});A.prototype=B;return new A()};Object.applyDefaults=function(C,B){C=C||{};if(!B){return C}for(var A in B){if(A in C){continue}C[A]=B[A]}return C};Object.extend=function(C,A){C=C||{};for(var B in A){C[B]=A[B]}return C};Object.merge=function(C,A){var B={};var D;for(D in C){B[D]=C[D]}for(D in A){if(D in B){continue}B[D]=A[D]}return B};(function(){var B=Set("file","submit","image","reset","button");var D={};function E(I,H,J){var G=I[H];var F=DC.typeOf(G);if("string"===F){I[H]=[G,J]}else{if("array"===F){G.push(J)}else{I[H]=J}}}function C(H){var F=H.name;var G=(H.type||"").toLowerCase();if(H.disabled||G in B){return }if("radio"===G||"checkbox"===G){if(H.checked){E(this,F,H.value)}}else{if(H.multiple){function I(J){if(J.selected){E(this,F,J.value)}}this[F]=[];Array.forEach(H.options,I,this)}else{E(this,F,H.value);if("image"===G){E(this,F+".x",0);E(this,F+".y",0)}}}}Object.fromForm=function(G){var F={};Array.forEach(G.elements,C,F);return F};function A(H){H=H.split("=");if(1===H.length){return }var F=decodeURIComponent(H[0].trim());var G=decodeURIComponent(H[1].trim())||null;E(this,F,G)}Object.fromQueryString=function(G){if("?"==G.charAt(0)){G=G.slice(1)}G=G.split(/\s*&\s*/);var F={};G.forEach(A,F);return F};Object.toQueryString=function(K){if(!K){return""}var H;var J;var F;var G=[];function I(M){if(null!==M&&"undefined"!==typeof (M)){M=encodeURIComponent(M)}var L=M+"";if(L.length){G.push(H+"="+L)}else{G.push(H)}}for(H in K){J=K[H];F=DC.typeOf(J);if("function"===F||J===D[H]){continue}H=encodeURIComponent(H);if("array"===F){J.forEach(I)}else{I(J)}}return G.join("&")}})();RegExp.escape=function(A){return A.replace(RegExp._escapeRegex,"\\$1")};RegExp.specialCharacters=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];RegExp._escapeRegex=new RegExp("(\\"+RegExp.specialCharacters.join("|\\")+")","g");DC.strings={"marker.input.multipleValues":"Multiple Values","marker.input.placeholder":"","marker.input.noSelection":"No Selection","marker.text.multipleValues":"Multiple Values","marker.text.placeholder":"","marker.text.noSelection":"No Selection","error.no_description":"An unspecified error occurred.","error.invalid_value":"This value is not valid.","error.invalid_number":"This value is not a valid number."};DC.localisedString=function(A){return{toString:function(){if(A in DC.strings){return DC.strings[A]}console.log("Localisation missing string for key: "+A);return A}}};var _=DC.localisedString;DC.Error=Class.create({constructor:function(A){Object.extend(this,A)},description:_("error.no_description"),recoverySuggestion:null});DC.KeyInfo=Class.create({constructor:function(D,B){var A=DC.KVO.getPropertyMethodsForKeyOnObject(B,D);this.__uid=[B,DC.generateUid()].join("_");this.reader=A.getter;this.mutator=A.mutator;this.validator=A.validator;this.key=B;this.mutable=((this.mutator||!this.reader)?true:false);if(!this.reader&&!this.mutator){this.mutable=true}this.changeCount=0;var C=A.value;if(!C){return }var E=DC.typeOf(C);if(E in DC.KVO.typesOfKeyValuesToIgnore||!C._addParentLink){return }C._addParentLink(D,this)},get:function(B){if(this.reader){return this.reader.call(B)}var A;if(this.key in B){A=B[this.key]}else{A=null}if(A&&A._addParentLink){A._addParentLink(B,this)}return A},set:function(B,A){if(this.mutator){this.mutator.call(B,A)}else{B.willChangeValueForKey(this.key,this);B[this.key]=A;B.didChangeValueForKey(this.key,this)}},validate:function(B,A){if(!this.validator){return A}return this.validator.call(B,A)},unlinkParentLink:function(){if(!this.parentLink){return }this.parentLink.observer=null;this.parentLink.callback=null;this.parentLink=null}});DC.ChangeType={setting:0,insertion:1,deletion:2,replacement:3};DC.ChangeNotification=Class.create({constructor:function(D,A,E,C,B){this.object=D;this.changeType=A;this.newValue=E;this.oldValue=C;this.indexes=B;this.objectKeyPath=[]},toString:function(){var A="[ChangeNotification changeType: ";switch(this.changeType){case DC.ChangeType.setting:A+="setting";break;case DC.ChangeType.insertion:A+="insertion";break;case DC.ChangeType.deletion:A+="deletion";break;case DC.ChangeType.replacement:A+="replacement";break;default:A+="<<unknown>>";break}A+=" newValue="+this.newValue+" oldValue="+this.oldValue+(this.indexes?" indexes="+this.indexes.join(", "):"")+"]";return A}});DC.ObserverEntry=Class.create({constructor:function(A,C,B){this.observer=A;this.callback=C;this.context=B},observeChangeForKeyPath:function(A,B){if(!this.callback||!this.observer||-1!==A.objectKeyPath.indexOf(this.observer)){return }this.callback.call(this.observer,A,B,this.context)}});DC.KVO=Class.create({constructor:function(){},__factory__:function(){var B=Array.from(arguments);var A=this;function C(){}return function(){C.prototype=A.prototype;var D=new C();A.prototype.constructor.apply(D,B);return D}},setValueForKeyPath:function(C,D){if(!D||0===D.length){throw new InvalidArgumentError("keyPath may not be empty")}if("string"==typeof (D)){D=D.split(".")}var B=D[0];if(1==D.length){this.setValueForKey(C,B);return }if("@"==B.charAt(0)){return }var A=this.valueForKey(B);if(!A){return }A.setValueForKeyPath(C,D.slice(1))},setValueForKey:function(B,A){if(!A||0===A.length){throw new InvalidArgumentError("key may not be empty")}var C=this.infoForKey(A);if(!C||!C.mutable){return }C.set(this,B)},valueForKeyPath:function(E){if(!E||0===E.length){throw new InvalidArgumentError("keyPath may not be empty")}if("string"==typeof (E)){E=E.split(".")}var D=E[0];if(1==E.length){return this.valueForKey(D)}if("@"==D.charAt(0)){var B=D.substr(1);var A=this.valueForKeyPath(E.slice(1));return DC.ArrayOperator[B](A)}var C=this.valueForKey(D);if("undefined"===typeof (C)||null===C){return undefined}return C.valueForKeyPath(E.slice(1))},valueForKey:function(A){if(!A||0===A.length){throw new InvalidArgumentError("the key is empty")}var B=this.infoForKey(A);if(!B){return null}return B.get(this)},validateValueForKeyPath:function(C,D){if(!D||0===D.length){throw new InvalidArgumentError("keyPath may not be empty")}if("string"==typeof (D)){D=D.split(".")}var B=D[0];if(1==D.length){return this.validateValueForKey(C,B)}var A=this.valueForKey(B);if("undefined"===typeof (A)||null===A){return C}return A.validateValueForKeyPath(C,D.slice(1))},validateValueForKey:function(B,A){if(!A||!A.length){throw new InvalidArgumentError("missing key")}var C=this.infoForKey(A);return C.validate(this,B)},observeChildObjectChangeForKeyPath:function(D,C,A){if(DC.KVO.kAllPropertiesKey!=C){C=A+"."+C}else{C=A}var B=Object.clone(D);B.object=this;this.notifyObserversOfChangeForKeyPath(B,C)},infoForKeyPath:function(D){if(!D||0===D.length){throw new InvalidArgumentError("keyPath is empty")}if("string"==typeof (D)){D=D.split(".")}var B=D[0];if(1==D.length){return this.infoForKey(B)}else{if("@"==B.charAt(0)){var C=new DC.KeyInfo(null,null);C.mutable=false;return C}else{var A=this.valueForKey(B);if(!A){return undefined}if(!A.infoForKeyPath){return undefined}return A.infoForKeyPath(D.slice(1))}}},infoForKey:function(A){var B;if(!this.__keys){this.__keys={}}if(DC.KVO.kAllPropertiesKey==A){return null}B=this.__keys[A];if(B){return B}B=new DC.KeyInfo(this,A);this.__keys[A]=B;return B},setKeysTriggerChangeNotificationsForDependentKey:function(D,C){if(!D||!D.length){throw new InvalidArgumentError("keys array is not valid")}if(!C){throw new InvalidArgumentError("dependentKey can not be null")}if(-1!==C.indexOf(".")){throw new InvalidArgumentError("dependentKey may not be a key path")}var B;var F;var A;var E;if("string"===typeof (D)){D=[D]}if(!this.__dependentKeys){this.__dependentKeys={}}for(A=0;A<D.length;++A){B=D[A];if(!B){throw new InvalidArgumentError("key at index "+A+" was null")}if(!(B in this.__dependentKeys)){this.__dependentKeys[B]=[]}DC.KVO.getPropertyMethodsForKeyOnObject(B,this);E=this.__dependentKeys[B];if(-1==E.indexOf(C)){E.push(C)}}},mutableKeys:function(){var D=[];var B;var A;var C;if("__mutableKeys" in this&&this.__mutableKeys.concat){return this.__mutableKeys}var E=Set.union(DC.KVO.keysToIgnore,this.__keysToIgnore);for(B in this){if(B in E||"__"===B.substr(0,2)){continue}A=this[B];if("function"!==typeof (A)){D.push(B);continue}if(1!==A.length||"set"!==B.substr(0,3)){continue}C=B.charAt(3);if(C!==C.toUpperCase()){continue}B=C.toLowerCase()+B.substr(4);if(-1===D.indexOf(B)){D.push(B)}}return D},initialiseKeyValueObserving:function(){this.__uid=this.__uid||DC.generateUid();this.__observers={}},_addParentLink:function(D,E,C){if(!this.hasOwnProperty("__observers")){this.initialiseKeyValueObserving()}var B=this.__observers[DC.KVO.kAllPropertiesKey];if(!B){B=this.__observers[DC.KVO.kAllPropertiesKey]={}}C=C||E.__uid;if(C in B){return }var A=new DC.ObserverEntry(D,D.observeChildObjectChangeForKeyPath,E?E.key:"");B[C]=A;if(!E){return }E.unlinkParentLink();E.parentLink=A},_removeParentLink:function(C,D,B){if(!this.__observers){return }var A=this.__observers[DC.KVO.kAllPropertiesKey];if(!A){A=this.__observers[DC.KVO.kAllPropertiesKey]={}}B=B||D.__uid;if(D&&D.parentLink===A[B]){D.unlinkParentLink()}delete A[B]},addObserverForKeyPath:function(A,E,D,B){if(!D||0===D.length){throw new InvalidArgumentError("keyPath is empty")}if(!A){throw new InvalidArgumentError("Observer may not be null")}if(!E){E=A.observeChangeForKeyPath}if("string"===typeof (E)){E=A[E]}if(!E){throw new InvalidArgumentError("Missing callback method")}if(!this.hasOwnProperty("__observers")){this.initialiseKeyValueObserving()}if(!this.__observers[D]){this.infoForKeyPath(D);this.__observers[D]=[]}var C=new DC.ObserverEntry(A,E,B);this.__observers[D].push(C)},removeObserverForKeyPath:function(C,F){if(!F||0===F.length){throw new InvalidArgumentError("keyPath may not be empty")}if(!C){throw new InvalidArgumentError("Observer may not be null")}if(!this.__observers||!this.__observers[F]){return }var E=this.__observers[F];var B=-1;var D;var A=E.length;for(B=0;B<A;++B){D=E[B];if(D.observer==C){E.splice(B,1);return }}},willChangeValueForKey:function(A,C){if(!A){throw new InvalidArgumentError("key may not be null")}C=(C instanceof DC.KeyInfo)?C:this.infoForKey(A);if(!C){return }if(1!==++C.changeCount){return }var B=(this.__dependentKeys&&this.__dependentKeys[A]);if(B){B.forEach(this.willChangeValueForKey,this)}C.previousValue=C.get(this)},forceChangeNotificationForKey:function(A,B){if(!A){throw new InvalidArgumentError("key may not be null")}B=(B instanceof DC.KeyInfo)?B:this.infoForKey(A);if(!B){return }if(0!==B.changeCount){return }B.changeCount=1;this.didChangeValueForKey(A,B)},didChangeValueForKey:function(B,F){if(!B){throw new InvalidArgumentError("key may not be null")}F=(F instanceof DC.KeyInfo)?F:this.infoForKey(B);if(!F){return }if(0!==--F.changeCount){return }var C=F.get(this);var A=F.previousValue;F.previousValue=null;if(C!==A){var E=new DC.ChangeNotification(this,DC.ChangeType.setting,C,A);this.notifyObserversOfChangeForKeyPath(E,B);if(A&&A._removeParentLink){A._removeParentLink(this,F)}if(C&&C._addParentLink){C._addParentLink(this,F)}}var D=(this.__dependentKeys&&this.__dependentKeys[B]);if(D){D.forEach(this.didChangeValueForKey,this)}},notifyObserversOfChangeForKeyPath:function(J,L){if(!L){throw new InvalidArgumentError("keyPath may not be null")}if(!this.__observers){return }var G;var F;var H;F=this.__observers[DC.KVO.kAllPropertiesKey];if(F){var E=Object.clone(J);var A=J.objectKeyPath.length;J.objectKeyPath.push(this);for(G in F){var B=F[G];B.observeChangeForKeyPath(E,L)}J.objectKeyPath.length=A}if(DC.KVO.kAllPropertiesKey==L){return }F=this.__observers[L];if(F&&F.length){H=F.length;for(G=0;G<H;++G){F[G].observeChangeForKeyPath(J,L)}}var D=L+".";var I=D.length;var K;var M;var P;var O;var C;var N=!(null===J.oldValue||"undefined"===typeof (J.oldValue));for(M in this.__observers){if(M.substr(0,I)!=D){continue}F=this.__observers[M];if(!F||!F.length){continue}K=M.substr(I);O=J.oldValue;if(O&&O.valueForKeyPath){O=O.valueForKeyPath(K)}else{O=null}C=J.newValue;if(C&&C.valueForKeyPath){C=C.valueForKeyPath(K)}else{C=null}if(N&&O===C){continue}P=new DC.ChangeNotification(J.object,J.changeType,C,O,J.indexes);H=F.length;for(G=0;G<H;++G){F[G].observeChangeForKeyPath(P,M)}}}});DC.KVO.kAllPropertiesKey="*";DC.KVO.keysToIgnore=$S("__keys","__observers","__keysToIgnore","__dependentKeys","__mutableKeys","__factories__");DC.KVO.typesOfKeyValuesToIgnore=$S("string","number","boolean","date","regexp","function");DC.KVO.getPropertyMethodsForKeyOnObject=(function(){function B(H,F){F=F||"__kvo_prop_"+H;var G={getter:function(){var I=null;if(F in this){I=this[F]}var J=this.__keys?this.__keys[H]:null;if(!J){return I}if(I&&I._addParentLink){I._addParentLink(this,J)}else{J.unlinkParentLink()}return I},mutator:function(I){this.willChangeValueForKey(H);if("undefined"===typeof (I)){I=null}this[F]=I;this.didChangeValueForKey(H);return I}};G.mutator.__key=H;G.getter.__key=H;return G}function C(H,G){function F(J){this.willChangeValueForKey(G);var I=H.call(this,J);this.didChangeValueForKey(G);return I}F.__key=G;F.valueOf=function(){return H};F.toString=function(){return String(H)};return F}function D(F,H){function G(){var I=F.call(this);var J=this.__keys?this.__keys[H]:null;if(!J){return I}if(I&&I._addParentLink){I._addParentLink(this,J)}else{J.unlinkParentLink()}return I}G.__key=H;G.valueOf=function(){return F};G.toString=function(){return String(F)};return G}function E(T,K){var M=K.constructor.prototype;var J=(M==K);var L=(M!=Object.prototype&&M!=DC.KVO.prototype)?M:K;var U=T.titleCase();var P="get"+U;var Q="set"+U;var I="validate"+U;var O;var H;var S;var F=K[I];var N=("undefined"!==typeof (O=K.__lookupGetter__(T))&&"undefined"!==typeof (H=K.__lookupSetter__(T)));if(!N){P=(P in K)?P:T;O=K[P];H=K[Q]}if("function"!==typeof (O)){var R="__kvo_prop_"+T;var G=B(T,R);if(T in K){S=K[R]=("undefined"==typeof (O)?null:O);delete K[T]}O=G.getter;H=G.mutator;N=true}else{if(O&&!J){S=O.valueOf().call(K)}if(O&&T!==O.__key){O=D(O,T)}if(H&&T!==H.__key){H=C(H,T)}}if(N){L.__defineGetter__(T,O);L.__defineSetter__(T,H)}else{if(O){if(K.hasOwnProperty(P)){K[P]=O}else{L[P]=O}}if(H){if(K.hasOwnProperty(Q)){K[Q]=H}else{L[Q]=H}}}return{getter:O,mutator:H,validator:F,value:S}}function A(Q,J){var L=J.constructor.prototype;var I=(L==J);var K=(L!=Object.prototype&&L!=DC.KVO.prototype)?L:J;var R=Q.titleCase();var O="set"+R;var N="get"+R;var H="validate"+R;N=(N in J)?N:Q;var M=J[N];var G=J[O];var F=J[H];var P;if("function"!==typeof (M)){if(Q in J){P=M}M=null;G=null}else{if(M&&!I){P=M.valueOf().call(J)}if(M&&Q!==M.__key){M=D(M,Q)}if(G&&Q!==G.__key){G=C(G,Q)}}if(M){if(J.hasOwnProperty(N)){J[N]=M}else{K[N]=M}}if(G){if(J.hasOwnProperty(O)){J[O]=G}else{K[O]=G}}return{getter:M,mutator:G,validator:F,value:P}}if(DC.Support.Properties){return E}else{return A}})();DC.KVO.adapt=function(B){if(!B){throw new InvalidArgumentError("Can't adapt a null object")}var A;for(A in DC.KVO.prototype){if(A in B){continue}B[A]=DC.KVO.prototype[A]}if("keyDependencies" in B&&!("__dependentKeys" in B)){var C=B.keyDependencies;for(A in C){B.setKeysTriggerChangeNotificationsForDependentKey(C[A],A)}}return B};DC.KVO.adaptTree=function(C){DC.KVO.adapt(C);var B;var A;for(B in C){if(B in DC.KVO.keysToIgnore){continue}A=C[B];if(!A){continue}if(DC.typeOf(A) in DC.KVO.typesOfKeyValuesToIgnore){continue}DC.KVO.adaptTree(A)}return C};DC.KVO.__subclassCreated__=function(A){var D=A.superclass.prototype;var B=A.prototype;if(D.keyDependencies===B.keyDependencies){return }var E=B.keyDependencies||{};for(var C in E){B.setKeysTriggerChangeNotificationsForDependentKey(E[C],C)}};DC.Bindable=Class.create(DC.KVO,{constructor:function(A){this.bindings={};this.__parameters=A;this.__context=DC.dataModel},__createFactoryObjects:function(){var A=DC.dataModel;var C=this.__context;DC.dataModel=this.__context=this;var D;var B;for(D in this.__factories__){B=this[D];if(!B.__factoryFn__){continue}this[D]=B.call(this)}DC.dataModel=A;this.__context=C},exposedBindings:[],defaultPlaceholders:{},automaticallySetupBindings:true,__relativeSource:null,defaultPlaceholderForMarkerWithBinding:function(B,C){var A=this.defaultPlaceholders[C];if(!A){return null}return A[B]||null},__createObserverMethod:function(B,C){function A(E){if(DC.ChangeType.setting!==E.changeType){throw new InvalidArgumentError('Received invalid change type for synthesized binding observer (name="'+B+'" keyPath="'+C+'")')}var D=E.newValue;this.setValueForKey(E.newValue,B)}return A},bindNameToKeyPath:function(B,G,A){var D;var F;var E={};if(!this.bindings){this.bindings={}}D=this["observe"+B.titleCase()+"Change"]||this.__createObserverMethod(B,G);if(this.bindings[B]){this.bindings[B].unbind()}var C=this.__context;if("object"===typeof (G)){Object.extend(E,G);G=E.keypath}Object.extend(E,DC.Binding.bindingInfoFromString(G));if("transformValue" in E){E.transformer={transformValue:E.transformValue,reverseTransformedValue:E.reverseTransformedValue||null};delete E.transformValue;delete E.reverseTransformedValue}if("*."===E.keypath.substr(0,2)){if(A){C=A}else{C=new DC.KVO()}E.keypath=E.keypath.substr(2)}E.name=B;E.object=C;E.observer=this;E.observerFn=D;F=new DC.Binding(E);F.bind();this.bindings[B]=F},__postConstruct:function(){if(!this.automaticallySetupBindings){return }this.__initialising=true;this.__copyParameters(this.__parameters||{});this.setupBindings();this.updateBindings();this.createObservers();delete this.__initialising},__copyParameters:function(C){var D;var A;var B=DC.KVO.adaptTree;for(D in C){if(-1!==D.search(/Binding$/)){continue}A=C[D];if("object"===DC.typeOf(A)&&!("addObserverForKeyPath" in A)){B(A)}this[D]=A}this.__parameters=C},bindingInfoForName:function(A){if(!this.__parameters){return null}return this.__parameters[A+"Binding"]},__createAutoObserver:function(C,B){var A=DC.ChangeType.setting;return function(D){if(this.bindings[B]||A==D.changeType){return }C.apply(this,arguments)}},createObservers:function(){var E=this.exposedBindings;var A=E.length;var B;var D;var C;for(B=0;B<A;++B){C=E[B];D=this["observe"+C.titleCase()+"Change"];if(!D){continue}D=this.__createAutoObserver(D,C);this.addObserverForKeyPath(this,D,C,"__auto_observer__")}},setupBindings:function(){var D=this.exposedBindings;var B=D.length;var E;var A;var C;for(C=0;C<B;++C){A=D[C];E=this.bindingInfoForName(A);if(!E){continue}this.bindNameToKeyPath(A,E,this.__relativeSource)}},updateBindings:function(){var E=this.bindings;var D=this.exposedBindings;var B=D.length;var A;var C;for(C=0;C<B;++C){A=E[D[C]];if(!A){continue}A.update()}},unbind:function(){for(var A in this.bindings){this.bindings[A].unbind()}}});DC.Bindable.__subclassCreated__=function(C){var E=C.superclass.prototype;var D=C.prototype;if(D.hasOwnProperty("defaultPlaceholders")){var B=Object.clone(E.defaultPlaceholders);D.defaultPlaceholders=Object.extend(B,D.defaultPlaceholders)}if(E.exposedBindings===D.exposedBindings&&!D.maskedBindings){return }var A=(E.maskedBindings===D.maskedBindings)?{}:$S(D.maskedBindings);function F(H){return !(H in A)}var G=E.exposedBindings.filter(F);if(E.exposedBindings!==D.exposedBindings){G=G.concat(D.exposedBindings.filter(F))}D.exposedBindings=G};DC.SortDescriptor=Class.create({constructor:function(D,A,B){this.keyPath=D;this.ascending=A;this.comparisonFn=B||this.defaultCompare;var C=typeof (this.comparisonFn);if("string"!=C&&"function"!=C){throw new InvalidArgumentError("comparisonFn must be either the name of a method or a function reference")}},resolveComparisonFn:function(B){var A=this.comparisonFn;if("string"===typeof (A)){A=B[A]}if("function"!==typeof (A)){throw new TypeError("comparisonFn does not resolve to a function")}return A},compareObjects:function(C,B){if(!C.valueForKeyPath||!B.valueForKeyPath){throw new InvalidArgumentError("Objects are not Key Value compliant")}var E=C.valueForKeyPath(this.keyPath);var D=B.valueForKeyPath(this.keyPath);var A=this.resolveComparisonFn(E);return A.call(E,D)},defaultCompare:function(A){return DC.compareValues(this,A)},reversedSortDescriptor:function(){return new DC.SortDescriptor(this.keyPath,!this.ascending,this.comparisonFn)}});DC.ValueTransformer=Class.create({transformedValue:function(A){return A},reverseTransformedValue:function(A){return A},__factory__:function(){var B=Array.from(arguments);var A=this;function C(){}return function(){C.prototype=A.prototype;var D=new C();A.prototype.constructor.apply(D,B);return D}}});DC.ValueTransformer.__subclassCreated__=function(A){var C=DC.ValueTransformer.prototype;var B=A.prototype;if(C.reverseTransformedValue==B.reverseTransformedValue){A.prototype.reverseTransformedValue=null}};DC.transformer={};DC.transformerInstances={};DC.findTransformerWithName=function(transformerName){var valueTransformer=DC.transformerInstances[transformerName.toLowerCase()];if(valueTransformer){return valueTransformer}if(-1===transformerName.indexOf(".")){valueTransformer=DC.transformer[transformerName]}if(!valueTransformer){try{valueTransformer=eval(transformerName)}catch(e){}}if(!valueTransformer){throw new InvalidArgumentError("The transformerName argument does not specify a valid ValueTransformer: "+transformerName)}if("function"!==typeof (valueTransformer)){return valueTransformer}if(valueTransformer.__factoryFn__){valueTransformer=valueTransformer()}else{valueTransformer=new valueTransformer()}return valueTransformer};DC.registerTransformerWithName=function(B,A){if(!B.transformedValue){throw new InvalidArgumentError("The valueTransformer argument does not support the ValueTransformer method transformedValue")}A=A.toLowerCase();DC.transformerInstances[A]=B};DC.transformer.Not=Class.create(DC.ValueTransformer,{transformedValue:function(A){return(A?false:true)},reverseTransformedValue:function(A){return !!A}});DC.registerTransformerWithName(new DC.transformer.Not(),"not");DC.transformer.Boolean=Class.create(DC.ValueTransformer,{constructor:function(A,B){this.trueValue=A;this.falseValue=B},transformedValue:function(A){return(A==this.trueValue)},reverseTransformedValue:function(A){return(A?this.trueValue:this.falseValue)}});DC.transformer.Matches=Class.create(DC.ValueTransformer,{constructor:function(A){this.trueRegex=A},transformedValue:function(A){return this.trueRegex.test(A)}});DC.transformer.Generic=Class.create(DC.ValueTransformer,{constructor:function(A,B){this.modelValues=A;this.displayValues=B},transformedValue:function(B){var A=this.modelValues.indexOf(B);var C;if(-1==A){return C}else{return this.displayValues[A]}},reverseTransformedValue:function(B){var A=this.displayValues.indexOf(B);var C;if(-1==A){return C}else{return this.modelValues[A]}}});DC.transformer.Truncated=Class.create(DC.ValueTransformer,{constructor:function(A){this.max=A||50},ellipsis:String.fromCharCode(8230),transformedValue:function(C){if(!C&&0!==C){return C}C=""+C;var A=C.length;if(A<=this.max){return C}var B=this.max/2-2;return[C.substr(0,B),this.ellipsis,C.substr(A-B)].join(" ")}});DC.registerTransformerWithName(new DC.transformer.Truncated(50),"truncated");DC.transformer.StringsToObjects=Class.create(DC.ValueTransformer,{constructor:function(A){this.key=A||"string"},transformedValue:function(B){if(!B||!B.map){return B}function A(C){var D=new DC.KVO();D[this.key]=C;return D}return B.map(A,this)},reverseTransformedValue:function(B){if(!B||!B.map){return B}function A(C){return C[this.key]}return B.map(A,this)}});DC.registerTransformerWithName(new DC.transformer.StringsToObjects("string"),"StringsToObjects");DC.transformer.FirstObject=Class.create(DC.ValueTransformer,{transformedValue:function(A){if(DC.typeOf(A)=="array"){return A[0]}return A}});Object.extend(DC,{NoSelectionMarkerType:"noSelection",MultipleValuesMarkerType:"multipleValues",NullValueMarkerType:"nullValue"});DC.Binding=Class.create({constructor:function(A){Object.extend(this,A);if("string"===typeof (this.transformer)){this.transformer=DC.findTransformerWithName(this.transformer)}if("function"===typeof (this.transformer)){if(this.transformer.__factoryFn__){this.transformer=this.transformer()}else{this.transformer=new this.transformer()}}this.refresh()},bind:function(){this.object.addObserverForKeyPath(this,this.observeChangeForKeyPath,this.keypath)},unbind:function(){this.object.removeObserverForKeyPath(this,this.keypath)},refresh:function(){var A=this.object.valueForKeyPath(this.keypath);this.cachedOriginalValue=A;this.markerType=this.markerTypeFromValue(A);if(this.markerType){if((this.markerType+"Placeholder") in this){A=this[this.markerType+"Placeholder"]}else{A=this.observer.defaultPlaceholderForMarkerWithBinding(this.markerType,this.name)}}else{A=this.transformedValue(A)}this.cachedValue=A},transformedValue:function(A){if(!this.transformer){return A}return this.transformer.transformedValue(A)},validateProposedValue:function(B){if(this.transformer){if(!this.transformer.reverseTransformedValue){throw new Error("Can't validate a value when the transformer doesn't have a reverseTransformedValue method")}B=this.transformer.reverseTransformedValue(B)}var A=this.object.validateValueForKeyPath(B,this.keypath);if(A instanceof DC.Error){return A}return this.transformedValue(A)},setValue:function(A){if(this.cachedValue===A){return }this.markerType=this.markerTypeFromValue(A);this.cachedValue=A;if(this.transformer){if(!this.transformer.reverseTransformedValue){return }A=this.transformer.reverseTransformedValue(A)}this.cachedOriginalValue=A;var B=this.updating;this.updating=true;this.object.setValueForKeyPath(A,this.keypath);this.updating=B},mutable:function(){if(this.transformer&&!this.transformer.reverseTransformedValue){return false}var A=this.object.infoForKeyPath(this.keypath);return A&&A.mutable},value:function(){return this.cachedValue},update:function(){var B=this.value();var C=new DC.ChangeNotification(this.object,DC.ChangeType.setting,B);this.updating=true;try{this.observerFn.call(this.observer,C,this.keypath)}catch(A){console.error('Exception while bindng "'+this.name+'" to keypath "'+this.keypath+' ": '+A)}this.updating=false},observerFn:function(C,A,B){},markerTypeFromValue:function(A){if(null===A||"undefined"===typeof (A)||""===A){return DC.NullValueMarkerType}if(DC.Markers.MultipleValues===A){return DC.MultipleValuesMarkerType}if(DC.Markers.NoSelection===A){return DC.NoSelectionMarkerType}return null},placeholderValue:function(){var A;if((this.markerType+"Placeholder") in this){A=this[this.markerType+"Placeholder"]}else{A=this.observer.defaultPlaceholderForMarkerWithBinding(this.markerType,this.name)}if("function"===typeof (A)){A=A.call(this.object)}return A},observeChangeForKeyPath:function(G,A,B){if(this.updating&&G.newValue===this.cachedOriginalValue){return }this.cachedOriginalValue=G.newValue;var E=G.newValue;this.markerType=this.markerTypeFromValue(E);if(this.markerType){E=this.placeholderValue()}else{E=this.transformedValue(E)}var C=Object.clone(G);C.newValue=E;if(DC.ChangeType.setting===G.changeType){this.cachedValue=E}var F=this.updating;this.updating=true;try{this.observerFn.call(this.observer,C,A,B)}catch(D){console.error('Exception while bindng "'+this.name+'" to keypath "'+this.keypath+' ": '+D)}this.updating=F}});DC.Binding.bindingRegex=/^(.*?)(?:\((.*)\))?$/;DC.Binding.compoundRegex=/^\s*([^&|].*?)\s*(\&\&|\|\|)\s*(\S.+)\s*$/;DC.Binding.bindingInfoFromString=function(B){var A;var C;A=B.match(DC.Binding.bindingRegex);if(!A||A.length<3){throw new InvalidArgumentError("bindingString isn't in correct format")}var D={keypath:A[1]};if(A[2]){D.transformer=DC.findTransformerWithName(A[2])}return D};Class.extend(Array,{containsObject:function(A){return -1!==this.indexOf(A)},valueForKey:function(D){if(!D||0===D.length){throw new InvalidArgumentError("the key is empty")}if("@count"==D){return this.length}var E=new Array(this.length);var C;var A=this.length;var B;for(C=0;C<A;++C){B=this[C];E[C]=B?B.valueForKey(D):null}return E},setValueForKey:function(D,C){if(!C||0===C.length){throw new InvalidArgumentError("key is empty")}var B;var A=this.length;for(B=0;B<A;++B){this[B].setValueForKey(D,C)}},indexesOfObjects:function(E){var D;var B=E.length;var A=[];var C;for(D=0;D<B;++D){C=this.indexOf(E[D]);if(-1===C){continue}A.push(C)}return A},addObject:function(B){var A=this.length;var C=new DC.ChangeNotification(this,DC.ChangeType.insertion,[B],null,[A]);this.push(B);this.observeElementAtIndex(A);this.notifyObserversOfChangeForKeyPath(C,DC.KVO.kAllPropertiesKey)},addObjects:function(G){var B=G.length;var E=this.length;var C=[];var A=[];var F=new DC.ChangeNotification(this,DC.ChangeType.insertion,C,null,A);for(index=0;index<B;++index){var D=G[index];this.push(D);this.observeElementAtIndex(E);C.push(D);A.push(E++)}this.notifyObserversOfChangeForKeyPath(F,DC.KVO.kAllPropertiesKey)},insertObjectAtIndex:function(B,A){if(A<0||A>this.length){throw new RangeError("index must be within the bounds of the array")}var C=new DC.ChangeNotification(this,DC.ChangeType.insertion,[B],null,[A]);this.splice(A,0,B);this.observeElementAtIndex(A);this.notifyObserversOfChangeForKeyPath(C,DC.KVO.kAllPropertiesKey)},insertObjectsAtIndexes:function(E,C){if(E.length!==C.length){throw new InvalidArgumentError("length of objects and indexes parameters must be equal")}var A=E.length;var D;var B;for(D=0;D<A;++D){B=C[D];this.splice(B,0,E[D]);this.observeElementAtIndex(B)}var F=new DC.ChangeNotification(this,DC.ChangeType.insertion,E,null,C);this.notifyObserversOfChangeForKeyPath(F,DC.KVO.kAllPropertiesKey)},replaceObjectAtIndex:function(C,B){var A=this[B];this[B]=C;var D=new DC.ChangeNotification(this,DC.ChangeType.replacement,[C],[A],[B]);this.notifyObserversOfChangeForKeyPath(D,DC.KVO.kAllPropertiesKey)},replaceObjectsAtIndexes:function(F,D){var B=[];var A=F.length;var E;var C;for(E=0;E<A;++E){C=D[E];B[E]=this[C];this.stopObservingElementAtIndex(C);this[C]=F[E];this.observeElementAtIndex(C)}var G=new DC.ChangeNotification(this,DC.ChangeType.replacement,F,null,D);this.notifyObserversOfChangeForKeyPath(G,DC.KVO.kAllPropertiesKey)},removeObject:function(B){var A=this.indexOf(B);if(-1===A){return }this.removeObjectAtIndex(A)},removeObjects:function(D){var A=D.length;var B;for(var C=0;C<A;++C){B=this.indexOf(D[C]);if(-1===B){continue}this.removeObjectAtIndex(B)}},removeObjectsAtIndexes:function(D){var C;var E=D.sort(function(I,H){return H-I});var A=D.length;var B=[];for(C=0;C<A;++C){var F=E[C];this.stopObservingElementAtIndex(F);B.push(this[F]);this.splice(F,1)}var G=new DC.ChangeNotification(this,DC.ChangeType.deletion,null,B,E);this.notifyObserversOfChangeForKeyPath(G,DC.KVO.kAllPropertiesKey)},removeObjectAtIndex:function(B){if(B<0||B>=this.length){throw new RangeError("index must be within the bounds of the array")}this.stopObservingElementAtIndex(B);var A=this.splice(B,1);var C=new DC.ChangeNotification(this,DC.ChangeType.deletion,null,A,[B]);this.notifyObserversOfChangeForKeyPath(C,DC.KVO.kAllPropertiesKey)},removeAllObjects:function(){var D;var C=[];var A=this.length;C.length=A;for(D=0;D<A;++D){this.stopObservingElementAtIndex(D);C[D]=D}var B=this.splice(0,A);var E=new DC.ChangeNotification(this,DC.ChangeType.deletion,null,B,C);this.notifyObserversOfChangeForKeyPath(E,DC.KVO.kAllPropertiesKey)},objectsAtIndexes:function(C){var D;var B=[];var A=C.length;B.length=C.length;for(D=0;D<A;++D){B[D]=this[C[D]]}return B},observeChildObjectChangeForKeyPath:function(F,E,B){var D=F.object;var C=this.indexOf(D);if(!this.__uid){this.initialiseKeyValueObserving()}if(-1===C){D._removeParentLink(this,null,this.__uid);return }var A=new DC.ChangeNotification(D,DC.ChangeType.replacement,[F.newValue],[F.oldValue],[C]);this.notifyObserversOfChangeForKeyPath(A,E)},observeElementAtIndex:function(A){var B=this[A];if(!B||!B._addParentLink){return }if(!this.__uid){this.initialiseKeyValueObserving()}B._addParentLink(this,null,this.__uid)},stopObservingElementAtIndex:function(A){var B=this[A];if(!B||!B._removeParentLink){return }if(!this.__uid){this.initialiseKeyValueObserving()}B._removeParentLink(this,null,this.__uid)},initialiseKeyValueObserving:function(){var B;var A=this.length;this.__observers={};this.__uid=this.__uid||DC.generateUid();for(B=0;B<A;++B){this.observeElementAtIndex(B)}}});DC.KVO.adapt(Array.prototype);DC.ArrayOperator={avg:function(A){return this.sum(A)/A.length},count:function(A){throw new InvalidArgumentError("@count operator must end the keyPath")},distinctUnionOfArrays:function(A){return this.unionOfArrays(A).distinct()},distinctUnionOfObjects:function(A){return A.distinct()},max:function(D){var B=null;var E;var A;var C;for(E=0,A=D.length;E<A;++E){C=D[E];if(null===B||C>B){B=C}}return B},min:function(C){var E=null;var D;var A;var B;for(D=0,A=C.length;D<A;++D){B=C[D];if(null===E||B<E){E=B}}return E},sum:function(B){var D=0;var A=B.length;var C;for(C=0;C<A;++C){D+=B[C]}return D},unionOfArrays:function(B){var D=[];var A;var C;for(C=0,A=B.length;C<A;++C){D=D.concat(B[C])}return D},unionOfObjects:function(A){return A}};Object.extend(DC,{dataModel:new DC.KVO(),registerModelWithName:function(B,A){DC.dataModel.setValueForKey(B,A)},unregisterModelWithName:function(A){delete DC.dataModel[A]}});String.prototype.titleCase=function(){return this.charAt(0).toUpperCase()+this.substr(1)};String.prototype.trim=function(){var B=this.replace(/^\s+/,"");for(var A=B.length-1;A>0;--A){if(/\S/.test(B.charAt(A))){B=B.substring(0,A+1);break}}return B};String.prototype.beginsWith=function(A){return A===this.substring(0,A.length)};if(!String.prototype.localeCompare){String.prototype.localeCompare=function(A){if(this<A){return -1}else{if(this>A){return 1}else{return 0}}}}String.prototype.expand=function(C,A){function B(F,D){var E=C[D];if(null===E||"undefined"===typeof (E)){return A}return E}return this.replace(/\$\{(\w+)\}/g,B)};DC.Controller=Class.create(DC.Bindable,{constructor:function(A){this.base(A)},registerWithName:function(A){if(!A){return }this.name=A;DC.registerModelWithName(this,A)}});DC.Markers={MultipleValues:"ThisIsAnUniqueStringThatRepresentsMultipleValues",NoSelection:"ThisIsAnUniqueStringThatRepresentsNoSelection"};DC.SelectionProxy=Class.create(DC.KVO,{constructor:function(A){this.controller=A;this.mutable=true},infoForKey:function(B){var A=this.controller.selectedObjects();var C=A.infoForKey(B);C.mutable&=this.mutable;return C},infoForKeyPath:function(C){var A=this.controller.selectedObjects();var B=A.infoForKeyPath(C);B.mutable&=this.mutable;return B},translateValue:function(D){if("array"!==DC.typeOf(D)){return D}if(1===D.length){return D[0]}var C;var A;var B=D[0];for(C=1,A=D.length;C<A;++C){if(0!==DC.compareValues(B,D[C])){return DC.Markers.MultipleValues}}return B},valueForKey:function(C){var B=this.controller.selectedObjects();if(0===B.length){return DC.Markers.NoSelection}var A=B.valueForKey(C);return this.translateValue(A)},validateValueForKeyPath:function(E,F){var B=this.controller.selectedObjects();var A=B.length;var D;if(0===A){return E}var C;for(D=0;D<A;++D){C=B[D].validateValueForKeyPath(E,F);if(C instanceof DC.Error){return C}}return C},valueForKeyPath:function(C){var B=this.controller.selectedObjects();if(0===B.length){return DC.Markers.NoSelection}var A=B.valueForKeyPath(C);return this.translateValue(A)},setValueForKey:function(D,C){if(!this.mutable){return }var B=this.controller.selectedObjects();var A=this.valueForKey(C);B.setValueForKey(D,C);var E=this.valueForKey(C);if(A===E){return }var F=new DC.ChangeNotification(this,DC.ChangeType.setting,E,A);this.notifyObserversOfChangeForKeyPath(F,C)},setValueForKeyPath:function(C,F){if(!this.mutable){return }var B=this.controller.selectedObjects();var A=this.valueForKeyPath(F);B.setValueForKeyPath(C,F);var D=this.valueForKeyPath(F);if(A===D){return }var E=new DC.ChangeNotification(this,DC.ChangeType.setting,D,A);this.notifyObserversOfChangeForKeyPath(E,F)}});DC.ObjectController=Class.create(DC.Controller,{constructor:function(A){this.base(A);this.objectClass=DC.KVO;this.__content=null;this.__editable=true;this.__selectedObjects=[];this.__selection=new DC.SelectionProxy(this)},observeChildObjectChangeForKeyPath:function(F,E,B){this.base(F,E,B);if("selectedObjects"!==B){return }var C="selection."+E;var D=this.valueForKeyPath(C);var A=new DC.ChangeNotification(this,DC.ChangeType.setting,D,null);this.notifyObserversOfChangeForKeyPath(A,C)},keyDependencies:{},exposedBindings:["editable","content"],editable:function(){var A=this.__editable;if(this.bindings.content){A&=this.bindings.content.mutable()}return A},setEditable:function(A){if(this.bindings.content){A&=this.bindings.content.mutable()}if(this.bindings.editable){this.bingings.editable.setValue(A)}this.__editable=A},content:function(){return this.__content},setContent:function(A){if(this.bindings.content){this.bindings.content.setValue(A)}this.__content=A;this.willChangeValueForKey("selectedObjects");if(!A){this.__selectedObjects=[]}else{this.__selectedObjects=[A]}this.didChangeValueForKey("selectedObjects");this.forceChangeNotificationForKey("selection")},selectedObjects:function(){return this.__selectedObjects},selection:function(){return this.__selection}});function IndexRange(C,A){var B;var D=[];if(1==arguments.length&&C.length){A=C.length-1;C=0}for(B=C;B<=A;++B){D.push(B)}return D}DC.ArrayController=Class.create(DC.ObjectController,{constructor:function(A){this.base(A);this.arrangedObjects=[];this.__sortDescriptors=[];this.__filterPredicate=null;this.__selectionIndexes=[]},keyDependencies:{selectedObjects:["selectionIndexes"],selectionIndex:["selectionIndexes"],hasSelection:["selectionIndexes"],canRemove:["editable","selectionIndexes"],canAdd:["editable"]},selectsInsertedObjects:true,exposedBindings:["selectionIndexes","sortDescriptors","filterPredicate","contentForMultipleSelection"],observeContentChange:function(D){var A;var C;switch(D.changeType){case DC.ChangeType.setting:this.setContent(D.newValue);break;case DC.ChangeType.insertion:this._insertObjectsIntoArrangedObjects(D.newValue);if(this.selectsInsertedObjects&&!this.selectedObjects()){var B=this.selectedObjects();B=B.concat(D.newValue);this.setSelectedObjects(B)}else{if(!this.selectionIndexes().length&&this.avoidsEmptySelection()){this.setValueForKey([0],"selectionIndexes")}}break;case DC.ChangeType.deletion:this.rearrangeObjects();break;case DC.ChangeType.replacement:this.rearrangeObjects();break;default:break}},canAdd:function(){return this.editable()},add:function(){var A=new (this.objectClass)();var B=this.content();B.addObject(A)},canRemove:function(){return this.editable()&&this.selectionIndexes().length},remove:function(){var A=this.selectedObjects();var B=this.content();B.removeObjects(A)},setContent:function(A){A=A||[];if(this.bindings.content){this.bindings.content.setValue(A)}this.__content=A;this.rearrangeObjects(A)},sortDescriptors:function(){return this.__sortDescriptors},setSortDescriptors:function(A){if(this.bindings.sortDescriptors){this.bindings.sortDescriptors.setValue(A)}this.__sortDescriptors=A;this.rearrangeObjects()},filterPredicate:function(){return this.__filterPredicate},setFilterPredicate:function(A){if(this.bindings.filterPredicate){this.bindings.filterPredicate.setValue(A)}this.__filterPredicate=A;this.rearrangeObjects()},filterObjects:function(E){var F=this.filterPredicate();if(!F){return IndexRange(E)}var C=[];var D;var A;var B;for(D=0,A=E.length;D<A;++D){B=E[D];if(F(B)){C.push(D)}}return C},_compareObjects:function(F,E){var D;var B;var C=this.sortDescriptors();var A=C.length;for(D=0;D<A;++D){B=C[D].compareObjects(F,E);if(!C[D].ascending){B*=-1}if(0!==B){return B>0?1:-1}}return 0},sortObjects:function(D,B){B=B||IndexRange(D);var C=this.sortDescriptors();var E=C.length;function A(M,L){var I;var G;var K=D[M];var J=D[L];var F=E;var H=C;for(I=0;I<F;++I){G=H[I].compareObjects(K,J);if(!H[I].ascending){G*=-1}if(0!==G){return G}}return 0}if(0!==C.length){B.sort(A)}return B},arrangeObjects:function(E){var C=this.filterObjects(E);C=this.sortObjects(E,C);if(E===this.content()){var D=[];var A=C.length;for(var B=0;B<A;++B){D[C[B]]=B}this.__contentToArrangedMap=D;this.__arrangedToContentMap=C}return E.objectsAtIndexes(C)},rearrangeObjects:function(D){var G=D||this.content()||[];var C=this.arrangeObjects(G);var B=this.selectedObjects();var E=[];var A=B.length;var H;var F;this._inReArrangeObjects=true;for(F=0;F<A;++F){H=C.indexOf(B[F]);if(-1!==H){E.push(H)}}if(C.length&&this.avoidsEmptySelection()&&!E.length){E.push(0)}this.setValueForKey(C,"arrangedObjects");this.setValueForKey(E,"selectionIndexes");this._inReArrangeObjects=false},_insertObjectsIntoArrangedObjects:function(A){var H=this.arrangeObjects(A);var J=H.length;var B=this.arrangedObjects;var F=B.length;var G=[];var I=0;var D;var C;var E;G.length=J;for(E=0;E<J;++E){D=H[E];while(I<F){C=B[I];if(-1===this._compareObjects(D,C)){break}++I}G[E]=I+E}B.insertObjectsAtIndexes(H,G)},selectedObjects:function(){return this.__selectedObjects},setSelectedObjects:function(B){var C=[];var E;var D;var A=this.arrangedObjects;for(E=0;E<B.length;++E){D=A.indexOf(B[E]);if(-1===D){continue}C.push(D)}return this.setSelectionIndexes(C)},selectionIndexes:function(){return this.__selectionIndexes},setSelectionIndexes:function(B){B=B||[];B.sort();if((0===(this.selectionIndexes()||[]).compare(B))&&!this._inReArrangeObjects){return false}if(this.bindings.selectionIndexes){this.bindings.selectionIndexes.setValue(B)}this.__selectionIndexes=B;var A=this.arrangedObjects;this.__selectedObjects=A.objectsAtIndexes(B);this.forceChangeNotificationForKey("selection");return true},setSelectionIndex:function(B){var A=this.setSelectionIndexes([B]);return A},selectionIndex:function(){var A=this.selectionIndexes();if(0===A.length){return -1}return A[0]},hasSelection:function(){return(this.selectionIndexes().length>0)},setAvoidsEmptySelection:function(A){this.__avoidsEmptySelection=A;if(!this.hasSelection()&&this.arrangedObjects.length){this.setValueForKey([0],"selectionIndexes")}},avoidsEmptySelection:function(){return this.__avoidsEmptySelection}});(function(){var A=this.Element;this.Element={};Object.extend(this.Element,A||{})}).call(window);Object.extend(Element,{uniqueId:function(){return"DC_id_"+Element.assignId.uniqueId++},assignId:function(A){return A.id||(A.id=("DC_id_"+Element.assignId.uniqueId++))},regexForClassName:function(B){var A=arguments.callee;if(!A._lookup){A._lookup={}}if(B in A._lookup){return A._lookup[B]}return(A._lookup[B]=new RegExp("(^|\\s)"+B+"(\\s|$)"))},hasClassName:function(A,B){var C=A.className;if(!C){return false}if(C==B){return true}return Element.regexForClassName(B).test(C)},addClassName:function(A,B){if(!B){return }if(Element.hasClassName(A,B)){return }A.className+=" "+B},removeClassName:function(A,B){if(!A||!B){return }var C=Element.regexForClassName(B);A.className=A.className.replace(C," ").trim()},replaceClassName:function(B,C,A){if(!C){return }if(!A){Element.removeClassName(B,C);return }var D=Element.regexForClassName(C);B.className=B.className.replace(D,"$1"+A+"$2").trim()},toggleClassName:function(A,B){if(!B){return }var C=Element.regexForClassName(B);var D=A.className;if(C.test(D)){A.className=D.replace(C," ").trim()}else{A.className+=" "+B}},updateClass:function(F,G,C){var E=$S(F.className.split(" "));var H=Set.add;var B=Set.remove;var D;var A;if("string"===typeof (G)){H(E,G)}else{for(D=0,A=G.length;D<A;++D){H(E,G[D])}}if("string"===typeof (C)){B(E,C)}else{for(D=0,A=C.length;D<A;++D){B(E,C[D])}}F.className=Set.join(E," ")},PROPERTIES:["backgroundColor","backgroundPosition","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","color","display","fontSize","letterSpacing","lineHeight","opacity","width","height","top","bottom","left","right","marginTop","marginRight","marginBottom","marginLeft","paddingTop","paddingRight","paddingBottom","paddingLeft"],getStyles:function(E,D){var F={};var B=window.getComputedStyle(E,null);if("string"===typeof (D)){return E.style[D]||B[D]||null}D=D||Element.PROPERTIES;var G;var A=D.length;for(var C=0;C<A;++C){G=D[C];F[G]=E.style[G]||B[G]||null}return F},setStyle:function(A,B,C){A.style[B]=C},setStyles:function(A,B){var C=A.style;for(var D in B){C[D]=B[D]}},getDimensions:function(E){var G=Element.getStyle(E,"display");if(G&&G!="none"){return{left:E.offsetLeft,top:E.offsetTop,width:E.offsetWidth,height:E.offsetHeight}}var B=E.style;var F=B.visibility;var C=B.position;var A=B.display;B.visibility="hidden";B.position="absolute";B.display="block";var D={width:E.offsetWidth,height:E.offsetHeight,left:E.offsetLeft,top:E.offsetTop};B.display=A;B.position=C;B.visibility=F;return D},set3PiecesBorderImage:function(G,B,E,J){if(DC.Support.BorderImage){G.style.borderWidth=B?"0px "+J+"px 0px "+E+"px ":"0px";var K=B?"url("+B+") 0 "+J+" 0 "+E+" repeat stretch":"";G.style.webkitBorderImage=K;G.style.MozBorderImage=K}else{if(!B){G.innerHTML="";return }var A=document.createElement("div");var F=A.style;F.position="absolute";F.top="0px";F.bottom="0px";var L=A.cloneNode(false);L.style.left="0px";L.style.right="0px";var C=A.cloneNode(false);var D=C.style;D.backgroundImage="url("+B+")";D.backgroundRepeat="no-repeat";var H=C.cloneNode(false);var I=H.style;D.left="0px";D.width=E+"px";I.right="0px";I.width=J+"px";I.backgroundPosition="100% 0px";F.left=E+"px";F.right=J+"px";F.backgroundImage="url("+B.replace(/.png/,"__mid.png")+")";F.backgroundRepeat="repeat-x";if(G.firstChild){G.insertBefore(L,G.firstChild)}else{G.appendChild(L)}L.appendChild(C);L.appendChild(A);L.appendChild(H)}},clone:function(A){return A.cloneNode(true)},depthFirstTraversal:function(D,E,C){if(!D||!E){return }var A=D.nextSibling||D.parentNode;var B;C=C||E;while(D!==A){if(1===D.nodeType){B=E.call(C,D);if(false!==B&&D.firstChild){D=D.firstChild;continue}}while(!D.nextSibling){D=D.parentNode;if(D===A){return }}D=D.nextSibling}},query:function(B,A){if(1==arguments.length){A=B;B=document}else{if(B!=document){A="#"+Element.assignId(B)+" "+A}}return B.querySelector(A)},queryAll:function(B,A){if(1==arguments.length){A=B;B=document}else{if(B!=document){A="#"+Element.assignId(B)+" "+A}}return Array.from(B.querySelectorAll(A))},match:function(B,A){return Sizzle.matches(A,[B]).length==1},getViewport:function(){var B=document.documentElement;var A=document.body;return{left:window.scrollLeft||B.scrollLeft||A.scrollLeft,top:window.scrollTop||B.scrollTop||A.scrollTop,width:window.innerWidth||B.clientWidth||A.clientWidth,height:window.innerHeight|B.clientHeight||A.clientHeight}},scrollParent:function(F){var E;var C=Element.getStyles;var A=document.body;while(F&&F!=A){E=C(F,["overflow","overflowX","overflowY"]);for(var B in E){var D=E[B];if("auto"==D||"scroll"==D){return F}}F=F.parentNode}return F},getRect:function(P,N){if(!P){return null}var R=document.documentElement;var M=document.body;var D=0;var O=0;if(P!=document.body&&P.getBoundingClientRect){var L=P.getBoundingClientRect();L={left:L.left,right:L.right,top:L.top,bottom:L.bottom};if(!!N===false){L.left+=Math.max(R.scrollLeft,M.scrollLeft);L.right+=Math.max(R.scrollLeft,M.scrollLeft);L.top+=Math.max(R.scrollTop,M.scrollTop);L.bottom+=Math.max(R.scrollTop,M.scrollTop)}L.left-=R.clientLeft;L.right-=R.clientLeft;L.top-=R.clientTop;L.bottom-=R.clientTop;L.width=L.right-L.left+1;L.height=L.bottom-L.top+1;return L}var J=P.parentNode;var F=P;var A=P.offsetParent;var K=DC.Browser.Mozilla;var Q=DC.Browser.Safari&&!DC.Browser.Safari2;var B=DC.Browser.Safari2;var H=Element.getStyles;var G=Element.getDimensions(P);var C=("fixed"===Element.getStyles(P,"position"));var I;D+=P.offsetLeft;O+=P.offsetTop;while(!C&&A){D+=A.offsetLeft;O+=A.offsetTop;if(K&&!((/^t(able|d|h)$/i).test(A.tagName))||Q){I=H(A,["borderLeftWidth","borderTopWidth"]);D+=parseInt(I.borderLeftWidth||0,10);O+=parseInt(I.borderTopWidth||0,10)}if(!C){C=("fixed"===H(A,"position"))}if("BODY"!==A.tagName){F=A}A=A.offsetParent}var E=K?["display","overflow","borderLeftWidth","borderTopWidth"]:["display"];while(J&&J.tagName&&"BODY"!==J.tagName&&"HTML"!==J.tagName){I=H(J,E);if(!((/^inline|table.*$/i).test(I.display))){D-=J.scrollLeft;O-=J.scrollTop}if(K&&"visible"!=I.overflow){D+=parseInt(I.borderLeftWidth||0,10);O+=parseInt(I.borderTopWidth||0,10)}J=J.parentNode}var S=H(F,"position");if((B&&(C||S=="absolute"))||(K&&S!="absolute")){D-=M.offsetLeft;O-=M.offsetTop}if(N===true&&!C){D-=Math.max(R.scrollLeft,M.scrollLeft);O-=Math.max(R.scrollTop,M.scrollTop)}return{left:D,top:O,right:D+G.width-1,bottom:O+G.height-1,width:G.width,height:G.height}}});Element.getStyle=Element.getStyles;Element.assignId.uniqueId=1;if(!DC.Support.QuerySelector){Object.extend(Element,{query:function(B,A){if(1==arguments.length){A=B;B=document}return(Sizzle(A,B)[0]||null)},queryAll:function(B,A){if(1==arguments.length){A=B;B=document}return(Sizzle(A,B)||null)}})}if("undefined"===typeof (document.documentElement.children)){HTMLElement.prototype.__defineGetter__("children",function(){var B=[];var A=this.childNodes.length;var D;for(var C=0;C<A;++C){D=this.childNodes[C];if(Node.ELEMENT_NODE!==D.nodeType){continue}B.push(D)}return B})}if("undefined"===typeof (document.documentElement.innerText)){HTMLElement.prototype.__defineGetter__("innerText",function(){return this.textContent});HTMLElement.prototype.__defineSetter__("innerText",function(A){this.textContent=A})};(function(){var A=this.Event;this.Event={};Object.extend(this.Event,A||{})}).call(window);Object.extend(Event,{KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,KEY_INSERT:45,_domHasFinishedLoading:function(){if(arguments.callee.done){return }arguments.callee.done=true;if(this._domLoadedTimer){window.clearInterval(this._domLoadedTimer)}var C=Event._readyCallbacks;var A=C.length;var B;for(B=0;B<A;++B){C[B]()}Event._readyCallbacks=null},observe:function(C,A,B){if("on"==A.slice(0,2)){A=A.slice(2)}C.addEventListener(A,B,false)},stopObserving:function(C,A,B){if("on"==A.slice(0,2)){A=A.slice(2)}C.removeEventListener(A,B,false)},stop:function(A){A.preventDefault();A.stopPropagation()},preventDefault:function(A){A.preventDefault()},onDomReady:function(A){if(Event._domHasFinishedLoading.done){window.setTimeout(A,0);return }if(!Event._readyCallbacks){document.addEventListener("DOMContentLoaded",Event._domHasFinishedLoading,false);function B(){if((/loaded|complete/).test(document.readyState)){Event._domHasFinishedLoading()}}if(DC.Browser.Safari){Event._domLoadedTimer=window.setInterval(B,10)}Event.observe(window,"load",Event._domHasFinishedLoading);Event._readyCallbacks=[]}Event._readyCallbacks.push(A)}});DC.PartFinder=(function(){function C(G,E){var H=G.length;var D=Array.from(E);function I(){G=[];D=null;H=0}function M(P){G.splice(P,1);if(D){D.splice(P,1)}H=G.length}function F(P){var R=Element.assignId(P);var Q=G.indexOf(R);if(-1==Q){return }G.splice(Q,1);if(D){D.splice(Q,1)}H=G.length}function O(R,Q){var P=Element.assignId(R);G.splice(Q,0,P);if(D){D.splice(Q,0,R)}H=G.length}function N(P){G.push(Element.assignId(P));H=G.length;if(D){D.push(P)}}function K(){D=null}function J(){var R=[];var P;for(var Q=0;Q<H;++Q){P=document.getElementById(G[Q]);if(!P){continue}R.push(G[Q])}G=R;H=R.length;D=null}function L(R){if(D){if(1==arguments.length){return D[R]}return D}if(1==arguments.length){return document.getElementById(G[R])}var P=[];for(var Q=0;Q<H;++Q){P[Q]=document.getElementById(G[Q])}D=P;window.setTimeout(K,250);return P}if(E){window.setTimeout(K,250)}L.removePartAtIndex=M;L.removePart=F;L.insertPartAtIndex=O;L.add=N;L.removeAll=I;L.refresh=J;return L}function A(G,E){var D=E;function F(){D=null}function H(){if(D){return D}D=document.getElementById(G);window.setTimeout(F,250);return D}return H}function B(E,D){var F=Element.queryAll(E,D);var G=Array.map(F,Element.assignId);return{nodes:F,ids:G}}return{singlePart:function(E,D){function F(){var K=D;var G=typeof (K);if("function"===G){K=K()}else{if("string"===G){K=document.getElementById(K)}else{if(!K){K=this.viewElement()}}}var H=B(K,E);var J=A(H.ids[0],H.nodes[0]);var I=Class.findPropertyName(this,arguments.callee);if(I){this[I]=J}return H.nodes[0]}return F},multipleParts:function(E,D){function F(I){var L=D;var G=typeof (L);if("function"===G){L=L()}else{if("string"===G){L=document.getElementById(L)}else{if(!L){L=this.viewElement()}}}var H=B(L,E);var K=C(H.ids,H.nodes);var J=Class.findPropertyName(this,arguments.callee);if(J){this[J]=K}if(arguments.length){return H.nodes[I]}else{return Array.from(H.nodes)}}return F}}})();var Part=DC.PartFinder.singlePart;var PartList=DC.PartFinder.multipleParts;DC.Style={kSelectedClass:"selected",kDisabledClass:"disabled",kReadOnlyClass:"read-only",kMarkerClass:"nullValue",kFocusClass:"focused",kHoverClass:"hover",kAscendingClass:"asc",kDescendingClass:"desc",kActiveClass:"active",kUpdatingClass:"updating",kFadingClass:"invisible",kInvalidValueClass:"invalid",kInsertedClass:"inserted",kDeletedClass:"deleted",kReplacingClass:"replacing",kLoadingClass:"loading",kFirstClass:"first",kLastClass:"last"};DC.Style.__styles=(function(){var A=[];var B=DC.Style;for(var C in B){A.push(B[C])}return A})();window.FIRST_RESPONDER="__first_responder__";DC.Responder=Class.create(DC.Bindable,{sendActionToView:function(B,A){if(FIRST_RESPONDER===A){A=DC.page.firstResponder}var C=A||DC.page.firstResponder||this;while(C){if(B in C){C[B](this);return true}C=C.nextResponder()}return false},acceptsFirstResponder:function(){return false},becomeFirstResponder:function(){return true},resignFirstResponder:function(){return true},nextResponder:function(){return this.__nextResponder||null},setNextResponder:function(A){this.__nextResponder=A},presentError:function(B){this.willPresentError(B);if(!("field" in B)){B.field=this}var A=this.nextResponder();if(A){return A.presentError(B)}return false},clearAllErrors:function(B){var A=this.nextResponder();if(A){A.clearAllErrors(B||this)}},willPresentError:function(A){},onmousedown:function(A){var B=this.nextResponder();if(B){B.onmousedown(A)}},onmouseup:function(A){var B=this.nextResponder();if(B){B.onmouseup(A)}},onmousedrag:function(A){var B=this.nextResponder();if(B){B.onmousedrag(A)}},onmouseenter:function(A){var B=this.nextResponder();if(B){B.onmouseenter(A)}},onmouseleave:function(A){var B=this.nextResponder();if(B){B.onmouseleave(A)}},onclick:function(A){var B=this.nextResponder();if(B){B.onclick(A)}},ondblclick:function(A){var B=this.nextResponder();if(B){B.ondblclick(A)}},onkeydown:function(A){var B=this.nextResponder();if(B){B.onkeydown(A)}},onkeyup:function(A){var B=this.nextResponder();if(B){B.onkeyup(A)}},onkeypress:function(A){var B=this.nextResponder();if(B){B.onkeypress(A)}},ontouchstart:function(A){var B=this.nextResponder();if(B){B.ontouchstart(A)}},ontouchmove:function(A){var B=this.nextResponder();if(B){B.ontouchmove(A)}},ontouchend:function(A){var B=this.nextResponder();if(B){B.ontouchend(A)}},onswipe:function(A){var B=this.nextResponder();if(B){B.onswipe(A)}}});DC.View=Class.create(DC.Responder,{exposedBindings:["visible","class","enabled","editable","html","text"],defaultPlaceholders:{text:{multipleValues:_("marker.text.multipleValues"),nullValue:_("marker.text.placeholder"),noSelection:_("marker.text.noSelection")},html:{multipleValues:_("marker.text.multipleValues"),nullValue:_("marker.text.placeholder"),noSelection:_("marker.text.noSelection")}},automaticallySetupBindings:false,formatter:null,target:null,action:null,sendActionOn:["click"],animated:false,updateAnimationDuration:0,updateAnimationDelay:0,postUpdateAnimationDuration:0,postUpdateAnimationDelay:0,preUpdateAnimationDuration:0,preUpdateAnimationDelay:0,constructor:function(A,B,C){this.base(C);if("string"===typeof (A)){this.id=A;this.__view=document.getElementById(A)}else{this.id=Element.assignId(A);this.__view=A}if("object"===DC.typeOf(B)&&!("addObserverForKeyPath" in B)){DC.KVO.adaptTree(B)}this.__relativeSource=B;if(this.id in DC.View.viewLookup){throw new Error("Two views share the same ID: "+this.id)}this.viewElement().object=this;this.__updating=null;DC.View.viewLookup[this.id]=this},__postConstruct:function(){var B=this;function C(){if(DC.Browser.IE){delete B.__view;delete B.__container}}C.delay(250);var A=this.viewElement();if(A){this.__init()}else{Event.onDomReady(this.__init.bind(this))}},__init:function(){this.__initialising=true;var F=this.viewElement();if(!F){throw new Error("Unable to locate node with ID: "+this.id)}this.viewElement=function(){return F};var G;var A;var B=F.getAttribute("__parametersId");var H=this.__parameters||DC.View.nodeParameters[B]||{};this.__copyParameters(H);if(this.innerHTML&&""===String(F.innerHTML).trim()){F.innerHTML=this.innerHTML}var I=DC.dataModel;var C=this.__context;DC.dataModel=this.__context=this;var D=this.structure()||{};var E={};for(A in D){G=D[A];if(G&&"function"==typeof (G)&&(G=G.valueOf()).__factoryFn__){E[A]=G;G.call(this,A,true)}}for(A in E){E[A].call(this,A,false)}this.__context=C;DC.dataModel=I;this.setupBindings();this.init();this.initFromDOM();this.updateBindings();this.createObservers();delete this.__initialising;delete this.viewElement},teardown:function(){for(var A in this.bindings){this.bindings[A].unbind()}if(this.viewElement()){this.viewElement().object=null}if(!DC.Browser.IE){delete this.__view;delete this.__container}delete DC.View.viewLookup[this.id]},__factory__:function(D,I,A){var G=this;var F=Element.queryAll;var E=false;if("string"!==typeof (D)){A=I;I=D;D=null}I=I||{};var H="parameters_"+DC.generateUid();DC.View.nodeParameters[H]=I;I.viewClass=G;function C(K){K.setAttribute("__parametersId",H);var J;if("sortKey" in I){K.setAttribute("sortKey",I.sortKey)}}function B(K){if(!E){C(K)}var L=this.__relativeSource||this;var J=DC.View.fromNode(K)||new G(K,L);DC.View.createViewsForNodeTree(K,L,this.__context)}return function(L,K){if(L&&1===L.nodeType){return new G(L,K,I)}var M=A||(this?this.viewElement():document);var J=F(M,D||L);if(!J.length){return null}if("action" in I){if(!I.target){I.target=this}if(FIRST_RESPONDER!==I.target&&"string"===typeof (I.action)){I.action=(I.target)[I.action]}}Array.forEach(J,K?C:B,this);E=true;return DC.View.fromNode(J[0])}},init:function(){},initFromDOM:function(){},structure:function(){return this.__structure__},viewElement:function(){return this.__view||document.getElementById(this.id)},container:function(){return this.__container||this.__view||document.getElementById(this.__containerId||this.id)},setContainer:function(A){if(this.__view){this.__container=A}this.__containerId=Element.assignId(A);return A},superview:function(){var B=this.viewElement();if(!B){return null}var A=null;while(B&&!A){B=B.parentNode;if(!B){return null}if(document==B){return DC.page}A=DC.View.fromNode(B)}return A},isDescendantOf:function(B){if(!B){return false}var A=B.viewElement();var C=this.viewElement();while(C&&C!==document.body){if(C.id==A.id){return true}C=C.parentNode}return false},nextResponder:function(){return this.__nextResponder||this.superview()},focus:function(){var A=this.viewElement();A.focus()},blur:function(){var A=this.viewElement();A.blur()},sendAction:function(){var B=DC.EventLoop.currentEvent;if(!this.action){return }if(FIRST_RESPONDER!==this.target||"string"!==typeof (this.action)){this.action.call(this.target||this.action,this,B);return }var A=DC.page.firstResponder||this;var C=this.action;while(A){if(C in A){A[C](this,B);return }A=A.nextResponder()}},onclick:function(A){if(this.disabled){Event.stop(A);return }if(this.action&&this.sendActionOn.containsObject("click")){this.sendAction();Event.stop(A)}else{this.base(A)}},addTrackingInfo:function(A){DC.page.addTrackingInfo(this.id,A)},observeVisibleChange:function(F,E,B){var A=this.viewElement();var D=DC.Style.kFadingClass;function C(){A.style.display="none";Element.removeClassName(A,D)}if(!this.animated){A.style.display=(F.newValue?"":"none")}else{if(F.newValue){if(A.style.display!==""){Element.addClassName(A,D);A.style.display=""}DC.Animator.removeClassName(A,D,{duration:this.updateAnimationDuration||300})}else{DC.Animator.addClassName(A,D,{duration:this.updateAnimationDuration||300,callback:C})}}},observeEnabledChange:function(B){var A=this.viewElement();this.disabled=A.disabled=!B.newValue;if(A.disabled){Element.addClassName(A,DC.Style.kDisabledClass)}else{Element.removeClassName(A,DC.Style.kDisabledClass)}},observeEditableChange:function(B){var A=this.viewElement();A.readOnly=!B.newValue;if(A.readOnly){Element.addClassName(A,DC.Style.kReadOnlyClass)}else{Element.removeClassName(A,DC.Style.kReadOnlyClass)}},observeClassChange:function(H,G,D){var A=this.viewElement();var C=$S(A.className.split(" "));var F=$S((H.newValue||"").split(" "));function E(I){if(I in C){Set.add(F,I)}}DC.Style.__styles.forEach(E);var B=Set.join(F," ");if(this.animated){DC.Animator.setClassName(A,B,{duration:500})}else{A.className=B}},_beginUpdate:function(B,A){if(B){B.call(this)}},observeTextChange:function(G,F,C){var B=this.viewElement();var A=this.bindings.text&&this.bindings.text.markerType;var E=G.newValue;if(A){if(null===E||"undefined"===typeof (E)){E=""}Element.addClassName(B,DC.Style.kMarkerClass)}else{Element.removeClassName(B,DC.Style.kMarkerClass);if(this.formatter){E=this.formatter.stringFromValue(E)}}function D(){var H=document.createTextNode(E);B.innerHTML="";B.appendChild(H)}this._beginUpdate(D)},observeHtmlChange:function(G,F,C){var B=this.viewElement();var A=this.bindings.html&&this.bindings.html.markerType;var E=G.newValue;if(A){if(null===E||"undefined"===typeof (E)){E=""}Element.addClassName(B,DC.Style.kMarkerClass)}else{Element.removeClassName(B,DC.Style.kMarkerClass);if(this.formatter){E=this.formatter.stringFromValue(E)}}function D(){B.innerHTML=E}this._beginUpdate(D)},removeChild:function(A){if(!A){return null}DC.View.teardownViewsForNodeTree(A);if(this.beforeRemoveElement){this.beforeRemoveElement(A)}return A.parentNode.removeChild(A)},clonedFrom:function(A){}});DC.View.nodeParameters={};DC.View.viewLookup={};DC.View.__subclassCreated__=function(A){var B=A.prototype;var C=A.superclass.prototype;if(B.__structure__!==C.__structure__){Object.applyDefaults(B.__structure__,C.__structure__)}};DC.View.viewClassForNode=function(B,A){var C=B.getAttribute("__parametersId");if(!C){return null}return DC.View.nodeParameters[C].viewClass};DC.View.createViewForNode=function(C,E,B){var A=DC.View.fromNode(C);if(A){return A}var D=DC.View.viewClassForNode(C,B);return new (D||DC.View)(C,E,B)};DC.View.fromNode=function(A){var B=DC.View.viewLookup;var C=null;if(DC.typeOf(A)=="string"){C=A}else{if("id" in A){C=A.id}}if(!B||!C||!B[C]){return null}return B[C]};DC.View.rebindNodeTreeWithRelativeSource=function(B,D,C){function A(F){var E=DC.View.fromNode(F);if(!E||(D&&E.__relativeSource!==D)){return }E.__relativeSource=C;E.setupBindings();E.updateBindings()}Element.depthFirstTraversal(B,A)};DC.View.unbindNodeTree=function(B){function A(D){var C=DC.View.fromNode(D);if(!C){return }C.unbind()}Element.depthFirstTraversal(B,A)};DC.View.createViewsForNodeTree=function(E,C,D){function B(F){if(DC.View.fromNode(F)){return }var G=DC.View.viewClassForNode(F);if(!G){return }new (G)(F,C,DC.DashcodePart.PropertiesForNode(F))}var A=DC.dataModel;if(D){DC.dataModel=D}Element.depthFirstTraversal(E||document.body,B);if(D){DC.dataModel=A}};DC.View.teardownViewsForNodeTree=function(A){function B(D){var C=DC.View.fromNode(D);if(!C){return }C.teardown()}Element.depthFirstTraversal(A||document.body,B)};DC.View.cloneViewsForTreeNode=function(D,A,C){var F={};var B=Element.clone(D);function E(K){var G=K.id;if(K==D&&!G){G=D.id}if(G){F[G]=K}K.originalID=G;K.id="";var H=DC.View.fromNode(G);var I=DC.View.viewClassForNode(K);var J=null;if(!I||K.object){return true}J=new (I)(K,A,DC.DashcodePart.PropertiesForNode(K));if(H&&J){J.clonedFrom(H)}return true}Element.depthFirstTraversal(B,E);if(!B.object){B.object={}}B.object.templateElements=F;return B};DC.ImageView=Class.create(DC.View,{exposedBindings:["src","alt","width","height"],maskedBindings:["text","html"],init:function(){this.base();var A=this.viewElement();if(!this.defaultPlaceholders.src&&A.src){var B={};B.nullValue=B.noSelection=A.src;this.defaultPlaceholders.src=B}Event.observe(A,"error",this.onerror.bind(this));Event.observe(A,"load",this.onload.bind(this))},onload:function(){var A=this.viewElement();this.setValueForKey(false,"loading");Element.removeClassName(A,DC.Style.kLoadingClass)},onerror:function(){var A=this.viewElement();this.setValueForKey(false,"loading");Element.updateClass(A,DC.Style.kInvalidValueClass,DC.Style.kLoadingClass)},src:function(){var A=this.viewElement().src;return("about:blank"===A)?null:A},setSrc:function(C){if(this.bindings.src){this.bindings.src.setValue(C)}this.setValueForKey(true,"loading");var B=this.viewElement();Element.updateClass(B,DC.Style.kLoadingClass,DC.Style.kInvalidValueClass);if(!C){C="about:blank"}var A=B.src;B.src=C;if(DC.Browser.Safari&&B.src===A){this.onload()}},observeSrcChange:function(C){var B=this.viewElement();var A=this.bindings.src&&this.bindings.src.markerType;if(A){Element.addClassName(B,DC.Style.kMarkerClass)}else{Element.removeClassName(B,DC.Style.kMarkerClass)}this.setSrc(C.newValue)},observeWidthChange:function(C){var A=this.viewElement();var B=parseInt(C.newValue,10);if(isNaN(B)){A.removeAttribute("width")}else{A.width=B}},observeAltChange:function(B){var A=this.viewElement();A.alt=B.newValue||""},observeHeightChange:function(C){var B=this.viewElement();var A=parseInt(C.newValue,10);if(isNaN(A)){B.removeAttribute("height")}else{B.height=A}}});DC.ImageLayout=Class.create(DC.ImageView,{constructor:function(B,C,D){var A=B.getElementsByTagName("img")[0];if(!A){A=document.createElement("img");B.appendChild(A)}this.setContainer(B);this._mediaElement=A;this.base(B,C,D)},viewElement:function(){return this._mediaElement},superview:function(){var A=null;var B=this.viewElement;this.viewElement=function(){return this.container()};A=this.base();this.viewElement=B;return A}});DC.DashcodePart=Class.create(DC.View,{maskedBindings:["html","text"],constructor:function(A,C,D,B){if(!B&&(A.id||A.originalID)&&dashcodePartSpecs){B=dashcodePartSpecs[A.originalID?A.originalID:A.id];if(B&&!D&&!dashcode.inDesign){D=B.propertyValues}}if(A.object){return }this.base(A,C,D);this._registerForDocumentInsertionNotifcationIfNeeded();this.partSetup(B)},partSetup:function(A){},_sendLegacyOnClick:function(D,C,E){var B=this;this._savedOnClick=C.onclick;C.onclick=function(F){E(F);C.onclick=B._savedOnClick;delete B._savedOnClick};if(document.createEvent){var A=document.createEvent("MouseEvents");A.initMouseEvent("click",false,false,window,1,D?D.screenX:0,D?D.screenY:0,D?D.clientX:0,D?D.clientY:0,D?D.ctrlKey:false,D?D.altKey:false,D?D.shiftKey:false,D?D.metaKey:false,D?D.button:0,null);C.dispatchEvent(A)}else{C.onclick(D)}},_setOnClickAsAction:function(C,B){var A=this;if(!B){B=this.viewElement()}if(C){this.action=function(D,E){A._sendLegacyOnClick(E,B,C)}}else{this.action=null}},insertedIntoDocument:function(){},_registerForDocumentInsertionNotifcationIfNeeded:function(){var D=this.viewElement();var C=D;var A=D.ownerDocument;while(D.parentNode){C=D;D=D.parentNode}if(D==A){return false}var B=this;Event.observe(C,"DOMNodeInsertedIntoDocument",function(E){B.insertedIntoDocument()})},observeEnabledChange:function(A){if(this.__initialising&&(null===A.newValue||"undefined"===A.newValue)){this.bindings.enabled.setValue(!this.valueForKey("enabled"));return }this.setValueForKey(A.newValue,"enabled")}});DC.DashcodePart.PropertiesForNode=function(B){if(dashcode.inDesign){return undefined}if((B.id||B.originalID)&&dashcodePartSpecs){var A=dashcodePartSpecs[B.originalID?B.originalID:B.id];if(A){return A.propertyValues}}return undefined};DC.DashcodePart.updateViewId=function(C,B){var A=DC.View.fromNode(C);A.id=B;delete DC.View.viewLookup[C];DC.View.viewLookup[B]=A};DC.Text=Class.create(DC.DashcodePart,{exposedBindings:["text","html"],partSetup:function(A){if(A.text){var B=A.text;if(window.dashcode&&dashcode.getLocalizedString){B=dashcode.getLocalizedString(B)}this.viewElement().innerText=B}}});DC.DashcodeOverrides={Original:{View:{createViewForNode:DC.View.createViewForNode,viewClassForNode:DC.View.viewClassForNode},Binding:{bindingFromString:DC.Binding.bindingFromString}},Replacement:{View:{createViewForNode:function(B,C,A){return DC.DashcodeOverrides.Original.View.createViewForNode(B,C,A)},viewClassForNode:function(node,hasBindings){var viewClass=undefined;if(node&&(node.originalID||node.id)){var spec=dashcodePartSpecs[node.originalID?node.originalID:node.id];if(spec&&spec.view){try{viewClass=eval(spec.view)}catch(e){}}if(spec&&spec.hasBindings){if(!hasBindings){hasBindings=true}}}if(!viewClass){viewClass=DC.DashcodeOverrides.Original.View.viewClassForNode(node,hasBindings)}return viewClass}},Binding:{bindingFromString:function(B,A){if(DC.DashcodeOverrides.bindToContent&&(A instanceof DC.ObjectController)){if((B.substr(0,7)!="content")){B="content."+B}}return DC.DashcodeOverrides.Original.Binding.bindingFromString(B,A)}}}};DC.View.viewClassForNode=DC.DashcodeOverrides.Replacement.View.viewClassForNode;DC.Binding.bindingFromString=DC.DashcodeOverrides.Replacement.Binding.bindingFromString;DC.FormControl=Class.create(DC.View,{exposedBindings:["value","name"],maskedBindings:["text","html"],observeValueChange:function(D){var B=this.viewElement();var C=D.newValue;var A=this.bindings.value&&this.bindings.value.markerType;if(DC.NoSelectionMarkerType===A){B.disabled=true}else{if(!this.bindings.enabled){B.disabled=false}}if(!this.bindings.editable){B.readOnly=!this.bindings.value.mutable()}if(B.readOnly){Element.addClassName(B,DC.Style.kReadOnlyClass)}else{Element.removeClassName(B,DC.Style.kReadOnlyClass)}if(B.disabled){Element.addClassName(B,DC.Style.kDisabledClass)}else{Element.removeClassName(B,DC.Style.kDisabledClass)}B.value=C},observeNameChange:function(D,C,B){var A=this.viewElement();A.name=D.newValue},validate:function(){return this.viewElement().value}});DC.TextField=Class.create(DC.FormControl,{init:function(){this.base();var A=this.viewElement();Event.observe(A,"change",this.valueChanged.bindAsEventListener(this));Event.observe(A,"drop",this.fieldReceivedDropEvent.bindAsEventListener(this));this.editing=false;this.validationError=null},defaultPlaceholders:{value:{nullValue:_("marker.input.placeholder"),multipleValues:_("marker.input.multipleValues"),noSelection:_("marker.input.noSelection")}},keypressUpdateTimeout:500,continuallyUpdatesValue:true,sendsActionOnEndEditing:true,sendActionOn:["blur","keydown"],beginEditing:function(){this.editing=true},endEditing:function(){this.editing=false;if(this.sendsActionOnEndEditing&&this.action){this.sendAction()}},validate:function(){var A=this.viewElement();var C=A.value;if(this.formatter){var B=this.formatter.isStringValid(C);if(B!==true){this.presentError(B);return B}C=this.formatter.valueForString(C)}if(this.bindings.value){C=this.bindings.value.validateProposedValue(C);if(C instanceof DC.Error){this.presentError(C);return C}}return C},presentError:function(A){this.validationError=A;Element.addClassName(this.viewElement(),DC.Style.kInvalidValueClass);return this.base.apply(this,arguments)},clearAllErrors:function(){this.validationError=null;Element.removeClassName(this.viewElement(),DC.Style.kInvalidValueClass);return this.base.apply(this,arguments)},acceptsFirstResponder:function(){var A=this.viewElement();if(A.disabled||A.readOnly){return false}return true},becomeFirstResponder:function(){var A=this.viewElement();if(A.disabled||A.readOnly){return false}this.hidePlaceholder();this.hasFocus=true;this.beginEditing();return true},resignFirstResponder:function(B){var A=this.viewElement();this.hasFocus=false;if(""===A.value){this.showPlaceholder()}this.endEditing();return true},showPlaceholder:function(){var A=this.viewElement();if(this.bindings.value){A.value=this.bindings.value.placeholderValue()}else{if(this.placeholder){A.value=this.placeholder}else{return }}this.__showingPlaceholder=true;Element.addClassName(A,DC.Style.kMarkerClass)},hidePlaceholder:function(){if(!this.__showingPlaceholder){return }var A=this.viewElement();A.value="";this.__showingPlaceholder=false;Element.removeClassName(A,DC.Style.kMarkerClass)},valueChanged:function(A){if(this.updateTimer){window.clearTimeout(this.updateTmer);this.updateTimer=null}if(this.markerValue){return }var B=this.validate();if(!(B instanceof DC.Error)&&this.bindings.value){this.bindings.value.setValue(B);if(this.validationError){this.clearAllErrors()}}},fieldReceivedDropEvent:function(B){var A=this.viewElement();A.value=""},onkeyup:function(B){if(!this.continuallyUpdatesValue){return }var A=this.viewElement();if(this.updateTimer){window.clearTimeout(this.updateTimer)}if(A.readOnly||A.disabled){return }this.updateTimer=this.valueChanged.bindAndDelay(this,this.keypressUpdateTimeout)},onkeydown:function(A){if(this.action&&A.keyCode===Event.KEY_RETURN){this.valueChanged(null);if(this.validationError){return }this.sendAction();Event.stop(A)}},onkeypress:function(A){if(!this.formatter){return }if(!A.charCode||A.altKey||A.metaKey||A.ctrlKey){return }var B=String.fromCharCode(A.charCode||A.keyCode);if(!this.formatter.isValidInputCharacter(B)){Event.stop(A)}},observeValueChange:function(D){var B=this.viewElement();var C=D.newValue;var A=this.bindings.value&&this.bindings.value.markerType;if(!A&&this.formatter){C=this.formatter.stringForValue(C)}if(DC.NoSelectionMarkerType===A){B.disabled=true}else{if(!this.bindings.enabled){B.disabled=false}}if(!this.bindings.editable){B.readOnly=!this.bindings.value.mutable()}if(B.readOnly){Element.addClassName(B,DC.Style.kReadOnlyClass)}else{Element.removeClassName(B,DC.Style.kReadOnlyClass)}if(B.disabled){Element.addClassName(B,DC.Style.kDisabledClass)}else{Element.removeClassName(B,DC.Style.kDisabledClass)}if(!this.bindings.errorMessage){this.clearAllErrors()}if(this.hasFocus){return }if(A){this.placeholder=C;B.value="";this.showPlaceholder()}else{this.hidePlaceholder();B.value=C}},observeErrorMessageChange:function(C){var B=C.newValue;if(!B){this.clearAllErrors();return }var A=new DC.Error({description:C.newValue});this.presentError(A)}});DC.ListView=Class.create(DC.DashcodePart,{exposedBindings:["content","selectionIndexes","selectedIndex","selectedObject"],allowsEmpty:true,_items:null,_activeItem:-1,maximumCachedRows:30,init:function(){this.base();var B=this.viewElement();var A;switch(B.tagName){case"SELECT":this._isSelectElement=true;this._items=PartList("option");this.templateElement=document.createElement("option");Event.observe(B,"change",this.selectedIndexChanged.bindAsEventListener(this));break;case"TABLE":A=this.setContainer(B.tBodies[0]);this._items=PartList("> tbody tr");this.templateElement=Element.clone(this._items(0));break;default:A=this.container();var C=B.firstChild;while(C){if(1===C.nodeType){break}C=C.nextSibling}if(!C){return }this._items=PartList(C.nodeName);this.templateElement=C;DC.View.createViewsForNodeTree(C,null,this.__context);C.parentNode.removeChild(C);this._items().forEach(this.removeChild,this);this._items.removeAll();break}if("true"===(B.getAttribute("multiple")||"").toLowerCase()){this.multiple=true}if(this.template&&"function"!==typeof (this.template)){delete this.template}if(this.template&&!(this.template.valueOf()).__factoryFn__){this.template=this.template()}},initFromDOM:function(){var A=this.container();A.innerHTML="";if(this._items&&this._items.removeAll){this._items.removeAll()}},clonedFrom:function(A){if(A.templateElement){this.templateElement=A.templateElement;this._items=PartList(this.templateElement.nodeName);this._items().forEach(this.removeChild,this);this._items.removeAll()}},computeSelectionIndexes:function(){var B=[];var A=this._items();function C(E,D){if(E.selected){B.push(D)}}A.forEach(C);return B},acceptsFirstResponder:function(){var A=this.viewElement();if(A.disabled||A.readOnly){return false}return true},highlightSelection:function(B,A){return },highlightSelectionIndexes:function(E){var K=this.viewElement();var J=this._items();var G=J.length;var F;var C=!!this._isSelectElement;var D;var B=DC.Style.kSelectedClass;var I;var M;if(this.animated){var N={curve:DC.easing.inOutSine,duration:300};I=function(P,O){DC.Animator.addClassName(P,O,N)};M=function(P,O){DC.Animator.removeClassName(P,O,N)}}else{I=Element.addClassName;M=Element.removeClassName}if(!C){var H=this.__selectionIndexes?this.__selectionIndexes.length:0;for(F=0;F<H;F++){var A=this.__selectionIndexes[F];if(E.containsObject(A)){continue}if(A<J.length){J[A].selected=false;M(J[A],B);this.highlightSelection(J[A],false)}}for(F=0;F<E.length;F++){var L=E[F];J[L].selected=true;I(J[L],B);this.highlightSelection(J[L],true)}}if(1===E.length){this.selectedIndex=K.selectedIndex=E[0]}this.__selectionIndexes=E},selectionIndexes:function(){return this.__selectionIndexes},setSelectionIndexes:function(E){var A;var B=this.viewElement();var F=this.bindings;E=(E||[]).concat();if(String(E)===String(this.__selectionIndexes)){E=this.__selectionIndexes}if(1===E.length){A=this.selectedIndex=B.selectedIndex=E[0]}else{if(E.length){A=B.selectedIndex=E[0]}else{A=B.selectedIndex=-1}}if(F.selectionIndexes){F.selectionIndexes.setValue(E)}if(F.selectedIndex){F.selectedIndex.setValue(A)}if(F.selectedObject&&F.content){var C=null;if(-1!==A){C=(this.__content||[])[A]}F.selectedObject.setValue(C)}if(F.selectedValue){var D=null;if(-1!==A){D=B.options[A].value}F.selectedValue.setValue(D)}this.highlightSelectionIndexes(E)},selectedObjects:function(){var A=this.__content||[];return A.objectsAtIndexes(this.selectionIndexes()||[])},onkeydown:function(B){var J=this.viewElement();if(J.disabled){return }if(Event.KEY_UP!=B.keyCode&&Event.KEY_DOWN!=B.keyCode){return }Event.stop(B);var I=this.selectionIndexes().sort(function(P,O){return P-O});var E=(this.__content||[]).length-1;var L;if(this.multiple&&B.shiftKey&&I.length){var H=(this.selectedIndex==I[0]);var G=I[0];var K=I[I.length-1];if(1==I.length){if(Event.KEY_UP==B.keyCode){L=G-1}else{L=G+1}if(L<0||L>E){return }I.push(L)}else{if(H){if(Event.KEY_UP==B.keyCode){I.length--}else{if(K<E){I.push(L=K+1)}}}else{if(Event.KEY_DOWN==B.keyCode){I.splice(0,1)}else{if(G>0){I.push(L=G-1)}}}}}else{if(!I.length){if(Event.KEY_UP==B.keyCode){this.selectedIndex=E}else{if(Event.KEY_DOWN==B.keyCode){this.selectedIndex=0}}I=[L=this.selectedIndex]}else{if(Event.KEY_UP==B.keyCode&&this.selectedIndex>0){this.selectedIndex--}else{if(Event.KEY_DOWN==B.keyCode&&this.selectedIndex<E){this.selectedIndex++}}I=[L=this.selectedIndex]}}if(!isNaN(L)){var N=this._items(L);var M=Element.scrollParent(J);var F=M.offsetHeight;var C=N.offsetTop-M.scrollTop;var D=N.offsetHeight;var A=this.container();if(N.offsetParent!==A){C-=A.offsetTop}if(C<0){N.scrollIntoView(true)}else{if(C+D>F){N.scrollIntoView(false)}}}this.setSelectionIndexes(I);return },selectedIndexChanged:function(C){if(!this.bindings.selectionIndexes&&!this.bindings.selectedIndex&&!this.bindings.selectedObject&&!this.bindings.selectedValue){return }var A=this.viewElement();var B;if(this.multiple){B=this.computeSelectionIndexes()}else{B=[this.selectedIndex=A.selectedIndex]}this.setSelectionIndexes(B)},_clearSelection:function(){var A=this.viewElement();var E=("SELECT"!==A.tagName);var F=Element.removeClassName;var C=DC.Style.kSelectedClass;function D(G){G.selected=false;if(E){F(G,C)}}var B=this._items();B.forEach(D);A.selectedIndex=-1},observeSelectedIndexChange:function(D){var C=D.newValue;var B=(-1!==C&&null!==C&&"undefined"!==typeof (C));var A=B?[C]:[];this.setSelectionIndexes(A)},observeSelectedObjectChange:function(E){var D=E.newValue;var C=this.__content||[];var A=C.indexOf(D);var B=(-1===A?[]:[A]);this.setSelectionIndexes(B)},observeSelectionIndexesChange:function(B){var A=B.newValue||[];this.setSelectionIndexes(A)},_updateDomWithContent:function(I){var K=DC.View.rebindNodeTreeWithRelativeSource;var O=DC.View.unbindNodeTree;var P=this.selectedObjects();var G=[];var C=I.length;var J=this._items();var L=J.length;var D=Math.min(L,C);var F=0;var E;var H;var A;var M;while(F<D){E=I[F];if(-1!==P.indexOf(E)){G.push(F)}H=J[F];A=H.objectValue;H.objectValue=E;if("undefined"===typeof (A)){this.setupElement(H,H.objectValue)}else{K(H,A,E)}M=DC.View.fromNode(H);if(!M||!M.bindings.visible){H.style.display=""}this.elementUsedForIndex(H,F);++F}if(F<C){var B=this.container();var N=document.createDocumentFragment();while(F<C){E=I[F];if(-1!==P.indexOf(E)){G.push(F)}H=this.createElement(E,null,N,F);this._items.add(H);++F}B.appendChild(N)}else{while(F<L){H=J[F];if(F>this.maximumCachedRows){this.removeChild(J[F])}else{O(H);H.objectValue=null;H.style.display="none";this.elementUsedForIndex(H,-1)}++F}if(L>this.maximumCachedRows){this._items.refresh()}}this.highlightSelectionIndexes(G)},observeContentChange:function(L){var A=this.container();var N=this.viewElement();var Q=this;var H;var M;var I;var K=this._items();var G;var F=[];var O=DC.View.rebindNodeTreeWithRelativeSource;var P=DC.View.unbindNodeTree;var D=K[0];var J=this.__content?this.__content.length-1:0;function C(U,T,S){var R=U.objectValue;U.objectValue=T;O(U,R,T);U.style.display="";Q.elementUsedForIndex(U,S)}switch(L.changeType){case DC.ChangeType.setting:this.__content=L.newValue||[];this._updateDomWithContent(this.__content);break;case DC.ChangeType.insertion:J-=L.indexes.length;for(H=0;H<L.indexes.length;++H){M=this._items(L.indexes[H]);if(M&&"none"===M.style.display){I=M;C(M,L.newValue[H],L.indexes[H])}else{I=this.createElement(L.newValue[H],M,null,L.indexes[H]);this._items.insertPartAtIndex(I,L.indexes[H])}if(this.animated){Element.addClassName(I,DC.Style.kInsertedClass);DC.Animator.removeClassName(I,DC.Style.kInsertedClass,{discreteTransitionPoint:1,duration:this.updateAnimationDuration})}}break;case DC.ChangeType.replacement:function E(R){C(R,R.newObjectValue);R.newObjectValue=null;DC.Animator.removeClassName(R,DC.Style.kReplacingClass,{duration:250,discreteTransitionPoint:1})}for(H=0;H<L.indexes.length;++H){I=this._items(L.indexes[H]);if(!this.animated){C(I,L.newValue[H],L.indexes[H])}else{I.newObjectValue=L.newValue[H];DC.Animator.addClassName(I,DC.Style.kReplacingClass,{duration:this.updateAnimationDuration,discreteTransitionPoint:0,callback:E.bind(this)})}}break;case DC.ChangeType.deletion:J+=L.indexes.length;F=this.selectionIndexes();for(H=L.indexes.length-1;H>=0;--H){var B=L.indexes[H];F.removeObject(B);I=this._items(B);this._items.removePartAtIndex(B);if(!this.animated){this.removeChild(I)}else{DC.Animator.addClassName(I,DC.Style.kDeletedClass,{duration:this.updateAnimationDuration,discreteTransitionPoint:0,callback:this.removeChild.bind(this)})}}this.setSelectionIndexes(F);break;default:console.log("Unknown change type: "+L.changeType);break}if(this.__content&&this.__content.length){if(K[0]!=D){Element.addClassName(K[0],DC.Style.kFirstClass);Element.removeClassName(D,DC.Style.kFirstClass)}if(J!=(this.__content.length-1)){Element.addClassName(K[this.__content.length-1],DC.Style.kLastClass);if(J<K.length){Element.removeClassName(K[J],DC.Style.kLastClass)}}}else{if(K.length){Element.removeClassName(D,DC.Style.kFirstClass);if(J<K.length){Element.removeClassName(D,DC.Style.kLastClass)}}}if(this.bindings.displayValues){this.bindings.displayValues.update()}if(this.bindings.contentValues){this.bindings.contentValues.update()}},setupElement:function(D,C){D.objectValue=C;if(this.template){var A=DC.dataModel;var B;DC.dataModel=this.__context;this.template.call(this,D,C);DC.dataModel=A}else{DC.View.createViewsForNodeTree(D,C,this.__context)}return D},createElement:function(B,H,C,F){if(!this.templateElement){console.log("No template row");return }var I=this.viewElement();var G=null;var E=null;C=C||this.container();if(this.template){E=Element.clone(this.templateElement);if(H){G=C.insertBefore(E,H)}else{G=C.appendChild(E)}G=this.setupElement(G,B)}else{E=DC.View.cloneViewsForTreeNode(this.templateElement,B,this.__context);if(!H){var A=C.children;var D=null;if(A&&A.length){D=A[A.length-1]}if(D){H=D.nextSibling}}if(H){G=C.insertBefore(E,H)}else{G=C.appendChild(E)}G.objectValue=B}this.elementUsedForIndex(G,F);return G},elementUsedForIndex:function(B,A){return },ontouchstart:function(B){var C=B.target||B.srcElement;var A=this.container();while(C&&C.parentNode!=A){C=C.parentNode}if(C!=A){this._touchedRow=C}else{this._touchedRow=null}},onmousedown:function(D){var B=this.viewElement();if(B.disabled){return }if("SELECT"===B.tagName){this.base(D);return }var E=null;if(DC.Support.Touches&&this._touchedRow){E=this._touchedRow}else{E=D.target||D.srcElement}var A=this.container();var C=this._items();if(E==A){return }while(E&&E.parentNode!=A){E=E.parentNode}if(E==A){return }this._activeItem=C.indexOf(E);Element.addClassName(E,DC.Style.kActiveClass)},onmouseup:function(B){var A=this.viewElement();if(A.disabled){return }if(-1!==this._activeItem){Element.removeClassName(this._items(this._activeItem),DC.Style.kActiveClass)}this._activeItem=-1},ontouchmove:function(B){var A=this.viewElement();if(A.disabled){return }if(-1!==this._activeItem){Element.removeClassName(this._items(this._activeItem),DC.Style.kActiveClass)}this._activeItem=-1;this.base(B)},onclick:function(A){var I=this.viewElement();if(I.disabled){this.base(A);Event.stop(A);return }if("SELECT"===I.tagName){this.base(A);return }var G=A.target||A.srcElement;var D=-1;var C=null;var B=this.container();var H=this._items();if(G==B){return }while(G&&G.parentNode!=B){G=G.parentNode}if(G){D=H.indexOf(G);C=G.objectValue}var F;if(!this.multiple){if((A.ctrlKey||A.metaKey)&&this.allowsEmpty){F=this.selectionIndexes();if(-1!=F.indexOf(D)){D=-1}}if(D!=-1){F=[D]}else{F=[]}this.setSelectionIndexes(F)}else{F=this.selectionIndexes().slice();if(A.shiftKey){var J=[];if(this.selectedIndex>D){J=IndexRange(D,this.selectedIndex)}else{J=IndexRange(this.selectedIndex,D)}this.setSelectionIndexes(J)}else{if(A.ctrlKey||A.metaKey){var E=F.indexOf(D);if(-1===E){this.selectedIndex=D;F.push(D)}else{if(this.allowsEmpty||(F.length>1)){F.splice(E,1)}}this.setSelectionIndexes(F)}else{this.selectedIndex=D;this.setSelectionIndexes([D])}}}if(G&&"A"==G.tagName){G.blur()}this.sendAction()}});DC.SelectField=Class.create(DC.ListView,{exposedBindings:["displayValues","contentValues","selectedValue","name"],observeContentValuesChange:function(G){var B=this.viewElement();var E;var D;var F=B.options;var A=F.length;switch(G.changeType){case DC.ChangeType.setting:if(!G.newValue){break}for(E=0;E<A;++E){F[E].value=G.newValue[E]}break;case DC.ChangeType.insertion:case DC.ChangeType.replacement:var C;for(C=0;C<G.indexes.length;++C){E=G.indexes[C];D=F[E];D.value=G.newValue[C]}break;default:console.log("Unknown change type: "+G.changeType);break}},observeDisplayValuesChange:function(G){var B=this.viewElement();var E;var D;var F=B.options;var A=F.length;switch(G.changeType){case DC.ChangeType.setting:if(!G.newValue){break}for(E=0;E<A;++E){if(DC.Browser.IE){F[E].innerText=G.newValue[E]}else{F[E].text=G.newValue[E]}}break;case DC.ChangeType.insertion:case DC.ChangeType.replacement:var C;for(C=0;C<G.indexes.length;++C){E=G.indexes[C];D=F[E];D.text=G.newValue[C]}break;default:console.log("Unknown change type: "+G.changeType);break}},observeSelectedValueChange:function(F,H,B){if(this.bindings.content&&!this.bindings.content.value()){return }var G=this.viewElement();var I=G.options;var E=I.length;var A=F.newValue;G.disabled="undefined"===typeof (A)||DC.Markers.MultipleValues===A||DC.Markers.NoSelection===A;var D=[];for(var C=0;C<E;++C){if(I[C].value==A){D=[C];break}}this.setSelectionIndexes(D)},observeNameChange:function(D,C,B){var A=this.viewElement();A.name=D.newValue}});DC.ToggleButton=Class.create(DC.FormControl,{exposedBindings:["checked","selection"],onclick:function(C){var A=this.viewElement();var B=A.checked;if(this.bindings.selection){this.bindings.selection.setValue(A.value)}if(this.bindings.checked){this.bindings.checked.setValue(B)}this.sendAction()},observeValueChange:function(C){this.base(C);var A=this.viewElement();var B=C.newValue;A.value=B;if(!this.bindings.selection){return }A.checked=(this.bindings.selection.value()==B);if(this.bindings.checked){this.bindings.checked.setValue(A.checked)}},observeCheckedChange:function(E,D,B){var A=this.viewElement();var C=!!E.newValue;A.checked=C;if(this.bindings.selection){this.bindings.selection.setValue(A.value)}},observeSelectionChange:function(E,D,B){var A=this.viewElement();var C=(E.newValue===A.value);A.checked=C;if(this.bindings.checked){this.bindings.checked.setValue(C)}}});DC.SearchField=Class.create(DC.TextField,{exposedBindings:["predicate"],init:function(){this.base();var A=this.viewElement();if("search"===A.type){Event.observe(A,"search",this.valueChanged.bindAsEventListener(this))}},keypressUpdateTimeout:25,valueChanged:function(A){this.base(A);if(this.bindings.predicate){this.bindings.predicate.setValue(this.createFilterPredicate())}},createFilterPredicate:function(){var A=this.viewElement();var D=this.predicate;var C=A.value.toLowerCase();function B(F){var E=F.valueForKeyPath(D);if(!E){return !!C}if(E.toLocaleString){E=E.toLocaleString()}else{E=E.toString()}E=E.toLowerCase();return(-1!==E.indexOf(C))}return B},observePredicateChange:function(A){}});DC.EventLoop={currentEvent:null,getStart:function(){if(!this._start){this._start=new Date().getTime()}return this._start},begin:function(A){this._start=new Date().getTime();this.currentEvent=A},end:function(){this.currentEvent=null;this._start=null}};DC.Page=Class.create(DC.Responder,{focusedElement:null,constructor:function(){this.firstResponder=null;this.__hoverTrackingIds={};this._onmousedragHandler=this._onmousedrag.bindAsEventListener(this);this._delegates={click:[]};this.onclick=this._fireDelegates},targetViewForEvent:function(C){var B=C.target||C.srcElement;var A;var D=DC.View.fromNode;while(B&&B!=document&&!(A=D(B))){B=B.parentNode}if(!B||B==document){return null}return A},makeFirstResponder:function(A){if(this.firstResponder==A){return true}if(this.firstResponder&&!this.firstResponder.resignFirstResponder()){return false}if(this.firstResponder){Element.removeClassName(this.firstResponder.viewElement(),DC.Style.kFocusClass)}if(A&&!A.becomeFirstResponder()){return false}this.willChangeValueForKey("firstResponder");this.firstResponder=A;this.didChangeValueForKey("firstResponder");if(A){A.focus();Element.addClassName(A.viewElement(),DC.Style.kFocusClass)}return true},addTrackingInfo:function(C,B){if("string"!==typeof (C)){C=Element.assignId(C)}var A=this.__hoverTrackingIds[C];if(!A){A=this.__hoverTrackingIds[C]=[]}A.push(B)},superview:function(){return null},presentError:function(A){function B(){var C=A.description;if(A.recoverySuggestion){C+="\n"+A.recoverySuggestion}window.alert(C);DC.page.makeFirstResponder(A.field)}B.delay(0)},delegate:function(A,C,B){if("string"===typeof (C)){this._delegates[C].push({sel:A,fn:B})}else{var D;for(D in C){if(!(D in this._delegates)){throw new Error("Invalid delegation event type: "+D)}this._delegates[D].push({sel:A,fn:C[D]})}}},superview:function(){return null},_fireDelegates:function(E){var C=E.target||E.srcElement;var B=Element.match;var A=this._delegates[E.type]||[];function D(F){if(B(C,F.sel)){F.fn(E)}}A.forEach(D)},_findFirstResponder:function(A){while(A&&!A.acceptsFirstResponder()){A=A.superview()}if(!A){return }this.makeFirstResponder(A)},_onmousedown:function(B){var A=this.targetViewForEvent(B);if(A){this._findFirstResponder(A);A.onmousedown(B);Event.observe(document,"mousemove",this._onmousedragHandler)}this._mousedownView=A},_onmouseup:function(A){if(this._mousedownView){this._mousedownView.onmouseup(A)}Event.stopObserving(document,"mousemove",this._onmousedragHandler)},_onmousedrag:function(A){if(this._mousedownView){this._mousedownView.onmousedrag(A)}},_onmouseover:function(A){var E=this.__hoverTrackingIds||{};var L=this.__mouseOverIds||{};var C={};var H=A.target||A.srcElement;var F=document.body;var I;var K;var B;var D;var G;var J;for(;H&&H!=F;H=H.parentNode){B=H.id;if(!B||!(B in E)){continue}C[B]=true;if(B in L){continue}I=E[B];G=I.length;for(D=0;D<G;++D){J=I[D];if(J.onmouseenter){J.onmouseenter.call(J.owner,H,J.ownerInfo)}}}for(B in L){if(B in C){continue}H=document.getElementById(B);if(!H){continue}I=E[B];G=I.length;for(D=0;D<G;++D){J=I[D];if(J.onmouseleave){J.onmouseleave.call(J.owner,H,J.ownerInfo)}}}this.__mouseOverIds=C},_onmouseout:function(A){},_onclick:function(B){if(DC.Browser.Mozilla&&B.button===2){return }var A=this.targetViewForEvent(B);if(A){A.onclick(B)}else{this._fireDelegates(B)}},_ondblclick:function(A){if(this._mousedownView){this._mousedownView.ondblclick(A)}},_onkeydown:function(A){var B=this.firstResponder;if(B){B.onkeydown(A)}},_onkeyup:function(A){var B=this.firstResponder;if(B){B.onkeyup(A)}},_onkeypress:function(A){var B=this.firstResponder;if(B){B.onkeypress(A)}},_onfocus:function(B){var C=(B.target||B.srcElement)==window;if(DC.Browser.IE){if(document.activeElement==this.focusedElement){C=true}}if(C){if(!this._documentFocused){this.makeFirstResponder(this._previousFirstResponder||null);this._previousFirstResponder=null;this._documentFocused=true;if(!dashcode.inDesign&&document.body){Element.removeClassName(document.body,"DC_windowInactive")}}}else{var A=this.targetViewForEvent(B);if(A&&A.acceptsFirstResponder()){this.makeFirstResponder(A)}else{this.makeFirstResponder(null)}this.focusedElement=B.target||B.srcElement}},_onblur:function(B){var C=(B.target||B.srcElement)==window;if(DC.Browser.IE){if(document.activeElement==this.focusedElement){C=true}}if(C){this._documentFocused=false;this._previousFirstResponder=this.firstResponder;this.makeFirstResponder(null);if(!dashcode.inDesign&&document.body){Element.addClassName(document.body,"DC_windowInactive")}}else{var A=this.targetViewForEvent(B);this.focusedElement=null;if(A&&A.acceptsFirstResponder()){this.makeFirstResponder(null)}}},_ontouchstart:function(C){var A=this.targetViewForEvent(C);if(A){var B=this;A.ontouchstart(C);this._touchstartMouseDownDelay=window.setTimeout(function(){A.onmousedown(C);B._touchsentMD=true;delete B._touchstartMouseDownDelay},100)}this._touchstartView=A;this._touchmovedX=false;this._touchmovedY=false;this._touchsentMD=false;this._touchstartX=C.targetTouches[0].clientX;this._touchstartY=C.targetTouches[0].clientY},_ontouchmove:function(D){var A=D.targetTouches[0].clientX;var E=D.targetTouches[0].clientY;var B=false;var C=false;if(!this._touchmovedX&&Math.abs(this._touchstartX-A)>5){B=this._touchmovedX=true}if(!this._touchmovedY&&Math.abs(this._touchstartY-E)>5){C=this._touchmovedY=true}if(this._touchstartView){this._touchstartView.ontouchmove(D);if(this._touchstartMouseDownDelay){window.clearTimeout(this._touchstartMouseDownDelay);delete this._touchstartMouseDownDelay}if(B||C){if(this._touchsentMD){this._touchstartView.onmouseup(D);this._touchsentMD=false}if(!this._touchmovedY&&B){this._touchstartView.onswipe(D)}}}},_ontouchend:function(A){if(this._touchstartView){this._touchstartView.ontouchend(A);if(this._touchstartMouseDownDelay){var B=this._touchstartView;window.clearTimeout(this._touchstartMouseDownDelay);delete this._touchstartMouseDownDelay;this._touchstartView.onmousedown(A);this._touchsentMD=true;setTimeout(function(){B.onmouseup(A);B.onclick(A)},0)}else{if(this._touchsentMD){this._touchstartView.onmouseup(A);if(!this._touchmovedX&&!this._touchmovedY){this._touchstartView.onclick(A)}}}}},_ontouchcancel:function(A){if(this._touchstartView){this._touchstartView.ontouchend(A);if(this._touchstartMouseDownDelay){window.clearTimeout(this._touchstartMouseDownDelay);delete this._touchstartMouseDownDelay}else{if(this._touchsentMD){this._touchstartView.onmouseup(A)}}}},_onunload:function(){var B;var A=DC.View.viewLookup;for(B in A){A[B].teardown();delete A[B]}}});(function(){DC.page=new DC.Page();window._setTimeout=window.setTimeout;window.setTimeout=function(F,E){if(!F){return null}if("string"===typeof (F)){F="DC.EventLoop.begin();do {"+F+"} while (false); DC.EventLoop.end();";return window._setTimeout(F,E)}var D=Array.from(arguments,2);function C(){DC.EventLoop.begin();var G=F.apply(this,D);DC.EventLoop.end();return G}return window._setTimeout(C,E)};window._setInterval=window.setInterval;window.setInterval=function(F,E){if(!F){return null}if("string"===typeof (F)){F="DC.EventLoop.begin();do {"+F+"} while (false); DC.EventLoop.end();";return window._setInterval(F,E)}var D=Array.from(arguments,2);function C(){DC.EventLoop.begin();var G=F.apply(this,D);DC.EventLoop.end();return G}return window._setInterval(C,E)};var B=DC.page;var A;if(DC.Browser.IE){A=function(C){return function(){DC.EventLoop.begin(window.event);B[C](window.event);DC.EventLoop.end()}};document.attachEvent("onmouseover",A("_onmouseover"));document.attachEvent("onmouseout",A("_onmouseout"));document.attachEvent("onmousedown",A("_onmousedown"));document.attachEvent("onmouseup",A("_onmouseup"));document.attachEvent("onclick",A("_onclick"));document.attachEvent("ondblclick",A("_ondblclick"));document.attachEvent("onkeydown",A("_onkeydown"));document.attachEvent("onkeyup",A("_onkeyup"));document.attachEvent("onkeypress",A("_onkeypress"));document.attachEvent("onfocusin",A("_onfocus"));document.attachEvent("onfocusout",A("_onblur"));window.attachEvent("focus",A("_onfocus"));window.attachEvent("blur",A("_onblur"));window.attachEvent("onunload",A("_onunload"))}else{A=function(C){return function(D){DC.EventLoop.begin(D);B[C](D);DC.EventLoop.end()}};document.addEventListener("keydown",A("_onkeydown"),false);document.addEventListener("keyup",A("_onkeyup"),false);document.addEventListener("keypress",A("_onkeypress"),false);document.addEventListener("focus",A("_onfocus"),true);document.addEventListener("blur",A("_onblur"),true);window.addEventListener("focus",A("_onfocus"),false);window.addEventListener("blur",A("_onblur"),false);if(!DC.Browser.MobileSafari){document.addEventListener("click",A("_onclick"),false);document.addEventListener("dblclick",A("_ondblclick"),false)}if(DC.Support.Touches){document.addEventListener("touchstart",A("_ontouchstart"),true);document.addEventListener("touchmove",A("_ontouchmove"),true);document.addEventListener("touchend",A("_ontouchend"),true);document.addEventListener("touchcancel",A("_ontouchcancel"),true)}else{document.addEventListener("mouseover",A("_onmouseover"),false);document.addEventListener("mouseout",A("_onmouseout"),false);document.addEventListener("mousedown",A("_onmousedown"),false);document.addEventListener("mouseup",A("_onmouseup"),false)}}})();/* 
 This file was generated by Dashcode and is covered by the 
 license.txt included in the project.  You may edit this file, 
 however it is recommended to first turn off the Dashcode 
 code generator otherwise the changes will be lost.
 */
var dashcodePartSpecs = {
    "back": { "initialHeight": 30, "initialWidth": 76, "leftImageWidth": 16, "onclick": "backSection", "rightImageWidth": 5, "text": "Back", "view": "DC.PushButton" },
    "beginDate": { "text": "Item", "view": "DC.Text" },
    "beginDateDisplay": { "text": "Text", "view": "DC.Text" },
    "button": { "initialHeight": 30, "initialWidth": 60, "leftImageWidth": 5, "onclick": "goSplashScreen", "rightImageWidth": 16, "text": "About", "view": "DC.PushButton" },
    "button1": { "initialHeight": 30, "initialWidth": 92, "leftImageWidth": 5, "onclick": "goLookfors", "rightImageWidth": 16, "text": "Continue", "view": "DC.PushButton" },
    "button3": { "initialHeight": 30, "initialWidth": 75, "leftImageWidth": 16, "onclick": "goTeacherList", "rightImageWidth": 5, "text": "Teachers", "view": "DC.PushButton" },
    "button4": { "customImage": "Images/show_details.png", "customImagePosition": "DC.PushButton.IMAGE_POSITION_CENTER", "customImagePressed": "Images/show_details_pressed.png", "initialHeight": 30, "initialWidth": 80, "noBackground": true, "onclick": "selectForm", "text": "Button", "view": "DC.PushButton" },
    "button5": { "customImagePosition": "PushButton.IMAGE_POSITION_NONE", "initialHeight": 30, "leftImageWidth": 16, "onclick": "goTeacherList", "rightImageWidth": 5, "text": "Teachers", "view": "DC.PushButton" },
    "button6": { "customImagePosition": "DC.PushButton.IMAGE_POSITION_NONE", "initialHeight": 30, "initialWidth": 91, "leftImageWidth": 16, "onclick": "returnFromTeacherInfo", "rightImageWidth": 5, "text": "Observation", "view": "DC.PushButton" },
    "button7": { "initialHeight": 30, "initialWidth": 92, "leftImageWidth": 16, "onclick": "doneEditDate", "rightImageWidth": 5, "text": "Teacher Info", "view": "DC.PushButton" },
    "chooseformLabel": { "text": "Choose an Observation Form:", "view": "DC.Text" },
    "clearObservation": { "initialHeight": 30, "leftImageWidth": 1, "onclick": "clearObservation", "rightImageWidth": 1, "text": "Clear", "view": "DC.PushButton" },
    "clearSettings": { "initialHeight": 30, "initialWidth": 109, "leftImageWidth": 5, "onclick": "clearSettings", "rightImageWidth": 5, "text": "Clear", "view": "DC.PushButton" },
    "currentTemplateName": { "text": "Unset", "view": "DC.Text" },
    "currentTemplateName2": { "text": "Unset", "view": "DC.Text" },
    "descriptionText": { "text": "Text", "view": "DC.Text" },
    "done_Button1": { "initialHeight": 30, "initialWidth": 64, "leftImageWidth": 5, "onclick": "doneEditDate", "rightImageWidth": 5, "text": "Done", "view": "DC.PushButton" },
    "doneButton": { "initialHeight": 30, "initialWidth": 64, "leftImageWidth": 5, "onclick": "nextSection", "rightImageWidth": 5, "text": "Done", "view": "DC.PushButton" },
    "doneButton1": { "initialHeight": 30, "initialWidth": 64, "leftImageWidth": 5, "onclick": "endObservation", "rightImageWidth": 5, "text": "Done", "view": "DC.PushButton" },
    "doneButton2": { "initialHeight": 30, "initialWidth": 64, "leftImageWidth": 5, "onclick": "doneSelectForm", "rightImageWidth": 5, "text": "Done", "view": "DC.PushButton" },
    "editObservation": { "customImagePosition": "PushButton.IMAGE_POSITION_NONE", "initialHeight": 30, "initialWidth": 64, "leftImageWidth": 5, "onclick": "toggleEdit", "rightImageWidth": 5, "text": "Edit", "view": "DC.PushButton" },
    "footer": { "text": "Copyright 2010, LoTi, Inc.", "view": "DC.Text" },
    "formsList": { "allowsEmptySelection": true, "dataArray": ["Item 1"], "dataSourceName": "formsListDataSource", "labelElementId": "label1", "listStyle": "List.ROUNDED_RECTANGLE", "sampleRows": 1, "selectionEnabled": true, "useDataSource": true, "view": "DC.List" },
    "image": { "view": "DC.ImageLayout" },
    "image1": { "view": "DC.ImageLayout" },
    "initialSetupButton": { "initialHeight": 30, "initialWidth": 60, "leftImageWidth": 5, "onclick": "goSettings", "rightImageWidth": 5, "text": "Login", "view": "DC.PushButton" },
    "label": { "text": "Item", "view": "DC.Text" },
    "label1": { "text": "Item", "view": "DC.Text" },
    "label2": { "text": "Item", "view": "DC.Text" },
    "list": { "allowsEmptySelection": true, "dataArray": ["Item 1", "Item 2", "Item 3"], "dataSourceName": "teacherListData", "labelElementId": "label", "listStyle": "List.ROUNDED_RECTANGLE", "sampleRows": 3, "selectionEnabled": true, "useDataSource": true, "view": "DC.List" },
    "lookforLabel": { "text": "Item", "view": "DC.Text" },
    "lookforList": { "allowsEmptySelection": true, "dataArray": ["Item 1", "Item 2", "Item 3"], "labelElementId": "lookforLabel", "listStyle": "List.EDGE_TO_EDGE", "sampleRows": 3, "selectionEnabled": true, "view": "DC.List" },
    "message": { "text": "Enter your LoTi Username and Password", "view": "DC.Text" },
    "next": { "initialHeight": 30, "initialWidth": 76, "leftImageWidth": 5, "onclick": "nextSection", "rightImageWidth": 16, "text": "Next", "view": "DC.PushButton" },
    "numberOfObservations": { "text": "2", "view": "DC.Text" },
    "numberOfTeachers": { "text": "No Teachers listed - Login to download your teacher list", "view": "DC.Text" },
    "numberToUpload": { "text": "0 Observations ready to upload", "view": "DC.Text" },
    "observationType": { "text": "H.E.A.T.", "view": "DC.Text" },
    "observatonButton": { "customImagePosition": "DC.PushButton.IMAGE_POSITION_NONE", "initialHeight": 30, "initialWidth": 30, "leftImageWidth": 16, "onclick": "returnObservationMain", "rightImageWidth": 5, "text": "<", "view": "DC.PushButton" },
    "pageTitle1": { "text": "Teachers", "view": "DC.Text" },
    "pageTitle2": { "text": "Observation", "view": "DC.Text" },
    "pageTitle3": { "text": "Teacher Information", "view": "DC.Text" },
    "pageTitle4": { "text": "Edit Date", "view": "DC.Text" },
    "pageTitle6": { "text": "Login", "view": "DC.Text" },
    "programming": { "text": "Programming:  Mark Fisher", "view": "DC.Text" },
    "pswd": { "view": "DC.TextField" },
    "searchfield": { "propertyValues": { "predicate": "Search:" }, "view": "DC.SearchField" },
    "sectionList": { "allowsEmptySelection": true, "dataArray": ["Item 1", "Item 2", "Item 3"], "dataSourceName": "sectionDataSource", "listStyle": "List.ROUNDED_RECTANGLE", "sampleRows": 2, "selectionEnabled": true, "useDataSource": true, "view": "DC.List" },
    "sectionTitle": { "text": "Setting...", "view": "DC.Text" },
    "settingsStackLayout": { "subviewsTransitions": [{ "direction": "right-left", "duration": "", "timing": "ease-in-out", "type": "push" }, { "direction": "right-left", "duration": "", "timing": "ease-in-out", "type": "push" }], "view": "DC.StackLayout" },
    "stackLayout": { "subviewsTransitions": [{ "direction": "right-left", "duration": "", "timing": "ease-in-out", "type": "push" }, { "direction": "right-left", "duration": "", "timing": "ease-in-out", "type": "push" }, { "direction": "right-left", "duration": "", "timing": "ease-in-out", "type": "push" }, { "direction": "right-left", "duration": "", "timing": "ease-in-out", "type": "push" }, { "direction": "right-left", "duration": "", "timing": "ease-in-out", "type": "push" }, { "direction": "right-left", "duration": "", "timing": "ease-in-out", "type": "push" }, { "direction": "right-left", "duration": "", "timing": "ease-in-out", "type": "push" }], "view": "DC.StackLayout" },
    "syncButton": { "initialHeight": 30, "initialWidth": 102, "leftImageWidth": 5, "onclick": "clickConnect", "rightImageWidth": 5, "text": "Login", "view": "DC.PushButton" },
    "sysDesign": { "text": "System Design:  Mark Fisher, Chris Moersch, Dennee Saunders, Fred Saunders", "view": "DC.Text" },
    "teacherName": { "text": "Item", "view": "DC.Text" },
    "text": { "text": "Select a teacher to begin an Observation", "view": "DC.Text" },
    "text16": { "text": "Observation Form", "view": "DC.Text" },
    "text2": { "text": "Username:", "view": "DC.Text" },
    "text3": { "text": "Password:", "view": "DC.Text" },
    "text4": { "text": "Teacher Information", "view": "DC.Text" },
    "text6": { "text": "Observation Look-fors", "view": "DC.Text" },
    "text8": { "text": "Date:", "view": "DC.Text" },
    "text9": { "text": "Comments:", "view": "DC.Text" },
    "textlabel1": { "text": "Observation Date:", "view": "DC.Text" },
    "tiList": { "allowsEmptySelection": true, "dataArray": ["Teacher Info"], "labelElementId": "label", "listStyle": "List.ROUNDED_RECTANGLE", "sampleRows": 3, "selectionEnabled": true, "view": "DC.List" },
    "tName": { "text": "Jane Doe, janedoe@edu.com", "view": "DC.Text" },
    "uploadButton": { "initialHeight": 30, "initialWidth": 68, "leftImageWidth": 5, "onclick": "uploadObservatons", "rightImageWidth": 5, "text": "*Upload*", "view": "DC.PushButton" },
    "userID": { "view": "DC.TextField" },
    "versionLabel": { "text": "Version 2.6", "view": "DC.Text" },
    "versionLabel1": { "text": "Version 2.6.2", "view": "DC.Text" }
};
























































/* 
 This file was generated by Dashcode and is covered by the 
 license.txt included in the project.  You may edit this file, 
 however it is recommended to first turn off the Dashcode 
 code generator otherwise the changes will be lost.
 */
var dashcodeDataSources = {};











Transition.NONE_TYPE="none";Transition.PUSH_TYPE="push";Transition.DISSOLVE_TYPE="dissolve";Transition.SLIDE_TYPE="slide";Transition.FADE_TYPE="fade";Transition.FLIP_TYPE="flip";Transition.CUBE_TYPE="cube";Transition.SWAP_TYPE="swap";Transition.REVOLVE_TYPE="revolve";Transition.EASE_TIMING="ease";Transition.LINEAR_TIMING="linear";Transition.EASE_IN_TIMING="ease-in";Transition.EASE_OUT_TIMING="ease-out";Transition.EASE_IN_OUT_TIMING="ease-in-out";Transition.RIGHT_TO_LEFT_DIRECTION="right-left";Transition.LEFT_TO_RIGHT_DIRECTION="left-right";Transition.TOP_TO_BOTTOM_DIRECTION="top-bottom";Transition.BOTTOM_TO_TOP_DIRECTION="bottom-top";function Transition(A,C,B){this.type=A;this.setDuration(C);this.timing=B;this._useTransforms=Transition.areTransformsSupported()}function CreateTransitionWithProperties(A){var C=new Transition();for(var B in A){if(B=="duration"){C.setDuration(A[B])}else{C[B]=A[B]}}return C}Transition.prototype.perform=function(G,B,E){if(!G||!G.parentNode){return }var F=G.parentNode;if(B){if(B.parentNode!=F){return }if(B==G){return }F=B.parentNode;if(F.getAttribute("apple-transition-flip-push-container")){this._pushContainer=F;F=this._pushContainer.parentNode}else{this._pushContainer=null}var A=B.style;A.zIndex=0;this._containerWidth=F.offsetWidth+"px";A.width=this._containerWidth;A.top=B.offsetTop+"px";if(this._useTransforms){A.webkitTransitionProperty="none";A.webkitTransform=this._translateOp(0,0);A.webkitBackfaceVisibility=""}if(!this.type||this.type==Transition.NONE_TYPE||!this._useTransforms){if((this.type!=Transition.FADE_TYPE)&&(this.type!=Transition.SLIDE_TYPE)||E){A.display="none"}}}F.style.overflow="hidden";var D=Element.getStyles(F,"position");if((D!="absolute")&&(D!="relative")){F.style.position="relative"}var C=G.style;if(this._useTransforms){C.webkitTransitionProperty="none";C.webkitTransform=this._translateOp(0,0);C.webkitBackfaceVisibility="";F.parentNode.style.zIndex=0}C.width=null;C.position="relative";C.display="block";if(this.startTransitionCallback){this.startTransitionCallback(this,B,G)}if(this.type&&this.type!=Transition.NONE_TYPE&&this._useTransforms){this._checkedForEnded=false;this._containerElement=F;this._newView=G;this._oldView=B;this._previousNewStyleOpacity=C.opacity;this._shouldHideOldView=true;if(B){A.position="absolute";this._preventEventsInContainer();this._originalContainerElementHeight=F.style.height;F.style.height=Math.max(B.offsetHeight,G.offsetHeight)+"px"}if(this._pushContainer&&(this.type!=Transition.FLIP_TYPE)){this._clearPushContainer()}if(this.type==Transition.DISSOLVE_TYPE||this.type==Transition.FADE_TYPE){this._performFadeTransition(E)}else{if(this.type==Transition.PUSH_TYPE||this.type==Transition.SLIDE_TYPE){this._performPushOrSlideTransition(E)}else{if(this.type==Transition.FLIP_TYPE){this._performFlipTransition(E)}else{if(this.type==Transition.CUBE_TYPE){this._performCubeTransition(E)}else{if(this.type==Transition.SWAP_TYPE){this._performSwapTransition(E)}else{if(this.type==Transition.REVOLVE_TYPE){this._performRevolveTransition(E)}}}}}}}else{if(this._privateEndTransitionCallback){this._privateEndTransitionCallback(this,B,G)}if(this.endTransitionCallback){this.endTransitionCallback(this,B,G)}}};Transition.areTransformsSupported=function(){if(!Transition._areTransformsSupported){Transition._areTransformsSupported=(window.WebKitCSSMatrix?true:false)}return Transition._areTransformsSupported};Transition._DEFAULT_DURATION={none:"0.35",push:"0.35",dissolve:"0.35",slide:"0.35",fade:"0.35",flip:"0.65",cube:"0.55",swap:"0.55",revolve:"0.35"};Transition.prototype.getDuration=function(){var A=this._duration;if(A==""){A=Transition._DEFAULT_DURATION[this.type];if(!A){A="0.3"}}return A};Transition.prototype.setDuration=function(A){this._duration=A};Transition.prototype._getDurationString=function(){var A=parseFloat(this.getDuration());if(!isNaN(A)){A+="s"}else{A="0s"}return A};Transition.prototype._getDurationStringForFadingEffect=function(){var A=parseFloat(this.getDuration());if(!isNaN(A)){A=A*(1+((A<0.25)?0.5:Math.pow(4,-0.25-A)))+"s"}else{A="0s"}return A};Transition.prototype._translateOp=function(A,B){return"translate("+A+"px, "+B+"px)"};Transition.prototype._rotateOp=function(A,B){return"rotate"+A+"("+B+"deg)"};Transition.prototype._setupTransition=function(C,E,F,D,B,A){C.webkitTransitionProperty=E;C.webkitTransitionDuration=F;C.webkitTransitionTimingFunction=D;C[B]=A};Transition.prototype.handleEvent=function(A){switch(A.type){case"webkitTransitionEnd":this._transitionEnded(A);break;case"webkitAnimationEnd":this._animationEnded(A);break}};Transition.prototype._preventEventsInContainer=function(){if(!this._maskContainerElement){return }if(this._mask){this._maskContainerElement.removeChild(this._mask)}this._mask=document.createElement("div");this._mask.setAttribute("style","position: absolute; top: 0; left: 0; z-index: 1000;");this._mask.style.width=this._maskContainerElement.offsetWidth+"px";this._mask.style.height=this._maskContainerElement.offsetHeight+"px";this._maskContainerElement.appendChild(this._mask)};Transition.prototype._clearPushContainer=function(){if(this._pushContainer){this._containerElement.removeChild(this._pushContainer);var B=this._pushContainer.childNodes;for(var A=B.length-1;A>=0;A--){if(B[A]!=this._mask){this._containerElement.appendChild(B[A])}}delete this._pushContainer}};Transition.prototype._transitionEndedHelper=function(){if(this._shouldHideOldView){this._oldView.style.display="none"}this._newView.style.zIndex=1;this._newView.style.opacity=this._previousNewStyleOpacity;if(this._maskContainerElement&&this._mask){this._maskContainerElement.removeChild(this._mask);this._mask=null}this._containerElement.style.height=this._originalContainerElementHeight;if(this._privateEndTransitionCallback){this._privateEndTransitionCallback(this,this._oldView,this._newView)}if(this.endTransitionCallback){this.endTransitionCallback(this,this._oldView,this._newView)}};Transition.prototype._transitionEnded=function(A){if(!this._checkedForEnded){this._transitionEndedHelper();if(this.type==Transition.CUBE_TYPE){this._containerElement.style.webkitPerspective="";this._oldView.style.webkitTransformOrigin="";this._newView.style.webkitTransformOrigin=""}this._checkedForEnded=true}};Transition._findAnimationRule=function(E){var A=null;var F=document.styleSheets;var D=/Parts\/Transitions.css$/;for(var C=0;C<F.length;C++){var H=F[C];if(D.test(H.href)){for(var B=0;B<H.cssRules.length;B++){var G=H.cssRules[B];if(G.type==7&&G.name==E){A=G;break}}}}return A};Transition.prototype._animationEndedHelper=function(){this._transitionEndedHelper();Transition._removeClassName(this._oldView,this._oldViewAnimationName);Transition._removeClassName(this._newView,this._newViewAnimationName)};Transition.prototype._animationEnded=function(A){if(!this._checkedForEnded){this._animationEndedHelper();if(this.type==Transition.FLIP_TYPE){Transition._removeClassName(this._containerElement,"dashcode-transition-flip-container");Transition._removeClassName(this._pushContainer,"dashcode-transition-flip-container-pushback")}this._checkedForEnded=true}};Transition.prototype._performFadeTransition=function(E){if(this._oldView){var A=this;var D=this._newView.style;var B=this._oldView.style;var C=this.type==Transition.DISSOLVE_TYPE;var F=this.type==Transition.FADE_TYPE;if(F){if(!E){D.opacity=0}}else{if(C){D.opacity=0}}var G=this._getDurationStringForFadingEffect(this.getDuration());Transition._addDelayedTransitionCallback(function(){if(C||(F&&E)){A._setupTransition(B,"opacity",G,A.timing,"opacity",0)}else{A._shouldHideOldView=false}if(C||(F&&!E)){A._setupTransition(D,"opacity",G,A.timing,"opacity",A._previousNewStyleOpacity)}});Event.observe(this._newView,"webkitTransitionEnd",this)}};Transition.prototype._performPushOrSlideTransition=function(A){if(this._oldView){var I=this;var E=this._newView.style;var C=this._oldView.style;var B=this.type==Transition.PUSH_TYPE;var F=this.type==Transition.SLIDE_TYPE;var J=true;var H=A?-1:1;var D=parseInt(this._containerWidth,10);if(this.direction==Transition.BOTTOM_TO_TOP_DIRECTION){J=false;D=A?this._newView.offsetHeight:this._oldView.offsetHeight}else{if(this.direction==Transition.TOP_TO_BOTTOM_DIRECTION){J=false;D=A?this._oldView.offsetHeight:this._newView.offsetHeight}}if(this.direction==Transition.LEFT_TO_RIGHT_DIRECTION||this.direction==Transition.TOP_TO_BOTTOM_DIRECTION){H*=-1}if(B||(F&&!A)){E.webkitTransitionProperty="none";var G;if(J){G=this._translateOp(H*D,0)}else{G=this._translateOp(0,H*D)}E.webkitTransform=G}Transition._addDelayedTransitionCallback(function(){var L=I._getDurationString();if(B||(F&&A)){var K;if(J){K=I._translateOp(-1*H*D,0)}else{K=I._translateOp(0,-1*H*D)}I._setupTransition(C,"-webkit-transform",L,I.timing,"webkitTransform",K)}else{I._shouldHideOldView=false}if(B||(F&&!A)){I._setupTransition(E,"-webkit-transform",L,I.timing,"webkitTransform",I._translateOp(0,0))}});Event.observe(this._newView,"webkitTransitionEnd",this)}};Transition.prototype._performFlipTransition=function(B){if(this._oldView){var H=this._newView.style;var E=this._oldView.style;var G=parseInt(this._containerWidth,10);if(G!=320){if(Transition._containerFlipTranslateZStyle===undefined){var C=Transition._findAnimationRule("dashcode-transition-flip-container-pushback");try{Transition._containerFlipTranslateZStyle=C.findRule("50%").style}catch(J){Transition._containerFlipTranslateZStyle=null}}}if(Transition._containerFlipTranslateZStyle){Transition._containerFlipTranslateZStyle.webkitTransform="translateZ("+-1*G/2+"px)"}if(!this._pushContainer){this._pushContainer=document.createElement("div");this._pushContainer.setAttribute("apple-transition-flip-push-container","true");this._pushContainer.setAttribute("style","position: relative; top: 0; left: 0; overflow: visible; z-index: 0; -webkit-transform-style: preserve-3d;");var D=this._containerElement.childNodes;for(var I=D.length-1;I>=0;I--){if(D[I]!=this._mask){this._pushContainer.appendChild(D[I])}}this._containerElement.appendChild(this._pushContainer)}var M=this._getDurationString();var K=this.direction;if(K!=Transition.RIGHT_TO_LEFT_DIRECTION&&K!=Transition.LEFT_TO_RIGHT_DIRECTION){K=Transition.RIGHT_TO_LEFT_DIRECTION}var A=((K==Transition.RIGHT_TO_LEFT_DIRECTION)&&!B)||((K==Transition.LEFT_TO_RIGHT_DIRECTION)&&B);E.webkitAnimationDuration=M;E.webkitAnimationTimingFunction=this.timing;var L=A?"dashcode-transition-flip-right-old-view":"dashcode-transition-flip-left-old-view";Transition._addClassName(this._oldView,L);H.webkitAnimationDuration=M;H.webkitAnimationTimingFunction=this.timing;var F=A?"dashcode-transition-flip-right-new-view":"dashcode-transition-flip-left-new-view";Transition._addClassName(this._newView,F);this._pushContainer.style.webkitAnimationDuration=M;this._pushContainer.style.webkitAnimationTimingFunction=this.timing;Transition._addClassName(this._pushContainer,"dashcode-transition-flip-container-pushback");this._containerElement.style.webkitAnimationDuration=M;this._containerElement.style.webkitAnimationTimingFunction=this.timing;Transition._addClassName(this._containerElement,"dashcode-transition-flip-container");Event.observe(this._containerElement,"webkitAnimationEnd",this);this._newViewAnimationName=F;this._oldViewAnimationName=L}};Transition.prototype._performCubeTransition=function(A){if(this._oldView){var G=this;var E=this._newView.style;var C=this._oldView.style;var I=this._getDurationString();var H=this.direction;if(H!=Transition.RIGHT_TO_LEFT_DIRECTION&&H!=Transition.LEFT_TO_RIGHT_DIRECTION){H=Transition.RIGHT_TO_LEFT_DIRECTION}var B=((H==Transition.RIGHT_TO_LEFT_DIRECTION)&&!A)||((H==Transition.LEFT_TO_RIGHT_DIRECTION)&&A);this._containerElement.style.webkitPerspective="800";C.webkitBackfaceVisibility="hidden";C.webkitTransformOrigin=B?"100% 50%":"0% 50%";E.webkitBackfaceVisibility="hidden";E.webkitTransformOrigin=B?"0% 50%":"100% 50%";var F=B?1:-1;var D=parseInt(this._containerWidth,10);E.webkitTransitionProperty="none";E.webkitTransform=G._rotateOp("Y",F*90)+" translateZ("+D+"px)";Transition._addDelayedTransitionCallback(function(){var J=G._getDurationString();G._setupTransition(C,"-webkit-transform",J,G.timing,"webkitTransform",G._rotateOp("Y",F*-90)+" translateZ("+D+"px)");G._setupTransition(E,"-webkit-transform",J,G.timing,"webkitTransform","rotateY(0deg) translateZ(0px)")});Event.observe(this._newView,"webkitTransitionEnd",this)}};Transition.prototype._performSwapTransition=function(D){if(this._oldView){var C=this._newView.style;var A=this._oldView.style;var H=this._getDurationString();var F=this.direction;if(F!=Transition.RIGHT_TO_LEFT_DIRECTION&&F!=Transition.LEFT_TO_RIGHT_DIRECTION){F=Transition.RIGHT_TO_LEFT_DIRECTION}var B=((F==Transition.RIGHT_TO_LEFT_DIRECTION)&&!D)||((F==Transition.LEFT_TO_RIGHT_DIRECTION)&&D);A.webkitAnimationDuration=H;A.webkitAnimationTimingFunction=this.timing;var E=B?"dashcode-transition-swap-right-old-view":"dashcode-transition-swap-left-old-view";Transition._addClassName(this._oldView,E);C.webkitAnimationDuration=H;C.webkitAnimationTimingFunction=this.timing;var G=B?"dashcode-transition-swap-right-new-view":"dashcode-transition-swap-left-new-view";Transition._addClassName(this._newView,G);Event.observe(this._newView,"webkitAnimationEnd",this);this._newViewAnimationName=G;this._oldViewAnimationName=E}};Transition.prototype._performRevolveTransition=function(C){if(this._oldView){var B=this._newView.style;var A=this._oldView.style;var G=this._getDurationString();A.webkitAnimationDuration=G;A.webkitAnimationTimingFunction=this.timing;var E;var D=this.direction;if(D!=Transition.RIGHT_TO_LEFT_DIRECTION&&D!=Transition.LEFT_TO_RIGHT_DIRECTION){D=Transition.RIGHT_TO_LEFT_DIRECTION}if(D==Transition.RIGHT_TO_LEFT_DIRECTION){E=C?"dashcode-transition-revolve-right-old-view":"dashcode-transition-revolve-right-reverse-old-view"}else{E=C?"dashcode-transition-revolve-left-old-view":"dashcode-transition-revolve-left-reverse-old-view"}Transition._addClassName(this._oldView,E);B.webkitAnimationDuration=G;B.webkitAnimationTimingFunction=this.timing;var F;if(D==Transition.RIGHT_TO_LEFT_DIRECTION){F=C?"dashcode-transition-revolve-right-new-view":"dashcode-transition-revolve-right-reverse-new-view"}else{F=C?"dashcode-transition-revolve-left-new-view":"dashcode-transition-revolve-left-reverse-new-view"}Transition._addClassName(this._newView,F);Event.observe(this._newView,"webkitAnimationEnd",this);this._newViewAnimationName=F;this._oldViewAnimationName=E}};Transition._hasClassName=function(A,B){if(A){var C=A.className;return(C.length>0&&(C==B||new RegExp("(^|\\s)"+B+"(\\s|$)").test(C)))}};Transition._addClassName=function(A,B){if(A){if(!this._hasClassName(A,B)){A.className+=(A.className?" ":"")+B}return A}return null};Transition._removeClassName=function(A,B){if(A){A.className=A.className.replace(new RegExp("(^|\\s+)"+B+"(\\s+|$)")," ");A.className=A.className.replace(/^\s+|\s+$/g,"");return A}return null};Transition._addDelayedTransitionCallback=function(C){var B=Transition;if(!B._delayedCallbacks){B._delayedCallbacks=new Array();var A=function(){var D=B._delayedCallbacks.length;for(var E=0;E<D;E++){B._delayedCallbacks[E]()}delete B._delayedCallbacks};setTimeout(A,0)}B._delayedCallbacks.push(C)};DC.StackLayout=Class.create(DC.DashcodePart,{__viewClassName__:"StackLayout",exposedBindings:["currentView"],clonedFrom:function(A){this.base(A);this._viewsOldOpacity=A._viewsOldOpacity},partSetup:function(I){this.base(I);var D=I.subviewsTransitions||[];var B=this.viewElement();var E=I.originalID?I.originalID:B.originalID;this._viewsOldOpacity=[];this._views=[];this._currentView=null;var A=B.children;this._inDesign=window.dashcode&&window.dashcode.inDesign;var H=false;for(var C=0;C<A.length;C++){var G=A[C];this._views.push(G);if(!this._inDesign&&!E){G.style.display=(H)?"none":"block";if(this._viewsOldOpacity.length<=C){this._viewsOldOpacity.push(G.style.opacity)}G.style.opacity=(H)?0:1;H=true}}if(this._views.length>0){this._viewsTransition=[];this.setCurrentView(this._views[0]);if(this._views.length==D.length){for(var C=0;C<this._views.length;C++){this._viewsTransition[C]=CreateTransitionWithProperties(D[C])}}}this._topPosFromBody=0;var F=this.viewElement();do{this._topPosFromBody+=F.offsetTop}while(F=F.offsetParent);this._maskContainerElement=B},getAllViews:function(){return this._views},getCurrentView:function(){return this._currentView},setCurrentView:function(A){this.setCurrentViewWrapped(A,arguments[1],arguments[2])},setCurrentViewWrapped:function(E,C,B){E=this._getView(E);var A=this.getCurrentView();if(!E||(A==E)){return }if(!E.parentNode==this.viewElement()){return }var D=this._viewsTransition[this._indexOfView(E)];if(!D){D=new Transition(Transition.NONE_TYPE)}if(A){if(C){D=this._viewsTransition[this._indexOfView(A)]}}this._setCurrentViewPrimitive(E,A,D,C,B)},setCurrentViewWithTransition:function(E,D,C,B){E=this._getView(E);if(!E){return }if(!E.parentNode==this.viewElement()){return }var A=this.getCurrentView();this._setCurrentViewPrimitive(E,A,D,C,B)},getTransitionForView:function(A){A=this._getView(A);return this._viewsTransition[this._indexOfView(A)]},addView:function(A,B){this._views.push(A);this._viewsOldOpacity.push(A.style.opacity);A.style.opacity=(this._views.length==1?1:0);A.style.display=(this._views.length==1?"none":"block");A.style.webkitTransform="translate(0px, 0px)";if(!B){B=null}this._viewsTransition[this._views.length-1]=B;this.viewElement().appendChild(A);if(this._views.length==1){this.setCurrentView(A)}},removeView:function(B){var A=this._indexOfView(B);if((A<0)||(this._views.length==1)){return }if(B==this.getCurrentView()){this.setCurrentView(this._views[(A==0?1:0)])}this._views.splice(A,1);this._viewsOldOpacity.splice(A,1);this._viewsTransition.splice(A,1);this.viewElement().removeChild(B)},_indexOfView:function(A){var B=-1;if(this._views.indexOf){B=this._views.indexOf(A)}else{for(var C=0;C<this._views.length;C++){if(this._views[C]==A){B=C;break}}}return B},_getView:function(A){if(A){if(A.nodeType==1){return A}if(A.element){return A.element}for(var B=0;B<this._views.length;B++){var C=this._views[B];if((C.id==A)||(C.originalID==A)){return C}}}return null},_setRestrictToBrowserTransition:function(A){this._restrictedBrowserTransition=A?CreateTransitionWithProperties({type:Transition.PUSH_TYPE,direction:Transition.RIGHT_TO_LEFT_DIRECTION,timing:Transition.EASE_IN_OUT_TIMING}):null},_getRealTransition:function(B){var A=B;if(this._restrictedBrowserTransition){A=this._restrictedBrowserTransition;A.setDuration(B.getDuration())}return A},_setCurrentViewPrimitive:function(H,D,G,E,C){if(!this._inDesign){if(this.startTransitionCallback){this.startTransitionCallback(this,D,H)}if(C){var F=this._topPosFromBody-window.pageYOffset;if(F<0){window.scrollBy(0,F)}}if(DC.page.focusedElement){DC.page.focusedElement.blur()}if(G){this._restoreOldOpacity(D);this._restoreOldOpacity(H);var B=this._getRealTransition(G);var A=this;B._privateEndTransitionCallback=function(I){A._transitionEnded(I,D,H)};B._maskContainerElement=this._maskContainerElement;B.perform(H,D,E)}else{if(D){D.style.display="none"}if(H){H.style.display="block";this._restoreOldOpacity(H)}this._transitionEnded(null,D,H)}}this._currentView=H},_transitionEnded:function(B,A,C){if(this._privateEndTransitionCallback){this._privateEndTransitionCallback(this,A,C)}if(this.endTransitionCallback){this.endTransitionCallback(this,A,C)}},_restoreOldOpacity:function(A){if(A){var B=this._viewsOldOpacity[this._indexOfView(A)];A.style.opacity=(B!==undefined)?B:null}}});/* 
 This file was generated by Dashcode and is covered by the 
 license.txt included in the project.  You may edit this file, 
 however it is recommended to first turn off the Dashcode 
 code generator otherwise the changes will be lost.
 */

// Note: Properties and methods beginning with underbar ("_") are considered private and subject to change in future Dashcode releases.

/*jsl:import DashcodePart.js*/

/**   
 *  @declare DC.PushButton
 *  @extends DC.DashcodePart
 *  
 */
DC.PushButton = Class.create(DC.DashcodePart, {

    exposedBindings: ["sizeToFit","state","text"],

    __viewClassName__: "PushButton",
    partSetup: function(spec) 
    {
        var buttonElement = this.viewElement();
        var _self = this;
        var originalID = spec.originalID ? spec.originalID : buttonElement.originalID;
        if (!buttonElement || !spec)
            return;
                
        // when cloning template, get size from original
        if (originalID) {
            while (buttonElement.firstChild) 
                buttonElement.removeChild(buttonElement.firstChild);
        }
        
        this.enabled = !spec.disabled;
        
        // calculate sizes and margins
        this._initialWidth = spec.initialWidth || 0;
        this._initialHeight = spec.initialHeight || 0;
        this._leftImageWidth = spec.leftImageWidth || 0;
        this._rightImageWidth = spec.rightImageWidth || 0;
        this._noBackground = spec.noBackground || false;
        this._containerLeft = 0;
        this._containerRight = 0;

        // determine URL of background images
        this._pressed = false;
        var imagePrefix = "Parts/Images/" + (originalID?originalID:buttonElement.id);
        this._bgIimageURL = imagePrefix + ".png"
        this._pressedBgImageURL = imagePrefix + "_clicked.png";
        
        // create internal elements
        var style;
        this._backgroundElement = document.createElement("div");
        style = this._backgroundElement.style;
        style.position = "absolute";
        style.top = "0px";
        style.left = "0px";
        style.right = "0px";
        style.bottom = "0px";
        buttonElement.appendChild(this._backgroundElement);
        this._backgroundElementPressed = this._backgroundElement.cloneNode(false);
        style = this._backgroundElementPressed.style;
        style.visibility = "hidden";
        buttonElement.appendChild(this._backgroundElementPressed);
        this._containerElement = this._backgroundElement.cloneNode(false);
        style = this._containerElement.style;
        style.textOverflow = "ellipsis";
        buttonElement.appendChild(this._containerElement);
        this._textElement = document.createElement("span");
        style = this._textElement.style;
        style.display = "inline";
        this._containerElement.appendChild(this._textElement);
        this._imageElement = document.createElement("img");
        style = this._imageElement.style;
        style.display = "inline";
        style.verticalAlign = "middle";
        this._containerElement.appendChild(this._imageElement);
        this._lineBreakElement = document.createElement("br");
        this._containerElement.appendChild(this._lineBreakElement);
        this._eventsElement = this._backgroundElement.cloneNode(false);
        style = this._eventsElement.style;
        buttonElement.appendChild(this._eventsElement);

        // set the text and image values
        this._updateBackgroundImage();
        var text = spec.text || '';
        if (window.dashcode && dashcode.getLocalizedString) text = dashcode.getLocalizedString(text);
        this.setText(text);
        this.setImageURL(spec.customImage || '');
        this.setPressedImageURL(spec.customImagePressed || '');
        var imagePosition = (spec.customImagePosition == undefined) || (spec.customImagePosition.length < 1) ? DC.PushButton.IMAGE_POSITION_NONE : eval(spec.customImagePosition);
        this.setImagePosition(imagePosition);
        
        if (spec.onclick && !dashcode.inDesign) {
            try {
                var onClickHandler = eval(spec.onclick);
                
                if (onClickHandler) {
                    this._setOnClickAsAction(onClickHandler,this._eventsElement);
                }
            } catch (e) {};
        }
    },
    
    onmousedown: function(event)
    {
        if (this.enabled)
            this._setPressed(true);
    },

    onmouseup: function(event)
    {
        if (this.enabled)
            this._setPressed(false);        
    },

    onclick: function(event)
    {
        if (this.enabled && this.action){
            this.sendAction();
        }
    },

    setEnabled: function(enabled)
    {
        // ensure 'enabled' is a boolean
        enabled = !(!enabled);
        
        if (this.enabled == enabled) {
            return;
        } 
        
        this.enabled = enabled;
        var originalOpacity = 1;
        var element = this.viewElement();
        
        var style = Element.getStyles(element, ["opacity"]);
        if (style && style["opacity"] != null) {
            originalOpacity = +style["opacity"];
        }
        
        if (enabled) {
            element.style.opacity = originalOpacity * (1/DC.PushButton.DISABLED_OPACITY);
            element.style.appleDashboardRegion = "dashboard-region(control rectangle)";
        } else {
            element.style.opacity = DC.PushButton.DISABLED_OPACITY * originalOpacity;
            element.style.appleDashboardRegion = "none";
        }
    },
    
    getEnabled: function()
    {
        return this.enabled;
    },
    
    observeEnabledChange: function(change)
    {
        
        if (this.__initialising && (null===change.newValue ||
            'undefined'===change.newValue))
        {
            this.bindings.enabled.setValue(this.enabled);
            return;
        }
            
        this.setEnabled(change.newValue);
    },
    
    observeTextChange: function(change, keyPath, context)
    {
        if (this.__initialising &&
            (null===change.newValue || 'undefined'===typeof(change.newValue)))
        {
            this.bindings.text.setValue(this.getText());
            return;
        }
        
        this.setText(change.newValue);
    },
    
    setText: function(text) 
    {
       this._textElement.innerText = text;
       if (this._sizeToFit)
        this.sizeToFit();
    },
    
    getText: function()
    {
        return this._textElement.innerText;
    },
    
    setSizeToFit: function(sizeToFit) 
    {
        this._sizeToFit = sizeToFit;
        if (sizeToFit)
            this.sizeToFit();
    },
    
    getSizeToFit: function()
    {
        return this._sizeToFit;
    },
    
    sizeToFit: function(minWidth,maxWidth)
    {
        var minWidthToFit = this._widthRequiredToFit();
        
        if( maxWidth && (maxWidth < minWidthToFit) ){
            minWidthToFit = parseInt(maxWidth, 10);
        }else if( minWidth && (minWidth > minWidthToFit) ){
            minWidthToFit = parseInt(minWidth, 10);
        }
        
        this.viewElement().style.width = minWidthToFit + "px";	
        this._layoutElements();
    },
    
    setImagePosition: function(position)
    {
        this._imagePosition = position;
        this._layoutElements();
    },
    
    getImagePosition: function()
    {
        return this._imagePosition;
    },
    
    setImageURL: function(imageURL)
    {
        this._customImageURL = imageURL;
        this._customImageLoaded = false;
        if (this._customImageURL) {
            this._customImage = new Image();
            var _self = this;
            this._customImage.onload = function () {
                _self._customImageLoaded = true;
                _self._setCustomImage();
            }
            this._customImage.src = this._customImageURL;
        }  else {
            this._customImage = null;
            this._setCustomImage();
        }  
    },
    
    getImageURL: function()
    {
         return this._customImageURL;
    },
    
    setPressedImageURL: function(imageURL)
    {
        this._customImagePressedURL = imageURL;
        this._customImagePressedLoaded = false;
        if (this._customImagePressedURL) {
            this._customImagePressed = new Image();
            var _self = this;
            this._customImagePressed.onload = function () {
                _self._customImagePressedLoaded = true;
                _self._setCustomImage();
            }
            this._customImagePressed.src = this._customImagePressedURL;
        }  else {
            this._customImagePressed = null;
            this._setCustomImage();
        }
    },
    
    getPressedImageURL: function()
    {
        return this._customImagePressedURL;
    },
    
    setState: function(state)
    {
        this._pressed = (state == DC.PushButton.STATE_ON);
        // show the normal or pressed background (and custom image)
        if (this._pressed) {
            this._backgroundElement.style.visibility = "hidden";
            this._backgroundElementPressed.style.visibility = "visible";
        } else {
            this._backgroundElement.style.visibility = "visible";
            this._backgroundElementPressed.style.visibility = "hidden";
        }
        this._setCustomImage();
        // Work-around for WebKit issue 5882457, otherwise, sometimes the image position on the button can be incorrect.
        this._imageElement.offsetLeft;
    },
    
    getState: function()
    {
        return this._pressed ? DC.PushButton.STATE_ON : DC.PushButton.STATE_OFF;
    }

    /*********************
     * Private handlers
     *********************/,
    
    _setCustomImage: function()
    {
        var imageStyle = this._imageElement.style;
        if (this._pressed && this._customImagePressed && this._customImagePressedLoaded) {
            this._imageElement.src = this._customImagePressedURL;
            imageStyle.width = this._customImagePressed.width + "px";
            imageStyle.height = this._customImagePressed.height + "px";
        } else if (!this._pressed && this._customImage && this._customImageLoaded) {
            this._imageElement.src = this._customImageURL;
            imageStyle.width = this._customImage.width + "px";
            imageStyle.height = this._customImage.height + "px";
        } else {
            this._imageElement.src = null;
        }
        this._layoutElements();
    },
    
    _setPressed: function(pressed)
    {
        var state = pressed ? DC.PushButton.STATE_ON : DC.PushButton.STATE_OFF;
        this.setState(state);
    },
    
    _updateBackgroundImage: function()
    {
        var style = this._backgroundElement.style;
        var pressedStyle = this._backgroundElementPressed.style;

        // sets background-image or border-image
        if (this._noBackground) {
            Element.set3PiecesBorderImage(this._backgroundElement, null);
            Element.set3PiecesBorderImage(this._backgroundElementPressed, null);
            style.backgroundImage = "";
            pressedStyle.backgroundImage = "";
        } else if (this._leftImageWidth > 0 || this._rightImageWidth > 0) {
            Element.set3PiecesBorderImage(this._backgroundElement, this._bgIimageURL, this._leftImageWidth, this._rightImageWidth);
            Element.set3PiecesBorderImage(this._backgroundElementPressed, this._pressedBgImageURL, this._leftImageWidth, this._rightImageWidth);
            style.backgroundImage = "";
            pressedStyle.backgroundImage = "";
        } else {
            Element.set3PiecesBorderImage(this._backgroundElement, null);
            Element.set3PiecesBorderImage(this._backgroundElementPressed, null);
            style.backgroundImage = "url(" + this._bgIimageURL + ")";
            pressedStyle.backgroundImage = "url(" + this._pressedBgImageURL + ")";
            style.backgroundRepeat = "repeat-x";
            pressedStyle.backgroundRepeat = "repeat-x";
        }

        var minMargin = 2;
        this._containerLeft = +this._leftImageWidth + minMargin;
        this._containerRight = +this._rightImageWidth + minMargin;
        if (this._containerLeft > this._containerRight) {
            this._containerLeft = Math.ceil((this._containerRight + this._containerLeft) / 2);
        } else if (this._containerRight > this._containerLeft) {
            this._containerRight = Math.ceil((this._containerRight + this._containerLeft) / 2);
        }
        this._containerElement.style.marginLeft = this._containerLeft + "px";
        this._containerElement.style.marginRight = this._containerRight + "px";
    },
    
    _layoutElements: function() {
        var position = this._imagePosition;
        if (!this._customImage || (!this._customImageLoaded && !this._customImagePressedLoaded && (position != DC.PushButton.IMAGE_POSITION_CENTER))) {
            position = DC.PushButton.IMAGE_POSITION_NONE;
        }
        var imageStyle = this._imageElement.style;
        var textStyle = this._textElement.style;
        var containerStyle = this._containerElement.style;
        var lineBreakStyle = this._lineBreakElement.style;

        var buttonHeight = this.viewElement().offsetHeight;
        if (buttonHeight < 1) buttonHeight = this._initialHeight;
        var buttonWidth = this.viewElement.offsetWidth;
        if (buttonWidth < 1) buttonWidth = this._initialWidth;

        // if no image
        if (position == DC.PushButton.IMAGE_POSITION_NONE) {
            textStyle.position = "static";
            imageStyle.display = "none";
            textStyle.display = "inline";
            containerStyle.lineHeight = buttonHeight + "px";
            containerStyle.overflow = "hidden";
            containerStyle.marginTop = "";
            lineBreakStyle.display = "none";
        } else {
            // get element dimensions
            var textHeight = this._textElement.offsetHeight;
            if (textHeight < 1) {
                var style = Element.getStyles(this._textElement, ["font-size"]);
                if (style && style["font-size"] != null) {
                    textHeight = parseFloat(style["font-size"]);
                }
            }
            var imageWidth = 0;
            var imageHeight = 0;
            var horizontalSpacing = 5;
            var verticalSpacing = 5;
                            
            if (this._pressed && this._customImagePressed) {
                imageWidth = this._customImagePressed.width;
                imageHeight = this._customImagePressed.height;
            } else if (this._customImage) {
                imageWidth = this._customImage.width;
                imageHeight = this._customImage.height;                            
            }
                            
            // lay out the text and image
            if (position == DC.PushButton.IMAGE_POSITION_LEFT || position == DC.PushButton.IMAGE_POSITION_RIGHT) {
                textStyle.display = "inline";
                imageStyle.display = "inline";
                imageStyle.marginTop = "";
                imageStyle.marginBottom = "";
                containerStyle.marginTop = "";
                containerStyle.lineHeight = buttonHeight + "px";
                containerStyle.overflow = "hidden";
                lineBreakStyle.display = "none";
                if (position == DC.PushButton.IMAGE_POSITION_LEFT) {
                    this._containerElement.insertBefore(this._imageElement, this._textElement);
                    imageStyle.marginLeft = "";
                    imageStyle.marginRight = horizontalSpacing+"px";
                } else {
                    this._containerElement.insertBefore(this._textElement, this._imageElement);
                    imageStyle.marginLeft = horizontalSpacing+"px";
                    imageStyle.marginRight = "";
                }
            } else if(position == DC.PushButton.IMAGE_POSITION_TOP || position == DC.PushButton.IMAGE_POSITION_BOTTOM) {
                textStyle.display = "inline";
                imageStyle.display = "inline";
                imageStyle.marginLeft = "";
                imageStyle.marginRight = "";
                containerStyle.lineHeight = "";
                containerStyle.overflow = "hidden";
                var containerMarginTop = Math.floor((buttonHeight - (textHeight + imageHeight + verticalSpacing)) / 2);
                containerStyle.marginTop = Math.max(containerMarginTop, 0) + "px";
                lineBreakStyle.display = "inline";
                if(position == DC.PushButton.IMAGE_POSITION_TOP) {
                    imageStyle.marginTop = "";
                    imageStyle.marginBottom = verticalSpacing + "px";
                    this._containerElement.insertBefore(this._imageElement, this._textElement);
                    this._containerElement.insertBefore(this._lineBreakElement, this._textElement);
                } else {
                    imageStyle.marginTop = verticalSpacing + "px";
                    imageStyle.marginBottom = "";
                    this._containerElement.insertBefore(this._textElement, this._imageElement);
                    this._containerElement.insertBefore(this._lineBreakElement, this._imageElement);
                }
            } else { // position IMAGE_POSITION_CENTER
                textStyle.display = "none";
                imageStyle.display = "inline";
                containerStyle.lineHeight = buttonHeight + "px";
                containerStyle.overflow = "visible";
                containerStyle.marginTop = "";
                lineBreakStyle.display = "none";
                // if the image is larger than the button, compensate to center
                var horizontalDifference = imageWidth - (buttonWidth - this._containerLeft - this._containerRight);
                var marginLeft = (horizontalDifference > 0) ? -horizontalDifference / 2 : 0;
                var verticalDifference = imageHeight - buttonHeight;
                var marginTop = (verticalDifference > 0) ? -verticalDifference / 2 : 0;
                imageStyle.marginLeft = marginLeft + "px";
                imageStyle.marginTop = marginTop + "px";
                imageStyle.marginRight = "";
                imageStyle.marginBottom = "";
            }        
        }
    },
    
    _widthRequiredToFit: function()
    {
        var textWidth = this._textElement.offsetWidth;
        var width = 0;
        
        // If there is an image
        if(this._imagePosition != DC.PushButton.IMAGE_POSITION_NONE && (this._customImageLoaded || this._customImagePressedLoaded)){
            var imageWidth = this._pressed ? this._customImagePressed.width : this._customImage.width;
            
            switch( this._imagePosition ){
                case DC.PushButton.IMAGE_POSITION_LEFT:
                case DC.PushButton.IMAGE_POSITION_RIGHT:
                    if( this._imageElement.style.marginLeft )
                        width += parseInt(this._imageElement.style.marginLeft, 10);
                    if( this._imageElement.style.marginRight )
                        width += parseInt(this._imageElement.style.marginRight, 10);
                    
                    width += textWidth + imageWidth;
                    break;
                    default:
                    if( textWidth > imageWidth )
                        width += textWidth;
                    else
                        width += imageWidth;
                    break;
            }
            
        }else{ // If there is not an image
            width += textWidth;
        }
        
        width += this._containerLeft + this._containerRight;
        
        return width;
    },
    
    _setNoBackground: function(newValue)
    {
        this._noBackground = newValue;
    }
});

DC.PushButton.DISABLED_OPACITY = 0.5;

DC.PushButton.IMAGE_POSITION_NONE = 0;
DC.PushButton.IMAGE_POSITION_LEFT = 1;
DC.PushButton.IMAGE_POSITION_RIGHT = 2;
DC.PushButton.IMAGE_POSITION_TOP = 3;
DC.PushButton.IMAGE_POSITION_BOTTOM = 4;
DC.PushButton.IMAGE_POSITION_CENTER = 5;

DC.PushButton.STATE_OFF = 0;
DC.PushButton.STATE_ON = 1;

// For backward compatibility
if (!window.PushButton)
    window.PushButton = DC.PushButton;/* 
 This file was generated by Dashcode and is covered by the 
 license.txt included in the project.  You may edit this file, 
 however it is recommended to first turn off the Dashcode 
 code generator otherwise the changes will be lost.
 */

// Note: Properties and methods beginning with underbar ("_") are considered private and subject to change in future Dashcode releases.

/*jsl:import DashcodePart.js*/

/**   
 *  @declare DC.List
 *  @extends DC.DashcodePart
 *  
 */

// Public properties:
//     element: the List's DOM element (read-only)
//     templateRowElement: the List's template row, the element that will be cloned to form the rows of the List
//     dataSource: for dynamic Lists, the dataSource object
//     dataArray: for static Lists, the static list data
//     rows: the current row elements for the list (read-only)
//     selectionIndexes: array of row indexes currently selected
//     selectedObject: object value of the first selected row 
//
// Public Methods:
//     selectionIndexes(): returns an array with the indexes of the selected rows
//     setSelectionIndexes(array, animated): set the selection row indexes, highlighting the selected rows. If 'animated' is true, the selection highlight will fade in/out.
//     setDataSource(dataSource): set the List to be dynamic, using the given dataSource (will reload the list)
//     setDataArray(array): set the List to be static, using the given data.  The array should be like [[row0Label, row0Value], [row1Label, row1Value], ...].
//     reloadData(): causes the List to reload itself.  Mostly useful for dynamic Lists when you know the data has changed and need the List to show the updated data.
//     setSelectionEnabled(newValue): set if the rows of the list can be selected..
//     setAllowsMultipleSelection(newValue): set if the list allows multiple selection.
//     setAllowsEmptySelection(newValue): set if there can be no row selected at any time.
//     setUseAlternatingRows(boolean): set if the list uses alternating background for rows.

//
// Row objects: (Each instantiated row has an "object" property.  Those objects have the following properties.)
//     rowIndex: the index of the row within the List
//     value: the value of the row (only for static Lists)
//     templateElements: a dictionary mapping original element ids from the template row element to the corresponding clones in this row

DC.List= Class.create(DC.ListView, {
    __viewClassName__: "DashcodeList",
	selectsInsertedItems: false,
    maskedBindings: ["content","selectionIndexes","selectedIndex","selectedObject"],
    exposedBindings: ["dataArray"],
					
    partSetup: function(spec)
    {
        // Backwards compatibility (this.viewElement() does the same thing)
        this.element = this.viewElement();
        
        try {
            this._listStyle = eval(spec.listStyle);
        } catch (e) {
            this._listStyle = this.EDGE_TO_EDGE;
        }

        this._selectionEnabled = spec.selectionEnabled || false;
        this.setAllowsEmptySelection(spec.allowsEmptySelection || false);
        this.setAllowsMultipleSelection(spec.allowsMultipleSelection || false);
        this._labelElementId = spec.labelElementId || 'label';

        this.setUseAlternatingRows(spec.useAlternatingRows || false);
				 
        var dataArray = spec.dataArray || null;
        var dataSourceName = spec.dataSourceName || null;
        
        this._useDataSource = spec.useDataSource || false;
        this._sampleRows = spec.sampleRows || 0;
        
        // When using this part inside a list template row, preserve ids temporarily
        spec.preserveChildIdsWhenCloning = true;
        
        // Set up the highlight element
        if (!dashcode.inDesign){
            this._rowHighlight = document.createElement("div");
            this._rowHighlight.className = "DC_selectionBG";
            this._rowHighlight.style.position = "absolute";
            this._rowHighlight.style.right = "0";
            this._rowHighlight.style.left = "0";
            this._rowHighlight.style.top = "0";
            this._rowHighlight.style.bottom = "0";
        } else {
            this.maximumCachedRows = 0;
        }
        
        // determine where to get the data from
        if (this._useDataSource) {
            var dataSource = window[dataSourceName];
            if (dataSource) {
                this.dataSource = dataSource;
            }
        } else if (dataArray) {
            var self = this;
            this.dataArray = dataArray;
        }
        
        this.viewElement().style.display = "block";
        
        this.selectedIndex = null;
        
        this.rows = [];
    },
    
    init: function(){
        this.base();
        
        // The super class already has the template element
        this.templateRowElement = this.templateElement;
        
        if (dashcode.inDesign && this.templateElement) {
            this.reloadData();
        }
    },
    clonedFrom: function(originalView){
        this.base(originalView);
        
        if (dashcode.inDesign) {
            this.templateElement = Element.clone(this.templateElement);
        }
        this.reloadData();
    },
	
    //
    // Set the data source object that will insert the data and format each row for dynamic lists.
    // dataSource must implement two required callback methods: numberOfRows() and prepareRow(rowElement, rowIndex, templateElements).
    // dataSource.numberOfRows() is called while the list is initializing and it should return the total number of rows in the list.
    // dataSource.prepareRow() is called once for each row. It is passed 3 parameters:
    //     rowElement: The HTML DOM element that represents the row being prepared. Typically an <li> element.
    //     rowIndex: The position of the row in the list, starting at 0.
    //     templateElements: A JavaScript object that contains a reference to each cloned element that had an ID in the template row. For example, if the template row had an element with id="label", the cloned element can be obtained using templateElements.label. These elements are descendants of rowElement.
    //
    setDataSource: function(dataSource)
    {
        this._useDataSource = true;
        this.dataSource = dataSource;
        this.reloadData();
    },
    
    observeDataArrayChange: function(change)
    {
        if (change.changeType == DC.ChangeType.setting) {
            var builtInAC = this._builtInArrayController(true);
            
            if (builtInAC){
                if (!builtInAC.bindings.arrangedObjects) {
                    if (builtInAC.bindings.content) {
                        builtInAC.bindings.content.unbind();
                    }
                    this.bindNameToKeyPath("content","*.arrangedObjects", this._builtInAC);
                }
                
                builtInAC.setValueForKey(change.newValue,"content");
                    
                /*
                // If we have a set value and we don't allow empty selection
                // ensure selection
                if (change.newValue && !this.getAllowsEmptySelection() && this.getSelectionEnabled() && !dashcode.inDesign) {
                    if (builtInAC.selectionIndex() == -1) {
                        builtInAC.setSelectionIndex(0);
                    }
                }
                */
            }
        }
    },
        
    //
    // Set the data array to use in static lists.
    // dataArray should be an Array of HTML strings and a row will be created for each item. The HTML string will be inserted as the innerHTML of the element with the ID specified in the part spec as labelElementId.
    //
    setDataArray: function(dataArray)
    {
        this._useDataSource = false;
        this.dataArray = dataArray;
        this.reloadData();
    },
    
    //
    // Get/set if selection is enabled for this list
    // The default is true
    //
    getSelectionEnabled: function()
    {
        return this._selectionEnabled;
    },
    setSelectionEnabled: function(newValue)
    {
        this._selectionEnabled = newValue;
        
        var builtInAC = this._builtInArrayController(false);
        
        if (builtInAC) {
            builtInAC.setAvoidsEmptySelection(!this.allowsEmpty && this._selectionEnabled && !dashcode.inDesign);
        }

    },

    //
    // Get/set if the list allows multiple selection
    // The default is false
    // This value is ignored if selectionEnabled is false
    //
    getAllowsMultipleSelection: function()
    {
        return this.multiple;
    },
    setAllowsMultipleSelection: function(newValue)
    {
        this.multiple = newValue;
    },

    //
    // Get/set if the list allows empty selection
    // The default is true
    // This value is ignored if selectionEnabled is false
    //
    getAllowsEmptySelection: function()
    {
        return this.allowsEmpty;
    },
    setAllowsEmptySelection: function(newValue)
    {
        this.allowsEmpty = newValue;
        
        var builtInAC = this._builtInArrayController(false);
        
        if (builtInAC) {
            builtInAC.setAvoidsEmptySelection(!this.allowsEmpty && this._selectionEnabled && !dashcode.inDesign);
        }

    },
 
   
    //
    // Get/set if the list uses alternating background for rows.
    // The default is true.
    //
    getUseAlternatingRows: function(){
        return this._useAlternatingRows;
    },
    setUseAlternatingRows: function(flag){
        this._useAlternatingRows = flag;
        
        if(flag)
            Element.addClassName(this.viewElement(), "useAlternatingRows");
        else
            Element.removeClassName(this.viewElement(), "useAlternatingRows");
    },


    //
    // This function is called by setupParts after all the parts have been set up.  
    // We do not initially load our data until all setup is complete.
    //
    finishLoading: function()
    {
        this.reloadData();
    },
    
    //
    // Reload the data from the data source (for dynamic lists) or from the data array (for static lists).
    // The list is regenerated by removing all the rows and cloning the template row. Parts inside each cloned row are also initialized.
    //
    reloadData: function()
    {
        // Prevent any problems with a real binding to the list
        if (!this._builtInAC && this.bindings && this.bindings.content)
            return;
        
        // If we have a binding on the data array, we aren't consulted
        if (this.bindings && this.bindings.dataArray)
            return;

        this.rows = [];
        this._anchorIndex = null;
                
        var builtInArrayController = this._builtInArrayController(true);
        var generatedData = DC.KVO.adaptTree([]);
        
        if (!builtInArrayController) {
            console.error("error generating built in array controller");
            return;
        }
        
        if (!builtInArrayController.bindings.content) {
            if (builtInArrayController.bindings.arrangedObjects) {
                builtInArrayController.bindings.arrangedObjects.unbind();
            }
            this.bindNameToKeyPath("content","*.arrangedObjects", builtInArrayController);
        }

        builtInArrayController.setValueForKey(generatedData,"content");            
        
        if(this._useDataSource && dashcode.inDesign){
            // Loop through and create an entry for each row
            for (var rowIndex=0; rowIndex<this._sampleRows; rowIndex++) {
                generatedData.addObject(DC.KVO.adapt({index:rowIndex}));        
            }
        } else if (this.dataArray) {
            for (var rowIndex=0; rowIndex<this.dataArray.length; rowIndex++) {
                generatedData.addObject(this.dataArray[rowIndex]);
            }
        } else if (this._useDataSource && this.dataSource) {
            var numberOfRows = this.dataSource.numberOfRows();

            for (var rowIndex=0; rowIndex<numberOfRows; rowIndex++) {
                var rowRepresentation = null;
                
                if (this.dataSource.objectForRow) {
                    rowRepresentation = this.dataSource.representationForRow(rowIndex);
                    
                    if (rowRepresentation && DC.typeOf(rowRepresentation) == "object") {
                        DC.KVO.adaptTree(rowRepresentation);
                    }
                }
                
                generatedData.addObject(rowRepresentation);
            }
        }
        
        if (!dashcode.inDesign && generatedData && generatedData.length && this.getSelectionEnabled() && !this.getAllowsEmptySelection()) {
            if (builtInArrayController.selectionIndex() == -1) {
                builtInArrayController.setSelectionIndex(0);
            }
        }
        
        // show the list after the data is loaded
        if (dashcode.inDesign) {
            var self = this;
            setTimeout(function() {if(self.viewElement()) { self.viewElement().style.display = "block";}}, 0);
        } else {
            this.viewElement().style.display = "block";
        }
                      
        // if it is inside a scroll area, notify it of the change
        if (typeof(AppleScrollArea) != "undefined") {
            var scrollElement = list.parentNode;
            while (scrollElement && scrollElement != document) {
                if (scrollElement.object && scrollElement.object.constructor == AppleScrollArea) {
                    scrollElement.object.refresh();
                    break;
                }
                scrollElement = scrollElement.parentNode;
            }
        }
    
    },
    
    createElement: function(relativeSource, beforeNode, container, index)
    {
        var row = this.base(relativeSource, beforeNode, container, index);
            
        if (dashcode.inDesign && (index == 0) && (row != this.templateElement)){
            container= container || this.container();
             container.insertBefore(this.templateElement,container.firstChild);        
            container.removeChild(row);
            if(row.parentNode){
                row.parentNode.removeChild(row);
            }
            this.templateElement.objectValue = row.objectValue;
            row = this.templateElement;
            DC.View.createViewsForNodeTree(row, null , this.__context)
            this.elementUsedForIndex(row,index);
        }
        
        return row;
    },
    
    highlightSelectionIndexes: function(selectionIndexes)
    {
        if (dashcode.inDesign)
            return;
        
        this.base(selectionIndexes);
    },
    
    elementUsedForIndex: function(row, index)
    {
        if (index == -1) {
            // unhighlight any rows not in use anymore
            this._setRowHighlighted(row, false, false);
            this.rows.removeObject(row);
            return;
        } else {
            while(index >= this.rows.length) {
                this.rows.addObject(null);
            }
            this.rows[index] = row;
        }
        
        if (!("object" in row)){
            row.object = {};
        }
        
        if (this._listStyle == DC.List.ROUNDED_RECTANGLE) {
            row.style.borderTopWidth = index > 0 ? "1px" : "0px";
        }
        
        if (this._useDataSource) {
            if (this.dataSource && this.dataSource.prepareRow) {
                this.dataSource.prepareRow(row, index, row.object.templateElements);
            }
        } else if (this.dataArray){
            if (row != this.templateRowElement && row.object) {
                row.object.index = index;
                row.object.value = this.dataArray[index];
            }
            
            // If static list
            this._prepareStaticRow(row,index,row.object.templateElements);
        }
        
        if (row.onclick) {
            var self = this;
            var originalHandler = null;

            row.object.clickHandler = row.onclick;
            if (row != this.templateRowElement)
                row.onclick = null;
            row.style.webkitTapHighlightColor = "rgba(0,0,0,0)";
            row.style.webkitTouchCallout = "none"; 
        }                        
    },
    
    
    // --------- Selection ----------------- //
    
    //
    // Set the selection indexes. Optionally, animate the change.
    //
    setSelectionIndexes: function(newSelection, animated)
    {
        var oldSelection = this._selectionIndexes;
        
        if (!this._selectionEnabled) {
            return;
        }

        if (dashcode.inDesign)
            return;
        
        this._animateHighlight = animated;
        
        // call super to update internal state and bindings
        this.base(newSelection);
        
        delete this._animateHighlight;
        
    },
    
    highlightSelection: function(item,highlight)
    {
        this.base(item,highlight);
        this._setRowHighlighted(item, highlight, this._animateHighlight);
    },
    
    clearSelection: function(animated)
    {
        this.setSelectionIndexes([], animated);
    },
    
    _findRow: function(child)
    {  
        if (!child){
            return null;
        }
        var parent = child.parentNode;
        
        if (this.viewElement() == parent) {
            return child;
        }
        
        return this._findRow(parent);
    },
    
    onmousedown: function(event)
    {
        if (DC.Support.Touches) {
            // first use the row found during touch start
            var realTarget = this._touchedRow;
            // if none, find it now
            if (!realTarget) {
                realTarget = this._findRow(event.target ? event.target : event.srcElement);            
            }
            
            if (realTarget && realTarget.object && !realTarget.object._highlighted && this._selectionEnabled){
                this._setRowHighlighted(realTarget, true, false);
                this._temporaryHighlight = realTarget;
            }
        }
        this.base(event);
    },
    
    onmouseup: function(event)
    {
        if (DC.Support.Touches) {
            if (this._temporaryHighlight){
                this._setRowHighlighted(this._temporaryHighlight, false, false);
                delete this._temporaryHighlight;
            }
        }
        
        this.base(event);
    },
    
    onclick: function(event)
    {
        var targetRow = this._temporaryHighlight;
        this.base(event);
                
        if (!this.action){
            if (!targetRow)
                targetRow = this._findRow(event.target ? event.target : event.srcElement);
            
            if (targetRow && targetRow.object && targetRow.object.clickHandler) {
                this._sendLegacyOnClick(event,targetRow,targetRow.object.clickHandler);
            }
        }        
  
        delete this._temporaryHighlight;
    },
    
    onswipe: function(event)
    {
        // set a swipe callback if the datasource defines one
        if (this.dataSource && this.dataSource.rowSwiped) {
            var targetRow = this._findRow(event.target ? event.target : event.srcElement);
            
            this.dataSource.rowSwiped(targetRow,event,5);
        }

    },
    
    // --------- Private methods ----------------- //
    
    
    _prepareStaticRow: function(rowElement,rowIndex,templateElements)
    {
        var labelElement = null;
        var data = this.dataArray[rowIndex];

        if (dashcode.inDesign && !templateElements){
            labelElement = document.getElementById(this._labelElementId);
        }
        
        for (var key in templateElements) {
            // try to find the label element
            if (this._labelElementId && this._labelElementId.length > 0 && key.indexOf(this._labelElementId) == 0) { 
                labelElement = templateElements[key];
                break;
            }
        }
        
        if (this._labelElementId && this._labelElementId.length && (rowElement == this.templateElement)) {
            var query = Element.queryAll(rowElement,"#" + this._labelElementId);
            
            if (query.length > 0)
                labelElement = query[0];
        }
        
        // get the text and value
        var itemLabel = '';
        var itemValue = '';
        if ((data) instanceof Array) {
            if (data.length > 0) {
                itemLabel = data[0];
                if (data.length > 1) {
                    itemValue = data[1];
                }
            }
        }
        else {
            itemLabel = data;
            itemValue = itemLabel;
        }
        
        // assign the label and insert it
        if (labelElement) {
            var localizedLabel = dashcode.getLocalizedString(itemLabel);
            if (localizedLabel) {
                itemLabel = localizedLabel;
            }
                      
            labelElement.innerHTML = itemLabel;
        }

    },
    
    _builtInArrayController: function(createIfNecessary)
    {
        if (!("_builtInAC" in this)){
            // Set up built in Array Controller
            this._builtInAC = new DC.ArrayController();
            this._builtInAC.selectsInsertedObjects = false;
            this._builtInAC.setAvoidsEmptySelection(!this.getAllowsEmptySelection() && this.getSelectionEnabled() && !dashcode.inDesign);
            this.bindNameToKeyPath("content","*.arrangedObjects", this._builtInAC);
            this.bindNameToKeyPath("selectionIndexes","*.selectionIndexes", this._builtInAC);
            // If we have an id, register so we can bind
            if (this.id)
                this._builtInAC.registerWithName(this.id);
        }
        
        return this._builtInAC;
    },
    
    _setDataArray: function(dataArray)
    {
        this.dataArray = dataArray;
        this.reloadData();
    },

    _setSampleRows: function(numberOfRows)
    {
        this._sampleRows = numberOfRows;
        this.reloadData();
    },

    _setUseDataSource: function(useDataSource)
    {
        this._useDataSource = useDataSource;
        this.reloadData();
    },

    _setLabelElementId: function(newId)
    {
        this._labelElementId = newId;
        this.reloadData();
    },

    _setRowHighlighted: function(rowElement, highlight, animated)
    {
        if (!rowElement || !rowElement.object)
            return;
        
        if (highlight != rowElement.object._highlighted) {
            if (highlight) {
                if (this._rowHighlight){
                    // if this row still has no highlight element, create it
                    if (!rowElement.object.rowHighlight) {
                        rowElement.object.rowHighlight = this._rowHighlight.cloneNode(true);
                        
                        var rowIndex = rowElement.object.index;
                        if (this._listStyle == DC.List.ROUNDED_RECTANGLE && (rowIndex == 0 || rowIndex == rowElement.parentNode.children.length-1) ) {
                            // Add rounded corners to the rowHighlight if it is in the first or last row.
                            var ULStyle = Element.getStyles(this.viewElement(), ["border-top-width", "border-bottom-width", "-webkit-border-top-left-radius", "-webkit-border-top-right-radius", "-webkit-border-bottom-left-radius", "-webkit-border-bottom-right-radius"]);
                            var rowStyle = rowElement.object.rowHighlight.style;
                            
                            // First Row.
                            if(rowIndex == 0){
                                var borderWidth = parseInt(ULStyle["border-top-width"], 10);
                                rowStyle.webkitBorderTopLeftRadius = (parseInt(ULStyle["-webkit-border-top-left-radius"], 10) - borderWidth) + "px";
                                rowStyle.webkitBorderTopRightRadius = (parseInt(ULStyle["-webkit-border-top-right-radius"], 10) - borderWidth) + "px";
                            }
                            // Last row. Note that it can be the same as the first row.
                            if(rowIndex == rowElement.parentNode.children.length-1){
                                var borderWidth = parseInt(ULStyle["border-bottom-width"], 10);
                                rowStyle.webkitBorderBottomLeftRadius = (parseInt(ULStyle["-webkit-border-bottom-left-radius"], 10) - borderWidth) + "px";
                                rowStyle.webkitBorderBottomRightRadius = (parseInt(ULStyle["-webkit-border-bottom-right-radius"], 10) - borderWidth) + "px";
                            }
                        }
                    }
                    // show it
                    var rowHighlight = rowElement.object.rowHighlight;
                    rowHighlight.style.opacity = 0;
                    rowElement.insertBefore(rowHighlight, rowElement.firstChild);
                    if (animated) {
                        rowHighlight.style.webkitTransitionProperty = 'opacity';
                        rowHighlight.style.webkitTransitionDuration = '.25s';
                        window.setTimeout(function() {
                            rowHighlight.style.opacity = 1;
                        }, 0);
                    } else {
                        rowHighlight.style.webkitTransitionProperty = 'none';
                        rowHighlight.style.webkitTransitionDuration = '0s';
                        rowHighlight.style.opacity = 1;                        
                    }
                    Element.addClassName(rowElement, DC.Style.kSelectedClass);
                }
            } else {
                var rowHighlight = rowElement.object.rowHighlight;

                // hide the highlight element
                if (rowHighlight){
                    if (animated) {
                        rowHighlight.style.webkitTransitionProperty = 'opacity';
                        rowHighlight.style.webkitTransitionDuration = '.25s';
                        var removeHighlight = function() {
                            rowElement.removeChild(rowHighlight);
                            Event.stopObserving(rowHighlight, 'webkitTransitionEnd', arguments.callee);
                        };
                        Event.observe(rowHighlight, 'webkitTransitionEnd', removeHighlight);
                        window.setTimeout(function() {
                            rowHighlight.style.opacity = 0;
                        }, 0);
                    } else {
                        rowHighlight.style.webkitTransitionProperty = 'none';
                        rowHighlight.style.webkitTransitionDuration = '0s';
                        rowHighlight.style.opacity = 0;
                    }                    
                    Element.removeClassName(rowElement, DC.Style.kSelectedClass);
                }
            }
            rowElement.object._highlighted = highlight;
        }
    }    
});

// Constants for the list types
DC.List.EDGE_TO_EDGE = 1;
DC.List.ROUNDED_RECTANGLE = 2;
DC.List.DESKTOP = 3;

if (!window.List) {
    window.List = DC.List;
}