(function(){var each=tinymce.each;tinymce.create('tinymce.plugins.ArticlePlugin',{init:function(ed,url){var t=this;t.editor=ed;t.url=url;function isReadMore(n){return n.nodeName=='IMG'&&ed.dom.hasClass(n,'mceItemReadMore')};function isPageBreak(n){return n.nodeName=='IMG'&&ed.dom.hasClass(n,'mceItemPageBreak')};ed.addCommand('mceReadMore',function(){if(ed.dom.get('system-readmore')){alert(ed.getLang('article.readmore_alert','There is already a Read More break inserted in this article. Only one such break is permitted. Use a Pagebreak to split the page up further.'));return false}t._insertBreak('readmore',{id:'system-readmore'})});ed.addCommand('mcePageBreak',function(ui,v){if(ui){ed.windowManager.open({file:url+'/pagebreak.htm',width:400,height:100,inline:1},{plugin_url:url})}else{tinymce.extend(v,{'id':'system-pagebreak'});t._insertBreak('pagebreak',v)}});if(ed.getParam('article_readmore',true)){ed.addButton('readmore',{title:'article.readmore',cmd:'mceReadMore',image:url+'/img/readmore.gif'})}if(ed.getParam('article_pagebreak',true)){ed.addButton('pagebreak',{title:'article.pagebreak',cmd:'mcePageBreak',image:url+'/img/pagebreak.gif',ui:true})}ed.onInit.add(function(){ed.dom.loadCSS(url+"/css/content.css");if(ed.getParam('article_hide_xtd_btns')){tinymce.DOM.hide(ed.dom.select('div.readmore, div.pagebreak',tinymce.DOM.get('editor-xtd-buttons')))}});ed.onNodeChange.add(function(ed,cm,n){cm.setActive('readmore',isReadMore(n));cm.setActive('pagebreak',isPageBreak(n))});ed.onSetContent.add(function(ed,o){var dom=ed.dom,body=ed.getBody(),p,b;each(dom.select('HR',body),function(n){if(ed.dom.getAttrib(n,'id')=='system-readmore'||ed.dom.hasClass(n,'system-pagebreak')){dom.replace(t._createImg(n),n)}})});ed.onPreProcess.add(function(ed,o){var dom=ed.dom;if(o.get){each(dom.select('IMG',o.node),function(n){if(isReadMore(n)||isPageBreak(n)){dom.replace(t._buildHR(n),n)}})}});ed.onPostProcess.add(function(ed,o){if(o.get){o.content=o.content.replace(/mce_alt=/g,'alt=');if(ed.getParam('forced_root_block')){o.content=o.content.replace(/<(p|div)>[\s\n]*?<hr([\s\S]+)(id|class)="system-(readmore|pagebreak)"([^>]+?)>[\s\n]*?<\/(p|div)>/gi,'<hr$2$3="system-$4"$5>')}}})},_insertBreak:function(s,args){var t=this,ed=this.editor,n=ed.selection.getNode(),ns,h,c,re,isBlock=false,desc='';var bElm='P,DIV,ADDRESS,PRE,FORM,TABLE,OL,UL,CAPTION,BLOCKQUOTE,CENTER,DL,DIR,FIELDSET,NOSCRIPT,NOFRAMES,MENU,ISINDEX,SAMP';n=ed.dom.getParent(n,bElm,'BODY')||n;tinymce.extend(args,{src:t.url+'/img/trans.gif','class':s=='pagebreak'?'mceItemPageBreak mceItemNoResize':'mceItemReadMore mceItemNoResize'});ed.execCommand('mceInsertContent',false,'<img id="__mce_tmp" src="javascript:;" />',{skip_undo:1});img=ed.dom.get('__mce_tmp');ed.dom.setAttribs('__mce_tmp',args);img.setAttribute('_mce_type','system-'+s);if(ed.dom.isBlock(n)){p=ed.dom.getParent(img,bElm,'BODY');if(n.nodeName=='P'||n.nodeName=='DIV'){ed.dom.split(n,img);ns=img.nextSibling;if(ns&&ns.nodeName==n.nodeName){h=tinymce.trim(ns.innerHTML);if(h==''||h=='<br>'){ed.dom.remove(ns)}}}else{if(p){if(p.parentNode.nodeName=='BODY'){ed.dom.insertAfter(img,n)}else{p.insertBefore(img,n)}}else{if(n.parentNode.nodeName=='BODY'){ed.dom.insertAfter(img,n)}else{n.parentNode.insertBefore(img,n)}}p=img.parentNode;while(/^(ADDRESS|PRE|FORM|TABLE|OL|UL|CAPTION|BLOCKQUOTE|CENTER|DL|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(p.nodeName)){p.parentNode.insertBefore(img,p);p=img.parentNode}}ns=img.nextSibling;if(!ns){var el=ed.getParam('forced_root_block')||(ed.getParam('force_p_newlines')?'p':'br');ns=ed.dom.create(el);if(el!='br'){ns.innerHTML='\u00a0'}ed.dom.insertAfter(ns,img);s=ed.selection.select(ns);ed.selection.collapse(1)}}ed.dom.setAttrib(ed.dom.get('system-pagebreak'),'id','')},_buildHR:function(n){var ed=this.editor,dom=ed.dom,args;if(dom.hasClass(n,'mceItemPageBreak')){args={title:dom.getAttrib(n,'title'),mce_alt:dom.getAttrib(n,'alt'),'class':'system-pagebreak'}}else{args={id:'system-readmore'}}return dom.create('hr',args)},_createImg:function(n){var ed=this.editor,dom=ed.dom,t=this,args;args={src:t.url+'/img/trans.gif','class':'mceItemReadMore'};if(dom.hasClass(n,'system-pagebreak')){tinymce.extend(args,{'class':'mceItemPageBreak',title:dom.getAttrib(n,'title',''),alt:dom.getAttrib(n,'alt',''),'_mce_type':'system-pagebreak'})}else{tinymce.extend(args,{id:'system-readmore',alt:ed.getLang('article.readmore_title',ed.getLang('article.readmore_title','Read More')),title:ed.getLang('article.readmore_title',ed.getLang('article.readmore_title','Read More')),'_mce_type':'system-readmore'})}return dom.create('img',args)},getInfo:function(){return{longname:'Article',author:'Ryan Demmer',authorurl:'http://www.joomlacontenteditor.net',infourl:'http://www.joomlacontenteditor.net',version:'1.5.7.9'}}});tinymce.PluginManager.add('article',tinymce.plugins.ArticlePlugin)})();