//>>built
define("dojox/dtl/dom","dojo/_base/lang ./_base dojox/string/tokenize ./Context dojo/dom dojo/dom-construct dojo/_base/html dojo/_base/array dojo/_base/connect dojo/_base/sniff".split(" "),function(n,f,C,K,D,E,y,F,G,u){f.BOOLS={checked:1,disabled:1,readonly:1};f.TOKEN_CHANGE=-11;f.TOKEN_ATTR=-12;f.TOKEN_CUSTOM=-13;f.TOKEN_NODE=1;var w=f.text,x=f.dom={_attributes:{},_uppers:{},_re4:/^function anonymous\(\)\s*{\s*(.*)\s*}$/,_reTrim:/(?:^[\n\s]*(\{%)?\s*|\s*(%\})?[\n\s]*$)/g,_reSplit:/\s*%\}[\n\s]*\{%\s*/g,
getTemplate:function(a){if("undefined"==typeof this._commentable){this._commentable=!1;var b=document.createElement("div");b.innerHTML="\x3c!--Test comment handling, and long comments, using comments whenever possible.--\x3e";b.childNodes.length&&8==b.firstChild.nodeType&&"Test comment handling, and long comments, using comments whenever possible."==b.firstChild.data&&(this._commentable=!0)}this._commentable||(a=a.replace(/\x3c!--({({|%).*?(%|})})--\x3e/g,"$1"));u("ie")&&(a=a.replace(/\b(checked|disabled|readonly|style)="/g,
't$1\x3d"'));a=a.replace(/\bstyle="/g,'tstyle\x3d"');b=u("webkit");for(var e=[[!0,"select","option"],[b,"tr","td|th"],[b,"thead","tr","th"],[b,"tbody","tr","td"],[b,"table","tbody|thead|tr","tr","td"]],c=[],d=0,g;g=e[d];d++)if(g[0]&&-1!=a.indexOf("\x3c"+g[1])){var h=new RegExp("\x3c"+g[1]+"(?:.|\n)*?\x3e((?:.|\n)+?)\x3c/"+g[1]+"\x3e","ig");for(;b=h.exec(a);){for(var k=g[2].split("|"),m=[],l=0,p;p=k[l];l++)m.push("\x3c"+p+"(?:.|\n)*?\x3e(?:.|\n)*?\x3c/"+p+"\x3e");var t=[];k=C(b[1],new RegExp("("+m.join("|")+
")","ig"),function(B){var z=/<(\w+)/.exec(B)[1];t[z]||(t[z]=!0,t.push(z));return{data:B}});if(t.length){m=1==t.length?t[0]:g[2].split("|")[0];p=[];l=0;for(var H=k.length;l<H;l++){var r=k[l];if(n.isObject(r))p.push(r.data);else if(r=r.replace(this._reTrim,"")){r=r.split(this._reSplit);for(var A=0,I=r.length;A<I;A++){for(var v="",q=2,J=g.length;q<J;q++)2==q?v+="\x3c"+m+' dtlinstruction\x3d"{% '+r[A].replace(/"/g,'\\"')+' %}"\x3e':m!=g[q]&&(v+="\x3c"+g[q]+"\x3e");v+="DTL";for(q=g.length-1;1<q;q--)2==
q?v+="\x3c/"+m+"\x3e":m!=g[q]&&(v+="\x3c/"+g[q]+"\x3e");p.push("\u00ff"+c.length);c.push(v)}}}a=a.replace(b[1],p.join(""))}}}for(d=c.length;d--;)a=a.replace("\u00ff"+d,c[d]);for(e=/\b([a-zA-Z_:][a-zA-Z0-9_\-\.:]*)=['"]/g;b=e.exec(a);)c=b[1].toLowerCase(),"dtlinstruction"!=c&&(c!=b[1]&&(this._uppers[c]=b[1]),this._attributes[c]=!0);b=document.createElement("div");b.innerHTML=a;for(a={nodes:[]};b.childNodes.length;)a.nodes.push(b.removeChild(b.childNodes[0]));return a},tokenize:function(a){for(var b=
[],e=0,c;c=a[e++];)1!=c.nodeType?this.__tokenize(c,b):this._tokenize(c,b);return b},_swallowed:[],_tokenize:function(a,b){var e=!1,c=this._swallowed,d,g,h;if(!b.first){e=b.first=!0;var k=f.register.getAttributeTags();for(d=0;g=k[d];d++)try{g[2]({swallowNode:function(){throw 1;}},new f.Token(f.TOKEN_ATTR,""))}catch(t){c.push(g)}}for(d=0;g=c[d];d++)if(k=a.getAttribute(g[0]))if(c=!1,g=g[2]({swallowNode:function(){c=!0;return a}},new f.Token(f.TOKEN_ATTR,g[0]+" "+k)),c){a.parentNode&&a.parentNode.removeChild&&
a.parentNode.removeChild(a);b.push([f.TOKEN_CUSTOM,g]);return}g=[];if(u("ie")&&"SCRIPT"==a.tagName)g.push({nodeType:3,data:a.text}),a.text="";else for(d=0;h=a.childNodes[d];d++)g.push(h);b.push([f.TOKEN_NODE,a]);k=!1;g.length&&(b.push([f.TOKEN_CHANGE,a]),k=!0);for(var m in this._attributes){d=!1;var l="";if("class"==m)l=a.className||l;else if("for"==m)l=a.htmlFor||l;else if(a.getAttribute)if(l=a.getAttribute(m,2)||l,"href"==m||"src"==m){if(u("ie")){var p=location.href.lastIndexOf(location.hash);p=
location.href.substring(0,p).split("/");p.pop();p=p.join("/")+"/";0==l.indexOf(p)&&(l=l.replace(p,""));l=decodeURIComponent(l)}}else"tstyle"==m?(d=m,m="style"):f.BOOLS[m.slice(1)]&&n.trim(l)?m=m.slice(1):this._uppers[m]&&n.trim(l)&&(d=this._uppers[m]);d&&(a.setAttribute(d,""),a.removeAttribute(d));"function"==typeof l&&(l=l.toString().replace(this._re4,"$1"));k||(b.push([f.TOKEN_CHANGE,a]),k=!0);b.push([f.TOKEN_ATTR,a,m,l])}d=0;for(h;h=g[d];d++)1==h.nodeType&&(m=h.getAttribute("dtlinstruction"))&&
(h.parentNode.removeChild(h),h={nodeType:8,data:m}),this.__tokenize(h,b);!e&&a.parentNode&&a.parentNode.tagName?(k&&b.push([f.TOKEN_CHANGE,a,!0]),b.push([f.TOKEN_CHANGE,a.parentNode]),a.parentNode.removeChild(a)):b.push([f.TOKEN_CHANGE,a,!0,!0])},__tokenize:function(a,b){var e=a.data;switch(a.nodeType){case 1:this._tokenize(a,b);break;case 3:if(!e.match(/[^\s\n]/)||-1==e.indexOf("{{")&&-1==e.indexOf("{%"))b.push([a.nodeType,a]);else{e=w.tokenize(e);for(var c=0,d;d=e[c];c++)"string"==typeof d?b.push([f.TOKEN_TEXT,
d]):b.push(d)}a.parentNode&&a.parentNode.removeChild(a);break;case 8:if(0==e.indexOf("{%")){d=n.trim(e.slice(2,-2));if("load "==d.substr(0,5)){c=n.trim(d).split(/\s+/g);for(var g=1,h;h=c[g];g++)/\./.test(h)&&(h=h.replace(/\./g,"/")),require([h])}b.push([f.TOKEN_BLOCK,d])}0==e.indexOf("{{")&&b.push([f.TOKEN_VAR,n.trim(e.slice(2,-2))]);a.parentNode&&a.parentNode.removeChild(a)}}};f.DomTemplate=n.extend(function(a){if(!a.nodes){var b=D.byId(a);b&&1==b.nodeType?(F.forEach(["class","src","href","name",
"value"],function(e){x._attributes[e]=!0}),a={nodes:[b]}):("object"==typeof a&&(a=w.getTemplateString(a)),a=x.getTemplate(a))}a=x.tokenize(a.nodes);f.tests&&(this.tokens=a.slice(0));this.nodelist=(new f._DomParser(a)).parse()},{_count:0,_re:/\bdojo:([a-zA-Z0-9_]+)\b/g,setClass:function(a){this.getRootNode().className=a},getRootNode:function(){return this.buffer.rootNode},getBuffer:function(){return new f.DomBuffer},render:function(a,b){b=this.buffer=b||this.getBuffer();this.rootNode=null;for(var e=
this.nodelist.render(a||new f.Context({}),b),c=0,d;d=b._cache[c];c++)d._cache&&(d._cache.length=0);return e},unrender:function(a,b){return this.nodelist.unrender(a,b)}});f.DomBuffer=n.extend(function(a){this._parent=a;this._cache=[]},{concat:function(a){var b=this._parent;if(b&&a.parentNode&&a.parentNode===b&&!b._dirty)return this;if(1==a.nodeType&&!this.rootNode)return this.rootNode=a||!0,this;if(!b){if(3==a.nodeType&&n.trim(a.data))throw Error("Text should not exist outside of the root node in template");
return this}if(this._closed){if(3!=a.nodeType||n.trim(a.data))throw Error("Content should not exist outside of the root node in template");return this}if(b._dirty){if(a._drawn&&a.parentNode==b){var e=b._cache;if(e){for(var c=0,d;d=e[c];c++)this.onAddNode&&this.onAddNode(d),b.insertBefore(d,a),this.onAddNodeComplete&&this.onAddNodeComplete(d);e.length=0}}b._dirty=!1}b._cache||(b._cache=[],this._cache.push(b));b._dirty=!0;b._cache.push(a);return this},remove:function(a){if("string"==typeof a)this._parent&&
this._parent.removeAttribute(a);else{if(1==a.nodeType&&!this.getRootNode()&&!this._removed)return this._removed=!0,this;a.parentNode&&(this.onRemoveNode&&this.onRemoveNode(a),a.parentNode&&a.parentNode.removeChild(a))}return this},setAttribute:function(a,b){var e=y.attr(this._parent,a);if(this.onChangeAttribute&&e!=b)this.onChangeAttribute(this._parent,a,e,b);"style"==a?this._parent.style.cssText=b:(y.attr(this._parent,a,b),"value"==a&&this._parent.setAttribute(a,b));return this},addEvent:function(a,
b,e,c){if(!a.getThis())throw Error("You must use Context.setObject(instance)");this.onAddEvent&&this.onAddEvent(this.getParent(),b,e);var d=e;n.isArray(c)&&(d=function(g){this[e].apply(this,[g].concat(c))});return G.connect(this.getParent(),b,a.getThis(),d)},setParent:function(a,b,e){this._parent||(this._parent=this._first=a);b&&e&&a===this._first&&(this._closed=!0);if(b){var c=this._parent,d="",g=u("ie")&&"SCRIPT"==c.tagName;g&&(c.text="");if(c._dirty){for(var h=c._cache,k="SELECT"==c.tagName&&!c.options.length,
m=0,l;l=h[m];m++)l!==c&&(this.onAddNode&&this.onAddNode(l),g?d+=l.data:(c.appendChild(l),k&&l.defaultSelected&&m&&(k=m)),this.onAddNodeComplete&&this.onAddNodeComplete(l));k&&(c.options.selectedIndex="number"==typeof k?k:0);h.length=0;c._dirty=!1}g&&(c.text=d)}this._parent=a;this.onSetParent&&this.onSetParent(a,b,e);return this},getParent:function(){return this._parent},getRootNode:function(){return this.rootNode}});f._DomNode=n.extend(function(a){this.contents=a},{render:function(a,b){this._rendered=
!0;return b.concat(this.contents)},unrender:function(a,b){if(!this._rendered)return b;this._rendered=!1;return b.remove(this.contents)},clone:function(a){return new this.constructor(this.contents)}});f._DomNodeList=n.extend(function(a){this.contents=a||[]},{push:function(a){this.contents.push(a)},unshift:function(a){this.contents.unshift(a)},render:function(a,b,e){b=b||f.DomTemplate.prototype.getBuffer();if(e)var c=b.getParent();for(e=0;e<this.contents.length;e++)if(b=this.contents[e].render(a,b),
!b)throw Error("Template node render functions must return their buffer");c&&b.setParent(c);return b},dummyRender:function(a,b,e){var c=document.createElement("div"),d=b.getParent(),g=d._clone;d._clone=c;var h=this.clone(b,c);d._clone=g?g:null;b=f.DomTemplate.prototype.getBuffer();h.unshift(new f.ChangeNode(c));h.unshift(new f._DomNode(c));h.push(new f.ChangeNode(c,!0));h.render(a,b);if(e)return b.getRootNode();a=c.innerHTML;return u("ie")?E.replace(/\s*_(dirty|clone)="[^"]*"/g,""):a},unrender:function(a,
b,e){if(e)var c=b.getParent();for(e=0;e<this.contents.length;e++)if(b=this.contents[e].unrender(a,b),!b)throw Error("Template node render functions must return their buffer");c&&b.setParent(c);return b},clone:function(a){for(var b=a.getParent(),e=this.contents,c=new f._DomNodeList,d=[],g=0;g<e.length;g++){var h=e[g].clone(a);if(h instanceof f.ChangeNode||h instanceof f._DomNode){var k=h.contents._clone;k?h.contents=k:b!=h.contents&&h instanceof f._DomNode&&(k=h.contents,h.contents=h.contents.cloneNode(!1),
a.onClone&&a.onClone(k,h.contents),d.push(k),k._clone=h.contents)}c.push(h)}for(g=0;h=d[g];g++)h._clone=null;return c},rtrim:function(){for(;;){var a=this.contents.length-1;if(this.contents[a]instanceof f._DomTextNode&&this.contents[a].isEmpty())this.contents.pop();else break}return this}});f._DomVarNode=n.extend(function(a){this.contents=new f._Filter(a)},{render:function(a,b){var e=this.contents.resolve(a),c="text";e&&(e.render&&e.getRootNode?c="injection":e.safe&&(e.nodeType?c="node":e.toString&&
(e=e.toString(),c="html")));this._type&&c!=this._type&&this.unrender(a,b);this._type=c;switch(c){case "text":return this._rendered=!0,this._txt=this._txt||document.createTextNode(e),this._txt.data!=e&&(c=this._txt.data,this._txt.data=e,b.onChangeData&&b.onChangeData(this._txt,c,this._txt.data)),b.concat(this._txt);case "injection":c=e.getRootNode();this._rendered&&c!=this._root&&(b=this.unrender(a,b));this._root=c;var d=this._injected=new f._DomNodeList;d.push(new f.ChangeNode(b.getParent()));d.push(new f._DomNode(c));
d.push(e);d.push(new f.ChangeNode(b.getParent()));this._rendered=!0;return d.render(a,b);case "node":return this._rendered=!0,this._node&&this._node!=e&&this._node.parentNode&&this._node.parentNode===b.getParent()&&this._node.parentNode.removeChild(this._node),this._node=e,b.concat(e);case "html":this._rendered&&this._src!=e&&(b=this.unrender(a,b));this._src=e;if(!this._rendered)for(this._rendered=!0,this._html=this._html||[],c=this._div=this._div||document.createElement("div"),c.innerHTML=e,e=c.childNodes;e.length;)d=
c.removeChild(e[0]),this._html.push(d),b=b.concat(d);return b;default:return b}},unrender:function(a,b){if(!this._rendered)return b;this._rendered=!1;switch(this._type){case "text":return b.remove(this._txt);case "injection":return this._injection.unrender(a,b);case "node":return this._node.parentNode===b.getParent()?b.remove(this._node):b;case "html":for(var e=0,c=this._html.length;e<c;e++)b=b.remove(this._html[e]);return b;default:return b}},clone:function(){return new this.constructor(this.contents.getExpression())}});
f.ChangeNode=n.extend(function(a,b,e){this.contents=a;this.up=b;this.root=e},{render:function(a,b){return b.setParent(this.contents,this.up,this.root)},unrender:function(a,b){return b.getParent()?b.setParent(this.contents):b},clone:function(){return new this.constructor(this.contents,this.up,this.root)}});f.AttributeNode=n.extend(function(a,b){this.key=a;this.contents=this.value=b;this._pool[b]?this.nodelist=this._pool[b]:((this.nodelist=f.quickFilter(b))||(this.nodelist=(new f.Template(b,!0)).nodelist),
this._pool[b]=this.nodelist);this.contents=""},{_pool:{},render:function(a,b){var e=this.key,c=this.nodelist.dummyRender(a);f.BOOLS[e]&&(c=!("false"==c||"undefined"==c||!c));return c!==this.contents||""===c?(this.contents=c,b.setAttribute(e,c)):b},unrender:function(a,b){this.contents="";return b.remove(this.key)},clone:function(a){return new this.constructor(this.key,this.value)}});f._DomTextNode=n.extend(function(a){this.contents=document.createTextNode(a);this.upcoming=a},{set:function(a){this.upcoming=
a;return this},render:function(a,b){if(this.contents.data!=this.upcoming){var e=this.contents.data;this.contents.data=this.upcoming;b.onChangeData&&b.onChangeData(this.contents,e,this.upcoming)}return b.concat(this.contents)},unrender:function(a,b){return b.remove(this.contents)},isEmpty:function(){return!n.trim(this.contents.data)},clone:function(){return new this.constructor(this.contents.data)}});f._DomParser=n.extend(function(a){this.contents=a},{i:0,parse:function(a){var b={},e=this.contents;
a||(a=[]);for(var c=0;c<a.length;c++)b[a[c]]=!0;for(c=new f._DomNodeList;this.i<e.length;){var d=e[this.i++],g=d[0],h=d[1];if(g==f.TOKEN_CUSTOM)c.push(h);else if(g==f.TOKEN_CHANGE)g=new f.ChangeNode(h,d[2],d[3]),h[g.attr]=g,c.push(g);else if(g==f.TOKEN_ATTR){var k=w.getTag("attr:"+d[2],!0);if(k&&d[3])-1==d[3].indexOf("{%")&&-1==d[3].indexOf("{{")||h.setAttribute(d[2],""),c.push(k(null,new f.Token(g,d[2]+" "+d[3])));else if(n.isString(d[3]))if("style"==d[2]||-1!=d[3].indexOf("{%")||-1!=d[3].indexOf("{{"))c.push(new f.AttributeNode(d[2],
d[3]));else if(n.trim(d[3]))try{y.attr(h,d[2],d[3])}catch(m){}}else if(g==f.TOKEN_NODE)(k=w.getTag("node:"+h.tagName.toLowerCase(),!0))&&c.push(k(null,new f.Token(g,h),h.tagName.toLowerCase())),c.push(new f._DomNode(h));else if(g==f.TOKEN_VAR)c.push(new f._DomVarNode(h));else if(g==f.TOKEN_TEXT)c.push(new f._DomTextNode(h.data||h));else if(g==f.TOKEN_BLOCK){if(b[h])return--this.i,c;d=h.split(/\s+/g);if(d.length){d=d[0];k=w.getTag(d);if("function"!=typeof k)throw Error("Function not found for "+d);
(h=k(this,new f.Token(g,h)))&&c.push(h)}}}if(a.length)throw Error("Could not find closing tag(s): "+a.toString());return c},next_token:function(){var a=this.contents[this.i++];return new f.Token(a[0],a[1])},delete_first_token:function(){this.i++},skip_past:function(a){return f._Parser.prototype.skip_past.call(this,a)},create_variable_node:function(a){return new f._DomVarNode(a)},create_text_node:function(a){return new f._DomTextNode(a||"")},getTemplate:function(a){return new f.DomTemplate(x.getTemplate(a))}});
return x});