(function(y){var P=y.fn.domManip,B="_tmplitem",O=/^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,z={},D={},C,N={key:0,data:{}},F=0,A=0,J=[];function E(f,b,h,j){var a={data:j||(b?b.data:{}),_wrap:b?b._wrap:null,tmpl:null,parent:b||null,nodes:[],calls:S,nest:U,wrap:V,html:T,update:R};f&&y.extend(a,f,{nodes:[],parent:b});if(h){a.tmpl=h;a._ctnt=a._ctnt||a.tmpl(y,a);a.key=++F;(J.length?D:z)[F]=a}return a}y.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(b,a){y.fn[b]=function(r){var c=[],e=y(r),o,d,q,p,f=this.length===1&&this[0].parentNode;C=z||{};if(f&&f.nodeType===11&&f.childNodes.length===1&&e.length===1){e[a](this[0]);c=this}else{for(d=0,q=e.length;d<q;d++){A=d;o=(d>0?this.clone(true):this).get();y.fn[a].apply(y(e[d]),o);c=c.concat(o)}A=0;c=this.pushStack(c,b,e.selector)}p=C;C=null;y.tmpl.complete(p);return c}});y.fn.extend({tmpl:function(f,e,a){return y.tmpl(this[0],f,e,a)},tmplItem:function(){return y.tmplItem(this[0])},template:function(a){return y.template(a,this[0])},domManip:function(a,n,m){if(a[0]&&a[0].nodeType){var b=y.makeArray(arguments),c=a.length,k=0,e;while(k<c&&!(e=y.data(a[k++],"tmplItem"))){}if(c>1){b[0]=[y.makeArray(a)]}if(e&&A){b[2]=function(d){y.tmpl.afterManip(this,d,m)}}P.apply(this,b)}else{P.apply(this,arguments)}A=0;!C&&y.tmpl.complete(z);return this}});y.extend({tmpl:function(b,g,f,a){var i,l=!a;if(l){a=N;b=y.template[b]||y.template(null,b);D={}}else{if(!b){b=a.tmpl;z[a.key]=a;a.nodes=[];a.wrapped&&L(a,a.wrapped);return y(G(a,null,a.tmpl(y,a)))}}if(!b){return[]}if(typeof g==="function"){g=g.call(a||{})}f&&f.wrapped&&L(f,f.wrapped);i=y.isArray(g)?y.map(g,function(c){return c?E(f,a,b,c):null}):[E(f,a,b,g)];return l?y(G(a,null,i)):i},tmplItem:function(a){var d;if(a instanceof y){a=a[0]}while(a&&a.nodeType===1&&!(d=y.data(a,"tmplItem"))&&(a=a.parentNode)){}return d||N},template:function(d,a){if(a){if(typeof a==="string"){a=M(a)}else{if(a instanceof y){a=a[0]||{}}}if(a.nodeType){a=y.data(a,"tmpl")||y.data(a,"tmpl",M(a.innerHTML))}return typeof d==="string"?(y.template[d]=a):a}return d?typeof d!=="string"?y.template(null,d):y.template[d]||y.template(null,O.test(d)?d:y(d)):null},encode:function(b){return(""+b).split("<").join("&lt;").split(">").join("&gt;").split('"').join("&#34;").split("'").join("&#39;")}});y.extend(y.tmpl,{tag:{tmpl:{_default:{$2:"null"},open:"if($notnull_1){_=_.concat($item.nest($1,$2));}"},wrap:{_default:{$2:"null"},open:"$item.calls(_,$1,$2);_=[];",close:"call=$item.calls();_=call._.concat($item.wrap(call,_));"},each:{_default:{$2:"$index, $value"},open:"if($notnull_1){$.each($1a,function($2){with(this){",close:"}});}"},"if":{open:"if(($notnull_1) && $1a){",close:"}"},"else":{_default:{$1:"true"},open:"}else if(($notnull_1) && $1a){"},html:{open:"if($notnull_1){_.push($1a);}"},"=":{_default:{$1:"$data"},open:"if($notnull_1){_.push($.encode($1a));}"},"!":{open:""}},complete:function(){z={}},afterManip:function(h,a,c){var g=a.nodeType===11?y.makeArray(a.childNodes):a.nodeType===1?[a]:[];c.call(h,a);K(g);A++}});function G(h,j,i){var a,d=i?y.map(i,function(b){return typeof b==="string"?h.key?b.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g,"$1 "+B+'="'+h.key+'" $2'):b:G(b,h,b._ctnt)}):h;if(j){return d}d=d.join("");d.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/,function(l,b,k,g){a=y(k).get();K(a);if(b){a=H(b).concat(a)}if(g){a=a.concat(H(g))}});return a?a:H(d)}function H(d){var a=document.createElement("div");a.innerHTML=d;return y.makeArray(a.childNodes)}function M(a){return new Function("jQuery","$item","var $=jQuery,call,_=[],$data=$item.data;with($data){_.push('"+y.trim(a).replace(/([\\'])/g,"\\$1").replace(/[\r\t\n]/g," ").replace(/\$\{([^\}]*)\}/g,"{{= $1}}").replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,function(w,v,u,o,k,n,p){var t=y.tmpl.tag[u],s,q,r;if(!t){throw"Template command not found: "+u}s=t._default||[];if(n&&!/\w$/.test(k)){k+=n;n=""}if(k){k=I(k);p=p?","+I(p)+")":n?")":"";q=n?k.indexOf(".")>-1?k+n:"("+k+").call($item"+p:k;r=n?q:"(typeof("+k+")==='function'?("+k+").call($item):("+k+"))"}else{r=q=s.$1||"null"}o=I(o);return"');"+t[v?"close":"open"].split("$notnull_1").join(k?"typeof("+k+")!=='undefined' && ("+k+")!=null":"true").split("$1a").join(r).split("$1").join(q).split("$2").join(o?o.replace(/\s*([^\(]+)\s*(\((.*?)\))?/g,function(h,g,f,e){e=e?","+e+")":f?")":"";return e?"("+g+").call($item"+e:h}):s.$2||"")+"_.push('"})+"');}return _;")}function L(d,a){d._wrap=G(d,true,y.isArray(a)?a:[O.test(a)?a:y(a).html()]).join("")}function I(b){return b?b.replace(/\\'/g,"'").replace(/\\\\/g,"\\"):null}function Q(d){var c=document.createElement("div");c.appendChild(d.cloneNode(true));return c.innerHTML}function K(q){var h="_"+A,d,c,f={},a,r,b;for(a=0,r=q.length;a<r;a++){if((d=q[a]).nodeType!==1){continue}c=d.getElementsByTagName("*");for(b=c.length-1;b>=0;b--){g(c[b])}g(d)}function g(s){var w,n=s,t,l,u;if(u=s.getAttribute(B)){while(n.parentNode&&(n=n.parentNode).nodeType===1&&!(w=n.getAttribute(B))){}if(w!==u){n=n.parentNode?n.nodeType===11?0:n.getAttribute(B)||0:0;if(!(l=z[u])){l=D[u];l=E(l,z[n]||D[n],null,true);l.key=++F;z[F]=l}A&&v(u)}s.removeAttribute(B)}else{if(A&&(l=y.data(s,"tmplItem"))){v(l.key);z[l.key]=l;n=y.data(s.parentNode,"tmplItem");n=n?n.key:0}}if(l){t=l;while(t&&t.key!=n){t.nodes.push(s);t=t.parent}delete l._ctnt;delete l._wrap;y.data(s,"tmplItem",l)}function v(e){e=e+h;l=f[e]=f[e]||E(l,z[l.parent.key+h]||l.parent,null,true)}}}function S(e,h,g,f){if(!e){return J.pop()}J.push({_:e,tmpl:h,item:this,data:g,options:f})}function U(f,e,a){return y.tmpl(y.template(f),e,a,this)}function V(a,f){var e=a.options||{};e.wrapped=f;return y.tmpl(y.template(a.tmpl),a.data,e,a.item)}function T(f,e){var a=this._wrap;return y.map(y(y.isArray(a)?a.join(""):a).filter(f||"*"),function(b){return e?b.innerText||b.textContent:b.outerHTML||Q(b)})}function R(){var a=this.nodes;y.tmpl(null,null,null,this).insertBefore(a[0]);y(a).remove()}})(jQuery);
