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