libreccm-legacy/ccm-core/web/assets/xinha/XinhaCore.js

17 lines
94 KiB
JavaScript

/* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */
/* The URL of the most recent uncompressed version of this file is http://svn.xinha.org/trunk/XinhaCore.js */
/*--------------------------------------------------------------------------
-- Xinha (is not htmlArea) - http://xinha.org
--
-- Use of Xinha is granted by the terms of the htmlArea License (based on
-- BSD license) please read license.txt in this package for details.
--
-- Copyright (c) 2005-2010 Xinha Developer Team and contributors
--
-- Xinha was originally based on work by Mihai Bazon which is:
-- Copyright (c) 2003-2004 dynarch.com.
-- Copyright (c) 2002-2003 interactivetools.com, inc.
-- This copyright notice MUST stay intact for use.
-------------------------------------------------------------------------*/
Xinha.version={Release:"Trunk",Head:"$HeadURL: http://svn.xinha.org/trunk/XinhaCore.js $".replace(/^[^:]*:\s*(.*)\s*\$$/,"$1"),Date:"$LastChangedDate: 2010-05-12 09:40:06 +1200 (Wed, 12 May 2010) $".replace(/^[^:]*:\s*([0-9\-]*) ([0-9:]*) ([+0-9]*) \((.*)\)\s*\$/,"$4 $2 $3"),Revision:"$LastChangedRevision: 1263 $".replace(/^[^:]*:\s*(.*)\s*\$$/,"$1"),RevisionBy:"$LastChangedBy: gogo $".replace(/^[^:]*:\s*(.*)\s*\$$/,"$1")};Xinha._resolveRelativeUrl=function(d,c){if(c.match(/^([^:]+\:)?\/\//)){return c}else{var a=d.split("/");if(a[a.length-1]===""){a.pop()}var e=c.split("/");if(e[0]=="."){e.shift()}while(e[0]==".."){a.pop();e.shift()}return a.join("/")+"/"+e.join("/")}};if(typeof _editor_url=="string"){_editor_url=_editor_url.replace(/\x2f*$/,"/");if(!_editor_url.match(/^([^:]+\:)?\//)){(function(){var a=window.location.toString().replace(/\?.*$/,"").split("/");a.pop();_editor_url=Xinha._resolveRelativeUrl(a.join("/"),_editor_url)})()}}else{alert("WARNING: _editor_url is not set! You should set this variable to the editor files path; it should preferably be an absolute path, like in '/xinha/', but it can be relative if you prefer. Further we will try to load the editor files correctly but we'll probably fail.");_editor_url=""}if(typeof _editor_lang=="string"){_editor_lang=_editor_lang.toLowerCase()}else{_editor_lang="en"}if(typeof _editor_skin!=="string"){_editor_skin=""}if(typeof _editor_icons!=="string"){_editor_icons=""}var __xinhas=[];Xinha.agt=navigator.userAgent.toLowerCase();Xinha.is_ie=((Xinha.agt.indexOf("msie")!=-1)&&(Xinha.agt.indexOf("opera")==-1));Xinha.ie_version=parseFloat(Xinha.agt.substring(Xinha.agt.indexOf("msie")+5));Xinha.is_opera=(Xinha.agt.indexOf("opera")!=-1);if(Xinha.is_opera&&Xinha.agt.match(/opera[\/ ]([0-9.]+)/)){Xinha.opera_version=parseFloat(RegExp.$1)}else{Xinha.opera_version=0}Xinha.is_khtml=(Xinha.agt.indexOf("khtml")!=-1);Xinha.is_webkit=(Xinha.agt.indexOf("applewebkit")!=-1);Xinha.webkit_version=parseInt(navigator.appVersion.replace(/.*?AppleWebKit\/([\d]).*?/,"$1"),10);Xinha.is_safari=(Xinha.agt.indexOf("safari")!=-1);Xinha.is_chrome=(Xinha.agt.indexOf("chrome")!=-1);Xinha.is_mac=(Xinha.agt.indexOf("mac")!=-1);Xinha.is_mac_ie=(Xinha.is_ie&&Xinha.is_mac);Xinha.is_win_ie=(Xinha.is_ie&&!Xinha.is_mac);Xinha.is_gecko=(navigator.product=="Gecko")||Xinha.is_opera;Xinha.is_real_gecko=(navigator.product=="Gecko"&&!Xinha.is_webkit);Xinha.is_ff2=Xinha.is_real_gecko&&parseInt(navigator.productSub.substr(0,10),10)<20071210;Xinha.isRunLocally=document.URL.toLowerCase().search(/^file:/)!=-1;Xinha.is_designMode=(typeof document.designMode!="undefined"&&!Xinha.is_ie);Xinha.checkSupportedBrowser=function(){return Xinha.is_real_gecko||(Xinha.is_opera&&Xinha.opera_version>=9.2)||Xinha.ie_version>=5.5||Xinha.webkit_version>=522};Xinha.isSupportedBrowser=Xinha.checkSupportedBrowser();if(Xinha.isRunLocally&&Xinha.isSupportedBrowser){alert('Xinha *must* be installed on a web server. Locally opened files (those that use the "file://" protocol) cannot properly function. Xinha will try to initialize but may not be correctly loaded.')}function Xinha(d,c){if(!Xinha.isSupportedBrowser){return}if(!d){throw new Error("Tried to create Xinha without textarea specified.")}if(typeof c=="undefined"){this.config=new Xinha.Config()}else{this.config=c}if(typeof d!="object"){d=Xinha.getElementById("textarea",d)}this._textArea=d;this._textArea.spellcheck=false;Xinha.freeLater(this,"_textArea");this._initial_ta_size={w:d.style.width?d.style.width:(d.offsetWidth?(d.offsetWidth+"px"):(d.cols+"em")),h:d.style.height?d.style.height:(d.offsetHeight?(d.offsetHeight+"px"):(d.rows+"em"))};if(document.getElementById("loading_"+d.id)||this.config.showLoading){if(!document.getElementById("loading_"+d.id)){Xinha.createLoadingMessage(d)}this.setLoadingMessage(Xinha._lc("Constructing object"))}this._editMode="wysiwyg";this.plugins={};this._timerToolbar=null;this._timerUndo=null;this._undoQueue=[this.config.undoSteps];this._undoPos=-1;this._customUndo=true;this._mdoc=document;this.doctype="";this.__htmlarea_id_num=__xinhas.length;__xinhas[this.__htmlarea_id_num]=this;this._notifyListeners={};var b={right:{on:true,container:document.createElement("td"),panels:[]},left:{on:true,container:document.createElement("td"),panels:[]},top:{on:true,container:document.createElement("td"),panels:[]},bottom:{on:true,container:document.createElement("td"),panels:[]}};for(var a in b){if(!b[a].container){continue}b[a].div=b[a].container;b[a].container.className="panels panels_"+a;Xinha.freeLater(b[a],"container");Xinha.freeLater(b[a],"div")}this._panels=b;this._statusBar=null;this._statusBarTree=null;this._statusBarTextMode=null;this._statusBarItems=[];this._framework={};this._htmlArea=null;this._iframe=null;this._doc=null;this._toolBar=this._toolbar=null;this._toolbarObjects={};this.plugins.Events={name:"Events",developer:"The Xinha Core Developer Team",instance:c.Events}}Xinha.onload=function(){};Xinha.init=function(){Xinha.onload()};Xinha.RE_tagName=/(<\/|<)\s*([^ \t\n>]+)/ig;Xinha.RE_doctype=/(<!doctype((.|\n)*?)>)\n?/i;Xinha.RE_head=/<head>((.|\n)*?)<\/head>/i;Xinha.RE_body=/<body[^>]*>((.|\n|\r|\t)*?)<\/body>/i;Xinha.RE_Specials=/([\/\^$*+?.()|{}\[\]])/g;Xinha.escapeStringForRegExp=function(a){return a.replace(Xinha.RE_Specials,"\\$1")};Xinha.RE_email=/^[_a-z\d\-\.]{3,}@[_a-z\d\-]{2,}(\.[_a-z\d\-]{2,})+$/i;Xinha.RE_url=/(https?:\/\/)?(([a-z0-9_]+:[a-z0-9_]+@)?[a-z0-9_\-]{2,}(\.[a-z0-9_\-]{2,}){2,}(:[0-9]+)?(\/\S+)*)/i;Xinha.Config=function(){this.version=Xinha.version.Revision;this.width="auto";this.height="auto";this.sizeIncludesBars=true;this.sizeIncludesPanels=true;this.panel_dimensions={left:"200px",right:"200px",top:"100px",bottom:"100px"};this.iframeWidth=null;this.statusBar=true;this.htmlareaPaste=false;this.mozParaHandler="best";this.getHtmlMethod="DOMwalk";this.undoSteps=20;this.undoTimeout=500;this.changeJustifyWithDirection=false;this.fullPage=false;this.pageStyle="";this.pageStyleSheets=[];this.baseHref=null;this.expandRelativeUrl=true;this.stripBaseHref=true;this.stripSelfNamedAnchors=true;this.only7BitPrintablesInURLs=true;this.sevenBitClean=false;this.specialReplacements={};this.inwardHtml=function(c){return c};this.outwardHtml=function(c){return c};this.autofocus=false;this.killWordOnPaste=true;this.makeLinkShowsTarget=true;this.charSet=(typeof document.characterSet!="undefined")?document.characterSet:document.charset;this.browserQuirksMode=null;this.imgURL="images/";this.popupURL="popups/";this.htmlRemoveTags=null;this.flowToolbars=true;this.toolbarAlign="left";this.showFontStylesInToolbar=false;this.showLoading=false;this.stripScripts=true;this.convertUrlsToLinks=true;this.colorPickerCellSize="6px";this.colorPickerGranularity=18;this.colorPickerPosition="bottom,right";this.colorPickerWebSafe=false;this.colorPickerSaveColors=20;this.fullScreen=false;this.fullScreenMargins=[0,0,0,0];this.fullScreenSizeDownMethod="initSize";this.toolbar=[["popupeditor"],["separator","formatblock","fontname","fontsize","bold","italic","underline","strikethrough"],["separator","forecolor","hilitecolor","textindicator"],["separator","subscript","superscript"],["linebreak","separator","justifyleft","justifycenter","justifyright","justifyfull"],["separator","insertorderedlist","insertunorderedlist","outdent","indent"],["separator","inserthorizontalrule","createlink","insertimage","inserttable"],["linebreak","separator","undo","redo","selectall","print"],(Xinha.is_gecko?[]:["cut","copy","paste","overwrite","saveas"]),["separator","killword","clearfonts","removeformat","toggleborders","splitblock","lefttoright","righttoleft"],["separator","htmlmode","showhelp","about"]];this.fontname={"&#8212; font &#8212;":"",Arial:"arial,helvetica,sans-serif","Courier New":"courier new,courier,monospace",Georgia:"georgia,times new roman,times,serif",Tahoma:"tahoma,arial,helvetica,sans-serif","Times New Roman":"times new roman,times,serif",Verdana:"verdana,arial,helvetica,sans-serif",impact:"impact",WingDings:"wingdings"};this.fontsize={"&#8212; size &#8212;":"","1 (8 pt)":"1","2 (10 pt)":"2","3 (12 pt)":"3","4 (14 pt)":"4","5 (18 pt)":"5","6 (24 pt)":"6","7 (36 pt)":"7"};this.formatblock={"&#8212; format &#8212;":"","Heading 1":"h1","Heading 2":"h2","Heading 3":"h3","Heading 4":"h4","Heading 5":"h5","Heading 6":"h6",Normal:"p",Address:"address",Formatted:"pre"};this.dialogOptions={centered:true,greyout:true,closeOnEscape:true};this.Events={};this.customSelects={};this.debug=false;this.URIs={blank:_editor_url+"popups/blank.html",link:_editor_url+"modules/CreateLink/link.html",insert_image:_editor_url+"modules/InsertImage/insert_image.html",insert_table:_editor_url+"modules/InsertTable/insert_table.html",select_color:_editor_url+"popups/select_color.html",help:_editor_url+"popups/editor_help.html"};this.btnList={bold:["Bold",Xinha._lc({key:"button_bold",string:["ed_buttons_main.png",3,2]},"Xinha"),false,function(c){c.execCommand("bold")}],italic:["Italic",Xinha._lc({key:"button_italic",string:["ed_buttons_main.png",2,2]},"Xinha"),false,function(c){c.execCommand("italic")}],underline:["Underline",Xinha._lc({key:"button_underline",string:["ed_buttons_main.png",2,0]},"Xinha"),false,function(c){c.execCommand("underline")}],strikethrough:["Strikethrough",Xinha._lc({key:"button_strikethrough",string:["ed_buttons_main.png",3,0]},"Xinha"),false,function(c){c.execCommand("strikethrough")}],subscript:["Subscript",Xinha._lc({key:"button_subscript",string:["ed_buttons_main.png",3,1]},"Xinha"),false,function(c){c.execCommand("subscript")}],superscript:["Superscript",Xinha._lc({key:"button_superscript",string:["ed_buttons_main.png",2,1]},"Xinha"),false,function(c){c.execCommand("superscript")}],justifyleft:["Justify Left",["ed_buttons_main.png",0,0],false,function(c){c.execCommand("justifyleft")}],justifycenter:["Justify Center",["ed_buttons_main.png",1,1],false,function(c){c.execCommand("justifycenter")}],justifyright:["Justify Right",["ed_buttons_main.png",1,0],false,function(c){c.execCommand("justifyright")}],justifyfull:["Justify Full",["ed_buttons_main.png",0,1],false,function(c){c.execCommand("justifyfull")}],orderedlist:["Ordered List",["ed_buttons_main.png",0,3],false,function(c){c.execCommand("insertorderedlist")}],unorderedlist:["Bulleted List",["ed_buttons_main.png",1,3],false,function(c){c.execCommand("insertunorderedlist")}],insertorderedlist:["Ordered List",["ed_buttons_main.png",0,3],false,function(c){c.execCommand("insertorderedlist")}],insertunorderedlist:["Bulleted List",["ed_buttons_main.png",1,3],false,function(c){c.execCommand("insertunorderedlist")}],outdent:["Decrease Indent",["ed_buttons_main.png",1,2],false,function(c){c.execCommand("outdent")}],indent:["Increase Indent",["ed_buttons_main.png",0,2],false,function(c){c.execCommand("indent")}],forecolor:["Font Color",["ed_buttons_main.png",3,3],false,function(c){c.execCommand("forecolor")}],hilitecolor:["Background Color",["ed_buttons_main.png",2,3],false,function(c){c.execCommand("hilitecolor")}],undo:["Undoes your last action",["ed_buttons_main.png",4,2],false,function(c){c.execCommand("undo")}],redo:["Redoes your last action",["ed_buttons_main.png",5,2],false,function(c){c.execCommand("redo")}],cut:["Cut selection",["ed_buttons_main.png",5,0],false,function(d,c){d.execCommand(c)}],copy:["Copy selection",["ed_buttons_main.png",4,0],false,function(d,c){d.execCommand(c)}],paste:["Paste from clipboard",["ed_buttons_main.png",4,1],false,function(d,c){d.execCommand(c)}],selectall:["Select all",["ed_buttons_main.png",3,5],false,function(c){c.execCommand("selectall")}],inserthorizontalrule:["Horizontal Rule",["ed_buttons_main.png",6,0],false,function(c){c.execCommand("inserthorizontalrule")}],createlink:["Insert Web Link",["ed_buttons_main.png",6,1],false,function(c){c._createLink()}],insertimage:["Insert/Modify Image",["ed_buttons_main.png",6,3],false,function(c){c.execCommand("insertimage")}],inserttable:["Insert Table",["ed_buttons_main.png",6,2],false,function(c){c.execCommand("inserttable")}],htmlmode:["Toggle HTML Source",["ed_buttons_main.png",7,0],true,function(c){c.execCommand("htmlmode")}],toggleborders:["Toggle Borders",["ed_buttons_main.png",7,2],false,function(c){c._toggleBorders()}],print:["Print document",["ed_buttons_main.png",8,1],false,function(c){if(Xinha.is_gecko){c._iframe.contentWindow.print()}else{c.focusEditor();print()}}],saveas:["Save as",["ed_buttons_main.png",9,1],false,function(c){c.execCommand("saveas",false,"noname.htm")}],about:["About this editor",["ed_buttons_main.png",8,2],true,function(c){c.getPluginInstance("AboutBox").show()}],showhelp:["Help using editor",["ed_buttons_main.png",9,2],true,function(c){c.execCommand("showhelp")}],splitblock:["Split Block","ed_splitblock.gif",false,function(c){c._splitBlock()}],lefttoright:["Direction left to right",["ed_buttons_main.png",0,2],false,function(c){c.execCommand("lefttoright")}],righttoleft:["Direction right to left",["ed_buttons_main.png",1,2],false,function(c){c.execCommand("righttoleft")}],overwrite:["Insert/Overwrite","ed_overwrite.gif",false,function(c){c.execCommand("overwrite")}],wordclean:["MS Word Cleaner",["ed_buttons_main.png",5,3],false,function(c){c._wordClean()}],clearfonts:["Clear Inline Font Specifications",["ed_buttons_main.png",5,4],true,function(c){c._clearFonts()}],removeformat:["Remove formatting",["ed_buttons_main.png",4,4],false,function(c){c.execCommand("removeformat")}],killword:["Clear MSOffice tags",["ed_buttons_main.png",4,3],false,function(c){c.execCommand("killword")}]};this.dblclickList={a:[function(c,d){c._createLink(d)}],img:[function(c,d){c._insertImage(d)}]};this.iconList={dialogCaption:_editor_url+"images/xinha-small-icon.gif",wysiwygmode:[_editor_url+"images/ed_buttons_main.png",7,1]};for(var b in this.btnList){var a=this.btnList[b];if(typeof a!="object"){continue}if(typeof a[1]!="string"){a[1][0]=_editor_url+this.imgURL+a[1][0]}else{a[1]=_editor_url+this.imgURL+a[1]}a[0]=Xinha._lc(a[0])}};Xinha.Config.prototype.registerIcon=function(b,a){this.iconList[b]=a};Xinha.Config.prototype.registerButton=function(f,b,e,d,a,c){if(typeof f=="string"){this.btnList[f]=[b,e,d,a,c]}else{if(typeof f=="object"){this.btnList[f.id]=[f.tooltip,f.image,f.textMode,f.action,f.context]}else{alert("ERROR [Xinha.Config::registerButton]:\ninvalid arguments");return false}}};Xinha.prototype.registerPanel=function(c,b){if(!c){c="right"}this.setLoadingMessage("Register "+c+" panel ");var a=this.addPanel(c);if(b){b.drawPanelIn(a)}};Xinha.Config.prototype.registerDropdown=function(a){this.customSelects[a.id]=a};Xinha.Config.prototype.hideSomeButtons=function(f){var c=this.toolbar;for(var e=c.length;--e>=0;){var b=c[e];for(var d=b.length;--d>=0;){if(f.indexOf(" "+b[d]+" ")>=0){var a=1;if(/separator|space/.test(b[d+1])){a=2}b.splice(d,a)}}}};Xinha.Config.prototype.addToolbarElement=function(d,k,m){var s=this.toolbar;var q,l,h,f,c;var p=false;var b=false;var n=0;var g=0;var e=0;var r=false;var t=false;if((d&&typeof d=="object")&&(d.constructor==Array)){p=true}if((k&&typeof k=="object")&&(k.constructor==Array)){b=true;n=k.length}if(p){for(l=0;l<d.length;++l){if((d[l]!="separator")&&(d[l].indexOf("T[")!==0)){c=d[l]}}}else{c=d}for(l=0;l<s.length;++l){q=s[l];for(h=0;h<q.length;++h){if(q[h]==c){return}}}for(l=0;!t&&l<s.length;++l){q=s[l];for(h=0;!t&&h<q.length;++h){if(b){for(f=0;f<n;++f){if(q[h]==k[f]){if(f===0){t=true;h--;break}else{e=l;g=h;n=f}}}}else{if(q[h]==k){t=true;break}}}}if(!t&&b){if(k.length!=n){h=g;q=s[e];t=true}}if(t){if(m===0){if(p){q[h]=d[d.length-1];for(l=d.length-1;--l>=0;){q.splice(h,0,d[l])}}else{q[h]=d}}else{if(m<0){h=h+m+1}else{if(m>0){h=h+m}}if(p){for(l=d.length;--l>=0;){q.splice(h,0,d[l])}}else{q.splice(h,0,d)}}}else{s[0].splice(0,0,"separator");if(p){for(l=d.length;--l>=0;){s[0].splice(0,0,d[l])}}else{s[0].splice(0,0,d)}}};Xinha.Config.prototype.removeToolbarElement=Xinha.Config.prototype.hideSomeButtons;Xinha.replaceAll=function(b){var c=document.getElementsByTagName("textarea");for(var a=c.length;a>0;new Xinha(c[--a],b).generate()){}};Xinha.replace=function(c,b){var a=Xinha.getElementById("textarea",c);return a?new Xinha(a,b).generate():null};Xinha.prototype._createToolbar=function(){this.setLoadingMessage(Xinha._lc("Create Toolbar"));var b=this;var a=document.createElement("div");this._toolBar=this._toolbar=a;a.className="toolbar";a.align=this.config.toolbarAlign;Xinha.freeLater(this,"_toolBar");Xinha.freeLater(this,"_toolbar");var c=null;var e={};this._toolbarObjects=e;this._createToolbar1(b,a,e);function d(g){if(g.tagName){g.unselectable="on"}if(g.childNodes){for(var f=0;f<g.childNodes.length;f++){if(g.tagName){d(g.childNodes(f))}}}}if(Xinha.is_ie){d(a)}this._htmlArea.appendChild(a);return a};Xinha.prototype._setConfig=function(a){this.config=a};Xinha.prototype._rebuildToolbar=function(){this._createToolbar1(this,this._toolbar,this._toolbarObjects);if(Xinha._currentlyActiveEditor){if(Xinha._currentlyActiveEditor==this){this.activateEditor()}}else{this.disableToolbar()}};Xinha._createToolbarBreakingElement=function(){var a=document.createElement("div");a.style.height="1px";a.style.width="1px";a.style.lineHeight="1px";a.style.fontSize="1px";a.style.clear="both";return a};Xinha.prototype._createToolbar1=function(d,s,p){while(s.lastChild){s.removeChild(s.lastChild)}var l;if(d.config.flowToolbars){s.appendChild(Xinha._createToolbarBreakingElement())}function n(){if(typeof l!="undefined"&&l.childNodes.length===0){return}var i=document.createElement("table");i.border="0px";i.cellSpacing="0px";i.cellPadding="0px";if(d.config.flowToolbars){if(Xinha.is_ie){i.style.styleFloat="left"}else{i.style.cssFloat="left"}}s.appendChild(i);var j=document.createElement("tbody");i.appendChild(j);l=document.createElement("tr");j.appendChild(l);i.className="toolbarRow"}n();function m(u,i){var j=this[u];var t=this.element;if(j!=i){switch(u){case"enabled":if(i){Xinha._removeClass(t,"buttonDisabled");t.disabled=false}else{Xinha._addClass(t,"buttonDisabled");t.disabled=true}break;case"active":if(i){Xinha._addClass(t,"buttonPressed")}else{Xinha._removeClass(t,"buttonPressed")}break}this[u]=i}}function c(x){var A=null;var t=null;var u=null;var C=d.config.customSelects;var j=null;var z="";switch(x){case"fontsize":case"fontname":case"formatblock":A=d.config[x];u=x;break;default:u=x;var B=C[u];if(typeof B!="undefined"){A=B.options;j=B.context;if(typeof B.tooltip!="undefined"){z=B.tooltip}}else{alert("ERROR [createSelect]:\nCan't find the requested dropdown definition")}break}if(A){t=document.createElement("select");t.title=z;t.style.width="auto";t.name=x;var w={name:x,element:t,enabled:true,text:false,cmd:u,state:m,context:j};Xinha.freeLater(w);p[x]=w;for(var v in A){if(typeof A[v]!="string"){continue}var y=document.createElement("option");y.innerHTML=Xinha._lc(v);y.value=A[v];if(x=="fontname"&&d.config.showFontStylesInToolbar){y.style.fontFamily=A[v]}t.appendChild(y)}Xinha._addEvent(t,"change",function(){d._comboSelected(t,x)})}return t}function q(i){var u,t,w=null;switch(i){case"separator":if(d.config.flowToolbars){n()}u=document.createElement("div");u.className="separator";break;case"space":u=document.createElement("div");u.className="space";break;case"linebreak":n();return false;case"textindicator":u=document.createElement("div");u.appendChild(document.createTextNode("A"));u.className="indicator";u.title=Xinha._lc("Current style");w={name:i,element:u,enabled:true,active:false,text:false,cmd:"textindicator",state:m};Xinha.freeLater(w);p[i]=w;break;default:t=d.config.btnList[i]}if(!u&&t){u=document.createElement("a");u.style.display="block";u.href="javascript:void(0)";u.style.textDecoration="none";u.title=t[0];u.className="button";u.style.direction="ltr";w={name:i,element:u,enabled:true,active:false,text:t[2],cmd:t[3],state:m,context:t[4]||null};Xinha.freeLater(u);Xinha.freeLater(w);p[i]=w;u.ondrag=function(){return false};Xinha._addEvent(u,"mouseout",function(x){if(w.enabled){Xinha._removeClass(u,"buttonActive");if(w.active){Xinha._addClass(u,"buttonPressed")}}});Xinha._addEvent(u,"mousedown",function(x){if(w.enabled){Xinha._addClass(u,"buttonActive");Xinha._removeClass(u,"buttonPressed");Xinha._stopEvent(Xinha.is_ie?window.event:x)}});Xinha._addEvent(u,"click",function(x){x=x||window.event;d.btnClickEvent={clientX:x.clientX,clientY:x.clientY};if(w.enabled){Xinha._removeClass(u,"buttonActive");if(Xinha.is_gecko){d.activateEditor()}w.cmd(d,w.name,w,x);Xinha._stopEvent(x)}});var v=Xinha.makeBtnImg(t[1]);var j=v.firstChild;Xinha.freeLater(v);Xinha.freeLater(j);u.appendChild(v);w.imgel=j;w.swapImage=function(x){if(typeof x!="string"){j.src=x[0];j.style.position="relative";j.style.top=x[2]?("-"+(18*(x[2]+1))+"px"):"-18px";j.style.left=x[1]?("-"+(18*(x[1]+1))+"px"):"-18px"}else{w.imgel.src=x;j.style.top="0px";j.style.left="0px"}}}else{if(!u){u=c(i)}}return u}var k=true;for(var h=0;h<this.config.toolbar.length;++h){if(!k){}else{k=false}if(this.config.toolbar[h]===null){this.config.toolbar[h]=["separator"]}var r=this.config.toolbar[h];for(var g=0;g<r.length;++g){var b=r[g];var a;if(/^([IT])\[(.*?)\]/.test(b)){var f=RegExp.$1=="I";var o=RegExp.$2;if(f){o=Xinha._lc(o)}a=document.createElement("td");l.appendChild(a);a.className="label";a.innerHTML=o}else{if(typeof b!="function"){var e=q(b);if(e){a=document.createElement("td");a.className="toolbarElement";l.appendChild(a);a.appendChild(e)}else{if(e===null){alert("FIXME: Unknown toolbar item: "+b)}}}}}}if(d.config.flowToolbars){s.appendChild(Xinha._createToolbarBreakingElement())}return s};Xinha.makeBtnImg=function(b,d){if(!d){d=document}if(!d._xinhaImgCache){d._xinhaImgCache={};Xinha.freeLater(d._xinhaImgCache)}var c=null;if(Xinha.is_ie&&((!d.compatMode)||(d.compatMode&&d.compatMode=="BackCompat"))){c=d.createElement("span")}else{c=d.createElement("div");c.style.position="relative"}c.style.overflow="hidden";c.style.width="18px";c.style.height="18px";c.className="buttonImageContainer";var a=null;if(typeof b=="string"){if(d._xinhaImgCache[b]){a=d._xinhaImgCache[b].cloneNode()}else{if(Xinha.ie_version<7&&/\.png$/.test(b[0])){a=d.createElement("span");a.style.display="block";a.style.width="18px";a.style.height="18px";a.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+b+'")';a.unselectable="on"}else{a=d.createElement("img");a.src=b}}}else{if(d._xinhaImgCache[b[0]]){a=d._xinhaImgCache[b[0]].cloneNode()}else{if(Xinha.ie_version<7&&/\.png$/.test(b[0])){a=d.createElement("span");a.style.display="block";a.style.width="18px";a.style.height="18px";a.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+b[0]+'")';a.unselectable="on"}else{a=d.createElement("img");a.src=b[0]}a.style.position="relative"}a.style.top=b[2]?("-"+(18*(b[2]+1))+"px"):"-18px";a.style.left=b[1]?("-"+(18*(b[1]+1))+"px"):"-18px"}c.appendChild(a);return c};Xinha.prototype._createStatusBar=function(){this.setLoadingMessage(Xinha._lc("Create Statusbar"));var b=document.createElement("div");b.style.position="relative";b.className="statusBar";b.style.width="100%";Xinha.freeLater(this,"_statusBar");var d=document.createElement("div");d.className="statusBarWidgetContainer";d.style.position="absolute";d.style.right="0";d.style.top="0";d.style.padding="3px 3px 3px 10px";b.appendChild(d);var e=document.createElement("span");e.className="statusBarTree";e.innerHTML=Xinha._lc("Path")+": ";this._statusBarTree=e;Xinha.freeLater(this,"_statusBarTree");b.appendChild(e);var c=document.createElement("span");c.innerHTML=Xinha.htmlEncode(Xinha._lc("You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG."));c.style.display="none";this._statusBarTextMode=c;Xinha.freeLater(this,"_statusBarTextMode");b.appendChild(c);b.style.whiteSpace="nowrap";var a=this;this.notifyOn("before_resize",function(f,g){a._statusBar.style.width=null});this.notifyOn("resize",function(f,g){if(Xinha.is_ie&&Xinha.ie_version==6){a._statusBar.style.width="100%"}else{var h=g.width;a._statusBar.style.width=h+"px"}});this.notifyOn("modechange",function(g,l){for(var j in a._statusWidgets){var f=a._statusWidgets[j];for(var h=0;h<f.modes.length;h++){if(f.modes[h]==l.mode){var k=true}}if(typeof k=="undefined"){f.block.style.display="none"}else{f.block.style.display=""}}});if(!this.config.statusBar){b.style.display="none"}return b};Xinha.prototype.registerStatusWidget=function(e,c){c=c||["wysiwyg"];if(!this._statusWidgets){this._statusWidgets={}}var d=document.createElement("div");d.className="statusBarWidget";d=this._statusBar.firstChild.appendChild(d);var b=false;for(var a=0;a<c.length;a++){if(c[a]==this._editMode){b=true}}d.style.display=b==true?"":"none";this._statusWidgets[e]={block:d,modes:c};return d};Xinha.prototype.generate=function(){if(!Xinha.isSupportedBrowser){return}var w;var k=this;var g;var o=false;var c=document.getElementsByTagName("link");if(!document.getElementById("XinhaCoreDesign")){_editor_css=(typeof _editor_css=="string")?_editor_css:"Xinha.css";for(w=0;w<c.length;w++){if((c[w].rel=="stylesheet")&&(c[w].href==_editor_url+_editor_css)){o=true}}if(!o){Xinha.loadStyle(_editor_css,null,"XinhaCoreDesign",true)}}if(_editor_skin!==""&&!document.getElementById("XinhaSkin")){o=false;for(w=0;w<c.length;w++){if((c[w].rel=="stylesheet")&&(c[w].href==_editor_url+"skins/"+_editor_skin+"/skin.css")){o=true}}if(!o){Xinha.loadStyle("skins/"+_editor_skin+"/skin.css",null,"XinhaSkin")}}var h=function(){k.generate()};if(Xinha.is_ie){g=_editor_url+"modules/InternetExplorer/InternetExplorer.js";if(!Xinha.loadPlugins([{plugin:"InternetExplorer",url:g}],h)){return false}if(!this.plugins.InternetExplorer){k._browserSpecificPlugin=k.registerPlugin("InternetExplorer")}}else{if(Xinha.is_webkit){g=_editor_url+"modules/WebKit/WebKit.js";if(!Xinha.loadPlugins([{plugin:"WebKit",url:g}],h)){return false}if(!this.plugins.Webkit){k._browserSpecificPlugin=k.registerPlugin("WebKit")}}else{if(Xinha.is_opera){g=_editor_url+"modules/Opera/Opera.js";if(!Xinha.loadPlugins([{plugin:"Opera",url:g}],h)){return false}if(!this.plugins.Opera){k._browserSpecificPlugin=k.registerPlugin("Opera")}}else{if(Xinha.is_gecko){g=_editor_url+"modules/Gecko/Gecko.js";if(!Xinha.loadPlugins([{plugin:"Gecko",url:g}],h)){return false}if(!this.plugins.Gecko){k._browserSpecificPlugin=k.registerPlugin("Gecko")}}}}}if(typeof Dialog=="undefined"&&!Xinha._loadback(_editor_url+"modules/Dialogs/dialog.js",h,this)){return false}if(typeof Xinha.Dialog=="undefined"&&!Xinha._loadback(_editor_url+"modules/Dialogs/XinhaDialog.js",h,this)){return false}g=_editor_url+"modules/FullScreen/full-screen.js";if(!Xinha.loadPlugins([{plugin:"FullScreen",url:g}],h)){return false}g=_editor_url+"modules/ColorPicker/ColorPicker.js";if(!Xinha.loadPlugins([{plugin:"ColorPicker",url:g}],h)){return false}else{if(typeof Xinha.getPluginConstructor("ColorPicker")!="undefined"&&!this.plugins.colorPicker){k.registerPlugin("ColorPicker")}}var a=k.config.toolbar;for(w=a.length;--w>=0;){for(var v=a[w].length;--v>=0;){switch(a[w][v]){case"popupeditor":if(!this.plugins.FullScreen){k.registerPlugin("FullScreen")}break;case"insertimage":g=_editor_url+"modules/InsertImage/insert_image.js";if(typeof Xinha.prototype._insertImage=="undefined"&&!Xinha.loadPlugins([{plugin:"InsertImage",url:g}],h)){return false}else{if(typeof Xinha.getPluginConstructor("InsertImage")!="undefined"&&!this.plugins.InsertImage){k.registerPlugin("InsertImage")}}break;case"createlink":g=_editor_url+"modules/CreateLink/link.js";if(typeof Xinha.getPluginConstructor("Linker")=="undefined"&&!Xinha.loadPlugins([{plugin:"CreateLink",url:g}],h)){return false}else{if(typeof Xinha.getPluginConstructor("CreateLink")!="undefined"&&!this.plugins.CreateLink){k.registerPlugin("CreateLink")}}break;case"inserttable":g=_editor_url+"modules/InsertTable/insert_table.js";if(!Xinha.loadPlugins([{plugin:"InsertTable",url:g}],h)){return false}else{if(typeof Xinha.getPluginConstructor("InsertTable")!="undefined"&&!this.plugins.InsertTable){k.registerPlugin("InsertTable")}}break;case"about":g=_editor_url+"modules/AboutBox/AboutBox.js";if(!Xinha.loadPlugins([{plugin:"AboutBox",url:g}],h)){return false}else{if(typeof Xinha.getPluginConstructor("AboutBox")!="undefined"&&!this.plugins.AboutBox){k.registerPlugin("AboutBox")}}break}}}if(Xinha.is_gecko&&k.config.mozParaHandler!="built-in"){if(!Xinha.loadPlugins([{plugin:"EnterParagraphs",url:_editor_url+"modules/Gecko/paraHandlerBest.js"}],h)){return false}if(!this.plugins.EnterParagraphs){k.registerPlugin("EnterParagraphs")}}var C=this.config.getHtmlMethod=="TransformInnerHTML"?_editor_url+"modules/GetHtml/TransformInnerHTML.js":_editor_url+"modules/GetHtml/DOMwalk.js";if(!Xinha.loadPlugins([{plugin:"GetHtmlImplementation",url:C}],h)){return false}else{if(!this.plugins.GetHtmlImplementation){k.registerPlugin("GetHtmlImplementation")}}function D(i){return i.textContent||i.text}if(_editor_skin){this.skinInfo={};var s=Xinha._geturlcontent(_editor_url+"skins/"+_editor_skin+"/skin.xml",true);if(s){var p=s.getElementsByTagName("meta");for(w=0;w<p.length;w++){this.skinInfo[p[w].getAttribute("name")]=p[w].getAttribute("value")}var t=s.getElementsByTagName("recommendedIcons");if(!_editor_icons&&t.length&&D(t[0])){_editor_icons=D(t[0])}}}if(_editor_icons){var b=Xinha._geturlcontent(_editor_url+"iconsets/"+_editor_icons+"/iconset.xml",true);if(b){var E=b.getElementsByTagName("icon");var A,r,q,f,n,m;for(w=0;w<E.length;w++){A=E[w];r=A.getAttribute("id");if(A.getElementsByTagName(_editor_lang).length){A=A.getElementsByTagName(_editor_lang)[0]}else{A=A.getElementsByTagName("default")[0]}q=D(A.getElementsByTagName("path")[0]);q=(!/^\//.test(q)?_editor_url:"")+q;f=A.getAttribute("type");if(f=="map"){n=parseInt(D(A.getElementsByTagName("x")[0]),10);m=parseInt(D(A.getElementsByTagName("y")[0]),10);if(this.config.btnList[r]){this.config.btnList[r][1]=[q,n,m]}if(this.config.iconList[r]){this.config.iconList[r]=[q,n,m]}}else{if(this.config.btnList[r]){this.config.btnList[r][1]=q}if(this.config.iconList[r]){this.config.iconList[r]=q}}}}}this.setLoadingMessage(Xinha._lc("Generate Xinha framework"));this._framework={table:document.createElement("table"),tbody:document.createElement("tbody"),tb_row:document.createElement("tr"),tb_cell:document.createElement("td"),tp_row:document.createElement("tr"),tp_cell:this._panels.top.container,ler_row:document.createElement("tr"),lp_cell:this._panels.left.container,ed_cell:document.createElement("td"),rp_cell:this._panels.right.container,bp_row:document.createElement("tr"),bp_cell:this._panels.bottom.container,sb_row:document.createElement("tr"),sb_cell:document.createElement("td")};Xinha.freeLater(this._framework);var e=this._framework;e.table.border="0";e.table.cellPadding="0";e.table.cellSpacing="0";e.tb_row.style.verticalAlign="top";e.tp_row.style.verticalAlign="top";e.ler_row.style.verticalAlign="top";e.bp_row.style.verticalAlign="top";e.sb_row.style.verticalAlign="top";e.ed_cell.style.position="relative";e.tb_row.appendChild(e.tb_cell);e.tb_cell.colSpan=3;e.tp_row.appendChild(e.tp_cell);e.tp_cell.colSpan=3;e.ler_row.appendChild(e.lp_cell);e.ler_row.appendChild(e.ed_cell);e.ler_row.appendChild(e.rp_cell);e.bp_row.appendChild(e.bp_cell);e.bp_cell.colSpan=3;e.sb_row.appendChild(e.sb_cell);e.sb_cell.colSpan=3;e.tbody.appendChild(e.tb_row);e.tbody.appendChild(e.tp_row);e.tbody.appendChild(e.ler_row);e.tbody.appendChild(e.bp_row);e.tbody.appendChild(e.sb_row);e.table.appendChild(e.tbody);var B=e.table;this._htmlArea=B;Xinha.freeLater(this,"_htmlArea");B.className="htmlarea";e.tb_cell.appendChild(this._createToolbar());var d=document.createElement("iframe");d.src=this.popupURL(k.config.URIs.blank);d.id="XinhaIFrame_"+this._textArea.id;e.ed_cell.appendChild(d);this._iframe=d;this._iframe.className="xinha_iframe";Xinha.freeLater(this,"_iframe");var u=this._createStatusBar();this._statusBar=e.sb_cell.appendChild(u);var F=this._textArea;F.parentNode.insertBefore(B,F);F.className="xinha_textarea";Xinha.removeFromParent(F);e.ed_cell.appendChild(F);Xinha.addDom0Event(this._textArea,"click",function(){if(Xinha._currentlyActiveEditor!=this){k.updateToolbar()}return true});if(F.form){Xinha.prependDom0Event(this._textArea.form,"submit",function(){k.firePluginEvent("onBeforeSubmit");k._textArea.value=k.outwardHtml(k.getHTML());return true});var l=F.value;Xinha.prependDom0Event(this._textArea.form,"reset",function(){k.setHTML(k.inwardHtml(l));k.updateToolbar();return true});if(!F.form.xinha_submit){try{F.form.xinha_submit=F.form.submit;F.form.submit=function(){this.onsubmit();this.xinha_submit()}}catch(z){}}}Xinha.prependDom0Event(window,"unload",function(){k.firePluginEvent("onBeforeUnload");F.value=k.outwardHtml(k.getHTML());if(!Xinha.is_ie){B.parentNode.replaceChild(F,B)}return true});F.style.display="none";k.initSize();this.setLoadingMessage(Xinha._lc("Finishing"));k._iframeLoadDone=false;if(Xinha.is_opera){k.initIframe()}else{Xinha._addEvent(this._iframe,"load",function(i){if(!k._iframeLoadDone){k._iframeLoadDone=true;k.initIframe()}return true})}};Xinha.prototype.initSize=function(){this.setLoadingMessage(Xinha._lc("Init editor size"));var a=this;var b=null;var c=null;switch(this.config.width){case"auto":b=this._initial_ta_size.w;break;case"toolbar":b=this._toolBar.offsetWidth+"px";break;default:b=/[^0-9]/.test(this.config.width)?this.config.width:this.config.width+"px";break}c=this.config.height=="auto"?this._initial_ta_size.h:/[^0-9]/.test(this.config.height)?this.config.height:this.config.height+"px";this.sizeEditor(b,c,this.config.sizeIncludesBars,this.config.sizeIncludesPanels);this.notifyOn("panel_change",function(){a.sizeEditor()})};Xinha.prototype.sizeEditor=function(c,o,j,a){if(this._risizing){return}this._risizing=true;var k=this._framework;this.notifyOf("before_resize",{width:c,height:o});this.firePluginEvent("onBeforeResize",c,o);this._iframe.style.height="100%";this._textArea.style.height="1px";this._iframe.style.width="0px";this._textArea.style.width="0px";if(j!==null){this._htmlArea.sizeIncludesToolbars=j}if(a!==null){this._htmlArea.sizeIncludesPanels=a}if(c){this._htmlArea.style.width=c;if(!this._htmlArea.sizeIncludesPanels){var p=this._panels.right;if(p.on&&p.panels.length&&Xinha.hasDisplayedChildren(p.div)){this._htmlArea.style.width=(this._htmlArea.offsetWidth+parseInt(this.config.panel_dimensions.right,10))+"px"}var l=this._panels.left;if(l.on&&l.panels.length&&Xinha.hasDisplayedChildren(l.div)){this._htmlArea.style.width=(this._htmlArea.offsetWidth+parseInt(this.config.panel_dimensions.left,10))+"px"}}}if(o){this._htmlArea.style.height=o;if(!this._htmlArea.sizeIncludesToolbars){this._htmlArea.style.height=(this._htmlArea.offsetHeight+this._toolbar.offsetHeight+this._statusBar.offsetHeight)+"px"}if(!this._htmlArea.sizeIncludesPanels){var e=this._panels.top;if(e.on&&e.panels.length&&Xinha.hasDisplayedChildren(e.div)){this._htmlArea.style.height=(this._htmlArea.offsetHeight+parseInt(this.config.panel_dimensions.top,10))+"px"}var n=this._panels.bottom;if(n.on&&n.panels.length&&Xinha.hasDisplayedChildren(n.div)){this._htmlArea.style.height=(this._htmlArea.offsetHeight+parseInt(this.config.panel_dimensions.bottom,10))+"px"}}}c=this._htmlArea.offsetWidth;o=this._htmlArea.offsetHeight;var b=this._panels;var d=this;var i=1;function h(q){if(b[q].on&&b[q].panels.length&&Xinha.hasDisplayedChildren(b[q].container)){b[q].container.style.display="";return true}else{b[q].container.style.display="none";return false}}if(h("left")){i+=1}if(h("right")){i+=1}k.tb_cell.colSpan=i;k.tp_cell.colSpan=i;k.bp_cell.colSpan=i;k.sb_cell.colSpan=i;if(!k.tp_row.childNodes.length){Xinha.removeFromParent(k.tp_row)}else{if(!Xinha.hasParentNode(k.tp_row)){k.tbody.insertBefore(k.tp_row,k.ler_row)}}if(!k.bp_row.childNodes.length){Xinha.removeFromParent(k.bp_row)}else{if(!Xinha.hasParentNode(k.bp_row)){k.tbody.insertBefore(k.bp_row,k.ler_row.nextSibling)}}if(!this.config.statusBar){Xinha.removeFromParent(k.sb_row)}else{if(!Xinha.hasParentNode(k.sb_row)){k.table.appendChild(k.sb_row)}}k.lp_cell.style.width=this.config.panel_dimensions.left;k.rp_cell.style.width=this.config.panel_dimensions.right;k.tp_cell.style.height=this.config.panel_dimensions.top;k.bp_cell.style.height=this.config.panel_dimensions.bottom;k.tb_cell.style.height=this._toolBar.offsetHeight+"px";k.sb_cell.style.height=this._statusBar.offsetHeight+"px";var m=o-this._toolBar.offsetHeight-this._statusBar.offsetHeight;if(h("top")){m-=parseInt(this.config.panel_dimensions.top,10)}if(h("bottom")){m-=parseInt(this.config.panel_dimensions.bottom,10)}this._iframe.style.height=m+"px";var f=c;if(h("left")){f-=parseInt(this.config.panel_dimensions.left,10)}if(h("right")){f-=parseInt(this.config.panel_dimensions.right,10)}var g=this.config.iframeWidth?parseInt(this.config.iframeWidth,10):null;this._iframe.style.width=(g&&g<f)?g+"px":f+"px";this._textArea.style.height=this._iframe.style.height;this._textArea.style.width=this._iframe.style.width;this.notifyOf("resize",{width:this._htmlArea.offsetWidth,height:this._htmlArea.offsetHeight});this.firePluginEvent("onResize",this._htmlArea.offsetWidth,this._htmlArea.offsetWidth);this._risizing=false};Xinha.prototype.registerPanel=function(c,b){if(!c){c="right"}this.setLoadingMessage("Register "+c+" panel ");var a=this.addPanel(c);if(b){b.drawPanelIn(a)}};Xinha.prototype.addPanel=function(a){var b=document.createElement("div");b.side=a;if(a=="left"||a=="right"){b.style.width=this.config.panel_dimensions[a];if(this._iframe){b.style.height=this._iframe.style.height}}Xinha.addClasses(b,"panel");this._panels[a].panels.push(b);this._panels[a].div.appendChild(b);this.notifyOf("panel_change",{action:"add",panel:b});this.firePluginEvent("onPanelChange","add",b);return b};Xinha.prototype.removePanel=function(a){this._panels[a.side].div.removeChild(a);var c=[];for(var b=0;b<this._panels[a.side].panels.length;b++){if(this._panels[a.side].panels[b]!=a){c.push(this._panels[a.side].panels[b])}}this._panels[a.side].panels=c;this.notifyOf("panel_change",{action:"remove",panel:a});this.firePluginEvent("onPanelChange","remove",a)};Xinha.prototype.hidePanel=function(a){if(a&&a.style.display!="none"){try{var c=this.scrollPos(this._iframe.contentWindow)}catch(b){}a.style.display="none";this.notifyOf("panel_change",{action:"hide",panel:a});this.firePluginEvent("onPanelChange","hide",a);try{this._iframe.contentWindow.scrollTo(c.x,c.y)}catch(b){}}};Xinha.prototype.showPanel=function(a){if(a&&a.style.display=="none"){try{var c=this.scrollPos(this._iframe.contentWindow)}catch(b){}a.style.display="";this.notifyOf("panel_change",{action:"show",panel:a});this.firePluginEvent("onPanelChange","show",a);try{this._iframe.contentWindow.scrollTo(c.x,c.y)}catch(b){}}};Xinha.prototype.hidePanels=function(b){if(typeof b=="undefined"){b=["left","right","top","bottom"]}var c=[];for(var a=0;a<b.length;a++){if(this._panels[b[a]].on){c.push(b[a]);this._panels[b[a]].on=false}}this.notifyOf("panel_change",{action:"multi_hide",sides:b});this.firePluginEvent("onPanelChange","multi_hide",b)};Xinha.prototype.showPanels=function(b){if(typeof b=="undefined"){b=["left","right","top","bottom"]}var c=[];for(var a=0;a<b.length;a++){if(!this._panels[b[a]].on){c.push(b[a]);this._panels[b[a]].on=true}}this.notifyOf("panel_change",{action:"multi_show",sides:b});this.firePluginEvent("onPanelChange","multi_show",b)};Xinha.objectProperties=function(c){var b=[];for(var a in c){b[b.length]=a}return b};Xinha.prototype.editorIsActivated=function(){try{return Xinha.is_designMode?this._doc.designMode=="on":this._doc.body.contentEditable}catch(a){return false}};Xinha._someEditorHasBeenActivated=false;Xinha._currentlyActiveEditor=null;Xinha.prototype.activateEditor=function(){if(this.currentModal){return}if(Xinha._currentlyActiveEditor){if(Xinha._currentlyActiveEditor==this){return true}Xinha._currentlyActiveEditor.deactivateEditor()}if(Xinha.is_designMode&&this._doc.designMode!="on"){try{if(this._iframe.style.display=="none"){this._iframe.style.display="";this._doc.designMode="on";this._iframe.style.display="none"}else{this._doc.designMode="on"}if(Xinha.is_opera){this.setEditorEvents(true)}}catch(b){}}else{if(Xinha.is_ie&&this._doc.body.contentEditable!==true){this._doc.body.contentEditable=true}}Xinha._someEditorHasBeenActivated=true;Xinha._currentlyActiveEditor=this;var a=this;this.enableToolbar()};Xinha.prototype.deactivateEditor=function(){this.disableToolbar();if(Xinha.is_designMode&&this._doc.designMode!="off"){try{this._doc.designMode="off"}catch(a){}}else{if(!Xinha.is_designMode&&this._doc.body.contentEditable!==false){this._doc.body.contentEditable=false}}if(Xinha._currentlyActiveEditor!=this){return}Xinha._currentlyActiveEditor=false};Xinha.prototype.initIframe=function(){this.disableToolbar();var g=null;var b=this;try{if(b._iframe.contentDocument){this._doc=b._iframe.contentDocument}else{this._doc=b._iframe.contentWindow.document}g=this._doc;if(!g){if(Xinha.is_gecko){setTimeout(function(){b.initIframe()},50);return false}else{alert("ERROR: IFRAME can't be initialized.")}}}catch(f){setTimeout(function(){b.initIframe()},50);return false}Xinha.freeLater(this,"_doc");g.open("text/html","replace");var e="",a;if(b.config.browserQuirksMode===false){a='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'}else{if(b.config.browserQuirksMode===true){a=""}else{a=Xinha.getDoctype(document)}}if(!b.config.fullPage){e+=a+"\n";e+="<html>\n";e+="<head>\n";e+='<meta http-equiv="Content-Type" content="text/html; charset='+b.config.charSet+'">\n';if(typeof b.config.baseHref!="undefined"&&b.config.baseHref!==null){e+='<base href="'+b.config.baseHref+'"/>\n'}e+=Xinha.addCoreCSS();if(typeof b.config.pageStyleSheets!=="undefined"){for(var d=0;d<b.config.pageStyleSheets.length;d++){if(b.config.pageStyleSheets[d].length>0){e+='<link rel="stylesheet" type="text/css" href="'+b.config.pageStyleSheets[d]+'">'}}}if(b.config.pageStyle){e+='<style type="text/css">\n'+b.config.pageStyle+"\n</style>"}e+="</head>\n";e+="<body"+(b.config.bodyID?(' id="'+b.config.bodyID+'"'):"")+(b.config.bodyClass?(' class="'+b.config.bodyClass+'"'):"")+">\n";e+=b.inwardHtml(b._textArea.value);e+="</body>\n";e+="</html>"}else{e=b.inwardHtml(b._textArea.value);if(e.match(Xinha.RE_doctype)){b.setDoctype(RegExp.$1)}var c=e.match(/<link\s+[\s\S]*?["']\s*\/?>/gi);e=e.replace(/<link\s+[\s\S]*?["']\s*\/?>\s*/gi,"");if(c){e=e.replace(/<\/head>/i,c.join("\n")+"\n</head>")}}g.write(e);g.close();if(this.config.fullScreen){this._fullScreen()}this.setEditorEvents();if((typeof b.config.autofocus!="undefined")&&b.config.autofocus!==false&&((b.config.autofocus==b._textArea.id)||b.config.autofocus==true)){b.activateEditor();b.focusEditor()}};Xinha.prototype.whenDocReady=function(a){var b=this;if(this._doc&&this._doc.body){a()}else{setTimeout(function(){b.whenDocReady(a)},50)}};Xinha.prototype.setMode=function(b){var a;if(typeof b=="undefined"){b=this._editMode=="textmode"?"wysiwyg":"textmode"}switch(b){case"textmode":this.firePluginEvent("onBeforeMode","textmode");this._toolbarObjects.htmlmode.swapImage(this.config.iconList.wysiwygmode);this.setCC("iframe");a=this.outwardHtml(this.getHTML());this.setHTML(a);this.deactivateEditor();this._iframe.style.display="none";this._textArea.style.display="";if(this.config.statusBar){this._statusBarTree.style.display="none";this._statusBarTextMode.style.display=""}this.findCC("textarea");this.notifyOf("modechange",{mode:"text"});this.firePluginEvent("onMode","textmode");break;case"wysiwyg":this.firePluginEvent("onBeforeMode","wysiwyg");this._toolbarObjects.htmlmode.swapImage([this.imgURL("images/ed_buttons_main.png"),7,0]);this.setCC("textarea");a=this.inwardHtml(this.getHTML());this.deactivateEditor();this.setHTML(a);this._iframe.style.display="";this._textArea.style.display="none";this.activateEditor();if(this.config.statusBar){this._statusBarTree.style.display="";this._statusBarTextMode.style.display="none"}this.findCC("iframe");this.notifyOf("modechange",{mode:"wysiwyg"});this.firePluginEvent("onMode","wysiwyg");break;default:alert("Mode <"+b+"> not defined!");return false}this._editMode=b};Xinha.prototype.setFullHTML=function(c){var a=RegExp.multiline;RegExp.multiline=true;if(c.match(Xinha.RE_doctype)){this.setDoctype(RegExp.$1)}RegExp.multiline=a;if(0){if(c.match(Xinha.RE_head)){this._doc.getElementsByTagName("head")[0].innerHTML=RegExp.$1}if(c.match(Xinha.RE_body)){this._doc.getElementsByTagName("body")[0].innerHTML=RegExp.$1}}else{var d=this.editorIsActivated();if(d){this.deactivateEditor()}var b=/<html>((.|\n)*?)<\/html>/i;c=c.replace(b,"$1");this._doc.open("text/html","replace");this._doc.write(c);this._doc.close();if(d){this.activateEditor()}this.setEditorEvents();return true}};Xinha.prototype.setEditorEvents=function(c){var a=this;var b=this._doc;a.whenDocReady(function(){if(!c){Xinha._addEvents(b,["mousedown"],function(){a.activateEditor();return true});if(Xinha.is_ie){Xinha._addEvent(a._doc.getElementsByTagName("html")[0],"click",function(){if(a._iframe.contentWindow.event.srcElement.tagName.toLowerCase()=="html"){var f=a._doc.body.createTextRange();f.collapse();f.select()}return true})}}Xinha._addEvents(b,["keydown","keypress","mousedown","mouseup","drag"],function(f){return a._editorEvent(Xinha.is_ie?a._iframe.contentWindow.event:f)});Xinha._addEvents(b,["dblclick"],function(f){return a._onDoubleClick(Xinha.is_ie?a._iframe.contentWindow.event:f)});if(c){return}for(var e in a.plugins){var d=a.plugins[e].instance;Xinha.refreshPlugin(d)}if(typeof a._onGenerate=="function"){a._onGenerate()}Xinha.addDom0Event(window,"resize",function(f){if(Xinha.ie_version>7&&!window.parent){if(a.execResize){a.sizeEditor();a.execResize=false}else{a.execResize=true}}else{a.sizeEditor()}});a.removeLoadingMessage()})};Xinha.getPluginConstructor=function(a){return Xinha.plugins[a]||window[a]};Xinha.prototype.registerPlugin=function(){if(!Xinha.isSupportedBrowser){return}var a=arguments[0];if(a===null||typeof a=="undefined"||(typeof a=="string"&&Xinha.getPluginConstructor(a)=="undefined")){return false}var b=[];for(var c=1;c<arguments.length;++c){b.push(arguments[c])}return this.registerPlugin2(a,b)};Xinha.prototype.registerPlugin2=function(b,c){if(typeof b=="string"&&typeof Xinha.getPluginConstructor(b)=="function"){var a=b;b=Xinha.getPluginConstructor(b)}if(typeof b=="undefined"){return false}if(!b._pluginInfo){b._pluginInfo={name:a}}var f=new b(this,c);if(f){var g={};var e=b._pluginInfo;for(var d in e){g[d]=e[d]}g.instance=f;g.args=c;this.plugins[b._pluginInfo.name]=g;return f}else{Xinha.debugMsg("Can't register plugin "+b.toString()+".","warn")}};Xinha.getPluginDir=function(a,b){if(Xinha.externalPlugins[a]){return Xinha.externalPlugins[a][0]}if(b||(Xinha.getPluginConstructor(a)&&(typeof Xinha.getPluginConstructor(a).supported!="undefined")&&!Xinha.getPluginConstructor(a).supported)){return _editor_url+"unsupported_plugins/"+a}return _editor_url+"plugins/"+a};Xinha.loadPlugin=function(b,e,d){if(!Xinha.isSupportedBrowser){return}Xinha.setLoadingMessage(Xinha._lc("Loading plugin $plugin="+b+"$"));if(typeof Xinha.getPluginConstructor(b)!="undefined"){if(e){e(b)}return true}Xinha._pluginLoadStatus[b]="loading";function a(j,f){var m,i,l,k;switch(j){case"start":m="old_naming";i=Xinha.getPluginDir(f);l=f+".js";break;case"old_naming":m="unsupported";i=Xinha.getPluginDir(f);l=f.replace(/([a-z])([A-Z])([a-z])/g,function(p,o,n,q){return o+"-"+n.toLowerCase()+q}).toLowerCase()+".js";k="You are using an obsolete naming scheme for the Xinha plugin "+f+". Please rename "+l+" to "+f+".js";break;case"unsupported":m="unsupported_old_name";i=Xinha.getPluginDir(f,true);l=f+".js";k="You are using the unsupported Xinha plugin "+f+". If you wish continued support, please see http://trac.xinha.org/ticket/1297";break;case"unsupported_old_name":m="";i=Xinha.getPluginDir(f,true);l=f.replace(/([a-z])([A-Z])([a-z])/g,function(p,o,n,q){return o+"-"+n.toLowerCase()+q}).toLowerCase()+".js";k="You are using the unsupported Xinha plugin "+f+". If you wish continued support, please see http://trac.xinha.org/ticket/1297";break;default:Xinha._pluginLoadStatus[f]="failed";Xinha.debugMsg("Xinha was not able to find the plugin "+f+". Please make sure the plugin exists.","warn");return}var h=i+"/"+l;function g(n){Xinha.getPluginConstructor(n).supported=j.indexOf("unsupported")!==0;e(n)}Xinha._loadback(h,g,this,f);Xinha.ping(h,function(){if(k){Xinha.debugMsg(k)}},function(){Xinha.removeFromParent(document.getElementById(h));a(m,f)})}if(!d){if(Xinha.externalPlugins[b]){Xinha._loadback(Xinha.externalPlugins[b][0]+Xinha.externalPlugins[b][1],e,this,b)}else{var c=this;a("start",b)}}else{Xinha._loadback(d,e,this,b)}return false};Xinha._pluginLoadStatus={};Xinha.externalPlugins={};Xinha.plugins={};Xinha.loadPlugins=function(f,c,d){if(!Xinha.isSupportedBrowser){return}var b,e;for(e=0;e<f.length;e++){if(typeof f[e]=="object"){b=f[e].url.match(/(.*)(\/[^\/]*)$/);Xinha.externalPlugins[f[e].plugin]=[b[1],b[2]];f[e]=f[e].plugin}}var h=true;var a=Xinha.cloneObject(f);for(e=0;e<a.length;e++){var g=a[e];if(g=="FullScreen"&&!Xinha.externalPlugins.FullScreen){continue}if(typeof Xinha._pluginLoadStatus[g]=="undefined"){Xinha.loadPlugin(g,function(i){Xinha.setLoadingMessage(Xinha._lc("Finishing"));if(typeof Xinha.getPluginConstructor(i)!="undefined"){Xinha._pluginLoadStatus[i]="ready"}else{Xinha._pluginLoadStatus[i]="failed"}},d);h=false}else{if(Xinha._pluginLoadStatus[g]=="loading"){h=false}}}if(h){return true}if(c){setTimeout(function(){if(Xinha.loadPlugins(f,c)){c()}},50)}return h};Xinha.refreshPlugin=function(a){if(a&&typeof a.onGenerate=="function"){a.onGenerate()}if(a&&typeof a.onGenerateOnce=="function"){a._ongenerateOnce=a.onGenerateOnce;delete (a.onGenerateOnce);a._ongenerateOnce();delete (a._ongenerateOnce)}};Xinha.prototype.firePluginEvent=function(c){var e=[];for(var b=1;b<arguments.length;b++){e[b-1]=arguments[b]}for(b in this.plugins){var a=this.plugins[b].instance;if(a==this._browserSpecificPlugin){continue}if(a&&typeof a[c]=="function"){var d=(b=="Events")?this:a;if(a[c].apply(d,e)){return true}}}a=this._browserSpecificPlugin;if(a&&typeof a[c]=="function"){if(a[c].apply(a,e)){return true}}return false};Xinha.loadStyle=function(e,a,g,d){var b=_editor_url||"";if(a){b=Xinha.getPluginDir(a)+"/"}b+=e;if(/^\//.test(e)){b=e}var c=document.getElementsByTagName("head")[0];var f=document.createElement("link");f.rel="stylesheet";f.href=b;f.type="text/css";if(g){f.id=g}if(d&&c.getElementsByTagName("link")[0]){c.insertBefore(f,c.getElementsByTagName("link")[0])}else{c.appendChild(f)}};Xinha.loadScript=function(c,a,d){var b=_editor_url||"";if(a){b=Xinha.getPluginDir(a)+"/"}b+=c;if(/^\//.test(c)){b=c}Xinha._loadback(b,d)};Xinha.includeAssets=function(){var b={pendingAssets:[],loaderRunning:false,loadedScripts:[]};b.callbacks=[];b.loadNext=function(){var d=this;this.loaderRunning=true;if(this.pendingAssets.length){var c=this.pendingAssets[0];this.pendingAssets.splice(0,1);switch(c.type){case"text/css":Xinha.loadStyle(c.url,c.plugin);return this.loadNext();case"text/javascript":Xinha.loadScript(c.url,c.plugin,function(){d.loadNext()})}}else{this.loaderRunning=false;this.runCallback()}};b.loadScript=function(e,c){var d=this;this.pendingAssets.push({type:"text/javascript",url:e,plugin:c});if(!this.loaderRunning){this.loadNext()}return this};b.loadScriptOnce=function(d,c){for(var e=0;e<this.loadedScripts.length;e++){if(this.loadedScripts[e].url==d&&this.loadedScripts[e].plugin==c){return this}}return this.loadScript(d,c)};b.loadStyle=function(e,c){var d=this;this.pendingAssets.push({type:"text/css",url:e,plugin:c});if(!this.loaderRunning){this.loadNext()}return this};b.whenReady=function(c){this.callbacks.push(c);if(!this.loaderRunning){this.loadNext()}return this};b.runCallback=function(){while(this.callbacks.length){var c=this.callbacks.splice(0,1);c[0]();c=null}return this};for(var a=0;a<arguments.length;a++){if(typeof arguments[a]=="string"){if(arguments[a].match(/\.css$/i)){b.loadStyle(arguments[a])}else{b.loadScript(arguments[a])}}else{if(arguments[a].type){if(arguments[a].type.match(/text\/css/i)){b.loadStyle(arguments[a].url,arguments[a].plugin)}else{if(arguments[a].type.match(/text\/javascript/i)){b.loadScript(arguments[a].url,arguments[a].plugin)}}}else{if(arguments[a].length>=1){if(arguments[a][0].match(/\.css$/i)){b.loadStyle(arguments[a][0],arguments[a][1])}else{b.loadScript(arguments[a][0],arguments[a][1])}}}}}return b};Xinha.prototype.debugTree=function(){var c=document.createElement("textarea");c.style.width="100%";c.style.height="20em";c.value="";function b(d,e){for(;--d>=0;){c.value+=" "}c.value+=e+"\n"}function a(e,h){var d=e.tagName.toLowerCase(),f;var g=Xinha.is_ie?e.scopeName:e.prefix;b(h,"- "+d+" ["+g+"]");for(f=e.firstChild;f;f=f.nextSibling){if(f.nodeType==1){a(f,h+2)}}}a(this._doc.body,0);document.body.appendChild(c)};Xinha.getInnerText=function(c){var a="",b;for(b=c.firstChild;b;b=b.nextSibling){if(b.nodeType==3){a+=b.data}else{if(b.nodeType==1){a+=Xinha.getInnerText(b)}}}return a};Xinha.prototype._wordClean=function(){var b=this;var e={empty_tags:0,cond_comm:0,mso_elmts:0,mso_class:0,mso_style:0,mso_xmlel:0,orig_len:this._doc.body.innerHTML.length,T:new Date().getTime()};var g={empty_tags:"Empty tags removed: ",cond_comm:"Conditional comments removed",mso_elmts:"MSO invalid elements removed",mso_class:"MSO class names removed: ",mso_style:"MSO inline style removed: ",mso_xmlel:"MSO XML elements stripped: "};function f(){var j="Xinha word cleaner stats: \n\n";for(var k in e){if(g[k]){j+=g[k]+e[k]+"\n"}}j+="\nInitial document length: "+e.orig_len+"\n";j+="Final document length: "+b._doc.body.innerHTML.length+"\n";j+="Clean-up took "+((new Date().getTime()-e.T)/1000)+" seconds";alert(j)}function h(j){var k=j.className.replace(/(^|\s)mso.*?(\s|$)/ig," ");if(k!=j.className){j.className=k;if(!/\S/.test(j.className)){j.removeAttribute("className");++e.mso_class}}}function a(k){var l=k.style.cssText.split(/\s*;\s*/);for(var j=l.length;--j>=0;){if(/^mso|^tab-stops/i.test(l[j])||/^margin\s*:\s*0..\s+0..\s+0../i.test(l[j])){++e.mso_style;l.splice(j,1)}}k.style.cssText=l.join("; ")}function c(j){if(("link"==j.tagName.toLowerCase()&&(j.attributes&&/File-List|Edit-Time-Data|themeData|colorSchemeMapping/.test(j.attributes.rel.nodeValue)))||/^(style|meta)$/i.test(j.tagName)){Xinha.removeFromParent(j);++e.mso_elmts;return true}return false}function d(j){if(/^(a|span|b|strong|i|em|font|div|p)$/i.test(j.tagName)&&!j.firstChild){Xinha.removeFromParent(j);++e.empty_tags;return true}return false}function i(j){h(j);a(j);var m;for(var l=j.firstChild;l;l=m){m=l.nextSibling;if(l.nodeType==1&&i(l)){if((Xinha.is_ie&&j.scopeName!="HTML")||(!Xinha.is_ie&&/:/.test(l.tagName))){for(var k=l.childNodes&&l.childNodes.length-1;l.childNodes&&l.childNodes.length&&l.childNodes[k];--k){if(l.nextSibling){l.parentNode.insertBefore(l.childNodes[k],l.nextSibling)}else{l.parentNode.appendChild(l.childNodes[k])}}Xinha.removeFromParent(l);continue}if(d(l)){continue}if(c(l)){continue}}else{if(l.nodeType==8){if(/(\s*\[\s*if\s*(([gl]te?|!)\s*)?(IE|mso)\s*(\d+(\.\d+)?\s*)?\]>)/.test(l.nodeValue)){Xinha.removeFromParent(l);++e.cond_comm}}}}return true}i(this._doc.body);this.updateToolbar()};Xinha.prototype._clearFonts=function(){var a=this.getInnerHTML();if(confirm(Xinha._lc("Would you like to clear font typefaces?"))){a=a.replace(/face="[^"]*"/gi,"");a=a.replace(/font-family:[^;}"']+;?/gi,"")}if(confirm(Xinha._lc("Would you like to clear font sizes?"))){a=a.replace(/size="[^"]*"/gi,"");a=a.replace(/font-size:[^;}"']+;?/gi,"")}if(confirm(Xinha._lc("Would you like to clear font colours?"))){a=a.replace(/color="[^"]*"/gi,"");a=a.replace(/([^\-])color:[^;}"']+;?/gi,"$1")}a=a.replace(/(style|class)="\s*"/gi,"");a=a.replace(/<(font|span)\s*>/gi,"");this.setHTML(a);this.updateToolbar()};Xinha.prototype._splitBlock=function(){this._doc.execCommand("formatblock",false,"div")};Xinha.prototype.forceRedraw=function(){this._doc.body.style.visibility="hidden";this._doc.body.style.visibility=""};Xinha.prototype.focusEditor=function(){switch(this._editMode){case"wysiwyg":try{if(Xinha._someEditorHasBeenActivated){this.activateEditor();this._iframe.contentWindow.focus()}}catch(a){}break;case"textmode":try{this._textArea.focus()}catch(b){}break;default:alert("ERROR: mode "+this._editMode+" is not defined")}return this._doc};Xinha.prototype._undoTakeSnapshot=function(){++this._undoPos;if(this._undoPos>=this.config.undoSteps){this._undoQueue.shift();--this._undoPos}var b=true;var a=this.getInnerHTML();if(this._undoPos>0){b=(this._undoQueue[this._undoPos-1]!=a)}if(b){this._undoQueue[this._undoPos]=a}else{this._undoPos--}};Xinha.prototype.undo=function(){if(this._undoPos>0){var a=this._undoQueue[--this._undoPos];if(a){this.setHTML(a)}else{++this._undoPos}}};Xinha.prototype.redo=function(){if(this._undoPos<this._undoQueue.length-1){var a=this._undoQueue[++this._undoPos];if(a){this.setHTML(a)}else{--this._undoPos}}};Xinha.prototype.disableToolbar=function(a){if(this._timerToolbar){clearTimeout(this._timerToolbar)}if(typeof a=="undefined"){a=[]}else{if(typeof a!="object"){a=[a]}}for(var c in this._toolbarObjects){var b=this._toolbarObjects[c];if(a.contains(c)){continue}if(typeof b.state!="function"){continue}b.state("enabled",false)}};Xinha.prototype.enableToolbar=function(){this.updateToolbar()};Xinha.prototype.updateToolbar=function(noStatus){if(this.suspendUpdateToolbar){return}var doc=this._doc;var text=(this._editMode=="textmode");var ancestors=null;if(!text){ancestors=this.getAllAncestors();if(this.config.statusBar&&!noStatus){while(this._statusBarItems.length){var item=this._statusBarItems.pop();item.el=null;item.editor=null;item.onclick=null;item.oncontextmenu=null;item._xinha_dom0Events.click=null;item._xinha_dom0Events.contextmenu=null;item=null}this._statusBarTree.innerHTML=" ";this._statusBarTree.appendChild(document.createTextNode(Xinha._lc("Path")+": "));for(var i=ancestors.length;--i>=0;){var el=ancestors[i];if(!el){continue}var a=document.createElement("a");a.href="javascript:void(0);";a.el=el;a.editor=this;this._statusBarItems.push(a);Xinha.addDom0Event(a,"click",function(){this.blur();this.editor.selectNodeContents(this.el);this.editor.updateToolbar(true);return false});Xinha.addDom0Event(a,"contextmenu",function(){this.blur();var info="Inline style:\n\n";info+=this.el.style.cssText.split(/;\s*/).join(";\n");alert(info);return false});var txt=el.tagName.toLowerCase();switch(txt){case"b":txt="strong";break;case"i":txt="em";break;case"strike":txt="del";break}if(typeof el.style!="undefined"){a.title=el.style.cssText}if(el.id){txt+="#"+el.id}if(el.className){txt+="."+el.className}a.appendChild(document.createTextNode(txt));this._statusBarTree.appendChild(a);if(i!==0){this._statusBarTree.appendChild(document.createTextNode(String.fromCharCode(187)))}Xinha.freeLater(a)}}}for(var cmd in this._toolbarObjects){var btn=this._toolbarObjects[cmd];var inContext=true;if(typeof btn.state!="function"){continue}if(btn.context&&!text){inContext=false;var context=btn.context;var attrs=[];if(/(.*)\[(.*?)\]/.test(context)){context=RegExp.$1;attrs=RegExp.$2.split(",")}context=context.toLowerCase();var match=(context=="*");for(var k=0;k<ancestors.length;++k){if(!ancestors[k]){continue}if(match||(ancestors[k].tagName.toLowerCase()==context)){inContext=true;var contextSplit=null;var att=null;var comp=null;var attVal=null;for(var ka=0;ka<attrs.length;++ka){contextSplit=attrs[ka].match(/(.*)(==|!=|===|!==|>|>=|<|<=)(.*)/);att=contextSplit[1];comp=contextSplit[2];attVal=contextSplit[3];if(!eval(ancestors[k][att]+comp+attVal)){inContext=false;break}}if(inContext){break}}}}btn.state("enabled",(!text||btn.text)&&inContext);if(typeof cmd=="function"){continue}var dropdown=this.config.customSelects[cmd];if((!text||btn.text)&&(typeof dropdown!="undefined")){dropdown.refresh(this);continue}switch(cmd){case"fontname":case"fontsize":if(!text){try{var value=(""+doc.queryCommandValue(cmd)).toLowerCase();if(!value){btn.element.selectedIndex=0;break}var options=this.config[cmd];var sIndex=0;for(var j in options){if((j.toLowerCase()==value)||(options[j].substr(0,value.length).toLowerCase()==value)){btn.element.selectedIndex=sIndex;throw"ok"}++sIndex}btn.element.selectedIndex=0}catch(ex){}}break;case"formatblock":var blocks=[];for(var indexBlock in this.config.formatblock){if(typeof this.config.formatblock[indexBlock]=="string"){blocks[blocks.length]=this.config.formatblock[indexBlock]}}var deepestAncestor=this._getFirstAncestor(this.getSelection(),blocks);if(deepestAncestor){for(var x=0;x<blocks.length;x++){if(blocks[x].toLowerCase()==deepestAncestor.tagName.toLowerCase()){btn.element.selectedIndex=x}}}else{btn.element.selectedIndex=0}break;case"textindicator":if(!text){try{var style=btn.element.style;style.backgroundColor=Xinha._makeColor(doc.queryCommandValue(Xinha.is_ie?"backcolor":"hilitecolor"));if(/transparent/i.test(style.backgroundColor)){style.backgroundColor=Xinha._makeColor(doc.queryCommandValue("backcolor"))}style.color=Xinha._makeColor(doc.queryCommandValue("forecolor"));style.fontFamily=doc.queryCommandValue("fontname");style.fontWeight=doc.queryCommandState("bold")?"bold":"normal";style.fontStyle=doc.queryCommandState("italic")?"italic":"normal"}catch(ex){}}break;case"htmlmode":btn.state("active",text);break;case"lefttoright":case"righttoleft":var eltBlock=this.getParentElement();while(eltBlock&&!Xinha.isBlockElement(eltBlock)){eltBlock=eltBlock.parentNode}if(eltBlock){btn.state("active",(eltBlock.style.direction==((cmd=="righttoleft")?"rtl":"ltr")))}break;default:cmd=cmd.replace(/(un)?orderedlist/i,"insert$1orderedlist");try{btn.state("active",(!text&&doc.queryCommandState(cmd)))}catch(ex){}break}}if(this._customUndo&&!this._timerUndo){this._undoTakeSnapshot();var editor=this;this._timerUndo=setTimeout(function(){editor._timerUndo=null},this.config.undoTimeout)}this.firePluginEvent("onUpdateToolbar")};Xinha.getEditor=function(c){for(var b=__xinhas.length;b--;){var a=__xinhas[b];if(a&&(a._textArea.id==c||a._textArea.name==c||a._textArea==c)){return a}}return null};Xinha.prototype.getPluginInstance=function(a){if(this.plugins[a]){return this.plugins[a].instance}else{return null}};Xinha.prototype.getAllAncestors=function(){var c=this.getParentElement();var b=[];while(c&&(c.nodeType==1)&&(c.tagName.toLowerCase()!="body")){b.push(c);c=c.parentNode}b.push(this._doc.body);return b};Xinha.prototype._getFirstAncestor=function(e,d){var c=this.activeElement(e);if(c===null){try{c=(Xinha.is_ie?this.createRange(e).parentElement():this.createRange(e).commonAncestorContainer)}catch(b){return null}}if(typeof d=="string"){d=[d]}while(c){if(c.nodeType==1){if(d===null){return c}for(var a=0;a<d.length;++a){if(typeof d[a]=="string"&&d[a]==c.tagName.toLowerCase()){return c}else{if(typeof d[a]=="function"&&d[a](this,c)){return c}}}if(c.tagName.toLowerCase()=="body"){break}if(c.tagName.toLowerCase()=="table"){break}}c=c.parentNode}return null};Xinha.prototype._getAncestorBlock=function(b){var a=(Xinha.is_ie?this.createRange(b).parentElement:this.createRange(b).commonAncestorContainer);while(a&&(a.nodeType==1)){switch(a.tagName.toLowerCase()){case"div":case"p":case"address":case"blockquote":case"center":case"del":case"ins":case"pre":case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":case"h7":return a;case"body":case"noframes":case"dd":case"li":case"th":case"td":case"noscript":return null;default:break}}return null};Xinha.prototype._createImplicitBlock=function(b){var c=this.getSelection();if(Xinha.is_ie){c.empty()}else{c.collapseToStart()}var a=this.createRange(c)};Xinha.prototype.surroundHTML=function(c,a){var b=this.getSelectedHTML();this.insertHTML(c+b+a)};Xinha.prototype.hasSelectedText=function(){return this.getSelectedHTML()!==""};Xinha.prototype._comboSelected=function(b,a){this.focusEditor();var c=b.options[b.selectedIndex].value;switch(a){case"fontname":case"fontsize":this.execCommand(a,false,c);break;case"formatblock":if(!c){this.updateToolbar();break}if(!Xinha.is_gecko||c!=="blockquote"){c="<"+c+">"}this.execCommand(a,false,c);break;default:var d=this.config.customSelects[a];if(typeof d!="undefined"){d.action(this,c,b,a)}else{alert("FIXME: combo box "+a+" not implemented")}break}};Xinha.prototype._colorSelector=function(h){var d=this;if(Xinha.is_gecko){try{d._doc.execCommand("useCSS",false,false);d._doc.execCommand("styleWithCSS",false,true)}catch(g){}}var f=d._toolbarObjects[h].element;var c;if(h=="hilitecolor"){if(Xinha.is_ie){h="backcolor";c=Xinha._colorToRgb(d._doc.queryCommandValue("backcolor"))}else{c=Xinha._colorToRgb(d._doc.queryCommandValue("hilitecolor"))}}else{c=Xinha._colorToRgb(d._doc.queryCommandValue("forecolor"))}var b=function(i){d._doc.execCommand(h,false,i)};if(Xinha.is_ie){var a=d.createRange(d.getSelection());b=function(i){a.select();d._doc.execCommand(h,false,i)}}var e=new Xinha.colorPicker({cellsize:d.config.colorPickerCellSize,callback:b,granularity:d.config.colorPickerGranularity,websafe:d.config.colorPickerWebSafe,savecolors:d.config.colorPickerSaveColors});e.open(d.config.colorPickerPosition,f,c)};Xinha.prototype.execCommand=function(h,f,g){var a=this;this.focusEditor();h=h.toLowerCase();if(this.firePluginEvent("onExecCommand",h,f,g)){this.updateToolbar();return false}switch(h){case"htmlmode":this.setMode();break;case"hilitecolor":case"forecolor":this._colorSelector(h);break;case"createlink":this._createLink();break;case"undo":case"redo":if(this._customUndo){this[h]()}else{this._doc.execCommand(h,f,g)}break;case"inserttable":this._insertTable();break;case"insertimage":this._insertImage();break;case"showhelp":this._popupDialog(a.config.URIs.help,null,this);break;case"killword":this._wordClean();break;case"cut":case"copy":case"paste":this._doc.execCommand(h,f,g);if(this.config.killWordOnPaste){this._wordClean()}break;case"lefttoright":case"righttoleft":if(this.config.changeJustifyWithDirection){this._doc.execCommand((h=="righttoleft")?"justifyright":"justifyleft",f,g)}var b=(h=="righttoleft")?"rtl":"ltr";var e=this.getParentElement();while(e&&!Xinha.isBlockElement(e)){e=e.parentNode}if(e){if(e.style.direction==b){e.style.direction=""}else{e.style.direction=b}}break;case"justifyleft":case"justifyright":h.match(/^justify(.*)$/);var d=this.activeElement(this.getSelection());if(d&&d.tagName.toLowerCase()=="img"){d.align=d.align==RegExp.$1?"":RegExp.$1}else{this._doc.execCommand(h,f,g)}break;default:try{this._doc.execCommand(h,f,g)}catch(c){if(this.config.debug){alert(c+"\n\nby execCommand("+h+");")}}break}this.updateToolbar();return false};Xinha.prototype._editorEvent=function(b){var a=this;if(typeof a._textArea["on"+b.type]=="function"){a._textArea["on"+b.type](b)}if(this.isKeyEvent(b)){if(a.firePluginEvent("onKeyPress",b)){return false}if(this.isShortCut(b)){this._shortCuts(b)}}if(b.type=="mousedown"){if(a.firePluginEvent("onMouseDown",b)){return false}}if(a._timerToolbar){clearTimeout(a._timerToolbar)}if(!this.suspendUpdateToolbar){a._timerToolbar=setTimeout(function(){a.updateToolbar();a._timerToolbar=null},250)}};Xinha.prototype._onDoubleClick=function(d){var c=this;var e=Xinha.is_ie?d.srcElement:d.target;var a=e.tagName;var b=e.className;if(a){a=a.toLowerCase();if(b&&(this.config.dblclickList[a+"."+b]!=undefined)){this.config.dblclickList[a+"."+b][0](c,e)}else{if(this.config.dblclickList[a]!=undefined){this.config.dblclickList[a][0](c,e)}}}};Xinha.prototype._shortCuts=function(b){var a=this.getKey(b).toLowerCase();var d=null;var c=null;switch(a){case"b":d="bold";break;case"i":d="italic";break;case"u":d="underline";break;case"s":d="strikethrough";break;case"l":d="justifyleft";break;case"e":d="justifycenter";break;case"r":d="justifyright";break;case"j":d="justifyfull";break;case"z":d="undo";break;case"y":d="redo";break;case"v":d="paste";break;case"n":d="formatblock";c="p";break;case"0":d="killword";break;case"1":case"2":case"3":case"4":case"5":case"6":d="formatblock";c="h"+a;break}if(d){this.execCommand(d,false,c);Xinha._stopEvent(b)}};Xinha.prototype.convertNode=function(a,c){var b=this._doc.createElement(c);while(a.firstChild){b.appendChild(a.firstChild)}return b};Xinha.prototype.scrollToElement=function(b){if(!b){b=this.getParentElement();if(!b){return}}var a=Xinha.getElementTopLeft(b);this._iframe.contentWindow.scrollTo(a.left,a.top)};Xinha.prototype.getEditorContent=function(){return this.outwardHtml(this.getHTML())};Xinha.prototype.setEditorContent=function(a){this.setHTML(this.inwardHtml(a))};Xinha.updateTextareas=function(){var b;for(var a=0;a<__xinhas.length;a++){b=__xinhas[a];b._textArea.value=b.getEditorContent()}};Xinha.prototype.getHTML=function(){var a="";switch(this._editMode){case"wysiwyg":if(!this.config.fullPage){a=Xinha.getHTML(this._doc.body,false,this).trim()}else{a=this.doctype+"\n"+Xinha.getHTML(this._doc.documentElement,true,this)}break;case"textmode":a=this._textArea.value;break;default:alert("Mode <"+this._editMode+"> not defined!");return false}return a};Xinha.prototype.outwardHtml=function(d){for(var c in this.plugins){var a=this.plugins[c].instance;if(a&&typeof a.outwardHtml=="function"){d=a.outwardHtml(d)}}d=d.replace(/<(\/?)b(\s|>|\/)/ig,"<$1strong$2");d=d.replace(/<(\/?)i(\s|>|\/)/ig,"<$1em$2");d=d.replace(/<(\/?)strike(\s|>|\/)/ig,"<$1del$2");d=d.replace(/(<[^>]*on(click|mouse(over|out|up|down))=['"])if\(window\.parent &amp;&amp; window\.parent\.Xinha\)\{return false\}/gi,"$1");var b=location.href.replace(/(https?:\/\/[^\/]*)\/.*/,"$1")+"/";d=d.replace(/https?:\/\/null\//g,b);d=d.replace(/((href|src|background)=[\'\"])\/+/ig,"$1"+b);d=this.outwardSpecialReplacements(d);d=this.fixRelativeLinks(d);if(this.config.sevenBitClean){d=d.replace(/[^ -~\r\n\t]/g,function(e){return(e!=Xinha.cc)?"&#"+e.charCodeAt(0)+";":e})}d=d.replace(/(<script[^>]*((type=[\"\']text\/)|(language=[\"\'])))(freezescript)/gi,"$1javascript");if(this.config.fullPage){d=Xinha.stripCoreCSS(d)}if(typeof this.config.outwardHtml=="function"){d=this.config.outwardHtml(d)}return d};Xinha.prototype.inwardHtml=function(c){for(var b in this.plugins){var a=this.plugins[b].instance;if(a&&typeof a.inwardHtml=="function"){c=a.inwardHtml(c)}}c=c.replace(/<(\/?)del(\s|>|\/)/ig,"<$1strike$2");c=c.replace(/(<[^>]*on(click|mouse(over|out|up|down))=["'])/gi,"$1if(window.parent &amp;&amp; window.parent.Xinha){return false}");c=this.inwardSpecialReplacements(c);c=c.replace(/(<script[^>]*((type=[\"\']text\/)|(language=[\"\'])))(javascript)/gi,"$1freezescript");var d=new RegExp("((href|src|background)=['\"])/+","gi");c=c.replace(d,"$1"+location.href.replace(/(https?:\/\/[^\/]*)\/.*/,"$1")+"/");c=this.fixRelativeLinks(c);if(this.config.fullPage){c=Xinha.addCoreCSS(c)}if(typeof this.config.inwardHtml=="function"){c=this.config.inwardHtml(c)}return c};Xinha.prototype.outwardSpecialReplacements=function(b){for(var a in this.config.specialReplacements){var e=this.config.specialReplacements[a];var d=a;if(typeof e.replace!="function"||typeof d.replace!="function"){continue}var c=new RegExp(Xinha.escapeStringForRegExp(e),"g");b=b.replace(c,d.replace(/\$/g,"$$$$"))}return b};Xinha.prototype.inwardSpecialReplacements=function(b){for(var a in this.config.specialReplacements){var e=a;var d=this.config.specialReplacements[a];if(typeof e.replace!="function"||typeof d.replace!="function"){continue}var c=new RegExp(Xinha.escapeStringForRegExp(e),"g");b=b.replace(c,d.replace(/\$/g,"$$$$"))}return b};Xinha.prototype.fixRelativeLinks=function(f){if(typeof this.config.expandRelativeUrl!="undefined"&&this.config.expandRelativeUrl){if(f==null){return""}var c=f.match(/(src|href)="([^"]*)"/gi);var j=document.location.href;if(c){var d,l,k,m,h;for(var e=0;e<c.length;++e){d=c[e].match(/(src|href)="([^"]*)"/i);l=d[2].match(/\.\.\//g);if(l){k=new RegExp("(.*?)(([^/]*/){"+l.length+"})[^/]*$");m=j.match(k);h=d[2].replace(/(\.\.\/)*/,m[1]);f=f.replace(new RegExp(Xinha.escapeStringForRegExp(d[2])),h)}}}}if(typeof this.config.stripSelfNamedAnchors!="undefined"&&this.config.stripSelfNamedAnchors){var g=new RegExp('((href|src|background)=")('+Xinha.escapeStringForRegExp(window.unescape(document.location.href.replace(/&/g,"&amp;")))+")([#?][^'\" ]*)","g");f=f.replace(g,"$1$4")}if(typeof this.config.stripBaseHref!="undefined"&&this.config.stripBaseHref){var a=null;if(typeof this.config.baseHref!="undefined"&&this.config.baseHref!==null){a=new RegExp('((href|src|background|action)=")('+Xinha.escapeStringForRegExp(this.config.baseHref.replace(/([^\/]\/)(?=.+\.)[^\/]*$/,"$1"))+")","g");f=f.replace(a,"$1")}a=new RegExp('((href|src|background|action)=")('+Xinha.escapeStringForRegExp(document.location.href.replace(/^(https?:\/\/[^\/]*)(.*)/,"$1"))+")","g");f=f.replace(a,"$1")}return f};Xinha.prototype.getInnerHTML=function(){if(!this._doc.body){return""}var a="";switch(this._editMode){case"wysiwyg":if(!this.config.fullPage){a=this._doc.body.innerHTML}else{a=this.doctype+"\n"+this._doc.documentElement.innerHTML}break;case"textmode":a=this._textArea.value;break;default:alert("Mode <"+this._editMode+"> not defined!");return false}return a};Xinha.prototype.setHTML=function(a){if(!this.config.fullPage){this._doc.body.innerHTML=a}else{this.setFullHTML(a)}this._textArea.value=a};Xinha.prototype.setDoctype=function(a){this.doctype=a};Xinha._object=null;Array.prototype.isArray=true;RegExp.prototype.isRegExp=true;Xinha.cloneObject=function(obj){if(!obj){return null}var newObj=obj.isArray?[]:{};if(obj.constructor.toString().match(/\s*function Function\(/)||typeof obj=="function"){newObj=obj}else{if(obj.isRegExp){newObj=eval(obj.toString())}else{for(var n in obj){var node=obj[n];if(typeof node=="object"){newObj[n]=Xinha.cloneObject(node)}else{newObj[n]=node}}}}return newObj};Xinha.extend=function(a,c){function b(){}b.prototype=c.prototype;a.prototype=new b();a.prototype.constructor=a;a.parentConstructor=c;a.superClass=c.prototype};Xinha.flushEvents=function(){var a=0;var c=Xinha._eventFlushers.pop();while(c){try{if(c.length==3){Xinha._removeEvent(c[0],c[1],c[2]);a++}else{if(c.length==2){c[0]["on"+c[1]]=null;c[0]._xinha_dom0Events[c[1]]=null;a++}}}catch(b){}c=Xinha._eventFlushers.pop()}};Xinha._eventFlushers=[];if(document.addEventListener){Xinha._addEvent=function(b,a,c){b.addEventListener(a,c,false);Xinha._eventFlushers.push([b,a,c])};Xinha._removeEvent=function(b,a,c){b.removeEventListener(a,c,false)};Xinha._stopEvent=function(a){a.preventDefault();a.stopPropagation()}}else{if(document.attachEvent){Xinha._addEvent=function(b,a,c){b.attachEvent("on"+a,c);Xinha._eventFlushers.push([b,a,c])};Xinha._removeEvent=function(b,a,c){b.detachEvent("on"+a,c)};Xinha._stopEvent=function(b){try{b.cancelBubble=true;b.returnValue=false}catch(a){}}}else{Xinha._addEvent=function(b,a,c){alert("_addEvent is not supported")};Xinha._removeEvent=function(b,a,c){alert("_removeEvent is not supported")};Xinha._stopEvent=function(a){alert("_stopEvent is not supported")}}}Xinha._addEvents=function(c,a,d){for(var b=a.length;--b>=0;){Xinha._addEvent(c,a[b],d)}};Xinha._removeEvents=function(c,a,d){for(var b=a.length;--b>=0;){Xinha._removeEvent(c,a[b],d)}};Xinha.addOnloadHandler=function(b,a){a=a?a:window;var c=function(){if(arguments.callee.done){return}arguments.callee.done=true;if(Xinha.onloadTimer){clearInterval(Xinha.onloadTimer)}b()};if(Xinha.is_ie){document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",arguments.callee);c()}});if(document.documentElement.doScroll&&typeof window.frameElement==="undefined"){(function(){if(arguments.callee.done){return}try{document.documentElement.doScroll("left")}catch(d){setTimeout(arguments.callee,0);return}c()})()}}else{if(/applewebkit|KHTML/i.test(navigator.userAgent)){Xinha.onloadTimer=a.setInterval(function(){if(/loaded|complete/.test(a.document.readyState)){c()}},10)}else{a.document.addEventListener("DOMContentLoaded",c,false)}}Xinha._addEvent(a,"load",c)};Xinha.addDom0Event=function(b,c,a){Xinha._prepareForDom0Events(b,c);b._xinha_dom0Events[c].unshift(a)};Xinha.prependDom0Event=function(b,c,a){Xinha._prepareForDom0Events(b,c);b._xinha_dom0Events[c].push(a)};Xinha.getEvent=function(a){return a||window.event};Xinha._prepareForDom0Events=function(a,b){if(typeof a._xinha_dom0Events=="undefined"){a._xinha_dom0Events={};Xinha.freeLater(a,"_xinha_dom0Events")}if(typeof a._xinha_dom0Events[b]=="undefined"){a._xinha_dom0Events[b]=[];if(typeof a["on"+b]=="function"){a._xinha_dom0Events[b].push(a["on"+b])}a["on"+b]=function(e){var c=a._xinha_dom0Events[b];var f=true;for(var d=c.length;--d>=0;){a._xinha_tempEventHandler=c[d];if(a._xinha_tempEventHandler(e)===false){a._xinha_tempEventHandler=null;f=false;break}a._xinha_tempEventHandler=null}return f};Xinha._eventFlushers.push([a,b])}};Xinha.prototype.notifyOn=function(b,a){if(typeof this._notifyListeners[b]=="undefined"){this._notifyListeners[b]=[];Xinha.freeLater(this,"_notifyListeners")}this._notifyListeners[b].push(a)};Xinha.prototype.notifyOf=function(c,a){if(this._notifyListeners[c]){for(var b=0;b<this._notifyListeners[c].length;b++){this._notifyListeners[c][b](c,a)}}};Xinha._blockTags=" body form textarea fieldset ul ol dl li div p h1 h2 h3 h4 h5 h6 quote pre table thead tbody tfoot tr td th iframe address blockquote title meta link style head ";Xinha.isBlockElement=function(a){return a&&a.nodeType==1&&(Xinha._blockTags.indexOf(" "+a.tagName.toLowerCase()+" ")!=-1)};Xinha._paraContainerTags=" body td th caption fieldset div ";Xinha.isParaContainer=function(a){return a&&a.nodeType==1&&(Xinha._paraContainerTags.indexOf(" "+a.tagName.toLowerCase()+" ")!=-1)};Xinha._closingTags=" a abbr acronym address applet b bdo big blockquote button caption center cite code del dfn dir div dl em fieldset font form frameset h1 h2 h3 h4 h5 h6 i iframe ins kbd label legend map menu noframes noscript object ol optgroup pre q s samp script select small span strike strong style sub sup table textarea title tt u ul var ";Xinha.needsClosingTag=function(a){return a&&a.nodeType==1&&(Xinha._closingTags.indexOf(" "+a.tagName.toLowerCase()+" ")!=-1)};Xinha.htmlEncode=function(a){if(!a){return""}if(typeof a.replace=="undefined"){a=a.toString()}a=a.replace(/&/ig,"&amp;");a=a.replace(/</ig,"&lt;");a=a.replace(/>/ig,"&gt;");a=a.replace(/\xA0/g,"&nbsp;");a=a.replace(/\x22/g,"&quot;");return a};Xinha.prototype.stripBaseURL=function(b){if(this.config.baseHref===null||!this.config.stripBaseHref){return b}var c=this.config.baseHref.replace(/^(https?:\/\/[^\/]+)(.*)$/,"$1");var a=new RegExp(c);return b.replace(a,"")};if(typeof String.prototype.trim!="function"){String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")}}Xinha._makeColor=function(c){if(typeof c!="number"){return c}var e=c&255;var d=(c>>8)&255;var a=(c>>16)&255;return"rgb("+e+","+d+","+a+")"};Xinha._colorToRgb=function(c){if(!c){return""}var h,f,a;function e(b){return(b<16)?("0"+b.toString(16)):b.toString(16)}if(typeof c=="number"){h=c&255;f=(c>>8)&255;a=(c>>16)&255;return"#"+e(h)+e(f)+e(a)}if(c.substr(0,3)=="rgb"){var d=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/;if(c.match(d)){h=parseInt(RegExp.$1,10);f=parseInt(RegExp.$2,10);a=parseInt(RegExp.$3,10);return"#"+e(h)+e(f)+e(a)}return null}if(c.substr(0,1)=="#"){return c}return null};Xinha.prototype._popupDialog=function(b,a,c){Dialog(this.popupURL(b),a,c)};Xinha.prototype.imgURL=function(b,a){if(typeof a=="undefined"){return _editor_url+b}else{return Xinha.getPluginDir(a)+"/img/"+b}};Xinha.prototype.popupURL=function(d){var c="";if(d.match(/^plugin:\/\/(.*?)\/(.*)/)){var b=RegExp.$1;var a=RegExp.$2;if(!/\.(html?|php)$/.test(a)){a+=".html"}c=Xinha.getPluginDir(b)+"/popups/"+a}else{if(d.match(/^\/.*?/)||d.match(/^https?:\/\//)){c=d}else{c=_editor_url+this.config.popupURL+d}}return c};Xinha.getElementById=function(a,e){var c,b,d=document.getElementsByTagName(a);for(b=d.length;--b>=0&&(c=d[b]);){if(c.id==e){return c}}return null};Xinha.prototype._toggleBorders=function(){var a=this._doc.getElementsByTagName("TABLE");if(a.length!==0){if(!this.borders){this.borders=true}else{this.borders=false}for(var b=0;b<a.length;b++){if(this.borders){Xinha._addClass(a[b],"htmtableborders")}else{Xinha._removeClass(a[b],"htmtableborders")}}}return true};Xinha.addCoreCSS=function(b){var a='<style title="XinhaInternalCSS" type="text/css">.htmtableborders, .htmtableborders td, .htmtableborders th {border : 1px dashed lightgrey ! important;}\nhtml, body { border: 0px; } \nbody { background-color: #ffffff; } \nimg, hr { cursor: default } \n</style>\n';if(b&&/<head>/i.test(b)){return b.replace(/<head>/i,"<head>"+a)}else{if(b){return a+b}else{return a}}};Xinha.prototype.addEditorStylesheet=function(a){var b=this._doc.createElement("link");b.rel="stylesheet";b.type="text/css";b.title="XinhaInternalCSS";b.href=a;this._doc.getElementsByTagName("HEAD")[0].appendChild(b)};Xinha.stripCoreCSS=function(a){return a.replace(/<style[^>]+title="XinhaInternalCSS"(.|\n)*?<\/style>/ig,"").replace(/<link[^>]+title="XinhaInternalCSS"(.|\n)*?>/ig,"")};Xinha._removeClass=function(e,c){if(!(e&&e.className)){return}var a=e.className.split(" ");var b=[];for(var d=a.length;d>0;){if(a[--d]!=c){b[b.length]=a[d]}}e.className=b.join(" ")};Xinha._addClass=function(b,a){Xinha._removeClass(b,a);b.className+=" "+a};Xinha.addClasses=function(g,e){if(g!==null){var f=g.className.trim().split(" ");var d=e.split(" ");for(var a=0;a<d.length;a++){var b=false;for(var c=0;b===false&&c<f.length;c++){if(f[c]==d[a]){b=true}}if(b===false){f[f.length]=d[a]}}g.className=f.join(" ").trim()}};Xinha.removeClasses=function(e,d){var b=e.className.trim().split();var f=[];var h=d.trim().split();for(var c=0;c<b.length;c++){var g=false;for(var a=0;a<h.length&&!g;a++){if(b[c]==h[a]){g=true}}if(!g){f[f.length]=b[c]}}return f.join(" ")};Xinha.addClass=Xinha._addClass;Xinha.removeClass=Xinha._removeClass;Xinha._addClasses=Xinha.addClasses;Xinha._removeClasses=Xinha.removeClasses;Xinha._hasClass=function(d,b){if(!(d&&d.className)){return false}var a=d.className.split(" ");for(var c=a.length;c>0;){if(a[--c]==b){return true}}return false};Xinha._postback_send_charset=true;Xinha._postback=function(b,g,h,d){var f=null;f=Xinha.getXMLHTTPRequestObject();var e="";if(typeof g=="string"){e=g}else{if(typeof g=="object"){for(var c in g){e+=(e.length?"&":"")+c+"="+encodeURIComponent(g[c])}}}function a(){if(f.readyState==4){if(((f.status/100)==2)||Xinha.isRunLocally&&f.status===0){if(typeof h=="function"){h(f.responseText,f)}}else{if(Xinha._postback_send_charset){Xinha._postback_send_charset=false;Xinha._postback(b,g,h,d)}else{if(typeof d=="function"){d(f)}else{alert("An error has occurred: "+f.statusText+"\nURL: "+b)}}}}}f.onreadystatechange=a;f.open("POST",b,true);f.setRequestHeader("Content-Type","application/x-www-form-urlencoded"+(Xinha._postback_send_charset?"; charset=UTF-8":""));f.send(e)};Xinha._getback=function(b,e,c){var d=null;d=Xinha.getXMLHTTPRequestObject();function a(){if(d.readyState==4){if(((d.status/100)==2)||Xinha.isRunLocally&&d.status===0){e(d.responseText,d)}else{if(typeof c=="function"){c(d)}else{alert("An error has occurred: "+d.statusText+"\nURL: "+b)}}}}d.onreadystatechange=a;d.open("GET",b,true);d.send(null)};Xinha.ping=function(d,c,b){var e=null;e=Xinha.getXMLHTTPRequestObject();function a(){if(e.readyState==4){if(((e.status/100)==2)||Xinha.isRunLocally&&e.status===0){if(c){c(e)}}else{if(b){b(e)}}}}var f="GET";e.onreadystatechange=a;e.open(f,d,true);e.send(null)};Xinha._geturlcontent=function(a,c){var b=null;b=Xinha.getXMLHTTPRequestObject();b.open("GET",a,false);b.send(null);if(((b.status/100)==2)||Xinha.isRunLocally&&b.status===0){return(c)?b.responseXML:b.responseText}else{return""}};if(typeof dumpValues=="undefined"){dumpValues=function(c){var b="";for(var d in c){if(window.console&&typeof window.console.log=="function"){if(typeof console.firebug!="undefined"){console.log(c)}else{console.log(d+" = "+c[d]+"\n")}}else{b+=d+" = "+c[d]+"\n"}}if(b){if(document.getElementById("errors")){document.getElementById("errors").value+=b}else{var a=window.open("","debugger");a.document.write("<pre>"+b+"</pre>")}}}}if(!Array.prototype.contains){Array.prototype.contains=function(c){var b=this;for(var a=0;a<b.length;a++){if(c==b[a]){return true}}return false}}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(c){var b=this;for(var a=0;a<b.length;a++){if(c==b[a]){return a}}return null}}if(!Array.prototype.append){Array.prototype.append=function(b){for(var c=0;c<b.length;c++){this.push(b[c])}return this}}if(!Array.prototype.forEach){Array.prototype.forEach=function(d){var a=this.length;if(typeof d!="function"){throw new TypeError()}var c=arguments[1];for(var b=0;b<a;b++){if(b in this){d.call(c,this[b],b,this)}}}}Xinha.getElementsByClassName=function(d,a){if(d.getElementsByClassName){return Array.prototype.slice.call(d.getElementsByClassName(a))}else{var c=d.getElementsByTagName("*");var e=[];var f;for(var b=0;b<c.length;b++){f=c[b].className.split(" ");if(f.contains(a)){e.push(c[b])}}return e}};Xinha.arrayContainsArray=function(c,b){var e=true;for(var a=0;a<b.length;a++){var f=false;for(var d=0;d<c.length;d++){if(c[d]==b[a]){f=true;break}}if(!f){e=false;break}}return e};Xinha.arrayFilter=function(c,b){var d=[];for(var a=0;a<c.length;a++){if(b(c[a])){d[d.length]=c[a]}}return d};Xinha.collectionToArray=function(c){try{return c.length?Array.prototype.slice.call(c):[]}catch(b){}var d=[];for(var a=0;a<c.length;a++){d.push(c.item(a))}return d};Xinha.uniq_count=0;Xinha.uniq=function(a){return a+Xinha.uniq_count++};Xinha._loadlang=function(context,url){var lang;if(typeof _editor_lcbackend=="string"){url=_editor_lcbackend;url=url.replace(/%lang%/,_editor_lang);url=url.replace(/%context%/,context)}else{if(!url){if(context!="Xinha"){url=Xinha.getPluginDir(context)+"/lang/"+_editor_lang+".js"}else{Xinha.setLoadingMessage("Loading language");url=_editor_url+"lang/"+_editor_lang+".js"}}}var langData=Xinha._geturlcontent(url);if(langData!==""){try{eval("lang = "+langData)}catch(ex){alert("Error reading Language-File ("+url+"):\n"+Error.toString());lang={}}}else{lang={}}return lang};Xinha._lc=function(d,b,c){var a,h;if(typeof b=="object"&&b.url&&b.context){a=b.url+_editor_lang+".js";b=b.context}var f=null;if(typeof d=="string"){f=d.match(/\$(.*?)=(.*?)\$/g)}if(f){if(!c){c={}}for(var g=0;g<f.length;g++){var e=f[g].match(/\$(.*?)=(.*?)\$/);c[e[1]]=e[2];d=d.replace(e[0],"$"+e[1])}}if(_editor_lang=="en"){if(typeof d=="object"&&d.string){h=d.string}else{h=d}}else{if(typeof Xinha._lc_catalog=="undefined"){Xinha._lc_catalog=[]}if(typeof b=="undefined"){b="Xinha"}if(typeof Xinha._lc_catalog[b]=="undefined"){Xinha._lc_catalog[b]=Xinha._loadlang(b,a)}var j;if(typeof d=="object"&&d.key){j=d.key}else{if(typeof d=="object"&&d.string){j=d.string}else{j=d}}if(typeof Xinha._lc_catalog[b][j]=="undefined"){if(b=="Xinha"){if(typeof d=="object"&&d.string){h=d.string}else{h=d}}else{return Xinha._lc(d,"Xinha",c)}}else{h=Xinha._lc_catalog[b][j]}}if(typeof d=="object"&&d.replace){c=d.replace}if(typeof c!="undefined"){for(g in c){h=h.replace("$"+g,c[g])}}return h};Xinha.hasDisplayedChildren=function(c){var b=c.childNodes;for(var a=0;a<b.length;a++){if(b[a].tagName){if(b[a].style.display!="none"){return true}}}return false};Xinha._loadback=function(a,e,d,f){if(document.getElementById(a)){return true}var b=!Xinha.is_ie?"onload":"onreadystatechange";var c=document.createElement("script");c.type="text/javascript";c.src=a;c.id=a;if(e){c[b]=function(){if(Xinha.is_ie&&(!/loaded|complete/.test(window.event.srcElement.readyState))){return}e.call(d?d:this,f);c[b]=null}}document.getElementsByTagName("head")[0].appendChild(c);return false};Xinha.makeEditors=function(d,f,g){if(!Xinha.isSupportedBrowser){return}if(typeof f=="function"){f=f()}var b={};var e;for(var a=0;a<d.length;a++){if(typeof d[a]=="string"){e=Xinha.getElementById("textarea",d[a]);if(!e){d[a]=null;continue}}else{if(typeof d[a]=="object"&&d[a].tagName&&d[a].tagName.toLowerCase()=="textarea"){e=d[a];if(!e.id){e.id="xinha_id_"+a}}}var c=new Xinha(e,Xinha.cloneObject(f));c.registerPlugins(g);b[e.id]=c}return b};Xinha.startEditors=function(a){if(!Xinha.isSupportedBrowser){return}for(var b in a){if(a[b].generate){a[b].generate()}}};Xinha.prototype.registerPlugins=function(b){if(!Xinha.isSupportedBrowser){return}if(b){for(var a=0;a<b.length;a++){this.setLoadingMessage(Xinha._lc("Register plugin $plugin","Xinha",{plugin:b[a]}));this.registerPlugin(b[a])}}};Xinha.base64_encode=function(d){var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var b="";var k,h,g;var l,j,f,e;var a=0;do{k=d.charCodeAt(a++);h=d.charCodeAt(a++);g=d.charCodeAt(a++);l=k>>2;j=((k&3)<<4)|(h>>4);f=((h&15)<<2)|(g>>6);e=g&63;if(isNaN(h)){f=e=64}else{if(isNaN(g)){e=64}}b=b+c.charAt(l)+c.charAt(j)+c.charAt(f)+c.charAt(e)}while(a<d.length);return b};Xinha.base64_decode=function(d){var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var b="";var k,h,g;var l,j,f,e;var a=0;d=d.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{l=c.indexOf(d.charAt(a++));j=c.indexOf(d.charAt(a++));f=c.indexOf(d.charAt(a++));e=c.indexOf(d.charAt(a++));k=(l<<2)|(j>>4);h=((j&15)<<4)|(f>>2);g=((f&3)<<6)|e;b=b+String.fromCharCode(k);if(f!=64){b=b+String.fromCharCode(h)}if(e!=64){b=b+String.fromCharCode(g)}}while(a<d.length);return b};Xinha.removeFromParent=function(b){if(!b.parentNode){return}var a=b.parentNode;return a.removeChild(b)};Xinha.hasParentNode=function(a){if(a.parentNode){if(a.parentNode.nodeType==11){return false}return true}return false};Xinha.viewportSize=function(b){b=(b)?b:window;var a,c;if(b.innerHeight){a=b.innerWidth;c=b.innerHeight}else{if(b.document.documentElement&&b.document.documentElement.clientHeight){a=b.document.documentElement.clientWidth;c=b.document.documentElement.clientHeight}else{if(b.document.body){a=b.document.body.clientWidth;c=b.document.body.clientHeight}}}return{x:a,y:c}};Xinha.pageSize=function(d){d=(d)?d:window;var a,e;var c=d.document.body.scrollHeight;var b=d.document.documentElement.scrollHeight;if(c>b){a=d.document.body.scrollWidth;e=d.document.body.scrollHeight}else{a=d.document.documentElement.scrollWidth;e=d.document.documentElement.scrollHeight}return{x:a,y:e}};Xinha.prototype.scrollPos=function(b){b=(b)?b:window;var a,c;if(typeof b.pageYOffset!="undefined"){a=b.pageXOffset;c=b.pageYOffset}else{if(b.document.documentElement&&typeof document.documentElement.scrollTop!="undefined"){a=b.document.documentElement.scrollLeft;c=b.document.documentElement.scrollTop}else{if(b.document.body){a=b.document.body.scrollLeft;c=b.document.body.scrollTop}}}return{x:a,y:c}};Xinha.getElementTopLeft=function(b){var c=0;var a=0;if(b.offsetParent){c=b.offsetLeft;a=b.offsetTop;while(b=b.offsetParent){c+=b.offsetLeft;a+=b.offsetTop}}return{top:a,left:c}};Xinha.findPosX=function(a){var b=0;if(a.offsetParent){return Xinha.getElementTopLeft(a).left}else{if(a.x){b+=a.x}}return b};Xinha.findPosY=function(b){var a=0;if(b.offsetParent){return Xinha.getElementTopLeft(b).top}else{if(b.y){a+=b.y}}return a};Xinha.createLoadingMessages=function(b){if(Xinha.loadingMessages||!Xinha.isSupportedBrowser){return}Xinha.loadingMessages=[];for(var a=0;a<b.length;a++){if(!document.getElementById(b[a])){continue}Xinha.loadingMessages.push(Xinha.createLoadingMessage(Xinha.getElementById("textarea",b[a])))}};Xinha.createLoadingMessage=function(d,e){if(document.getElementById("loading_"+d.id)||!Xinha.isSupportedBrowser){return}var a=document.createElement("div");a.id="loading_"+d.id;a.className="loading";a.style.left=(Xinha.findPosX(d)+d.offsetWidth/2)-106+"px";a.style.top=(Xinha.findPosY(d)+d.offsetHeight/2)-50+"px";var b=document.createElement("div");b.className="loading_main";b.id="loading_main_"+d.id;b.appendChild(document.createTextNode(Xinha._lc("Loading in progress. Please wait!")));var c=document.createElement("div");c.className="loading_sub";c.id="loading_sub_"+d.id;e=e?e:Xinha._lc("Loading Core");c.appendChild(document.createTextNode(e));a.appendChild(b);a.appendChild(c);document.body.appendChild(a);Xinha.freeLater(a);Xinha.freeLater(b);Xinha.freeLater(c);return c};Xinha.prototype.setLoadingMessage=function(b,a){if(!document.getElementById("loading_sub_"+this._textArea.id)){return}document.getElementById("loading_main_"+this._textArea.id).innerHTML=a?a:Xinha._lc("Loading in progress. Please wait!");document.getElementById("loading_sub_"+this._textArea.id).innerHTML=b};Xinha.setLoadingMessage=function(b){if(!Xinha.loadingMessages){return}for(var a=0;a<Xinha.loadingMessages.length;a++){Xinha.loadingMessages[a].innerHTML=b}};Xinha.prototype.removeLoadingMessage=function(){if(document.getElementById("loading_"+this._textArea.id)){document.body.removeChild(document.getElementById("loading_"+this._textArea.id))}};Xinha.removeLoadingMessages=function(c){for(var b=0;b<c.length;b++){if(!document.getElementById(c[b])){continue}var a=document.getElementById("loading_"+document.getElementById(c[b]).id);a.parentNode.removeChild(a)}Xinha.loadingMessages=null};Xinha.toFree=[];Xinha.freeLater=function(a,b){Xinha.toFree.push({o:a,p:b})};Xinha.free=function(c,d){if(c&&!d){for(var b in c){Xinha.free(c,b)}}else{if(c){if(d.indexOf("src")==-1){try{c[d]=null}catch(a){}}}}};Xinha.collectGarbageForIE=function(){Xinha.flushEvents();for(var a=0;a<Xinha.toFree.length;a++){Xinha.free(Xinha.toFree[a].o,Xinha.toFree[a].p);Xinha.toFree[a].o=null}};Xinha.prototype.insertNodeAtSelection=function(a){Xinha.notImplemented("insertNodeAtSelection")};Xinha.prototype.getParentElement=function(a){Xinha.notImplemented("getParentElement")};Xinha.prototype.activeElement=function(a){Xinha.notImplemented("activeElement")};Xinha.prototype.selectionEmpty=function(a){Xinha.notImplemented("selectionEmpty")};Xinha.prototype.saveSelection=function(){Xinha.notImplemented("saveSelection")};Xinha.prototype.restoreSelection=function(a){Xinha.notImplemented("restoreSelection")};Xinha.prototype.selectNodeContents=function(a,b){Xinha.notImplemented("selectNodeContents")};Xinha.prototype.insertHTML=function(a){Xinha.notImplemented("insertHTML")};Xinha.prototype.getSelectedHTML=function(){Xinha.notImplemented("getSelectedHTML")};Xinha.prototype.getSelection=function(){Xinha.notImplemented("getSelection")};Xinha.prototype.createRange=function(a){Xinha.notImplemented("createRange")};Xinha.prototype.isKeyEvent=function(a){Xinha.notImplemented("isKeyEvent")};Xinha.prototype.isShortCut=function(a){if(a.ctrlKey&&!a.altKey){return true}return false};Xinha.prototype.getKey=function(a){Xinha.notImplemented("getKey")};Xinha.getOuterHTML=function(a){Xinha.notImplemented("getOuterHTML")};Xinha.getXMLHTTPRequestObject=function(){try{if(typeof XMLHttpRequest!="undefined"&&typeof XMLHttpRequest.constructor=="function"){return new XMLHttpRequest()}else{if(typeof ActiveXObject=="function"){return new ActiveXObject("Microsoft.XMLHTTP")}}}catch(a){Xinha.notImplemented("getXMLHTTPRequestObject")}};Xinha.prototype._activeElement=function(a){return this.activeElement(a)};Xinha.prototype._selectionEmpty=function(a){return this.selectionEmpty(a)};Xinha.prototype._getSelection=function(){return this.getSelection()};Xinha.prototype._createRange=function(a){return this.createRange(a)};HTMLArea=Xinha;Xinha.init();if(Xinha.ie_version<8){Xinha.addDom0Event(window,"unload",Xinha.collectGarbageForIE)}Xinha.debugMsg=function(a,b){if(typeof console!="undefined"&&typeof console.log=="function"){if(b&&b=="warn"&&typeof console.warn=="function"){console.warn(a)}else{if(b&&b=="info"&&typeof console.info=="function"){console.info(a)}else{console.log(a)}}}else{if(typeof opera!="undefined"&&typeof opera.postError=="function"){opera.postError(a)}}};Xinha.notImplemented=function(a){throw new Error("Method Not Implemented","Part of Xinha has tried to call the "+a+" method which has not been implemented.")};