/* KindEditor 4.0 beta (2011-08-17), Copyright (C) kindsoft.net, Licence: http://www.kindsoft.net/license.php */(function(A,m){function ca(a){if(!a)return!1;return Object.prototype.toString.call(a)==="[object Array]"}function Ua(a){if(!a)return!1;return Object.prototype.toString.call(a)==="[object Function]"}function I(a,b){for(var c=0,d=b.length;c=0}function s(a){return a&&/^\d+$/.test(a)?a+"px":a}function w(a){var b;return a&&(b=/(\d+)/.exec(a))?parseInt(b[1],10):0}function Va(a){return a.replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}function da(a){var b=a.split("-"),a="";k(b,function(b,d){a+=b>0?d.charAt(0).toUpperCase()+d.substr(1):d});return a}function ma(a){function b(a){a=parseInt(a,10).toString(16).toUpperCase();return a.length>
1?a:"0"+a}return a.replace(/rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/ig,function(a,d,e,g){return"#"+b(d)+b(e)+b(g)})}function v(a,b){var b=b===m?",":b,c={},d=ca(a)?a:a.split(b),e;k(d,function(a,b){if(e=/^(\d+)\.\.(\d+)$/.exec(b))for(var d=parseInt(e[1],10);d<=parseInt(e[2],10);d++)c[d.toString()]=!0;else c[b]=!0});return c}function Aa(a,b){return Array.prototype.slice.call(a,b||0)}function o(a,b){return a===m?b:a}function C(a,b,c){c||(c=b,b=null);var d;if(b){var e=function(){};e.prototype=b.prototype;
d=new e;k(c,function(a,b){d[a]=b})}else d=c;d.constructor=a;a.prototype=d;a.parent=b?b.prototype:null}function Wa(a){var b;if(b=/\{[\s\S]*\}|\[[\s\S]*\]/.exec(a))a=b[0];b=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;b.lastIndex=0;b.test(a)&&(a=a.replace(b,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return eval("("+a+")");throw"JSON parse error";}function Hb(a,b,c){a.addEventListener?a.addEventListener(b,c,Xa):a.attachEvent&&a.attachEvent("on"+b,c)}function na(a,b,c){a.removeEventListener?a.removeEventListener(b,c,Xa):a.detachEvent&&a.detachEvent("on"+b,c)}function Ya(a,b){this.init(a,b)}function Za(a){try{delete a[W]}catch(b){a.removeAttribute&&a.removeAttribute(W)}}function X(a,b,c){if(b.indexOf(",")>=0)k(b.split(","),function(){X(a,this,c)});else{var d=
a[W]||null;d||(a[W]=++$a,d=$a);t[d]===m&&(t[d]={});var e=t[d][b];e&&e.length>0?na(a,b,e[0]):(t[d][b]=[],t[d].el=a);e=t[d][b];e.length===0&&(e[0]=function(b){var c=b?new Ya(a,b):m;k(e,function(b,d){b>0&&d&&d.call(a,c)})});I(c,e)<0&&e.push(c);Hb(a,b,e[0])}}function M(a,b,c){if(b&&b.indexOf(",")>=0)k(b.split(","),function(){M(a,this,c)});else{var d=a[W]||null;if(d)if(b===m)d in t&&(k(t[d],function(b,c){b!="el"&&c.length>0&&na(a,b,c[0])}),delete t[d],Za(a));else if(t[d]){var e=t[d][b];if(e&&e.length>
0){c===m?(na(a,b,e[0]),delete t[d][b]):(k(e,function(a,b){a>0&&b===c&&e.splice(a,1)}),e.length==1&&(na(a,b,e[0]),delete t[d][b]));var g=0;k(t[d],function(){g++});g<2&&(delete t[d],Za(a))}}}}function ab(a,b){if(b.indexOf(",")>=0)k(b.split(","),function(){ab(a,this)});else{var c=a[W]||null;if(c){var d=t[c][b];if(t[c]&&d&&d.length>0)d[0]()}}}function Ba(a,b,c){b=/^\d{2,}$/.test(b)?b:b.toUpperCase().charCodeAt(0);X(a,"keydown",function(d){d.ctrlKey&&d.which==b&&!d.shiftKey&&!d.altKey&&(c.call(a),d.stop())})}
function oa(a){for(var b={},c=/\s*([\w\-]+)\s*:([^;]*)(;|$)/g,d;d=c.exec(a);){var e=B(d[1].toLowerCase());d=B(ma(d[2]));b[e]=d}return b}function N(a){for(var b={},c=/\s+(?:([\w\-:]+)|(?:([\w\-:]+)=([^\s"'<>]+))|(?:([\w\-:"]+)="([^"]*)")|(?:([\w\-:"]+)='([^']*)'))(?=(?:\s|\/|>)+)/g,d;d=c.exec(a);){var e=(d[1]||d[2]||d[4]||d[6]).toLowerCase();b[e]=(d[2]?d[3]:d[4]?d[5]:d[7])||""}return b}function Ib(a,b){return a=/\s+class\s*=/.test(a)?a.replace(/(\s+class=["']?)([^"']*)(["']?[\s>])/,function(a,d,e,
g){return(" "+e+" ").indexOf(" "+b+" ")<0?e===""?d+b+g:d+e+" "+b+g:a}):a.substr(0,a.length-1)+' class="'+b+'">'}function Jb(a){var b="";k(oa(a),function(a,d){b+=a+":"+d+";"});return b}function bb(a,b,c,d){function e(a){for(var a=a.split("/"),b=[],c=0,d=a.length;c0&&b.pop():e!==""&&e!="."&&b.push(e)}return"/"+b.join("/")}function g(b,c){if(a.substr(0,b.length)===b){for(var e=[],f=0;f0&&(f+="/"+e.join("/"));d=="/"&&(f+="/");return f+
a.substr(b.length)}else if(h=/^(.*)\//.exec(b))return g(h[1],++c)}b=o(b,"").toLowerCase();if(I(b,["absolute","relative","domain"])<0)return a;c=c||location.protocol+"//"+location.host;if(d===m)var f=location.pathname.match(/^(\/.*)\//),d=f?f[1]:"";var h;if(h=/^(\w+:\/\/[^\/]*)/.exec(a)){if(h[1]!==c)return a}else if(/^\w+:/.test(a))return a;/^\//.test(a)?a=c+e(a.substr(1)):/^\w+:\/\//.test(a)||(a=c+e(d+"/"+a));b==="relative"?a=g(c+d,0).substr(2):b==="absolute"&&a.substr(0,c.length)===c&&(a=a.substr(c.length));
return a}function Y(a,b,c,d,e){var c=c||"",d=o(d,!1),e=o(e,"\t"),f="xx-small,x-small,small,medium,large,x-large,xx-large".split(","),a=a.replace(/(<(?:pre|pre\s[^>]*)>)([\s\S]*?)(<\/pre>)/ig,function(a,b,c,d){return b+c.replace(/<(?:br|br\s[^>]*)>/ig,"\n")+d}),a=a.replace(/<(?:br|br\s[^>]*)\s*\/?>\s*<\/p>/ig,"
"),a=a.replace(/(<(?:p|p\s[^>]*)>)\s*(<\/p>)/ig,function(a,b,c){return b+" "+c}),a=a.replace(/\u200B/g,""),i={};b&&k(b,function(a,b){for(var c=a.split(","),d=0,e=c.length;d]+)|(?:\s+[\w\-:"]+="[^"]*")|(?:\s+[\w\-:"]+='[^']*'))*)(\/)?>(\s*)/g,function(a,l,p,q,J,m,D){var l=l||"",p=p||"",r=q.toLowerCase(),n=J||"",q=m?" "+m:"",D=D||"";if(b&&!i[r])return"";q===""&&cb[r]&&(q=" /");db[r]&&(l&&(l=" "),D&&(D=" "));Ca[r]&&(p?D="\n":l="\n");d&&r=="br"&&(D="\n");if(eb[r]&&!Ca[r])if(d){p&&h.length>0&&h[h.length-1]===r?h.pop():h.push(r);D=l="\n";J=0;for(m=p?h.length:h.length-1;J=0&&(u[a]=bb(d,c));(b&&a!=="style"&&!i[r]["*"]&&!i[r][a]||
r==="body"&&a==="contenteditable"||/^kindeditor_\d+$/.test(a))&&delete u[a];if(a==="style"&&d!==""){var e=oa(d);k(e,function(a){b&&!i[r].style&&!i[r]["."+a]&&delete e[a]});var f="";k(e,function(a,b){f+=a+":"+b+";"});u.style=f}});n="";k(u,function(a,b){a==="style"&&b===""||(n+=" "+a+'="'+b+'"')})}r==="font"&&(r="span");return l+"<"+p+r+n+q+">"+D}),a=a.replace(/(<(?:pre|pre\s[^>]*)>)([\s\S]*?)(<\/pre>)/ig,function(a,b,c,d){return b+c.replace(/\n/g,'\n')+d}),a=a.replace(/\n\s*\n/g,
"\n"),a=a.replace(/\n/g,"\n");return B(a)}function fb(a){if(/\.(rm|rmvb)(\?|$)/i.test(a))return"audio/x-pn-realaudio-plugin";if(/\.(swf|flv)(\?|$)/i.test(a))return"application/x-shockwave-flash";return"video/x-ms-asf-plugin"}function gb(a){return N(unescape(a))}function Da(a){var b="";return b}function hb(a,b){var c=b.width,d=b.height,e=b.type||fb(b.src),f=Da(b),i="";c>0&&(i+="width:"+c+"px;");d>0&&(i+="height:"+
d+"px;");c=/realaudio/i.test(e)?"ke-rm":/flash/i.test(e)?"ke-flash":"ke-media";c='';return c}function pa(a,b){if(a.nodeType==9&&b.nodeType!=9)return!0;for(;b=b.parentNode;)if(b==a)return!0;return!1}function qa(a,b){var b=b.toLowerCase(),c=null;if(n&&F<8){var d=a.ownerDocument.createElement("div");d.appendChild(a.cloneNode(!1));d=N(d.innerHTML.toLowerCase());b in d&&(c=d[b])}else c=a.getAttribute(b,
2);b==="style"&&c!==null&&(c=Jb(c));return c}function ra(a,b){function c(a){if(typeof a!="string")return a;return a.replace(/([^\w\-])/g,"\\$1")}function d(a,b){return a==="*"||a.toLowerCase()===c(b.toLowerCase())}function e(a,b,c){var e=[];(a=(c.ownerDocument||c).getElementById(a.replace(/\\/g,"")))&&d(b,a.nodeName)&&pa(c,a)&&e.push(a);return e}function f(a,b,c){var e=c.ownerDocument||c,h=[],g,j,i;if(c.getElementsByClassName){e=c.getElementsByClassName(a.replace(/\\/g,""));g=0;for(j=e.length;g-1&&h.push(i)}return h}function i(a,b,d,e){for(var f=[],d=e.getElementsByTagName(d),g=0,h=d.length;g])+)/.exec(a))?h[1]:"*";if(h=/#((?:[\w\-]|\\.)+)$/.exec(a))c=e(h[1],j,b);else if(h=/\.((?:[\w\-]|\\.)+)$/.exec(a))c=f(h[1],j,b);else if(h=/\[((?:[\w\-]|\\.)+)\]/.exec(a))c=i(h[1].toLowerCase(),null,j,b);else if(h=/\[((?:[\w\-]|\\.)+)\s*=\s*['"]?((?:\\.|[^'"]+)+)['"]?\]/.exec(a)){c=h[1].toLowerCase();h=h[2];if(c==="id")j=e(h,j,b);else if(c==="class")j=f(h,j,b);else if(c==="name"){c=[];h=(b.ownerDocument||b).getElementsByName(h.replace(/\\/g,
""));for(var l,q=0,p=h.length;q1){var l=[];k(j,function(){k(ra(this,b),function(){I(this,l)<0&&l.push(this)})});return l}for(var b=b||document,j=[],p,q=/((?:\\.|[^\s>])+|[\s>])/g;p=q.exec(a);)p[1]!==" "&&j.push(p[1]);p=[];if(j.length==1)return h(j[0],b);var q=!1,J,
m,n,r,o,u,K,E,s,t;u=0;for(lenth=j.length;u")q=!0;else{if(u>0){m=[];K=0;for(s=p.length;K0?g.splitText(e):g,f0&&(i=d.splitText(e),a.setStart(d,e));f=0&&p<=0&&(p=o.compareBoundaryPoints(ha,a));p>=0&&q<=0&&(q=o.compareBoundaryPoints($,a));q>=0&&k<=0&&(k=o.compareBoundaryPoints(ia,a));if(k>=0)return!1;o=n.nextSibling;if(l>0)if(n.nodeType==1)if(p>=0&&q<=0)b&&m.appendChild(n.cloneNode(!0)),c&&h.push(n);else{var r;b&&(r=n.cloneNode(!1),m.appendChild(r));if(f(n,r)===!1)return!1}else if(n.nodeType==3&&(n=n==j.startContainer?d(n,j.startOffset,n.nodeValue.length):n==j.endContainer?d(n,0,j.endOffset):d(n,0,n.nodeValue.length),
b))try{m.appendChild(n)}catch(D){}n=o}}var i=a.doc,h=[],j=a.cloneRange().down(),l=-1,p=-1,q=-1,k=-1,m=a.commonAncestor(),n=i.createDocumentFragment();if(m.nodeType==3)return m=d(m,a.startOffset,a.endOffset),b&&n.appendChild(m),e(),b?n:a;f(m,n);c&&a.up().collapse(!0);for(var m=0,r=h.length;m0?h+=n.text.replace(/\r\n|\n|\r/g,"").length:h=0;m&&f(m).remove()}else k.nodeType==3&&(l.moveStart("character",k.nodeValue.length),h+=k.nodeValue.length);j<0&&(i=k)}if(j<0&&i.nodeType==1)return{node:e,offset:f(e.lastChild).index()+1};if(j>0)for(;i.nodeType==1;)i=i.nextSibling;l=a.duplicate();ja(l,e);l.setEndPoint("StartToEnd",d);h-=l.text.replace(/\r\n|\n|\r/g,"").length;return{node:i,offset:h}}function kb(a,b){var c=a.ownerDocument||a,d=c.body.createTextRange();
if(c==a)return d.collapse(!0),d;if(a.nodeType==1&&a.childNodes.length>0){var e=a.childNodes,g;b===0?(g=e[0],e=!0):(g=e[b-1],e=!1);if(!g)return d;if(f(g).name==="head")return b===1&&(e=!0),b===2&&(e=!1),d.collapse(e),d;if(g.nodeType==1){var i=f(g),h;i.isControl()&&(h=c.createElement("span"),e?i.before(h):i.after(h),g=h);ja(d,g);d.collapse(e);h&&f(h).remove();return d}a=g;b=e?0:g.nodeValue.length}c=c.createElement("span");f(a).before(c);ja(d,c);d.moveStart("character",b);f(c).remove();return d}function Mb(a){function b(a){if(f(a.node).name==
"tr")a.node=a.node.cells[a.offset],a.offset=0}var c;if(n){if(a.item)return c=ea(a.item(0)),c=new S(c),c.selectNode(a.item(0)),c;c=a.parentElement().ownerDocument;var d=jb(a,!0),a=jb(a,!1);b(d);b(a);c=new S(c);c.setStart(d.node,d.offset);c.setEnd(a.node,a.offset);return c}d=a.startContainer;c=d.ownerDocument||d;c=new S(c);c.setStart(d,a.startOffset);c.setEnd(a.endContainer,a.endOffset);return c}function S(a){this.init(a)}function Ia(a){if(!a.nodeName)return a.get?a:Mb(a);return new S(a)}function T(a,
b,c){try{a.execCommand(b,!1,c)}catch(d){}}function lb(a,b){var c="";try{c=a.queryCommandValue(b)}catch(d){}typeof c!=="string"&&(c="");return c}function Ja(a){var b=R(a);return a.selection||b.getSelection()}function mb(a){var b={},c,d;k(a,function(a,f){c=a.split(",");for(var i=0,h=c.length;iKindEditor',""];ca(c)||(c=[c]);k(c,function(a,b){b&&e.push('')});
d&&e.push("");e.push("