(function(){tinymce.create('tinymce.plugins.CodeprotectPlugin',{init:function(ed,url){var t=this;t.editor=ed;t.url=url;ed.onBeforeSetContent.add(function(ed,o){var startPos=0;var endPos=0;var startTag="<?";var endTag="?>";var running=true;while((running==true)&&(o.content.indexOf(startTag)!=-1)){startPos=o.content.indexOf(startTag);endPos=o.content.indexOf(endTag);if(endPos!=-1){encodedPHPCode=escape(o.content.substr(startPos+startTag.length,endPos-(startPos+startTag.length)));o.content=o.content.substr(0,startPos)+'<img src="'+url+'/img/codeprotect.gif'+'" border="0" alt="'+encodedPHPCode+'" />'+o.content.substr(endPos+endTag.length)}else{running=false}}o.content=o.content.replace(/&amp;quot;mceNonEditable&amp;quot;/gi,"mceNonEditable");o.content=o.content.replace(/'/gi,"'");o.content=o.content.replace(/&quot;/gi,'"')});ed.onPostProcess.add(function(ed,o){if(o.get){var startPos=0;var endPos=0;var startTag='<img src="'+url+'/img/codeprotect.gif'+'" border="0" alt="';var endTag='" />';var running=true;while((running==true)&&(o.content.indexOf(startTag)!=-1)){startPos=o.content.indexOf(startTag);endPos=o.content.indexOf(endTag,startPos);if(endPos!=-1){encodedPHPCode=o.content.substr(startPos+startTag.length,endPos-(startPos+startTag.length));decodedPHPCode=unescape(encodedPHPCode);o.content=o.content.substr(0,startPos)+"<?"+decodedPHPCode+"?>"+o.content.substr(endPos+endTag.length)}else{running=false}}o.content=o.content.replace(/&lt;\?/gi,"<?");o.content=o.content.replace(/\?&gt;/gi,"?>");o.content=o.content.replace(/&amp;quot;mceNonEditable&amp;quot;/gi,"mceNonEditable");o.content=o.content.replace(/'/gi,"'");o.content=o.content.replace(/&quot;/gi,'"')}})},getInfo:function(){return{longname:'CodeProtect plugin',author:'Ben Hitchcock (Updated from original by Tijmen Schep)',authorurl:'http://www.hotpebble.com',infourl:'',version:"1.2.1"}}});tinymce.PluginManager.add('codeprotect',tinymce.plugins.CodeprotectPlugin)})();