(function(e){if(e.xheditor)return false;e.fn.xheditor=function(z){var C=[];this.each(function(){if(e.nodeName(this,"TEXTAREA"))if(z===false){if(this.xheditor){this.xheditor.remove();this.xheditor=null}}else if(this.xheditor)C.push(this.xheditor);else{var I=/({.*})/.exec(e(this).attr("class"));if(I){try{I=eval("("+I[1]+")")}catch(Za){}z=e.extend({},I,z)}I=new e.xheditor(this,z);if(I.init()){this.xheditor=I;C.push(I)}}});if(C.length===0)C=false;if(C.length===1)C=C[0];return C};var ga=0,Ja=e.browser.version,
y=e.browser.msie,za=e.browser.mozilla,V=e.browser.safari,pb=e.browser.opera,R=false,Aa=true,Ba=false,$a=false,N,na,oa,ha,Z,Ka,ia,La,Ma,Na,W;e("script[src*=xheditor]").each(function(){var z=this.src;if(z.match(/xheditor[^\/]*\.js/i)){W=z.replace(/[\?#].*$/,"").replace(/(^|[\/\\])[^\/]*$/,"$1");return false}});var qb={27:"esc",9:"tab",32:"space",13:"enter",8:"backspace",145:"scroll",20:"capslock",144:"numlock",19:"pause",45:"insert",36:"home",46:"del",35:"end",33:"pageup",34:"pagedown",37:"left",38:"up",
39:"right",40:"down",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12"},rb=["#FFFFFF","#CCCCCC","#C0C0C0","#999999","#666666","#333333","#000000","#FFCCCC","#FF6666","#FF0000","#CC0000","#990000","#660000","#330000","#FFCC99","#FF9966","#FF9900","#FF6600","#CC6600","#993300","#663300","#FFFF99","#FFFF66","#FFCC66","#FFCC33","#CC9933","#996633","#663333","#FFFFCC","#FFFF33","#FFFF00","#FFCC00","#999900","#666600","#333300","#99FF99","#66FF99",
"#33FF33","#33CC00","#009900","#006600","#003300","#99FFFF","#33FFFF","#66CCCC","#00CCCC","#339999","#336666","#003333","#CCFFFF","#66FFFF","#33CCFF","#3366FF","#3333FF","#000099","#000066","#CCCCFF","#9999FF","#6666CC","#6633FF","#6600CC","#333399","#330099","#FFCCFF","#FF99FF","#CC66CC","#CC33CC","#993399","#663366","#330033"],sb=[{n:"p",t:"\u666e\u901a\u6bb5\u843d"},{n:"h1",t:"\u6807\u98981"},{n:"h2",t:"\u6807\u98982"},{n:"h3",t:"\u6807\u98983"},{n:"h4",t:"\u6807\u98984"},{n:"h5",t:"\u6807\u98985"},
{n:"h6",t:"\u6807\u98986"},{n:"pre",t:"\u5df2\u7f16\u6392\u683c\u5f0f"},{n:"address",t:"\u5730\u5740"}],tb=[{n:"\u5b8b\u4f53",c:"SimSun"},{n:"\u4eff\u5b8b\u4f53",c:"FangSong_GB2312"},{n:"\u9ed1\u4f53",c:"SimHei"},{n:"\u6977\u4f53",c:"KaiTi_GB2312"},{n:"\u5fae\u8f6f\u96c5\u9ed1",c:"Microsoft YaHei"},{n:"Arial"},{n:"Arial Narrow"},{n:"Arial Black"},{n:"Comic Sans MS"},{n:"Courier New"},{n:"System"},{n:"Times New Roman"},{n:"Tahoma"},{n:"Verdana"}],S=[{n:"xx-small",wkn:"x-small",s:"8pt",t:"\u6781\u5c0f"},
{n:"x-small",wkn:"small",s:"10pt",t:"\u7279\u5c0f"},{n:"small",wkn:"medium",s:"12pt",t:"\u5c0f"},{n:"medium",wkn:"large",s:"14pt",t:"\u4e2d"},{n:"large",wkn:"x-large",s:"18pt",t:"\u5927"},{n:"x-large",wkn:"xx-large",s:"24pt",t:"\u7279\u5927"},{n:"xx-large",wkn:"-webkit-xxx-large",s:"36pt",t:"\u6781\u5927"}],ub=[{s:"\u5de6\u5bf9\u9f50",v:"justifyleft"},{s:"\u5c45\u4e2d",v:"justifycenter"},{s:"\u53f3\u5bf9\u9f50",v:"justifyright"},{s:"\u4e24\u7aef\u5bf9\u9f50",v:"justifyfull"}],vb=[{s:"\u6570\u5b57\u5217\u8868",
v:"insertOrderedList"},{s:"\u7b26\u53f7\u5217\u8868",v:"insertUnorderedList"}],wb={"default":{name:"\u9ed8\u8ba4",width:24,height:24,line:7,list:{smile:"\u5fae\u7b11",tongue:"\u5410\u820c\u5934",titter:"\u5077\u7b11",laugh:"\u5927\u7b11",sad:"\u96be\u8fc7",wronged:"\u59d4\u5c48",fastcry:"\u5feb\u54ed\u4e86",cry:"\u54ed",wail:"\u5927\u54ed",mad:"\u751f\u6c14",knock:"\u6572\u6253",curse:"\u9a82\u4eba",crazy:"\u6293\u72c2",angry:"\u53d1\u706b",ohmy:"\u60ca\u8bb6",awkward:"\u5c34\u5c2c",panic:"\u60ca\u6050",
shy:"\u5bb3\u7f9e",cute:"\u53ef\u601c",envy:"\u7fa1\u6155",proud:"\u5f97\u610f",struggle:"\u594b\u6597",quiet:"\u5b89\u9759",shutup:"\u95ed\u5634",doubt:"\u7591\u95ee",despise:"\u9119\u89c6",sleep:"\u7761\u89c9",bye:"\u518d\u89c1"}}},pa={Cut:{t:"\u526a\u5207 (Ctrl+X)"},Copy:{t:"\u590d\u5236 (Ctrl+C)"},Paste:{t:"\u7c98\u8d34 (Ctrl+V)"},Pastetext:{t:"\u7c98\u8d34\u6587\u672c",h:y?0:1},Blocktag:{t:"\u6bb5\u843d\u6807\u7b7e",h:1},Fontface:{t:"\u5b57\u4f53",h:1},FontSize:{t:"\u5b57\u4f53\u5927\u5c0f",
h:1},Bold:{t:"\u52a0\u7c97 (Ctrl+B)",s:"Ctrl+B"},Italic:{t:"\u659c\u4f53 (Ctrl+I)",s:"Ctrl+I"},Underline:{t:"\u4e0b\u5212\u7ebf (Ctrl+U)",s:"Ctrl+U"},Strikethrough:{t:"\u5220\u9664\u7ebf"},FontColor:{t:"\u5b57\u4f53\u989c\u8272",h:1},BackColor:{t:"\u80cc\u666f\u989c\u8272",h:1},SelectAll:{t:"\u5168\u9009 (Ctrl+A)"},Removeformat:{t:"\u5220\u9664\u6587\u5b57\u683c\u5f0f"},Align:{t:"\u5bf9\u9f50",h:1},List:{t:"\u5217\u8868",h:1},Outdent:{t:"\u51cf\u5c11\u7f29\u8fdb (Shift+Tab)",s:"Shift+Tab"},Indent:{t:"\u589e\u52a0\u7f29\u8fdb (Tab)",
s:"Tab"},Link:{t:"\u8d85\u94fe\u63a5 (Ctrl+K)",s:"Ctrl+K",h:1},Unlink:{t:"\u53d6\u6d88\u8d85\u94fe\u63a5"},Img:{t:"\u56fe\u7247",h:1},Flash:{t:"Flash\u52a8\u753b",h:1},Media:{t:"\u591a\u5a92\u4f53\u6587\u4ef6",h:1},Emot:{t:"\u8868\u60c5",s:"ctrl+e",h:1},Table:{t:"\u8868\u683c",h:1},Source:{t:"\u6e90\u4ee3\u7801"},Preview:{t:"\u9884\u89c8"},Print:{t:"\u6253\u5370 (Ctrl+P)",s:"Ctrl+P"},Fullscreen:{t:"\u5168\u5c4f\u7f16\u8f91 (Esc)",s:"Esc"},About:{t:"\u5173\u4e8e xhEditor"}},Oa={mini:"Bold,Italic,Underline,Strikethrough,|,Align,List,|,Link,Img",
simple:"Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,|,Align,List,Outdent,Indent,|,Link,Img,Emot",full:"Cut,Copy,Paste,Pastetext,|,Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,SelectAll,Removeformat,|,Align,List,Outdent,Indent,|,Link,Unlink,Img,Flash,Media,Emot,Table,|,Source,Preview,Print,Fullscreen"};Oa.mfull=Oa.full.replace(/\|(,Align)/i,"/$1");var xb={a:"Link",img:"Img",embed:"Embed"},yb={"<":"&lt;",">":"&gt;",'"':"&quot;",
"\u00ae":"&reg;","\u00a9":"&copy;"},zb=/[<>"\u00ae\u00a9]/g;e.xheditor=function(z,C){function I(a){a=a.target;var b=xb[a.tagName.toLowerCase()];if(b){if(b==="Embed")b={"application/x-shockwave-flash":"Flash","application/x-mplayer2":"Media"}[a.type.toLowerCase()];d.exec(b)}}function Za(a){if(a.which===27){if(Ba)d.removeModal();else R&&d.hidePanel();return false}}function ab(){setTimeout(d.setSource,10)}function qa(){d.getSource()}function Ab(a){if(H||Pa)return true;Pa=true;d.saveBookmark();var b=
e('<div style="position:absolute;left:-1000px;top:'+$.scrollTop()+'px;overflow:hidden;width:1px;height:1px;" />',w),c=b[0],g=d.getSel(),n=d.getRng(true);e(w.body).append(b);if(y){n.moveToElementText(c);n.execCommand("Paste");a.preventDefault()}else{n.selectNodeContents(c);g.removeAllRanges();g.addRange(n)}setTimeout(function(){var p=o.forcePasteText,j;j=p?b.text():c.innerHTML;b.remove();d.loadBookmark();if(p)d.pasteText(j);else{j=d.cleanHTML(j);j=d.formatXHTML(j);j=d.cleanWord(j);d.pasteHTML(j)}Pa=
false},0)}function Qa(a){try{d._exec("styleWithCSS",a,true)}catch(b){try{d._exec("useCSS",!a,true)}catch(c){}}}function Ra(){if(Sa&&!H){Qa(false);try{d._exec("enableObjectResizing",true,true)}catch(a){}if(y)try{d._exec("BackgroundImageCache",true,true)}catch(b){}}}function Bb(a){if(H||a.which!==13||a.shiftKey||a.ctrlKey||a.altKey)return true;a=d.getParent("p,h1,h2,h3,h4,h5,h6,pre,address,div,li");if(a.is("li"))return true;if(o.forcePtag)a.length===0&&d._exec("formatblock","<p>");else{d.pasteHTML("<br />");
y&&a.length>0&&d.getRng().parentElement().childNodes.length===2&&d.pasteHTML("<br />");return false}}function Ta(){if(!za&&!V){ra&&O.height("100%").css("height",O.outerHeight()-M.outerHeight());y&&M.hide().show()}}function Cb(a){a=a.target;if(a.tagName.match(/(img|embed)/i)){var b=d.getSel(),c=d.getRng(true);c.selectNode(a);b.removeAllRanges();b.addRange(c)}}function aa(a,b,c){if(!b)return false;var g="_xhe_"+b;if(c){if(Ca)c=ba(c,Ca,P);a.attr(b,P?ba(c,"abs",P):c).removeAttr(g).attr(g,c)}return a.attr(g)||
a.attr(b)}function Ua(){Aa&&d.hidePanel()}function Db(a){if(H)return true;var b=a.which,c=qb[b];b=c?c:String.fromCharCode(b).toLowerCase();sKey="";sKey+=a.ctrlKey?"ctrl+":"";sKey+=a.altKey?"alt+":"";sKey+=a.shiftKey?"shift+":"";sKey+=b;a=sa[sKey];for(var g in a){g=a[g];if(e.isFunction(g)){if(g.call(d)===false)return false}else{d.exec(g);return false}}}function ca(a,b){var c=typeof a;if(!b)return c!="undefined";if(b==="array"&&a.hasOwnProperty&&a instanceof Array)return true;return c===b}function ba(a,
b,c){if(a.match(/^(file|mailto|ftp):/i))return a;var g=c?e('<a href="'+c+'" />')[0]:location;c=g.protocol;var n=g.host,p=g.hostname,j=g.port;g=g.pathname.replace(/\\/g,"/").replace(/[^\/]+$/i,"");if(j==="")j="80";if(g==="")g="/";else if(g.charAt(0)!=="/")g="/"+g;a=e.trim(a);if(b!=="abs")a=a.replace(RegExp(c+"\\/\\/"+p.replace(/\./g,"\\.")+"(?::"+j+")"+(j==="80"?"?":"")+"(/|$)","i"),"/");if(b==="rel")a=a.replace(RegExp("^"+g.replace(/([\/\.\+\[\]\(\)])/g,"\\$1"),"i"),"");if(b!=="rel"){a.match(/^(https?:\/\/|\/)/i)||
(a=g+a);if(a.charAt(0)==="/"){p=[];a=a.split("/");var i=a.length;for(g=0;g<i;g++){j=a[g];if(j==="..")p.pop();else j!==""&&j!=="."&&p.push(j)}a[i-1]===""&&p.push("");a="/"+p.join("/")}}if(b==="abs"&&!a.match(/^https?:\/\//i))a=c+"//"+n+a;return a=a.replace(/(https?:\/\/[^:\/?#]+):80(\/|$)/i,"$1$2")}function bb(a,b){if(b==="*"||a.match(RegExp(".("+b.replace(/,/g,"|")+")$","i")))return true;else{alert("\u4e0a\u4f20\u6587\u4ef6\u6269\u5c55\u540d\u5fc5\u9700\u4e3a: "+b);return false}}function cb(a){var b=
Math.floor(Math.log(a)/Math.log(1024));return(a/Math.pow(1024,Math.floor(b))).toFixed(2)+["Byte","KB","MB","GB","TB","PB"][b]}function X(){return false}var d=this,T=e(z),db=T.closest("form"),M,O,Y,$,w,Da,ja,Sa=false,H=false,ra=false,Pa=false,eb,ta=false,fb="",Q=null,Va,ua=false,Wa=false,ka=null,da=null,U=0,o=d.settings=e.extend({},{skin:"default",tools:"full",clickCancelDialog:true,linkTag:false,internalScript:false,inlineScript:false,internalStyle:true,inlineStyle:true,showBlocktag:false,forcePtag:true,
upLinkExt:"zip,rar,txt",upImgExt:"jpg,jpeg,gif,png",upFlashExt:"swf",upMediaExt:"wmv,avi,wma,mp3,mid",modalWidth:350,modalHeight:220,modalTitle:true,defLinkText:"\u70b9\u51fb\u6253\u5f00\u94fe\u63a5",layerShadow:3,emotMark:false,upBtnText:"\u4e0a\u4f20",wordDeepClean:true,hoverExecDelay:100,html5Upload:true,upMultiple:99},C),Ea=o.plugins,Fa=[];if(Ea){pa=e.extend({},pa,Ea);e.each(Ea,function(a){Fa.push(a)});Fa=Fa.join(",")}if(o.tools.match(/^\s*(m?full|simple|mini)\s*$/i)){var gb=Oa[e.trim(o.tools)];
o.tools=o.tools.match(/m?full/i)&&Ea?gb.replace("Table","Table,"+Fa):gb}o.tools.match(/(^|,)\s*About\s*(,|$)/i)||(o.tools+=",About");o.tools=o.tools.split(",");if(o.editorRoot)W=o.editorRoot;W=ba(W,"abs");if(o.urlBase)o.urlBase=ba(o.urlBase,"abs");var hb="xheCSS_"+o.skin,va="xhe"+ga+"_container",ib="xhe"+ga+"_Tool",jb="xhe"+ga+"_iframearea",kb="xhe"+ga+"_iframe",Ga="xhe"+ga+"_fixffcursor",wa="",la="",Xa=W+"xheditor_skin/"+o.skin+"/",Ha=wb,Ca=o.urlType,P=o.urlBase,ea=o.emotPath;ea=ea?ea:W+"xheditor_emot/";
var Ya="";Ha=e.extend({},Ha,o.emots);ea=ba(ea,"rel",P?P:null);if(ta=o.showBlocktag)la+=" showBlocktag";var sa=[];this.init=function(){e("#"+hb).length===0&&e("head").append('<link id="'+hb+'" rel="stylesheet" type="text/css" href="'+Xa+'ui.css" />');var a=o.width||z.style.width||T.outerWidth();U=o.height||z.style.height||T.outerHeight();if(ca(U,"string"))U=U.replace(/[^\d]+/g,"");if(a<=0||U<=0){alert("\u5f53\u524dtextarea\u5904\u4e8e\u9690\u85cf\u72b6\u6001\uff0c\u8bf7\u5c06\u4e4b\u663e\u793a\u540e\u518d\u521d\u59cb\u5316xhEditor\uff0c\u6216\u8005\u76f4\u63a5\u8bbe\u7f6etextarea\u7684width\u548cheight\u6837\u5f0f");
return false}if(/^[0-9\.]+$/i.test(""+a))a+="px";var b=o.background||z.style.background,c=['<span class="xheGStart"/>'],g,n,p=/\||\//i;e.each(o.tools,function(f,h){h.match(p)&&c.push('<span class="xheGEnd"/>');if(h==="|")c.push('<span class="xheSeparator"/>');else if(h==="/")c.push("<br />");else{g=pa[h];if(!g)return;n=g.c?g.c:"xheIcon xheBtn"+h;c.push('<span><a href="javascript:void(0);" title="'+g.t+'" name="'+h+'" class="xheButton xheEnabled" tabindex="-1"><span class="'+n+'" unselectable="on" /></a></span>');
g.s&&d.addShortcuts(g.s,h)}h.match(p)&&c.push('<span class="xheGStart"/>')});c.push('<span class="xheGEnd"/><br />');T.after(e('<input type="text" id="'+Ga+'" style="position:absolute;display:none;" /><span id="'+va+'" class="xhe_'+o.skin+'" style="display:none"><table cellspacing="0" cellpadding="0" class="xheLayout" style="width:'+a+";height:"+U+'px;"><tbody><tr><td id="'+ib+'" class="xheTool" unselectable="on" style="height:1px;"></td></tr><tr><td id="'+jb+'" class="xheIframeArea"><iframe frameborder="0" id="'+
kb+'" src="javascript:;" style="width:100%;"></iframe></td></tr></tbody></table></span>'));M=e("#"+ib);O=e("#"+jb);wa='<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/><link rel="stylesheet" href="'+Xa+'iframe.css"/>';if(a=o.loadCSS)if(ca(a,"array"))for(var j in a)wa+='<link rel="stylesheet" href="'+a[j]+'"/>';else wa+=a.match(/\s*<style(\s+[^>]*?)?>[\s\S]+?<\/style>\s*/i)?a:'<link rel="stylesheet" href="'+a+'"/>';j="<html><head>"+wa;if(b)j+="<style>body{background:"+b+";}</style>";
j+='</head><body spellcheck="false" class="editMode'+la+'"></body></html>';d.win=Y=e("#"+kb)[0].contentWindow;$=e(Y);try{this.doc=w=Y.document;Da=e(w);w.open();w.write(j);w.close();if(y)w.body.contentEditable="true";else w.designMode="On"}catch(i){}setTimeout(Ra,300);d.setSource();Y.setInterval=null;M.append(c.join("")).bind("mousedown contextmenu",X).click(function(f){var h=e(f.target).closest("a");if(h.is(".xheEnabled")){Q=f;d.exec(h.attr("name"))}return false});M.find(".xheButton").hover(function(f){var h=
e(this),m=o.hoverExecDelay,k=da;da=null;if(m===-1||ua||!h.is(".xheEnabled"))return false;if(k&&k>10){ua=true;setTimeout(function(){ua=false},100);return false}var q=h.attr("name");if(pa[q].h!==1){d.hidePanel();return false}if(Wa)m=0;if(m>=0)Va=setTimeout(function(){Q=f;ka={x:Q.clientX,y:Q.clientY};d.exec(q)},m)},function(){ka=null;Va&&clearTimeout(Va)}).mousemove(function(f){if(ka){var h={x:f.clientX-ka.x,y:f.clientY-ka.y};if(Math.abs(h.x)>1||Math.abs(h.y)>1){if(h.x>0&&h.y>0){h=Math.round(Math.atan(h.y/
h.x)/0.017453293);da=da?(da+h)/2:h}else da=null;ka={x:f.clientX,y:f.clientY}}}});N=e("#xhePanel");na=e("#xheShadow");oa=e("#xheCntLine");if(N.length===0){N=e('<div id="xhePanel"></div>').mousedown(function(f){f.stopPropagation()});na=e('<div id="xheShadow"></div>');oa=e('<div id="xheCntLine"></div>');setTimeout(function(){e(document.body).append(N).append(na).append(oa)},10)}e("#"+va).show();T.hide();O.css("height",U-M.outerHeight());setTimeout(function(){O.css("height",U-M.outerHeight())},100);T.focus(d.focus);
db.submit(qa).bind("reset",ab);e(window).bind("unload beforeunload",qa).bind("resize",Ta);e(document).mousedown(Ua);if(!$a){e(document).keydown(Za);$a=true}$.focus(function(){o.focus&&o.focus()}).blur(function(){o.blur&&o.blur()});V&&$.click(Cb);Da.mousedown(Ua).keydown(Db).keypress(Bb).dblclick(I).bind("mousedown click",function(f){T.trigger(f.type)});if(y){Da.keydown(function(f){var h=d.getRng();if(f.which===8&&h.item){e(h.item(0)).remove();return false}});var l=function(f){f=e(f.target);var h;
if(h=f.css("width"))f.css("width","").attr("width",h.replace(/[^0-9%]+/g,""));if(h=f.css("height"))f.css("height","").attr("height",h.replace(/[^0-9%]+/g,""))};Da.bind("controlselect",function(f){f=f.target;e.nodeName(f,"IMG")&&e(f).unbind("resizeend",l).bind("resizeend",l)})}b=e(w.documentElement);b.bind("paste",Ab);o.disableContextmenu&&b.bind("contextmenu",X);o.html5Upload&&b.bind("dragenter dragover",function(f){var h;if((h=f.originalEvent.dataTransfer.types)&&e.inArray("Files",h)!==-1)return false}).bind("drop",
function(f){f=f.originalEvent.dataTransfer;var h;if(f&&(h=f.files)&&h.length>0){var m,k;f=["Link","Img","Flash","Media"];var q=[],r;for(m in f){k=f[m];o["up"+k+"Url"]&&o["up"+k+"Url"].match(/^[^!].*/i)&&q.push(k+":,"+o["up"+k+"Ext"])}if(q.length===0)return false;else r=q.join(",");k=function(v){var s,t;for(m=0;m<v.length;m++){s=v[m].fileName.replace(/.+\./,"");if(s=r.match(RegExp("(\\w+):[^:]*,"+s+"(?:,|$)","i")))if(t){if(t!==s[1])return 2}else t=s[1];else return 1}return t}(h);if(k===1)alert("\u4e0a\u4f20\u6587\u4ef6\u7684\u6269\u5c55\u540d\u5fc5\u9700\u4e3a\uff1a"+
r.replace(/\w+:,/g,""));else if(k===2)alert("\u6bcf\u6b21\u53ea\u80fd\u62d6\u653e\u4e0a\u4f20\u540c\u4e00\u7c7b\u578b\u6587\u4ef6");else k&&d.startUpload(h,o["up"+k+"Url"],"*",function(v){var s=[],t;(t=o.onUpload)&&t(v);for(m in v){t=v[m];url=ca(t,"string")?t:t.url;if(url.substr(0,1)==="!")url=url.substr(1);s.push(url)}d.exec(k);e("#xhe"+k+"Url").val(s.join(" "));e("#xheSave").click()});return false}});(b=o.shortcuts)&&e.each(b,function(f,h){d.addShortcuts(f,h)});ga++;Sa=true;if(o.fullscreen)d.toggleFullscreen();
else o.sourceMode&&setTimeout(d.toggleSource,20);return true};this.remove=function(){d.hidePanel();qa();T.unbind("focus",d.focus);db.unbind("submit",qa).unbind("reset",ab);e(window).unbind("unload beforeunload",qa).unbind("resize",Ta);e(document).unbind("mousedown",Ua);e("#"+va).remove();e("#"+Ga).remove();T.show();Sa=false};this.saveBookmark=function(){if(!H){var a=d.getRng();a=a.cloneRange?a.cloneRange():a;ja={top:$.scrollTop(),rng:a}}};this.loadBookmark=function(){if(!(H||!ja)){d.focus();var a=
ja.rng;if(y)a.select();else{var b=d.getSel();b.removeAllRanges();b.addRange(a)}$.scrollTop(ja.top);ja=null}};this.focus=function(){H?e("#sourceCode",w).focus():$.focus();if(y){var a=d.getRng();a.parentElement&&a.parentElement().ownerDocument!==w&&d.setCursorFirst()}return false};this.setCursorFirst=function(a){Y.scrollTo(0,0);var b=d.getRng(true),c=w.body,g=c,n;if(a&&g.firstChild&&(n=g.firstChild.tagName)&&n.match(/^p|div|h[1-6]$/i))g=c.firstChild;y?b.moveToElementText(g):b.setStart(g,0);b.collapse(true);
if(y)b.select();else{a=d.getSel();a.removeAllRanges();a.addRange(b)}};this.getSel=function(){return Y.getSelection?Y.getSelection():w.selection};this.getRng=function(a){var b,c;try{if(!a){b=d.getSel();c=b.rangeCount>0?b.getRangeAt(0):b.createRange?b.createRange():null}c||(c=w.createRange?w.createRange():w.body.createTextRange())}catch(g){}return c};this.getParent=function(a){var b=d.getRng(),c;if(y)c=b.item?b.item(0):b.parentElement();else{c=b.commonAncestorContainer;if(!b.collapsed)if(b.startContainer===
b.endContainer&&b.startOffset-b.endOffset<2&&b.startContainer.hasChildNodes())c=b.startContainer.childNodes[b.startOffset]}a=a?a:"*";c=e(c);c.is(a)||(c=e(c).closest(a));return c};this.getSelect=function(a){var b=d.getSel(),c=d.getRng(),g=true;g=!c||c.item?false:!b||c.boundingWidth===0||c.collapsed;if(a==="text")return g?"":c.text||(b.toString?b.toString():"");if(c.cloneContents){a=e("<div></div>");(c=c.cloneContents())&&a.append(c);c=a.html()}else c=ca(c.item)?c.item(0).outerHTML:ca(c.htmlText)?c.htmlText:
c.toString();if(g)c="";c=d.processHTML(c,"read");c=d.cleanHTML(c);return c=d.formatXHTML(c)};this.pasteHTML=function(a,b){if(H)return false;d.focus();a=d.processHTML(a,"write");var c=d.getSel(),g=d.getRng();if(b!==undefined){if(g.item){var n=g.item(0);g=d.getRng(true);g.moveToElementText(n);g.select()}g.collapse(b)}a+="<"+(y?"img":"span")+' id="_xhe_temp" width="0" height="0" />';if(g.insertNode){g.deleteContents();g.insertNode(g.createContextualFragment(a))}else{if(c.type.toLowerCase()==="control"){c.clear();
g=d.getRng()}g.pasteHTML(a)}n=e("#_xhe_temp",w);var p=n[0];if(y){g.moveToElementText(p);g.select()}else{g.selectNode(p);c.removeAllRanges();c.addRange(g)}n.remove()};this.pasteText=function(a,b){a||(a="");a=d.domEncode(a);a=a.replace(/\r?\n/g,"<br />");d.pasteHTML(a,b)};this.appendHTML=function(a){if(H)return false;d.focus();a=d.processHTML(a,"write");e(w.body).append(a)};this.domEncode=function(a){return a.replace(zb,function(b){return yb[b]})};this.setSource=function(a){ja=null;if(typeof a!=="string"&&
a!=="")a=z.value;if(H)e("#sourceCode",w).val(a);else{if(o.beforeSetSource)a=o.beforeSetSource(a);a=d.cleanHTML(a);a=d.formatXHTML(a);a=d.processHTML(a,"write");if(y){w.body.innerHTML='<img id="_xhe_temp" width="0" height="0" />'+a+"\n";e("#_xhe_temp",w).remove()}else w.body.innerHTML=a}};this.processHTML=function(a,b){if(b==="write"){a=a.replace(/(<(\/?)(\w+))((?:\s+[\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))*)\s*((\/?)>)/g,function(p,j,i,l,f,h,m){l=l.toLowerCase();if(za)if(l==="strong")l="b";else{if(l===
"em")l="i"}else if(V)if(l==="strong"){l="span";i||(f+=' class="Apple-style-span" style="font-weight: bold;"')}else if(l==="em"){l="span";i||(f+=' class="Apple-style-span" style="font-style: italic;"')}else if(l==="u"){l="span";i||(f+=' class="Apple-style-span" style="text-decoration: underline;"')}else if(l==="strike"){l="span";i||(f+=' class="Apple-style-span" style="text-decoration: line-through;"')}var k,q;if(l==="del")l="strike";else if(l==="img")f=f.replace(/\s+emot\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/i,
function(v,s){k=s.match(/^(["']?)(.*)\1/)[2];k=k.split(",");if(!k[1]){k[1]=k[0];k[0]=""}if(k[0]==="default")k[0]="";return o.emotMark?v:""});else if(l==="a"&&m)h="></a>";else if(l==="table"&&!i){p=f.match(/\s+border\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/i);if(!p||p[1].match(/^(["']?)\s*0\s*\1$/))q="xhe-border"}var r;f=f.replace(/\s+([\w-]+)\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/g,function(v,s,t){s=s.toLowerCase();t=t.match(/^(["']?)(.*)\1/)[2];aft="";if(y&&s.match(/^(disabled|checked|readonly|selected)$/)&&t.match(/^(false|0)$/i))return"";
if(l==="img"&&k&&s==="src")return"";if(s.match(/^(src|href)$/)){aft=" _xhe_"+s+'="'+t+'"';if(P)t=ba(t,"abs",P)}if(q&&s==="class"){t+=" "+q;q=""}if(V&&s==="style"){t=t.replace(/(^|;)\s*(font-size)\s*:\s*([a-z-]+)\s*(;|$)/i,function(A,K,D,F,E){for(var B,L=0;L<S.length;L++){A=S[L];if(F===A.n){B=A.wkn;break}}return K+D+":"+B+E});if(l==="span"&&t.match(/(^|;)\s*(font-family|font-size|color|background-color)\s*:\s*[^;]+\s*(;|$)/i))r=true}return" "+s+'="'+t+'"'+aft});if(k)f+=' src="'+ea+(k[0]?k[0]:"default")+
"/"+k[1]+'.gif"';if(r)f+=' class="Apple-style-span"';if(q)f+=' class="'+q+'"';return"<"+i+l+f+h});if(y)a=a.replace(/&apos;/ig,"&#39;");if(!V){var c=function(p,j,i,l){j="";var f,h;if(f=i.match(/font-family\s*:\s*([^;"]+)/i))j+=' face="'+f[1]+'"';if(f=i.match(/font-size\s*:\s*([^;"]+)/i)){f=f[1].toLowerCase();for(var m=0;m<S.length;m++)if(f===S[m].n||f===S[m].s){h=m+1;break}if(h){j+=' size="'+h+'"';i=i.replace(/(^|;)(\s*font-size\s*:\s*[^;"]+;?)+/ig,"$1")}}if(h=i.match(/(?:^|[\s;])color\s*:\s*([^;"]+)/i)){if(f=
h[1].match(/\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i)){h[1]="#";for(m=1;m<=3;m++)h[1]+=(f[m]-0).toString(16)}h[1]=h[1].replace(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i,"#$1$1$2$2$3$3");j+=' color="'+h[1]+'"'}i=i.replace(/(^|;)(\s*(font-family|color)\s*:\s*[^;"]+;?)+/ig,"$1");if(j!==""){if(i)j+=' style="'+i+'"';return"<font"+j+">"+l+"</font>"}else return p};a=a.replace(/<(span)(?:\s+[^>]*?)?\s+style\s*=\s*"((?:[^"]*?;)*\s*(?:font-family|font-size|color)\s*:[^"]*)"(?: [^>]*)?>(((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S])*?<\/\1>)*?<\/\1>)*?)<\/\1>/ig,
c);a=a.replace(/<(span)(?:\s+[^>]*?)?\s+style\s*=\s*"((?:[^"]*?;)*\s*(?:font-family|font-size|color)\s*:[^"]*)"(?: [^>]*)?>(((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S])*?<\/\1>)*?)<\/\1>/ig,c);a=a.replace(/<(span)(?:\s+[^>]*?)?\s+style\s*=\s*"((?:[^"]*?;)*\s*(?:font-family|font-size|color)\s*:[^"]*)"(?: [^>]*)?>(((?!<\1(\s+[^>]*?)?>)[\s\S])*?)<\/\1>/ig,c)}}else{if(V){var g=[{r:/font-weight:\sbold/ig,t:"strong"},{r:/font-style:\sitalic/ig,t:"em"},{r:/text-decoration:\sunderline/ig,
t:"u"},{r:/text-decoration:\sline-through/ig,t:"strike"}];c=function(p,j,i,l,f){j=i+l;i="";if(!j)return f;for(l=0;l<g.length;l++)if(j.match(g[l].r)){i=g[l].t;break}return i?"<"+i+">"+f+"</"+i+">":p};for(var n=0;n<2;n++){a=a.replace(/<(span)(\s+[^>]*?)?\s+class\s*=\s*"Apple-style-span"(\s+[^>]*?)?>(((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S])*?<\/\1>)*?<\/\1>)*?)<\/\1>/ig,c);a=a.replace(/<(span)(\s+[^>]*?)?\s+class\s*=\s*"Apple-style-span"(\s+[^>]*?)?>(((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S])*?<\/\1>)*?)<\/\1>/ig,
c);a=a.replace(/<(span)(\s+[^>]*?)?\s+class\s*=\s*"Apple-style-span"(\s+[^>]*?)?>(((?!<\1(\s+[^>]*?)?>)[\s\S])*?)<\/\1>/ig,c)}}a=a.replace(/(<(\w+))((?:\s+[\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))*)\s*(\/?>)/g,function(p,j,i,l,f){i=i.toLowerCase();var h;l=l.replace(/\s+_xhe_(?:src|href)\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/i,function(m,k){h=k.match(/^(["']?)(.*)\1/)[2];return""});if(h&&Ca)h=ba(h,Ca,P);l=l.replace(/\s+([\w-]+)\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/g,function(m,k,q){k=k.toLowerCase();q=q.match(/^(["']?)(.*)\1/)[2];
if(k==="class"){if(q.match(/^["']?(apple|webkit)/i))return"";if(i==="table"){q=q.replace(/\s?xhe-border/ig,"");if(q==="")return""}}else if(k.match(/^((_xhe_|_moz_|_webkit_)|jquery\d+)/i))return"";else if(h&&k.match(/^(src|href)$/i))return" "+k+'="'+h+'"';else if(V&&k==="style")q=q.replace(/(^|;)\s*(font-size)\s*:\s*([a-z-]+)\s*(;|$)/i,function(r,v,s,t,A){for(var K,D=0;D<S.length;D++){r=S[D];if(t===r.wkn){K=r.n;break}}return v+s+":"+K+A});return" "+k+'="'+q+'"'});if(i==="img"&&!l.match(/\s+alt\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/i))l+=
' alt=""';return j+l+f})}return a};this.getSource=function(a){var b,c=o.beforeGetSource;if(H){b=e("#sourceCode",w).val();c||(b=b.replace(/(?:(?!<(?:script|style)(?:\s+[^>]*?)?>)[\s\S])+|<(script|style)(?:\s+[^>]*?)?>[\s\S]+<\/\1>/g,function(g){return g.match(/^<(script|style)(?:\s+[^>]*?)?>/i)?g:g.replace(/(\t*\r?\n\t*)+/g,"")}))}else{b=d.processHTML(w.body.innerHTML,"read");b=b.replace(/^\s*(?:<(p|div)(?:\s+[^>]*?)?>)?\s*(<br(?:\s+[^>]*?)?>)*\s*(?:<\/\1>)?\s*$/i,"");b=d.cleanHTML(b);b=d.formatXHTML(b,
a);if(c)b=c(b)}return z.value=b};this.cleanWord=function(a){if(a.match(/mso(-|normal)|WordDocument|<td\s+class="xl[23]\d"/i)){var b=o.wordDeepClean;a=a.replace(/<!--[\s\S]*?--\>|<!(--)?\[[\s\S]+?\](--)?>|<style(\s+[^>]*?)?>[\s\S]*?<\/style>/ig,"");a=a.replace(/\r?\n/ig,"");a=a.replace(/(<(\/?)([\w:]+))((?:\s[\w-:]+="[^"]*")*)\s*(\/?>)/ig,function(g,n,p,j,i,l){j=j.toLowerCase();if(j.match(/^(link|img)$/)&&i.match(/file:\/\//i)||j.match(/:/)||j==="span"&&b)return"";if(!p){i=i.replace(/\s([\w-:]+)="\s*([^"]*)\s*"/ig,
function(f,h,m){h=h.toLowerCase();if(h.match(/:/))return"";else if(h.match(/^(class|lang|language|span)$/))return"";else if(j==="td"&&(h==="height"||h==="width"&&!i.match(/\scolspan="\d+"/i)))return"";else if(h==="style"){if(b)return"";return(m=e.trim(m.replace(/\s*(mso-[^:]+:.+?|margin\s*:\s*0cm 0cm 0pt\s*|(text-align|font-variant|line-height)\s*:\s*.+?)(;|$)\s*/ig,"")))?" "+h+'="'+m+'"':""}return f});if(j==="span"&&i.match(/^\s*$/)||j==="a"&&!i.match(/\s+href\s*=/))return""}return n+i+l});for(var c=
0;c<3;c++)a=a.replace(/<([^\s>]+)(\s+[^>]*)?>\s*<\/\1>/g,"")}return a};this.cleanHTML=function(a){a=a.replace(/<!?\/?(DOCTYPE|html|body|meta)(\s+[^>]*?)?>/ig,"");var b;a=a.replace(/<head(?:\s+[^>]*?)?>([\s\S]*?)<\/head>/i,function(c,g){b=g.match(/<(script|style)(\s+[^>]*?)?>[\s\S]*?<\/\1>/ig);return""});if(b)a=b.join("")+a;a=a.replace(/<\??xml(:\w+)?(\s+[^>]*?)?>([\s\S]*?<\/xml>)?/ig,"");o.internalScript||(a=a.replace(/<script(\s+[^>]*?)?>[\s\S]*?<\/script>/ig,""));o.internalStyle||(a=a.replace(/<style(\s+[^>]*?)?>[\s\S]*?<\/style>/ig,
""));if(!o.linkTag||!o.inlineScript||!o.inlineStyle)a=a.replace(/(<(\w+))((?:\s+[\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))*)\s*(\/?>)/ig,function(c,g,n,p,j){if(!o.linkTag&&n.toLowerCase()==="link")return"";o.inlineScript||(p=p.replace(/\s+on(?:click|dblclick|mouse(down|up|move|over|out|enter|leave|wheel)|key(down|press|up)|change|select|submit|reset|blur|focus|load|unload)\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/ig,""));o.inlineStyle||(p=p.replace(/\s+(style|class)\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/ig,""));
return g+p+j});return a=a.replace(/<\/(strong|b|u|strike|em|i)>((?:\s|<br\/?>|&nbsp;)*?)<\1(\s+[^>]*?)?>/ig,"$2")};this.formatXHTML=function(a,b){function c(u){var x={};u=u.split(",");for(var G=0;G<u.length;G++)x[u[G]]=true;return x}function g(u){u=u.toLowerCase();var x=t[u];return x?x:u}function n(u,x,G){if(k[u])for(;F.last()&&q[F.last()];)p(F.last());r[u]&&F.last()===u&&parseEndTag(u);(G=m[u]||!!G)||F.push(u);var J=[];J.push("<"+u);x.replace(K,function(lb,xa,mb,nb,ob){xa=xa.toLowerCase();J.push(" "+
xa+'="'+(mb?mb:nb?nb:ob?ob:v[xa]?xa:"")+'"')});J.push((G?" /":"")+">");l(J.join(""),u,true)}function p(u){if(u)for(x=F.length-1;x>=0;x--){if(F[x]===u)break}else var x=0;if(x>=0){for(u=F.length-1;u>=x;u--)l("</"+F[u]+">",F[u]);F.length=x}}function j(u){l(d.domEncode(u))}function i(u){l(u)}function l(u,x,G){if(b===true){u=u.replace(/(\t*\r?\n\t*)+/g,"");if(!u.match(/^\s*$/)){var J=k[x],lb=J?x:"";if(J){G&&ma++;Ia===""&&ma--}else Ia&&ma++;if(lb!==Ia||J)f();D.push(u);x==="br"&&f();if(J&&(m[x]||!G))ma--;
Ia=J?x:""}}else D.push(u)}function f(){D.push("\r\n");if(ma>0)for(var u=ma;u--;)D.push("\t")}function h(u,x,G,J){if(!G)return J;u="";if(x=G.match(/ face\s*=\s*"\s*([^"]+)\s*"/i))u+="font-family:"+x[1]+";";if(x=G.match(/ size\s*=\s*"\s*(\d+)\s*"/i))u+="font-size:"+S[(x[1]>7?7:x[1]<1?1:x[1])-1].n+";";if(x=G.match(/ color\s*=\s*"\s*([^"]+)\s*"/i))u+="color:"+x[1]+";";if(G=G.match(/ style\s*=\s*"\s*([^"]+)\s*"/i))u+=G[1];if(u)J='<span style="'+u+'">'+J+"</span>";return J}var m=c("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed"),
k=c("address,applet,blockquote,button,center,dd,dir,div,dl,dt,fieldset,form,frameset,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,p,pre,script,style,table,tbody,td,tfoot,th,thead,tr,ul"),q=c("a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"),r=c("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"),v=c("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"),
s=c("script,style"),t={b:"strong",i:"em",s:"del",strike:"del"},A=/<(?:\/([\w:]+)|!--([\S\s]*?)--|([\w:]+)((?:\s+[\w-:]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))?)*)\s*(\/?))>/g,K=/\s+([\w-:]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s]+)))?/g,D=[],F=[];F.last=function(){return this[this.length-1]};for(var E,B,L=0,fa,ya,ma=-1,Ia="body";E=A.exec(a);){B=E.index;if(B>L){L=a.substring(L,B);fa?ya.push(L):j(L)}L=A.lastIndex;if(B=E[1]){B=g(B);if(fa&&B===fa){i(ya.join(""));ya=fa=null}if(!fa){p(B);continue}}if(fa)ya.push(E[0]);
else if(B=E[3]){B=g(B);n(B,E[4],E[5]);if(s[B]){fa=B;ya=[]}}else if(B=E[2])l()}a.length>L&&j(a.substring(L,a.length));p();a=D.join("");D=null;a=a.replace(/<(font)(\s+[^>]*?)?>(((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S])*?<\/\1>)*?<\/\1>)*?)<\/\1>/ig,h);a=a.replace(/<(font)(\s+[^>]*?)?>(((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S])*?<\/\1>)*?)<\/\1>/ig,h);a=a.replace(/<(font)(\s+[^>]*?)?>(((?!<\1(\s+[^>]*?)?>)[\s\S])*?)<\/\1>/ig,
h);a=a.replace(/^(\s*\r?\n)+|(\s*\r?\n)+$/g,"");return a=a.replace(/(\t*\r?\n)+/g,"\r\n")};this.toggleShowBlocktag=function(a){if(ta!==a){ta=!ta;a=e(w.body);if(ta){la+=" showBlocktag";a.addClass("showBlocktag")}else{la=la.replace(" showBlocktag","");a.removeClass("showBlocktag")}}};this.toggleSource=function(a){if(H!==a){M.find("[name=Source]").toggleClass("xheEnabled").toggleClass("xheActive");var b=w.body,c=e(b),g,n;a=0;if(H){g=d.getSource();c.html("").removeAttr("scroll").attr("class","editMode"+
la);if(y)b.contentEditable="true";else w.designMode="On";if(za){d._exec("inserthtml","-");e("#"+Ga).show().focus().hide()}}else{d.pasteHTML('<span id="_xhe_cursor"></span>',true);g=d.getSource(true);a=g.indexOf('<span id="_xhe_cursor"></span>');if(!pb)a=g.substring(0,a).replace(/\r/g,"").length;g=g.replace(RegExp("(\r\n)?s*"+'<span id="_xhe_cursor"></span>'.replace("/","\\/")+"s*"),"");if(y)b.contentEditable="false";else w.designMode="Off";c.attr("scroll","no").attr("class","sourceMode").html('<textarea id="sourceCode" wrap="soft" spellcheck="false" height="100%" />');
n=e("#sourceCode",c).blur(d.getSource)[0]}H=!H;d.setSource(g);d.focus();if(H)if(n.setSelectionRange)n.setSelectionRange(a,a);else{n=n.createTextRange();n.move("character",a);n.select()}else d.setCursorFirst(true);M.find("[name=Source],[name=Preview]").toggleClass("xheEnabled");M.find(".xheButton").not("[name=Source],[name=Fullscreen],[name=About]").toggleClass("xheEnabled");setTimeout(Ra,300)}};this.showPreview=function(){var a=o.beforeSetSource,b=d.getSource();if(a)b=a(b);a="<html><head>"+wa+"<title>\u9884\u89c8</title>"+
(P?'<base href="'+P+'"/>':"")+"</head><body>"+b+"</body></html>";b=window.screen;b=window.open("","xhePreview","toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width="+Math.round(b.width*0.9)+",height="+Math.round(b.height*0.8)+",left="+Math.round(b.width*0.05));var c=b.document;c.open();c.write(a);c.close();b.focus()};this.toggleFullscreen=function(a){if(ra!==a){a=e("#"+va).find(".xheLayout");var b=e("#"+va);if(ra){a.attr("style",fb);O.height(U-M.outerHeight());setTimeout(function(){e(window).scrollTop(eb)},
10)}else{eb=e(window).scrollTop();fb=a.attr("style");a.removeAttr("style");O.height("100%");setTimeout(Ta,100)}if(za){e("#"+Ga).show().focus().hide();setTimeout(d.focus,1)}ra=!ra;b.toggleClass("xhe_Fullscreen");e("html").toggleClass("xhe_Fullfix");M.find("[name=Fullscreen]").toggleClass("xheActive");setTimeout(Ra,300)}};this.showMenu=function(a,b){var c=e('<div class="xheMenu"></div>'),g=[];e.each(a,function(n,p){g.push('<a href="javascript:void(0);" title="'+(p.t?p.t:p.s)+'" v="'+p.v+'">'+p.s+"</a>")});
c.append(g.join(""));c.click(function(n){b(e(n.target).closest("a").attr("v"));d.hidePanel();return false}).mousedown(X);d.showPanel(c)};this.showColor=function(a){var b=e('<div class="xheColor"></div>'),c=[],g=0;e.each(rb,function(n,p){if(g%7===0)c.push((g>0?"</div>":"")+"<div>");c.push('<a href="javascript:void(0);" xhev="'+p+'" title="'+p+'" style="background:'+p+'"></a>');g++});c.push("</div>");b.append(c.join(""));b.click(function(n){n=n.target;if(e.nodeName(n,"A")){a(e(n).attr("xhev"));d.hidePanel();
return false}}).mousedown(X);d.showPanel(b)};this.showPastetext=function(){var a=e('<div>\u4f7f\u7528\u952e\u76d8\u5feb\u6377\u952e(Ctrl+V)\u628a\u5185\u5bb9\u7c98\u8d34\u5230\u65b9\u6846\u91cc\uff0c\u6309 \u786e\u5b9a</div><div><textarea id="xhePastetextValue" wrap="soft" spellcheck="false" style="width:300px;height:100px;" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="\u786e\u5b9a" /></div>'),b=e("#xhePastetextValue",a);e("#xheSave",a).click(function(){d.loadBookmark();
var c=b.val();c&&d.pasteText(c);d.hidePanel();return false});d.showDialog(a)};this.showLink=function(){var a=e('<div>\u94fe\u63a5\u5730\u5740: <input type="text" id="xheLinkUrl" value="http://" class="xheText" /></div><div>\u6253\u5f00\u65b9\u5f0f: <select id="xheLinkTarget"><option selected="selected" value="">\u9ed8\u8ba4</option><option value="_blank">\u65b0\u7a97\u53e3</option><option value="_self">\u5f53\u524d\u7a97\u53e3</option><option value="_parent">\u7236\u7a97\u53e3</option></select></div><div style="display:none">\u94fe\u63a5\u6587\u5b57: <input type="text" id="xheLinkText" value="" class="xheText" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="\u786e\u5b9a" /></div>'),
b=d.getParent("a"),c=e("#xheLinkText",a),g=e("#xheLinkUrl",a),n=e("#xheLinkTarget",a),p=e("#xheSave",a),j=d.getSelect();if(b.length===1){g.val(aa(b,"href"));n.attr("value",b.attr("target"))}else j===""&&c.val(o.defLinkText).closest("div").show();o.upLinkUrl&&d.uploadInit(g,o.upLinkUrl,o.upLinkExt);p.click(function(){var i=g.val();d.loadBookmark();if(i===""||b.length===0)d._exec("unlink");if(i!==""&&i!=="http://"){var l=i.split(" "),f=n.val(),h=c.val();if(l.length>1){d._exec("unlink");j=d.getSelect();
var m='<a href="xhe_tmpurl"',k=[];if(f!=="")m+=' target="'+f+'"';m+=">xhe_tmptext</a>";h=j!==""?j:h?h:i;for(var q in l){i=l[q];if(i!==""){i=i.split("||");f=m;f=f.replace("xhe_tmpurl",i[0]);f=f.replace("xhe_tmptext",i[1]?i[1]:h);k.push(f)}}d.pasteHTML(k.join("&nbsp;"))}else{i=l[0].split("||");h||(h=i[0]);h=i[1]?i[1]:j!==""?"":h?h:i[0];if(b.length===0){h?d.pasteHTML('<a href="#xhe_tmpurl">'+h+"</a>"):d._exec("createlink","#xhe_tmpurl");b=e('a[href$="#xhe_tmpurl"]',w)}else h&&!V&&b.text(h);aa(b,"href",
i[0]);f!==""?b.attr("target",f):b.removeAttr("target")}}d.hidePanel();return false});d.showDialog(a)};this.showImg=function(){var a=e('<div>\u56fe\u7247\u6587\u4ef6: <input type="text" id="xheImgUrl" value="http://" class="xheText" /></div><div>\u66ff\u6362\u6587\u672c: <input type="text" id="xheImgAlt" /></div><div>\u5bf9\u9f50\u65b9\u5f0f: <select id="xheImgAlign"><option selected="selected" value="">\u9ed8\u8ba4</option><option value="left">\u5de6\u5bf9\u9f50</option><option value="right">\u53f3\u5bf9\u9f50</option><option value="top">\u9876\u7aef</option><option value="middle">\u5c45\u4e2d</option><option value="baseline">\u57fa\u7ebf</option><option value="bottom">\u5e95\u8fb9</option></select></div><div>\u5bbd\u5ea6\u9ad8\u5ea6: <input type="text" id="xheImgWidth" style="width:40px;" /> x <input type="text" id="xheImgHeight" style="width:40px;" /></div><div>\u8fb9\u6846\u5927\u5c0f: <input type="text" id="xheImgBorder" style="width:40px;" /></div><div>\u6c34\u5e73\u95f4\u8ddd: <input type="text" id="xheImgHspace" style="width:40px;" /> \u5782\u76f4\u95f4\u8ddd: <input type="text" id="xheImgVspace" style="width:40px;" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="\u786e\u5b9a" /></div>'),
b=d.getParent("img"),c=e("#xheImgUrl",a),g=e("#xheImgAlt",a),n=e("#xheImgAlign",a),p=e("#xheImgWidth",a),j=e("#xheImgHeight",a),i=e("#xheImgBorder",a),l=e("#xheImgVspace",a),f=e("#xheImgHspace",a),h=e("#xheSave",a);if(b.length===1){c.val(aa(b,"src"));g.val(b.attr("alt"));n.val(b.attr("align"));p.val(b.attr("width"));j.val(b.attr("height"));i.val(b.attr("border"));var m=b.attr("vspace"),k=b.attr("hspace");l.val(m<=0?"":m);f.val(k<=0?"":k)}o.upImgUrl&&d.uploadInit(c,o.upImgUrl,o.upImgExt);h.click(function(){d.loadBookmark();
var q=c.val();if(q!==""&&q!=="http://"){var r=q.split(" "),v=g.val(),s=n.val(),t=p.val(),A=j.val(),K=i.val(),D=l.val(),F=f.val();if(r.length>1){var E='<img src="xhe_tmpurl"',B=[];if(v!=="")E+=' alt="'+v+'"';if(s!=="")E+=' align="'+s+'"';if(t!=="")E+=' width="'+t+'"';if(A!=="")E+=' height="'+A+'"';if(K!=="")E+=' border="'+K+'"';if(D!=="")E+=' vspace="'+D+'"';if(F!=="")E+=' hspace="'+F+'"';E+=" />";for(var L in r){q=r[L];if(q!==""){q=q.split("||");v=E;v=v.replace("xhe_tmpurl",q[0]);if(q[1])v='<a href="'+
q[1]+'" target="_blank">'+v+"</a>";B.push(v)}}d.pasteHTML(B.join("&nbsp;"))}else if(r.length===1){q=r[0];if(q!==""){q=q.split("||");if(b.length===0){d.pasteHTML('<img src="'+q[0]+'#xhe_tmpurl" />');b=e('img[src$="#xhe_tmpurl"]',w)}aa(b,"src",q[0]);v!==""&&b.attr("alt",v);s!==""?b.attr("align",s):b.removeAttr("align");t!==""?b.attr("width",t):b.removeAttr("width");A!==""?b.attr("height",A):b.removeAttr("height");K!==""?b.attr("border",K):b.removeAttr("border");D!==""?b.attr("vspace",D):b.removeAttr("vspace");
F!==""?b.attr("hspace",F):b.removeAttr("hspace");if(q[1]){r=b.parent("a");if(r.length===0){b.wrap("<a></a>");r=b.parent("a")}aa(r,"href",q[1]);r.attr("target","_blank")}}}}else b.length===1&&b.remove();d.hidePanel();return false});d.showDialog(a)};this.showEmbed=function(a,b,c,g,n,p,j){b=e(b);var i=d.getParent('embed[type="'+c+'"],embed[classid="'+g+'"]'),l=e("#xhe"+a+"Url",b),f=e("#xhe"+a+"Width",b),h=e("#xhe"+a+"Height",b);a=e("#xheSave",b);p&&d.uploadInit(l,p,j);d.showDialog(b);if(i.length===1){l.val(aa(i,
"src"));f.val(i.attr("width"));h.val(i.attr("height"))}a.click(function(){d.loadBookmark();var m=l.val();if(m!==""&&m!=="http://"){var k=f.val(),q=h.val(),r=/^\d+%?$/;r.test(k)||(k=412);r.test(q)||(q=300);var v='<embed type="'+c+'" classid="'+g+'" src="xhe_tmpurl"'+n;r=m.split(" ");if(r.length>1){v=v+"";var s,t=[];v+=' width="xhe_width" height="xhe_height" />';for(var A in r){m=r[A].split("||");s=v;s=s.replace("xhe_tmpurl",m[0]);s=s.replace("xhe_width",m[1]?m[1]:k);s=s.replace("xhe_height",m[2]?m[2]:
q);m!==""&&t.push(s)}d.pasteHTML(t.join("&nbsp;"))}else if(r.length===1){m=r[0].split("||");if(i.length===0){d.pasteHTML(v.replace("xhe_tmpurl",m[0]+"#xhe_tmpurl")+" />");i=e('embed[src$="#xhe_tmpurl"]',w)}aa(i,"src",m[0]);i.attr("width",m[1]?m[1]:k);i.attr("height",m[2]?m[2]:q)}}else i.length===1&&i.remove();d.hidePanel();return false})};this.showEmot=function(a){var b=e('<div class="xheEmot"></div>');a=a?a:Ya?Ya:"default";var c=Ha[a],g=ea+a+"/",n=0,p=[],j="";j=c.width;var i=c.height,l=c.line,f=
c.count;c=c.list;if(f)for(c=1;c<=f;c++){n++;p.push('<a href="javascript:void(0);" style="background-image:url('+g+c+'.gif);" emot="'+a+","+c+'" xhev="">&nbsp;</a>');n%l===0&&p.push("<br />")}else e.each(c,function(k,q){n++;p.push('<a href="javascript:void(0);" style="background-image:url('+g+k+'.gif);" emot="'+a+","+k+'" title="'+q+'" xhev="'+q+'">&nbsp;</a>');n%l===0&&p.push("<br />")});f=l*(j+12);c=f*0.75;if(Math.ceil(n/l)*(i+12)<=c)c="";j=e("<style>"+(c?".xheEmot div{width:"+(f+20)+"px;height:"+
c+"px;}":"")+".xheEmot div a{width:"+j+"px;height:"+i+"px;}</style><div>"+p.join("")+"</div>").click(function(k){k=k.target;var q=e(k);if(e.nodeName(k,"A")){d.pasteHTML('<img emot="'+q.attr("emot")+'" alt="'+q.attr("xhev")+'">');d.hidePanel();return false}}).mousedown(X);b.append(j);var h=0,m=["<ul>"];e.each(Ha,function(k,q){h++;m.push("<li"+(a===k?' class="cur"':"")+'><a href="javascript:void(0);" group="'+k+'">'+q.name+"</a></li>")});if(h>1){m.push('</ul><br style="clear:both;" />');j=e(m.join("")).click(function(k){Ya=
e(k.target).attr("group");d.exec("Emot");return false}).mousedown(X);b.append(j)}d.showPanel(b)};this.showTable=function(){var a=e('<div>\u884c\u6570\u5217\u6570: <input type="text" id="xheTableRows" style="width:40px;" value="3" /> x <input type="text" id="xheTableColumns" style="width:40px;" value="2" /></div><div>\u6807\u9898\u5355\u5143: <select id="xheTableHeaders"><option selected="selected" value="">\u65e0</option><option value="row">\u7b2c\u4e00\u884c</option><option value="col">\u7b2c\u4e00\u5217</option><option value="both">\u7b2c\u4e00\u884c\u548c\u7b2c\u4e00\u5217</option></select></div><div>\u5bbd\u5ea6\u9ad8\u5ea6: <input type="text" id="xheTableWidth" style="width:40px;" value="200" /> x <input type="text" id="xheTableHeight" style="width:40px;" value="" /></div><div>\u8fb9\u6846\u5927\u5c0f: <input type="text" id="xheTableBorder" style="width:40px;" value="1" /></div><div>\u8868\u683c\u95f4\u8ddd: <input type="text" id="xheTableCellSpacing" style="width:40px;" value="1" /> \u8868\u683c\u586b\u5145: <input type="text" id="xheTableCellPadding" style="width:40px;" value="1" /></div><div>\u5bf9\u9f50\u65b9\u5f0f: <select id="xheTableAlign"><option selected="selected" value="">\u9ed8\u8ba4</option><option value="left">\u5de6\u5bf9\u9f50</option><option value="center">\u5c45\u4e2d</option><option value="right">\u53f3\u5bf9\u9f50</option></select></div><div>\u8868\u683c\u6807\u9898: <input type="text" id="xheTableCaption" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="\u786e\u5b9a" /></div>'),
b=e("#xheTableRows",a),c=e("#xheTableColumns",a),g=e("#xheTableHeaders",a),n=e("#xheTableWidth",a),p=e("#xheTableHeight",a),j=e("#xheTableBorder",a),i=e("#xheTableCellSpacing",a),l=e("#xheTableCellPadding",a),f=e("#xheTableAlign",a),h=e("#xheTableCaption",a);e("#xheSave",a).click(function(){d.loadBookmark();var m=h.val(),k=j.val(),q=b.val(),r=c.val(),v=g.val(),s=n.val(),t=p.val(),A=i.val(),K=l.val(),D=f.val();k="<table"+(k!==""?' border="'+k+'"':"")+(s!==""?' width="'+s+'"':"")+(t!==""?' width="'+
t+'"':"")+(A!==""?' cellspacing="'+A+'"':"")+(K!==""?' cellpadding="'+K+'"':"")+(D!==""?' align="'+D+'"':"")+">";if(m!=="")k+="<caption>"+m+"</caption>";if(v==="row"||v==="both"){k+="<tr>";for(m=0;m<r;m++)k+='<th scope="col">&nbsp;</th>';k+="</tr>";q--}k+="<tbody>";for(m=0;m<q;m++){k+="<tr>";for(s=0;s<r;s++)k+=s===0&&(v==="col"||v==="both")?'<th scope="row">&nbsp;</th>':"<td>&nbsp;</td>";k+="</tr>"}k+="</tbody></table>";d.pasteHTML(k);d.hidePanel();return false});d.showDialog(a)};this.showAbout=function(){var a=
e('<div style="font:12px Arial;width:245px;word-wrap:break-word;word-break:break-all;"><p><span style="font-size:20px;color:#1997DF;">xhEditor</span><br />v1.1.3 (build 110101)</p><p>xhEditor\u662f\u57fa\u4e8ejQuery\u5f00\u53d1\u7684\u8de8\u5e73\u53f0\u8f7b\u91cfXHTML\u7f16\u8f91\u5668\uff0c\u57fa\u4e8e<a href="http://www.gnu.org/licenses/lgpl.html" target="_blank">LGPL</a>\u5f00\u6e90\u534f\u8bae\u53d1\u5e03\u3002</p><p>Copyright \u00a9 <a href="http://xheditor.com/" target="_blank">xhEditor.com</a>. All rights reserved.</p></div>');
d.showDialog(a)};this.addShortcuts=function(a,b){a=a.toLowerCase();if(sa[a]===undefined)sa[a]=[];sa[a].push(b)};this.delShortcuts=function(a){delete sa[a]};this.uploadInit=function(a,b,c){function g(f){if(ca(f,"string"))f=[f];var h=false,m,k=f.length,q,r=[];(m=o.onUpload)&&m(f);for(m=0;m<k;m++){q=f[m];q=ca(q,"string")?q:q.url;if(q.substr(0,1)==="!"){h=true;q=q.substr(1)}r.push(q)}a.val(r.join(" "));h&&a.closest(".xheDialog").find("#xheSave").click()}var n=e('<span class="xheUpload"><input type="text" style="visibility:hidden;" tabindex="-1" /><input type="button" value="'+
o.upBtnText+'" class="xheBtn" tabindex="-1" /></span>'),p=e(".xheBtn",n),j=o.html5Upload,i=j?o.upMultiple:1;a.after(n);p.before(a);b=b.replace(/{editorRoot}/ig,W);if(b.substr(0,1)==="!")p.click(function(){R=false;d.showIframeModal("\u4e0a\u4f20\u6587\u4ef6",b.substr(1),g,null,null,function(){R=true})});else{n.append('<input type="file"'+(i>1?' multiple=""':"")+' class="xheFile" size="13" name="filedata" tabindex="-1" />');var l=e(".xheFile",n);l.change(function(){d.startUpload(l[0],b,c,g)});setTimeout(function(){a.closest(".xheDialog").bind("dragenter dragover",
X).bind("drop",function(f){f=f.originalEvent.dataTransfer;var h;if(j&&f&&(h=f.files)&&h.length>0)d.startUpload(h,b,c,g);return false})},10)}};this.startUpload=function(a,b,c,g){function n(r,v){var s=Object,t=false;try{s=eval("("+r+")")}catch(A){}if(s.err===undefined||s.msg===undefined)alert(b+" \u4e0a\u4f20\u63a5\u53e3\u53d1\u751f\u9519\u8bef\uff01\r\n\r\n\u8fd4\u56de\u7684\u9519\u8bef\u5185\u5bb9\u4e3a: \r\n\r\n"+r);else if(s.err)alert(s.err);else{p.push(s.msg);t=true}if(!t||v)d.removeModal();v&&
t&&g(p);return t}var p=[],j=o.html5Upload,i=j?o.upMultiple:1,l,f,h=e('<div style="padding:22px 0;text-align:center;line-height:30px;">\u6587\u4ef6\u4e0a\u4f20\u4e2d\uff0c\u8bf7\u7a0d\u5019\u2026\u2026<br /></div>'),m='<img src="'+Xa+'img/loading.gif">';if(!j||a.nodeType&&!((f=a.files)&&f[0])){if(!bb(a.value,c))return;h.append(m);l=new d.html4Upload(a,b,n)}else{f||(f=a);a=f.length;if(a>i){alert("\u8bf7\u4e0d\u8981\u4e00\u6b21\u4e0a\u4f20\u8d85\u8fc7"+i+"\u4e2a\u6587\u4ef6");return}for(i=0;i<a;i++)if(!bb(f[i].fileName,
c))return;var k=e('<div class="xheProgress"><div><span>0%</span></div></div>');h.append(k);l=new d.html5Upload("filedata",f,b,n,function(r){if(r.loaded>=0){var v=Math.round(r.loaded*100/r.total)+"%";e("div",k).css("width",v);e("span",k).text(v+" ( "+cb(r.loaded)+" / "+cb(r.total)+" )")}else k.replaceWith(m)})}var q=R;if(q)R=false;d.showModal("\u6587\u4ef6\u4e0a\u4f20\u4e2d(Esc\u53d6\u6d88\u4e0a\u4f20)",h,320,150,function(){R=q;l.remove()});l.start()};this.html4Upload=function(a,b,c){var g="jUploadFrame"+
(new Date).getTime(),n=this,p=e('<iframe name="'+g+'" class="xheHideArea" />').appendTo("body"),j=e('<form action="'+b+'" target="'+g+'" method="post" enctype="multipart/form-data" class="xheHideArea"></form>').appendTo("body"),i=e(a),l=i.clone().attr("disabled","true");i.before(l).appendTo(j);this.remove=function(){if(n!==null){l.before(i).remove();p.remove();j.remove();n=null}};this.onLoad=function(){c(e(p[0].contentWindow.document.body).text(),true)};this.start=function(){j.submit();p.load(n.onLoad)};
return this};this.html5Upload=function(a,b,c,g,n){function p(r,v,s,t){i=new XMLHttpRequest;upload=i.upload;i.onreadystatechange=function(){i.readyState===4&&s(i.responseText)};if(upload)upload.onprogress=function(A){t(A.loaded)};else t(-1);i.open("POST",v);i.setRequestHeader("Content-Type","application/octet-stream");i.setRequestHeader("Content-Disposition",'attachment; name="'+a+'"; filename="'+r.fileName+'"');i.sendAsBinary?i.sendAsBinary(r.getAsBinary()):i.send(r)}function j(r){n&&n({loaded:h+
r,total:m})}for(var i,l=0,f=b.length,h=0,m=0,k=this,q=0;q<f;q++)m+=b[q].fileSize;this.remove=function(){if(i){i.abort();i=null}};this.uploadNext=function(r){if(r){h+=b[l-1].fileSize;j(0)}if((!r||r&&g(r,l===f)===true)&&l<f)p(b[l++],c,k.uploadNext,function(v){j(v)})};this.start=function(){k.uploadNext()}};this.showIframeModal=function(a,b,c,g,n,p){b=e('<iframe frameborder="0" src="'+b.replace(/{editorRoot}/ig,W)+'" style="width:100%;height:100%;display:none;" /><div class="xheModalIfmWait"></div>');
var j=e(b[0]),i=e(b[1]);d.showModal(a,b,g,n,p);j.load(function(){var l=j[0].contentWindow,f=e(l.document);l.callback=function(h){d.removeModal();c(h)};l.unloadme=d.removeModal;f.keydown(d.checkEsc);j.show();i.remove()})};this.showModal=function(a,b,c,g,n){if(Ba)return false;ia=o.layerShadow;c=c?c:o.modalWidth;g=g?g:o.modalHeight;Z=e('<div class="xheModal" style="width:'+(c-1)+"px;height:"+g+"px;margin-left:-"+Math.ceil(c/2)+"px;"+(y&&Ja<=7?"":"margin-top:-"+Math.ceil(g/2)+"px")+'">'+(o.modalTitle?
'<div class="xheModalTitle"><span class="xheModalClose" title="\u5173\u95ed (Esc)"></span>'+a+"</div>":"")+'<div class="xheModalContent"></div></div>').appendTo("body");La=e('<div class="xheModalOverlay"></div>').appendTo("body");if(ia>0)Ka=e('<div class="xheModalShadow" style="width:'+Z.outerWidth()+"px;height:"+Z.outerHeight()+"px;margin-left:-"+(Math.ceil(c/2)-ia-2)+"px;"+(y&&Ja<=7?"":"margin-top:-"+(Math.ceil(g/2)-ia-2)+"px")+'"></div>').appendTo("body");e(".xheModalContent",Z).css("height",g-
(o.modalTitle?e(".xheModalTitle").outerHeight():0)).html(b);if(y&&Ja===6)Ma=e("select:visible").css("visibility","hidden");e(".xheModalClose",Z).click(d.removeModal);La.show();ia>0&&Ka.show();Z.show();Ba=true;Na=n};this.removeModal=function(){Ma&&Ma.css("visibility","visible");Z.html("").remove();ia>0&&Ka.remove();La.remove();Na&&Na();Ba=false};this.showDialog=function(a){var b=e('<div class="xheDialog"></div>');a=e(a);var c=e("#xheSave",a);if(c.length===1){a.find("input[type=text],select").keypress(function(p){if(p.which===
13){c.click();return false}});a.find("textarea").keydown(function(p){if(p.ctrlKey&&p.which===13){c.click();return false}});c.after(' <input type="button" id="xheCancel" value="\u53d6\u6d88" />');e("#xheCancel",a).click(d.hidePanel);if(!o.clickCancelDialog){Aa=false;var g=e('<div class="xheFixCancel"></div>').appendTo("body").mousedown(X),n=O.offset();g.css({left:n.left,top:n.top,width:O.outerWidth(),height:O.outerHeight()})}b.mousedown(function(){ua=true})}b.append(a);d.showPanel(b);y||setTimeout(function(){b.find("input[type=text],textarea").filter(":visible").filter(function(){return e(this).css("visibility")!==
"hidden"}).eq(0).focus()},10)};this.showPanel=function(a){if(!Q.target)return false;N.html("").append(a).css("left",-999).css("top",-999);ha=e(Q.target).closest("a").addClass("xheActive");var b=ha.offset();a=b.left;b=b.top;b+=ha.outerHeight()-1;oa.css({left:a+1,top:b,width:ha.width()}).show();if(a+N.outerWidth()>document.body.clientWidth)a-=N.outerWidth()-ha.outerWidth();var c=o.layerShadow;c>0&&na.css({left:a+c,top:b+c,width:N.outerWidth(),height:N.outerHeight()}).show();N.css({left:a,top:b}).show();
Wa=R=true};this.hidePanel=function(){if(R){ha.removeClass("xheActive");na.hide();oa.hide();N.hide();R=false;if(!Aa){e(".xheFixCancel").remove();Aa=true}Wa=ua=false;da=null}};this.exec=function(a){d.focus();d.hidePanel();d.saveBookmark();var b=pa[a];if(!b)return false;if(Q===null){Q={};var c=M.find(".xheButton[name="+a+"]");if(c.length===1)Q.target=c}if(b.e)b.e.call(d);else{a=a.toLowerCase();switch(a){case "cut":try{w.execCommand(a);if(!w.queryCommandSupported(a))throw"Error";}catch(g){alert("\u60a8\u7684\u6d4f\u89c8\u5668\u5b89\u5168\u8bbe\u7f6e\u4e0d\u5141\u8bb8\u4f7f\u7528\u526a\u5207\u64cd\u4f5c\uff0c\u8bf7\u4f7f\u7528\u952e\u76d8\u5feb\u6377\u952e(Ctrl + X)\u6765\u5b8c\u6210")}break;
case "copy":try{w.execCommand(a);if(!w.queryCommandSupported(a))throw"Error";}catch(n){alert("\u60a8\u7684\u6d4f\u89c8\u5668\u5b89\u5168\u8bbe\u7f6e\u4e0d\u5141\u8bb8\u4f7f\u7528\u590d\u5236\u64cd\u4f5c\uff0c\u8bf7\u4f7f\u7528\u952e\u76d8\u5feb\u6377\u952e(Ctrl + C)\u6765\u5b8c\u6210")}break;case "paste":try{w.execCommand(a);if(!w.queryCommandSupported(a))throw"Error";}catch(p){alert("\u60a8\u7684\u6d4f\u89c8\u5668\u5b89\u5168\u8bbe\u7f6e\u4e0d\u5141\u8bb8\u4f7f\u7528\u7c98\u8d34\u64cd\u4f5c\uff0c\u8bf7\u4f7f\u7528\u952e\u76d8\u5feb\u6377\u952e(Ctrl + V)\u6765\u5b8c\u6210")}break;
case "pastetext":window.clipboardData?d.pasteText(window.clipboardData.getData("Text",true)):d.showPastetext();break;case "blocktag":var j=[];e.each(sb,function(f,h){j.push({s:"<"+h.n+">"+h.t+"</"+h.n+">",v:"<"+h.n+">",t:h.t})});d.showMenu(j,function(f){d._exec("formatblock",f)});break;case "fontface":var i=[];e.each(tb,function(f,h){h.c=h.c?h.c:h.n;i.push({s:'<span style="font-family:'+h.c+'">'+h.n+"</span>",v:h.c,t:h.n})});d.showMenu(i,function(f){d._exec("fontname",f)});break;case "fontsize":var l=
[];e.each(S,function(f,h){l.push({s:'<span style="font-size:'+h.s+';">'+h.t+"("+h.s+")</span>",v:f+1,t:h.t})});d.showMenu(l,function(f){d._exec("fontsize",f)});break;case "fontcolor":d.showColor(function(f){d._exec("forecolor",f)});break;case "backcolor":d.showColor(function(f){if(y)d._exec("backcolor",f);else{Qa(true);d._exec("hilitecolor",f);Qa(false)}});break;case "align":d.showMenu(ub,function(f){d._exec(f)});break;case "list":d.showMenu(vb,function(f){d._exec(f)});break;case "link":d.showLink();
break;case "img":d.showImg();break;case "flash":d.showEmbed("Flash",'<div>\u52a8\u753b\u6587\u4ef6: <input type="text" id="xheFlashUrl" value="http://" class="xheText" /></div><div>\u5bbd\u5ea6\u9ad8\u5ea6: <input type="text" id="xheFlashWidth" style="width:40px;" value="480" /> x <input type="text" id="xheFlashHeight" style="width:40px;" value="400" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="\u786e\u5b9a" /></div>',"application/x-shockwave-flash","clsid:d27cdb6e-ae6d-11cf-96b8-4445535400000",
' wmode="opaque" quality="high" menu="false" play="true" loop="true" allowfullscreen="true"',o.upFlashUrl,o.upFlashExt);break;case "media":d.showEmbed("Media",'<div>\u5a92\u4f53\u6587\u4ef6: <input type="text" id="xheMediaUrl" value="http://" class="xheText" /></div><div>\u5bbd\u5ea6\u9ad8\u5ea6: <input type="text" id="xheMediaWidth" style="width:40px;" value="480" /> x <input type="text" id="xheMediaHeight" style="width:40px;" value="400" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="\u786e\u5b9a" /></div>',
"application/x-mplayer2","clsid:6bf52a52-394a-11d3-b153-00c04f79faa6",' enablecontextmenu="false" autostart="false"',o.upMediaUrl,o.upMediaExt);break;case "emot":d.showEmot();break;case "table":d.showTable();break;case "source":d.toggleSource();break;case "preview":d.showPreview();break;case "print":Y.print();break;case "fullscreen":d.toggleFullscreen();break;case "about":d.showAbout();break;default:d._exec(a)}}Q=null};this._exec=function(a,b,c){c||d.focus();return b!==undefined?w.execCommand(a,false,
b):w.execCommand(a,false,null)}};e(function(){e.fn.oldVal=e.fn.val;e.fn.val=function(z){var C=this,I;if(z===undefined)return C[0]&&(I=C[0].xheditor)?I.getSource():C.oldVal();return C.each(function(){(I=this.xheditor)?I.setSource(z):C.oldVal(z)})};e("textarea").each(function(){var z=e(this),C=z.attr("class").match(/(?:^|\s)xheditor(?:\-(m?full|simple|mini))?(?:\s|$)/i);if(C)z.xheditor(C[1]?{tools:C[1]}:null)})})})(jQuery);

