(function(i){var x=function(a){return a.replace(/^\/\//,"").replace(/[\/\.]/g,"_")},y=1,e,o,p;isDeferred=function(a){return a&&i.isFunction(a.always)};getDeferreds=function(a){var b=[];if(isDeferred(a))return[a];else for(var c in a)isDeferred(a[c])&&b.push(a[c]);return b};usefulPart=function(a){return i.isArray(a)&&a.length===3&&a[1]==="success"?a[0]:a};e=i.View=function(a,b,c,d){if(typeof c==="function"){d=c;c=undefined}var f=getDeferreds(b);if(f.length){var g=i.Deferred();f.push(p(a,true));i.when.apply(i, f).then(function(j){var k=i.makeArray(arguments),l=k.pop()[0];if(isDeferred(b))b=usefulPart(j);else for(var m in b)if(isDeferred(b[m]))b[m]=usefulPart(k.shift());k=l(b,c);g.resolve(k);d&&d(k)});return g.promise()}else{var h;f=typeof d==="function";g=p(a,f);if(f){h=g;g.done(function(j){d(j(b,c))})}else g.done(function(j){h=j(b,c)});return h}};o=function(a,b){if(!a.match(/[^\s]/))throw"$.View ERROR: There is no template or an empty template at "+b;};p=function(a,b){return i.ajax({url:a,dataType:"view", async:b})};i.ajaxTransport("view",function(a,b){a=b.url;var c=a.match(/\.[\w\d]+$/),d,f,g,h=a,j,k=function(l){l=d.renderer(g,l);if(e.cache)e.cached[g]=l;return{view:l}};if(f=document.getElementById(a))c=f.type.match(/\/[\d\w]+$/)[0].replace(/^\//,".");if(!c){c=e.ext;h+=e.ext}g=x(h);if(h.match(/^\/\//))h=typeof steal==="undefined"?"/"+h.substr(2):steal.root.join(h.substr(2));d=e.types[c];return{send:function(l,m){if(e.cached[g])return m(200,"success",{view:e.cached[g]});else if(f)m(200,"success",k(f.innerHTML)); else j=i.ajax({async:b.async,url:h,dataType:"text",error:function(){o("",h);m(404)},success:function(s){o(s,h);m(200,"success",k(s))}})},abort:function(){j&&j.abort()}}});i.extend(e,{hookups:{},hookup:function(a){var b=++y;e.hookups[b]=a;return b},cached:{},cache:true,register:function(a){this.types["."+a.suffix]=a},types:{},ext:".ejs",registerScript:function(a,b,c){return"$.View.preload('"+b+"',"+e.types["."+a].script(b,c)+");"},preload:function(a,b){e.cached[a]=function(c,d){return b.call(c,c,d)}}}); var t,n,u,v,w,q;t=function(a){var b=i.fn[a];i.fn[a]=function(){var c=i.makeArray(arguments),d,f,g=this;if(u(c)){if(d=v(c)){f=c[d];c[d]=function(h){n.call(g,[h],b);f.call(g,h)};e.apply(e,c);return this}c=e.apply(e,c);if(isDeferred(c)){c.done(function(h){n.call(g,[h],b)});return this}else c=[c]}return n.call(this,c,b)}};n=function(a,b){var c;for(var d in e.hookups)break;if(d){c=e.hookups;e.hookups={};a[0]=i(a[0])}b=b.apply(this,a);d&&w(a[0],c);return b};u=function(a){var b=typeof a[1];return typeof a[0]== "string"&&(b=="object"||b=="function")&&!a[1].nodeType&&!a[1].jquery};v=function(a){return typeof a[3]==="function"?3:typeof a[2]==="function"&&2};w=function(a,b){var c,d=0,f,g;a=a.filter(function(){return this.nodeType!=3});a=a.add("[data-view-id]",a);for(c=a.length;d/g,">").replace(/"/g,""").replace(/'/g,"'")};EJS=function(a){if(this.constructor!=EJS){var b=new EJS(a);return function(c,e){return b.render(c,e)}}if(typeof a=="function"){this.template={};this.template.process= a}else{j(this,EJS.options,a);this.template=s(this.text,this.type,this.name)}};g.EJS=EJS;EJS.prototype={constructor:EJS,render:function(a,b){a=a||{};this._extra_helpers=b;b=new EJS.Helpers(a,b||{});return this.template.process.call(a,a,b)}};EJS.text=function(a){if(typeof a=="string")return a;if(a===null||a===undefined)return"";var b=a.hookup&&function(c,e){a.hookup.call(a,c,e)}||typeof a=="function"&&a||r(a)&&function(c,e){for(var d=0;d"),a||"",function(h,f){if(i===null)switch(h){case "\n":d+="\n";o(d);e.cr();k();break;case f.left:case f.eLeft:case f.eeLeft:case f.cleanLeft:case f.cmnt:i= h;d.length>0&&o(d);k();break;case f.dLeft:d+=f.left;break;default:d+=h;break}else switch(h){case f.right:switch(i){case f.left:if(d[d.length-1]=="\n"){d=q(d);e.push(d,";");e.cr()}else e.push(d,";");break;case f.cleanLeft:e.push("___v1ew.push(","(jQuery.EJS.clean(",d,")));");break;case f.eLeft:e.push("___v1ew.push(","(jQuery.EJS.text(",d,")));");break;case f.eeLeft:e.push("___v1ew.push(","(jQuery.EJS.text(",d,")));");break}i=null;k();break;case f.dRight:d+=f.right;break;default:d+=h;break}});d.length> 0&&e.push("___v1ew.push(",'"',m(d)+'");');a={out:"try { with(_VIEW) { with (_CONTEXT) {"+e.close()+" return ___v1ew.join('');}}}catch(e){e.lineNumber=null;throw e;}"};p.call(a,"this.process = (function(_CONTEXT,_VIEW){"+a.out+"});\r\n//@ sourceURL="+c+".js");return a};EJS.Buffer=function(a,b){this.line=[];this.script=[];this.post=b;this.push.apply(this,a)};EJS.Buffer.prototype={push:function(){this.line.push.apply(this.line,arguments)},cr:function(){this.script.push(this.line.join(""),"\n");this.line= []},close:function(){if(this.line.length>0){this.script.push(this.line.join(""));this.line=[]}this.post.length&&this.push.apply(this,this.post);this.script.push(";");return this.script.join("")}};EJS.options={type:"<",ext:".ejs"};EJS.Helpers=function(a,b){this._data=a;this._extras=b;j(this,b)};EJS.Helpers.prototype={plugin:function(){var a=g.makeArray(arguments),b=a.shift();return function(c){c=g(c);c[b].apply(c,a)}},view:function(a,b,c){c=c||this._extras;b=b||this._data;return g.View(a,b,c)}};g.View.register({suffix:"ejs", script:function(a,b){return"jQuery.EJS(function(_CONTEXT,_VIEW) { "+(new EJS({text:b})).template.out+" })"},renderer:function(a,b){var c=new EJS({text:b,name:a});return function(e,d){return c.render.call(c,e,d)}}})})(jQuery);