!function(t,e){var n={},r={getFormattedDateString:function(t,e){return e=e||"MMMM yyyy",new Date(t).toLocaleDateString(e)}};t.fn.loadTemplate=function(e,a,o){function c(e,n){i(e,n),f.each(function(){t(this).html(e.html())}),"function"==typeof s.complete&&s.complete()}function i(e,n){function a(n,r,a,o){t("["+n+"]",e).each(function(e,c){var i=t(c).attr(n);t(c).removeAttr(n),r[i]&&a?a(t(c),r[i]):o&&o(t(c))})}function o(t,e,n){var a=t.attr("data-format-target");if(a==n||!a&&"content"==n){var o=t.attr("data-format");if(o&&"function"==typeof r[o]){var c=t.attr("data-format-template");return r[o](e,c)}}return e}a("data-content",n=n||{},function(t,e){t.html(o(t,e,"content"))}),a("data-src",n,function(t,e){t.attr("src",o(t,e,"src"))},function(t){t.remove()}),a("data-alt",n,function(t,e){t.attr("alt",o(t,e,"alt"))}),a("data-link",n,function(e,n){var r=t("");r.attr("href",o(e,n,"link")),r.html(e.html()),e.html(r)}),a("data-link-wrap",n,function(e,n){var r=t("");r.attr("href",o(e,n,"link-wrap")),e.wrap(r)})}var f=this,s=t.extend({overwriteCache:!1,complete:null,success:null,error:function(){f.each(function(){t(this).html(s.errorMessage)})},errorMessage:"There was an error loading the template."},o);if(!function(t){return"string"==typeof t&&t.indexOf("/")>-1}(e))var u=t(e);var l=s.isFile||void 0===s.isFile&&(!u||0==u.length);if(l&&!s.overwriteCache&&n[e])c(m=n[e],a),"function"==typeof s.success&&s.success();else if(l)(m=t("
")).load(e,function(t,r,o){"error"==r?("function"==typeof s.error&&s.error(),"function"==typeof s.complete&&s.complete()):(n[e]=m,c(m,a),"success"==r&&"function"==typeof s.success&&s.success())});else{var m=t("");u.is("script")&&(u=t.parseHTML(u.html().trim())),m.html(u),c(m,a),"function"==typeof s.success&&s.success()}return this},t.addTemplateFormatter=function(e,n){n?r[e]=n:r=t.extend(r,e)}}(jQuery);