/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/

(function(){CKEDITOR.plugins.add('readmore',{requires:['fakeobjects','htmldataprocessor'],init:function(a){a.addCommand('readmore',{exec:function(){var c=a.document.getElementsByTag('img');for(var d=0,e=c.count();d<e;d++){var f=c.getItem(d);if(f.hasClass('cke_wygwam_read_more')){if(confirm('This entry already contains a "Read More" break.  Would you like to remove it and place a new one here?')){f.remove();break;}else return;}}b('read_more');}});a.ui.addButton('ReadMore',{label:'Read More',command:'readmore'});a.addCss('img.cke_wygwam_read_more{background-image: url('+CKEDITOR.getUrl(this.path+'images/readmore.gif')+');'+'background-position: left bottom;'+'background-repeat: no-repeat;'+'clear: both;'+'display: block;'+'float: none;'+'width:100% !important; _width:99.9% !important;'+'border-top: #CCC 1px dotted;'+'height: 9px !important;'+'}');function b(c){if(!CKEDITOR.dom.comment.prototype.getAttribute){CKEDITOR.dom.comment.prototype.getAttribute=function(){return '';};CKEDITOR.dom.comment.prototype.attributes={align:''};}var d=a.createFakeElement(new CKEDITOR.dom.comment(c),'cke_wygwam_'+c,'hr'),e=a.getSelection().getRanges()[0],f=new CKEDITOR.dom.elementPath(e.getCommonAncestor(true)),g=f.block&&f.block.getParent()||f.blockLimit,h;while(g&&g.getName()!='body'){e.moveToPosition(g,4);h=1;g=g.getParent();}if(!h)e.splitBlock('p');e.insertNode(d);var i=d;while((i=i.getNext())&&!e.moveToElementEditStart(i)){}};},afterInit:function(a){a.dataProcessor.dataFilter.addRules({comment:function(b){if(!CKEDITOR.htmlParser.comment.prototype.getAttribute){CKEDITOR.htmlParser.comment.prototype.getAttribute=function(){return '';};CKEDITOR.htmlParser.comment.prototype.attributes={align:''};}if(b=='read_more')return a.createFakeParserElement(new CKEDITOR.htmlParser.comment(b),'cke_wygwam_'+b,'hr');return b;}});}});})();
