(function(){var b=tinymce.each;tinymce.create("tinymce.plugins.TemplatePlugin",{init:function(a,f){var e=this;e.editor=a;a.addCommand("mceTemplate",function(c){a.windowManager.open({file:f+"/template.htm",width:a.getParam("template_popup_width",750),height:a.getParam("template_popup_height",600),inline:1},{plugin_url:f})});a.addCommand("mceInsertTemplate",e._insertTemplate,e);a.addButton("template",{title:"template.desc",cmd:"mceTemplate"});a.onPreProcess.add(function(h,c){var d=h.dom;b(d.select("div",c.node),function(g){if(d.hasClass(g,"mceTmpl")){b(d.select("*",g),function(j){if(d.hasClass(j,h.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))){j.innerHTML=e._getDateTime(new Date(),h.getParam("template_mdate_format",h.getLang("template.mdate_format")))}});e._replaceVals(g)}})})},getInfo:function(){return{longname:"Template plugin",author:"Moxiecode Systems AB",authorurl:"http://www.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/template",version:tinymce.majorVersion+"."+tinymce.minorVersion}},_insertTemplate:function(l,h){var a=this,m=a.editor,o,r,q=m.dom,s=m.selection.getContent();o=h.content;b(a.editor.getParam("template_replace_values"),function(c,d){if(typeof(c)!="function"){o=o.replace(new RegExp("\\{\\$"+d+"\\}","g"),c)}});r=q.create("div",null,o);n=q.select(".mceTmpl",r);if(n&&n.length>0){r=q.create("div",null);r.appendChild(n[0].cloneNode(true))}function p(c,d){return new RegExp("\\b"+d+"\\b","g").test(c.className)}b(q.select("*",r),function(c){if(p(c,m.getParam("template_cdate_classes","cdate").replace(/\s+/g,"|"))){c.innerHTML=a._getDateTime(new Date(),m.getParam("template_cdate_format",m.getLang("template.cdate_format")))}if(p(c,m.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))){c.innerHTML=a._getDateTime(new Date(),m.getParam("template_mdate_format",m.getLang("template.mdate_format")))}if(p(c,m.getParam("template_selected_content_classes","selcontent").replace(/\s+/g,"|"))){c.innerHTML=s}});a._replaceVals(r);m.execCommand("mceInsertContent",false,r.innerHTML);m.addVisual()},_replaceVals:function(f){var e=this.editor.dom,a=this.editor.getParam("template_replace_values");b(e.select("*",f),function(c){b(a,function(d,h){if(e.hasClass(c,h)){if(typeof(a[h])=="function"){a[h](c)}}})})},_getDateTime:function(d,a){if(!a){return""}function f(c,h){var e;c=""+c;if(c.length