/*
 * xhEditor - WYSIWYG XHTML Editor
 * @requires jQuery v1.3.2
 * 
 * @author Yanis.Wang<yanis.wang@gmail.com>
 * @site http://pirate9.com/
 * @licence LGPL(http://www.opensource.org/licenses/lgpl-license.php)
 * 
 * @Version: 0.9.9 build 091123
 */
(function(h){h.fn.xheditor=function(i,s){return this.each(function(){if(this.tagName.toLowerCase()!="textarea"){return}if(i){if(!this.xheditor){var H=new h.xheditor(this,s);if(H.init()){this.xheditor=H}else{H=null}}}else{if(this.xheditor){this.xheditor.remove();this.xheditor=null}}})};var k=0,r=h.browser.msie,l=h.browser.mozilla,F=h.browser.safari,t=false;var d,p,j;var D,B;D=window.location.href.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]*$/,"");D+="/";var E=h("script[src*=xheditor]"),o;for(var z=0;z<E.length;z++){o=E[z].src;if(o.match(/xheditor[^\/]*\.js/i)){B=o.replace(/[\?#].*$/,"").replace(/(^|[\/\\])[^\/]*$/,"");if(B!=""){B+="/"}break}}var C={27:"esc",9:"tab",32:"space",13:"return",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"};var m=["#FFFFFF","#E5E4E4","#D9D8D8","#C0BDBD","#A7A4A4","#8E8A8B","#827E7F","#767173","#5C585A","#000000","#FEFCDF","#FEF4C4","#FEED9B","#FEE573","#FFED43","#F6CC0B","#E0B800","#C9A601","#AD8E00","#8C7301","#FFDED3","#FFC4B0","#FF9D7D","#FF7A4E","#FF6600","#E95D00","#D15502","#BA4B01","#A44201","#8D3901","#FFD2D0","#FFBAB7","#FE9A95","#FF7A73","#FF483F","#FE2419","#F10B00","#D40A00","#940000","#6D201B","#FFDAED","#FFB7DC","#FFA1D1","#FF84C3","#FF57AC","#FD1289","#EC0078","#D6006D","#BB005F","#9B014F","#FCD6FE","#FBBCFF","#F9A1FE","#F784FE","#F564FE","#F546FF","#F328FF","#D801E5","#C001CB","#8F0197","#E2F0FE","#C7E2FE","#ADD5FE","#92C7FE","#6EB5FF","#48A2FF","#2690FE","#0162F4","#013ADD","#0021B0","#D3FDFF","#ACFAFD","#7CFAFF","#4AF7FE","#1DE6FE","#01DEFF","#00CDEC","#01B6DE","#00A0C2","#0084A0","#EDFFCF","#DFFEAA","#D1FD88","#BEFA5A","#A8F32A","#8FD80A","#79C101","#3FA701","#307F00","#156200","#D4C89F","#DAAD88","#C49578","#C2877E","#AC8295","#C0A5C4","#969AC2","#92B7D7","#80ADAF","#9CA53B"];var A=[{n:"p",t:"Paragraph"},{n:"h1",t:"Heading 1"},{n:"h2",t:"Heading 2"},{n:"h3",t:"Heading 3"},{n:"h4",t:"Heading 4"},{n:"h5",t:"Heading 5"},{n:"h6",t:"Heading 6"},{n:"pre",t:"Preformatted"},{n:"address",t:"Address"}];var c=["Arial","Arial Narrow","Arial Black","Comic Sans MS","Courier New","System","Times New Roman","Tahoma","Verdana"];var w=[{n:"xx-small",wkn:"x-small",s:"8pt",t:"xx-small"},{n:"x-small",wkn:"small",s:"10pt",t:"x-small"},{n:"small",wkn:"medium",s:"12pt",t:"small"},{n:"medium",wkn:"large",s:"14pt",t:"medium"},{n:"large",wkn:"x-large",s:"18pt",t:"large"},{n:"x-large",wkn:"xx-large",s:"24pt",t:"x-large"},{n:"xx-large",wkn:"-webkit-xxx-large",s:"36pt",t:"xx-large"}];var e=[{s:"Align left",v:"justifyleft",t:"Align left"},{s:"Align center",v:"justifycenter",t:"Align center"},{s:"Align right",v:"justifyright",t:"Align right"},{s:"Align full",v:"justifyfull",t:"Align full"}],f=[{s:"Ordered list",v:"insertOrderedList",t:"Ordered list"},{s:"Unordered list",v:"insertUnorderedList",t:"Unordered list"}];var a='<div>Use Ctrl+V on your keyboard to paste the text.</div><div><textarea id="xhEdtPastetextValue" wrap="soft" spellcheck="false" style="width:300px;height:100px;" /></div><div style="text-align:right;"><input type="button" id="xhEdtSave" value="OK" /></div>';var b='<div>Link URL: <input type="text" id="xhEdtLinkHref" value="http://" class="text" /></div><div>Target:&nbsp;&nbsp; <select id="xhEdtLinkTarget"><option selected="selected" value="">Default</option><option value="_blank">New window</option><option value="_self">Same window</option><option value="_parent">Parent window</option></select></div><div style="text-align:right;"><input type="button" id="xhEdtSave" value="Ok" /></div>';var y='<div>Img URL:&nbsp; <input type="text" id="xhEdtImgSrc" value="http://" class="text" /></div><div>Alt text: <input type="text" id="xhEdtImgAlt" /></div><div>Alignment:<select id="xhEdtImgAlign"><option selected="selected" value="">Default</option><option value="left">Left</option><option value="right">Right</option><option value="top">Top</option><option value="middle">Middle</option><option value="baseline">Baseline</option><option value="bottom">Bottom</option></select></div><div>Dimension:<input type="text" id="xhEdtImgWidth" style="width:40px;" /> x <input type="text" id="xhEdtImgHeight" style="width:40px;" /></div><div>Border:&nbsp;&nbsp;&nbsp;<input type="text" id="xhEdtImgBorder" style="width:40px;" /></div><div>Hspace:&nbsp;&nbsp;&nbsp;<input type="text" id="xhEdtImgHspace" style="width:40px;" /> Vspace:<input type="text" id="xhEdtImgVspace" style="width:40px;" /></div><div style="text-align:right;"><input type="button" id="xhEdtSave" value="OK" /></div>';var G='<div>Flash URL:<input type="text" id="xhEdtFlashSrc" value="http://" class="text" /></div><div>Dimension:<input type="text" id="xhEdtFlashWidth" style="width:40px;" value="480" /> x <input type="text" id="xhEdtFlashHeight" style="width:40px;" value="400" /></div><div style="text-align:right;"><input type="button" id="xhEdtSave" value="OK" /></div>';var x='<div>Media URL:<input type="text" id="xhEdtMediaSrc" value="http://" class="text" /></div><div>Dimension:<input type="text" id="xhEdtMediaWidth" style="width:40px;" value="480" /> x <input type="text" id="xhEdtMediaHeight" style="width:40px;" value="400" /></div><div style="text-align:right;"><input type="button" id="xhEdtSave" value="OK" /></div>';var g='<div>Rows&Cols:&nbsp;&nbsp;<input type="text" id="xhEdtTableRows" style="width:40px;" value="3" /> x <input type="text" id="xhEdtTableColumns" style="width:40px;" value="2" /></div><div>Headers:&nbsp;&nbsp;&nbsp;&nbsp;<select id="xhEdtTableHeaders"><option selected="selected" value="">None</option><option value="row">First row</option><option value="col">First column</option><option value="both">Both</option></select></div><div>Dimension:&nbsp;&nbsp;<input type="text" id="xhEdtTableWidth" style="width:40px;" value="200" /> x <input type="text" id="xhEdtTableHeight" style="width:40px;" value="" /></div><div>Border:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="xhEdtTableBorder" style="width:40px;" value="1" /></div><div>CellSpacing:<input type="text" id="xhEdtTableCellSpacing" style="width:40px;" value="1" /> CellPadding:<input type="text" id="xhEdtTableCellPadding" style="width:40px;" value="1" /></div><div>Align:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<select id="xhEdtTableAlign"><option selected="selected" value="">Default</option><option value="left">Left</option><option value="center">Center</option><option value="right">Right</option></select></div><div>Caption:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="xhEdtTableCaption" /></div><div style="text-align:right;"><input type="button" id="xhEdtSave" value="OK" /></div>';var q='<div style="width:200px;word-wrap:break-word;word-break:break-all;"><p><span style="font-size:20px;color:#1997DF;">xhEditor</span><br />ver: v0.9.9 build 20091123</p><p>xhEditor is a simple,small,fast WYSWYG(What You See What You Get) XHTML editor based by jQuery.</p><p><a href="http://xheditor.com/" target="_blank">http://xheditor.com/</a></p></div>';var n=[{t:"Big grin",s:"biggrin.gif"},{t:"Smile",s:"smile.gif"},{t:"Titter",s:"titter.gif"},{t:"Lol",s:"lol.gif"},{t:"Call",s:"call.gif"},{t:"Victory",s:"victory.gif"},{t:"Shy",s:"shy.gif"},{t:"Handshake",s:"handshake.gif"},{t:"Kiss",s:"kiss.gif"},{t:"Sad",s:"sad.gif"},{t:"Cry",s:"cry.gif"},{t:"Huffy",s:"huffy.gif"},{t:"Mad",s:"mad.gif"},{t:"Tongue",s:"tongue.gif"},{t:"Sweat",s:"sweat.gif"},{t:"Shocked",s:"shocked.gif"},{t:"Time",s:"time.gif"},{t:"Hug",s:"hug.gif"}];var v={GStart:{},GEnd:{},Separator:{},Cut:{t:"Cut (Ctrl+X)"},Copy:{t:"Copy (Ctrl+C)"},Paste:{t:"Paste (Ctrl+V)"},Pastetext:{t:"Paste as plain text"},Blocktag:{t:"Block tag"},Fontface:{t:"Font family"},FontSize:{t:"Font size"},Bold:{t:"Bold (Ctrl+B)",s:"Ctrl+B"},Italic:{t:"Italic (Ctrl+I)",s:"Ctrl+I"},Underline:{t:"Underline (Ctrl+U)",s:"Ctrl+U"},Strikethrough:{t:"Strikethrough (Ctrl+S)",s:"Ctrl+S"},FontColor:{t:"Select text color"},BackColor:{t:"Select background color"},Removeformat:{t:"Remove formatting"},Align:{t:"Align"},List:{t:"List"},Outdent:{t:"Outdent (Shift+Tab)",s:"Shift+Tab"},Indent:{t:"Indent (Tab)",s:"Tab"},Link:{t:"Insert/edit link"},Unlink:{t:"Unlink"},Img:{t:"Insert/edit image"},Flash:{t:"Insert/edit flash"},Media:{t:"Insert/edit media"},Emot:{t:"Emotions"},Table:{t:"Insert a new table"},Source:{t:"Edit source code"},Preview:{t:"Preview"},Fullscreen:{t:"Toggle fullscreen (Esc)",s:"Esc"},About:{t:"About xhEditor"}};var u={mini:"GStart,Bold,Italic,Underline,Strikethrough,GEnd,Separator,GStart,Align,List,GEnd,Separator,GStart,Link,Img,About,GEnd",simple:"GStart,Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,GEnd,Separator,GStart,Align,List,Outdent,Indent,GEnd,Separator,GStart,Link,Img,Emot,About,GEnd",full:"GStart,Cut,Copy,Paste,Pastetext,GEnd,Separator,GStart,Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,Removeformat,GEnd,Separator,GStart,Align,List,Outdent,Indent,GEnd,Separator,GStart,Link,Unlink,Img,Flash,Media,Emot,Table,GEnd,Separator,GStart,Source,Preview,Fullscreen,About,GEnd"};h.xheditor=function(W,L){var T={skin:"default",tools:"full",internalScript:false,inlineScript:false,internalStyle:false,inlineStyle:true,showBlocktag:false,forcePtag:true,keepValue:true,upLinkExt:"zip,rar,txt",upImgExt:"jpg,jpeg,gif,png",upFlashExt:"swf",upMediaExt:"avi",modalWidth:350,modalHeight:220,modalTitle:true,baseUrl:D,attachLinkText:"Click to open link"};var ac=this,J=W,ad=h(J),Q=ad.closest("form"),U,S,ak,K,aa;var R;var V=false,O=false,H=false,aj=false,Z=false,s=false,Y="",ah;var ag=0,ai=0;this.settings=h.extend({},T,L);if(ac.settings.plugins){v=h.extend({},v,ac.settings.plugins)}if(ac.settings.tools.match(/^\s*(mini|simple|full)\s*$/i)){ac.settings.tools=h.trim(ac.settings.tools);ac.settings.tools=u[ac.settings.tools]}if(!ac.settings.tools.match(/(^|,)\s*About\s*(,|$)/i)){ac.settings.tools+=",About"}ac.settings.tools=ac.settings.tools.split(",");var N="xhEdtCSS_"+ac.settings.skin,ab="xhEdt"+k+"_container",i="xhEdt"+k+"_Tool",X="xhEdt"+k+"_iframearea",af="xhEdt"+k+"_iframe";var ae="",I=B+"xheditor_skin/"+ac.settings.skin+"/";s=ac.settings.showBlocktag;if(s){ae+=" showBlocktag"}var M=[];this.init=function(){if(h("#"+N).size()==0){h("head").append('<link id="'+N+'" rel="stylesheet" type="text/css" href="'+I+'ui.css" />')}var al=ac.settings.width||J.style.width||ad.width();ai=ac.settings.height||ad.height();if(/^[0-9\.]+$/i.test(""+al)){al+="px"}var ao="",am,an=1;h.each(ac.settings.tools,function(ar,au){am=v[au];if(au=="GStart"){ao+='<span class="xhEdtGStart"/>'}else{if(au=="GEnd"){ao+='<span class="xhEdtGEnd"/>'}else{if(au=="Separator"){ao+='<span class="xhEdtSeparator"/>'}else{if(au=="BtnBr"){ao+="<br />";an++}else{var at;if(am.c){at=am.c}else{at="xhEdtIcon xhEdtBtn"+au}ao+='<span><a href="javascript:;" title="'+am.t+'" name="'+au+'" class="xhEdtButton xhEdtEnabled"><span class="'+at+'" /></a></span>';if(am.s){ac.addShortCut(am.s,au)}}}}}});ag=an*24+2;ao+="<br />";if((ai-ag)<16){ai=ag+16}ad.after(h('<span id="'+ab+'" class="xhEdt_'+ac.settings.skin+'" style="display:none"><table cellspacing="0" cellpadding="0" class="xhEdtLayout" style="width:'+al+";height:"+ai+'px;"><tbody><tr><td id="'+i+'" class="xhEdtTool" style="height:'+ag+'px"></td></tr><tr><td id="'+X+'" class="xhEdtIframeArea" style="height:'+(ai-ag)+'px"><iframe frameborder="0" id="'+af+'" src="javascript:;" style="width:100%;"></iframe></td></tr></tbody></table></span>'));var ap='<html><head><base target="_blank"'+(ac.settings.baseUrl!=D?' href="'+ac.settings.baseUrl+'"':"")+' /><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/><link rel="stylesheet" href="'+I+'iframe.css"/>';if(ac.settings.loadCSS){ap+='<link rel="stylesheet" href="'+ac.settings.loadCSS+'"/>'}ap+='</head><body spellcheck="false" dir="ltr" class="editMode'+ae+'"></body></html>';S=h("#"+af)[0].contentWindow;ak=h(S);try{K=S.document;aa=h(K);K.open();K.write(ap);K.close();if(r){K.body.contentEditable="true"}else{K.designMode="On"}}catch(aq){}setTimeout(ac.setOpts,300);ac.setSource();S.setInterval=null;U=h("#"+i).append(ao);U.find(".xhEdtButton").click(function(at){ac.hidePanel();ac.focus();ah=at;var ar=h(this);if(ar.is(".xhEdtEnabled")){ac.exec(ar.attr("name"))}ah.stopPropagation()}).mousedown(function(){return false});d=h("#xhEdtPanel");p=h("#xhEdtCntLine");if(d.size()==0){d=h('<div id="xhEdtPanel"></div>').mousedown(function(ar){ar.stopPropagation()});p=h('<div id="xhEdtCntLine"><img src="'+I+'img/spacer.gif" /></div>');h(document.body).append(d).append(p)}h(document).mousedown(ac.hidePanel);aa.mousedown(ac.hidePanel);h("#"+ab).show();ad.hide();ac.bind();k++;V=true;if(ac.settings.fullscreen){ac.toggleFullscreen()}if(ac.settings.readonly){ac.toggleReadonly(true)}else{if(ac.settings.sourceMode){setTimeout(ac.toggleSource,20)}}return true};this.remove=function(){ac.unbind();h("#"+ab).remove();ad.show();V=false};this.bind=function(){ad.focus(ac.focus);Q.submit(ac.getSource).bind("reset",ac.setSource);var al=h(window);al.unload(ac.getSource).bind("beforeunload",ac.getSource);al.resize(ac.fixFullHeight);ak.blur(ac.getSource).focus(function(){if(ac.settings.focus){ac.settings.focus()}}).blur(function(){if(ac.settings.blur){ac.settings.blur()}});if(F){ak.click(ac.fixAppleSel)}aa.keydown(ac.checkShortCut).keydown(ac.forcePtag)};this.unbind=function(){ad.unbind("focus",ac.focus);Q.unbind("submit",ac.getSource).unbind("reset",ac.setSource);var al=h(window);al.unbind("unload",ac.getSource).unbind("beforeunload",ac.getSource);al.unbind("resize",ac.fixFullHeight);ak.unbind("blur",ac.getSource);if(F){ak.unbind("click",ac.fixAppleSel)}aa.unbind("keydown",ac.checkShortCut).unbind("keydown",ac.forcePtag)};this.setCSS=function(al){try{ac._exec("styleWithCSS",al)}catch(am){try{ac._exec("useCSS",!al)}catch(am){}}};this.setOpts=function(){if(V&&!H&&!O){ac.setCSS(false);try{ac._exec("enableObjectResizing",true)}catch(al){}try{ac._exec("enableInlineTableEditing",false)}catch(al){}if(r){try{ac._exec("BackgroundImageCache",true)}catch(al){}}}};this.forcePtag=function(am){if(O||H||am.keyCode!=13||am.shiftKey||am.ctrlKey||am.altKey){return true}var al=ac.getParent("p,h1,h2,h3,h4,h5,h6,pre,address,div,li");if(ac.settings.forcePtag){if(al.size()==0){ac._exec("formatblock","<p>")}}else{ac.pasteHTML("<br />");return false}};this.fixFullHeight=function(){if(!l&&!F){var al=h("#"+X);al.height("100%");if(aj){al.height((al.height()-ag)+"px")}if(r){U.hide().show()}}};this.fixAppleSel=function(an){an=an.target;if(an.tagName.match(/(img|embed)/i)){var am=ac.getSel(),al=K.createRange();al.selectNode(an);am.removeAllRanges();am.addRange(al)}};this.focus=function(){if(!O){ak.focus()}else{h("#sourceCode",K).focus()}if(r&&!O&&R){R.select();R=null}return false};this.getSel=function(){return S.getSelection?S.getSelection():K.selection};this.getRng=function(){var an=ac.getSel(),al;try{al=an.rangeCount>0?an.getRangeAt(0):(an.createRange?an.createRange():K.createRange())}catch(am){}if(!al){al=r?K.body.createTextRange():K.createRange()}return al};this.getParent=function(al){var am=ac.getRng(),an;if(!r){an=am.commonAncestorContainer;if(!am.collapsed){if(am.startContainer==am.endContainer&&am.startOffset-am.endOffset<2&&am.startContainer.hasChildNodes()){an=am.startContainer.childNodes[am.startOffset]}}}else{an=am.item?am.item(0):am.parentElement()}al=al?al:"*";an=h(an);if(!an.is(al)){an=h(an).closest(al)}return an};this.getSelect=function(ap){var ao=ac.getSel(),al=ac.getRng(),am=true;if(!al||al.item){am=false}else{am=!ao||al.boundingWidth==0||al.collapsed}if(ap=="text"){return am?"":(al.text||(ao.toString?ao.toString():""))}var aq;if(al.cloneContents){var an=h("<div></div>"),ar;ar=al.cloneContents();if(ar){an.append(ar)}aq=an.html()}else{if(P(al.item)){aq=al.item(0).outerHTML}else{if(P(al.htmlText)){aq=al.htmlText}else{aq=al.toString()}}}aq=ac.processHTML(aq,"read");aq=ac.cleanHTML(aq);aq=ac.formatXHTML(aq);return aq};function P(am,al){var an=typeof(am);if(!al){return an!="undefined"}if(al=="array"&&(am.hasOwnProperty&&am instanceof Array)){return true}return an==al}this.pasteHTML=function(ao){if(O||H){return false}ac.focus();ao=ac.processHTML(ao,"write");var al=ac.getRng();ao+='<span id="__caret" />';if(al.insertNode){al.deleteContents();al.insertNode(al.createContextualFragment(ao))}else{al.pasteHTML(ao)}var am=h("#__caret",K),ap=am[0],an=ac.getSel();if(r){al.moveToElementText(ap);al.select()}else{al.selectNode(ap);an.removeAllRanges();an.addRange(al)}am.remove()};this.pasteText=function(al){if(!al){al=""}al=ac.domEncode(al);al=al.replace(/\r?\n/g,"<br>");ac.pasteHTML(al)};this.appendHTML=function(al){if(O||H){return false}ac.focus();al=ac.processHTML(al,"write");h(K.body).append(al)};this.domEncode=function(am){if(am){var al={"<":"&lt;",">":"&gt;"};am=am.replace(/[<>]/g,function(an){return al[an]})}return am};this.setSource=function(al){setTimeout(function(){ac._setSource(al)},10)};this._setSource=function(al){R=null;if(typeof al!="string"&&al!=""){al=ad.val()}if(O){h("#sourceCode",K).val(al)}else{if(ac.settings.beforeSetSource){al=ac.settings.beforeSetSource(al)}al=ac.formatXHTML(al);h(K.body)[0].innerHTML=ac.processHTML(al,"write")}};this.processHTML=function(at,ar){var ao=' class="Apple-style-span"';if(ar=="write"){if(ac.settings.keepValue){function al(ax,au,aw,aA,ay,av,az){aw+=" _xhe_"+aA+'="'+av+'"';return"<"+au+aw+" "+az+">"}at=at.replace(/<(\w+(?:\:\w+)?)(\s+[^>]*?(src|href)\s*=\s*(['"]?)\s*([^'"\s]*)\s*\4[^\/>]*?)(\/?)>/ig,al)}at=at.replace(/<(\/?)del( [^>]+)?>/ig,"<$1strike$2>");if(l){at=at.replace(/<(\/?)strong( [^>]+)?>/ig,"<$1b$2>");at=at.replace(/<(\/?)em( [^>]+)?>/ig,"<$1i$2>")}else{if(F){at=at.replace(/("|;)\s*font-size\s*:\s*([a-z-]+)(;?)/ig,function(ay,aA,au,az){var aw,ax;for(var av=0;av<w.length;av++){aw=w[av];if(au==aw.n){ax=aw.wkn;break}}return aA+"font-size:"+ax+az});at=at.replace(/<strong( [^>]+)?>/ig,"<span"+ao+' style="font-weight: bold;"$1>');at=at.replace(/<em( [^>]+)?>/ig,"<span"+ao+' style="font-style: italic;"$1>');at=at.replace(/<u( [^>]+)?>/ig,"<span"+ao+' style="text-decoration: underline;"$1>');at=at.replace(/<strike( [^>]+)?>/ig,"<span"+ao+' style="text-decoration: line-through;"$1>');at=at.replace(/<\/(strong|em|u|strike)>/ig,"</span>");at=at.replace(/<span((?:\s+[^>]+)?\s+style="([^"]*;)*\s*(font-family|font-size|color|background-color)\s*:\s*[^;"]+\s*;?"[^>]*)>/ig,"<span"+ao+"$1>")}else{if(r){at=at.replace(/&apos;/ig,"&#39;");at=at.replace(/\s+(disabled|checked|readonly|selected)\s*=\s*[\"\']?(false|0)[\"\']?/ig,"")}}}at=at.replace(/<a(\s+[^>]+)?\/>/,"<a$1></a>");if(!F){function ap(aA,aE,au,ax){var aD="",aw,aC,aB,az;aw=au.match(/font-family\s*:\s*([^;"]+)/i);if(aw){aD+=' face="'+aw[1]+'"'}aC=au.match(/font-size\s*:\s*([^;"]+)/i);if(aC){aC=aC[1].toLowerCase();for(var av=0;av<w.length;av++){if(aC==w[av].n||aC==w[av].s){aB=av+1;break}}if(aB){aD+=' size="'+aB+'"';au=au.replace(/(^|;)(\s*font-size\s*:\s*[^;"]+;?)+/ig,"$1")}}az=au.match(/(?:^|[\s;])color\s*:\s*([^;"]+)/i);if(az){var ay;if(ay=az[1].match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i)){ay=Number(ay[1])*65536+Number(ay[2])*256+Number(ay[3]);ay=ay.toString(16);while(ay.length<6){ay="0"+ay}az[1]="#"+ay}else{if(ay=az[1].match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i)){az[1]="#"+ay[1]+ay[1]+ay[2]+ay[2]+ay[3]+ay[3]}}aD+=' color="'+az[1]+'"'}au=au.replace(/(^|;)(\s*(font-family|color)\s*:\s*[^;"]+;?)+/ig,"$1");if(aD!=""){if(au){aD+=' style="'+au+'"'}return"<font"+aD+">"+ax+"</font>"}else{return aA}}at=at.replace(/<(span)(?:\s+[^>]+)? style="((?:[^"]*?;)*\s*(?:font-family|font-size|color)\s*:[^"]*)"(?: [^>]+)?>(((?!<\1(\s+[^>]+)?>)[\s\S])*?)<\/\1>/ig,ap);at=at.replace(/<(span)(?:\s+[^>]+)? style="((?:[^"]*?;)*\s*(?:font-family|font-size|color)\s*:[^"]*)"(?: [^>]+)?>(((?!<\1(\s+[^>]+)?>)[\s\S]|<\1(\s+[^>]+)?>((?!<\1(\s+[^>]+)?>)[\s\S])*?<\/\1>)*?)<\/\1>/ig,ap);at=at.replace(/<(span)(?:\s+[^>]+)? style="((?:[^"]*?;)*\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,ap)}}else{if(ac.settings.keepValue){function am(ax,au,aw,az,ay,av){aw=aw.replace(new RegExp("\\s+"+az+"\\s*=\\s*([\"']?)[^\"'\\s]*\\1","ig")," "+az+'="'+av+'"');return"<"+au+aw+">"}at=at.replace(/<(\w+(?:\:\w+)?)(\s+[^>]*?_xhe_(src|href)\s*=\s*(['"]?)\s*([^'"\s]*)\s*\4[^>]*)>/ig,am)}if(F){at=at.replace(/("|;)\s*font-size\s*:\s*([a-z-]+)(;?)/ig,function(ay,aA,au,az){var aw,ax;for(var av=0;av<w.length;av++){aw=w[av];if(au==aw.wkn){ax=aw.n;break}}return aA+"font-size:"+ax+az});var aq=[{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"}];function an(aA,av,ax,aw,aB){var au=ax+aw,az="";for(var ay=0;ay<aq.length;ay++){if(au.match(aq[ay].r)){az=aq[ay].t;break}}if(az){return"<"+az+">"+aB+"</"+az+">"}else{return aA}}at=at.replace(/<(span)(\s+[^>]+|)? class="Apple-style-span"(\s+[^>]+|)?>(((?!<\1(\s+[^>]+)?>)[\s\S])*?)<\/\1>/ig,an);at=at.replace(/<(span)(\s+[^>]+|)? class="Apple-style-span"(\s+[^>]+|)?>(((?!<\1(\s+[^>]+)?>)[\s\S]|<\1(\s+[^>]+)?>((?!<\1(\s+[^>]+)?>)[\s\S])*?<\/\1>)*?)<\/\1>/ig,an);at=at.replace(/<(span)(\s+[^>]+|)? class="Apple-style-span"(\s+[^>]+|)?>(((?!<\1(\s+[^>]+)?>)[\s\S]|<\1(\s+[^>]+)?>((?!<\1(\s+[^>]+)?>)[\s\S]|<\1(\s+[^>]+)?>((?!<\1(\s+[^>]+)?>)[\s\S])*?<\/\1>)*?<\/\1>)*?)<\/\1>/ig,an)}at=at.replace(/(\s+)(?:_xhe_|_moz_|_webkit_)[^=]+?\s*=\s*(["']?)[^"'\s>]*\2\s*/ig,"$1");at=at.replace(/<(\w+[^>]*?)\s+class="?(?:apple|webkit)\-[^ >]*([^>]*?)>/ig,"<$1$2>")}return at};this.getSource=function(){var al;if(O){al=h("#sourceCode",K).val()}else{al=ac.processHTML(h(K.body).html(),"read");al=ac.cleanWord(al);al=ac.cleanHTML(al);al=ac.formatXHTML(al);if(ac.settings.beforeGetSource){al=ac.settings.beforeGetSource(al)}}ad.val(al);return al};this.cleanWord=function(al){if(al.match(/mso-|MsoNormal/i)){al=al.replace(/<!--([\s\S]*?)-->|<style(\s+[^>]+)?>[\s\S]*?<\/style>/ig,"");al=al.replace(/<\/?\w+:[^>]*>/ig,"");al=al.replace(/<(\w+[^>]*?)\s+class="?mso[^ >]*([^>]*?)>/ig,"<$1$2>");al=al.replace(/<(\w+[^>]*?)\s+lang="?[^ \>]*([^>]*?)>/ig,"<$1$2>");al=al.replace(/<(\w+[^>]*?)\s+align="?left"?([^>]*?)>/ig,"<$1$2>");al=al.replace(/\s*mso-[^:]+:[^;"]+;?\s*/ig,"");al=al.replace(/\s*margin: 0cm 0cm 0pt\s*;\s*/ig,"");al=al.replace(/\s*margin: 0cm 0cm 0pt\s*"/ig,'"');al=al.replace(/\s*text-align:[^;"]+;?\s*/ig,"");al=al.replace(/\s*font-variant:[^;"]+;?\s*/ig,"");al=al.replace(/<(\w+[^>]*?)\s+style="?"?(\s+|>)/ig,"<$1$2");al=al.replace(/<(\w+[^>]*?)\s+style="?\s*([^">]+)\s*"?([^>]*?)>/ig,function(ao,an,ap,am){return"<"+an+' style="'+ap.replace(/&quot;/ig,"")+'"'+am+">"})}return al};this.cleanHTML=function(am){am=am.replace(/<\??xml(:\w+)?( [^>]+)?>([\s\S]*?<\/xml>)?/ig,"");am=am.replace(/<(meta|link)(\s+[^>]+)?>/ig,"");if(!ac.settings.internalScript){am=am.replace(/<(script)(\s+[^>]+)?>(((?!<\1(\s+[^>]+)?>)[\s\S]|<\1(\s+[^>]+)?>((?!<\1(\s+[^>]+)?>)[\s\S]|<\1(\s+[^>]+)?>((?!<\1(\s+[^>]+)?>)[\s\S])*?<\/\1>)*?<\/\1>)*?)<\/\1>/ig,"")}if(!ac.settings.inlineScript){am=am.replace(/<(\w+)(\s+[^>]+?)?\s+on(?:click|dblclick|mousedown|mouseup|mousemove|mouseover|mouseout|mouseenter|mouseleave|keydown|keypress|keyup|change|select|submit|reset|blur|focus|load|unload)\s*=\s*(["']?)[^"']*?\3(\s+[^>]+?)?>/ig,"<$1$2$4>")}if(!ac.settings.internalStyle){am=am.replace(/<(style)(\s+[^>]+)?>(((?!<\1(\s+[^>]+)?>)[\s\S]|<\1(\s+[^>]+)?>((?!<\1(\s+[^>]+)?>)[\s\S]|<\1(\s+[^>]+)?>((?!<\1(\s+[^>]+)?>)[\s\S])*?<\/\1>)*?<\/\1>)*?)<\/\1>/ig,"")}if(!ac.settings.inlineStyle){am=am.replace(/<(\w+)(\s+[^>]+?)?\s+style\s*=\s*(["']?)[^"']*?\3(\s+[^>]+?)?>/ig,"<$1$2$4>")}for(var al=0;al<3;al++){am=am.replace(/<(strong|b|u|del|strike|s|em|i)(?:\s+[^>]+)?>(((?!<\1(\s+[^>]+)?>)([ \t\r\n]|&nbsp;))*?)<\/\1>/ig,function(ao,an,ap){if(ap.match(/&nbsp;/i)){return ap.replace(/ +/g,"")}else{return""}})}am=am.replace(/<\/(strong|b|u|strike|em|i)>((?:\s|<br\/?>|&nbsp;)*?)<\1>/ig,"$2");am=am.replace(/<(p|div)(?:\s+[^>]+)?>(((?!<\1(?: [^>]+)?>)[\s\S])+?)<\/\1>/ig,function(ap,an,aq){var ao=aq.replace(/<\/?(span|strong|b|u|strike|em|i)(\s+[^>]+)?>/ig,"");ao=ao.replace(/([ \t\r\n]|&nbsp;)+/ig,"");if(ao!=""){return ap}else{return"<"+an+"></"+an+">"}});am=am.replace(/^(\r?\n)+/g,"");am=am.replace(/(\r?\n)+/g,"\r\n");am=am.replace(/\s+$/g,"");return am};this.formatXHTML=function(ay){var au=ax("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed");var an=ax("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,table,tbody,td,tfoot,th,thead,tr,ul");var al=ax("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,del,strong,sub,sup,textarea,tt,u,var");var aH=ax("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr");var av=ax("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected");var aG=ax("script,style");var am={b:"strong",i:"em",s:"del",strike:"del"};var aD=/^<(\w+(?:\:\w+)?)((?:\s+[\w-\:]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/;var ar=/^<\/(\w+(?:\:\w+)?)[^>]*>/;var aB=/([\w-(?:\:\w+)?]+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;var ap,aA=0,ao=[],at=ay,aw="",az=[];ao.last=function(){return this[this.length-1]};while(ay){if(!ao.last()||!aG[ao.last()]){aA=0;if(ay.indexOf("<!")==0){match=ay.match(/^<!(?:--)?(.*?)(?:--)?>/);if(match){aA=match[0].length;az.push("<!--"+match[1]+"-->")}else{aA=1}}else{if(ay.indexOf("</")==0){match=ay.match(ar);if(match){aA=match[0].length;match[0].replace(ar,aE)}else{aA=1}}else{if(ay.indexOf("<")==0){match=ay.match(aD);if(match){aA=match[0].length;match[0].replace(aD,aF)}else{aA=1}}}}if(aA==1){az.push("&lt;")}if(aA>0){ay=ay.substring(aA)}else{ap=ay.search(/<[^<>]+>/);aw=ap<0?ay:ay.substring(0,ap);ay=ap<0?"":ay.substring(ap);az.push(ac.domEncode(aw))}}else{ay=ay.replace(/^([\s\S]*?)<\/(?:style|script)>/i,function(aI,aJ){az.push(aJ);return""});aE("",ao.last())}at=ay}aE();ay=az.join("");function ax(aL){var aK={},aI=aL.split(",");for(var aJ=0;aJ<aI.length;aJ++){aK[aI[aJ]]=true}return aK}function aq(aJ){if(aJ){aJ=aJ.toLowerCase();var aI=am[aJ];if(aI){aJ=aI}}else{aJ=""}return aJ}function aF(aI,aK,aL,aJ){aK=aq(aK);if(an[aK]){while(ao.last()&&al[ao.last()]){aE("",ao.last())}}if(aH[aK]&&ao.last()==aK){aE("",aK)}aJ=au[aK]||!!aJ;if(!aJ){ao.push(aK)}az.push("<"+aK);aL.replace(aB,function(aN,aM){aM=aM.toLowerCase();var aO=arguments[2]?arguments[2]:arguments[3]?arguments[3]:arguments[4]?arguments[4]:av[aM]?aM:"";if(aO){az.push(" "+aM+'="'+aO.replace(/(^|[^\\])"/g,'$1\\"')+'"')}});az.push((aJ?" /":"")+">")}function aE(aI,aK){if(!aK){var aL=0}else{aK=aq(aK);for(var aL=ao.length-1;aL>=0;aL--){if(ao[aL]==aK){break}}}if(aL>=0){for(var aJ=ao.length-1;aJ>=aL;aJ--){az.push("</"+ao[aJ]+">")}ao.length=aL}}function aC(aM,aQ,aN,aK){var aO="",aJ,aP,aL,aI;aJ=aN.match(/ face\s*=\s*"\s*([^"]+)\s*"/i);if(aJ){aO+="font-family:"+aJ[1]+";"}aP=aN.match(/ size\s*=\s*"\s*(\d+)\s*"/i);if(aP){aO+="font-size:"+w[aP[1]-1].n+";"}aL=aN.match(/ color\s*=\s*"\s*([^"]+)\s*"/i);if(aL){aO+="color:"+aL[1]+";"}aI=aN.match(/ style\s*=\s*"\s*([^"]+)\s*"/i);if(aI){aO+=aI[1]}if(aO){aK='<span style="'+aO+'">'+aK+"</span>"}return aK}ay=ay.replace(/<(font)(\s+[^>]+|)?>(((?!<\1(\s+[^>]+)?>)[\s\S])*?)<\/\1>/ig,aC);ay=ay.replace(/<(font)(\s+[^>]+|)?>(((?!<\1(\s+[^>]+)?>)[\s\S]|<\1(\s+[^>]+)?>((?!<\1(\s+[^>]+)?>)[\s\S])*?<\/\1>)*?)<\/\1>/ig,aC);ay=ay.replace(/<(font)(\s+[^>]+|)?>(((?!<\1(\s+[^>]+)?>)[\s\S]|<\1(\s+[^>]+)?>((?!<\1(\s+[^>]+)?>)[\s\S]|<\1(\s+[^>]+)?>((?!<\1(\s+[^>]+)?>)[\s\S])*?<\/\1>)*?<\/\1>)*?)<\/\1>/ig,aC);return ay};this.toggleShowBlocktag=function(am){if(s===am){return}s=!s;var al=h(K.body);if(s){ae+=" showBlocktag";al.addClass("showBlocktag")}else{ae=ae.replace(" showBlocktag","");al.removeClass("showBlocktag")}};this.toggleReadonly=function(al){if(Z===al){return}if(O){ac.toggleSource(true)}Z=!Z;if(Z){if(!H){ac.togglePreview(true)}U.find("[name=Preview]").toggleClass("xhEdtEnabled").toggleClass("xhEdtActive")}else{U.find("[name=Preview]").toggleClass("xhEdtEnabled").toggleClass("xhEdtActive");if(H){ac.togglePreview()}}};this.toggleSource=function(am){if(H||O===am){return}U.find("[name=Source]").toggleClass("xhEdtEnabled").toggleClass("xhEdtActive");U.find(".xhEdtButton").not("[name=Source],[name=Fullscreen],[name=About]").toggleClass("xhEdtEnabled");if(t){ac.hidePanel()}var al=h(K.body),an=ac.getSource();if(!O){if(r){K.body.contentEditable="false"}else{K.designMode="Off"}al.attr("scroll","no").attr("class","sourceMode").html('<textarea id="sourceCode" wrap="soft" spellcheck="false" height="100%" />');al.find("#sourceCode").blur(ac.getSource)}else{al.find("#sourceCode").remove();if(r){K.body.contentEditable="true"}else{K.designMode="On";if(l){ac._exec("inserthtml","-")}}al.removeAttr("scroll").attr("class","editMode"+ae);setTimeout(function(){S.scrollTo(0,0)},10)}O=!O;ac._setSource(an);U.find("[name=Source]").toggleClass("xhEdtEnabled");setTimeout(ac.setOpts,300)};this.togglePreview=function(am){if(O||H===am){return}U.find("[name=Preview]").toggleClass("xhEdtActive").toggleClass("xhEdtEnabled");U.find(".xhEdtButton").not("[name=Preview],[name=Fullscreen],[name=About]").toggleClass("xhEdtEnabled");var al=h(K.body);if(!H){if(r){K.body.contentEditable="false"}else{K.designMode="Off"}al.attr("class","previewMode");al[0].innerHTML=al.html()}else{if(r){K.body.contentEditable="true"}else{K.designMode="On"}al.attr("class","editMode"+ae);al[0].innerHTML=al.html()}H=!H;U.find("[name=Preview]").toggleClass("xhEdtEnabled");setTimeout(ac.setOpts,300)};this.toggleFullscreen=function(ao){if(aj===ao){return}if(t){ac.hidePanel()}var am=h("#"+X),an=h("#"+ab).find(".xhEdtLayout"),al=h("#"+ab);if(aj){if(h.boxModel===false){ad.after(al)}an.attr("style",Y);am.height(ai-ag)}else{if(h.boxModel===false){h("body").append(al)}Y=an.attr("style");an.removeAttr("style");am.height("100%");setTimeout(ac.fixFullHeight,100)}aj=!aj;al.toggleClass("xhEdt_Fullscreen");h("html").toggleClass("xhEdt_Fullfix");U.find("[name=Fullscreen]").toggleClass("xhEdtActive");setTimeout(ac.setOpts,300)};this.addShortCut=function(al,am){M[al.toLowerCase()]=am};this.checkShortCut=function(an){if(O||H){return true}ah=an;var am=ah.which,al=C[am],ao=al?al:String.fromCharCode(am).toLowerCase();sKey="";sKey+=ah.ctrlKey?"ctrl+":"";sKey+=ah.altKey?"alt+":"";sKey+=ah.shiftKey?"shift+":"";sKey+=ao;if(M[sKey]){ac.exec(M[sKey]);return false}};this.showMenu=function(an,ao){var am=h('<div class="xhEdtMenu"></div>'),al;h.each(an,function(aq,ap){al=h('<a href="javascript:;" title="'+ap.t+'">'+ap.s+"</a>").click(function(){ac.focus();ao(ap.v);ac.hidePanel()}).mousedown(function(){return false});am.append(al)});ac.showPanel(am)};this.showColor=function(ap){var am=h('<div class="xhEdtColor"></div>'),an,al,ao=0;an=h("<div></div>");h.each(m,function(ar,aq){ao++;al=h('<a href="javascript:;" title="'+aq+'" style="background:'+aq+'"><img src="'+I+'img/spacer.gif" /></a>').click(function(){ac.focus();ap(aq);ac.hidePanel()}).mousedown(function(){return false});an.append(al);if(ao%10==0){am.append(an);an=h("<div></div>")}});am.append(an);ac.showPanel(am)};this.showPastetext=function(){var am=h(a);var an=h("#xhEdtPastetextValue",am),al=h("#xhEdtSave",am);al.click(function(){ac.focus();var ao=an.val();if(ao){ac.pasteText(ao)}ac.hidePanel();return false});ac.showDialog(am)};this.attr=function(an,ao,al){if(!ao){return false}var am="_xhe_"+ao;if(al){an.attr(ao,al);if(ac.settings.keepValue){an.removeAttr(am).attr(am,al)}}al=an.attr(ao);if(ac.settings.keepValue){al=an.attr(am)||al}return al};this.showLink=function(){var am=h(b);var an=ac.getParent("a"),ap=h("#xhEdtLinkHref",am),ao=h("#xhEdtLinkTarget",am),al=h("#xhEdtSave",am);if(an.size()==1){ap.val(ac.attr(an,"href"));ao.attr("value",an.attr("target"))}if(ac.settings.upLinkUrl){ac.ajaxUploadInit(ap,ac.settings.upLinkUrl,ac.settings.upLinkExt)}al.click(function(){ac.focus();var aq=ap.val();if(aq==""||an.size()==0){ac._exec("unlink")}if(aq!=""){if(an.size()==0){if(ac.getSelect("text")==""){ac.pasteHTML('<a href="#xhedt_tempurl">'+ac.settings.attachLinkText+"</a>")}else{ac._exec("createlink","#xhedt_tempurl")}an=h('a[href$="#xhedt_tempurl"]',K)}ac.attr(an,"href",aq);if(ao.val()!=""){an.attr("target",ao.val())}else{an.removeAttr("target")}}ac.hidePanel();return false});ac.showDialog(am)};this.showImg=function(){var au=h(y);var an=ac.getParent("img"),ao=h("#xhEdtImgSrc",au),av=h("#xhEdtImgAlt",au),ax=h("#xhEdtImgAlign",au),ap=h("#xhEdtImgWidth",au),aq=h("#xhEdtImgHeight",au),aw=h("#xhEdtImgBorder",au),al=h("#xhEdtImgVspace",au),ar=h("#xhEdtImgHspace",au),at=h("#xhEdtSave",au);if(an.size()==1){ao.val(ac.attr(an,"src"));av.val(an.attr("alt"));ax.val(an.attr("align"));ap.val(an.attr("width"));aq.val(an.attr("height"));aw.val(an.attr("border"));var am=an.attr("vspace"),ay=an.attr("hspace");al.val(am<0?0:am);ar.val(ay<0?0:ay)}if(ac.settings.upImgUrl){ac.ajaxUploadInit(ao,ac.settings.upImgUrl,ac.settings.upImgExt)}at.click(function(){ac.focus();var aA=ao.val();if(aA!=""){aA=aA.split("|");if(an.size()==0){ac.pasteHTML('<img src="#xhedt_tempurl" />');an=h('img[src$="#xhedt_tempurl"]',K)}ac.attr(an,"src",aA[0]);if(av.val()!=""){an.attr("alt",av.val())}else{an.removeAttr("alt")}if(ax.val()!=""){an.attr("align",ax.val())}else{an.removeAttr("align")}if(ap.val()!=""){an.attr("width",ap.val())}else{an.removeAttr("width")}if(aq.val()!=""){an.attr("height",aq.val())}else{an.removeAttr("height")}if(aw.val()!=""){an.attr("border",aw.val())}else{an.removeAttr("border")}if(al.val()!=""){an.attr("vspace",al.val())}else{an.removeAttr("vspace")}if(ar.val()!=""){an.attr("hspace",ar.val())}else{an.removeAttr("hspace")}if(aA[1]){var az=an.parent("a");if(az.size()==0){an.wrap("<a></a>");az=an.parent("a")}ac.attr(az,"href",aA[1]);az.attr("target","_blank")}}else{if(an.size()==1){an.remove()}}ac.hidePanel();return false});ac.showDialog(au)};this.showFlash=function(){var an=h(G);var ao=ac.getParent('embed[type="application/x-shockwave-flash"]'),aq=h("#xhEdtFlashSrc",an),ap=h("#xhEdtFlashWidth",an),al=h("#xhEdtFlashHeight",an),am=h("#xhEdtSave",an);if(ao.size()==1){aq.val(ac.attr(ao,"src"));ap.val(ao.attr("width"));al.val(ao.attr("height"))}if(ac.settings.upFlashUrl){ac.ajaxUploadInit(aq,ac.settings.upFlashUrl,ac.settings.upFlashExt)}am.click(function(){ac.focus();var at=aq.val();if(at!=""){if(ao.size()==0){ac.pasteHTML('<embed type="application/x-shockwave-flash" src="#xhedt_tempurl" wmode="opaque" quality="high" bgcolor="#ffffff" menu="false" play="true" loop="true" />');ao=h('embed[src$="#xhedt_tempurl"]',K)}ac.attr(ao,"src",at);var ar=ap.val(),av=al.val(),au=/^[0-9]+$/;if(!au.test(ar)){ar=412}if(!au.test(av)){av=300}ao.attr("width",ar);ao.attr("height",av)}else{if(ao.size()==1){ao.remove()}}ac.hidePanel();return false});ac.showDialog(an)};this.showMeida=function(){var aq=h(x);var an=ac.getParent('embed[type="application/x-mplayer2"]'),ap=h("#xhEdtMediaSrc",aq),ao=h("#xhEdtMediaWidth",aq),al=h("#xhEdtMediaHeight",aq),am=h("#xhEdtSave",aq);if(an.size()==1){ap.val(ac.attr(an,"src"));ao.val(an.attr("width"));al.val(an.attr("height"))}if(ac.settings.upMediaUrl){ac.ajaxUploadInit(ap,ac.settings.upMediaUrl,ac.settings.upMediaExt)}am.click(function(){ac.focus();var at=ap.val();if(at!=""){if(an.size()==0){ac.pasteHTML('<embed type="application/x-mplayer2" src="#xhedt_tempurl" enablecontextmenu="false" autostart="false" />');an=h('embed[src$="#xhedt_tempurl"]',K)}ac.attr(an,"src",at);var ar=ao.val(),av=al.val(),au=/^[0-9]+$/;if(!au.test(ar)){ar=412}if(!au.test(av)){av=300}an.attr("width",ar);an.attr("height",av)}else{if(an.size()==1){an.remove()}}ac.hidePanel();return false});ac.showDialog(aq)};this.ajaxUploadInit=function(ao,am,ap){var an='<span class="upload"><input type="text" style="visibility:hidden;" /><input type="button" value="Upload" class="btn" />',al;if(am.substr(0,1)=="!"){al=h(an+"</span>");ao.after(al);h(".btn",al).before(ao).click(function(){ac.showIframeModal(am.substr(1),"Upload file",function(ar){if(ar.substr(0,1)=="!"){ao.val(ar.substr(1));ao.closest(".xhEdtDialog").find("#xhEdtSave").click()}else{ao.val(ar)}})})}else{al=h(an+'<input type="file" class="file" size="13" name="upload" id="xhEdtUploadFile" /></span>');ao.after(al);h(".btn",al).before(ao);var aq=h("#xhEdtUploadFile",al);aq.change(function(){var at=aq.val();if(at!=""){if(at.match(new RegExp(".("+ap.replace(/,/g,"|")+")$","i"))){var ar=ac.showModal("Upload file",'<div style="margin:22px 0;text-align:center;line-height:30px;">File uploading,please wait...<br /><img src="'+I+'img/loading.gif"></div>',320,150);ac.ajaxUpload(aq,am,function(au){ar.unloadme();if(au.err){alert(au.err)}else{var av=au.msg;if(av.substr(0,1)=="!"){ao.val(av.substr(1));ao.closest(".xhEdtDialog").find("#xhEdtSave").click()}else{ao.val(av)}}})}else{alert("Upload file extension required for this:"+ap)}}})}};this.ajaxUpload=function(ao,al,at){var ar=new Date().getTime(),aq="jUploadFrame"+ar;var am=h('<iframe name="'+aq+'" class="xhEdtUploadIO" />').appendTo("body");var an=h('<form action="'+al+'" target="'+aq+'" method="post" enctype="multipart/form-data" class="xhEdtUploadForm"></form>').appendTo("body");var au=h(ao),ap=au.clone().attr("disabled","true");au.before(ap).appendTo(an);an.submit();am.load(function(){setTimeout(function(){ap.before(au).remove();am.remove();an.remove()},100);var av=h(am[0].contentWindow.document.body).text(),ax=Object;try{eval("data="+av)}catch(aw){}if(data.err!=undefined&&data.msg!=undefined){at(data)}else{alert(al+" upload interface error!")}})};this.showIframeModal=function(aq,ap,ar,al,an){var am=h('<iframe frameborder="0" src="'+aq+'" style="width:100%;" />');var ao=ac.showModal(ap,am,al,an);am.load(function(){var at=am[0].contentWindow;at.callback=ar;at.unloadme=ao.unloadme})};this.showModal=function(ar,ap,am,ao,al){var an=h('<div class="xhEdtOverlay"></div>').appendTo("body").mousedown(function(){return false});am=am?am:ac.settings.modalWidth;ao=ao?ao:ac.settings.modalHeight;var aq=h('<div class="xhEdtModal" style="width:'+am+"px;height:"+ao+"px;margin:-"+Math.ceil(ao/2)+"px 0px 0px -"+Math.ceil(am/2)+'px;">'+(ac.settings.modalTitle?'<div class="xhEdtTitle"><span class="xhEdtClose" title="Close"></span>'+ar+"</div>":"")+'<div class="xhEdtContent"></div></div>').appendTo("body").mousedown(function(){return false});this.unloadme=function(){aq.remove();an.remove();if(al){al()}};h(".xhEdtClose",aq).click(this.unloadme);h(".xhEdtContent",aq).html(ap);an.show();aq.show();return this};this.showEmot=function(){var ap=h('<div class="xhEdtEmot"></div>'),an,al,ao=0,am=B+"xheditor_emot/default/";an=h("<div></div>");h.each(n,function(ar,aq){ao++;al=h('<a href="javascript:;" title="'+aq.t+'"><img src="'+am+aq.s+'" /></a>').click(function(){ac.focus();ac.pasteHTML('<img src="'+am+aq.s+'" alt="'+aq.t+'">');ac.hidePanel()}).mousedown(function(){return false});an.append(al);if(ao%6==0){ap.append(an);an=h("<div></div>")}});ap.append(an);ac.showPanel(ap)};this.showTable=function(){var am=h(g);var al=h("#xhEdtTableRows",am),ax=h("#xhEdtTableColumns",am),au=h("#xhEdtTableHeaders",am),ao=h("#xhEdtTableWidth",am),ap=h("#xhEdtTableHeight",am),aw=h("#xhEdtTableBorder",am),an=h("#xhEdtTableCellSpacing",am),ar=h("#xhEdtTableCellPadding",am),av=h("#xhEdtTableAlign",am),aq=h("#xhEdtTableCaption",am),at=h("#xhEdtSave",am);at.click(function(){ac.focus();var aK=aq.val(),aJ=aw.val(),aC=al.val(),ay=ax.val(),aA=au.val(),az=ao.val(),aG=ap.val(),aE=an.val(),aH=ar.val(),aI=av.val();var aF,aD,aB="<table"+(aJ!=""?' border="'+aJ+'"':"")+(az!=""?' width="'+az+'"':"")+(aG!=""?' width="'+aG+'"':"")+(aE!=""?' cellspacing="'+aE+'"':"")+(aH!=""?' cellpadding="'+aH+'"':"")+(aI!=""?' align="'+aI+'"':"")+">";if(aK!=""){aB+="<caption>"+aK+"</caption>"}if(aA=="row"||aA=="both"){aB+="<tr>";for(aF=0;aF<ay;aF++){aB+='<th scope="col">&nbsp;</th>'}aB+="</tr>";aC--}aB+="<tbody>";for(aF=0;aF<aC;aF++){aB+="<tr>";for(aD=0;aD<ay;aD++){if(aD==0&&(aA=="col"||aA=="both")){aB+='<th scope="row">&nbsp;</th>'}else{aB+="<td>&nbsp;</td>"}}aB+="</tr>"}aB+="</tbody></table>";ac.pasteHTML(aB);ac.hidePanel();return false});ac.showDialog(am)};this.showAbout=function(){var am=h(q);var al=h("#xhEdtSave",am);al.click(function(){ac.focus();ac.hidePanel();return false});ac.showDialog(am)};this.showDialog=function(am){var al=h('<div class="xhEdtDialog"></div>');al.append(am);ac.showPanel(al)};this.showPanel=function(am){if(t){ac.hidePanel()}d.empty().append(am).css("left",0).css("top",0);j=h(ah.target).closest("a");var an=j.offset();var al=an.left,ao=an.top;ao+=j.height();j.addClass("xhEdtActive");p.css("left",al+1).css("top",ao).show();if((al+d.width())>document.body.clientWidth){al-=(d.width()-j.width())}d.css("left",al).css("top",ao).show();if(r&&!O){R=ac.getRng()}t=true};this.hidePanel=function(){if(t){j.removeClass("xhEdtActive");p.hide();d.hide();R=null;t=false}};this.exec=function(ao){var aq=v[ao].e;if(aq){return aq.call(this)}ao=ao.toLowerCase();switch(ao){case"cut":try{K.execCommand(ao);if(!K.queryCommandSupported(ao)){throw"Error"}}catch(an){alert("Currently not supported by your browser, use keyboard shortcuts(Ctrl+X) instead.")}break;case"copy":try{K.execCommand(ao);if(!K.queryCommandSupported(ao)){throw"Error"}}catch(an){alert("Currently not supported by your browser, use keyboard shortcuts(Ctrl+C) instead.")}break;case"paste":try{K.execCommand(ao);if(!K.queryCommandSupported(ao)){throw"Error"}}catch(an){alert("Currently not supported by your browser, use keyboard shortcuts(Ctrl+V) instead.")}break;case"pastetext":if(window.clipboardData){ac.pasteText(window.clipboardData.getData("Text",true))}else{ac.showPastetext()}break;case"blocktag":var ap=[];h.each(A,function(at,ar){ap.push({s:"<"+ar.n+">"+ar.t+"</"+ar.n+">",v:"<"+ar.n+">",t:ar.t})});ac.showMenu(ap,function(ar){ac._exec("formatblock",ar)});break;case"fontface":var al=[];h.each(c,function(at,ar){al.push({s:'<span style="font-family:'+ar+'">'+ar+"</span>",v:ar,t:ar})});ac.showMenu(al,function(ar){ac._exec("fontname",ar)});break;case"fontsize":var am=[];h.each(w,function(at,ar){am.push({s:'<span style="font-size:'+ar.s+'">'+ar.t+"("+ar.s+")</span>",v:at+1,t:ar.t})});ac.showMenu(am,function(ar){ac._exec("fontsize",ar)});break;case"fontcolor":ac.showColor(function(ar){ac._exec("forecolor",ar)});break;case"backcolor":ac.showColor(function(ar){if(r){ac._exec("backcolor",ar)}else{ac.setCSS(true);ac._exec("hilitecolor",ar);ac.setCSS(false)}});break;case"align":ac.showMenu(e,function(ar){ac._exec(ar)});break;case"list":ac.showMenu(f,function(ar){ac._exec(ar)});break;case"link":ac.showLink();break;case"img":ac.showImg();break;case"flash":ac.showFlash();break;case"media":ac.showMeida();break;case"emot":ac.showEmot();break;case"table":ac.showTable();break;case"source":ac.toggleSource();break;case"preview":ac.togglePreview();break;case"fullscreen":ac.toggleFullscreen();break;case"about":ac.showAbout();break;default:ac._exec(ao);break}};this._exec=function(al,am){if(am!=undefined){return K.execCommand(al,false,am)}else{return K.execCommand(al,false,null)}}};h(function(){h("textarea.xheditor").xheditor(true);h("textarea.xheditor-mini").xheditor(true,{tools:"mini"});h("textarea.xheditor-simple").xheditor(true,{tools:"simple"})})})(jQuery);