(function(a){a.plugins.Safari2x=function(h){var k=a.each,l=a.Event,g,f,j;if(!a.isOldWebKit){return}h.selection.getRng=function(){var n=this,o=n.getSel(),w=h.getDoc(),q,u,v,p;if(o.anchorNode){q=w.createRange();try{u=w.createRange();u.setStart(o.anchorNode,o.anchorOffset);u.collapse(1);v=w.createRange();v.setStart(o.focusNode,o.focusOffset);v.collapse(1);p=u.compareBoundaryPoints(u.START_TO_END,v)<0;q.setStart(p?o.anchorNode:o.focusNode,p?o.anchorOffset:o.focusOffset);q.setEnd(p?o.focusNode:o.anchorNode,p?o.focusOffset:o.anchorOffset)}catch(m){}}return q};f=h.selection.setContent;h.selection.setContent=function(o,n){var p=this.getRng();try{f.call(this,o,n)}catch(m){b=h.dom.create("body");b.innerHTML=o;k(b.childNodes,function(q){p.insertNode(q.cloneNode(true))})}};j=h.selection.collapse;h.selection.collapse=function(m){try{j.call(this,m)}catch(n){}};h.onInit.add(function(){a.DOM.get(h.settings.id+"_r").style.display="none"});h.onPreInit.add(function(){l.add(h.getDoc(),"click",function(m){if(m.target.nodeName=="A"){h.selection.select(m.target);return l.cancel(m)}});l.add(h.getDoc(),"keydown",function(q){var m=h.selection,v,t,p,u;if(q.charCode>32||q.keyCode==13){v=h.dom.getParent(m.getNode(),function(o){return o.nodeName=="LI"});if(v){t=m.getRng().startOffset;if(q.keyCode==13){if(!v.hasChildNodes()){if(!v.nextSibling||v.nextSibling.nodeName!="LI"){p=h.dom.getParent(m.getNode(),function(o){return/(UL|OL)/.test(o.nodeName)});v.parentNode.removeChild(v);m.select(p.nextSibling);return}return l.cancel(q)}u=h.getDoc().createTextNode("\u00a0");v.appendChild(u);window.setTimeout(function(){var o=m.getNode();if(o.firstChild&&o.firstChild.nodeValue.charAt(0)=="\u00a0"){o.removeChild(o.firstChild);m.select(o)}},1)}else{u=String.fromCharCode(q.charCode);if(!/^\w$/.test(u)){return}m.setContent(u);p=m.getRng();m=m.getSel();v=m.anchorNode;if(v.nodeName=="LI"){m.setBaseAndExtent(v,1,v,1)}else{v=v.nextSibling;m.setBaseAndExtent(v,1,v,1)}return l.cancel(q)}}}})});function c(t,m){var q=h.getDoc(),p,o;m=m||{};q.execCommand("FontName",false,"_tmp");k(h.dom.select("span"),function(n){if(n.style.fontFamily=="_tmp"){p=d(n,t,m);if(!o){o=p}}});p=p.firstChild;h.selection.getSel().setBaseAndExtent(o,0,p,p.nodeValue.length)}function i(p){var o=h.selection,m;o.setContent("<"+p+'>
'+p+">");m=h.dom.get("_tmp");m.id="";o.select(m);o.collapse(1)}function e(m){return h.dom.getParent(m,function(o){return/^(H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CODE|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(o.nodeName)})}function d(p,s,m){var q=h.getDoc(),o;m=m||{};o=q.createElement(s);k(p.attributes,function(t){if(t.specified&&t.nodeValue){o.setAttribute(t.nodeName,t.nodeValue)}});k(m,function(t,n){o.setAttribute(n,t)});k(p.childNodes,function(t){o.appendChild(t.cloneNode(true))});p.parentNode.replaceChild(o,p);return o}a.extend(h.commands,{IncreaseFontSize:function(){var n=h.getDoc(),m=parseInt(n.queryCommandValue("FontSize"));n.execCommand("FontSize",false,(m+1)+"px")},DecreaseFontSize:function(){var n=h.getDoc(),m=parseInt(n.queryCommandValue("FontSize"));if(m>0){n.execCommand("FontSize",false,(m-1)+"px")}},Strikethrough:function(){c("strike")},CreateLink:function(n,m){c("a",{href:m,mce_href:m})},Unlink:function(){var m=h.selection;m.setContent(m.getContent().replace(/(]+>|<\/a>)/,""))},RemoveFormat:function(){var m=h.selection;m.setContent(m.getContent().replace(/(<(span|b|i|strong|em|strike) [^>]+>|<(span|b|i|strong|em|strike)>|<\/(span|b|i|strong|em|strike)>|)/g,""))},FormatBlock:function(o,m){var p=h.selection,q;q=e(h.selection.getNode());if(q){r=d(q,m.replace(/<|>/g,""))}p.select(r);p.collapse(1)},InsertUnorderedList:function(){i("ul")},InsertOrderedList:function(){i("ol")},Indent:function(){var o=e(h.selection.getNode()),m;if(o){m=parseInt(o.style.paddingLeft)||0;o.style.paddingLeft=(m+10)+"px"}},Outdent:function(){var o=e(h.selection.getNode()),m;if(o){m=parseInt(o.style.paddingLeft)||0;if(m>=10){o.style.paddingLeft=(m-10)+"px"}}}})}})(punymce);