tinyMCEPopup.requireLangPack();var TemplateDialog={preInit:function(){var b=tinyMCEPopup.getParam("template_external_list_url");if(b!=null){document.write('<script language="javascript" type="text/javascript" src="'+tinyMCEPopup.editor.documentBaseURI.toAbsolute(b)+'"><\/script>')}},init:function(){var j=tinyMCEPopup.editor,f,h,g,i;f=j.getParam("template_templates",false);h=document.getElementById("tpath");if(!f&&typeof(tinyMCETemplateList)!="undefined"){for(g=0,f=[];g<tinyMCETemplateList.length;g++){f.push({title:tinyMCETemplateList[g][0],src:tinyMCETemplateList[g][1],description:tinyMCETemplateList[g][2]})}}for(g=0;g<f.length;g++){h.options[h.options.length]=new Option(f[g].title,tinyMCEPopup.editor.documentBaseURI.toAbsolute(f[g].src))}this.resize();this.tsrc=f},resize:function(){var e,d,f;if(!self.innerWidth){e=document.body.clientWidth-50;d=document.body.clientHeight-160}else{e=self.innerWidth-50;d=self.innerHeight-170}f=document.getElementById("templatesrc");if(f){f.style.height=Math.abs(d)+"px";f.style.width=Math.abs(e-5)+"px"}},loadCSSFiles:function(c){var d=tinyMCEPopup.editor;tinymce.each(d.getParam("content_css","").split(","),function(a){c.write('<link href="'+d.documentBaseURI.toAbsolute(a)+'" rel="stylesheet" type="text/css" />')})},selectTemplate:function(j,i){var h=window.frames.templatesrc.document,g,d=this.tsrc;if(!j){return}h.body.innerHTML=this.templateHTML=this.getFileContents(j);for(g=0;g<d.length;g++){if(d[g].title==i){document.getElementById("tmpldesc").innerHTML=d[g].description||""}}},insert:function(){tinyMCEPopup.execCommand("mceInsertTemplate",false,{content:this.templateHTML,selection:tinyMCEPopup.editor.selection.getContent()});tinyMCEPopup.close()},getFileContents:function(d){var g,h,j="text/plain";function i(a){g=0;try{g=new ActiveXObject(a)}catch(a){}return g}g=window.ActiveXObject?i("Msxml2.XMLHTTP")||i("Microsoft.XMLHTTP"):new XMLHttpRequest();g.overrideMimeType&&g.overrideMimeType(j);g.open("GET",d,false);g.send(null);return g.responseText}};TemplateDialog.preInit();tinyMCEPopup.onInit.add(TemplateDialog.init,TemplateDialog);