
(function($){function trimValForByteLength(safeVal,newVal,byteLimit,fn){var startMatches,endMatches,matchesLen,inpParts,oldVal=safeVal;if($.byteLength(fn?fn(newVal):newVal)<=byteLimit){return{newVal:newVal,trimmed:false};}
startMatches=0;endMatches=0;matchesLen=Math.min(newVal.length,oldVal.length);while(startMatches<matchesLen&&oldVal.charAt(startMatches)===newVal.charAt(startMatches)){startMatches+=1;}
while(endMatches<(matchesLen-startMatches)&&oldVal.charAt(oldVal.length-1-endMatches)===newVal.charAt(newVal.length-1-endMatches)){endMatches+=1;}
inpParts=[newVal.substring(0,startMatches),newVal.substring(startMatches,newVal.length-endMatches),newVal.substring(newVal.length-endMatches)];if(fn){while($.byteLength(fn(inpParts.join('')))>byteLimit&&inpParts[1].length>0){inpParts[1]=inpParts[1].slice(0,-1);}}else{while($.byteLength(inpParts.join(''))>byteLimit){inpParts[1]=inpParts[1].slice(0,-1);}}
newVal=inpParts.join('');return{newVal:newVal,trimmed:true};}
var eventKeys=['keyup.byteLimit','keydown.byteLimit','change.byteLimit','mouseup.byteLimit','cut.byteLimit','paste.byteLimit','focus.byteLimit','blur.byteLimit'].join(' ');$.fn.byteLimit=function(limit,fn){if($.isFunction(limit)){fn=limit;limit=undefined;}else if(!fn||!$.isFunction(fn)){fn=undefined;}
return this.each(function(i,el){var $el,elLimit,prevSafeVal;$el=$(el);elLimit=Number(limit===undefined?$el.attr('maxlength'):limit);if(!elLimit||elLimit<0){return;}
if(fn){$el.data('byteLimit.callback',fn);}
$el.off('.byteLimit');if(fn){$el.removeAttr('maxlength');}else{$el.attr('maxlength',elLimit);}
prevSafeVal='';$el.on(eventKeys,function(){var res=trimValForByteLength(prevSafeVal,this.value,elLimit,fn);if(res.trimmed===true){this.value=res.newVal;}
prevSafeVal=res.newVal;});});};}(jQuery));;(function($){if(document.selection&&document.selection.createRange){$.fn.extend({focus:(function(_focus){return function(){if(arguments.length==0){var $w=$(window);var state={top:$w.scrollTop(),left:$w.scrollLeft()};var result=_focus.apply(this,arguments);window.scrollTo(state.top,state.left);return result;}
return _focus.apply(this,arguments);};})($.fn.focus)});}
$.fn.textSelection=function(command,options){function rangeForElementIE(e){if(e.nodeName.toLowerCase()=='input'){return e.createTextRange();}else{var sel=document.body.createTextRange();sel.moveToElementText(e);return sel;}}
function activateElementOnIE(element){if(element.setActive){element.setActive();}else{$(element).focus();}}
var fn={getContents:function(){return this.val();},getSelection:function(){var e=this.get(0);var retval='';if($(e).is(':hidden')){}else if(document.selection&&document.selection.createRange){activateElementOnIE(e);var range=document.selection.createRange();retval=range.text;}else if(e.selectionStart||e.selectionStart=='0'){retval=e.value.substring(e.selectionStart,e.selectionEnd);}
return retval;},encapsulateSelection:function(options){return this.each(function(){var pre=options.pre,post=options.post;function checkSelectedText(){if(!selText){selText=options.peri;isSample=true;}else if(options.replace){selText=options.peri;}else{while(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);post+=' ';}
while(selText.charAt(0)==' '){selText=selText.substring(1,selText.length);pre=' '+pre;}}}
function doSplitLines(selText,pre,post){var insertText='';var selTextArr=selText.split('\n');for(var i=0;i<selTextArr.length;i++){insertText+=pre+selTextArr[i]+post;if(i!=selTextArr.length-1){insertText+='\n';}}
return insertText;}
var isSample=false;if(this.style.display=='none'){}else if(document.selection&&document.selection.createRange){activateElementOnIE(this);if(context){context.fn.restoreCursorAndScrollTop();}
if(options.selectionStart!==undefined){$(this).textSelection('setSelection',{'start':options.selectionStart,'end':options.selectionEnd});}
var selText=$(this).textSelection('getSelection');var scrollTop=this.scrollTop;var range=document.selection.createRange();checkSelectedText();var insertText=pre+selText+post;if(options.splitlines){insertText=doSplitLines(selText,pre,post);}
if(options.ownline&&range.moveStart){var range2=document.selection.createRange();range2.collapse();range2.moveStart('character',-1);if(range2.text!="\r"&&range2.text!="\n"&&range2.text!=""){insertText="\n"+insertText;pre+="\n";}
var range3=document.selection.createRange();range3.collapse(false);range3.moveEnd('character',1);if(range3.text!="\r"&&range3.text!="\n"&&range3.text!=""){insertText+="\n";post+="\n";}}
range.text=insertText;if(isSample&&options.selectPeri&&range.moveStart){range.moveStart('character',-post.length-selText.length);range.moveEnd('character',-post.length);}
range.select();this.scrollTop=scrollTop;}else if(this.selectionStart||this.selectionStart=='0'){$(this).focus();if(options.selectionStart!==undefined){$(this).textSelection('setSelection',{'start':options.selectionStart,'end':options.selectionEnd});}
var selText=$(this).textSelection('getSelection');var startPos=this.selectionStart;var endPos=this.selectionEnd;var scrollTop=this.scrollTop;checkSelectedText();if(options.selectionStart!==undefined&&endPos-startPos!=options.selectionEnd-options.selectionStart)
{startPos=options.selectionStart;}
var insertText=pre+selText+post;if(options.splitlines){insertText=doSplitLines(selText,pre,post);}
if(options.ownline){if(startPos!=0&&this.value.charAt(startPos-1)!="\n"&&this.value.charAt(startPos-1)!="\r"){insertText="\n"+insertText;pre+="\n";}
if(this.value.charAt(endPos)!="\n"&&this.value.charAt(endPos)!="\r"){insertText+="\n";post+="\n";}}
this.value=this.value.substring(0,startPos)+insertText+
this.value.substring(endPos,this.value.length);this.scrollTop=scrollTop;if(window.opera){pre=pre.replace(/\r?\n/g,"\r\n");selText=selText.replace(/\r?\n/g,"\r\n");post=post.replace(/\r?\n/g,"\r\n");}
if(isSample&&options.selectPeri&&!options.splitlines){this.selectionStart=startPos+pre.length;this.selectionEnd=startPos+pre.length+selText.length;}else{this.selectionStart=startPos+insertText.length;this.selectionEnd=this.selectionStart;}}
$(this).trigger('encapsulateSelection',[options.pre,options.peri,options.post,options.ownline,options.replace,options.spitlines]);});},getCaretPosition:function(options){function getCaret(e){var caretPos=0,endPos=0;if(document.selection&&document.selection.createRange){activateElementOnIE(e);var preFinished=false;var periFinished=false;var postFinished=false;var preText,rawPreText,periText;var rawPeriText,postText,rawPostText;var periRange=document.selection.createRange().duplicate();var preRange=rangeForElementIE(e);preRange.setEndPoint("EndToStart",periRange);var postRange=rangeForElementIE(e);postRange.setEndPoint("StartToEnd",periRange);preText=rawPreText=preRange.text;periText=rawPeriText=periRange.text;postText=rawPostText=postRange.text;do{if(!preFinished){if(preRange.compareEndPoints("StartToEnd",preRange)==0){preFinished=true;}else{preRange.moveEnd("character",-1);if(preRange.text==preText){rawPreText+="\r\n";}else{preFinished=true;}}}
if(!periFinished){if(periRange.compareEndPoints("StartToEnd",periRange)==0){periFinished=true;}else{periRange.moveEnd("character",-1);if(periRange.text==periText){rawPeriText+="\r\n";}else{periFinished=true;}}}
if(!postFinished){if(postRange.compareEndPoints("StartToEnd",postRange)==0){postFinished=true;}else{postRange.moveEnd("character",-1);if(postRange.text==postText){rawPostText+="\r\n";}else{postFinished=true;}}}}while((!preFinished||!periFinished||!postFinished));caretPos=rawPreText.replace(/\r\n/g,"\n").length;endPos=caretPos+rawPeriText.replace(/\r\n/g,"\n").length;}else if(e.selectionStart||e.selectionStart=='0'){caretPos=e.selectionStart;endPos=e.selectionEnd;}
return options.startAndEnd?[caretPos,endPos]:caretPos;}
return getCaret(this.get(0));},setSelection:function(options){return this.each(function(){if($(this).is(':hidden')){}else if(this.selectionStart||this.selectionStart=='0'){if(options.start>this.selectionEnd){this.selectionEnd=options.end;this.selectionStart=options.start;}else{this.selectionStart=options.start;this.selectionEnd=options.end;}}else if(document.body.createTextRange){var selection=rangeForElementIE(this);var length=this.value.length;var newLines=this.value.match(/\n/g);if(newLines)length=length-newLines.length;selection.moveStart('character',options.start);selection.moveEnd('character',-length+options.end);try{selection.select();}catch(e){}}});},scrollToCaretPosition:function(options){function getLineLength(e){return Math.floor(e.scrollWidth/($.client.profile().platform=='linux'?7:8));}
function getCaretScrollPosition(e){var text=e.value.replace(/\r/g,"");var caret=$(e).textSelection('getCaretPosition');var lineLength=getLineLength(e);var row=0;var charInLine=0;var lastSpaceInLine=0;for(i=0;i<caret;i++){charInLine++;if(text.charAt(i)==" "){lastSpaceInLine=charInLine;}else if(text.charAt(i)=="\n"){lastSpaceInLine=0;charInLine=0;row++;}
if(charInLine>lineLength){if(lastSpaceInLine>0){charInLine=charInLine-lastSpaceInLine;lastSpaceInLine=0;row++;}}}
var nextSpace=0;for(j=caret;j<caret+lineLength;j++){if(text.charAt(j)==" "||text.charAt(j)=="\n"||caret==text.length){nextSpace=j;break;}}
if(nextSpace>lineLength&&caret<=lineLength){charInLine=caret-lastSpaceInLine;row++;}
return($.client.profile().platform=='mac'?13:($.client.profile().platform=='linux'?15:16))*row;}
return this.each(function(){if($(this).is(':hidden')){}else if(this.selectionStart||this.selectionStart=='0'){var scroll=getCaretScrollPosition(this);if(options.force||scroll<$(this).scrollTop()||scroll>$(this).scrollTop()+$(this).height())
$(this).scrollTop(scroll);}else if(document.selection&&document.selection.createRange){var range=document.body.createTextRange();var savedRange=document.selection.createRange();var pos=$(this).textSelection('getCaretPosition');var oldScrollTop=this.scrollTop;range.moveToElementText(this);range.collapse();range.move('character',pos+1);range.select();if(this.scrollTop!=oldScrollTop)
this.scrollTop+=range.offsetTop;else if(options.force){range.move('character',-1);range.select();}
savedRange.select();}
$(this).trigger('scrollToPosition');});}};switch(command){case'encapsulateSelection':options=$.extend({'pre':'','peri':'','post':'','ownline':false,'replace':false,'selectPeri':true,'splitlines':false,'selectionStart':undefined,'selectionEnd':undefined},options);break;case'getCaretPosition':options=$.extend({'startAndEnd':false},options);break;case'setSelection':options=$.extend({'start':undefined,'end':undefined,'startContainer':undefined,'endContainer':undefined},options);if(options.end===undefined)
options.end=options.start;if(options.endContainer==undefined)
options.endContainer=options.startContainer;break;case'scrollToCaretPosition':options=$.extend({'force':false},options);break;}
var context=$(this).data('wikiEditor-context');var hasIframe=typeof context!=='undefined'&&context&&typeof context.$iframe!=='undefined';var needSave=false;if(hasIframe&&context.savedSelection!==null){context.fn.restoreSelection();needSave=true;}
var retval=(hasIframe?context.fn:fn)[command].call(this,options);if(hasIframe&&needSave){context.fn.saveSelection();}
return retval;};})(jQuery);;(function($,mw){var isReady,toolbar,currentFocused;isReady=false;var standardButtons={};if(mw.config.get('wgIsEditPage')){$.each('bold italic link extlink headline image media math nowiki sig hr wmu wpg vet'.split(' '),function(i,v){var k=v=='sig'?'signature':v;standardButtons['mw-editbutton-'+k]='button-'+v;});}
toolbar={$toolbar:false,buttons:[],addButton:function(){if(isReady){toolbar.insertButton.apply(toolbar,arguments);}else{toolbar.buttons.push([].slice.call(arguments));}},insertButton:function(imageFile,speedTip,tagOpen,tagClose,sampleText,imageId,selectText,onClick){if(toolbar.$toolbar.length===0){return false;}
if(imageId&&standardButtons[imageId]){imageFile=mw.config.get('wgBlankImgUrl');}
var image=$('<img>',{width:23,height:22,src:imageFile,alt:speedTip,title:speedTip,id:imageId||'','class':'mw-toolbar-editbutton'}).click(function(){mw.toolbar.insertTags(tagOpen,tagClose,sampleText,selectText);return false;});var userLanguage=mw.config.get('wgUserLanguage');if(imageId&&standardButtons[imageId]){image.addClass(standardButtons[imageId]);image.addClass(userLanguage+'-'+standardButtons[imageId]);}
if(typeof onClick==='function'){image.on('click',onClick);}
toolbar.$toolbar.append(image);return true;},insertTags:function(tagOpen,tagClose,sampleText,selectText){if(currentFocused&&currentFocused.length){currentFocused.textSelection('encapsulateSelection',{'pre':tagOpen,'peri':sampleText,'post':tagClose});var wikiaEditor=currentFocused.data('wikiaEditor');if(wikiaEditor){wikiaEditor.fire('editorInsertTags');}}},init:function(){}};window.addButton=toolbar.addButton;window.insertTags=toolbar.insertTags;mw.toolbar=toolbar;$(document).ready(function(){var buttons,i,c,iframe;currentFocused=$('#wpTextbox1');toolbar.$toolbar=$('#toolbar');if(typeof window.WikiaEditor=='undefined'){buttons=[].concat(toolbar.buttons,window.mwCustomEditButtons);for(i=0;i<buttons.length;i++){if($.isArray(buttons[i])){toolbar.insertButton.apply(toolbar,buttons[i]);}else{c=buttons[i];toolbar.insertButton(c.imageFile,c.speedTip,c.tagOpen,c.tagClose,c.sampleText,c.imageId,c.selectText,c.onclick);}}}
isReady=true;$('#wpSummary').byteLimit(250);(function scrollEditBox(){var editBox,scrollTop,$editForm;editBox=document.getElementById('wpTextbox1');scrollTop=document.getElementById('wpScrolltop');$editForm=$('#editform');if($editForm.length&&editBox&&scrollTop){if(scrollTop.value){editBox.scrollTop=scrollTop.value;}
$editForm.submit(function(){scrollTop.value=editBox.scrollTop;});}}());$('body').on('focus','textarea, input:text',function(){currentFocused=$(this);});iframe=$('.wikiEditor-ui-text iframe');if(iframe.length>0){$(iframe.get(0).contentWindow.document).add(iframe.get(0).contentWindow.document.body).focus(function(){currentFocused=iframe;});}});}(jQuery,mediaWiki));;(function(window,$){var WE=window.WikiaEditor=window.WikiaEditor||(new Observable()),slice=[].slice;WE.config={};WE.plugins={};WE.modules={};WE.instances={};WE.instanceId='';WE.instanceCount=0;WE.debounce=false;WE.load=(function(){var components={VideoEmbedTool:{loaded:false,requires:[wgResourceBasePath+'/extensions/wikia/VideoEmbedTool/js/VET_WikiaEditor.js']},WikiaMiniUpload:{loaded:false,requires:[$.loadYUI,$.loadJQueryAIM,$.getSassCommonURL('extensions/wikia/WikiaMiniUpload/css/WMU.scss'),wgResourceBasePath+'/extensions/wikia/WikiaMiniUpload/js/WMU.js']}};return function(name){var component=components[name],deferred=new $.Deferred();if(component){if(component.loaded){deferred.resolve();}else{component.loaded=true;deferred=$.when($.getResources(component.requires));}}else{deferred.reject({error:'WikiaEditor.load: invalid component name "'+name+'"'});}
return deferred.promise();}})();WE.setInstanceId=function(instanceId,event,forceEvents){var editor;if(typeof event=='boolean'){forceEvents=event;event=undefined;}
if(instanceId==WE.instanceId){if(!forceEvents){$().log('instance "'+WE.instanceId+'" already active','WikiaEditor');return;}}else{if((editor=WE.instances[WE.instanceId])){editor.fire('editorDeactivated',event);$().log('instance "'+WE.instanceId+'" deactivated','WikiaEditor');}
WE.instanceId=instanceId;}
if((editor=WE.instances[instanceId])){editor.fire('editorActivated',event);$().log('instance "'+WE.instanceId+'" activated','WikiaEditor');}};WE.getInstance=function(instanceId){return WE.instances[instanceId||WE.instanceId];};WE.formatToMode=function(format){return format=='richtext'?'wysiwyg':'source';};WE.modeToFormat=function(mode){return mode=='wysiwyg'?'richtext':'wikitext';};WE.create=function(plugins,config,event){var instance=new WE.Editor(plugins,config),instanceId=config.body.attr('id');if(!instanceId){instanceId='WikiaEditor-'+WE.instanceCount;config.body.attr('id',instanceId);}
instance.event=event;instance.instanceId=instanceId;WE.instances[instanceId]=instance;WE.setInstanceId(instanceId,event);WE.instanceCount++;config.body.data('wikiaEditor',instance);instance.fire('instanceCreated',event);instance.show();return instance;};WE.functions=[];WE.addFunction=function(callback,scope){var id=WE.functions.length;WE.functions.push({fn:callback,scope:scope||window});return id;};WE.callFunction=function(id){if(WE.debounce)return;setTimeout(function(){WE.debounce=false;},500);WE.debounce=true;var args=Array.prototype.slice.call(arguments,1);var conf=WE.functions[id];return conf.fn.apply(conf.scope,args);};WE.initAddons=(function(){var done=false;return function(){if(!done){window.GlobalTriggers.fire('wikiaeditoraddons',WE);}
done=true;};})();WE.reloadEditor=function(){var editorInstance=WE.getInstance(),editorForm=editorInstance.ui.getForm();editorForm.find('input[name=wpEditToken]').val('');editorInstance.setState(editorInstance.states.RELOADING);this.storeContent();window.location.reload(true);};WE.storeContent=function(){window.WikiaEditorStorage.store();}
WE.Editor=$.createClass(Observable,{states:{IDLE:1,INITIALIZING:2,SAVING:3,LOADING_SOURCE:4,LOADING_VISUAL:5,RELOADING:6},ready:false,editorElement:false,constructor:function(plugins,config){WE.initAddons();WE.Editor.superclass.constructor.call(this);WE.fire('newInstance',plugins,config);this.pluginConfigs=plugins;this.config=$.extend(true,{},WE.config,config);this.initialized=false;this.state=false;this.mode=false;},getFormat:function(){return WE.modeToFormat(this.mode);},initPlugins:function(){var order=[];var loaded={};function queuePlugin(name){if(loaded[name]){return;}
var plugin=WE.plugins[name];loaded[name]=true;if(!plugin){this.warn('Plugin not found: '+name);return;}
var requires=plugin.requires||plugin.prototype.requires;if($.isArray(requires)){for(var i=0;i<requires.length;i++){queuePlugin.call(this,requires[i]);}}
order.push(name);}
for(var i=0;i<this.pluginConfigs.length;i++){queuePlugin.call(this,this.pluginConfigs[i]);}
this.plugins={};for(var i=0;i<order.length;i++){var cls=WE.plugins[order[i]];if(typeof cls=='function'){this.plugins[order[i]]=new cls(this);}}},initPlugin:function(name){if(!this.plugins[name]){var cls=WE.plugins[name];if(typeof cls=='function'){this.plugins[name]=new cls(this);}}
return this.plugins[name];},markAsReady:function(){if(!this.ready){this.ready=true;this.setState(this.states.IDLE);this.fire('editorReady',this.event);GlobalTriggers.fire('WikiaEditorReady',this);$().log('Editor is ready!','WikiaEditor');WE.track({action:Wikia.Tracker.ACTIONS.IMPRESSION,label:'edit-page-ready',value:Math.round(new Date()-window.wgNow)});if(!this.config.isMiniEditor&&window.veTrack){veTrack({action:'ck-edit-page-stop'});}}},setState:function(state){if(this.state==state)return;this.state=state;this.fire('state',this,state);},setMode:function(mode,forceEvents){if(this.mode==mode&&!forceEvents)return;this.element.removeClass('mode-'+this.mode);this.mode=mode;this.element.addClass('mode-'+mode);this.fire('mode',this,mode);},setAsActiveInstance:function(event,forceEvents){if(typeof event=='boolean'){forceEvents=event;event=undefined;}
WE.setInstanceId(this.instanceId,event,forceEvents);},show:function(){if(!this.initialized){this.initPlugins();this.element=this.config.element;this.config.mode=this.config.mode||'source';this.setMode(this.config.mode);this.setState(this.states.INITIALIZING);this.fire('initConfig',this);this.fire('beforeInit',this);this.fire('init',this);this.fire('initEditor',this);this.fire('initDom',this);this.initialized=true;this.fire('afterShow',this,this.editorElement);}},_log:function(type,args){if(window.console){if(typeof window.console[type]=='function'&&typeof window.console[type].apply=='function'){window.console[type].apply(window.console,args);}else if(typeof window.console[type]=='object'){var x=[];for(var i=0;i<args.length;i++)x.push("args["+i+"]");eval("window.console."+type+"("+x.join(',')+");");}}else if(window.opera){window.opera.postError.apply(window.opera,args);}},log:function(){this._log('log',Array.prototype.slice.call(arguments,0));},warn:function(){this._log('warn',Array.prototype.slice.call(arguments,0));},error:function(){this._log('error',Array.prototype.slice.call(arguments,0));throw arguments[0];}});WE.plugin=$.createClass(Observable,{constructor:function(editor){WE.plugin.superclass.constructor.call(this);var methodName,autobindMethods=['initConfig','beforeInit','init','initEditor','initDom','afterShow'],i=0,l=autobindMethods.length;this.editor=editor;for(;methodName=autobindMethods[i],i<l;i++){if(typeof this[methodName]=='function'){this.editor.on(methodName,this[methodName],this);}}},proxy:function(fn){return $.proxy(fn,this);}});WE.plugins.messages=$.createClass(WE.plugin,{MESSAGE_NAMESPACE:'wikia-editor-',beforeInit:function(){this.editor.msg=this.proxy(this.msg);},msg:function(msg){var args=Array.prototype.slice.call(arguments,0);args[0]=this.MESSAGE_NAMESPACE+args[0];return $.msg.apply($,args);}});WE.plugins.ui=$.createClass(WE.plugin,{priority:0,ready:true,initDomCalled:false,uiReadyFired:false,initConfig:function(){this.items={};this.handlers={};this.providers=[this];},beforeInit:function(){this.editor.ui=this;var self=this;$('body').click(function(ev){self.fire('bodyClick',ev,this);});},init:function(){var chk=function(){if(!this.initDomCalled)return;if(this.uiReadyFired)return;for(var i=0;i<this.providers.length;i++){if(!this.providers[i].ready)return;}
this.uiReadyFired=true;this.addDefaults();this.editor.fire('uiReady',this);}
var chkInitDom=function(){this.initDomCalled=true;chk.apply(this);}
this.editor.on({uiExternalProviderReady:chk,initDom:chkInitDom,scope:this});},buildClickHandler:function(config){var editor=this.editor;if(config.forceLogin&&wgUserName==null&&typeof UserLogin!='undefined'){config.click=function(){WE.track('force-login-'+config.ckcommand);UserLogin.rteForceLogin();}}else if(!config.click){config.click=function(){var mode=editor.mode;if(typeof config['click'+mode]=='function'){return config['click'+mode].apply(this,arguments);}else{editor.warn('Mode "'+mode+'" not supported for button: '+config.name);}};this.editor.fire('uiBuildClickHandler',this.editor,config);}},addDefaults:function(){var elements={},config=this.editor.config;if(config.uiElements){$.extend(elements,config.uiElements);}
this.editor.fire('uiFetchDefaults',this.editor,elements);for(var name in elements){if(typeof elements[name].precondition!='function'||elements[name].precondition()){this.addElement(name,elements[name]);}}},addExternalProvider:function(externalProvider){this.providers=this.providers||[];for(var i=0;i<this.providers.length;i++){if(this.providers[i].priority>=externalProvider.priority){this.providers.splice(i,0,externalProvider);return;}}
if(i>=this.providers.length){this.providers.push(externalProvider)}
this.editor.fire('uiAddExternalProvider',this.editor,externalProvider);},addHandler:function(type,handler){this.handlers[type]=handler;this.editor.fire('uiAddHandler',this.editor,type,handler);},getHandler:function(type){return this.handlers[type];},addElement:function(name,def){def.name=name;this.buildClickHandler(def);this.items[name]=def;this.editor.fire('uiAddElement',this.editor,name,def);},getElement:function(name){return this.items[name];},getForm:function(){return this.editor.element.parent('form');},createElement:function(name){var element=this.getElement(name);if(!element)return false;var handler=this.getHandler(element.type);if(!handler)return false;var data={};var html=handler.render(element,data);this.editor.fire('uiStandardElementCreated',this.editor,element,data);return html;},create:function(name){for(var i=0;i<this.providers.length;i++){var html=this.providers[i].createElement(name);if(html){return html;}}
this.editor.warn('UI Element not found: '+name);return'';}});WE.plugins.uiautoregister=$.createClass(WE.plugin,{requires:['ui','functions'],init:function(){if(WE.ui){for(var i in WE.ui){if(i!='base'){this.editor.ui.addHandler(i,this);}}}},render:function(config,data){var type=config.type;if(!WE.ui[type])return'';var e=new WE.ui[type](this.editor,config,data);return e.render();}});WE.plugins.spaces=$.createClass(WE.plugin,{SPACE_TYPE_ATTRIBUTE:'data-space-type',EDITOR_SPACE:'editor',element:false,spaces:false,beforeInit:function(){this.element=this.editor.config.element;this.editor.getSpace=this.proxy(this.getSpace);this.editor.getEditorSpace=this.proxy(this.getEditorSpace);this.editor.getSpaces=this.proxy(this.getSpaces);this.spaces={};var spaces=this.element.find('['+this.SPACE_TYPE_ATTRIBUTE+']');for(var i=0;i<spaces.length;i++){var space=$(spaces.get(i));this.spaces[space.attr(this.SPACE_TYPE_ATTRIBUTE)]=space;}
if(this.editor.config.spaces){this.spaces=$.extend(this.spaces,this.editor.config.spaces);}},init:function(){this.editorElement=this.getEditorSpace();},getSpace:function(name){return this.spaces[name]||false;},getSpaces:function(){return this.spaces;},getEditorSpace:function(){return this.getSpace(this.EDITOR_SPACE);}});WE.plugins.modules=$.createClass(WE.plugin,{locals:false,globals:false,beforeInit:function(){this.locals={};this.globals=WE.modules;this.editor.modules=this;},add:function(name,module){this.local[name]=module;},get:function(name){if(this.locals[name])
return this.locals[name];if(this.globals[name])
return this.globals[name];return false;},create:function(config){if(typeof config=='string'){config={type:config};}
var module=this.get(config.type);if(module)
module=new module(this.editor,config);if(!module){this.editor.warn('Module not found: '+config.type);}
return module;}});WE.plugins.toolbarspaces=$.createClass(WE.plugin,{requires:['ui','spaces','modules'],AUTO_SHOW_ATTRIBUTE:'data-space-autoshow',beforeInit:function(){this.editor.on('uiReady',this.proxy(this.renderToolbars));this.toolbars={};},renderToolbars:function(){var spaces=this.editor.getSpaces();var toolbars=this.toolbars={};for(var spaceName in spaces){if(typeof this.editor.config.toolbars[spaceName]!='undefined'){toolbars[spaceName]={name:spaceName,el:spaces[spaceName],config:this.editor.config.toolbars[spaceName]};}}
var types=this.editor.config.toolbarTypes||{};for(var name in toolbars){var config=toolbars[name].config;if($.isArray(config))config={items:config};config.type=config.type||types[name]||'container';config.element=toolbars[name].el;toolbars[name].module=this.editor.modules.create(config);}
for(var name in toolbars){if(toolbars[name].module){toolbars[name].dom=toolbars[name].module.render();toolbars[name].module.afterAttach();}}
for(var name in toolbars){if(toolbars[name].dom&&toolbars[name].el.attr(this.AUTO_SHOW_ATTRIBUTE)=='true'){toolbars[name].el.show();}}
this.editor.fire('toolbarsRendered',this.editor);this.editor.fire('toolbarsResized',this.editor);}});WE.plugins.functions=$.createClass(WE.plugin,{ids:false,beforeInit:function(){this.ids={};this.editor.addFunction=this.proxy(this.add);this.editor.callFunction=this.proxy(this.call);this.editor.on('destroy',this.proxy(this.clear));},add:function(callback,scope){var id=WE.addFunction(callback,scope);this.ids[id]=true;return id;},call:function(id){return WE.callFunction.apply(WE,arguments);},clear:function(){for(var id in this.ids){WE.functions[id]=false;}}});WE.plugins.core=$.createClass(WE.plugin,{requires:['functions','messages','ui','uiautoregister','spaces','toolbarspaces','collapsiblemodules','tracker']});WE.plugins.mweditor=$.createClass(WE.plugin,{requires:['ui'],proxyMethods:['getContent','setContent','getEditbox','getEditboxWrapper','getEditorElement','editorFocus','editorBlur'],initConfig:function(){this.editor.config.mode='source';},beforeInit:function(){var i=0,l=this.proxyMethods.length;for(;methodName=this.proxyMethods[i],i<l;i++){this.editor[methodName]=this.proxy(this[methodName]);}},initEditor:function(){this.textarea=this.editor.config.body;if(!this.textarea.is('textarea')){this.textarea=$('<textarea>').addClass('body').attr('id','mw_'+this.editor.instanceId).val($.trim(this.textarea.text())).insertAfter(this.textarea.hide());}
this.textarea.focus(this.proxy(this.editorFocused)).blur(this.proxy(this.editorBlurred)).click(this.proxy(this.editorClicked)).keyup(this.proxy(this.editorKeyUp));this.editor.markAsReady();},initDom:function(){this.editor.fire('editboxReady',this.editor,this.getEditbox());},getContent:function(){return this.textarea.val();},getEditbox:function(){return this.textarea;},getEditboxWrapper:function(){return this.editor.element;},getEditorElement:function(){return this.editor.config.body;},editorFocus:function(){this.textarea.focus();},editorBlur:function(){this.textarea.blur();},setContent:function(content,datamode){var editbox=this.getEditbox();if(datamode=='wysiwyg'){this.html2wiki({html:content,title:wgPageName},function(data){editbox.val(data.wikitext);});}else{editbox.val(content);}},html2wiki:function(params,callback){if(typeof params!='object'){params={};}
params.method='html2wiki';jQuery.post(window.wgScript+'?action=ajax&rs=RTEAjax',params,function(data){if(typeof callback=='function'){callback(data);}},'json');},editorFocused:function(){this.getEditbox().addClass('focused');this.editor.fire('editorFocus',this.editor);},editorBlurred:function(){this.getEditbox().removeClass('focused');this.editor.fire('editorBlur',this.editor);},editorClicked:function(){this.editor.fire('editorClick',this.editor);},editorKeyUp:function(){this.editor.fire('editorKeyUp',this.editor);}});WE.plugins.ckeditor=$.createClass(WE.plugin,{requires:['ui'],proxyEvents:['blur','focus','instanceReady','keyUp','mode','modeSwitch','modeSwitchCancelled','sourceModeReady','themeLoaded','wysiwygModeReady'],proxyMethods:['getContent','setContent','getEditbox','getEditboxWrapper','getEditorElement','editorFocus','editorBlur'],beforeInit:function(){var i=0,l=this.proxyMethods.length;for(;methodName=this.proxyMethods[i],i<l;i++){this.editor[methodName]=this.proxy(this[methodName]);}},initEditor:function(){this.editor.on('ck-mode',this.proxy(this.modeChanged));this.editor.on('ck-modeSwitch',this.proxy(this.beforeModeChange));this.editor.on('ck-modeSwitchCancelled',this.proxy(this.modeChangeCancelled));this.editor.on('ck-themeLoaded',this.proxy(this.themeLoaded));this.editor.on('ck-focus',this.proxy(this.editorFocused));this.editor.on('ck-blur',this.proxy(this.editorBlurred));this.editor.on('ck-keyUp',this.proxy(this.editorKeyUp));this.editor.on('ckInstanceCreated',this.proxy(this.ckInstanceCreated));this.editor.on('afterLoadingStatus',this.proxy(this.afterLoadingStatus));RTE.init(this.editor);},afterLoadingStatus:function(){this.editor.markAsReady();$(this.editor.ck.container.$).addClass('visible').unbind('keydown.preventTyping');},ckInstanceCreated:function(ck){this.editor.ck=ck;for(var i=0,l=this.proxyEvents.length;i<l;i++){(function(eventName){this.editor.ck.on(eventName,function(){this.editor.fire.apply(this.editor,['ck-'+eventName,this.editor].concat(slice.call(arguments)));},this);}).call(this,this.proxyEvents[i]);}},getContent:function(){return this.editor.ck.getData();},getEditbox:function(){return $(this.editor.ck.mode=='wysiwyg'?this.editor.ck.document.getBody().$:this.editor.ck.textarea.$);},getEditboxWrapper:function(){return $(this.editor.ck.getThemeSpace('contents').$);},getEditorElement:function(){return $(this.editor.ck.element.$);},beforeModeChange:function(){$(this.editor.ck.container.$).removeClass('visible').bind('keydown.preventTyping',function(e){e.preventDefault();});this.editor.setState(this.editor.ck.mode=='wysiwyg'?this.editor.states.LOADING_SOURCE:this.editor.states.LOADING_VISUAL);},modeChanged:function(){this.editor.setMode(this.editor.ck.mode);this.editor.setState(this.editor.states.IDLE);this.getEditbox().click(this.proxy(this.editorClicked)).addClass('focused');},modeChangeCancelled:function(){this.editor.setState(this.editor.states.IDLE);},themeLoaded:function(){this.editor.fire('editboxReady',this.editor,$(this.editor.ck.getThemeSpace('contents').$));},editorFocus:function(){this.editor.ck.focus();},editorBlur:function(){this.editor.ck.blur();},setContent:function(content,datamode){var ckeditor=this.editor.ck;if(datamode&&ckeditor.mode!=datamode){var params={title:wgPageName};var isWysiwyg=ckeditor.mode=='wysiwyg';params[isWysiwyg?'wikitext':'html']=content;RTE.ajax(isWysiwyg?'wiki2html':'html2wiki',params,function(data){ckeditor.setData(data[isWysiwyg?'html':'wikitext']);});}else{ckeditor.setData(content);}},editorFocused:function(){this.getEditbox().addClass('focused');this.editor.fire('editorFocus',this.editor);},editorBlurred:function(){this.getEditbox().removeClass('focused');this.editor.fire('editorBlur',this.editor);},editorClicked:function(){this.editor.fire('editorClick',this.editor);},editorKeyUp:function(){this.editor.fire('editorKeyUp',this.editor);}});WE.plugins['ui-ckeditor']=$.createClass(WE.plugin,{requires:['ui','ckeditor'],priority:-1,ready:false,modeAwareCommands:{},stateProxiedCommands:{},beforeInit:function(){this.editor.ui.addExternalProvider(this);this.editor.on('ck-themeLoaded',this.ckReady,this);this.editor.on('uiBuildClickHandler',this.buildWysiwygClickHandler,this);this.editor.on('uiStandardElementCreated',this.elementCreated,this);this.editor.on('mode',this.modeChanged,this);},modeChanged:function(editor,mode){for(var name in this.modeAwareCommands){var command=this.editor.ck.getCommand(name);if(command&&command.modes){for(var i=0;i<command.uiItems.length;i++){var button=command.uiItems[i],ignores=['ModeWysiwyg','ModeSource'];if($.inArray(button.command,ignores)<0){if(button._.id){$('#'+button._.id).parent()[command.modes[mode]?'removeClass':'addClass']('cke_hidden');}}}}}
this.proxyAllCommandsState();},proxyAllCommandsState:function(){for(var commandName in this.stateProxiedCommands)
this.proxyCommandState(commandName);},proxyCommandState:function(commandName){var command=this.editor.ck.getCommand(commandName),state=command&&command.state,elements=this.stateProxiedCommands[commandName];if(!command)return;for(var i=0;i<elements.length;i++){var id=elements[i],el=$('#'+id);if(el){el=el.parent();el.removeClass('cke_on cke_off cke_disabled');if(this.editor.ck.mode=='wysiwyg'){el.addClass('cke_'+(state==CKEDITOR.TRISTATE_ON?'on':state==CKEDITOR.TRISTATE_DISABLED?'disabled':'off'));}else{el.addClass('cke_off');}}}},elementCreated:function(editor,element,data){if(element.ckcommand){var commandName=element.ckcommand;if(!this.stateProxiedCommands[commandName]){var command=this.editor.ck.getCommand(commandName);if(command){command.on('state',$.proxy(function(){this.proxyCommandState(commandName);},this));}
this.stateProxiedCommands[commandName]=[];}
this.stateProxiedCommands[commandName].push(data.id);}},ckReady:function(){this.ready=true;this.editor.fire('uiExternalProviderReady',this.editor);},buildWysiwygClickHandler:function(editor,button){button.clickwysiwyg=function(){this.editor.ck.execCommand(button.ckcommand,button.clickdatawysiwyg);};},createElement:function(name){var ck=this.editor.ck,ui=this.editor.ck.ui,item;if(ui._.items[name]&&(item=ui.create(name))){var output=[];item.render(ck,output);if(item.command){this.modeAwareCommands[item.command]=true;}
return output.join('');}
return false;}});WE.plugins.mweditorsuite=$.createClass(WE.plugin,{requires:['core','mweditor']});WE.plugins.ckeditorsuite=$.createClass(WE.plugin,{requires:['core','ckeditor','ui-ckeditor']});GlobalTriggers.fire('wikiaeditor',WE);})(this,jQuery);;var WikiaEditorStorage=function(){};WikiaEditorStorage.prototype={categories:undefined,summary:undefined,content:undefined,editorMode:undefined,articleId:undefined,editorDirty:false,store:function(){if(typeof wgArticleId!=='undefined'){var editorInstance=window.WikiaEditor.getInstance();if(typeof editorInstance.plugins.leaveconfirm==='undefined'||editorInstance.plugins.leaveconfirm.isDirty()){var summary=$('#wpSummary');var categorySelect=$('#CategorySelect').data('categorySelect');var toStore={articleId:wgArticleId,content:editorInstance.getContent(),editorMode:editorInstance.mode,summary:summary.exists()?summary.val():undefined,categories:typeof categorySelect!=='undefined'?categorySelect.getData():undefined};try{$.storage.set(this.getStoreContentKey(),toStore);}catch(e){$().log('Local Storage Exception:'+e.message);$.storage.flush();}}}},init:function(){this.fetchData();GlobalTriggers.bind('WikiaEditorReady',$.proxy(function(editor){if(this.getEditorDirty()){editor.fire('markDirty');this.modifySummary();this.modifyEditorContent(editor);this.modifyCategories($('#CategorySelect').data('categorySelect'));}},this));},fetchData:function(){var storageKey=this.getStoreContentKey();var storageData=$.storage.get(storageKey);if(storageData!=null&&storageData.articleId==wgArticleId){this.editorDirty=true;this.summary=storageData.summary;this.articleId=storageData.articleId;this.content=storageData.content;this.editorMode=storageData.editorMode;this.categories=storageData.categories;}
$.storage.del(storageKey);},modifyEditorContent:function(editor){var content=this.getContent();var editorMode=this.getEditorMode();if(typeof content!=='undefined'&&typeof editorMode!=='undefined'){editor.setContent(content,editorMode);}},modifySummary:function(){var summary=this.getSummary();if(typeof summary!=='undefined'){$('#wpSummary').val(summary);}},modifyCategories:function(categorySelect){var categories=this.getCategories();if(typeof categories!=='undefined'){var actualCategories=categorySelect.getCategories();var promises=[];for(var i=0;i<actualCategories.length;i++){promises.push(categorySelect.removeCategory(actualCategories[i]));}
$.when.apply(null,promises).done(function(){for(var i=0;i<categories.length;i++){categorySelect.addCategory(categories[i]);}});}},getContent:function(){return this.content;},getSummary:function(){return this.summary;},getEditorMode:function(){return this.editorMode;},getCategories:function(){return this.categories;},getEditorDirty:function(){return this.editorDirty;},getStoreContentKey:function(){return'WikiaEditorData';}};var WikiaEditorStorage=new WikiaEditorStorage();window.WikiaEditorStorage=WikiaEditorStorage;WikiaEditorStorage.init();;(function(window,$){var WE=window.WikiaEditor=window.WikiaEditor||(new Observable());WE.ui=WE.ui||{};WE.ui.base=$.createClass(Observable,{constructor:function(editor,config,data){WE.ui.base.superclass.constructor.call(this);this.editor=editor;this.config=config;if(typeof config=='object'){for(var k in config){this[k]=config[k];}}
this.data=data||{};this.data.button=this;this.init();},init:function(){},beforeRender:function(){},renderHtml:function(){return'';},render:function(){if(!this.config)
return'';this.beforeRender();return this.renderHtml();},proxy:function(fn){return $.proxy(fn,this);}});WE.ui.button=$.createClass(WE.ui.base,{statics:{nextId:1},clickButtonHandler:function(){var mode=this.editor.mode;if(typeof this['click'+mode]=='function'){return this['click'+mode].apply(this,arguments);}else{this.editor.warn('Mode "'+mode+'" not supported for button: '+this.name);}},buildClickHandler:function(){this.click=this.clickButtonHandler;this.editor.fire('uiBuildClickHandler',this.editor,this);},beforeRender:function(){this.label||(this.label=$.msg(this.labelId));if(typeof this.label!='undefined'){if(this.label.match(/<.*>/)){this.label=$.msg(this.label.replace('<','').replace('>',''));}}
this.label=this.label||'';this.title||(this.titleId&&(this.title=$.msg(this.titleId)))||(this.title=this.label);this.title=this.title||'';this.id='uielem_'+WE.ui.button.nextId++;this.buttonClass='cke_'+this.type;this.classes=(this.className||'');this.labelClass=this.labelClass||'cke_label';this.arrowClass=this.arrowClass||'cke_openbutton';this.click=this.click||this.buildClickHandler();this.clickFn=this.clickFn||this.editor.addFunction(this.proxy(this.click));},renderHtml:function(){var html='<span class="'+this.buttonClass+' '+this.classes+'">'
+'<a id="'+this.id+'" class="cke_off '+this.classes+'"'
+' title="'+this.title+'"'
+' tabindex="-1"'
+' hidefocus="true"'
+' role="button"'
+' aria-labelledby="'+this.id+'_label"'
+' onmousedown="WikiaEditor.callFunction('+this.clickFn+', this); return false;">';if(this.hasIcon!==false){html+='<span class="cke_icon">&nbsp;</span>';}
if(this.hasLabel!==false){html+='<span id="'+this.id+'_label" class="'+this.labelClass+'">'+this.label+'</span>';}
if(this.hasArrow){html+='<span class="'+this.arrowClass+'">&nbsp;</span>';}
html+='</a>'+'</span>';this.data.id=this.id;return html;}});WE.ui.panelbutton=$.createClass(WE.ui.button,{getEl:function(){var button=$('#'+this.id);return button.exists()&&button.closest('.cke_'+this.type);},moveInside:function(){this.data.inside++;},moveOutside:function(){this.data.inside--;},renderPanel:function(){var button=$('#'+this.id),el=this.getEl();if(button&&el&&!this.panel){var pos=el.position();var panel=this.panel=$('<div>');panel.addClass('cke_panel_dropdown').addClass(this.panelClass||'').appendTo(el.offsetParent());this.positionPanel();this.panelOnInit&&this.panelOnInit(this.panel,this,panel);panel.hide();button.add(panel).mouseenter(this.proxy(this.moveInside)).mouseleave(this.proxy(this.moveOutside));panel.delegate('.cke_button, .text-links a','mouseenter',this.proxy(this.moveOutside)).delegate('.cke_button, .text-links a','mouseleave',this.proxy(this.moveInside));}},positionPanel:function(){var el=this.getEl();var pos=el.position();var mod={left:5,top:-20};this.panel.css({position:'absolute',left:pos.left+mod.left,top:pos.top+mod.top+el.outerHeight(),'padding-top':-mod.top});},clickHandler:function(){var button=$('#'+this.id),el=button.closest('.cke_'+this.type);if(!this.panel)
this.renderPanel();if(!this.opened){el.addClass('cke_opened');this.panelOnShow&&this.panelOnShow(this.panel,this);this.positionPanel();this.panel.show();this.opened=true;this.inside=1;}else{el.removeClass('cke_opened');this.panelOnHide&&this.panelOnHide(this.panel,this);this.panel.hide();this.opened=false;this.inside=0;}},beforeRender:function(){this.opened=false;this.click=this.clickHandler;WE.ui.panelbutton.superclass.beforeRender.call(this);this.editor.ui.on('bodyClick',this.proxy(function(){if(this.opened&&this.inside==0){this.click();}}));this.editor.on('editorFocus',this.proxy(function(){if(this.opened){this.click();}}));this.hasArrow=true;this.labelClass='cke_text';if(this.autorenderpanel){this.editor.on('toolbarsRendered',this.proxy(this.renderPanel));};},panelOnInit:function(){},panelOnShow:function(){},panelOnHide:function(){}});WE.ui.modulebutton=$.createClass(WE.ui.panelbutton,{panelOnInit:function(panel,config,data){var module=this.moduleObject=this.editor.modules.create(config.module);var el=module.render();var headerClass=module.getHeaderClass();var elcontent=$('<div>').addClass('module_content').append(el)
var elmodule=$('<div>').addClass('module module_'+headerClass).attr('data-id',headerClass).append(elcontent);panel.append(elmodule);module.afterAttach();},beforeRender:function(){this.panelClass=this.panelClass?this.panelClass+' ':'';WE.ui.modulebutton.superclass.beforeRender.call(this);}});})(this,jQuery);;(function(window,$){var WE=window.WikiaEditor=window.WikiaEditor||(new Observable());WE.module=$.createClass(Observable,{MODULE_MESSAGES_PREFIX:'modules-',modes:{wysiwyg:true},enabled:true,headerClass:'',headerText:'',headerTextId:'',constructor:function(editor,options){WE.module.superclass.constructor.call(this);this.editor=editor;this.options=options;this.ui=this.editor.ui;this.init();},init:function(){},getHeaderClass:function(){return this.headerClass;},getHeaderText:function(){if(this.headerTextId){return this.msg(this.headerTextId);}
if(this.headerText){return this.headerText;}
return'';},setHeaderText:function(text){this.headerText=text;this.fire('headerchange',this,text);},getTemplate:function(){return this.template;},getData:function(){return this.data;},renderHtml:function(){return Mustache.render(this.getTemplate(),this.getData());},render:function(){if(!this.enabled){return false;}
var el=$(this.renderHtml());this.el=el;this.afterRender();return el;},afterRender:function(){},afterAttach:function(){},show:function(){this.el.show();this.fire('show',this);},hide:function(){this.el.hide();this.fire('hide',this);},msg:function(){var args=Array.prototype.slice.call(arguments,0);args[0]=this.MODULE_MESSAGES_PREFIX+args[0];return this.editor.msg.apply(this.editor,args);},proxy:function(fn){return $.proxy(fn,this);}});WE.modules.base=WE.module;})(this,jQuery);;(function(window,$){var WE=window.WikiaEditor=window.WikiaEditor||(new Observable());WE.plugins.MiniEditor=$.createClass(WE.plugin,{isReady:false,proxyEvents:['ck-instanceReady','editorActivated','editorAfterActivated','editorBeforeReady','editorBlur','editorClear','editorDeactivated','editorAfterDeactivated','editorFocus','editorReady','editorReset','editorResize','editorKeyUp'],beforeInit:function(){var i=0,l=this.proxyEvents.length;for(;eventName=this.proxyEvents[i],i<l;i++){(function(eventName){this.editor.on(eventName,this.proxy(function(){this[eventName].apply(this,arguments);this.editor.config.body.triggerHandler(eventName,[this.editor].concat(arguments));}));}).call(this,eventName);}},init:function(){this.originalHeight=this.editor.config.body.outerHeight(true);this.toolbar=this.editor.getSpace('toolbar');this.buttonsWrapper=this.editor.getSpace('buttons');if(this.buttonsWrapper.length){this.buttons=this.buttonsWrapper.find('button, input[submit]');}
this.editor.on('editorAddMedia',this.proxy(this.editorKeyUp));this.editor.on('editorAddLink',this.proxy(this.editorKeyUp));this.editor.on('editorInsertTags',this.proxy(this.editorKeyUp));},'ck-instanceReady':function(){var wikiaEditor=this.editor,ckeditor=wikiaEditor.ck;wikiaEditor.getEditboxWrapper().bind('mouseenter.MiniEditor',function(){RTE.repositionRTEOverlay(ckeditor.name);RTE.overlayNode.data('wikiaEditor',wikiaEditor);});},'ck-wysiwygModeReady':function(){this.editorResize();},editorActivated:function(event){$(window).on('beforeunload.PreventLeaveBeforeSave',function(e){if(this.editor.getContent().length){return $.msg('wikia-editor-leaveconfirm-message');}}.bind(this));var animations=this.editor.config.animations;if(event&&event.target!=this.editor.config.body.get(0)){return;}else if(!this.editor.element.hasClass('active')){this.editor.element.removeClass('preloading');if($.isFunction(animations.editorActivated)){animations.editorActivated.apply(this,[event,this.editor]);}}else{this.editor.fire('editorAfterActivated');}
this.editor.element.addClass('active');},editorKeyUp:function(){this.editorToggleButtonsDisabled();if(this.editor.ck!=undefined){this.editorResize();}},editorToggleButtonsDisabled:function(){this.buttons.prop('disabled',!this.editor.getContent().length);},editorAfterActivated:function(){this.showButtons();this.showToolbar();this.editor.element.addClass('editor-open').removeClass('editor-closed');if(!this.isReady){this.isReady=true;}},editorBeforeReady:function(){},editorBlur:function(){this.editor.element.removeClass('focused');},editorClear:function(){if(this.editor.ck){this.editor.ck.setData('');}else{this.editor.getEditbox().val('');}},editorDeactivated:function(force){$(window).off('beforeunload.PreventLeaveBeforeSave');var animations=this.editor.config.animations;this.hideToolbar();if(this.editor.element.hasClass('active')||force){if($.isFunction(animations.editorDeactivated)){animations.editorDeactivated.apply(this,[this.editor,force]);}}
this.editor.element.removeClass('active');},editorAfterDeactivated:function(){this.editor.element.removeClass('editor-open').addClass('editor-closed');},editorFocus:function(){if(this.editor.instanceId!=WikiaEditor.instanceId){this.editor.setAsActiveInstance();}
this.editor.element.addClass('focused');},editorReady:function(event){MiniEditor.initTime=(new Date().getTime()-MiniEditor.initTimer.getTime());$().log('End initialization ('+MiniEditor.initTime+'ms)','MiniEditor');$().log('Time consumed until ready: '+((MiniEditor.loadTime+MiniEditor.initTime)/1000)+'s','MiniEditor');this.editor.element.removeClass('loading');this.editor.fire('editorActivated',event);var replacedElement=this.editor.getEditorElement();if(replacedElement.is('textarea')&&typeof this.editor.ck!="undefined"){replacedElement.val("");}},editorReset:function(){this.editor.fire('editorClear');this.editor.fire('editorDeactivated',true);this.editor.getEditorElement().blur();},editorResize:function(){var editbox=this.editor.getEditbox(),currentHeight=editbox.outerHeight(true),newHeight=currentHeight>this.editor.config.maxHeight?this.editor.config.maxHeight:currentHeight>this.editor.config.minHeight?currentHeight:this.editor.config.minHeight;this.editor.getEditboxWrapper().height(newHeight);editbox.parent().toggleClass('resizing',newHeight<this.editor.config.maxHeight);},hideButtons:function(callback){if(this.buttonsWrapper.length){this.buttons.attr('disabled',true);this.buttonsWrapper.slideUp(this.proxy(callback));}else{callback.call(this);}},hideToolbar:function(){this.toolbar.slideUp();},showButtons:function(){if(this.buttonsWrapper.length){this.buttonsWrapper.slideDown();this.buttons.show();}},showToolbar:function(){this.toolbar.slideDown();}});})(this,jQuery);;(function(window,$){var slice=[].slice,Wikia=window.Wikia,WikiaEditor=window.WikiaEditor;if(!(Wikia||Wikia.Tracker)){return;}
WikiaEditor.plugins.tracker=$.createClass(WikiaEditor.plugin,{config:{action:Wikia.Tracker.ACTIONS.CLICK,trackingMethod:'analytics'},init:function(){var isMiniEditor=this.editor.config.isMiniEditor,editorType=(isMiniEditor?'-mini-':'-')+
((window.RTE!==undefined&&!window.RTEEdgeCase)?'ck':'mw');this.config.category='editor'+editorType;if(!isMiniEditor){if(window.veTrack){veTrack({action:'ck-edit-page-start'});}
this.track({action:Wikia.Tracker.ACTIONS.IMPRESSION,label:'edit-page'});}
this.editor.track=this.proxy(this.track);this.editor.trackWithEventData=this.proxy(this.trackWithEventData);this.editor.on('ckInstanceCreated',this.proxy(this.onCkInstanceCreated));},onCkInstanceCreated:function(ck){ck.on('buttonClick',this.proxy(this.onCkButtonClick));ck.on('dialogCancel',this.proxy(this.onCkDialogCancel));ck.on('dialogClose',this.proxy(this.onCkDialogClose));ck.on('dialogOk',this.proxy(this.onCkDialogOk));ck.on('dialogShow',this.proxy(this.onCkDialogShow));ck.on('panelClick',this.proxy(this.onCkPanelClick));ck.on('panelShow',this.proxy(this.onCkPanelShow));},onCkButtonClick:function(event){var label=event.data.button.label.toLowerCase();this.track('button-'+label);},onCkDialogCancel:function(event){var label=event.data._.name.toLowerCase();this.track('dialog-'+label+'-button-cancel');},onCkDialogClose:function(event){var label=event.data._.name.toLowerCase();this.track('dialog-'+label+'-button-close');},onCkDialogOk:function(event){var label=event.data._.name.toLowerCase();this.track('dialog-'+label+'-button-ok');},onCkDialogShow:function(event){var label=event.data._.name.toLowerCase();this.track({action:Wikia.Tracker.ACTIONS.OPEN,label:'dialog-'+label});},onCkPanelClick:function(event){var label=event.data.me.label.toLowerCase(),value=event.data.value;this.track('panel-'+label+'-item-'+value);},onCkPanelShow:function(event){var label=event.data.me.label.toLowerCase();this.track({action:Wikia.Tracker.ACTIONS.OPEN,label:'panel-'+label});},track:function(){var args=slice.call(arguments),data={},labelParts=[];$.each(args,function(i,arg){if(typeof arg==='string'){arg={label:arg};}else if(arg.category){labelParts.push(arg.category);}
$.extend(data,arg);});delete data.category;if(data.label!=undefined&&data.label!=''){labelParts.push(data.label);}
data.label=labelParts.join('-');Wikia.Tracker.track(this.config,data);},trackWithEventData:function(event){var data;if(typeof event==='object'&&typeof event.data==='object'&&(typeof event.condition!=='function'||event.condition()!==false)){data=event.data;data.browserEvent=event;this.track(data);}}});(function(){var i,l,methodNames=['track','trackWithEventData'];for(i=0,l=methodNames.length;i<l;i++){(function(methodName){WikiaEditor[methodName]=function(){var tracker=WikiaEditor.getInstance().plugins.tracker;tracker[methodName].apply(tracker,slice.call(arguments));}})(methodNames[i]);}})();$(function(){(function(){var label='toolbar-';$('#EditPageToolbar').on('mousedown','.cke_toolbar_expand',function(e){var title=$(e.currentTarget).find('.expand').is(':visible')?'more':'less';WikiaEditor.track(label+title);});})();});})(this,jQuery);;(function(window,$){var WE=window.WikiaEditor=window.WikiaEditor||(new Observable());WE.plugins.collapsiblemodules=$.createClass(WE.plugin,{requires:['modules'],MODULE_ID_ATTRIBUTE:'data-id',storageEntry:'wgRightRailModulesState',lastId:0,modules:false,beforeInit:function(){this.modules={};this.editor.collapsiblemodules=this;},add:function(moduleObj,el){if(!el.children('h3').exists()){return;}
this.lastId++;var id=el.attr(this.MODULE_ID_ATTRIBUTE);id=id?id:this.lastId;var module={id:id,module:moduleObj,el:el,header:el.children('h3'),chevron:false,content:el.children('.module_content'),state:true};module.chevron=module.header.find('.chevron');this.modules[id]=module;var self=this;module.header.bind('click.collapse',function(ev){self.toggle(id);});var defaultState=this.getDefaultState();module.state=this.readState(id,defaultState);this[module.state?'expand':'collapse'](id);},toggle:function(id){var module=this.modules[id],state=module.state;this[state?'collapse':'expand'](id,true);this.setState(id,!state);},collapse:function(id,animate){var module=this.modules[id];if(animate){module.content.slideUp(this.proxy(this.fireToolbarsResized));}
else{module.content.hide();this.fireToolbarsResized();}
module.chevron.removeClass('collapse').addClass('expand');},expand:function(id,animate){var module=this.modules[id];if(animate){module.content.slideDown(this.proxy(this.fireToolbarsResized));}
else{module.content.show();this.fireToolbarsResized();}
module.chevron.removeClass('expand').addClass('collapse');},readState:function(id,defaultState){var stateSet=$.storage.get(this.storageEntry),retval;if(stateSet&&(typeof stateSet[id]!='undefined')){retval=!!stateSet[id];}
else{retval=defaultState;this.saveState(id,defaultState);}
return retval;},saveState:function(id,state){var stateSet=$.storage.get(this.storageEntry)||{};stateSet[id]=!!state;$.storage.set(this.storageEntry,stateSet);},setState:function(id,state){var module=this.modules[id];module.state=state;this.saveState(id,state);},getDefaultState:function(){var viewport=$(window).height();if(viewport<600){return(this.lastId<2);}
else if(viewport<900){return(this.lastId<3);}
else{return true;}},fireToolbarsResized:function(){this.editor.fire('toolbarsResized',this.editor);}});})(this,jQuery);;(function(window,$){var WE=window.WikiaEditor=window.WikiaEditor||(new Observable());WE.plugins.cssloadcheck=$.createClass(WE.plugin,{CSS_STATE_NAME:'ck-stylesheets',pollStylesheetsTimer:false,pollStylesheetsTimerDelay:100,currentDelay:0,maxAllowedDelay:10000,lastAnnounced:false,enabled:false,beforeInit:function(){this.enabled=!!$.browser.mozilla&&(parseInt($.browser.version)>=2);if(this.enabled){this.pollStylesheetsTimer=new Timer(this.proxy(this.pollStylesheets),this.pollStylesheetsTimerDelay);this.editor.on('state',this.proxy(this.stateChanged));this.editor.on('editorReady',this.proxy(function(){if(this.editor.ck){this.editor.ck.on('modeSwitchCancelled',this.proxy(function(){this.fireState(this.editor.states.IDLE);}));}}));}},init:function(){if(this.enabled){this.stateChanged(this.editor,this.editor.state);}},stateChanged:function(editor,state){var states=this.editor.states;this.pollStylesheetsTimer.stop();if((state==states.INITIALIZING&&this.editor.mode=='wysiwyg')||state==states.LOADING_VISUAL){this.fireState(states.INITIALIZING);}else if(state==states.IDLE&&this.lastAnnounced==states.INITIALIZING){this.currentDelay=0;this.pollStylesheets();}else{this.fireState(states.IDLE);}},pollStylesheets:function(){this.pollStylesheetsTimer.stop();var ed=this.editor.element;if(ed){var iframe=ed.find('iframe');if(iframe.exists()){var doc=iframe.get(0).contentDocument,head=doc&&$('head',$(doc)),headColor=head&&head.css('color');if((typeof headColor=='string')&&$.inArray(headColor.toLowerCase(),['transparent','rgb(0, 0, 0)','white','#ffffff','#fff'])==-1){this.fireState(this.editor.states.IDLE);return;}}}
this.currentDelay+=this.pollStylesheetsTimerDelay;if(this.currentDelay>this.maxAllowedDelay){this.fireState(this.editor.states.IDLE);return;}
this.pollStylesheetsTimer.start();},fireState:function(state){if(this.lastAnnounced!==state){this.editor.fire('extraState',this.editor,this.CSS_STATE_NAME,state);this.lastAnnounced=state;}}});})(this,jQuery);;(function(window,$){var WE=window.WikiaEditor=window.WikiaEditor||(new Observable());WE.plugins.edittools=$.createClass(WE.plugin,{LINK_CAPTION_MESSAGE:'editpagelayout-more',DIALOG_TITLE_MESSAGE:'edittools-dialog-title',modal:false,html:false,beforeInit:function(){this.editor.on('mediawikiToolbarRendered',this.proxy(this.mediawikiToolbarRendered));},mediawikiToolbarRendered:function(editor,el){this.html=this.editor.element.find('.mw-editTools').html();if(this.html){var link=$('<span class="cke_toolbar_expand" />');link.html('<a class="expand" href="#" style="display: inline;"><label>'+$.msg(this.LINK_CAPTION_MESSAGE)+'</label><span>+</span></a>');link.click(this.proxy(this.showEdittools));$(el).append(link);}},showEdittools:function(evt){evt&&evt.preventDefault();var title=$.htmlentities(this.editor.msg(this.DIALOG_TITLE_MESSAGE));$.showModal(title,this.html,{callback:function(){$('#EditPageEditTools').delegate('a','click',function(){$('#EditPageEditTools').closeModal();});},id:'EditPageEditTools',width:680,rawHTML:true});}});})(this,jQuery);;(function(window,$){var WE=window.WikiaEditor=window.WikiaEditor||(new Observable());WE.plugins.loadingstatus=$.createClass(WE.plugin,{requires:['spaces'],MESSAGE_PREFIX:'loadingStates-',extraStates:{},extraStatesCount:0,init:function(){if((this.el=this.editor.getSpace('loading-status'))){this.textEl=this.el.find('.loading-text');this.editarea=this.editor.getSpace('editarea');this.editor.on('state',this.proxy(this.stateChanged));this.editor.on('extraState',this.proxy(this.extraStateChanged));}},extraStateChanged:function(editor,name,state){var states=editor.states;if(state==states.INITIALIZING){if(!this.extraStates[name]){this.extraStates[name]=1;this.extraStatesCount++;this.stateChanged(editor,editor.state);}}else{if(this.extraStates[name]){delete this.extraStates[name];this.extraStatesCount--;this.stateChanged(editor,editor.state);}}},stateChanged:function(editor,state){var states=editor.states,value=false;if(state==states.INITIALIZING){value='loading';}else if(state==states.LOADING_SOURCE){value='toSource';}else if(state==states.LOADING_VISUAL){value='toVisual';}else if(state==states.SAVING){value='saving';}
if(value==false&&this.extraStatesCount>0){return;}
this.set(value);},set:function(state){this.editor.log('loading-status: ',state);if((this.state=state)){var text=this.editor.msg(this.MESSAGE_PREFIX+state);if(state==='saving'&&window.wgSavingMessage){text=window.wgSavingMessage;}
this.textEl.text(text);this.el.show();}else{this.el.hide();this.editor.fire('afterLoadingStatus');}}});})(this,jQuery);;(function(window,$){'use strict';var buttons=window.wgEditorExtraButtons,extensionsPath=window.wgExtensionsPath,mediawikiButtons=window.mwCustomEditButtons;if(!buttons){buttons=window.wgEditorExtraButtons={};}
function checkGallery(){return typeof window.WikiaPhotoGallery!=='undefined'&&!window.wgEnableMediaGalleryExt;}
function getTextarea(){return WikiaEditor.getInstance().getEditbox()[0];}
buttons.InsertImage={type:'button',labelId:'wikia-editor-media-image',titleId:'wikia-editor-media-image-tooltip',className:'RTEImageButton',forceLogin:true,clicksource:function(){WikiaEditor.load('WikiaMiniUpload').done(function(){WMU_show();});},ckcommand:'addimage'};buttons.InsertGallery={type:'button',labelId:'wikia-editor-media-gallery',titleId:'wikia-editor-media-gallery-tooltip',className:'RTEGalleryButton',forceLogin:true,clicksource:function(){WikiaPhotoGallery.showEditor({from:'source',type:WikiaPhotoGallery.TYPE_GALLERY});},ckcommand:'addgallery',precondition:checkGallery};buttons.InsertSlideshow={type:'button',labelId:'wikia-editor-media-slideshow',titleId:'wikia-editor-media-slideshow-tooltip',className:'RTESlideshowButton',forceLogin:true,clicksource:function(){WikiaPhotoGallery.showEditor({from:'source',type:WikiaPhotoGallery.TYPE_SLIDESHOW});},ckcommand:'addslideshow',precondition:checkGallery};buttons.InsertSlider={type:'button',labelId:'wikia-editor-media-slider',titleId:'wikia-editor-media-slider-tooltip',className:'RTESliderButton',forceLogin:true,clicksource:function(){WikiaPhotoGallery.showEditor({from:'source',type:WikiaPhotoGallery.TYPE_SLIDER});},ckcommand:'addslider',precondition:checkGallery};if(window.wgEnableVideoToolExt){buttons.InsertVideo={type:'button',labelId:'wikia-editor-media-video',titleId:'wikia-editor-media-video-tooltip',className:'RTEVideoButton',forceLogin:true,clicksource:function(){WikiaEditor.load('VideoEmbedTool').done(function(){window.vetWikiaEditor({target:{id:'mw-editbutton-vet'}});});},ckcommand:'addvideo'};}
buttons.SourceBold={type:'button',labelId:'wikia-editor-source-bold',titleId:'wikia-editor-source-bold-tooltip',className:'cke_button_bold',clicksource:function(){insertTags("'''","'''",'Bold text',getTextarea());}};buttons.SourceItalic={type:'button',labelId:'wikia-editor-source-italic',titleId:'wikia-editor-source-italic-tooltip',className:'cke_button_italic',clicksource:function(){insertTags("''","''",'Italic text',getTextarea());}};buttons.SourceLink={type:'button',labelId:'wikia-editor-source-link',titleId:'wikia-editor-source-link-tooltip',className:'cke_button_link',clicksource:function(){insertTags('[[',']]','Link title',getTextarea());}};if(window.skin==='oasis'&&mediawikiButtons){if(window.wgEnableWikiaMiniUploadExt){mediawikiButtons.push({imageFile:extensionsPath+'/wikia/WikiaMiniUpload/images/button_wmu.png',speedTip:wmu_imagebutton,imageId:'mw-editbutton-wmu',onclick:function(){WikiaEditor.load('WikiaMiniUpload').done(function(){WMU_show();});}});}
if(window.wgEnableWikiaPhotoGalleryExt&&!window.wgEnableMediaGalleryExt){mediawikiButtons.push({imageFile:extensionsPath+'/wikia/WikiaPhotoGallery/images/gallery_add.png',speedTip:window.WikiaPhotoGalleryAddGallery,imageId:'mw-editbutton-wpg',onclick:function(){WikiaPhotoGallery.showEditor({from:'source'});}});}
if(window.wgEnableVideoToolExt&&window.showAddVideoBtn){mediawikiButtons.push({imageFile:extensionsPath+'/wikia/VideoEmbedTool/images/button_vet.png',speedTip:$.msg('vet-imagebutton'),imageId:'mw-editbutton-vet',onclick:function(event){WikiaEditor.load('VideoEmbedTool').done(function(){window.vetWikiaEditor(event);});}});}}})(window,jQuery);;(function(window){var WE=window.WikiaEditor;WE.modules.Container=$.createClass(WE.modules.base,{items:false,modules:false,moduleEls:false,init:function(){if(this.options.items&&!this.items){this.items=this.options.items;}
this.modules={};this.moduleEls={};var modules=this.modules;function traverse(item){if(typeof item=='string'){modules[item]=false;}else if($.isArray(item)){for(var i=0;i<item.length;i++){traverse(item[i]);}}else{traverse(item.items);}}
traverse(this.items);var module=false;for(var name in modules){modules[name]=this.editor.modules.create(name);}},afterRenderChild:function(no,module,el){return el;},renderChildren:function(el,children){var childEls=[];for(var i=0;i<children.length;i++){var child=children[i],childEl=false;if(typeof child=='string'){if(this.modules[child]){childEl=this.modules[child].render();}
if(childEl){this.moduleEls[child]=childEl;}
if(childEl){childEl=this.afterRenderChild(child,this.modules[child],childEl);}}else{childEl=$('<div>');if(child['cls'])childEl.addClass(child.cls);childEl=this.renderChildren(childEl,child.items);}
if(childEl)
childEls.push(childEl);}
if(childEls.length==0){return false;}
for(var i=0;i<childEls.length;i++){if(childEls[i])
el.append(childEls[i]);}
return el;},modeChanged:function(){var mode=this.editor.mode;for(var name in this.modules){if(this.modules[name]&&this.moduleEls[name]){var module=this.modules[name];if(typeof module.modes=='object'){module[module.modes[mode]?'show':'hide']();}}}},render:function(){var el=this.options.element||$('<div>');el.addClass(this.containerClass);this.el=this.renderChildren(el,this.items)||el;return this.el;},afterAttach:function(){for(var name in this.modules){if(this.modules[name]&&this.moduleEls[name]){this.modules[name].afterAttach();this.afterAttachChild(this.modules[name],this.moduleEls[name]);}}
this.editor.on('mode',this.modeChanged,this);this.modeChanged();},afterAttachChild:function(module,el){}});WE.modules.container=WE.modules.Container;})(this);;(function(window){var WE=window.WikiaEditor;WE.modules.ButtonsList=$.createClass(WE.modules.base,{items:[],getItems:function(){return this.items;},template:'<span class="{{className}}">{{#elements}}{{{.}}}{{/elements}}</span>',getData:function(){var items=this.getItems(),elements=[];for(var n=0;n<items.length;n++){elements.push(this.ui.create(items[n]));}
return{className:'cke_buttons cke_toolbar_'+this.headerClass,elements:elements};}});})(this);;(function(window){var WE=window.WikiaEditor;WE.modules.FormatMiniEditor=$.createClass(WE.modules.ButtonsList,{headerClass:'formatmini',items:['Bold','Italic','Link']});})(this);;(function(window){var WE=window.WikiaEditor;WE.modules.FormatMiniEditorSource=$.createClass(WE.modules.ButtonsList,{modes:{source:true},headerClass:'formatsourcemini',items:['SourceBold','SourceItalic','SourceLink']});})(this);;(function(window){var WE=window.WikiaEditor,items;items=['InsertImage','InsertGallery','InsertSlideshow','InsertSlider','InsertMedia','Poll','Table'];if(window.showAddVideoBtn){items.splice(4,0,'InsertVideo');}
WE.modules.Insert=$.createClass(WE.modules.ButtonsList,{modes:true,headerClass:'insert',headerTextId:'insert-title',cuttingPosition:false,cuttingText:false,items:items,init:function(){WE.modules.Insert.superclass.init.call(this);this.editor.on('beforemediawikibutton',this.beforeMediawikiButton,this);if(this.editor.config.insertCutPosition>=0&&this.editor.config.insertCutText){this.cuttingPosition=this.editor.config.insertCutPosition;this.cuttingText=this.editor.config.insertCutText;}},beforeMediawikiButton:function(editor,button){var disabled={'mw-editbutton-wmu':1,'mw-editbutton-wpg':1,'mw-editbutton-vet':1};return typeof button.imageId==='undefined'||typeof disabled[button.imageId]==='undefined';},afterRender:function(){WE.modules.Insert.superclass.afterRender.call(this);var buttons=this.el.find('.cke_button'),link;buttons.addClass('cke_button_big');if(this.cuttingPosition!==false){buttons.slice(this.cuttingPosition).hide();link=$('<a>').addClass('cke_more_buttons').html(this.cuttingText).click(function(){link.remove();buttons.show();});this.el.append(link);}}});WE.modules.ToolbarInsert=WE.modules.Insert;WE.modules.RailInsert=WE.modules.Insert;})(this);;(function(window){var WE=window.WikiaEditor,items;items=['InsertImage'];if(window.showAddVideoBtn){items.splice(1,0,"InsertVideo");}
WE.modules.InsertMiniEditor=$.createClass(WE.modules.Insert,{items:items,init:function(){WE.modules.InsertMiniEditor.superclass.init.call(this);}});})(this);;(function(window){var WE=window.WikiaEditor;WE.modules.ModeSwitch=$.createClass(WE.modules.ButtonsList,{modes:true,headerClass:'mode_switch',items:['ModeSource','ModeWysiwyg','|']});})(this);;(function(window,$){var Wikia=window.Wikia;var WikiaPhotoGallery={editor:{currentPage:false,currentPageParams:{},from:false,gallery:{images:[],externalImages:[],node:false,params:{},type:false,hash:false,id:0},msg:{},defaultParamValues:{},source:false,height:false,width:false},CHOOSE_TYPE_PAGE:0,UPLOAD_FIND_PAGE:1,UPLOAD_CONFLICT_PAGE:2,CAPTION_LINK_PAGE:3,GALLERY_PREVIEW_PAGE:4,SLIDESHOW_PREVIEW_PAGE:5,SLIDER_PREVIEW_PAGE:6,EDIT_CONFLICT_PAGE:7,TYPE_GALLERY:1,TYPE_SLIDESHOW:2,TYPE_SLIDER:3,RESULTS_RECENT_UPLOADS:0,RESULTS_IMAGES_FROM_THIS_PAGE:1,RESULTS_SEARCH:2,GALLERY_SLIDER_WIDTH:660,GALLERY_SLIDER_HEIGHT:360,ajax:function(method,params,callback){return $.post(wgScript+'?action=ajax&rs=WikiaPhotoGalleryAjax&method='+method,params,callback,'json');},log:function(msg){$().log(msg,'WikiaPhotoGallery');},isSlideshow:function(){return(this.editor.gallery.type==this.TYPE_SLIDESHOW);},isSlider:function(){return(this.editor.gallery.type==this.TYPE_SLIDER);},selectPage:function(selectedPage,params){params=params||{};params.source=this.editor.currentPage;this.editor.currentPage=selectedPage;this.editor.currentPageParams=params;this.log('selecting page #'+selectedPage);this.log(params);var pages=$('#WikiaPhotoGalleryEditor').find('.WikiaPhotoGalleryEditorPage');pages.hide();var msg=this.editor.msg;var saveButton=$('#WikiaPhotoGalleryEditorSave');var cancelButton=$('#WikiaPhotoGalleryEditorCancel');var selectImageButton=$('#WikiaPhotoGallerySearchResultsSelect');$('#WikiaPhotoGalleryEditConflictButtons').hide();selectImageButton.hide();var type=this.isSlideshow()?'slideshow':this.isSlider()?'slider':'gallery';var title='';switch(selectedPage){case this.CHOOSE_TYPE_PAGE:title=msg['wikiaPhotoGallery-choice-title'];saveButton.hide();cancelButton.hide();this.setupChooseTypePage(params);break;case this.UPLOAD_FIND_PAGE:title=msg['wikiaPhotoGallery-upload-title-'+type];saveButton.hide();if(params.source){cancelButton.show();}else{cancelButton.hide();}
selectImageButton.show();this.setupUploadPage(params);break;case this.UPLOAD_CONFLICT_PAGE:title=msg['wikiaPhotoGallery-upload-title-'+type];saveButton.hide();cancelButton.show();this.setupUploadConflictPage(params);break;case this.CAPTION_LINK_PAGE:title=msg['wikiaPhotoGallery-photooptions-title-'+type];saveButton.show().text(msg['wikiaPhotoGallery-photooptions-done']);cancelButton.show();this.setupCaptionLinkPage(params);break;case this.GALLERY_PREVIEW_PAGE:title=msg['wikiaPhotoGallery-preview-title'];saveButton.show().text(msg['wikiaPhotoGallery-finish']);cancelButton.hide();this.setupGalleryPreviewPage(params);break;case this.SLIDESHOW_PREVIEW_PAGE:title=msg['wikiaPhotoGallery-slideshowpreview-title'];saveButton.show().text(msg['wikiaPhotoGallery-finish']);cancelButton.hide();this.setupSlideshowPreviewPage(params);break;case this.SLIDER_PREVIEW_PAGE:$('#WikiaPhotoGalleryImageUploadSize').show();title=msg['wikiaPhotoGallery-sliderpreview-title'];saveButton.show().text(msg['wikiaPhotoGallery-finish']);cancelButton.hide();this.setupSliderPreviewPage(params);break;case this.EDIT_CONFLICT_PAGE:title+=msg['wikiaPhotoGallery-conflict-title'];saveButton.hide();cancelButton.hide();this.setupEditConflictPage(params);break;}
pages.eq(selectedPage).show();$('#WikiaPhotoGalleryEditorTitle').text(title);},onSave:function(){var params=this.editor.currentPageParams,hideModal=true,data,newPage=null,newParams={},position;switch(this.editor.currentPage){case this.UPLOAD_FIND_PAGE:break;case this.UPLOAD_CONFLICT_PAGE:break;case this.CAPTION_LINK_PAGE:var caption=$('#WikiaPhotoGalleryEditorCaption').val(),link='',linktext='';if(this.isSlideshow()){newPage=this.SLIDESHOW_PREVIEW_PAGE;link=$('#WikiaPhotoSlideshowLink').val();linktext=$('#WikiaPhotoSlideshowLinkText').val();}else if(this.isSlider()){newPage=this.SLIDER_PREVIEW_PAGE;link=$('#WikiaPhotoSliderLink').val();linktext=$('#WikiaPhotoSliderLinkText').val();}else{newPage=this.GALLERY_PREVIEW_PAGE;link=$('#WikiaPhotoGalleryLink').val();}
link.replace(/^(\[)+/,'').replace(/(\])+$/,'');data={caption:caption,link:link,linktext:linktext,name:params.imageName};if(params.imageId==null){this.editor.gallery.images.push(data);}
else{this.editor.gallery.images[params.imageId]=data;}
break;case this.SLIDER_PREVIEW_PAGE:case this.GALLERY_PREVIEW_PAGE:case this.SLIDESHOW_PREVIEW_PAGE:var gallery=this.editor.gallery;if(this.isSlideshow()){gallery.params.widths=this.sliderInput.val();}else if(!this.isSlider()){gallery.params.captionalign=$('#WikiaPhotoGalleryEditorGalleryCaptionAlignment').val();gallery.params.widths=this.sliderInput.val();gallery.params.position=$('#WikiaPhotoGalleryEditorGalleryPosition').val();}
gallery.wikitext=this.JSONtoWikiText(gallery);switch(this.editor.from){case'wysiwyg':data={images:gallery.images,params:gallery.params,wikitext:gallery.wikitext};this.log(data);if(gallery.node){this.log('updating existing gallery/slideshow');gallery.node.setData('externalImages',false);gallery.node.setData(data);position=gallery.params.position||'right';gallery.node.removeClass('alignLeft alignRight alignCenter').addClass('align'+position.substr(0,1).toUpperCase()+position.substr(1));}else{this.log('adding new gallery/slideshow');var node=RTE.tools.createPlaceholder('image-gallery',data);node.setData('type',gallery.type);node.removeClass('placeholder placeholder-ext').addClass('media-placeholder image-gallery');var dimensions={};if(this.isSlideshow()){position=gallery.params.position||'right';node.addClass('image-slideshow');node.addClass('align'+position.substr(0,1).toUpperCase()+position.substr(1));dimensions.width='300';dimensions.height='225';}else if(this.isSlider()){node.addClass('image-gallery-slider');dimensions.width=this.GALLERY_SLIDER_WIDTH;dimensions.height=this.GALLERY_SLIDER_HEIGHT;}else{position=gallery.params.position||'right';node.addClass('align'+position.substr(0,1).toUpperCase()+position.substr(1));dimensions.width='185';dimensions.height='185';}
node.attr(dimensions);RTE.tools.insertElement(node);}
break;case'source':this.log('adding new gallery');this.log(gallery.wikitext);var cursorPos=this.getCaretPosition();var textarea=this.getEditarea();var value=textarea.value;value=value.substring(0,cursorPos)+gallery.wikitext+value.substring(cursorPos);textarea.value=value;break;case'view':hideModal=false;var event=jQuery.Event("beforeSaveGalleryData");var element_id=this.editor.allparams.element_id||0;$("body").trigger(event,[element_id,gallery,$('#WikiaPhotoGalleryEditor')]);if(event.isDefaultPrevented()){return false;}
WikiaPhotoGallery.ajax('saveGalleryData',{hash:gallery.hash,wikitext:gallery.wikitext,title:wgPageName,starttime:gallery.starttime},function(data){if(data.info=='ok'){$('#WikiaPhotoGalleryEditor').hideModal();location.hash='#'+gallery.id;location.reload(true);}else if(data.info=='conflict'){WikiaPhotoGallery.selectPage(WikiaPhotoGallery.EDIT_CONFLICT_PAGE);}else{$('#WikiaPhotoGalleryEditor').hideModal();WikiaPhotoGallery.showAlert(data.errorCaption,data.error);}});break;}
if(hideModal){$('#WikiaPhotoGalleryEditor').hideModal();}
return;}
if(newPage!=null){this.selectPage(newPage,newParams);}else{this.log('this button has no action in this context - it should be hidden');}},onCancel:function(){var editor=this.editor;var params=editor.currentPageParams;var newPage=null;var newPageParams={};switch(editor.currentPage){case this.UPLOAD_FIND_PAGE:newPage=params.source;if(params.imageId!=null){newPageParams.imageId=params.imageId;}
if(params.imageName){newPageParams.imageName=params.imageName;}
if(params.caption){newPageParams.caption=params.caption;}
if(params.link){newPageParams.link=params.link;}
break;case this.UPLOAD_CONFLICT_PAGE:newPage=this.UPLOAD_FIND_PAGE;break;case this.CAPTION_LINK_PAGE:newPage=params.source;if(params.imageId!=null){newPageParams.imageId=params.imageId;}
break;case this.GALLERY_PREVIEW_PAGE:case this.SLIDESHOW_PREVIEW_PAGE:break;}
if(newPage!=null){this.selectPage(newPage,newPageParams);}else{this.log('this button has no action in this context - it should be hidden');}},setupEditor:function(params){delete this.lockEditor;var self=this;var firstPage=this.CHOOSE_TYPE_PAGE;this.editor.gallery={id:false,params:{},images:[],externalImages:[],node:false};switch(params.from){case'wysiwyg':if(typeof params.gallery=='object'){var data=params.gallery.getData();this.editor.gallery=$.extend(this.editor.gallery,{id:data.id,images:data.images,externalImages:data.externalImages,node:params.gallery,params:data.params,type:data.type});if(this.isSlideshow()){firstPage=this.SLIDESHOW_PREVIEW_PAGE;}else if(this.isSlider()){firstPage=this.SLIDER_PREVIEW_PAGE;}else{firstPage=this.GALLERY_PREVIEW_PAGE;}}else if(typeof params.type=='number'){this.editor.gallery.type=params.type;if(this.isSlideshow()){firstPage=this.SLIDESHOW_PREVIEW_PAGE;}else if(this.isSlider()){firstPage=this.SLIDER_PREVIEW_PAGE;}else{firstPage=this.GALLERY_PREVIEW_PAGE;}}
break;case'source':if(typeof params.type=='number'){this.editor.gallery.type=params.type;if(this.isSlideshow()){firstPage=this.SLIDESHOW_PREVIEW_PAGE;}else if(this.isSlider()){firstPage=this.SLIDER_PREVIEW_PAGE;}else{firstPage=this.GALLERY_PREVIEW_PAGE;}}
break;case'view':if(typeof params.gallery=='object'){this.editor.gallery=params.gallery;this.editor.allparams=params;if(this.isSlideshow()){firstPage=this.SLIDESHOW_PREVIEW_PAGE;}else if(this.isSlider()){firstPage=this.SLIDER_PREVIEW_PAGE;}else{firstPage=this.GALLERY_PREVIEW_PAGE;}}
break;}
this.editor.from=params.from;this.target=params.target;this.track({action:Wikia.Tracker.ACTIONS.OPEN});this.setupSearch();this.setupUpload();this.setupSearchResults(this.RESULTS_RECENT_UPLOADS);this.setupCaptionToolbar();this.setupLinkSuggest('WikiaPhotoGalleryLink');this.setupLinkSuggest('WikiaPhotoSlideshowLink');$('#WikiaPhotoGalleryEditorSave').unbind('.save').bind('click.save',function(){self.track({label:'button-finish'});self.onSave.apply(self);});$('#WikiaPhotoGalleryEditorCancel').unbind('.cancel').bind('click.cancel',function(){self.track({label:'button-back'});self.onCancel.apply(self);});this.selectPage(firstPage);},setupUpload:function(){var self=this;$('#WikiaPhotoGalleryImageUpload').unbind('.upload').bind('click.upload',function(ev){self.track({label:'button-upload-photo'});if(self.isSlider()){$('#WikiaPhotoGalleryImageUploadSize').show();}});$('#WikiaPhotoGalleryImageUploadForm').unbind('.upload').bind('change.upload',function(ev){$(this).submit();}).bind('submit.upload',function(ev){var uploadFileName=$('#WikiaPhotoGalleryImageUpload').val();if(uploadFileName==''){self.log('no file selected to upload');ev.preventDefault();return;}
$('#WikiaPhotoGalleryImageUploadButton').attr('disabled',true);$('#WikiaPhotoGalleryUploadProgress').show();$.AIM.submit(this,{onComplete:function(response){var data=$.parseJSON(response);$('#WikiaPhotoGalleryImageUploadButton').attr('disabled',false);$('#WikiaPhotoGalleryUploadProgress').hide();var imageId=self.editor.currentPageParams.imageId;if(data.success){self.selectPage(self.CAPTION_LINK_PAGE,{imageId:imageId,imageName:data.name});}else if(data.conflict){var thumbnail='<img src="'+data.thumbnail.url+'" alt="" border="0" '+'width="'+data.thumbnail.width+'" height ="'+data.thumbnail.height+'" />';self.selectPage(self.UPLOAD_CONFLICT_PAGE,{imageId:imageId,imageName:data.name,nameParts:data.nameParts,tempId:data.tempId,thumbnail:thumbnail});}else{self.showAlert(self.editor.msg['wikiaPhotoGallery-upload-title'],data.message);$('#WikiaPhotoGalleryImageUpload').val('');}}});});},setupSearchResults:function(type){var self=this;var chooserLinks=$('#WikiaPhotoGallerySearchResultsChooser').children('span');var query='[type='+type+']';chooserLinks.not(query).addClass('clickable');chooserLinks.filter(query).removeClass('clickable');chooserLinks.unbind('.chooser').bind('click.chooser',function(ev){var type=parseInt($(this).attr('type'));if(type===0){self.track({label:'find-recent-uploads'});}else if(type===1){self.track({label:'find-this-page'});}
self.setupSearchResults(type);});var results=$('#WikiaPhotoGallerySearchResults').children('ul');results.hide();results=results.eq(type);var selectImage=function(ev){var target=$(ev.target);if(!target.is('li')){target=target.parent();}
target.addClass('accent selected');};var unselectImage=function(ev){var target=$(ev.target);if(!target.is('li')){target=target.parent();}
var checkbox=target.children('input');if(!checkbox.attr('checked')){target.removeClass('accent selected');}};results.find('li').unbind('.imageHover').bind({'mouseover.imageHover':selectImage,'mouseout.imageHover':unselectImage});results.find('input').unbind('.imageHover').bind('change.imageHover',function(ev){var checkbox=$(this);self.track({label:'find-select-photo'});if(checkbox.attr('checked')){selectImage(ev);}
else{unselectImage(ev);}});results.find('a').unbind('.selectImage').bind('click.selectImage',function(ev){ev.preventDefault();var node=$(this);var imageName=node.attr('title');var imageId=self.editor.currentPageParams.imageId;self.selectPage(self.CAPTION_LINK_PAGE,{imageId:imageId,imageName:imageName});});$('#WikiaPhotoGallerySearchResultsSelect').unbind('.selectImage').bind('click.selectImage',function(ev){var selected=results.find('input:checked');self.track({label:'button-select'});if(!selected.exists()){return;}
if(selected.length==1){var imageName=selected.attr('value');var imageId=self.editor.currentPageParams.imageId;self.selectPage(self.CAPTION_LINK_PAGE,{imageId:imageId,imageName:imageName});}
else{selected.each(function(){var imageName=$(this).attr('value');var data={caption:'',link:'',linktext:'',name:imageName};self.editor.gallery.images.push(data);});if(self.isSlideshow()){self.selectPage(self.SLIDESHOW_PREVIEW_PAGE);}else if(self.isSlider()){self.selectPage(self.SLIDER_PREVIEW_PAGE);}else{self.selectPage(self.GALLERY_PREVIEW_PAGE);}}
selected.attr('checked',false).each(function(){$(this).parent().removeClass('accent selected');});$(this).hide();});results.show();},setupCaptionToolbar:function(){var captionEditor=$('#WikiaPhotoGalleryEditorCaption');var captionToolbar=$('#WikiaPhotoGalleryEditorCaptionToolbar').html('').hide();var toolbarHideTimeout=false;$('#WikiaPhotoGalleryEditorCaption').unbind('.editor').bind('focus.editor',function(ev){clearTimeout(toolbarHideTimeout);captionToolbar.show();}).bind('blur.editor',function(ev){toolbarHideTimeout=setTimeout(function(){captionToolbar.hide();},250);});var messages=this.editor.msg;var toolbarButtons=[{image:'bold',tagOpen:"'''",tagClose:"'''",title:messages['bold_tip']},{image:'italic',tagOpen:"''",tagClose:"''",title:messages['italic_tip']},{image:'link',tagOpen:"[[",tagClose:"]]",title:messages['link_tip']}];var self=this;var toolbarButtonOnClick=function(tagOpen,tagClose,sampleText){self.log(tagOpen+'foo'+tagClose);self.insertTags(captionEditor,tagOpen,tagClose,sampleText);clearTimeout(toolbarHideTimeout);captionEditor.focus();};for(var i=0;i<toolbarButtons.length;i++){var data=toolbarButtons[i];$('<img />').appendTo(captionToolbar).attr({alt:'',height:22,src:stylepath+'/common/images/button_'+data.image+'.png',tagClose:data.tagClose,tagOpen:data.tagOpen,title:data.title,width:23}).click(function(){var button=$(this);toolbarButtonOnClick(button.attr('tagOpen'),button.attr('tagClose'),button.attr('title'));});}},setupLinkSuggest:function(fieldId){var field=$('#'+fieldId);if(field.data('suggestSetUp')){return;}
field.autocomplete({minLength:2,source:function(request,response){$.getJSON(mw.util.wikiScript('api'),{format:'json',action:'opensearch',search:request.term},function(arr){if(arr&&arr.length>1){response(arr[1]);}
else{response([]);}});}});field.data('suggestSetUp',true);this.log('MW suggest set up for #'+fieldId);},setupSearch:function(){var self=this,form=$('#WikiaPhotoGallerySearch');form.unbind('.search').bind('submit.search',function(ev){self.onImageSearch.call(self,ev);});form.children('input[placeholder]').placeholder();},onImageSearch:function(ev){ev.preventDefault();var self=this,form=$('#WikiaPhotoGallerySearch'),field=form.children('input[placeholder]'),button=form.children('button'),results=$('#WikiaPhotoGallerySearchResults'),query=field.val();if((query=='')||(query==field.attr('placeholder'))){return;}
self.track({action:Wikia.Tracker.ACTIONS.SUBMIT,label:'find-search-photos'});button.attr('disabled',true);results.addClass('WikiaPhotoGalleryProgress');this.ajax('getSearchResult',{query:query},function(data){button.attr('disabled',false);results.removeClass('WikiaPhotoGalleryProgress');results.children('[type="results"]').remove();if(data.html){results.append(data.html);}
self.setupSearchResults(self.RESULTS_SEARCH);});if(query!=''){if(self.isSlider()){$('#WikiaPhotoGalleryImageUploadSize').show();}}},setupChooseTypePage:function(params){var self=this;var buttons=$('#WikiaPhotoGalleryEditor').find('.WikiaPhotoGalleryEditorChooseType').find('table').find('a');buttons.unbind('.choice').bind('click.choice',function(ev){ev.preventDefault();var type=parseInt($(this).attr('type'));self.editor.gallery.type=type;if(self.isSlideshow()){self.selectPage(self.SLIDESHOW_PREVIEW_PAGE);}else if(self.isSlider()){self.selectPage(self.SLIDER_PREVIEW_PAGE);}else{self.selectPage(self.GALLERY_PREVIEW_PAGE);}});},setupUploadPage:function(params){$('#WikiaPhotoGalleryImageUpload').val('');$('#WikiaPhotoGalleryImageUploadButton').attr('disabled',false);setTimeout($.proxy(function(){var resultsWrapper=$('#WikiaPhotoGallerySearchResults'),offsetTop=resultsWrapper.position().top;resultsWrapper.height(this.editor.height-offsetTop);},this),50);},setupUploadConflictPage:function(params){var self=this;if(params.nameParts){$('#WikiaPhotoGalleryEditorConflictNewName').val(params.nameParts[0]);$('#WikiaPhotoGalleryEditorConflictExtension').text('.'+params.nameParts[1]);}
var thumbCells=$('#WikiaPhotoGalleryEditorConflictThumbs').children();thumbCells.eq(0).html(params.thumbnail);this.loadThumbnail(params.imageName,thumbCells.eq(1));var imageId=self.editor.currentPageParams.imageId;$('#WikiaPhotoGalleryEditorConflictRename').unbind('.conflict').bind('submit.conflict',function(ev){ev.preventDefault();var form=$(this).children('[type=submit]');form.attr('disabled',true);var newName=$('#WikiaPhotoGalleryEditorConflictNewName').val()+$('#WikiaPhotoGalleryEditorConflictExtension').text();self.log('renaming conflicting image to "'+newName+'"');self.ajax('conflictRename',{newName:newName,tempId:params.tempId},function(data){form.attr('disabled',false);if(data.resolved){self.selectPage(self.CAPTION_LINK_PAGE,{imageId:imageId,imageName:newName});}
else{self.showAlert(self.editor.msg['wikiaPhotoGallery-upload-title'],data.msg);}});});$('#WikiaPhotoGalleryEditorConflictReuse').unbind('.conflict').bind('click.conflict',function(ev){self.log('reusing existing image');self.selectPage(self.CAPTION_LINK_PAGE,{imageId:imageId,imageName:params.imageName});});$('#WikiaPhotoGalleryEditorConflictOverwrite').unbind('.conflict').bind('click.conflict',function(ev){self.log('overwriting existing image');var form=$(this);form.attr('disabled',true);self.ajax('conflictOverwrite',{imageName:params.imageName,tempId:params.tempId},function(data){form.attr('disabled',false);self.selectPage(self.CAPTION_LINK_PAGE,{imageId:imageId,imageName:params.imageName});});});},setupCaptionLinkPage:function(params){var imagePreview=$('#WikiaPhotoGalleryEditorCaptionImagePreview');imagePreview.html('').addClass('WikiaPhotoGalleryProgress');this.loadThumbnail(params.imageName,imagePreview);var caption='';var link='';var linktext='';if(params.caption||params.link){if(params.caption)caption=params.caption;if(params.link)link=params.link;if(params.linktext)linktext=params.linktext;}
else if(params.imageId!=null){var image=this.editor.gallery.images[params.imageId];caption=image.caption;link=image.link;linktext=image.linktext;}
$('#WikiaPhotoGalleryEditorCaption').val(caption);var galleryLinkEditor=$('#WikiaPhotoGalleryLinkEditor');var slideshowLinkEditor=$('#WikiaPhotoSlideshowLinkEditor');var sliderLinkEditor=$('#WikiaPhotoSliderLinkEditor');var imageCaption=$('#WikiaPhotoGalleryEditorCaption');galleryLinkEditor.hide();slideshowLinkEditor.hide();sliderLinkEditor.hide();imageCaption.removeAttr('maxlength');if(this.isSlideshow()){slideshowLinkEditor.show();$('#WikiaPhotoSlideshowLink').val(link);$('#WikiaPhotoSlideshowLinkText').val(linktext);}else if(this.isSlider()){sliderLinkEditor.show();imageCaption.attr('maxlength','50');$('#WikiaPhotoSliderLink').val(link);$('#WikiaPhotoSliderLinkText').val(linktext);}else{galleryLinkEditor.show();$('#WikiaPhotoGalleryLink').val(link);}},renderPreview:function(node,method,type){var self=this;var gallery=this.editor.gallery;this.log(this.JSONtoWikiText(gallery));var preview=$(node);preview.html('').addClass('WikiaPhotoGalleryProgress');var galleryJSON=JSON.stringify({images:gallery.images,externalImages:gallery.externalImages||{},params:gallery.params});this.ajax(method,{gallery:galleryJSON},function(data){preview.removeClass('WikiaPhotoGalleryProgress').html(data.html);preview.find('.WikiaPhotoGalleryPreviewItem').not('.WikiaPhotoGalleryPreviewItemPlaceholder').hover(function(ev){var image=$(this);var imageId=parseInt(image.attr('imageid'));image.addClass('accent WikiaPhotoGalleryPreviewItemHover');var menu=image.children('.WikiaPhotoGalleryPreviewItemMenu').show();var menuItems=menu.children('a').unbind('.menu');menuItems.eq(0).bind('click.menu',function(ev){ev.preventDefault();self.modifyPhoto(imageId);});menuItems.eq(1).bind('click.menu',function(ev){ev.preventDefault();self.removePhoto(imageId);});},function(ev){var image=$(this);image.removeClass('accent WikiaPhotoGalleryPreviewItemHover');image.children('.WikiaPhotoGalleryPreviewItemMenu').hide();});preview.find('.WikiaPhotoGalleryPreviewItemPlaceholder').find('a').click(function(ev){ev.preventDefault();self.selectPage(self.UPLOAD_FIND_PAGE,{});});preview.find('.WikiaPhotoGalleryPreviewItemCaption').find('a').click(function(ev){ev.preventDefault();});preview.find('.WikiaPhotoGalleryPreviewItemCaption').add(preview.find('.WikiaPhotoGalleryPreviewItemLink')).click(function(ev){ev.preventDefault();});self.log('lazy loading preview images');var images=preview.find('.WikiaPhotoGalleryPreviewItem').find('img[data-src]');var thumb=images.eq(0).parent();var thumbWidth=thumb.width();var thumbHeight=thumb.height();var params=self.editor.gallery.params;var crop=(params.orientation&&params.orientation!=='none')||(params.crop&&params.crop==='true');images.each(function(){WikiaPhotoGalleryView.loadAndResizeImage($(this),thumbWidth,thumbHeight,function(image){image.css({'margin-left':(thumbWidth-parseInt(image.css('width')))>>1,'margin-top':(thumbHeight-parseInt(image.css('height')))>>1});},crop);});var gallery=preview.find('.WikiaPhotoGalleryPreview');gallery.sortable({containment:'.WikiaPhotoGalleryPreview',delay:100,forcePlaceholderSize:true,items:'.WikiaPhotoGalleryPreviewDraggable',opacity:0.5,placeholder:'WikiaPhotoGalleryPreviewDDPlaceholder',revert:200,start:function(ev,ui){var image=$(ui.item);image.removeClass('accent WikiaPhotoGalleryPreviewItemHover');image.children('.WikiaPhotoGalleryPreviewItemMenu').hide();},stop:function(ev,ui){var item=ui.item;item.css({left:'',top:''});var oldId=parseInt(item.attr('imageid'));var newId=0;gallery.find('.WikiaPhotoGalleryPreviewDraggable').each(function(i){if($(this).attr('imageid')==oldId){newId=i;}});if(oldId==newId){return;}
var images=self.editor.gallery.images;var temp=$.extend(true,images[oldId],{});images.splice(oldId,1);images.splice(newId,0,temp);if(self.isSlider()){self.renderSliderPreview();}else if(self.isSlideshow()){self.renderSlideshowPreview();}else{self.renderGalleryPreview();}}});gallery.disableSelection();});},setupGalleryPreviewPage:function(params){var self=this;var resizePreview=function(){var preview=$('#WikiaPhotoGalleryEditorPreview');preview.height(parseInt(self.editor.height-preview.position().top-$('#WikiaPhotoGalleryEditorCheckboxes').height()-20));};this.setupTabs($('#WikiaPhotoGalleryOptionsTabs'),function(index){resizePreview();});var values={min:50,max:310,ratio:2,"default":185};this.setupSlider($('#WikiaPhotoGallerySliderGallery'),'widths',values,function(slider,value){self.renderGalleryPreview();});this.setupDropdown($('#WikiaPhotoGalleryEditorGalleryColumns'),'columns',self.renderGalleryPreview);this.setupDropdown($('#WikiaPhotoGalleryEditorGalleryPosition'),'position',self.renderGalleryPreview);this.setupDropdown($('#WikiaPhotoGalleryEditorGalleryImageSpacing'),'spacing',self.renderGalleryPreview);this.setupDropdown($('#WikiaPhotoGalleryEditorGalleryCaptionPosition'),'captionposition',self.renderGalleryPreview);this.setupDropdown($('#WikiaPhotoGalleryEditorGalleryCaptionAlignment'),'captionalign',self.renderGalleryPreview);this.setupDropdown($('#WikiaPhotoGalleryEditorGalleryCaptionSize'),'captionsize',self.renderGalleryPreview);this.setupDropdown($('#WikiaPhotoGalleryEditorGalleryBorderSize'),'bordersize',self.renderGalleryPreview);this.setupColorPicker($('#WikiaPhotoGalleryEditorGalleryBorderColor'),'bordercolor',self.renderGalleryPreview);this.setupColorPicker($('#WikiaPhotoGalleryEditorGalleryCaptionColor'),'captiontextcolor',self.renderGalleryPreview);this.setupImageOption($('#WikiaPhotoGalleryOrientation'),'orientation',self.renderGalleryPreview);$('#WikiaPhotoGalleryAddImage').unbind('.addimage').bind('click.addimage',function(ev){var button=$(this);ev.preventDefault();self.track({label:'button-add-photo'});self.selectPage(self.UPLOAD_FIND_PAGE,{});});setTimeout(resizePreview,50);this.renderGalleryPreview();},renderGalleryPreview:function(){this.renderPreview('#WikiaPhotoGalleryEditorPreview','renderGalleryPreview','gallery');},setupSlideshowPreviewPage:function(params){var self=this;var values={min:200,max:500,ratio:2,"default":300};this.setupSlider($('#WikiaPhotoGallerySliderSlideshow'),'widths',values,function(slider,value){self.renderSlideshowPreview();});this.setupCheckbox($('#WikiaPhotoGallerySlideshowCrop'),'crop',self.renderSlideshowPreview);this.setupCheckbox($('#WikiaPhotoGallerySlideshowRecentUploads'),'showrecentuploads',self.renderSlideshowPreview);this.setupDropdown($('#WikiaPhotoGalleryEditorSlideshowAlign'),'position');$('#WikiaPhotoGallerySlideshowAddImage').unbind('.addimage').bind('click.addimage',function(ev){var button=$(this);ev.preventDefault();self.track({label:'button-add-photo'});self.selectPage(self.UPLOAD_FIND_PAGE,{});});this.updateAddAPhotoButton();var preview=$('#WikiaPhotoGallerySlideshowEditorPreview');preview.height(parseInt(this.editor.height-$('#WikiaPhotoGallerySlideshowEditorCheckboxes').height()-275));this.renderSlideshowPreview();},setupSliderPreviewPage:function(params){var self=this;this.setupImageOption($('#WikiaPhotoGallerySliderType'),'orientation',function(){});$('#WikiaPhotoGallerySliderAddImage').unbind('.addimage').bind('click.addimage',function(ev){var button=$(this);self.track({label:'slider-tool-button-add-photo'});ev.preventDefault();self.selectPage(self.UPLOAD_FIND_PAGE,{});});this.updateAddAPhotoButton();var preview=$('#WikiaPhotoGallerySliderEditorPreview');preview.height(parseInt(this.editor.height-$('#WikiaPhotoGallerySliderEditorCheckboxes').height()-275));this.renderSliderPreview();},renderSliderPreview:function(){this.renderPreview('#WikiaPhotoGallerySliderEditorPreview','renderSliderPreview','slider');},updateAddAPhotoButton:function(){var button=$('#WikiaPhotoGallerySlideshowAddImage');var params=this.editor.gallery.params;if(params.showrecentuploads==='true'){button.attr('disabled',true).addClass('secondary');}else{button.attr('disabled',false).removeClass('secondary');}},renderSlideshowPreview:function(){this.renderPreview('#WikiaPhotoGallerySlideshowEditorPreview','renderSlideshowPreview','slideshow');},setupEditConflictPage:function(params){var self=this;$('#WikiaPhotoGalleryEditConflictButtons').show();var buttons=$('#WikiaPhotoGalleryEditConflictButtons').children('a');var wikitext=$('#WikiaPhotoGalleryEditConflictWikitext');var pageUrl=window.wgArticlePath.replace(/\$1/,window.wgPageName);buttons.eq(0).attr('href',pageUrl+(pageUrl.indexOf('?')!=-1?'&':'?')+'action=edit');buttons.eq(1).attr('href',pageUrl);wikitext.val(this.editor.gallery.wikitext);},modifyPhoto:function(photoId){var image=this.editor.gallery.images[photoId];this.selectPage(this.CAPTION_LINK_PAGE,{imageId:photoId,imageName:image.name});},removePhoto:function(photoId){var self=this;var messages=this.editor.msg;jQuery.confirm({title:messages['wikiaPhotoGallery-preview-delete-title'],content:messages['wikiaPhotoGallery-preview-delete'],width:400,onOk:function(){self.log('removing photo #'+photoId);self.editor.gallery.images.splice(photoId,1);if(self.isSlideshow()){self.renderSlideshowPreview();}else if(self.isSlider()){self.renderSliderPreview();}else{self.renderGalleryPreview();}},okMsg:messages['ok'],cancelMsg:messages['cancel']});},setupTabs:function(tabsWrapper,switchCallback){var self=this;var tabs=tabsWrapper.find('.tabs,.wikia-tabs').find('a');var tabsContent=tabsWrapper.find('.WikiaPhotoGalleryOptionsTab');var selectTab=function(index,dontCallback){tabs.parent().removeClass('selected').eq(index).addClass('selected');tabsContent.hide().eq(index).show();if(typeof switchCallback=='function'&&!dontCallback){switchCallback(index);}};selectTab(0,true);tabs.unbind('.tabs').bind('click.tabs',function(ev){ev.preventDefault();var index=$(this).index(tabs);var label=(index===0?'tab-layout':(index===-1?'tab-borders':false));if(label!==false){self.track({label:label});}
selectTab(index);});},setupCheckbox:function(checkbox,paramName,callback){var self=this;var params=this.editor.gallery.params;checkbox.attr('checked',params[paramName]=='true');checkbox.unbind('.checkbox').bind('change.checkbox',function(ev){if($(this).attr('checked')){params[paramName]='true';}
else{delete params[paramName];}
if(paramName==='showrecentuploads'){self.track({label:'create-automatic'});}
if(typeof callback=='function'){callback.call(self);}});},setupDropdown:function(dropdown,paramName,callback){var self=this;var params=this.editor.gallery.params;if(typeof params[paramName]!='undefined'&&params[paramName]!='undefined'){dropdown.val(params[paramName]);}
dropdown.unbind('.dropdown').bind('change.dropdown',function(ev){var value=$(this).val();params[paramName]=value;self.track({label:'dropdown-'+paramName.replace('caption','caption-').replace('border','border-')});if(typeof callback=='function'){callback.call(self,value);}});},setupImageOption:function(widget,paramName,callback){function resetStatus(){widget.find('li').each(function(index){var elm=$(this);var elmWidth=parseInt(widget.attr('rel'),10);elm.css('background-position',(-elmWidth*((2*index)+1))+'px 0');});}
function selectOption(elm){resetStatus();elm=$(elm);var curBkgPosition=elm.css('background-position');if(!curBkgPosition)
curBkgPosition=elm.css('backgroundPositionX')+' '+elm.css('backgroundPositionY')
var curBkgPosition=parseInt(curBkgPosition.split(' ')[0],10);var optionWidth=parseInt(widget.attr('rel'),10);elm.css('background-position',(curBkgPosition+optionWidth)+'px 0');$('#'+widget.attr('id')+'_option_label').html(elm.attr('title'));}
var self=this;var params=this.editor.gallery.params;if(typeof params[paramName]!='undefined'){selectOption(widget.find('#'+widget.attr('id')+'_'+params[paramName]))}
else{selectOption(widget.children().first());}
widget.undelegate('li','click.imageOption').delegate('li','click.imageOption',function(ev){var elm=$(this);var value=elm.attr('rel');self.track({label:'orientation-'+value});if(value!=params[paramName]){selectOption(elm);params[paramName]=value;if(typeof callback=='function'){callback.call(self,value);}}});},setupSlider:function(sliderWrapper,paramName,values,onChangeCallback){var params=this.editor.gallery.params;var sliderInput=this.sliderInput=sliderWrapper.find('input');var slider=sliderWrapper.find('.slider');slider.css('width',Math.round((values.max-values.min)/values.ratio));var initialValue=parseInt(params[paramName])||values['default'];sliderInput.val(initialValue);slider.slider({animate:true,min:values.min,max:values.max,value:initialValue,slide:function(ev,ui){var value=ui.value;sliderInput.val(value);},stop:function(ev,ui){var value=ui.value;params[paramName]=value;if(typeof onChangeCallback=='function'){onChangeCallback(slider,value);}}});sliderInput.unbind('.slider').bind('keyup.slider blur.slider',function(ev){var value=parseInt($(this).val());if(ev.type=='blur'&&isNaN(value)){value=sliderValues.min;$(this).val(value);}
if(value>0){slider.slider('value',value);params[paramName]=value;}
if(ev.type=='blur'){if(typeof onChangeCallback=='function'){onChangeCallback(slider,value);}}});},setupColorPicker:function(colorPicker,paramName,callback){var self=this;var params=this.editor.gallery.params;function hex(x){return("0"+parseInt(x).toString(16)).slice(-2);}
function rgb2hex(rgb){components=rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(components){return"#"+hex(components[1])+hex(components[2])+hex(components[3]);}
else
return rgb;}
function getClassBorderColor(className){var cleanName=className.substr(1);var tmpId='dummy_'+cleanName;var tmpElem=$('<div id="'+tmpId+'">').addClass(cleanName).appendTo(document.body).hide();var bkgColors={};var colors=[];colors.push(tmpElem.css('border-top-color'));colors.push(tmpElem.css('border-right-color'));colors.push(tmpElem.css('border-bottom-color'));colors.push(tmpElem.css('border-left-color'));jQuery.each(colors,function(index,value){if(value!='')bkgColors[value]=(typeof bkgColors[value]!='undefined')?bkgColors[value]+1:1;});var maxCount=0;var bkgColor='rgb(0,0,0)';for(color in bkgColors){if(bkgColors[color]>maxCount){bkgColor=color;maxCount=bkgColors[color];}}
tmpElem.remove();return rgb2hex(bkgColor);}
function getClassBackgroundColor(className){var cleanName=className.substr(1);var tmpId='dummy_'+cleanName;var tmpElem=$('<div id="'+tmpId+'">').addClass(cleanName).appendTo(document.body).hide();var color=tmpElem.css('background-color');tmpElem.remove();return color;}
var colorPickerPopup=$('#'+colorPicker.attr('id')+'_popup');if(colorPickerPopup.data('moved')!==true){colorPickerPopup.appendTo(colorPicker.closest('.WikiaPhotoGalleryEditorPageInner'));colorPickerPopup.data('moved',true);}
colorPickerPopup.hide();var colorPickerTrigger=colorPicker.find('#'+colorPicker.attr('id')+'_trigger');var colorInput=colorPickerPopup.find('input');var title=colorPickerTrigger.attr('title');var color='#000000';if(typeof params[paramName]!='undefined'){if(params[paramName].indexOf('#')==0||(params[paramName]!='accent'&&params[paramName]!='color1')){color=params[paramName];title=params[paramName];}
else{var className='.'+params[paramName];color=getClassBorderColor(className);title=className;}}
else if(typeof title!='undefined'&&title!=''){if(title.indexOf('--')>0){var tokens=title.split('--');switch(tokens[1]){case'border':color=getClassBorderColor('.'+tokens[0]);break;case'background':default:color=getClassBackgroundColor('.'+tokens[0]);}
color=rgb2hex(color);title='.'+tokens[0];}}
if(color=='transparent'){colorPickerTrigger.addClass('transparent-color');}
else{colorPickerTrigger.removeClass('transparent-color');}
colorPickerTrigger.attr('title',title);colorPickerTrigger.css('background-color',color);colorInput.val(title);var colorBoxes=colorPickerPopup.find('ul').find('span');colorBoxes.each(function(index){var colorBox=$(this);var value=null;var title=colorBox.attr('title');if(title.indexOf('.')==0){value=title.substr(1);switch(colorBox.attr('rel')){case'border':color=getClassBorderColor(title);break;case'background':default:color=getClassBackgroundColor(title);}
colorBox.css('background-color',color);}
else if(title=='transparent'){value=title;}
else{value=rgb2hex(colorBox.css('background-color'));}
colorBox.attr('value',value);});colorBoxes.unbind('.colorpicker').bind('click.colorpicker',{caller:this},function(event){var value=null,param=null,node=$(this),title=node.attr('title');if(typeof title!='undefined'&&title.indexOf('.')==0){colorPickerTrigger.removeClass('transparent-color');value=rgb2hex(node.css('background-color'));param=title.substr(1);}else{param=value=rgb2hex(node.attr('value'));if(param=='transparent'){colorPickerTrigger.addClass('transparent-color');}
else{colorPickerTrigger.removeClass('transparent-color');}}
params[paramName]=param;colorPickerTrigger.css('background-color',value);colorPickerTrigger.attr('title',title);colorInput.val(title);$(document.body).unbind('.colorPicker');colorPickerPopup.hide();if(typeof callback=='function'){callback.call(event.data.caller,value);}});colorPicker.unbind('.colorpicker').bind('click.colorpicker',function(event){event.stopPropagation();var position=$(this).position();$('.WikiaPhotoGalleryColorPickerPopUp').hide();if(paramName=='captiontextcolor'){self.track({label:'color-caption'});}else if(paramName=='bordercolor'){self.track({label:'color-border'});}
colorPickerPopup.css({'left':parseInt(position.left)+30,'top':parseInt(position['top'])+5});colorPickerPopup.show();$(document.body).unbind('.colorPicker').bind('click.colorPicker',function(event){if(!$(event.target).hasClass('WikiaPhotoGalleryColorPickerPopUp')&&$(event.target).closest('.WikiaPhotoGalleryColorPickerPopUp').length==0){$(document.body).unbind('.colorPicker');$('.WikiaPhotoGalleryColorPickerPopUp').hide();}});});colorPickerPopup.find('button').unbind('.colorpicker').bind('click.colorpicker',{caller:this},function(event){var inputValue=jQuery.trim(colorInput.val());var value=null;var param=null
if(inputValue.indexOf('.')==0){colorPickerTrigger.removeClass('transparent-color');var color=null;if(inputValue=='.accent')
color=getClassBorderColor(inputValue);else
color=getClassBackgroundColor(inputValue);value=color;param=inputValue.substr(1);}
else{param=value=rgb2hex(inputValue);if(param=='transparent'){colorPickerTrigger.addClass('transparent-color');}
else{colorPickerTrigger.removeClass('transparent-color');}}
params[paramName]=param;colorPickerTrigger.css('background-color',value);colorPickerTrigger.attr('title',inputValue);$(document.body).unbind('.colorPicker');colorPickerPopup.hide();if(typeof callback=='function'){callback.call(event.data.caller,value);}});},showSaveAndQuitDialog:function(){var self=this;var messages=this.editor.msg;this.log('showSaveAndQuitDialog: show');var html='<p>'+messages['wikiaPhotoGallery-quit-intro']+'</p>'+'<div class="neutral modalToolbar">'+'<a class="wikia-button">'+messages['wikiaPhotoGallery-quit-savequit']+'</a>'+'<a class="wikia-button secondary">'+messages['wikiaPhotoGallery-quit-quitonly']+'</a>'+'<a class="wikia-button secondary">'+messages['cancel']+'</a>'+'</div>';jQuery.showModal(messages['wikiaPhotoGallery-quit-title'],html,{id:'WikiaPhotoGalleryShowSaveQuitDialog',width:400,callback:function(){var buttons=$('#WikiaPhotoGalleryShowSaveQuitDialog').find('.modalToolbar').children();buttons.eq(0).click(function(){self.track({label:'exit-button-save'});$('#WikiaPhotoGalleryShowSaveQuitDialog').closeModal();if(self.editor.currentPage==self.CAPTION_LINK_PAGE){self.onSave();}
self.editor.currentPage=self.GALLERY_PREVIEW_PAGE;self.onSave();});buttons.eq(1).click(function(){self.track({label:'exit-button-discard-changes'});$('#WikiaPhotoGalleryShowSaveQuitDialog').closeModal();$('#WikiaPhotoGalleryEditor').hideModal();});buttons.eq(2).click(function(){self.track({label:'exit-button-cancel'});$('#WikiaPhotoGalleryShowSaveQuitDialog').closeModal();});},onClose:function(){self.track({action:Wikia.Tracker.ACTIONS.CLOSE});}});},showEditor:function(params){$().log(params,"showEdit params");var self=WikiaPhotoGallery;if(self.lockEditor){self.log('lock detected - please wait for dialog to load');return;}
self.lockEditor=true;params=params||{};var width=parseInt($('#article').width());width=Math.min($(window).width()-75,width);width=Math.max(670,width);width=Math.min(1300,width);var height=parseInt($(window).height()-125);if(skin=='oasis'){height-=150;width=740;}
height=Math.max(460,height);self.log('showEditor() - '+width+'x'+height+'px');self.log(params);self.editor.width=width;self.editor.height=height;$('#WikiaPhotoGalleryEditor').remove();if(self.modalAjaxData){self.log('Using cached data for modal');self.processModal(self.modalAjaxData,height,params);}else{self.log('Loading required data for modal');$.when($.getResources([wgExtensionsPath+'/wikia/WikiaPhotoGallery/css/WikiaPhotoGallery.editor.css',stylepath+'/common/wikia_ui/tabs.css']),mw.loader.using(['jquery.ui.autocomplete','jquery.ui.slider','wikia.aim']),this.ajax('getEditorDialog',{title:wgPageName})).then(function(getResourcesData,mwLoaderUseData,ajaxData){self.modalAjaxData=ajaxData[0];self.processModal(self.modalAjaxData,height,params);});}},processModal:function(data,height,params){var self=WikiaPhotoGallery;self.editor.msg=data.msg;self.editor.defaultParamValues=data.defaultParamValues;$.showModal('',data.html,{callbackBefore:function(){$('#WikiaPhotoGalleryEditorPagesWrapper').height(height);},callback:function(){$('#WikiaPhotoGalleryEditorLoader').remove();if(skin=='oasis'){$('#WikiaPhotoGalleryEditor').children('h1').attr('id','WikiaPhotoGalleryEditorTitle');}
else{$('#WikiaPhotoGalleryEditor').children('.modalTitle').append('<span id="WikiaPhotoGalleryEditorTitle"></span>');}
self.setupEditor(params);},onClose:function(type){if(type.keypress){return false;}
self.track({action:Wikia.Tracker.ACTIONS.CLOSE});var currentPage=self.editor.currentPage;if(type.click){if(currentPage==self.EDIT_CONFLICT_PAGE){return;}
else if(currentPage==self.CHOOSE_TYPE_PAGE){return;}
else{self.showSaveAndQuitDialog();return false;}}},id:'WikiaPhotoGalleryEditor',persistent:false,width:self.editor.width});},loadThumbnail:function(imageName,node){this.ajax('getThumbnail',{imageName:imageName},function(data){node.removeClass('WikiaPhotoGalleryProgress').attr('title',imageName).html(data.thumbnail);});},showAlert:function(title,msg){var id='WikiaPhotoGalleryAlert';var html='<p>'+msg+'</p>'+'<div class="modalToolbar neutral"><a id="'+id+'Ok" class="wikia-button"><span>Ok</span></a></div>';$.showModal(title,html,{callbackBefore:function(){$('#'+id+'Ok').click(function(){$('#'+id).closeModal();});},id:id});},JSONtoWikiTextInner:function(data){HTML='';if(typeof data.params.showrecentuploads==='undefined'||data.params.showrecentuploads!=='true'){for(img in data.images){var imageData=data.images[img];if(imageData.recentlyUploaded){continue;}
if(typeof imageData.name=='undefined'){continue;}
HTML+=imageData.name;if(imageData.caption!=''){HTML+='|'+imageData.caption;}
if(imageData.link!=''){HTML+='|link='+imageData.link;}
if((this.isSlideshow()||this.isSlider())&&imageData.linktext!=''){HTML+='|linktext='+imageData.linktext;}
HTML+='\n';}}
return HTML;},JSONtoWikiText:function(data){var HTML='<gallery';var isSlideshow=this.isSlideshow();if(isSlideshow){data.params['type']='slideshow';}else if(this.isSlider()){data.params['type']='slider';}
$.each(data.params,function(key,value){WikiaPhotoGallery.log([key,value]);switch(key){case'widths':if(isSlideshow&&value==300){return;}
if(!isSlideshow&&value==185){return;}
break;case'position':if(isSlideshow&&value=='right'){return;}
if(!isSlideshow&&value=='left'){return;}
break;case'captionalign':if(value=='left'){return;}
break;}
if(value!=''){HTML+=' '+key+'="'+value+'"';}});HTML+='>\n';HTML+=this.JSONtoWikiTextInner(data);HTML+='</gallery>';return HTML;},insertTags:function(txtarea,tagOpen,tagClose,sampleText){var selText,isSample=false;txtarea=$(txtarea)[0];if(document.selection&&document.selection.createRange){if(document.documentElement&&document.documentElement.scrollTop)
var winScroll=document.documentElement.scrollTop
else if(document.body)
var winScroll=document.body.scrollTop;txtarea.focus();var range=document.selection.createRange();selText=range.text;checkSelectedText();range.text=tagOpen+selText+tagClose;if(isSample&&range.moveStart){if(window.opera)
tagClose=tagClose.replace(/\n/g,'');range.moveStart('character',-tagClose.length-selText.length);range.moveEnd('character',-tagClose.length);}
range.select();if(document.documentElement&&document.documentElement.scrollTop)
document.documentElement.scrollTop=winScroll
else if(document.body)
document.body.scrollTop=winScroll;}else if(txtarea.selectionStart||txtarea.selectionStart=='0'){var textScroll=txtarea.scrollTop;txtarea.focus();var startPos=txtarea.selectionStart;var endPos=txtarea.selectionEnd;selText=txtarea.value.substring(startPos,endPos);checkSelectedText();txtarea.value=txtarea.value.substring(0,startPos)
+tagOpen+selText+tagClose
+txtarea.value.substring(endPos,txtarea.value.length);if(isSample){txtarea.selectionStart=startPos+tagOpen.length;txtarea.selectionEnd=startPos+tagOpen.length+selText.length;}else{txtarea.selectionStart=startPos+tagOpen.length+selText.length+tagClose.length;txtarea.selectionEnd=txtarea.selectionStart;}
txtarea.scrollTop=textScroll;}
function checkSelectedText(){if(!selText){selText=sampleText;isSample=true;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);tagClose+=' '}}},getEditarea:function(){if(typeof window.RTE=='undefined'){var control=document.getElementById('wpTextbox1');}else{var control=RTE.getInstance().textarea.$;}
return control;},getCaretPosition:function(){var control=this.getEditarea();var caretPos=0;if(jQuery.browser.msie){control.focus();var sel=document.selection.createRange();var sel2=sel.duplicate();sel2.moveToElementText(control);var caretPos=-1;while(sel2.inRange(sel)){sel2.moveStart('character');caretPos++;}}
else if(control.selectionStart||control.selectionStart=='0'){caretPos=control.selectionStart;}
return caretPos;},track:(function(){var config={action:Wikia.Tracker.ACTIONS.CLICK,trackingMethod:'analytics'},slice=[].slice;return function(){var type=WikiaPhotoGallery.editor.gallery.type;config.category=(type==3?'slider':type==2?'slideshow':'gallery')+'-tool';Wikia.trackEditorComponent.apply(null,[config].concat(slice.call(arguments)));};})()};window.WikiaPhotoGallery=WikiaPhotoGallery;})(this,jQuery);;$.getEvent=function(e,boundEl){var ev=e||window.event;if(!ev){var c=this.getEvent.caller;while(c){ev=c.arguments[0];if(ev&&Event==ev.constructor){break;}
c=c.caller;}}
return ev;};var WMU_modal=null,WMU_curSourceId=0,WMU_lastQuery=[],WMU_jqXHR={abort:function(){}},WMU_curScreen='Main',WMU_prevScreen=null,WMU_slider=null,WMU_thumbSize=null,WMU_orgThumbSize=null,WMU_width=null,WMU_height=null,WMU_exactWidth=null,WMU_exactHeight=null,WMU_aspectRatio=null,WMU_refid=null,WMU_wysiwygStart=1,WMU_ratio=1,WMU_shownMax=false,WMU_gallery=-1,WMU_align=0,WMU_thumb=0,WMU_size=0,WMU_caption=0,WMU_link=0,WMU_box=-1,WMU_skipDetails=false,WMU_openedInEditor=true;if(typeof WMU_box_filled=='undefined'){WMU_box_filled=[];}
if('view'==wgAction){window.wmu_back='',window.wmu_imagebutton='',window.wmu_close='',window.wmu_warn1='',window.wmu_warn2='',window.wmu_warn3='',window.wmu_bad_extension='',window.wmu_show_message='',window.wmu_hide_message='',window.wmu_title='',window.wmu_max_thumb='',window.wmu_no_protect='',window.wmu_no_rights='',window.badfilename='',window.file_extensions='',window.file_blacklist='',window.check_file_extensions='',window.strict_file_extensions='',window.user_blocked=false,window.user_disallowed=false,window.user_protected=false;}
function WMU_ajax(method,data,callback){var url=window.wgScriptPath+'/index.php?action=ajax&rs=WMU&method='+encodeURIComponent(method);data=data||{};data.token=window.mw.user.tokens.get('editToken');WMU_jqXHR.abort();WMU_jqXHR=$.post(url,data,callback);}
function WMU_setSkip(){WMU_skipDetails=true;}
function WMU_getRTETxtarea(){return WikiaEditor.getInstance().getEditbox()[0];}
function WMU_loadDetails(){$('#ImageUploadMain').hide();WMU_indicator(1,true);var callback=function(responseText){WMU_displayDetails(responseText);$('#ImageUploadBack').hide();setTimeout(function(){if(!FCK.wysiwygData[WMU_refid].thumb){$('#ImageUploadThumbOption').prop('checked',false);$('#ImageUploadFullOption').prop('checked',true);}
if(FCK.wysiwygData[WMU_refid].align&&FCK.wysiwygData[WMU_refid].align=='left'){$('#ImageUploadLayoutLeft').prop('checked',true);$('#ImageUploadLayoutRight').prop('checked',false);}
if(FCK.wysiwygData[WMU_refid].width){WMU_slider.setValue(FCK.wysiwygData[WMU_refid].width/(WMU_slider.getRealValue()/WMU_slider.getValue()),true);MWU_imageWidthChanged();$('#ImageUploadSlider').css('visibility','visible');$('#ImageUploadInputWidth').css('visibility','visible');$('#ImageUploadSliderThumb').css('visibility','visible');$('#ImageUploadWidthCheckbox').attr('checked',true);$('#ImageUploadManualWidth').val(WMU_slider.getRealValue());if(WMU_thumbSize){$('#ImageUploadThumb').children(':first').width(WMU_thumbSize[0]).height(WMU_thumbSize[1]);}
$('#ImageUploadManualWidth').val(FCK.wysiwygData[WMU_refid].width);WMU_manualWidthInput();}},100);if(FCK.wysiwygData[WMU_refid].caption){$('#ImageUploadCaption').val(FCK.wysiwygData[WMU_refid].caption);}
if(FCK.wysiwygData[WMU_refid].link){$('#ImageUploadLink').val(FCK.wysiwygData[WMU_refid].link);}};WMU_ajax('chooseImage',{sourceId:0,itemId:FCK.wysiwygData[WMU_refid].href.split(":")[1]},callback);}
function WMU_moveBackButton(selector){if(window.skin!='oasis'){return;}
if(typeof window.WMUbackButton=='undefined'){var backButtonOriginal=$('#ImageUploadBack');var backButton=backButtonOriginal.clone();backButtonOriginal.css('visibility','hidden');backButton.removeAttr('id').remove();backButton=backButton.children('a').addClass('wikia-button yui-back secondary');backDetails=$(".ImageUploadNoBorder a.backbutton");if(backDetails.length>0){backButton.empty().append(backDetails.text());}
window.WMUbackButton=backButton;}
$('.yui-back').remove();window.WMUbackButton.clone().click(WMU_back).insertBefore(selector);}
function WMU_licenseSelectorCheck(){var selector=document.getElementById("ImageUploadLicense");var selection=selector.options[selector.selectedIndex].value;if(selector.selectedIndex>0){if(selection==""){selector.selectedIndex=0;}}
WMU_loadLicense(selection);}
function WMU_manualWidthInput(){var image=$('#ImageUploadThumb').children(':first');var val=parseInt($('#ImageUploadManualWidth').val());if(isNaN(val)){return false;}
if(!window.WMU_orgThumbSize){WMU_orgThumbSize=[image.width,image.height];}
WMU_ratio=WMU_width/WMU_height;if(val>WMU_width){if(!WMU_shownMax){image.width(WMU_width);image.height(WMU_width/WMU_ratio);WMU_thumbSize=[image.width(),image.height()];$('#ImageUploadManualWidth').val(image.width());WMU_readjustSlider(image.width());WMU_shownMax=true;}}else{image.height(val/WMU_ratio);image.width(val);WMU_thumbSize=[image.width(),image.height()];$('#ImageUploadManualWidth').val(val);WMU_readjustSlider(val);WMU_shownMax=false;}
if($("#ImageUploadWidthCheckbox").val()=="false"){$("#ImageUploadWidthCheckbox").val("true").attr('checked',true);}}
function WMU_readjustSlider(value){if(400<value){$('#ImageUploadSliderThumb').css('visibility','hidden');WMU_slider.setValue(200,true,true,true);}else{$('#ImageUploadSliderThumb').css('visibility','visible');var fixed_width=Math.min(400,WMU_width);value=Math.max(2,Math.round((value*200)/fixed_width));WMU_slider.setValue(value,true,true,true);}}
function WMU_loadMainFromView(){var callback=function(data){if(data.wmu_init_login){var fe=$.Event('FakeEvent');openLogin(fe);return;}
var element=document.createElement('div');element.id='WMU_div';element.style.width='722px';element.style.height='587px';wmu_back=unescape(data.wmu_back);wmu_imagebutton=unescape(data.wmu_imagebutton);wmu_close=unescape(data.wmu_close);wmu_warn1=unescape(data.wmu_warn1);wmu_warn2=unescape(data.wmu_warn2);wmu_warn3=unescape(data.wmu_warn3);wmu_bad_extension=unescape(data.wmu_bad_extension);wmu_show_message=unescape(data.wmu_show_message);wmu_hide_message=unescape(data.wmu_hide_message);wmu_title=unescape(data.wmu_title);wmu_max_thumb=unescape(data.wmu_max_thumb);wmu_no_protect=unescape(data.wmu_no_protect);wmu_no_rights=unescape(data.wmu_no_rights);badfilename=unescape(data.badfilename);file_extensions=data.file_extensions;file_blacklist=data.file_blacklist;check_file_extensions=data.check_file_extensions;strict_file_extensions=data.strict_file_extensions;user_blocked=data.user_blocked;user_disallowed=data.user_disallowed;user_protected=data.user_protected;if(user_blocked){document.location=wgScriptPath+'/index.php?title='+encodeURIComponent(wgTitle)+'&action=edit';}else{if(user_protected){alert(wmu_no_protect);return;}
if(user_disallowed){alert(wmu_no_rights);return;}
if(!$('#WMU_div').length){document.body.appendChild(element);}
WMU_modal=$(element).makeModal({onAfterClose:function(){WMU_switchScreen('Main');},persistent:true,width:722});$('#WMU_div').html(unescape(data.html));WMU_indicator(1,false);WMU_indicator(1,false);if($('#ImageQuery').length){$('#ImageQuery').focusNoScroll();}
var cookieMsg=document.cookie.indexOf("wmumainmesg=");if(cookieMsg>-1&&document.cookie.charAt(cookieMsg+12)==0){$('#ImageUploadTextCont').hide();$('#ImageUploadMessageLink').html('['+wmu_show_message+']');}}}
$.getJSON(wgScriptPath+'/index.php?action=ajax&rs=WMU&method=loadMainFromView&article='+encodeURIComponent(wgTitle)+'&ns='+wgNamespaceNumber,callback);WMU_curSourceId=0;}
function WMU_show(event,options){var track=options&&options.track;WMU_track({action:Wikia.Tracker.ACTIONS.OPEN});if(!track&&event&&event.data&&event.data.track){track=event.data.track;}
if(track){Wikia.Tracker.track({action:track.action||Wikia.Tracker.ACTIONS.OPEN,category:track.category||'vet',label:track.label||'',value:track.value||null,trackingMethod:track.method||'analytics'});}
WMU_openedInEditor=true;if(wgUserName==null&&wgAction=='edit'){UserLogin.rteForceLogin();return;}else if(UserLogin.isForceLogIn()){return;}
if(window.WikiaEditor){var wikiaEditor=WikiaEditor.getInstance();if(wikiaEditor.config.isMiniEditor){wikiaEditor.plugins.MiniEditor.hasFocus=true;}}
WMU_refid=null;WMU_wysiwygStart=1;WMU_gallery=-1;if(options&&options.gallery){if($('#editform').length&&(typeof event!='number')){alert(wmu_no_preview);return false;}
WMU_gallery=options.gallery;WMU_box=options.box;if(options.align){WMU_align=options.align;}
if(options.thumb){WMU_thumb=options.thumb;}
if(options.size){WMU_size=options.size;}
if(options.caption){WMU_caption=options.caption;}
if(options.link){WMU_link=options.link;}}
if(typeof event=='number'){WMU_refid=event;if(WMU_refid!=-1){if((typeof(FCK)!='undefined')&&FCK.wysiwygData[WMU_refid].exists){WMU_wysiwygStart=2;}else{}}}else if(typeof event=='object'){if(typeof event.type!='undefined'&&event.type=='rte'){window.WMU_RTEImage=event.data.element;if(window.WMU_RTEImage){var data=window.WMU_RTEImage.getData();if(event.data.isPlaceholder){RTE.log('image placeholder clicked');WMU_gallery=-2;}
else{data.href='File:'+data.title;data.thumb=data.params.thumbnail;$.extend(data,data.params);delete data.params;WMU_wysiwygStart=2;}
WMU_refid=0;window.FCK={wysiwygData:{0:{}}};window.FCK.wysiwygData[0]=data;}
else{WMU_refid=-1;}}}
$('#header_ad').css('display','none');if(WMU_modal!=null){WMU_modal.showModal();if(WMU_refid!=null&&WMU_wysiwygStart==2){WMU_loadDetails();}else{if($('#ImageQuery').length){$('#ImageQuery').focusNoScroll();}}
return;}
if(-1!=WMU_gallery){WMU_loadMainFromView();}else{var html='<div id="WMU_div" style="width:722px;height:587px;">';html+='<div class="reset" id="ImageUpload">';html+=' <div id="ImageUploadBorder"></div>';html+=' <div id="ImageUploadProgress1" class="ImageUploadProgress"></div>';html+='       <div id="ImageUploadBack"><img src="'+wgBlankImgUrl+'" id="fe_wmuback_img" class="sprite back" alt="'+wmu_back+'" /><a href="#">'+wmu_back+'</a></div>';html+=' <div id="ImageUploadBody">';html+='  <div id="ImageUploadError"></div>';html+='  <div id="ImageUploadMain"></div>';html+='  <div id="ImageUploadDetails" style="display: none;"></div>';html+='  <div id="ImageUploadConflict" style="display: none;"></div>';html+='  <div id="ImageUploadSummary" style="display: none;"></div>';html+=' </div>';html+='</div>';html+='</div>';WMU_modal=$(html).makeModal({onAfterClose:function(){WMU_switchScreen('Main');},persistent:true,width:722});if(WMU_refid!=null&&WMU_wysiwygStart==2){WMU_loadDetails();}else{WMU_loadMain();}}
$('#ImageUploadBack').click(WMU_back);}
function WMU_loadMain(){var callback=function(html){$('#ImageUploadMain').html(html);WMU_indicator(1,false);if($('#ImageQuery').length&&$('#ImageQuery').is(':visible')){$('#ImageQuery').focusNoScroll();}
var cookieMsg=document.cookie.indexOf("wmumainmesg=");if(cookieMsg>-1&&document.cookie.charAt(cookieMsg+12)==0){$('#ImageUploadTextCont').hide();$('#ImageUploadMessageLink').html('['+wmu_show_message+']');}}
WMU_indicator(1,true);baseUrl=wgScriptPath+'/index.php?action=ajax&rs=WMU&method=loadMain';if(WMU_exactHeight!=null){baseUrl=baseUrl+'&exactHeight='+WMU_exactHeight;}
if(WMU_exactWidth!=null){baseUrl=baseUrl+'&exactWidth='+WMU_exactWidth;}
if(WMU_aspectRatio!=null){baseUrl=baseUrl+'&aspectRatio='+WMU_aspectRatio;}
$.get(baseUrl,callback);WMU_curSourceId=0;}
function WMU_loadLicense(license){if(license==""){$('#ImageUploadLicenseText').html("");}else{var title='File:Sample.jpg';var url=wgScriptPath+'/api'+wgScriptExtension
+'?action=parse&text={{'+encodeURIComponent(license)+'}}'
+'&title='+encodeURIComponent(title)
+'&prop=text&pst&format=json';var callback=function(o){var o=eval('('+o.responseText+')');$('#ImageUploadLicenseText').html(o['parse']['text']['*']);WMU_indicator(1,false);}
WMU_track({label:'upload-licensing-dropdown'});WMU_indicator(1,true);$.ajax(url,{method:'get',complete:callback});}
WMU_curSourceId=0;}
function WMU_recentlyUploaded(param,pagination){var callback=function(html){$('#WMU_results_0').html(html);WMU_indicator(2,false);};WMU_track({label:'paginate-'+pagination});if(WMU_exactHeight){param=(param.length>0?param+'&':'')+'exactHeight='+WMU_exactHeight;}
if(WMU_exactWidth){param=(param.length>0?param+'&':'')+'exactWidth='+WMU_exactWidth;}
WMU_indicator(2,true);$.get(wgScriptPath+'/index.php?action=ajax&rs=WMU&method=recentlyUploaded&'+param,callback);}
function WMU_changeSource(e){e.preventDefault();var el=e.target;if(el.nodeName=='A'){var sourceId=el.id.substring(11);if(WMU_curSourceId!=sourceId){$('#WMU_source_'+WMU_curSourceId).css('fontWeight','');$('#WMU_source_'+sourceId).css('fontWeight','bold');$('#WMU_results_'+WMU_curSourceId).hide();$('#WMU_results_'+sourceId).show();if($('#ImageQuery').length){$('#ImageQuery').focusNoScroll();}
WMU_track({label:sourceId==0?'find-this-wiki':'find-flickr'});WMU_curSourceId=sourceId;WMU_trySendQuery();}}}
function WMU_trySendQuery(e){if(e&&e.type=="keydown"){if(e.keyCode!=13){return;}}
var query=$('#ImageQuery').val();if(!e&&WMU_lastQuery[WMU_curSourceId]==query){return;}
if(query==''){if(e){alert(wmu_warn1);}}else{WMU_sendQuery(query,1,WMU_curSourceId);}}
function WMU_sendQuery(query,page,sourceId,pagination){var callback=function(o){$('#WMU_results_'+sourceId).html(o.responseText);WMU_indicator(2,false);};WMU_track({label:'button-find'});WMU_lastQuery[sourceId]=query;WMU_indicator(2,true);WMU_jqXHR.abort();WMU_jqXHR=$.ajax(wgScriptPath+'/index.php?action=ajax&rs=WMU&method=query&'+'query='+query+'&page='+page+'&sourceId='+sourceId,{method:'get',complete:callback});}
function WMU_indicator(id,show){if(show){if(id==1){$('#ImageUploadProgress1').show();}else if(id==2){$('#ImageUploadProgress2').css('visibility','visible');}}else{if(id==1){$('#ImageUploadProgress1').hide();}else if(id==2){$('#ImageUploadProgress2').css('visibility','hidden');}}}
function WMU_chooseImage(sourceId,itemId){WMU_track({label:'add-recent-photo'});WMU_indicator(1,true);WMU_ajax('chooseImage',{sourceId:sourceId,itemId:itemId},function(resp){WMU_displayDetails(resp);});}
function WMU_upload(e){if($('#ImageUploadFile').val()==''){alert(wmu_warn2);return false;}else{if(WMU_initialCheck($('#ImageUploadFile').val())){WMU_track({label:'button-upload'});WMU_indicator(1,true);return true;}else{return false;}}}
function WMU_splitExtensions(filename){var bits=filename.split('.');var basename=bits.shift();return new Array(basename,bits);}
function WMU_in_array(elem,a_array){for(key in a_array){if(elem==a_array[key]){return true;}}
return false;}
function WMU_checkFileExtension(ext,list){return WMU_in_array(ext.toLowerCase(),list);}
function WMU_checkFileExtensionList(ext,list){for(elem in ext){if(WMU_in_array(ext[elem].toLowerCase(),list)){return true;}}
return false;}
function WMU_initialCheck(checkedName){var list_array=WMU_splitExtensions(checkedName);var partname=list_array[0];var ext=list_array[1];if(ext.length>0){var finalExt=ext[ext.length-1];}else{var finalExt='';}
if(ext.lenght>1){for(i=0;i<ext.length;i++){partname+='.'+ext[i];}}
if(partname.lenght<1){alert(minlength1);return false;}
if(finalExt==''){alert(filetype_missing);return false;}else if(WMU_checkFileExtensionList(ext,file_blacklist)||(check_file_extensions&&strict_file_extensions&&!WMU_checkFileExtension(finalExt,file_extensions))){alert(wmu_bad_extension);return false;}
return true;}
function WMU_displayDetails(responseText){WMU_switchScreen('Details');WMU_width=null;$('#ImageUploadBack').css('display','inline');$('#ImageUpload'+WMU_curScreen).html(responseText);$('#ImageUploadLicense').bind('change',WMU_licenseSelectorCheck);$('#ImageUploadLayoutLeft').on('click',function(){WMU_track({label:'checkbox-alignment-left'});});$('#ImageUploadLayoutRight').on('click',function(){WMU_track({label:'checkbox-alignment-right'});});$('#WMU_showhide').click(function(event){event.preventDefault();if($(".advanced").is(":visible")){WMU_track({label:'upload-fewer-options'});$(".ImageUploadRight .chevron").removeClass("up");$(this).text($(this).data("more"));}else{WMU_track({label:'upload-more-options'});$(".ImageUploadRight .chevron").addClass("up");$(this).text($(this).data("fewer"));}
$(".ImageUploadRight .advanced").slideToggle("fast");});if(WMU_skipDetails){$('#ImageUpload'+WMU_curScreen).hide();$('#ImageUploadLayoutLeft').attr('checked',true);$('#ImageUploadFullOption').attr('checked',true);WMU_insertImage('skip');}else if($('#ImageUploadThumb').length){WMU_orgThumbSize=null;var image=$('#ImageUploadThumb').children(':first');if(null==WMU_width){WMU_width=$('#ImageRealWidth').val();WMU_height=$('#ImageRealHeight').val();}
var thumbSize=[image.width(),image.height()];WMU_orgThumbSize=null;WMU_slider=YAHOO.widget.Slider.getHorizSlider('ImageUploadSlider','ImageUploadSliderThumb',0,200);WMU_slider.initialRound=true;WMU_slider.getRealValue=function(){return Math.max(2,Math.round(this.getValue()*(thumbSize[0]/200)));}
WMU_slider.subscribe("change",function(offsetFromStart){$('#ImageUploadSliderThumb').css('visibility','visible');if(WMU_slider.initialRound){$('#ImageUploadManualWidth').val('');WMU_slider.initialRound=false;}else{$('#ImageUploadManualWidth').val(WMU_slider.getRealValue());if($("#ImageUploadWidthCheckbox").val()=="false"){$("#ImageUploadWidthCheckbox").val("true").attr('checked',true);}}
image.width(WMU_slider.getRealValue());$('#ImageUploadManualWidth').val(image.width());image.height(image.width()/(thumbSize[0]/thumbSize[1]));if(WMU_orgThumbSize==null){WMU_orgThumbSize=[image.width(),image.height()];WMU_ratio=WMU_width/WMU_height;}
WMU_thumbSize=[image.width(),image.height()];});if(image.width()<250){WMU_slider.setValue(200,true);}else{WMU_slider.setValue(125,true);}
$('#ImageLinkRow').hide();}
if($('#WMU_error_box').html()){alert($('#WMU_error_box').html());}
if(0<WMU_align){if(1==WMU_align){$('#ImageUploadLayoutLeft').attr('checked',true);}else{$('#ImageUploadLayoutRight').attr('checked',true);}}
if(0<WMU_size){$('#ImageUploadWidthCheckbox').click();$('#ImageUploadManualWidth').val(WMU_size);WMU_manualWidthInput();}
if(''!=WMU_caption){$('#ImageUploadCaption').val(WMU_caption);}
if(''!=WMU_link){$('#ImageUploadLink').val(WMU_link);}
if($('#ImageUploadLicenseText').length){var cookieMsg=document.cookie.indexOf("wmulicensemesg=");if(cookieMsg>-1&&document.cookie.charAt(cookieMsg+15)==0){$('#ImageUploadLicenseText').hide();$('#ImageUploadLicenseLink').html('['+wmu_show_license_message+']');}}
if(typeof(WMU_Event_OnLoadDetails)=="function"){setTimeout(function(){WMU_Event_OnLoadDetails();},100);}
WMU_indicator(1,false);}
function WMU_insertPlaceholder(box){WMU_box_filled.push(box);var to_update=$('#WikiaImagePlaceholder'+box);to_update.html($('#ImageUploadCode').html());$.post(wgServer+wgScript+'?title='+wgPageName+'&action=purge');}
function WMU_insertImage(type){var params=[];params.push('type='+type);params.push('mwname='+$('#ImageUploadMWname').val());params.push('tempid='+$('#ImageUploadTempid').val());if(WMU_exactHeight){params.push('exactHeight='+WMU_exactHeight);}
if(WMU_exactWidth){params.push('exactWidth='+WMU_exactWidth);}
if(WMU_aspectRatio){params.push('aspectRatio='+WMU_aspectRatio);}
var captionUpdateInput=$('#ImageUploadReplaceDefault');if(captionUpdateInput.is(':hidden')){params.push('update_caption='+captionUpdateInput.val());}else{var isCaptionUpdate=(captionUpdateInput.is(':checked'))?'on':'';params.push('update_caption='+isCaptionUpdate);}
if(type=='overwrite'){params.push('name='+encodeURIComponent($('#ImageUploadExistingName').val()));}else if(type=='rename'){if(''==$('#ImageUploadRenameName').val()){alert(wmu_warn3);return;}
params.push('name='+encodeURIComponent($('#ImageUploadRenameName').val())+'.'+$('#ImageUploadRenameExtension').val());}else{if($('#ImageUploadName').length){if(''==$('#ImageUploadName').val()){alert(wmu_warn3);return;}
var uploadName=$('#ImageUploadName').val();if(uploadName&&uploadName.indexOf('/')>0){var parts=$('#ImageUploadName').val().split('/');var lastname=parts.pop();$('#ImageUploadName').val(lastname);alert(badfilename.replace('$1',lastname));return;}
params.push('name='+encodeURIComponent($('#ImageUploadName').val())+'.'+$('#ImageUploadExtension').val());}}
if($('#ImageUploadLicense').length){params.push('ImageUploadLicense='+$('#ImageUploadLicense').val());}
if($('#ImageUploadExtraId').length){params.push('extraId='+$('#ImageUploadExtraId').val());}
if($('#ImageUploadThumb').length){if($('#ImageUploadThumbOption').is(':checked')){params.push('size=thumb');var width=parseInt($('#ImageUploadManualWidth').val());if(width>0){params.push('width='+width+'px');}}else{params.push('size=full');}
params.push('layout='+($('#ImageUploadLayoutLeft').is(':checked')?'left':'right'));params.push('caption='+encodeURIComponent($('#ImageUploadCaption').val()));params.push('slider='+$('#ImageUploadWidthCheckbox').val());}
var link=$('#ImageUploadLink').val();if(link!=''){params.push('link='+link);}
if(-1!=WMU_gallery){params.push('gallery='+WMU_gallery);params.push('box='+WMU_box_in_article());params.push('article='+encodeURIComponent(wgTitle));params.push('ns='+wgNamespaceNumber);if(WMU_refid!=null){params.push('ck=true');}}
if(-2==WMU_gallery){if(0==WMU_link){if($('#ImageUploadLink').length){if(''!=$('#ImageUploadLink').val()){params.push('link='+encodeURIComponent($('#ImageUploadLink').val()));}}}else{params.push('link='+WMU_link);}}
var callback=function(resp){var screenType=WMU_jqXHR.getResponseHeader('X-screen-type');if(typeof screenType=="undefined"){screenType=WMU_jqXHR.getResponseHeader('X-Screen-Type');}
switch($.trim(screenType)){case'error':resp=resp.replace(/<script.*script>/,"");alert(resp);WMU_switchScreen('Summary');break;case'conflict':WMU_switchScreen('Conflict');$('#ImageUpload'+WMU_curScreen).html(resp);break;case'summary':WMU_switchScreen('Summary');if(typeof RTE!=='undefined'){RTE.getInstanceEditor().getEditbox().focus();}
$('#ImageUploadBack').hide();$('#ImageUpload'+WMU_curScreen).html(resp);var event=jQuery.Event("imageUploadSummary");$("body").trigger(event,[$('#ImageUpload'+WMU_curScreen)]);if(event.isDefaultPrevented()){return false;}
var $responseHTML=$(resp),wmuData={imageTitle:$responseHTML.find('#ImageUploadFileName').val(),imageWikiText:$responseHTML.find('#ImageUploadTag').val()};$(window).trigger('WMU_addFromSpecialPage',[wmuData]);if(!WMU_openedInEditor){return false;}
if((WMU_refid==null)||(wgAction=="view")||(wgAction=="purge")){if(-2==WMU_gallery){WMU_insertPlaceholder(WMU_box);}else{insertTags($('#ImageUploadTag').val(),'','',WMU_getRTETxtarea());}}else{var wikitag=$('#ImageUploadTag').val();var options={};if($('#ImageUploadThumbOption').is(':checked')){options.thumb=1;}else{options.thumb=null;}
if($('#ImageUploadWidthCheckbox').is(':checked')){options.width=WMU_slider.getRealValue();}else{options.width=null;}
if($('#ImageUploadLayoutLeft').is(':checked')){options.align='left';}else{options.align=null;}
options.caption=$('#ImageUploadCaption').val();if(!options.thumb){options.link=$('#ImageUploadLink').val();}
if(typeof window.WMU_RTEImage!='undefined'){var image=window.WMU_RTEImage;options.thumbnail=options.thumb;delete options.thumb;if(image){RTE.mediaEditor.update(image,wikitag,options);}
else{RTE.mediaEditor.addImage(wikitag,options);}
var wikiaEditor=WikiaEditor.getInstance();if(wikiaEditor.config.isMiniEditor){wikiaEditor.plugins.MiniEditor.hasFocus=false;}}
else if(WMU_refid!=-1){if(-2==WMU_gallery){FCK.ProtectImageAdd(wikitag,options,WMU_refid);}else{FCK.ProtectImageUpdate(WMU_refid,wikitag,options);}}else{FCK.ProtectImageAdd(wikitag,options);}}
break;case'existing':WMU_displayDetails(resp);break;}
WMU_indicator(1,false);};if(type=='details'){WMU_track({label:'button-add-photo'});}
WMU_indicator(1,true);WMU_jqXHR.abort();WMU_jqXHR=$.post(wgScriptPath+'/index.php?action=ajax&rs=WMU&method=insertImage&'+params.join('&'),{token:window.mw.user.tokens.get('editToken')},callback);}
function WMU_box_in_article(){var box=WMU_box;for(var i=0;i<WMU_box_filled.length;i++){if(WMU_box>WMU_box_filled[i])
box--;}
return box;}
function MWU_imageWidthChanged(){}
function MWU_imageSizeChanged(size){$('#ImageWidthRow').css('display',size=='thumb'?'':'none');if($('#ImageUploadThumb').length){var image=$('#ImageUploadThumb').children(':first');WMU_track({label:'checkbox-size-'+size});if(size=='thumb'){image.width(WMU_thumbSize[0]);image.height(WMU_thumbSize[1]);$('#ImageUploadManualWidth').val(WMU_thumbSize[0]);$('#ImageLinkRow').hide();}else if(size=='full'){image.width(WMU_orgThumbSize[0]);image.height(WMU_orgThumbSize[1]);$('#ImageUploadManualWidth').val(WMU_orgThumbSize[0]);if(0==WMU_link){$('#ImageLinkRow').show();}}else{if(0==WMU_link){$('#ImageLinkRow').show();}}}}
function WMU_toggleLicenseMesg(e){e.preventDefault();if('none'==$('#ImageUploadLicenseText').css('display')){WMU_track({label:'upload-licensing-show'});$('#ImageUploadLicenseText').show();$('#ImageUploadLicenseLink').html('['+wmu_hide_license_message+']');document.cookie="wmulicensemesg=1";}else{WMU_track({label:'upload-licensing-hide'});$('#ImageUploadLicenseText').hide();$('#ImageUploadLicenseLink').html('['+wmu_show_license_message+']');document.cookie="wmulicensemesg=0";}}
function WMU_switchScreen(to){WMU_prevScreen=WMU_curScreen;WMU_curScreen=to;$('#ImageUpload'+WMU_prevScreen).hide();$('#ImageUpload'+WMU_curScreen).show();if(WMU_curScreen=='Main'){$('#ImageUploadBack').hide();WMU_loadMain();}
if((WMU_prevScreen=='Details'||WMU_prevScreen=='Conflict')&&WMU_curScreen=='Main'&&$('#ImageUploadName').length){$.get('GET',wgScriptPath+'/index.php?action=ajax&rs=WMU&method=clean&mwname='+$('#ImageUploadMWname').val()+'&tempid='+$('#ImageUploadTempid').val());}
if(window.skin=='oasis'){setTimeout(function(){$().log(to,'WMU_switchScreen');switch(to){case'Details':WMU_moveBackButton($(".ImageUploadLeft").find('input:last'));break;case'Conflict':WMU_moveBackButton($('#ImageUploadConflict').children('h1'));break;}},50);}
if(WMU_curScreen=="Summary"){WMU_close();}}
function WMU_back(e){e.preventDefault();WMU_track({label:'button-back'});if(WMU_curScreen=='Details'){WMU_switchScreen('Main');}else if(WMU_curScreen=='Conflict'&&WMU_prevScreen=='Details'){WMU_switchScreen('Details');}}
function WMU_close(e){if(e){e.preventDefault();}
WMU_track({action:Wikia.Tracker.ACTIONS.CLOSE});WMU_modal.hideModal();if(typeof window.RTE=='undefined'&&$('#wpTextbox1').length)$('#wpTextbox1').focus();WMU_switchScreen('Main');WMU_loadMain();$('#header_ad').css('display','block');if(window.WikiaEditor){var wikiaEditor=WikiaEditor.getInstance();if(wikiaEditor.config.isMiniEditor){wikiaEditor.editorFocus();wikiaEditor.plugins.MiniEditor.hasFocus=false;}}}
var WMU_uploadCallback={onComplete:function(response){WMU_displayDetails(response);}}
var WMU_track=Wikia.Tracker.buildTrackingFunction(Wikia.trackEditorComponent,{action:Wikia.Tracker.ACTIONS.CLICK,category:'photo-tool',trackingMethod:'analytics'});;(function($,undefined){$.ui=$.ui||{};if($.ui.version){return;}
$.extend($.ui,{version:"1.8.23",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});$.fn.extend({propAttr:$.fn.prop||$.fn.attr,_focus:$.fn.focus,focus:function(delay,fn){return typeof delay==="number"?this.each(function(){var elem=this;setTimeout(function(){$(elem).focus();if(fn){fn.call(elem);}},delay);}):this._focus.apply(this,arguments);},scrollParent:function(){var scrollParent;if(($.browser.msie&&(/(static|relative)/).test(this.css('position')))||(/absolute/).test(this.css('position'))){scrollParent=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test($.curCSS(this,'position',1))&&(/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));}).eq(0);}else{scrollParent=this.parents().filter(function(){return(/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));}).eq(0);}
return(/fixed/).test(this.css('position'))||!scrollParent.length?$(document):scrollParent;},zIndex:function(zIndex){if(zIndex!==undefined){return this.css("zIndex",zIndex);}
if(this.length){var elem=$(this[0]),position,value;while(elem.length&&elem[0]!==document){position=elem.css("position");if(position==="absolute"||position==="relative"||position==="fixed"){value=parseInt(elem.css("zIndex"),10);if(!isNaN(value)&&value!==0){return value;}}
elem=elem.parent();}}
return 0;},disableSelection:function(){return this.bind(($.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(event){event.preventDefault();});},enableSelection:function(){return this.unbind(".ui-disableSelection");}});if(!$("<a>").outerWidth(1).jquery){$.each(["Width","Height"],function(i,name){var side=name==="Width"?["Left","Right"]:["Top","Bottom"],type=name.toLowerCase(),orig={innerWidth:$.fn.innerWidth,innerHeight:$.fn.innerHeight,outerWidth:$.fn.outerWidth,outerHeight:$.fn.outerHeight};function reduce(elem,size,border,margin){$.each(side,function(){size-=parseFloat($.curCSS(elem,"padding"+this,true))||0;if(border){size-=parseFloat($.curCSS(elem,"border"+this+"Width",true))||0;}
if(margin){size-=parseFloat($.curCSS(elem,"margin"+this,true))||0;}});return size;}
$.fn["inner"+name]=function(size){if(size===undefined){return orig["inner"+name].call(this);}
return this.each(function(){$(this).css(type,reduce(this,size)+"px");});};$.fn["outer"+name]=function(size,margin){if(typeof size!=="number"){return orig["outer"+name].call(this,size);}
return this.each(function(){$(this).css(type,reduce(this,size,true,margin)+"px");});};});}
function focusable(element,isTabIndexNotNaN){var nodeName=element.nodeName.toLowerCase();if("area"===nodeName){var map=element.parentNode,mapName=map.name,img;if(!element.href||!mapName||map.nodeName.toLowerCase()!=="map"){return false;}
img=$("img[usemap=#"+mapName+"]")[0];return!!img&&visible(img);}
return(/input|select|textarea|button|object/.test(nodeName)?!element.disabled:"a"==nodeName?element.href||isTabIndexNotNaN:isTabIndexNotNaN)&&visible(element);}
function visible(element){return!$(element).parents().andSelf().filter(function(){return $.curCSS(this,"visibility")==="hidden"||$.expr.filters.hidden(this);}).length;}
$.extend($.expr[":"],{data:$.expr.createPseudo?$.expr.createPseudo(function(dataName){return function(elem){return!!$.data(elem,dataName);};}):function(elem,i,match){return!!$.data(elem,match[3]);},focusable:function(element){return focusable(element,!isNaN($.attr(element,"tabindex")));},tabbable:function(element){var tabIndex=$.attr(element,"tabindex"),isTabIndexNaN=isNaN(tabIndex);return(isTabIndexNaN||tabIndex>=0)&&focusable(element,!isTabIndexNaN);}});$(function(){var body=document.body,div=body.appendChild(div=document.createElement("div"));div.offsetHeight;$.extend(div.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});$.support.minHeight=div.offsetHeight===100;$.support.selectstart="onselectstart"in div;body.removeChild(div).style.display="none";});if(!$.curCSS){$.curCSS=$.css;}
$.extend($.ui,{plugin:{add:function(module,option,set){var proto=$.ui[module].prototype;for(var i in set){proto.plugins[i]=proto.plugins[i]||[];proto.plugins[i].push([option,set[i]]);}},call:function(instance,name,args){var set=instance.plugins[name];if(!set||!instance.element[0].parentNode){return;}
for(var i=0;i<set.length;i++){if(instance.options[set[i][0]]){set[i][1].apply(instance.element,args);}}}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b);},hasScroll:function(el,a){if($(el).css("overflow")==="hidden"){return false;}
var scroll=(a&&a==="left")?"scrollLeft":"scrollTop",has=false;if(el[scroll]>0){return true;}
el[scroll]=1;has=(el[scroll]>0);el[scroll]=0;return has;},isOverAxis:function(x,reference,size){return(x>reference)&&(x<(reference+size));},isOver:function(y,x,top,left,height,width){return $.ui.isOverAxis(y,top,height)&&$.ui.isOverAxis(x,left,width);}});})(jQuery);;(function($,undefined){if($.cleanData){var _cleanData=$.cleanData;$.cleanData=function(elems){for(var i=0,elem;(elem=elems[i])!=null;i++){try{$(elem).triggerHandler("remove");}catch(e){}}
_cleanData(elems);};}else{var _remove=$.fn.remove;$.fn.remove=function(selector,keepData){return this.each(function(){if(!keepData){if(!selector||$.filter(selector,[this]).length){$("*",this).add([this]).each(function(){try{$(this).triggerHandler("remove");}catch(e){}});}}
return _remove.call($(this),selector,keepData);});};}
$.widget=function(name,base,prototype){var namespace=name.split(".")[0],fullName;name=name.split(".")[1];fullName=namespace+"-"+name;if(!prototype){prototype=base;base=$.Widget;}
$.expr[":"][fullName]=function(elem){return!!$.data(elem,name);};$[namespace]=$[namespace]||{};$[namespace][name]=function(options,element){if(arguments.length){this._createWidget(options,element);}};var basePrototype=new base();basePrototype.options=$.extend(true,{},basePrototype.options);$[namespace][name].prototype=$.extend(true,basePrototype,{namespace:namespace,widgetName:name,widgetEventPrefix:$[namespace][name].prototype.widgetEventPrefix||name,widgetBaseClass:fullName},prototype);$.widget.bridge(name,$[namespace][name]);};$.widget.bridge=function(name,object){$.fn[name]=function(options){var isMethodCall=typeof options==="string",args=Array.prototype.slice.call(arguments,1),returnValue=this;options=!isMethodCall&&args.length?$.extend.apply(null,[true,options].concat(args)):options;if(isMethodCall&&options.charAt(0)==="_"){return returnValue;}
if(isMethodCall){this.each(function(){var instance=$.data(this,name),methodValue=instance&&$.isFunction(instance[options])?instance[options].apply(instance,args):instance;if(methodValue!==instance&&methodValue!==undefined){returnValue=methodValue;return false;}});}else{this.each(function(){var instance=$.data(this,name);if(instance){instance.option(options||{})._init();}else{$.data(this,name,new object(options,this));}});}
return returnValue;};};$.Widget=function(options,element){if(arguments.length){this._createWidget(options,element);}};$.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(options,element){$.data(element,this.widgetName,this);this.element=$(element);this.options=$.extend(true,{},this.options,this._getCreateOptions(),options);var self=this;this.element.bind("remove."+this.widgetName,function(){self.destroy();});this._create();this._trigger("create");this._init();},_getCreateOptions:function(){return $.metadata&&$.metadata.get(this.element[0])[this.widgetName];},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled "+"ui-state-disabled");},widget:function(){return this.element;},option:function(key,value){var options=key;if(arguments.length===0){return $.extend({},this.options);}
if(typeof key==="string"){if(value===undefined){return this.options[key];}
options={};options[key]=value;}
this._setOptions(options);return this;},_setOptions:function(options){var self=this;$.each(options,function(key,value){self._setOption(key,value);});return this;},_setOption:function(key,value){this.options[key]=value;if(key==="disabled"){this.widget()
[value?"addClass":"removeClass"](this.widgetBaseClass+"-disabled"+" "+"ui-state-disabled").attr("aria-disabled",value);}
return this;},enable:function(){return this._setOption("disabled",false);},disable:function(){return this._setOption("disabled",true);},_trigger:function(type,event,data){var prop,orig,callback=this.options[type];data=data||{};event=$.Event(event);event.type=(type===this.widgetEventPrefix?type:this.widgetEventPrefix+type).toLowerCase();event.target=this.element[0];orig=event.originalEvent;if(orig){for(prop in orig){if(!(prop in event)){event[prop]=orig[prop];}}}
this.element.trigger(event,data);return!($.isFunction(callback)&&callback.call(this.element[0],event,data)===false||event.isDefaultPrevented());}};})(jQuery);;(function($,undefined){$.ui=$.ui||{};var horizontalPositions=/left|center|right/,verticalPositions=/top|center|bottom/,center="center",support={},_position=$.fn.position,_offset=$.fn.offset;$.fn.position=function(options){if(!options||!options.of){return _position.apply(this,arguments);}
options=$.extend({},options);var target=$(options.of),targetElem=target[0],collision=(options.collision||"flip").split(" "),offset=options.offset?options.offset.split(" "):[0,0],targetWidth,targetHeight,basePosition;if(targetElem.nodeType===9){targetWidth=target.width();targetHeight=target.height();basePosition={top:0,left:0};}else if(targetElem.setTimeout){targetWidth=target.width();targetHeight=target.height();basePosition={top:target.scrollTop(),left:target.scrollLeft()};}else if(targetElem.preventDefault){options.at="left top";targetWidth=targetHeight=0;basePosition={top:options.of.pageY,left:options.of.pageX};}else{targetWidth=target.outerWidth();targetHeight=target.outerHeight();basePosition=target.offset();}
$.each(["my","at"],function(){var pos=(options[this]||"").split(" ");if(pos.length===1){pos=horizontalPositions.test(pos[0])?pos.concat([center]):verticalPositions.test(pos[0])?[center].concat(pos):[center,center];}
pos[0]=horizontalPositions.test(pos[0])?pos[0]:center;pos[1]=verticalPositions.test(pos[1])?pos[1]:center;options[this]=pos;});if(collision.length===1){collision[1]=collision[0];}
offset[0]=parseInt(offset[0],10)||0;if(offset.length===1){offset[1]=offset[0];}
offset[1]=parseInt(offset[1],10)||0;if(options.at[0]==="right"){basePosition.left+=targetWidth;}else if(options.at[0]===center){basePosition.left+=targetWidth/2;}
if(options.at[1]==="bottom"){basePosition.top+=targetHeight;}else if(options.at[1]===center){basePosition.top+=targetHeight/2;}
basePosition.left+=offset[0];basePosition.top+=offset[1];return this.each(function(){var elem=$(this),elemWidth=elem.outerWidth(),elemHeight=elem.outerHeight(),marginLeft=parseInt($.curCSS(this,"marginLeft",true))||0,marginTop=parseInt($.curCSS(this,"marginTop",true))||0,collisionWidth=elemWidth+marginLeft+
(parseInt($.curCSS(this,"marginRight",true))||0),collisionHeight=elemHeight+marginTop+
(parseInt($.curCSS(this,"marginBottom",true))||0),position=$.extend({},basePosition),collisionPosition;if(options.my[0]==="right"){position.left-=elemWidth;}else if(options.my[0]===center){position.left-=elemWidth/2;}
if(options.my[1]==="bottom"){position.top-=elemHeight;}else if(options.my[1]===center){position.top-=elemHeight/2;}
if(!support.fractions){position.left=Math.round(position.left);position.top=Math.round(position.top);}
collisionPosition={left:position.left-marginLeft,top:position.top-marginTop};$.each(["left","top"],function(i,dir){if($.ui.position[collision[i]]){$.ui.position[collision[i]][dir](position,{targetWidth:targetWidth,targetHeight:targetHeight,elemWidth:elemWidth,elemHeight:elemHeight,collisionPosition:collisionPosition,collisionWidth:collisionWidth,collisionHeight:collisionHeight,offset:offset,my:options.my,at:options.at});}});if($.fn.bgiframe){elem.bgiframe();}
elem.offset($.extend(position,{using:options.using}));});};$.ui.position={fit:{left:function(position,data){var win=$(window),over=data.collisionPosition.left+data.collisionWidth-win.width()-win.scrollLeft();position.left=over>0?position.left-over:Math.max(position.left-data.collisionPosition.left,position.left);},top:function(position,data){var win=$(window),over=data.collisionPosition.top+data.collisionHeight-win.height()-win.scrollTop();position.top=over>0?position.top-over:Math.max(position.top-data.collisionPosition.top,position.top);}},flip:{left:function(position,data){if(data.at[0]===center){return;}
var win=$(window),over=data.collisionPosition.left+data.collisionWidth-win.width()-win.scrollLeft(),myOffset=data.my[0]==="left"?-data.elemWidth:data.my[0]==="right"?data.elemWidth:0,atOffset=data.at[0]==="left"?data.targetWidth:-data.targetWidth,offset=-2*data.offset[0];position.left+=data.collisionPosition.left<0?myOffset+atOffset+offset:over>0?myOffset+atOffset+offset:0;},top:function(position,data){if(data.at[1]===center){return;}
var win=$(window),over=data.collisionPosition.top+data.collisionHeight-win.height()-win.scrollTop(),myOffset=data.my[1]==="top"?-data.elemHeight:data.my[1]==="bottom"?data.elemHeight:0,atOffset=data.at[1]==="top"?data.targetHeight:-data.targetHeight,offset=-2*data.offset[1];position.top+=data.collisionPosition.top<0?myOffset+atOffset+offset:over>0?myOffset+atOffset+offset:0;}}};if(!$.offset.setOffset){$.offset.setOffset=function(elem,options){if(/static/.test($.curCSS(elem,"position"))){elem.style.position="relative";}
var curElem=$(elem),curOffset=curElem.offset(),curTop=parseInt($.curCSS(elem,"top",true),10)||0,curLeft=parseInt($.curCSS(elem,"left",true),10)||0,props={top:(options.top-curOffset.top)+curTop,left:(options.left-curOffset.left)+curLeft};if('using'in options){options.using.call(elem,props);}else{curElem.css(props);}};$.fn.offset=function(options){var elem=this[0];if(!elem||!elem.ownerDocument){return null;}
if(options){return this.each(function(){$.offset.setOffset(this,options);});}
return _offset.call(this);};}
(function(){var body=document.getElementsByTagName("body")[0],div=document.createElement("div"),testElement,testElementParent,testElementStyle,offset,offsetTotal;testElement=document.createElement(body?"div":"body");testElementStyle={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"};if(body){jQuery.extend(testElementStyle,{position:"absolute",left:"-1000px",top:"-1000px"});}
for(var i in testElementStyle){testElement.style[i]=testElementStyle[i];}
testElement.appendChild(div);testElementParent=body||document.documentElement;testElementParent.insertBefore(testElement,testElementParent.firstChild);div.style.cssText="position: absolute; left: 10.7432222px; top: 10.432325px; height: 30px; width: 201px;";offset=$(div).offset(function(_,offset){return offset;}).offset();testElement.innerHTML="";testElementParent.removeChild(testElement);offsetTotal=offset.top+offset.left+(body?2000:0);support.fractions=offsetTotal>21&&offsetTotal<22;})();}(jQuery));;(function($,undefined){var requestIndex=0;$.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:false,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var self=this,doc=this.element[0].ownerDocument,suppressKeyPress;this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(event){if(self.options.disabled||self.element.propAttr("readOnly")){return;}
suppressKeyPress=false;var keyCode=$.ui.keyCode;switch(event.keyCode){case keyCode.PAGE_UP:self._move("previousPage",event);break;case keyCode.PAGE_DOWN:self._move("nextPage",event);break;case keyCode.UP:self._move("previous",event);event.preventDefault();break;case keyCode.DOWN:self._move("next",event);event.preventDefault();break;case keyCode.ENTER:case keyCode.NUMPAD_ENTER:if(self.menu.active){suppressKeyPress=true;event.preventDefault();}
case keyCode.TAB:if(!self.menu.active){return;}
self.menu.select(event);break;case keyCode.ESCAPE:self.element.val(self.term);self.close(event);break;default:clearTimeout(self.searching);self.searching=setTimeout(function(){if(self.term!=self.element.val()){self.selectedItem=null;self.search(null,event);}},self.options.delay);break;}}).bind("keypress.autocomplete",function(event){if(suppressKeyPress){suppressKeyPress=false;event.preventDefault();}}).bind("focus.autocomplete",function(){if(self.options.disabled){return;}
self.selectedItem=null;self.previous=self.element.val();}).bind("blur.autocomplete",function(event){if(self.options.disabled){return;}
clearTimeout(self.searching);self.closing=setTimeout(function(){self.close(event);self._change(event);},150);});this._initSource();this.response=function(){return self._response.apply(self,arguments);};this.menu=$("<ul></ul>").addClass("ui-autocomplete").appendTo($(this.options.appendTo||"body",doc)[0]).mousedown(function(event){var menuElement=self.menu.element[0];if(!$(event.target).closest(".ui-menu-item").length){setTimeout(function(){$(document).one('mousedown',function(event){if(event.target!==self.element[0]&&event.target!==menuElement&&!$.ui.contains(menuElement,event.target)){self.close();}});},1);}
setTimeout(function(){clearTimeout(self.closing);},13);}).menu({focus:function(event,ui){var item=ui.item.data("item.autocomplete");if(false!==self._trigger("focus",event,{item:item})){if(/^key/.test(event.originalEvent.type)){self.element.val(item.value);}}},selected:function(event,ui){var item=ui.item.data("item.autocomplete"),previous=self.previous;if(self.element[0]!==doc.activeElement){self.element.focus();self.previous=previous;setTimeout(function(){self.previous=previous;self.selectedItem=item;},1);}
if(false!==self._trigger("select",event,{item:item})){self.element.val(item.value);}
self.term=self.element.val();self.close(event);self.selectedItem=item;},blur:function(event,ui){if(self.menu.element.is(":visible")&&(self.element.val()!==self.term)){self.element.val(self.term);}}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu");if($.fn.bgiframe){this.menu.element.bgiframe();}
self.beforeunloadHandler=function(){self.element.removeAttr("autocomplete");};$(window).bind("beforeunload",self.beforeunloadHandler);},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup");this.menu.element.remove();$(window).unbind("beforeunload",this.beforeunloadHandler);$.Widget.prototype.destroy.call(this);},_setOption:function(key,value){$.Widget.prototype._setOption.apply(this,arguments);if(key==="source"){this._initSource();}
if(key==="appendTo"){this.menu.element.appendTo($(value||"body",this.element[0].ownerDocument)[0])}
if(key==="disabled"&&value&&this.xhr){this.xhr.abort();}},_initSource:function(){var self=this,array,url;if($.isArray(this.options.source)){array=this.options.source;this.source=function(request,response){response($.ui.autocomplete.filter(array,request.term));};}else if(typeof this.options.source==="string"){url=this.options.source;this.source=function(request,response){if(self.xhr){self.xhr.abort();}
self.xhr=$.ajax({url:url,data:request,dataType:"json",autocompleteRequest:++requestIndex,success:function(data,status){if(this.autocompleteRequest===requestIndex){response(data);}},error:function(){if(this.autocompleteRequest===requestIndex){response([]);}}});};}else{this.source=this.options.source;}},search:function(value,event){value=value!=null?value:this.element.val();this.term=this.element.val();if(value.length<this.options.minLength){return this.close(event);}
clearTimeout(this.closing);if(this._trigger("search",event)===false){return;}
return this._search(value);},_search:function(value){this.pending++;this.element.addClass("ui-autocomplete-loading");this.source({term:value},this.response);},_response:function(content){if(!this.options.disabled&&content&&content.length){content=this._normalize(content);this._suggest(content);this._trigger("open");}else{this.close();}
this.pending--;if(!this.pending){this.element.removeClass("ui-autocomplete-loading");}},close:function(event){clearTimeout(this.closing);if(this.menu.element.is(":visible")){this.menu.element.hide();this.menu.deactivate();this._trigger("close",event);}},_change:function(event){if(this.previous!==this.element.val()){this._trigger("change",event,{item:this.selectedItem});}},_normalize:function(items){if(items.length&&items[0].label&&items[0].value){return items;}
return $.map(items,function(item){if(typeof item==="string"){return{label:item,value:item};}
return $.extend({label:item.label||item.value,value:item.value||item.label},item);});},_suggest:function(items){var ul=this.menu.element.empty().zIndex(this.element.zIndex()+1);this._renderMenu(ul,items);this.menu.deactivate();this.menu.refresh();ul.show();this._resizeMenu();ul.position($.extend({of:this.element},this.options.position));if(this.options.autoFocus){this.menu.next(new $.Event("mouseover"));}},_resizeMenu:function(){var ul=this.menu.element;ul.outerWidth(Math.max(ul.width("").outerWidth()+1,this.element.outerWidth()));},_renderMenu:function(ul,items){var self=this;$.each(items,function(index,item){self._renderItem(ul,item);});},_renderItem:function(ul,item){return $("<li></li>").data("item.autocomplete",item).append($("<a></a>").text(item.label)).appendTo(ul);},_move:function(direction,event){if(!this.menu.element.is(":visible")){this.search(null,event);return;}
if(this.menu.first()&&/^previous/.test(direction)||this.menu.last()&&/^next/.test(direction)){this.element.val(this.term);this.menu.deactivate();return;}
this.menu[direction](event);},widget:function(){return this.menu.element;}});$.extend($.ui.autocomplete,{escapeRegex:function(value){return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");},filter:function(array,term){var matcher=new RegExp($.ui.autocomplete.escapeRegex(term),"i");return $.grep(array,function(value){return matcher.test(value.label||value.value||value);});}});}(jQuery));(function($){$.widget("ui.menu",{_create:function(){var self=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(event){if(!$(event.target).closest(".ui-menu-item a").length){return;}
event.preventDefault();self.select(event);});this.refresh();},refresh:function(){var self=this;var items=this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem");items.children("a").addClass("ui-corner-all").attr("tabindex",-1).mouseenter(function(event){self.activate(event,$(this).parent());}).mouseleave(function(){self.deactivate();});},activate:function(event,item){this.deactivate();if(this.hasScroll()){var offset=item.offset().top-this.element.offset().top,scroll=this.element.scrollTop(),elementHeight=this.element.height();if(offset<0){this.element.scrollTop(scroll+offset);}else if(offset>=elementHeight){this.element.scrollTop(scroll+offset-elementHeight+item.height());}}
this.active=item.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end();this._trigger("focus",event,{item:item});},deactivate:function(){if(!this.active){return;}
this.active.children("a").removeClass("ui-state-hover").removeAttr("id");this._trigger("blur");this.active=null;},next:function(event){this.move("next",".ui-menu-item:first",event);},previous:function(event){this.move("prev",".ui-menu-item:last",event);},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length;},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length;},move:function(direction,edge,event){if(!this.active){this.activate(event,this.element.children(edge));return;}
var next=this.active[direction+"All"](".ui-menu-item").eq(0);if(next.length){this.activate(event,next);}else{this.activate(event,this.element.children(edge));}},nextPage:function(event){if(this.hasScroll()){if(!this.active||this.last()){this.activate(event,this.element.children(".ui-menu-item:first"));return;}
var base=this.active.offset().top,height=this.element.height(),result=this.element.children(".ui-menu-item").filter(function(){var close=$(this).offset().top-base-height+$(this).height();return close<10&&close>-10;});if(!result.length){result=this.element.children(".ui-menu-item:last");}
this.activate(event,result);}else{this.activate(event,this.element.children(".ui-menu-item").filter(!this.active||this.last()?":first":":last"));}},previousPage:function(event){if(this.hasScroll()){if(!this.active||this.first()){this.activate(event,this.element.children(".ui-menu-item:last"));return;}
var base=this.active.offset().top,height=this.element.height();result=this.element.children(".ui-menu-item").filter(function(){var close=$(this).offset().top-base+height-$(this).height();return close<10&&close>-10;});if(!result.length){result=this.element.children(".ui-menu-item:first");}
this.activate(event,result);}else{this.activate(event,this.element.children(".ui-menu-item").filter(!this.active||this.first()?":last":":first"));}},hasScroll:function(){return this.element.height()<this.element[$.fn.prop?"prop":"attr"]("scrollHeight");},select:function(event){this._trigger("selected",event,{item:this.active});}});}(jQuery));;var Mustache=(typeof module!=="undefined"&&module.exports)||{};(function(exports){exports.name="mustache.js";exports.version="0.5.0-dev";exports.tags=["{{","}}"];exports.parse=parse;exports.compile=compile;exports.render=render;exports.clearCache=clearCache;exports.to_html=function(template,view,partials,send){var result=render(template,view,partials);if(typeof send==="function"){send(result);}else{return result;}};var _toString=Object.prototype.toString;var _isArray=Array.isArray;var _forEach=Array.prototype.forEach;var _trim=String.prototype.trim;var isArray;if(_isArray){isArray=_isArray;}else{isArray=function(obj){return _toString.call(obj)==="[object Array]";};}
var forEach;if(_forEach){forEach=function(obj,callback,scope){return _forEach.call(obj,callback,scope);};}else{forEach=function(obj,callback,scope){for(var i=0,len=obj.length;i<len;++i){callback.call(scope,obj[i],i,obj);}};}
var spaceRe=/^\s*$/;function isWhitespace(string){return spaceRe.test(string);}
var trim;if(_trim){trim=function(string){return string==null?"":_trim.call(string);};}else{var trimLeft,trimRight;if(isWhitespace("\xA0")){trimLeft=/^\s+/;trimRight=/\s+$/;}else{trimLeft=/^[\s\xA0]+/;trimRight=/[\s\xA0]+$/;}
trim=function(string){return string==null?"":String(string).replace(trimLeft,"").replace(trimRight,"");};}
var escapeMap={"&":"&amp;","<":"&lt;",">":"&gt;",'"':'&quot;',"'":'&#39;'};function escapeHTML(string){return String(string).replace(/&(?!\w+;)|[<>"']/g,function(s){return escapeMap[s]||s;});}
function debug(e,template,line,file){file=file||"<template>";var lines=template.split("\n"),start=Math.max(line-3,0),end=Math.min(lines.length,line+3),context=lines.slice(start,end);var c;for(var i=0,len=context.length;i<len;++i){c=i+start+1;context[i]=(c===line?" >> ":"    ")+context[i];}
e.template=template;e.line=line;e.file=file;e.message=[file+":"+line,context.join("\n"),"",e.message].join("\n");return e;}
function lookup(name,stack,defaultValue){if(name==="."){return stack[stack.length-1];}
var names=name.split(".");var lastIndex=names.length-1;var target=names[lastIndex];var value,context,i=stack.length,j,localStack;while(i){localStack=stack.slice(0);context=stack[--i];j=0;while(j<lastIndex){context=context[names[j++]];if(context==null){break;}
localStack.push(context);}
if(context&&typeof context==="object"&&target in context){value=context[target];break;}}
if(typeof value==="function"){value=value.call(localStack[localStack.length-1]);}
if(value==null){return defaultValue;}
return value;}
function renderSection(name,stack,callback,inverted){var buffer="";var value=lookup(name,stack);if(inverted){if(value==null||value===false||(isArray(value)&&value.length===0)){buffer+=callback();}}else if(isArray(value)){forEach(value,function(value){stack.push(value);buffer+=callback();stack.pop();});}else if(typeof value==="object"){stack.push(value);buffer+=callback();stack.pop();}else if(typeof value==="function"){var scope=stack[stack.length-1];var scopedRender=function(template){return render(template,scope);};buffer+=value.call(scope,callback(),scopedRender)||"";}else if(value){buffer+=callback();}
return buffer;}
function parse(template,options){options=options||{};var tags=options.tags||exports.tags,openTag=tags[0],closeTag=tags[tags.length-1];var code=['var buffer = "";',"\nvar line = 1;","\ntry {",'\nbuffer += "'];var spaces=[],hasTag=false,nonSpace=false;var stripSpace=function(){if(hasTag&&!nonSpace&&!options.space){while(spaces.length){code.splice(spaces.pop(),1);}}else{spaces=[];}
hasTag=false;nonSpace=false;};var sectionStack=[],updateLine,nextOpenTag,nextCloseTag;var setTags=function(source){tags=trim(source).split(/\s+/);nextOpenTag=tags[0];nextCloseTag=tags[tags.length-1];};var includePartial=function(source){code.push('";',updateLine,'\nvar partial = partials["'+trim(source)+'"];','\nif (partial) {','\n  buffer += render(partial,stack[stack.length - 1],partials);','\n}','\nbuffer += "');};var openSection=function(source,inverted){var name=trim(source);if(name===""){throw debug(new Error("Section name may not be empty"),template,line,options.file);}
sectionStack.push({name:name,inverted:inverted});code.push('";',updateLine,'\nvar name = "'+name+'";','\nvar callback = (function () {','\n  return function () {','\n    var buffer = "";','\nbuffer += "');};var openInvertedSection=function(source){openSection(source,true);};var closeSection=function(source){var name=trim(source);var openName=sectionStack.length!=0&&sectionStack[sectionStack.length-1].name;if(!openName||name!=openName){throw debug(new Error('Section named "'+name+'" was never opened'),template,line,options.file);}
var section=sectionStack.pop();code.push('";','\n    return buffer;','\n  };','\n})();');if(section.inverted){code.push("\nbuffer += renderSection(name,stack,callback,true);");}else{code.push("\nbuffer += renderSection(name,stack,callback);");}
code.push('\nbuffer += "');};var sendPlain=function(source){code.push('";',updateLine,'\nbuffer += lookup("'+trim(source)+'",stack,"");','\nbuffer += "');};var sendEscaped=function(source){code.push('";',updateLine,'\nbuffer += escapeHTML(lookup("'+trim(source)+'",stack,""));','\nbuffer += "');};var line=1,c,callback;for(var i=0,len=template.length;i<len;++i){if(template.slice(i,i+openTag.length)===openTag){i+=openTag.length;c=template.substr(i,1);updateLine='\nline = '+line+';';nextOpenTag=openTag;nextCloseTag=closeTag;hasTag=true;switch(c){case"!":i++;callback=null;break;case"=":i++;closeTag="="+closeTag;callback=setTags;break;case">":i++;callback=includePartial;break;case"#":i++;callback=openSection;break;case"^":i++;callback=openInvertedSection;break;case"/":i++;callback=closeSection;break;case"{":closeTag="}"+closeTag;case"&":i++;nonSpace=true;callback=sendPlain;break;default:nonSpace=true;callback=sendEscaped;}
var end=template.indexOf(closeTag,i);if(end===-1){throw debug(new Error('Tag "'+openTag+'" was not closed properly'),template,line,options.file);}
var source=template.substring(i,end);if(callback){callback(source);}
var n=0;while(~(n=source.indexOf("\n",n))){line++;n++;}
i=end+closeTag.length-1;openTag=nextOpenTag;closeTag=nextCloseTag;}else{c=template.substr(i,1);switch(c){case'"':case"\\":nonSpace=true;code.push("\\"+c);break;case"\r":break;case"\n":spaces.push(code.length);code.push("\\n");stripSpace();line++;break;default:if(isWhitespace(c)){spaces.push(code.length);}else{nonSpace=true;}
code.push(c);}}}
if(sectionStack.length!=0){throw debug(new Error('Section "'+sectionStack[sectionStack.length-1].name+'" was not closed properly'),template,line,options.file);}
stripSpace();code.push('";',"\nreturn buffer;","\n} catch (e) { throw {error: e, line: line}; }");var body=code.join("").replace(/buffer \+= "";\n/g,"");if(options.debug){if(typeof console!="undefined"&&console.log){console.log(body);}else if(typeof print==="function"){print(body);}}
return body;}
function _compile(template,options){var args="view,partials,stack,lookup,escapeHTML,renderSection,render";var body=parse(template,options);var fn=new Function(args,body);return function(view,partials){partials=partials||{};var stack=[view];try{return fn(view,partials,stack,lookup,escapeHTML,renderSection,render);}catch(e){throw debug(e.error,template,e.line,options.file);}};}
var _cache={};function clearCache(){_cache={};}
function compile(template,options){options=options||{};if(options.cache!==false){if(!_cache[template]){_cache[template]=_compile(template,options);}
return _cache[template];}
return _compile(template,options);}
function render(template,view,partials){return compile(template)(view,partials);}})(Mustache);(function(context){context.Mustache=Mustache;if(context.define&&context.define.amd){context.define('wikia.mustache',Mustache);}}(window));;if(!window.CKEDITOR)
{window.CKEDITOR=(function()
{var CKEDITOR={timestamp:window.wgStyleVersion,version:'3.6.1',revision:'%REV%',_:{},status:'unloaded',basePath:(function()
{var path=window.CKEDITOR_BASEPATH||'';if(!path)
{var scripts=document.getElementsByTagName('script');for(var i=0;i<scripts.length;i++)
{var match=scripts[i].src.match(/(^|.*[\\\/])ckeditor(?:_basic)?(?:_source)?.js(?:\?.*)?$/i);if(match)
{path=match[1];break;}}}
if(path.indexOf(':/')==-1)
{if(path.indexOf('/')===0)
path=location.href.match(/^.*?:\/\/[^\/]*/)[0]+path;else
path=location.href.match(/^[^\?]*\/(?:)/)[0]+path;}
if(!path)
throw'The CKEditor installation path could not be automatically detected. Please set the global variable "CKEDITOR_BASEPATH" before creating editor instances.';return path;})(),getUrl:function(resource)
{if(resource.indexOf(':/')==-1&&resource.indexOf('/')!==0)
resource=this.basePath+resource;if(this.timestamp&&resource.charAt(resource.length-1)!='/'&&!(/[&?]t=/).test(resource))
resource+=(resource.indexOf('?')>=0?'&':'?')+'t='+this.timestamp;return resource;}};var newGetUrl=window.CKEDITOR_GETURL;if(newGetUrl)
{var originalGetUrl=CKEDITOR.getUrl;CKEDITOR.getUrl=function(resource)
{return newGetUrl.call(CKEDITOR,resource)||originalGetUrl.call(CKEDITOR,resource);};}
return CKEDITOR;})();};if(!CKEDITOR.event)
{CKEDITOR.event=function()
{};CKEDITOR.event.implementOn=function(targetObject)
{var eventProto=CKEDITOR.event.prototype;for(var prop in eventProto)
{if(targetObject[prop]==undefined)
targetObject[prop]=eventProto[prop];}};CKEDITOR.event.prototype=(function()
{var getPrivate=function(obj)
{var _=(obj.getPrivate&&obj.getPrivate())||obj._||(obj._={});return _.events||(_.events={});};var eventEntry=function(eventName)
{this.name=eventName;this.listeners=[];};eventEntry.prototype={getListenerIndex:function(listenerFunction)
{for(var i=0,listeners=this.listeners;i<listeners.length;i++)
{if(listeners[i].fn==listenerFunction)
return i;}
return-1;}};return{on:function(eventName,listenerFunction,scopeObj,listenerData,priority)
{var events=getPrivate(this),event=events[eventName]||(events[eventName]=new eventEntry(eventName));if(event.getListenerIndex(listenerFunction)<0)
{var listeners=event.listeners;if(!scopeObj)
scopeObj=this;if(isNaN(priority))
priority=10;var me=this;var listenerFirer=function(editor,publisherData,stopFn,cancelFn)
{var ev={name:eventName,sender:this,editor:editor,data:publisherData,listenerData:listenerData,stop:stopFn,cancel:cancelFn,removeListener:function()
{me.removeListener(eventName,listenerFunction);}};listenerFunction.call(scopeObj,ev);return ev.data;};listenerFirer.fn=listenerFunction;listenerFirer.priority=priority;for(var i=listeners.length-1;i>=0;i--)
{if(listeners[i].priority<=priority)
{listeners.splice(i+1,0,listenerFirer);return;}}
listeners.unshift(listenerFirer);}},fire:(function()
{var stopped=false;var stopEvent=function()
{stopped=true;};var canceled=false;var cancelEvent=function()
{canceled=true;};return function(eventName,data,editor)
{var event=getPrivate(this)[eventName];var previousStopped=stopped,previousCancelled=canceled;stopped=canceled=false;if(event)
{var listeners=event.listeners;if(listeners.length)
{listeners=listeners.slice(0);for(var i=0;i<listeners.length;i++)
{var retData=listeners[i].call(this,editor,data,stopEvent,cancelEvent);if(typeof retData!='undefined')
data=retData;if(stopped||canceled)
break;}}}
var ret=canceled||(typeof data=='undefined'?false:data);stopped=previousStopped;canceled=previousCancelled;return ret;};})(),fireOnce:function(eventName,data,editor)
{var ret=this.fire(eventName,data,editor);delete getPrivate(this)[eventName];return ret;},removeListener:function(eventName,listenerFunction)
{var event=getPrivate(this)[eventName];if(event)
{var index=event.getListenerIndex(listenerFunction);if(index>=0)
event.listeners.splice(index,1);}},hasListeners:function(eventName)
{var event=getPrivate(this)[eventName];return(event&&event.listeners.length>0);}};})();};if(!CKEDITOR.editor)
{CKEDITOR.ELEMENT_MODE_NONE=0;CKEDITOR.ELEMENT_MODE_REPLACE=1;CKEDITOR.ELEMENT_MODE_APPENDTO=2;CKEDITOR.editor=function(instanceConfig,element,mode,data)
{this._={instanceConfig:instanceConfig,element:element,data:data};this.elementMode=mode||CKEDITOR.ELEMENT_MODE_NONE;CKEDITOR.event.call(this);this._init();};CKEDITOR.editor.replace=function(elementOrIdOrName,config)
{var element=elementOrIdOrName;if(typeof element!='object')
{element=document.getElementById(elementOrIdOrName);if(element&&element.tagName.toLowerCase()in{style:1,script:1,base:1,link:1,meta:1,title:1})
element=null;if(!element)
{var i=0,textareasByName=document.getElementsByName(elementOrIdOrName);while((element=textareasByName[i++])&&element.tagName.toLowerCase()!='textarea')
{}}
if(!element)
throw'[CKEDITOR.editor.replace] The element with id or name "'+elementOrIdOrName+'" was not found.';}
return new CKEDITOR.editor(config,element,CKEDITOR.ELEMENT_MODE_REPLACE);};CKEDITOR.editor.appendTo=function(elementOrId,config,data)
{var element=elementOrId;if(typeof element!='object')
{element=document.getElementById(elementOrId);if(!element)
throw'[CKEDITOR.editor.appendTo] The element with id "'+elementOrId+'" was not found.';}
return new CKEDITOR.editor(config,element,CKEDITOR.ELEMENT_MODE_APPENDTO,data);};CKEDITOR.editor.prototype={_init:function()
{var pending=CKEDITOR.editor._pending||(CKEDITOR.editor._pending=[]);pending.push(this);},fire:function(eventName,data)
{return CKEDITOR.event.prototype.fire.call(this,eventName,data,this);},fireOnce:function(eventName,data)
{return CKEDITOR.event.prototype.fireOnce.call(this,eventName,data,this);}};CKEDITOR.event.implementOn(CKEDITOR.editor.prototype,true);};if(!CKEDITOR.env)
{CKEDITOR.env=(function()
{var agent=navigator.userAgent.toLowerCase();var opera=window.opera;var env={ie:eval("/*@cc_on!@*/false"),opera:(!!opera&&opera.version),webkit:(agent.indexOf(' applewebkit/')>-1),air:(agent.indexOf(' adobeair/')>-1),mac:(agent.indexOf('macintosh')>-1),quirks:(document.compatMode=='BackCompat'),mobile:(agent.indexOf('mobile')>-1),isCustomDomain:function()
{if(!this.ie)
return false;var domain=document.domain,hostname=window.location.hostname;return domain!=hostname&&domain!=('['+hostname+']');},secure:location.protocol=='https:'};env.gecko=(navigator.product=='Gecko'&&!env.webkit&&!env.opera);if(!env.ie){eval('env.ie  = /*@cc_on!@*/false;');}
var version=0;if(env.ie)
{version=parseFloat(agent.match(/msie (\d+)/)[1]);env.ieVersion==version;env.ie8=!!document.documentMode;env.ie8Compat=document.documentMode==8;env.ie9Compat=document.documentMode==9;env.ie7Compat=((version==7&&!document.documentMode)||document.documentMode==7);env.ie6Compat=(version<7||env.quirks);}
if(env.gecko)
{var geckoRelease=agent.match(/rv:([\d\.]+)/);if(geckoRelease)
{env.geckoRelease=geckoRelease[1];geckoRelease=geckoRelease[1].split('.');version=geckoRelease[0]*10000+(geckoRelease[1]||0)*100+(geckoRelease[2]||0)*1;}}
if(env.opera)
version=parseFloat(opera.version());if(env.air)
version=parseFloat(agent.match(/ adobeair\/(\d+)/)[1]);if(env.webkit)
version=parseFloat(agent.match(/ applewebkit\/(\d+)/)[1]);env.version=version;env.isCompatible=!env.mobile&&((env.ie&&version>=6)||(env.gecko&&version>=10801)||(env.opera&&version>=9.5)||(env.air&&version>=1)||(env.webkit&&version>=522)||false);env.cssClass='cke_browser_'+(env.ie?'ie':env.gecko?'gecko':env.opera?'opera':env.webkit?'webkit':'unknown');if(env.quirks)
env.cssClass+=' cke_browser_quirks';if(env.ie)
{env.cssClass+=' cke_browser_ie'+(env.version<7?'6':env.version>=8?document.documentMode:'7');if(env.quirks)
env.cssClass+=' cke_browser_iequirks';}
if(env.gecko&&version<10900)
env.cssClass+=' cke_browser_gecko18';if(env.air)
env.cssClass+=' cke_browser_air';return env;})();};if(CKEDITOR.status=='unloaded')
{(function()
{CKEDITOR.event.implementOn(CKEDITOR);CKEDITOR.loadFullCore=function()
{if(CKEDITOR.status!='basic_ready')
{CKEDITOR.loadFullCore._load=1;return;}
delete CKEDITOR.loadFullCore;var script=document.createElement('script');script.type='text/javascript';script.src=CKEDITOR.basePath+'ckeditor.js';script.src=CKEDITOR.basePath+'ckeditor_source.js';document.getElementsByTagName('head')[0].appendChild(script);};CKEDITOR.loadFullCoreTimeout=0;CKEDITOR.replaceClass='ckeditor';CKEDITOR.replaceByClassEnabled=1;var createInstance=function(elementOrIdOrName,config,creationFunction,data)
{if(CKEDITOR.env.isCompatible)
{if(CKEDITOR.loadFullCore)
CKEDITOR.loadFullCore();var editor=creationFunction(elementOrIdOrName,config,data);CKEDITOR.add(editor);return editor;}
return null;};CKEDITOR.replace=function(elementOrIdOrName,config)
{return createInstance(elementOrIdOrName,config,CKEDITOR.editor.replace);};CKEDITOR.appendTo=function(elementOrId,config,data)
{return createInstance(elementOrId,config,CKEDITOR.editor.appendTo,data);};CKEDITOR.add=function(editor)
{var pending=this._.pending||(this._.pending=[]);pending.push(editor);};CKEDITOR.replaceAll=function()
{var textareas=document.getElementsByTagName('textarea');for(var i=0;i<textareas.length;i++)
{var config=null,textarea=textareas[i];if(!textarea.name&&!textarea.id)
continue;if(typeof arguments[0]=='string')
{var classRegex=new RegExp('(?:^|\\s)'+arguments[0]+'(?:$|\\s)');if(!classRegex.test(textarea.className))
continue;}
else if(typeof arguments[0]=='function')
{config={};if(arguments[0](textarea,config)===false)
continue;}
this.replace(textarea,config);}};(function()
{var onload=function()
{var loadFullCore=CKEDITOR.loadFullCore,loadFullCoreTimeout=CKEDITOR.loadFullCoreTimeout;if(CKEDITOR.replaceByClassEnabled)
CKEDITOR.replaceAll(CKEDITOR.replaceClass);CKEDITOR.status='basic_ready';if(loadFullCore&&loadFullCore._load)
loadFullCore();else if(loadFullCoreTimeout)
{setTimeout(function()
{if(CKEDITOR.loadFullCore)
CKEDITOR.loadFullCore();},loadFullCoreTimeout*1000);}};if(window.addEventListener)
window.addEventListener('load',onload,false);else if(window.attachEvent)
window.attachEvent('onload',onload);})();CKEDITOR.status='basic_loaded';})();};CKEDITOR.dom={};;(function()
{var functions=[];CKEDITOR.on('reset',function()
{functions=[];});CKEDITOR.tools={arrayCompare:function(arrayA,arrayB)
{if(!arrayA&&!arrayB)
return true;if(!arrayA||!arrayB||arrayA.length!=arrayB.length)
return false;for(var i=0;i<arrayA.length;i++)
{if(arrayA[i]!=arrayB[i])
return false;}
return true;},clone:function(obj)
{var clone;if(obj&&(obj instanceof Array))
{clone=[];for(var i=0;i<obj.length;i++)
clone[i]=this.clone(obj[i]);return clone;}
if(obj===null||(typeof(obj)!='object')||(obj instanceof String)||(obj instanceof Number)||(obj instanceof Boolean)||(obj instanceof Date)||(obj instanceof RegExp))
{return obj;}
clone=new obj.constructor();for(var propertyName in obj)
{var property=obj[propertyName];clone[propertyName]=this.clone(property);}
return clone;},capitalize:function(str)
{return str.charAt(0).toUpperCase()+str.substring(1).toLowerCase();},extend:function(target)
{var argsLength=arguments.length,overwrite,propertiesList;if(typeof(overwrite=arguments[argsLength-1])=='boolean')
argsLength--;else if(typeof(overwrite=arguments[argsLength-2])=='boolean')
{propertiesList=arguments[argsLength-1];argsLength-=2;}
for(var i=1;i<argsLength;i++)
{var source=arguments[i];for(var propertyName in source)
{if(overwrite===true||target[propertyName]==undefined)
{if(!propertiesList||(propertyName in propertiesList))
target[propertyName]=source[propertyName];}}}
return target;},prototypedCopy:function(source)
{var copy=function()
{};copy.prototype=source;return new copy();},isArray:function(object)
{return(!!object&&object instanceof Array);},isEmpty:function(object)
{for(var i in object)
{if(object.hasOwnProperty(i))
return false;}
return true;},cssStyleToDomStyle:(function()
{var test=document.createElement('div').style;var cssFloat=(typeof test.cssFloat!='undefined')?'cssFloat':(typeof test.styleFloat!='undefined')?'styleFloat':'float';return function(cssName)
{if(cssName=='float')
return cssFloat;else
{return cssName.replace(/-./g,function(match)
{return match.substr(1).toUpperCase();});}};})(),buildStyleHtml:function(css)
{css=[].concat(css);var item,retval=[];for(var i=0;i<css.length;i++)
{item=css[i];if(/@import|[{}]/.test(item))
retval.push('<style>'+item+'</style>');else
retval.push('<link type="text/css" rel=stylesheet href="'+item+'">');}
return retval.join('');},htmlEncode:function(text)
{var standard=function(text)
{var span=new CKEDITOR.dom.element('span');span.setText(text);return span.getHtml();};var fix1=(standard('\n').toLowerCase()=='<br>')?function(text)
{return standard(text).replace(/<br>/gi,'\n');}:standard;var fix2=(standard('>')=='>')?function(text)
{return fix1(text).replace(/>/g,'&gt;');}:fix1;var fix3=(standard('  ')=='&nbsp; ')?function(text)
{return fix2(text).replace(/&nbsp;/g,' ');}:fix2;this.htmlEncode=fix3;return this.htmlEncode(text);},htmlEncodeAttr:function(text)
{return text.replace(/"/g,'&quot;').replace(/</g,'&lt;').replace(/>/g,'&gt;');},getNextNumber:(function()
{var last=0;return function()
{return++last;};})(),getNextId:function()
{return'cke_'+this.getNextNumber();},override:function(originalFunction,functionBuilder)
{return functionBuilder(originalFunction);},setTimeout:function(func,milliseconds,scope,args,ownerWindow)
{if(!ownerWindow)
ownerWindow=window;if(!scope)
scope=ownerWindow;return ownerWindow.setTimeout(function()
{if(args)
func.apply(scope,[].concat(args));else
func.apply(scope);},milliseconds||0);},trim:(function()
{var trimRegex=/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g;return function(str)
{return str.replace(trimRegex,'');};})(),ltrim:(function()
{var trimRegex=/^[ \t\n\r]+/g;return function(str)
{return str.replace(trimRegex,'');};})(),rtrim:(function()
{var trimRegex=/[ \t\n\r]+$/g;return function(str)
{return str.replace(trimRegex,'');};})(),indexOf:(Array.prototype.indexOf)?function(array,entry)
{return array.indexOf(entry);}:function(array,entry)
{for(var i=0,len=array.length;i<len;i++)
{if(array[i]===entry)
return i;}
return-1;},bind:function(func,obj)
{return function(){return func.apply(obj,arguments);};},createClass:function(definition)
{var $=definition.$,baseClass=definition.base,privates=definition.privates||definition._,proto=definition.proto,statics=definition.statics;if(privates)
{var originalConstructor=$;$=function()
{var _=this._||(this._={});for(var privateName in privates)
{var priv=privates[privateName];_[privateName]=(typeof priv=='function')?CKEDITOR.tools.bind(priv,this):priv;}
originalConstructor.apply(this,arguments);};}
if(baseClass)
{$.prototype=this.prototypedCopy(baseClass.prototype);$.prototype.constructor=$;$.prototype.base=function()
{this.base=baseClass.prototype.base;baseClass.apply(this,arguments);this.base=arguments.callee;};}
if(proto)
this.extend($.prototype,proto,true);if(statics)
this.extend($,statics,true);return $;},addFunction:function(fn,scope)
{return functions.push(function()
{return fn.apply(scope||this,arguments);})-1;},removeFunction:function(ref)
{functions[ref]=null;},callFunction:function(ref)
{var fn=functions[ref];return fn&&fn.apply(window,Array.prototype.slice.call(arguments,1));},cssLength:(function()
{return function(length)
{return length+(!length||isNaN(Number(length))?'':'px');};})(),convertToPx:(function()
{var calculator;return function(cssLength)
{if(!calculator)
{calculator=CKEDITOR.dom.element.createFromHtml('<div style="position:absolute;left:-9999px;'+'top:-9999px;margin:0px;padding:0px;border:0px;"'+'></div>',CKEDITOR.document);CKEDITOR.document.getBody().append(calculator);}
if(!(/%$/).test(cssLength))
{calculator.setStyle('width',cssLength);return calculator.$.clientWidth;}
return cssLength;};})(),repeat:function(str,times)
{return new Array(times+1).join(str);},tryThese:function()
{var returnValue;for(var i=0,length=arguments.length;i<length;i++)
{var lambda=arguments[i];try
{returnValue=lambda();break;}
catch(e){}}
return returnValue;},genKey:function()
{return Array.prototype.slice.call(arguments).join('-');}};})();;CKEDITOR.dtd=(function()
{var X=CKEDITOR.tools.extend,A={isindex:1,fieldset:1},B={input:1,button:1,select:1,textarea:1,label:1},C=X({a:1},B),D=X({iframe:1},C),E={hr:1,ul:1,menu:1,div:1,section:1,header:1,footer:1,nav:1,article:1,aside:1,figure:1,dialog:1,hgroup:1,mark:1,time:1,meter:1,command:1,keygen:1,output:1,progress:1,audio:1,video:1,details:1,datagrid:1,datalist:1,blockquote:1,noscript:1,table:1,center:1,address:1,dir:1,pre:1,h5:1,dl:1,h4:1,noframes:1,h6:1,ol:1,h1:1,h3:1,h2:1},F={ins:1,del:1,script:1,style:1},G=X({b:1,acronym:1,bdo:1,'var':1,'#':1,abbr:1,code:1,br:1,i:1,cite:1,kbd:1,u:1,strike:1,s:1,tt:1,strong:1,q:1,samp:1,em:1,dfn:1,span:1,wbr:1},F),H=X({sub:1,img:1,object:1,sup:1,basefont:1,map:1,applet:1,font:1,big:1,small:1,mark:1},G),I=X({p:1},H),J=X({iframe:1},H,B),K={img:1,noscript:1,br:1,kbd:1,center:1,button:1,basefont:1,h5:1,h4:1,samp:1,h6:1,ol:1,h1:1,h3:1,h2:1,form:1,font:1,'#':1,select:1,menu:1,ins:1,abbr:1,label:1,code:1,table:1,script:1,cite:1,input:1,iframe:1,strong:1,textarea:1,noframes:1,big:1,small:1,span:1,hr:1,sub:1,bdo:1,'var':1,div:1,section:1,header:1,footer:1,nav:1,article:1,aside:1,figure:1,dialog:1,hgroup:1,mark:1,time:1,meter:1,menu:1,command:1,keygen:1,output:1,progress:1,audio:1,video:1,details:1,datagrid:1,datalist:1,object:1,sup:1,strike:1,dir:1,map:1,dl:1,applet:1,del:1,isindex:1,fieldset:1,ul:1,b:1,acronym:1,a:1,blockquote:1,i:1,u:1,s:1,tt:1,address:1,q:1,pre:1,p:1,em:1,dfn:1},L=X({a:1},J),M={tr:1},N={'#':1},O=X({param:1},K),P=X({form:1},A,D,E,I),Q={li:1},R={style:1,script:1},S={base:1,link:1,meta:1,title:1},T=X(S,R),U={head:1,body:1},V={html:1};var block={address:1,blockquote:1,center:1,dir:1,div:1,section:1,header:1,footer:1,nav:1,article:1,aside:1,figure:1,dialog:1,hgroup:1,time:1,meter:1,menu:1,command:1,keygen:1,output:1,progress:1,audio:1,video:1,details:1,datagrid:1,datalist:1,dl:1,fieldset:1,form:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,hr:1,isindex:1,noframes:1,ol:1,p:1,pre:1,table:1,ul:1};return{$nonBodyContent:X(V,U,S),$block:block,$blockLimit:{body:1,div:1,section:1,header:1,footer:1,nav:1,article:1,aside:1,figure:1,dialog:1,hgroup:1,time:1,meter:1,menu:1,command:1,keygen:1,output:1,progress:1,audio:1,video:1,details:1,datagrid:1,datalist:1,td:1,th:1,caption:1,form:1},$inline:L,$body:X({script:1,style:1},block),$cdata:{script:1,style:1},$empty:{area:1,base:1,br:1,col:1,hr:1,img:1,input:1,link:1,meta:1,param:1,wbr:1},$listItem:{dd:1,dt:1,li:1},$list:{ul:1,ol:1,dl:1},$nonEditable:{applet:1,button:1,embed:1,iframe:1,map:1,object:1,option:1,script:1,textarea:1,param:1,audio:1,video:1},$captionBlock:{caption:1,legend:1},$removeEmpty:{abbr:1,acronym:1,address:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,s:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,'var':1,mark:1},$tabIndex:{a:1,area:1,button:1,input:1,object:1,select:1,textarea:1},$tableContent:{caption:1,col:1,colgroup:1,tbody:1,td:1,tfoot:1,th:1,thead:1,tr:1},html:U,head:T,style:N,script:N,body:P,base:{},link:{},meta:{},title:N,col:{},tr:{td:1,th:1},img:{},colgroup:{col:1},noscript:P,td:P,br:{},wbr:{},th:P,center:P,kbd:L,button:X(I,E),basefont:{},h5:L,h4:L,samp:L,h6:L,ol:Q,h1:L,h3:L,option:N,h2:L,form:X(A,D,E,I),select:{optgroup:1,option:1},font:L,ins:L,menu:Q,abbr:L,label:L,table:{thead:1,col:1,tbody:1,tr:1,colgroup:1,caption:1,tfoot:1},code:L,tfoot:M,cite:L,li:P,input:{},iframe:P,strong:L,textarea:N,noframes:P,big:L,small:L,span:L,hr:{},dt:L,sub:L,optgroup:{option:1},param:{},bdo:L,'var':L,div:P,object:O,sup:L,dd:P,strike:L,area:{},dir:Q,map:X({area:1,form:1,p:1},A,F,E),applet:O,dl:{dt:1,dd:1},del:L,isindex:{},fieldset:X({legend:1},K),thead:M,ul:Q,acronym:L,b:L,a:J,blockquote:P,caption:L,i:L,u:L,tbody:M,s:L,address:X(D,I),tt:L,legend:L,q:L,pre:X(G,C),p:L,em:L,dfn:L,section:P,header:P,footer:P,nav:P,article:P,aside:P,figure:P,dialog:P,hgroup:P,mark:L,time:L,meter:L,menu:L,command:L,keygen:L,output:L,progress:O,audio:O,video:O,details:O,datagrid:O,datalist:O};})();;CKEDITOR.dom.event=function(domEvent)
{this.$=domEvent;};CKEDITOR.dom.event.prototype={getKey:function()
{return this.$.keyCode||this.$.which;},getKeystroke:function()
{var keystroke=this.getKey();if(this.$.ctrlKey||this.$.metaKey)
keystroke+=CKEDITOR.CTRL;if(this.$.shiftKey)
keystroke+=CKEDITOR.SHIFT;if(this.$.altKey)
keystroke+=CKEDITOR.ALT;return keystroke;},preventDefault:function(stopPropagation)
{var $=this.$;if($.preventDefault)
$.preventDefault();else
$.returnValue=false;if(stopPropagation)
this.stopPropagation();},stopPropagation:function()
{var $=this.$;if($.stopPropagation)
$.stopPropagation();else
$.cancelBubble=true;},getTarget:function()
{var rawNode=this.$.target||this.$.srcElement;return rawNode?new CKEDITOR.dom.node(rawNode):null;}};CKEDITOR.CTRL=0x110000;CKEDITOR.SHIFT=0x220000;CKEDITOR.ALT=0x440000;;CKEDITOR.dom.domObject=function(nativeDomObject)
{if(nativeDomObject)
{this.$=nativeDomObject;}};CKEDITOR.dom.domObject.prototype=(function()
{var getNativeListener=function(domObject,eventName)
{return function(domEvent)
{if(typeof CKEDITOR!='undefined')
domObject.fire(eventName,new CKEDITOR.dom.event(domEvent));};};return{getPrivate:function()
{var priv;if(!(priv=this.getCustomData('_')))
this.setCustomData('_',(priv={}));return priv;},on:function(eventName)
{var nativeListeners=this.getCustomData('_cke_nativeListeners');if(!nativeListeners)
{nativeListeners={};this.setCustomData('_cke_nativeListeners',nativeListeners);}
if(!nativeListeners[eventName])
{var listener=nativeListeners[eventName]=getNativeListener(this,eventName);if(this.$.attachEvent)
this.$.attachEvent('on'+eventName,listener);else if(this.$.addEventListener)
this.$.addEventListener(eventName,listener,!!CKEDITOR.event.useCapture);}
return CKEDITOR.event.prototype.on.apply(this,arguments);},removeListener:function(eventName)
{CKEDITOR.event.prototype.removeListener.apply(this,arguments);if(!this.hasListeners(eventName))
{var nativeListeners=this.getCustomData('_cke_nativeListeners');var listener=nativeListeners&&nativeListeners[eventName];if(listener)
{if(this.$.detachEvent)
this.$.detachEvent('on'+eventName,listener);else if(this.$.removeEventListener)
this.$.removeEventListener(eventName,listener,false);delete nativeListeners[eventName];}}},removeAllListeners:function()
{var nativeListeners=this.getCustomData('_cke_nativeListeners');for(var eventName in nativeListeners)
{var listener=nativeListeners[eventName];if(this.$.detachEvent)
this.$.detachEvent('on'+eventName,listener);else if(this.$.removeEventListener)
this.$.removeEventListener(eventName,listener,false);delete nativeListeners[eventName];}}};})();(function(domObjectProto)
{var customData={};CKEDITOR.on('reset',function()
{customData={};});domObjectProto.equals=function(object)
{return(object&&object.$===this.$);};domObjectProto.setCustomData=function(key,value)
{var expandoNumber=this.getUniqueId(),dataSlot=customData[expandoNumber]||(customData[expandoNumber]={});dataSlot[key]=value;return this;};domObjectProto.getCustomData=function(key)
{var expandoNumber=this.$['data-cke-expando'],dataSlot=expandoNumber&&customData[expandoNumber];return dataSlot&&dataSlot[key];};domObjectProto.removeCustomData=function(key)
{var expandoNumber=this.$['data-cke-expando'],dataSlot=expandoNumber&&customData[expandoNumber],retval=dataSlot&&dataSlot[key];if(typeof retval!='undefined')
delete dataSlot[key];return retval||null;};domObjectProto.clearCustomData=function()
{this.removeAllListeners();var expandoNumber=this.$['data-cke-expando'];expandoNumber&&delete customData[expandoNumber];};domObjectProto.getUniqueId=function()
{return this.$['data-cke-expando']||(this.$['data-cke-expando']=CKEDITOR.tools.getNextNumber());};CKEDITOR.event.implementOn(domObjectProto);})(CKEDITOR.dom.domObject.prototype);;CKEDITOR.dom.window=function(domWindow)
{CKEDITOR.dom.domObject.call(this,domWindow);};CKEDITOR.dom.window.prototype=new CKEDITOR.dom.domObject();CKEDITOR.tools.extend(CKEDITOR.dom.window.prototype,{focus:function()
{if(CKEDITOR.env.webkit&&this.$.parent)
this.$.parent.focus();this.$.focus();},getViewPaneSize:function()
{var doc=this.$.document,stdMode=doc.compatMode=='CSS1Compat';return{width:(stdMode?doc.documentElement.clientWidth:doc.body.clientWidth)||0,height:(stdMode?doc.documentElement.clientHeight:doc.body.clientHeight)||0};},getScrollPosition:function()
{var $=this.$;if('pageXOffset'in $)
{return{x:$.pageXOffset||0,y:$.pageYOffset||0};}
else
{var doc=$.document;return{x:doc.documentElement.scrollLeft||doc.body.scrollLeft||0,y:doc.documentElement.scrollTop||doc.body.scrollTop||0};}}});;CKEDITOR.dom.document=function(domDocument)
{CKEDITOR.dom.domObject.call(this,domDocument);};CKEDITOR.dom.document.prototype=new CKEDITOR.dom.domObject();CKEDITOR.tools.extend(CKEDITOR.dom.document.prototype,{appendStyleSheet:function(cssFileUrl)
{if(this.$.createStyleSheet)
this.$.createStyleSheet(cssFileUrl);else
{var link=new CKEDITOR.dom.element('link');link.setAttributes({rel:'stylesheet',type:'text/css',href:cssFileUrl});this.getHead().append(link);}},appendStyleText:function(cssStyleText)
{if(this.$.createStyleSheet)
{var styleSheet=this.$.createStyleSheet("");styleSheet.cssText=cssStyleText;}
else
{var style=new CKEDITOR.dom.element('style',this);style.append(new CKEDITOR.dom.text(cssStyleText,this));this.getHead().append(style);}},createElement:function(name,attribsAndStyles)
{var element=new CKEDITOR.dom.element(name,this);if(attribsAndStyles)
{if(attribsAndStyles.attributes)
element.setAttributes(attribsAndStyles.attributes);if(attribsAndStyles.styles)
element.setStyles(attribsAndStyles.styles);}
return element;},createText:function(text)
{return new CKEDITOR.dom.text(text,this);},focus:function()
{this.getWindow().focus();},getById:function(elementId)
{var $=this.$.getElementById(elementId);return $?new CKEDITOR.dom.element($):null;},getByAddress:function(address,normalized)
{var $=this.$.documentElement;for(var i=0;$&&i<address.length;i++)
{var target=address[i];if(!normalized)
{$=$.childNodes[target];continue;}
var currentIndex=-1;for(var j=0;j<$.childNodes.length;j++)
{var candidate=$.childNodes[j];if(normalized===true&&candidate.nodeType==3&&candidate.previousSibling&&candidate.previousSibling.nodeType==3)
{continue;}
currentIndex++;if(currentIndex==target)
{$=candidate;break;}}}
return $?new CKEDITOR.dom.node($):null;},getElementsByTag:function(tagName,namespace)
{if(!(CKEDITOR.env.ie&&!(document.documentMode>8))&&namespace)
tagName=namespace+':'+tagName;return new CKEDITOR.dom.nodeList(this.$.getElementsByTagName(tagName));},getHead:function()
{var head=this.$.getElementsByTagName('head')[0];if(!head)
head=this.getDocumentElement().append(new CKEDITOR.dom.element('head'),true);else
head=new CKEDITOR.dom.element(head);return(this.getHead=function()
{return head;})();},getBody:function()
{var body=new CKEDITOR.dom.element(this.$.body);return(this.getBody=function()
{return body;})();},getDocumentElement:function()
{var documentElement=new CKEDITOR.dom.element(this.$.documentElement);return(this.getDocumentElement=function()
{return documentElement;})();},getWindow:function()
{var win=new CKEDITOR.dom.window(this.$.parentWindow||this.$.defaultView);return(this.getWindow=function()
{return win;})();},write:function(html)
{this.$.open('text/html','replace');CKEDITOR.env.isCustomDomain()&&(this.$.domain=document.domain);this.$.write(html);this.$.close();}});;CKEDITOR.dom.node=function(domNode)
{if(domNode)
{switch(domNode.nodeType)
{case CKEDITOR.NODE_DOCUMENT:return new CKEDITOR.dom.document(domNode);case CKEDITOR.NODE_ELEMENT:return new CKEDITOR.dom.element(domNode);case CKEDITOR.NODE_TEXT:return new CKEDITOR.dom.text(domNode);}
CKEDITOR.dom.domObject.call(this,domNode);}
return this;};CKEDITOR.dom.node.prototype=new CKEDITOR.dom.domObject();CKEDITOR.NODE_ELEMENT=1;CKEDITOR.NODE_DOCUMENT=9;CKEDITOR.NODE_TEXT=3;CKEDITOR.NODE_COMMENT=8;CKEDITOR.NODE_DOCUMENT_FRAGMENT=11;CKEDITOR.POSITION_IDENTICAL=0;CKEDITOR.POSITION_DISCONNECTED=1;CKEDITOR.POSITION_FOLLOWING=2;CKEDITOR.POSITION_PRECEDING=4;CKEDITOR.POSITION_IS_CONTAINED=8;CKEDITOR.POSITION_CONTAINS=16;CKEDITOR.tools.extend(CKEDITOR.dom.node.prototype,{appendTo:function(element,toStart)
{element.append(this,toStart);return element;},clone:function(includeChildren,cloneId)
{var $clone=this.$.cloneNode(includeChildren);var removeIds=function(node)
{if(node.nodeType!=CKEDITOR.NODE_ELEMENT)
return;if(!cloneId)
node.removeAttribute('id',false);node.removeAttribute('data-cke-expando',false);if(includeChildren)
{var childs=node.childNodes;for(var i=0;i<childs.length;i++)
removeIds(childs[i]);}};removeIds($clone);return new CKEDITOR.dom.node($clone);},hasPrevious:function()
{return!!this.$.previousSibling;},hasNext:function()
{return!!this.$.nextSibling;},insertAfter:function(node)
{node.$.parentNode.insertBefore(this.$,node.$.nextSibling);return node;},insertBefore:function(node)
{node.$.parentNode.insertBefore(this.$,node.$);return node;},insertBeforeMe:function(node)
{this.$.parentNode.insertBefore(node.$,this.$);return node;},getAddress:function(normalized)
{var address=[];var $documentElement=this.getDocument().$.documentElement;var node=this.$;while(node&&node!=$documentElement)
{var parentNode=node.parentNode;if(parentNode)
{address.unshift(this.getIndex.call({$:node},normalized));}
node=parentNode;}
return address;},getDocument:function()
{return new CKEDITOR.dom.document(this.$.ownerDocument||this.$.parentNode.ownerDocument);},getIndex:function(normalized)
{var current=this.$,index=0;while((current=current.previousSibling))
{if(normalized&&current.nodeType==3&&(!current.nodeValue.length||(current.previousSibling&&current.previousSibling.nodeType==3)))
{continue;}
index++;}
return index;},getNextSourceNode:function(startFromSibling,nodeType,guard)
{if(guard&&!guard.call)
{var guardNode=guard;guard=function(node)
{return!node.equals(guardNode);};}
var node=(!startFromSibling&&this.getFirst&&this.getFirst()),parent;if(!node)
{if(this.type==CKEDITOR.NODE_ELEMENT&&guard&&guard(this,true)===false)
return null;node=this.getNext();}
while(!node&&(parent=(parent||this).getParent()))
{if(guard&&guard(parent,true)===false)
return null;node=parent.getNext();}
if(!node)
return null;if(guard&&guard(node)===false)
return null;if(nodeType&&nodeType!=node.type)
return node.getNextSourceNode(false,nodeType,guard);return node;},getPreviousSourceNode:function(startFromSibling,nodeType,guard)
{if(guard&&!guard.call)
{var guardNode=guard;guard=function(node)
{return!node.equals(guardNode);};}
var node=(!startFromSibling&&this.getLast&&this.getLast()),parent;if(!node)
{if(this.type==CKEDITOR.NODE_ELEMENT&&guard&&guard(this,true)===false)
return null;node=this.getPrevious();}
while(!node&&(parent=(parent||this).getParent()))
{if(guard&&guard(parent,true)===false)
return null;node=parent.getPrevious();}
if(!node)
return null;if(guard&&guard(node)===false)
return null;if(nodeType&&node.type!=nodeType)
return node.getPreviousSourceNode(false,nodeType,guard);return node;},getPrevious:function(evaluator)
{var previous=this.$,retval;do
{previous=previous.previousSibling;retval=previous&&new CKEDITOR.dom.node(previous);}
while(retval&&evaluator&&!evaluator(retval))
return retval;},getNext:function(evaluator)
{var next=this.$,retval;do
{next=next.nextSibling;retval=next&&new CKEDITOR.dom.node(next);}
while(retval&&evaluator&&!evaluator(retval))
return retval;},getParent:function()
{var parent=this.$.parentNode;return(parent&&parent.nodeType==1)?new CKEDITOR.dom.node(parent):null;},getParents:function(closerFirst)
{var node=this;var parents=[];do
{parents[closerFirst?'push':'unshift'](node);}
while((node=node.getParent()))
return parents;},getCommonAncestor:function(node)
{if(node.equals(this))
return this;if(node.contains&&node.contains(this))
return node;var start=this.contains?this:this.getParent();do
{if(start.contains(node))
return start;}
while((start=start.getParent()));return null;},getPosition:function(otherNode)
{var $=this.$;var $other=otherNode.$;if($.compareDocumentPosition)
return $.compareDocumentPosition($other);if($==$other)
return CKEDITOR.POSITION_IDENTICAL;if(this.type==CKEDITOR.NODE_ELEMENT&&otherNode.type==CKEDITOR.NODE_ELEMENT)
{if($.contains)
{if($.contains($other))
return CKEDITOR.POSITION_CONTAINS+CKEDITOR.POSITION_PRECEDING;if($other.contains($))
return CKEDITOR.POSITION_IS_CONTAINED+CKEDITOR.POSITION_FOLLOWING;}
if('sourceIndex'in $)
{return($.sourceIndex<0||$other.sourceIndex<0)?CKEDITOR.POSITION_DISCONNECTED:($.sourceIndex<$other.sourceIndex)?CKEDITOR.POSITION_PRECEDING:CKEDITOR.POSITION_FOLLOWING;}}
var addressOfThis=this.getAddress(),addressOfOther=otherNode.getAddress(),minLevel=Math.min(addressOfThis.length,addressOfOther.length);for(var i=0;i<=minLevel-1;i++)
{if(addressOfThis[i]!=addressOfOther[i])
{if(i<minLevel)
{return addressOfThis[i]<addressOfOther[i]?CKEDITOR.POSITION_PRECEDING:CKEDITOR.POSITION_FOLLOWING;}
break;}}
return(addressOfThis.length<addressOfOther.length)?CKEDITOR.POSITION_CONTAINS+CKEDITOR.POSITION_PRECEDING:CKEDITOR.POSITION_IS_CONTAINED+CKEDITOR.POSITION_FOLLOWING;},getAscendant:function(reference,includeSelf)
{var $=this.$,name;if(!includeSelf)
$=$.parentNode;while($)
{if($.nodeName&&(name=$.nodeName.toLowerCase(),(typeof reference=='string'?name==reference:name in reference)))
return new CKEDITOR.dom.node($);$=$.parentNode;}
return null;},hasAscendant:function(name,includeSelf)
{var $=this.$;if(!includeSelf)
$=$.parentNode;while($)
{if($.nodeName&&$.nodeName.toLowerCase()==name)
return true;$=$.parentNode;}
return false;},move:function(target,toStart)
{target.append(this.remove(),toStart);},remove:function(preserveChildren)
{var $=this.$;var parent=$.parentNode;if(parent)
{if(preserveChildren)
{for(var child;(child=$.firstChild);)
{parent.insertBefore($.removeChild(child),$);}}
parent.removeChild($);}
return this;},replace:function(nodeToReplace)
{this.insertBefore(nodeToReplace);nodeToReplace.remove();},trim:function()
{this.ltrim();this.rtrim();},ltrim:function()
{var child;while(this.getFirst&&(child=this.getFirst()))
{if(child.type==CKEDITOR.NODE_TEXT)
{var trimmed=CKEDITOR.tools.ltrim(child.getText()),originalLength=child.getLength();if(!trimmed)
{child.remove();continue;}
else if(trimmed.length<originalLength)
{child.split(originalLength-trimmed.length);this.$.removeChild(this.$.firstChild);}}
break;}},rtrim:function()
{var child;while(this.getLast&&(child=this.getLast()))
{if(child.type==CKEDITOR.NODE_TEXT)
{var trimmed=CKEDITOR.tools.rtrim(child.getText()),originalLength=child.getLength();if(!trimmed)
{child.remove();continue;}
else if(trimmed.length<originalLength)
{child.split(trimmed.length);this.$.lastChild.parentNode.removeChild(this.$.lastChild);}}
break;}
if(!CKEDITOR.env.ie&&!CKEDITOR.env.opera)
{child=this.$.lastChild;if(child&&child.type==1&&child.nodeName.toLowerCase()=='br')
{child.parentNode.removeChild(child);}}},findFormattableAncestor:function()
{var current=this;while(current)
{if(current.type==CKEDITOR.NODE_ELEMENT)
{if(current.is('body')||current.getCustomData('_cke_notReadOnly'))
break;if(current.getAttribute('contentEditable')=='false'){if(current.getAttribute('formatEditable')=='true'){return current;}}else if(current.getAttribute('contentEditable')=='true')
break;}
current=current.getParent();}
return false;},isReadOnlyNotFormattable:function()
{var current=this;while(current)
{if(current.type==CKEDITOR.NODE_ELEMENT)
{if(current.is('body')||current.getCustomData('_cke_notReadOnly'))
break;if(current.getAttribute('contentEditable')=='false'){if(current.getAttribute('formatEditable')!='true'){return current;}}else if(current.getAttribute('contentEditable')=='true')
break;}
current=current.getParent();}
return false;},isReadOnly:function()
{var current=this;while(current)
{if(current.type==CKEDITOR.NODE_ELEMENT)
{if(current.is('body')||!!current.data('cke-editable'))
break;if(current.getAttribute('contentEditable')=='false')
return current;else if(current.getAttribute('contentEditable')=='true')
break;}
current=current.getParent();}
return false;}});;CKEDITOR.dom.nodeList=function(nativeList)
{this.$=nativeList;};CKEDITOR.dom.nodeList.prototype={count:function()
{return this.$.length;},getItem:function(index)
{var $node=this.$[index];return $node?new CKEDITOR.dom.node($node):null;}};;CKEDITOR.dom.element=function(element,ownerDocument)
{if(typeof element=='string')
element=(ownerDocument?ownerDocument.$:document).createElement(element);CKEDITOR.dom.domObject.call(this,element);};CKEDITOR.dom.element.get=function(element)
{return element&&(element.$?element:new CKEDITOR.dom.element(element));};CKEDITOR.dom.element.prototype=new CKEDITOR.dom.node();CKEDITOR.dom.element.createFromHtml=function(html,ownerDocument)
{var temp=new CKEDITOR.dom.element('div',ownerDocument);temp.setHtml(html);return temp.getFirst().remove();};CKEDITOR.dom.element.setMarker=function(database,element,name,value)
{var id=element.getCustomData('list_marker_id')||(element.setCustomData('list_marker_id',CKEDITOR.tools.getNextNumber()).getCustomData('list_marker_id')),markerNames=element.getCustomData('list_marker_names')||(element.setCustomData('list_marker_names',{}).getCustomData('list_marker_names'));database[id]=element;markerNames[name]=1;return element.setCustomData(name,value);};CKEDITOR.dom.element.clearAllMarkers=function(database)
{for(var i in database)
CKEDITOR.dom.element.clearMarkers(database,database[i],1);};CKEDITOR.dom.element.clearMarkers=function(database,element,removeFromDatabase)
{var names=element.getCustomData('list_marker_names'),id=element.getCustomData('list_marker_id');for(var i in names)
element.removeCustomData(i);element.removeCustomData('list_marker_names');if(removeFromDatabase)
{element.removeCustomData('list_marker_id');delete database[id];}};CKEDITOR.tools.extend(CKEDITOR.dom.element.prototype,{type:CKEDITOR.NODE_ELEMENT,addClass:function(className)
{var c=this.$.className;if(c)
{var regex=new RegExp('(?:^|\\s)'+className+'(?:\\s|$)','');if(!regex.test(c))
c+=' '+className;}
this.$.className=c||className;},removeClass:function(className)
{var c=this.getAttribute('class');if(c)
{var regex=new RegExp('(?:^|\\s+)'+className+'(?=\\s|$)','i');if(regex.test(c))
{c=c.replace(regex,'').replace(/^\s+/,'');if(c)
this.setAttribute('class',c);else
this.removeAttribute('class');}}},hasClass:function(className)
{var regex=new RegExp('(?:^|\\s+)'+className+'(?=\\s|$)','');return regex.test(this.getAttribute('class'));},append:function(node,toStart)
{if(typeof node=='string')
node=this.getDocument().createElement(node);if(toStart)
this.$.insertBefore(node.$,this.$.firstChild);else
this.$.appendChild(node.$);return node;},appendHtml:function(html)
{if(!this.$.childNodes.length)
this.setHtml(html);else
{var temp=new CKEDITOR.dom.element('div',this.getDocument());temp.setHtml(html);temp.moveChildren(this);}},appendText:function(text)
{if(this.$.text!=undefined)
this.$.text+=text;else
this.append(new CKEDITOR.dom.text(text));},appendBogus:function()
{var lastChild=this.getLast();while(lastChild&&lastChild.type==CKEDITOR.NODE_TEXT&&!CKEDITOR.tools.rtrim(lastChild.getText()))
lastChild=lastChild.getPrevious();if(!lastChild||!lastChild.is||!lastChild.is('br'))
{var bogus=CKEDITOR.env.opera?this.getDocument().createText(''):this.getDocument().createElement('br');CKEDITOR.env.gecko&&bogus.setAttribute('type','_moz');this.append(bogus);}},breakParent:function(parent)
{var range=new CKEDITOR.dom.range(this.getDocument());range.setStartAfter(this);range.setEndAfter(parent);var docFrag=range.extractContents();range.insertNode(this.remove());docFrag.insertAfterNode(this);},contains:CKEDITOR.env.ie||CKEDITOR.env.webkit?function(node)
{var $=this.$;return node.type!=CKEDITOR.NODE_ELEMENT?$.contains(node.getParent().$):$!=node.$&&$.contains(node.$);}:function(node)
{return!!(this.$.compareDocumentPosition(node.$)&16);},focus:(function()
{function exec()
{try
{this.$.focus();}
catch(e)
{}}
return function(defer)
{if(defer)
CKEDITOR.tools.setTimeout(exec,100,this);else
exec.call(this);};})(),getHtml:function()
{var retval;try{retval=this.$.innerHTML;}catch(err){return"";}
return CKEDITOR.env.ie?retval.replace(/<\?[^>]*>/g,''):retval;},getOuterHtml:function()
{if(this.$.outerHTML)
{return this.$.outerHTML.replace(/<\?[^>]*>/,'');}
var tmpDiv=this.$.ownerDocument.createElement('div');tmpDiv.appendChild(this.$.cloneNode(true));return tmpDiv.innerHTML;},setHtml:function(html)
{return(this.$.innerHTML=html);},setText:function(text)
{CKEDITOR.dom.element.prototype.setText=(this.$.innerText!=undefined)?function(text)
{return this.$.innerText=text;}:function(text)
{return this.$.textContent=text;};return this.setText(text);},getAttribute:(function()
{var standard=function(name)
{return this.$.getAttribute(name,2);};if(CKEDITOR.env.ie&&(CKEDITOR.env.ie7Compat||CKEDITOR.env.ie6Compat))
{return function(name)
{switch(name)
{case'class':name='className';break;case'http-equiv':name='httpEquiv';break;case'name':return this.$.name;case'tabindex':var tabIndex=standard.call(this,name);if(tabIndex!==0&&this.$.tabIndex===0)
tabIndex=null;return tabIndex;break;case'checked':{var attr=this.$.attributes.getNamedItem(name),attrValue=attr.specified?attr.nodeValue:this.$.checked;return attrValue?'checked':null;}
case'hspace':case'value':return this.$[name];case'style':return this.$.style.cssText;}
return standard.call(this,name);};}
else
return standard;})(),getChildren:function()
{return new CKEDITOR.dom.nodeList(this.$.childNodes);},getComputedStyle:CKEDITOR.env.ie?function(propertyName)
{return this.$.currentStyle[CKEDITOR.tools.cssStyleToDomStyle(propertyName)];}:function(propertyName)
{return this.getWindow().$.getComputedStyle(this.$,'').getPropertyValue(propertyName);},getDtd:function()
{var dtd=CKEDITOR.dtd[this.getName()];this.getDtd=function()
{return dtd;};return dtd;},getElementsByTag:CKEDITOR.dom.document.prototype.getElementsByTag,getTabIndex:CKEDITOR.env.ie?function()
{var tabIndex=this.$.tabIndex;if(tabIndex===0&&!CKEDITOR.dtd.$tabIndex[this.getName()]&&parseInt(this.getAttribute('tabindex'),10)!==0)
tabIndex=-1;return tabIndex;}:CKEDITOR.env.webkit?function()
{var tabIndex=this.$.tabIndex;if(tabIndex==undefined)
{tabIndex=parseInt(this.getAttribute('tabindex'),10);if(isNaN(tabIndex))
tabIndex=-1;}
return tabIndex;}:function()
{return this.$.tabIndex;},getText:function()
{return this.$.textContent||this.$.innerText||'';},getWindow:function()
{return this.getDocument().getWindow();},getId:function()
{return this.$.id||null;},getNameAtt:function()
{return this.$.name||null;},getName:function()
{var nodeName=this.$.nodeName.toLowerCase();if(CKEDITOR.env.ie&&!(document.documentMode>8))
{var scopeName=this.$.scopeName;if(typeof scopeName!='undefined'&&scopeName!='HTML')
nodeName=scopeName.toLowerCase()+':'+nodeName;}
return(this.getName=function()
{return nodeName;})();},getValue:function()
{var value=this.$.value;return(CKEDITOR.env.ie&&this.$.getAttribute('placeholder')==value)?'':value;},getFirst:function(evaluator)
{var first=this.$.firstChild,retval=first&&new CKEDITOR.dom.node(first);if(retval&&evaluator&&!evaluator(retval))
retval=retval.getNext(evaluator);return retval;},getLast:function(evaluator)
{var last=this.$.lastChild,retval=last&&new CKEDITOR.dom.node(last);if(retval&&evaluator&&!evaluator(retval))
retval=retval.getPrevious(evaluator);return retval;},getStyle:function(name)
{return this.$.style[CKEDITOR.tools.cssStyleToDomStyle(name)];},is:function()
{var name=this.getName();for(var i=0;i<arguments.length;i++)
{if(arguments[i]==name)
return true;}
return false;},isEditable:function()
{if(this.isReadOnly())
return false;var name=this.getName();var dtd=!CKEDITOR.dtd.$nonEditable[name]&&(CKEDITOR.dtd[name]||CKEDITOR.dtd.span);return(dtd&&dtd['#']);},isIdentical:function(otherElement)
{if(this.getName()!=otherElement.getName())
return false;var thisAttribs=this.$.attributes,otherAttribs=otherElement.$.attributes;var thisLength=thisAttribs.length,otherLength=otherAttribs.length;for(var i=0;i<thisLength;i++)
{var attribute=thisAttribs[i];if(attribute.nodeName=='_moz_dirty')
continue;if((!CKEDITOR.env.ie||(attribute.specified&&attribute.nodeName!='data-cke-expando'))&&attribute.nodeValue!=otherElement.getAttribute(attribute.nodeName))
return false;}
if(CKEDITOR.env.ie)
{for(i=0;i<otherLength;i++)
{attribute=otherAttribs[i];if(attribute.specified&&attribute.nodeName!='data-cke-expando'&&attribute.nodeValue!=this.getAttribute(attribute.nodeName))
return false;}}
return true;},isVisible:function()
{var isVisible=!!this.$.offsetHeight&&this.getComputedStyle('visibility')!='hidden',elementWindow,elementWindowFrame;if(isVisible&&(CKEDITOR.env.webkit||CKEDITOR.env.opera))
{elementWindow=this.getWindow();if(!elementWindow.equals(CKEDITOR.document.getWindow())&&(elementWindowFrame=elementWindow.$.frameElement))
{isVisible=new CKEDITOR.dom.element(elementWindowFrame).isVisible();}}
return isVisible;},isEmptyInlineRemoveable:function()
{if(!CKEDITOR.dtd.$removeEmpty[this.getName()])
return false;var children=this.getChildren();for(var i=0,count=children.count();i<count;i++)
{var child=children.getItem(i);if(child.type==CKEDITOR.NODE_ELEMENT&&child.data('cke-bookmark'))
continue;if(child.type==CKEDITOR.NODE_ELEMENT&&!child.isEmptyInlineRemoveable()||child.type==CKEDITOR.NODE_TEXT&&CKEDITOR.tools.trim(child.getText()))
{return false;}}
return true;},hasAttributes:CKEDITOR.env.ie&&(CKEDITOR.env.ie7Compat||CKEDITOR.env.ie6Compat)?function()
{var attributes=this.$.attributes;for(var i=0;i<attributes.length;i++)
{var attribute=attributes[i];switch(attribute.nodeName)
{case'class':if(this.getAttribute('class'))
return true;case'data-cke-expando':continue;default:if(attribute.specified)
return true;}}
return false;}:function()
{var attrs=this.$.attributes,attrsNum=attrs.length;var execludeAttrs={'data-cke-expando':1,_moz_dirty:1};return attrsNum>0&&(attrsNum>2||!execludeAttrs[attrs[0].nodeName]||(attrsNum==2&&!execludeAttrs[attrs[1].nodeName]));},hasAttribute:(function()
{function standard(name)
{var $attr=this.$.attributes.getNamedItem(name);return!!($attr&&$attr.specified);}
return(CKEDITOR.env.ie&&CKEDITOR.env.version<8)?function(name)
{if(name=='name')
return!!this.$.name;return standard.call(this,name);}:standard;})(),hide:function()
{this.setStyle('display','none');},moveChildren:function(target,toStart)
{var $=this.$;target=target.$;if($==target)
return;var child;if(toStart)
{while((child=$.lastChild))
target.insertBefore($.removeChild(child),target.firstChild);}
else
{while((child=$.firstChild))
target.appendChild($.removeChild(child));}},mergeSiblings:(function()
{function mergeElements(element,sibling,isNext)
{if(sibling&&sibling.type==CKEDITOR.NODE_ELEMENT)
{var pendingNodes=[];while(sibling.data('cke-bookmark')||sibling.isEmptyInlineRemoveable())
{pendingNodes.push(sibling);sibling=isNext?sibling.getNext():sibling.getPrevious();if(!sibling||sibling.type!=CKEDITOR.NODE_ELEMENT)
return;}
if(element.isIdentical(sibling))
{var innerSibling=isNext?element.getLast():element.getFirst();while(pendingNodes.length)
pendingNodes.shift().move(element,!isNext);sibling.moveChildren(element,!isNext);sibling.remove();if(innerSibling&&innerSibling.type==CKEDITOR.NODE_ELEMENT)
innerSibling.mergeSiblings();}}}
return function(inlineOnly)
{if(!(inlineOnly===false||CKEDITOR.dtd.$removeEmpty[this.getName()]||this.is('a')))
{return;}
mergeElements(this,this.getNext(),true);mergeElements(this,this.getPrevious());};})(),show:function()
{this.setStyles({display:'',visibility:''});},setAttribute:(function()
{var standard=function(name,value)
{this.$.setAttribute(name,value);return this;};if(CKEDITOR.env.ie&&(CKEDITOR.env.ie7Compat||CKEDITOR.env.ie6Compat))
{return function(name,value)
{if(name=='class')
this.$.className=value;else if(name=='style')
this.$.style.cssText=value;else if(name=='tabindex')
this.$.tabIndex=value;else if(name=='checked')
this.$.checked=value;else
standard.apply(this,arguments);return this;};}
else if(CKEDITOR.env.ie8Compat&&CKEDITOR.env.secure)
{return function(name,value)
{if(name=='src'&&value.match(/^http:\/\//))
try{standard.apply(this,arguments);}catch(e){}
else
standard.apply(this,arguments);return this;};}
else
return standard;})(),setAttributes:function(attributesPairs)
{for(var name in attributesPairs)
this.setAttribute(name,attributesPairs[name]);return this;},setValue:function(value)
{this.$.value=value;return this;},removeAttribute:(function()
{var standard=function(name)
{this.$.removeAttribute(name);};if(CKEDITOR.env.ie&&(CKEDITOR.env.ie7Compat||CKEDITOR.env.ie6Compat))
{return function(name)
{if(name=='class')
name='className';else if(name=='tabindex')
name='tabIndex';standard.call(this,name);};}
else
return standard;})(),removeAttributes:function(attributes)
{if(CKEDITOR.tools.isArray(attributes))
{for(var i=0;i<attributes.length;i++)
this.removeAttribute(attributes[i]);}
else
{for(var attr in attributes)
attributes.hasOwnProperty(attr)&&this.removeAttribute(attr);}},removeStyle:function(name)
{this.setStyle(name,'');if(this.$.style.removeAttribute)
this.$.style.removeAttribute(CKEDITOR.tools.cssStyleToDomStyle(name));if(!this.$.style.cssText)
this.removeAttribute('style');},setStyle:function(name,value)
{this.$.style[CKEDITOR.tools.cssStyleToDomStyle(name)]=value;return this;},setStyles:function(stylesPairs)
{for(var name in stylesPairs)
this.setStyle(name,stylesPairs[name]);return this;},setOpacity:function(opacity)
{if(CKEDITOR.env.ie)
{opacity=Math.round(opacity*100);this.setStyle('filter',opacity>=100?'':'progid:DXImageTransform.Microsoft.Alpha(opacity='+opacity+')');}
else
this.setStyle('opacity',opacity);},unselectable:CKEDITOR.env.gecko?function()
{this.$.style.MozUserSelect='none';this.on('dragstart',function(evt){evt.data.preventDefault();});}:CKEDITOR.env.webkit?function()
{this.$.style.KhtmlUserSelect='none';this.on('dragstart',function(evt){evt.data.preventDefault();});}:function()
{if(CKEDITOR.env.ie||CKEDITOR.env.opera)
{var element=this.$,e,i=0;element.unselectable='on';while((e=element.all[i++]))
{switch(e.tagName.toLowerCase())
{case'iframe':case'textarea':case'input':case'select':break;default:e.unselectable='on';}}}},getPositionedAncestor:function()
{var current=this;while(current.getName()!='html')
{if(current.getComputedStyle('position')!='static')
return current;current=current.getParent();}
return null;},getDocumentPosition:function(refDocument)
{var x=0,y=0,body=this.getDocument().getBody(),quirks=this.getDocument().$.compatMode=='BackCompat';var doc=this.getDocument();if(document.documentElement["getBoundingClientRect"])
{var box=this.$.getBoundingClientRect(),$doc=doc.$,$docElem=$doc.documentElement;var clientTop=$docElem.clientTop||body.$.clientTop||0,clientLeft=$docElem.clientLeft||body.$.clientLeft||0,needAdjustScrollAndBorders=true;if(CKEDITOR.env.ie)
{var inDocElem=doc.getDocumentElement().contains(this),inBody=doc.getBody().contains(this);needAdjustScrollAndBorders=(quirks&&inBody)||(!quirks&&inDocElem);}
if(needAdjustScrollAndBorders)
{x=box.left+(!quirks&&$docElem.scrollLeft||body.$.scrollLeft);x-=clientLeft;y=box.top+(!quirks&&$docElem.scrollTop||body.$.scrollTop);y-=clientTop;}}
else
{var current=this,previous=null,offsetParent;while(current&&!(current.getName()=='body'||current.getName()=='html'))
{x+=current.$.offsetLeft-current.$.scrollLeft;y+=current.$.offsetTop-current.$.scrollTop;if(!current.equals(this))
{x+=(current.$.clientLeft||0);y+=(current.$.clientTop||0);}
var scrollElement=previous;while(scrollElement&&!scrollElement.equals(current))
{x-=scrollElement.$.scrollLeft;y-=scrollElement.$.scrollTop;scrollElement=scrollElement.getParent();}
previous=current;current=(offsetParent=current.$.offsetParent)?new CKEDITOR.dom.element(offsetParent):null;}}
if(refDocument)
{var currentWindow=this.getWindow(),refWindow=refDocument.getWindow();if(!currentWindow.equals(refWindow)&&currentWindow.$.frameElement)
{var iframePosition=(new CKEDITOR.dom.element(currentWindow.$.frameElement)).getDocumentPosition(refDocument);x+=iframePosition.x;y+=iframePosition.y;}}
if(!document.documentElement["getBoundingClientRect"])
{if(CKEDITOR.env.gecko&&!quirks)
{x+=this.$.clientLeft?1:0;y+=this.$.clientTop?1:0;}}
return{x:x,y:y};},scrollIntoView:function(alignTop)
{var win=this.getWindow(),winHeight=win.getViewPaneSize().height;var offset=winHeight*-1;if(alignTop)
offset+=winHeight;else
{offset+=this.$.offsetHeight||0;offset+=parseInt(this.getComputedStyle('marginBottom')||0,10)||0;}
var elementPosition=this.getDocumentPosition();offset+=elementPosition.y;offset=offset<0?0:offset;var currentScroll=win.getScrollPosition().y;if(offset>currentScroll||offset<currentScroll-winHeight)
win.$.scrollTo(0,offset);},setState:function(state)
{switch(state)
{case CKEDITOR.TRISTATE_ON:this.addClass('cke_on');this.removeClass('cke_off');this.removeClass('cke_disabled');break;case CKEDITOR.TRISTATE_DISABLED:this.addClass('cke_disabled');this.removeClass('cke_off');this.removeClass('cke_on');break;default:this.addClass('cke_off');this.removeClass('cke_on');this.removeClass('cke_disabled');break;}},getFrameDocument:function()
{var $=this.$;try
{$.contentWindow.document;}
catch(e)
{$.src=$.src;if(CKEDITOR.env.ie&&CKEDITOR.env.version<7)
{window.showModalDialog('javascript:document.write("'+'<script>'+'window.setTimeout('+'function(){window.close();}'+',50);'+'</script>")');}}
return $&&new CKEDITOR.dom.document($.contentWindow.document);},copyAttributes:function(dest,skipAttributes)
{var attributes=this.$.attributes;skipAttributes=skipAttributes||{};for(var n=0;n<attributes.length;n++)
{var attribute=attributes[n];var attrName=attribute.nodeName.toLowerCase(),attrValue;if(attrName in skipAttributes)
continue;if(attrName=='checked'&&(attrValue=this.getAttribute(attrName)))
dest.setAttribute(attrName,attrValue);else if(attribute.specified||(CKEDITOR.env.ie&&attribute.nodeValue&&attrName=='value'))
{attrValue=this.getAttribute(attrName);if(attrValue===null)
attrValue=attribute.nodeValue;dest.setAttribute(attrName,attrValue);}}
if(this.$.style.cssText!=='')
dest.$.style.cssText=this.$.style.cssText;},renameNode:function(newTag)
{if(this.getName()==newTag)
return;var doc=this.getDocument();var newNode=new CKEDITOR.dom.element(newTag,doc);this.copyAttributes(newNode);this.moveChildren(newNode);this.getParent()&&this.$.parentNode.replaceChild(newNode.$,this.$);newNode.$['data-cke-expando']=this.$['data-cke-expando'];this.$=newNode.$;},getChild:function(indices)
{var rawNode=this.$;if(!indices.slice)
rawNode=rawNode.childNodes[indices];else
{while(indices.length>0&&rawNode)
rawNode=rawNode.childNodes[indices.shift()];}
return rawNode?new CKEDITOR.dom.node(rawNode):null;},getChildCount:function()
{return this.$.childNodes.length;},disableContextMenu:function()
{this.on('contextmenu',function(event)
{if(!event.data.getTarget().hasClass('cke_enable_context_menu'))
event.data.preventDefault();});},getDirection:function(useComputed)
{return useComputed?this.getComputedStyle('direction')||this.getDirection()||this.getDocument().$.dir||this.getDocument().getBody().getDirection(1):this.getStyle('direction')||this.getAttribute('dir');},data:function(name,value)
{name='data-'+name;if(value===undefined)
return this.getAttribute(name);else if(value===false)
this.removeAttribute(name);else
this.setAttribute(name,value);return null;}});(function()
{var sides={width:["border-left-width","border-right-width","padding-left","padding-right"],height:["border-top-width","border-bottom-width","padding-top","padding-bottom"]};function marginAndPaddingSize(type)
{var adjustment=0;for(var i=0,len=sides[type].length;i<len;i++)
adjustment+=parseInt(this.getComputedStyle(sides[type][i])||0,10)||0;return adjustment;}
CKEDITOR.dom.element.prototype.setSize=function(type,size,isBorderBox)
{if(typeof size=='number')
{if(isBorderBox&&!(CKEDITOR.env.ie&&CKEDITOR.env.quirks))
size-=marginAndPaddingSize.call(this,type);this.setStyle(type,size+'px');}};CKEDITOR.dom.element.prototype.getSize=function(type,isBorderBox)
{var size=Math.max(this.$['offset'+CKEDITOR.tools.capitalize(type)],this.$['client'+CKEDITOR.tools.capitalize(type)])||0;if(isBorderBox)
size-=marginAndPaddingSize.call(this,type);return size;};})();;CKEDITOR.command=function(editor,commandDefinition)
{this.uiItems=[];this.exec=function(data)
{if(this.state==CKEDITOR.TRISTATE_DISABLED)
return false;if($.inArray(editor,RTE.loaded)<0){return false;}
if(this.editorFocus)
editor.focus();return(commandDefinition.exec.call(this,editor,data)!==false);};CKEDITOR.tools.extend(this,commandDefinition,{modes:{wysiwyg:1},editorFocus:1,state:CKEDITOR.TRISTATE_OFF});CKEDITOR.event.call(this);};CKEDITOR.command.prototype={enable:function()
{if(this.state==CKEDITOR.TRISTATE_DISABLED)
this.setState((!this.preserveState||(typeof this.previousState=='undefined'))?CKEDITOR.TRISTATE_OFF:this.previousState);},disable:function()
{this.setState(CKEDITOR.TRISTATE_DISABLED);},setState:function(newState)
{if(this.state==newState)
return false;this.previousState=this.state;this.state=newState;this.fire('state');return true;},toggleState:function()
{if(this.state==CKEDITOR.TRISTATE_OFF)
this.setState(CKEDITOR.TRISTATE_ON);else if(this.state==CKEDITOR.TRISTATE_ON)
this.setState(CKEDITOR.TRISTATE_OFF);}};CKEDITOR.event.implementOn(CKEDITOR.command.prototype,true);;CKEDITOR.ENTER_P=1;CKEDITOR.ENTER_BR=2;CKEDITOR.ENTER_DIV=3;CKEDITOR.config={customConfig:'config.js',autoUpdateElement:true,baseHref:'',contentsCss:CKEDITOR.basePath+'contents.css',contentsLangDirection:'ui',contentsLanguage:'',language:'',defaultLanguage:'en',enterMode:CKEDITOR.ENTER_P,forceEnterMode:false,shiftEnterMode:CKEDITOR.ENTER_BR,corePlugins:'',docType:'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',bodyId:'',bodyClass:'',fullPage:false,height:200,plugins:'about,'+'a11yhelp,'+'basicstyles,'+'bidi,'+'blockquote,'+'button,'+'clipboard,'+'colorbutton,'+'colordialog,'+'contextmenu,'+'dialogadvtab,'+'div,'+'elementspath,'+'enterkey,'+'entities,'+'filebrowser,'+'find,'+'flash,'+'font,'+'format,'+'forms,'+'horizontalrule,'+'htmldataprocessor,'+'iframe,'+'image,'+'indent,'+'justify,'+'keystrokes,'+'link,'+'list,'+'liststyle,'+'maximize,'+'newpage,'+'pagebreak,'+'pastefromword,'+'pastetext,'+'popup,'+'preview,'+'print,'+'removeformat,'+'resize,'+'save,'+'scayt,'+'smiley,'+'showblocks,'+'showborders,'+'sourcearea,'+'stylescombo,'+'table,'+'tabletools,'+'specialchar,'+'tab,'+'templates,'+'toolbar,'+'undo,'+'wysiwygarea,'+'wsc',extraPlugins:'',removePlugins:'',protectedSource:[],tabIndex:0,theme:'default',skin:'kama',width:'',baseFloatZIndex:10000};;CKEDITOR.focusManager=function(editor)
{if(editor.focusManager)
return editor.focusManager;this.hasFocus=false;this._={editor:editor};return this;};CKEDITOR.focusManager.prototype={focus:function()
{if(this._.timer)
clearTimeout(this._.timer);if(!this.hasFocus)
{if(CKEDITOR.currentInstance)
CKEDITOR.currentInstance.focusManager.forceBlur();var editor=this._.editor;var firstChild=editor.container.getChild(1);if(firstChild){firstChild.addClass('cke_focus');}
this.hasFocus=true;editor.fire('focus');}},blur:function()
{var focusManager=this;if(focusManager._.timer)
clearTimeout(focusManager._.timer);focusManager._.timer=setTimeout(function()
{delete focusManager._.timer;focusManager.forceBlur();},100);},forceBlur:function()
{if(this.hasFocus)
{var editor=this._.editor;var firstChild=editor.container.getChild(1);if(firstChild){firstChild.removeClass('cke_focus');}
this.hasFocus=false;editor.fire('blur');}}};;(function()
{var loadedLangs={};CKEDITOR.lang={languages:{'af':1,'ar':1,'bg':1,'bn':1,'bs':1,'ca':1,'cs':1,'cy':1,'da':1,'de':1,'el':1,'en-au':1,'en-ca':1,'en-gb':1,'en':1,'eo':1,'es':1,'et':1,'eu':1,'fa':1,'fi':1,'fo':1,'fr-ca':1,'fr':1,'gl':1,'gu':1,'he':1,'hi':1,'hr':1,'hu':1,'is':1,'it':1,'ja':1,'ka':1,'km':1,'ko':1,'lt':1,'lv':1,'mn':1,'ms':1,'nb':1,'nl':1,'no':1,'pl':1,'pt-br':1,'pt':1,'ro':1,'ru':1,'sk':1,'sl':1,'sr-latn':1,'sr':1,'sv':1,'th':1,'tr':1,'uk':1,'vi':1,'zh-cn':1,'zh':1},load:function(languageCode,defaultLanguage,callback)
{if(!languageCode||!CKEDITOR.lang.languages[languageCode])
languageCode=this.detect(defaultLanguage,languageCode);if(!this[languageCode])
{CKEDITOR.scriptLoader.load(CKEDITOR.getUrl('lang/'+languageCode+'.js'),function()
{callback(languageCode,this[languageCode]);},this);}
else
callback(languageCode,this[languageCode]);},detect:function(defaultLanguage,probeLanguage)
{var languages=this.languages;probeLanguage=probeLanguage||navigator.userLanguage||navigator.language;var parts=probeLanguage.toLowerCase().match(/([a-z]+)(?:-([a-z]+))?/),lang=parts[1],locale=parts[2];if(languages[lang+'-'+locale])
lang=lang+'-'+locale;else if(!languages[lang])
lang=null;CKEDITOR.lang.detect=lang?function(){return lang;}:function(defaultLanguage){return defaultLanguage;};return lang||defaultLanguage;}};})();;CKEDITOR.scriptLoader=(function()
{var uniqueScripts={},waitingList={};return{load:function(scriptUrl,callback,scope,showBusy)
{var isString=(typeof scriptUrl=='string');if(isString)
scriptUrl=[scriptUrl];if(!scope)
scope=CKEDITOR;var scriptCount=scriptUrl.length,completed=[],failed=[];var doCallback=function(success)
{if(callback)
{if(isString)
callback.call(scope,success);else
callback.call(scope,completed,failed);}};if(scriptCount===0)
{doCallback(true);return;}
var checkLoaded=function(url,success)
{(success?completed:failed).push(url);if(--scriptCount<=0)
{showBusy&&CKEDITOR.document.getDocumentElement().removeStyle('cursor');doCallback(success);}};var onLoad=function(url,success)
{uniqueScripts[url]=1;var waitingInfo=waitingList[url];delete waitingList[url];for(var i=0;i<waitingInfo.length;i++)
waitingInfo[i](url,success);};var loadScript=function(url)
{if(uniqueScripts[url])
{checkLoaded(url,true);return;}
var waitingInfo=waitingList[url]||(waitingList[url]=[]);waitingInfo.push(checkLoaded);if(waitingInfo.length>1)
return;var script=new CKEDITOR.dom.element('script');script.setAttributes({type:'text/javascript',src:url});if(callback)
{if(CKEDITOR.env.ie)
{script.$.onreadystatechange=function()
{if(script.$.readyState=='loaded'||script.$.readyState=='complete')
{script.$.onreadystatechange=null;onLoad(url,true);}};}
else
{script.$.onload=function()
{setTimeout(function(){onLoad(url,true);},0);};script.$.onerror=function()
{onLoad(url,false);};}}
script.appendTo(CKEDITOR.document.getHead());};showBusy&&CKEDITOR.document.getDocumentElement().setStyle('cursor','wait');for(var i=0;i<scriptCount;i++)
{loadScript(scriptUrl[i]);}}};})();;CKEDITOR.resourceManager=function(basePath,fileName)
{this.basePath=basePath;this.fileName=fileName;this.registered={};this.loaded={};this.externals={};this._={waitingList:{}};};CKEDITOR.resourceManager.prototype={add:function(name,definition)
{if(this.registered[name])
throw'[CKEDITOR.resourceManager.add] The resource name "'+name+'" is already registered.';CKEDITOR.fire(name+CKEDITOR.tools.capitalize(this.fileName)+'Ready',this.registered[name]=definition||{});},get:function(name)
{return this.registered[name]||null;},getPath:function(name)
{var external=this.externals[name];return CKEDITOR.getUrl((external&&external.dir)||this.basePath+name+'/');},getFilePath:function(name)
{var external=this.externals[name];return CKEDITOR.getUrl(this.getPath(name)+
((external&&(typeof external.file=='string'))?external.file:this.fileName+'.js'));},addExternal:function(names,path,fileName)
{names=names.split(',');for(var i=0;i<names.length;i++)
{var name=names[i];this.externals[name]={dir:path,file:fileName};}},load:function(names,callback,scope)
{if(!CKEDITOR.tools.isArray(names))
names=names?[names]:[];var loaded=this.loaded,registered=this.registered,urls=[],urlsNames={},resources={};for(var i=0;i<names.length;i++)
{var name=names[i];if(!name)
continue;if(!loaded[name]&&!registered[name])
{var url=this.getFilePath(name);urls.push(url);if(!(url in urlsNames))
urlsNames[url]=[];urlsNames[url].push(name);}
else
resources[name]=this.get(name);}
CKEDITOR.scriptLoader.load(urls,function(completed,failed)
{if(failed.length)
{throw'[CKEDITOR.resourceManager.load] Resource name "'+urlsNames[failed[0]].join(',')
+'" was not found at "'+failed[0]+'".';}
for(var i=0;i<completed.length;i++)
{var nameList=urlsNames[completed[i]];for(var j=0;j<nameList.length;j++)
{var name=nameList[j];resources[name]=this.get(name);loaded[name]=1;}}
callback.call(scope,resources);},this);}};;CKEDITOR.plugins=new CKEDITOR.resourceManager('plugins/','plugin');CKEDITOR.plugins.load=CKEDITOR.tools.override(CKEDITOR.plugins.load,function(originalLoad)
{return function(name,callback,scope)
{var allPlugins={};var loadPlugins=function(names)
{originalLoad.call(this,names,function(plugins)
{CKEDITOR.tools.extend(allPlugins,plugins);var requiredPlugins=[];for(var pluginName in plugins)
{var plugin=plugins[pluginName],requires=plugin&&plugin.requires;if(requires)
{for(var i=0;i<requires.length;i++)
{if(!allPlugins[requires[i]])
requiredPlugins.push(requires[i]);}}}
if(requiredPlugins.length)
loadPlugins.call(this,requiredPlugins);else
{for(pluginName in allPlugins)
{plugin=allPlugins[pluginName];if(plugin.onLoad&&!plugin.onLoad._called)
{plugin.onLoad();plugin.onLoad._called=1;}}
if(callback)
callback.call(scope||window,allPlugins);}},this);};loadPlugins.call(this,name);};});CKEDITOR.plugins.setLang=function(pluginName,languageCode,languageEntries)
{var plugin=this.get(pluginName),pluginLangEntries=plugin.langEntries||(plugin.langEntries={}),pluginLang=plugin.lang||(plugin.lang=[]);if(CKEDITOR.tools.indexOf(pluginLang,languageCode)==-1)
pluginLang.push(languageCode);pluginLangEntries[languageCode]=languageEntries;};;CKEDITOR.skins=(function()
{var loaded={},paths={};var loadPart=function(editor,skinName,part,callback)
{var skinDefinition=loaded[skinName];if(!editor.skin)
{editor.skin=skinDefinition;if(skinDefinition.init)
skinDefinition.init(editor);}
var appendSkinPath=function(fileNames)
{for(var n=0;n<fileNames.length;n++)
{if(fileNames[n].indexOf('://')==-1&&fileNames[n].indexOf('/')!==0){fileNames[n]=CKEDITOR.getUrl(paths[skinName]+fileNames[n]);}}};function fixCSSTextRelativePath(cssStyleText,baseUrl)
{return cssStyleText.replace(/url\s*\(([\s'"]*)(.*?)([\s"']*)\)/g,function(match,opener,path,closer)
{if(/^\/|^\w?:/.test(path))
return match;else
return'url('+baseUrl+opener+path+closer+')';});}
part=skinDefinition[part];var partIsLoaded=!part||!!part._isLoaded;if(partIsLoaded)
callback&&callback();else
{var pending=part._pending||(part._pending=[]);pending.push(callback);if(pending.length>1)
return;var cssIsLoaded=!part.css||!part.css.length,jsIsLoaded=!part.js||!part.js.length;var checkIsLoaded=function()
{if(cssIsLoaded&&jsIsLoaded)
{part._isLoaded=1;for(var i=0;i<pending.length;i++)
{if(pending[i])
pending[i]();}}};if(!cssIsLoaded)
{var cssPart=part.css;if(CKEDITOR.tools.isArray(cssPart))
{appendSkinPath(cssPart);for(var c=0;c<cssPart.length;c++)
CKEDITOR.document.appendStyleSheet(cssPart[c]);}
else
{cssPart=fixCSSTextRelativePath(cssPart,CKEDITOR.getUrl(paths[skinName]));CKEDITOR.document.appendStyleText(cssPart);}
part.css=cssPart;cssIsLoaded=1;}
if(!jsIsLoaded)
{appendSkinPath(part.js);CKEDITOR.scriptLoader.load(part.js,function()
{jsIsLoaded=1;checkIsLoaded();});}
checkIsLoaded();}};return{add:function(skinName,skinDefinition)
{loaded[skinName]=skinDefinition;skinDefinition.skinPath=paths[skinName]||(paths[skinName]=CKEDITOR.getUrl('_source/'+'skins/'+skinName+'/'));},load:function(editor,skinPart,callback)
{var skinName=editor.skinName,skinPath=editor.skinPath;if(loaded[skinName])
loadPart(editor,skinName,skinPart,callback);else
{paths[skinName]=skinPath;CKEDITOR.scriptLoader.load(CKEDITOR.getUrl(skinPath+'skin.js'),function()
{loadPart(editor,skinName,skinPart,callback);});}}};})();;CKEDITOR.themes=new CKEDITOR.resourceManager('themes/','theme');;CKEDITOR.ui=function(editor)
{if(editor.ui)
return editor.ui;this._={handlers:{},items:{},editor:editor};return this;};CKEDITOR.ui.prototype={add:function(name,type,definition)
{this._.items[name]={type:type,command:definition.command||null,args:Array.prototype.slice.call(arguments,2)};},create:function(name)
{var item=this._.items[name],handler=item&&this._.handlers[item.type],command=item&&item.command&&this._.editor.getCommand(item.command);var result=handler&&handler.create.apply(this,item.args);item&&(result=CKEDITOR.tools.extend(result,this._.editor.skin[item.type],true));if(command)
command.uiItems.push(result);return result;},addHandler:function(type,handler)
{this._.handlers[type]=handler;}};CKEDITOR.event.implementOn(CKEDITOR.ui);;(function()
{var nameCounter=0;var getNewName=function()
{var name='editor'+(++nameCounter);return(CKEDITOR.instances&&CKEDITOR.instances[name])?getNewName():name;};var loadConfigLoaded={};var loadConfig=function(editor)
{var customConfig=editor.config.customConfig;if(!customConfig)
return false;customConfig=CKEDITOR.getUrl(customConfig);var loadedConfig=loadConfigLoaded[customConfig]||(loadConfigLoaded[customConfig]={});if(loadedConfig.fn)
{loadedConfig.fn.call(editor,editor.config);if(CKEDITOR.getUrl(editor.config.customConfig)==customConfig||!loadConfig(editor))
editor.fireOnce('customConfigLoaded');}
else
{CKEDITOR.scriptLoader.load(customConfig,function()
{if(CKEDITOR.editorConfig)
loadedConfig.fn=CKEDITOR.editorConfig;else
loadedConfig.fn=function(){};loadConfig(editor);});}
return true;};var initConfig=function(editor,instanceConfig)
{editor.on('customConfigLoaded',function()
{if(instanceConfig)
{if(instanceConfig.on)
{for(var eventName in instanceConfig.on)
{editor.on(eventName,instanceConfig.on[eventName]);}}
CKEDITOR.tools.extend(editor.config,instanceConfig,true);delete editor.config.on;}
onConfigLoaded(editor);});if(instanceConfig&&instanceConfig.customConfig!=undefined)
editor.config.customConfig=instanceConfig.customConfig;if(!loadConfig(editor))
editor.fireOnce('customConfigLoaded');};var onConfigLoaded=function(editor)
{var skin=editor.config.skin.split(','),skinName=skin[0],skinPath=CKEDITOR.getUrl(skin[1]||('skins/'+skinName+'/'));editor.skinName=skinName;editor.skinPath=skinPath;editor.skinClass='cke_skin_'+skinName;editor.tabIndex=editor.config.tabIndex||editor.element.getAttribute('tabindex')||0;editor.readOnly=!!(editor.config.readOnly||editor.element.getAttribute('disabled'));editor.fireOnce('configLoaded');loadSkin(editor);};var loadLang=function(editor)
{CKEDITOR.lang.load(editor.config.language,editor.config.defaultLanguage,function(languageCode,lang)
{editor.langCode=languageCode;editor.lang=CKEDITOR.tools.prototypedCopy(lang);if(CKEDITOR.env.gecko&&CKEDITOR.env.version<10900&&editor.lang.dir=='rtl')
editor.lang.dir='ltr';editor.fire('langLoaded');var config=editor.config;config.contentsLangDirection=='ui'&&(config.contentsLangDirection=editor.lang.dir);loadPlugins(editor);});};var loadPlugins=function(editor)
{var config=editor.config,plugins=config.plugins,extraPlugins=config.extraPlugins,removePlugins=config.removePlugins;if(extraPlugins)
{var removeRegex=new RegExp('(?:^|,)(?:'+extraPlugins.replace(/\s*,\s*/g,'|')+')(?=,|$)','g');plugins=plugins.replace(removeRegex,'');plugins+=','+extraPlugins;}
if(removePlugins)
{removeRegex=new RegExp('(?:^|,)(?:'+removePlugins.replace(/\s*,\s*/g,'|')+')(?=,|$)','g');plugins=plugins.replace(removeRegex,'');}
CKEDITOR.env.air&&(plugins+=',adobeair');CKEDITOR.plugins.load(plugins.split(','),function(plugins)
{var pluginsArray=[];var languageCodes=[];var languageFiles=[];editor.plugins=plugins;for(var pluginName in plugins)
{var plugin=plugins[pluginName],pluginLangs=plugin.lang,pluginPath=CKEDITOR.plugins.getPath(pluginName),lang=null;plugin.path=pluginPath;if(pluginLangs)
{lang=(CKEDITOR.tools.indexOf(pluginLangs,editor.langCode)>=0?editor.langCode:pluginLangs[0]);if(!plugin.langEntries||!plugin.langEntries[lang])
{languageFiles.push(CKEDITOR.getUrl(pluginPath+'lang/'+lang+'.js'));}
else
{CKEDITOR.tools.extend(editor.lang,plugin.langEntries[lang]);lang=null;}}
languageCodes.push(lang);pluginsArray.push(plugin);}
CKEDITOR.scriptLoader.load(languageFiles,function()
{var methods=['beforeInit','init','afterInit'];for(var m=0;m<methods.length;m++)
{for(var i=0;i<pluginsArray.length;i++)
{var plugin=pluginsArray[i];if(m===0&&languageCodes[i]&&plugin.lang)
CKEDITOR.tools.extend(editor.lang,plugin.langEntries[languageCodes[i]]);if(plugin[methods[m]])
plugin[methods[m]](editor);}}
editor.fire('pluginsLoaded');loadTheme(editor);});});};var loadSkin=function(editor)
{CKEDITOR.skins.load(editor,'editor',function()
{loadLang(editor);});};var loadTheme=function(editor)
{var theme=editor.config.theme;CKEDITOR.themes.load(theme,function()
{var editorTheme=editor.theme=CKEDITOR.themes.get(theme);editorTheme.path=CKEDITOR.themes.getPath(theme);editorTheme.build(editor);if(editor.config.autoUpdateElement)
attachToForm(editor);});};var attachToForm=function(editor)
{var element=editor.element;if(editor.elementMode==CKEDITOR.ELEMENT_MODE_REPLACE&&element.is('textarea'))
{var form=element.$.form&&new CKEDITOR.dom.element(element.$.form);if(form)
{function onSubmit()
{editor.updateElement();}
form.on('submit',onSubmit);if(!form.$.submit.nodeName&&!form.$.submit.length)
{form.$.submit=CKEDITOR.tools.override(form.$.submit,function(originalSubmit)
{return function()
{editor.updateElement();if(originalSubmit.apply)
originalSubmit.apply(this,arguments);else
originalSubmit();};});}
editor.on('destroy',function()
{form.removeListener('submit',onSubmit);});}}};function updateCommands()
{var command,commands=this._.commands,mode=this.mode;if(!mode)
return;for(var name in commands)
{command=commands[name];command[command.startDisabled?'disable':this.readOnly&&!command.readOnly?'disable':command.modes[mode]?'enable':'disable']();}}
CKEDITOR.editor.prototype._init=function()
{var element=CKEDITOR.dom.element.get(this._.element),instanceConfig=this._.instanceConfig;delete this._.element;delete this._.instanceConfig;this._.commands={};this._.styles=[];this.element=element;this.name=(element&&(this.elementMode==CKEDITOR.ELEMENT_MODE_REPLACE)&&(element.getId()||element.getNameAtt()))||getNewName();if(this.name in CKEDITOR.instances)
throw'[CKEDITOR.editor] The instance "'+this.name+'" already exists.';this.id=CKEDITOR.tools.getNextId();this.config=CKEDITOR.tools.prototypedCopy(CKEDITOR.config);this.ui=new CKEDITOR.ui(this);this.focusManager=new CKEDITOR.focusManager(this);CKEDITOR.fire('instanceCreated',null,this);this.on('mode',updateCommands,null,null,1);this.on('readOnly',updateCommands,null,null,1);initConfig(this,instanceConfig);};})();CKEDITOR.tools.extend(CKEDITOR.editor.prototype,{addCommand:function(commandName,commandDefinition)
{return this._.commands[commandName]=new CKEDITOR.command(this,commandDefinition);},addCss:function(css)
{this._.styles.push(css);},destroy:function(noUpdate)
{if(!noUpdate)
this.updateElement();this.fire('destroy');this.theme&&this.theme.destroy(this);CKEDITOR.remove(this);CKEDITOR.fire('instanceDestroyed',null,this);},execCommand:function(commandName,data)
{var command=this.getCommand(commandName);var eventData={name:commandName,commandData:data,command:command};if(command&&command.state!=CKEDITOR.TRISTATE_DISABLED)
{if(this.fire('beforeCommandExec',eventData)!==true)
{eventData.returnValue=command.exec(eventData.commandData);if(!command.async&&this.fire('afterCommandExec',eventData)!==true)
return eventData.returnValue;}}
return false;},getCommand:function(commandName)
{return this._.commands[commandName];},getData:function()
{this.fire('beforeGetData');var eventData=this._.data;if(typeof eventData!='string')
{var element=this.element;if(element&&this.elementMode==CKEDITOR.ELEMENT_MODE_REPLACE)
eventData=element.is('textarea')?element.getValue():element.getHtml();else
eventData='';}
eventData={dataValue:eventData};this.fire('getData',eventData);return eventData.dataValue;},getSnapshot:function()
{var data=this.fire('getSnapshot');if(typeof data!='string')
{var element=this.element;if(element&&this.elementMode==CKEDITOR.ELEMENT_MODE_REPLACE)
data=element.is('textarea')?element.getValue():element.getHtml();}
return data;},loadSnapshot:function(snapshot)
{this.fire('loadSnapshot',snapshot);},setData:function(data,callback,internal)
{if(callback)
{this.on('dataReady',function(evt)
{evt.removeListener();callback.call(evt.editor);});}
var eventData={dataValue:data};!internal&&this.fire('setData',eventData);this._.data=eventData.dataValue;!internal&&this.fire('afterSetData',eventData);},setReadOnly:function(isReadOnly)
{isReadOnly=(isReadOnly==undefined)||isReadOnly;if(this.readOnly!=isReadOnly)
{this.readOnly=isReadOnly;this.fire('readOnly');}},insertHtml:function(data)
{this.fire('insertHtml',data);},insertText:function(text)
{this.fire('insertText',text);},insertElement:function(element)
{this.fire('insertElement',element);},checkDirty:function()
{return(this.mayBeDirty&&this._.previousValue!==this.getSnapshot());},resetDirty:function()
{if(this.mayBeDirty)
this._.previousValue=this.getSnapshot();},updateElement:function()
{var element=this.element;if(element&&this.elementMode==CKEDITOR.ELEMENT_MODE_REPLACE)
{var data=this.getData();if(this.config.htmlEncodeOutput)
data=CKEDITOR.tools.htmlEncode(data);if(element.is('textarea'))
element.setValue(data);else
element.setHtml(data);}}});CKEDITOR.on('loaded',function()
{var pending=CKEDITOR.editor._pending;if(pending)
{delete CKEDITOR.editor._pending;for(var i=0;i<pending.length;i++)
pending[i]._init();}});;CKEDITOR.htmlParser=function()
{this._={htmlPartsRegex:new RegExp('<(?:(?:\\/([^>]+)>)|(?:!--([\\S|\\s]*?)-->)|(?:([^\\s>]+)\\s*((?:(?:"[^"]*")|(?:\'[^\']*\')|[^"\'>])*)\\/?>))','g')};};(function()
{var attribsRegex=/([\w\-:.]+)(?:(?:\s*=\s*(?:(?:"([^"]*)")|(?:'([^']*)')|([^\s>]+)))|(?=\s|$))/g,emptyAttribs={checked:1,compact:1,declare:1,defer:1,disabled:1,ismap:1,multiple:1,nohref:1,noresize:1,noshade:1,nowrap:1,readonly:1,selected:1};CKEDITOR.htmlParser.prototype={onTagOpen:function(){},onTagClose:function(){},onText:function(){},onCDATA:function(){},onComment:function(){},parse:function(html)
{var parts,tagName,nextIndex=0,cdata;while((parts=this._.htmlPartsRegex.exec(html)))
{var tagIndex=parts.index;if(tagIndex>nextIndex)
{var text=html.substring(nextIndex,tagIndex);if(cdata)
cdata.push(text);else
this.onText(text);}
nextIndex=this._.htmlPartsRegex.lastIndex;if((tagName=parts[1]))
{tagName=tagName.toLowerCase();if(cdata&&CKEDITOR.dtd.$cdata[tagName])
{this.onCDATA(cdata.join(''));cdata=null;}
if(!cdata)
{this.onTagClose(tagName);continue;}}
if(cdata)
{cdata.push(parts[0]);continue;}
if((tagName=parts[3]))
{tagName=tagName.toLowerCase();if(/="/.test(tagName))
continue;var attribs={},attribMatch,attribsPart=parts[4],selfClosing=!!(attribsPart&&attribsPart.charAt(attribsPart.length-1)=='/');if(attribsPart)
{while((attribMatch=attribsRegex.exec(attribsPart)))
{var attName=attribMatch[1].toLowerCase(),attValue=attribMatch[2]||attribMatch[3]||attribMatch[4]||'';if(!attValue&&emptyAttribs[attName])
attribs[attName]=attName;else
attribs[attName]=attValue;}}
this.onTagOpen(tagName,attribs,selfClosing);if(!cdata&&CKEDITOR.dtd.$cdata[tagName])
cdata=[];continue;}
if((tagName=parts[2]))
this.onComment(tagName);}
if(html.length>nextIndex)
this.onText(html.substring(nextIndex,html.length));}};})();;CKEDITOR.htmlParser.comment=function(value)
{this.value=value;this._={isBlockLike:false};};CKEDITOR.htmlParser.comment.prototype={type:CKEDITOR.NODE_COMMENT,writeHtml:function(writer,filter)
{var comment=this.value;if(filter)
{if(!(comment=filter.onComment(comment,this)))
return;if(typeof comment!='string')
{comment.parent=this.parent;comment.writeHtml(writer,filter);return;}}
writer.comment(comment);}};;(function()
{var spacesRegex=/[\t\r\n ]{2,}|[\t\r\n]/g;CKEDITOR.htmlParser.text=function(value)
{this.value=value;this._={isBlockLike:false};};CKEDITOR.htmlParser.text.prototype={type:CKEDITOR.NODE_TEXT,writeHtml:function(writer,filter)
{var text=this.value;if(filter&&!(text=filter.onText(text,this)))
return;writer.text(text);}};})();;(function()
{CKEDITOR.htmlParser.cdata=function(value)
{this.value=value;};CKEDITOR.htmlParser.cdata.prototype={type:CKEDITOR.NODE_TEXT,writeHtml:function(writer)
{writer.write(this.value);}};})();;CKEDITOR.htmlParser.fragment=function()
{this.children=[];this.parent=null;this._={isBlockLike:true,hasInlineStarted:false};};(function()
{var nonBreakingBlocks=CKEDITOR.tools.extend({table:1,ul:1,ol:1,dl:1},CKEDITOR.dtd.table,CKEDITOR.dtd.ul,CKEDITOR.dtd.ol,CKEDITOR.dtd.dl);var optionalCloseTags=CKEDITOR.env.ie&&CKEDITOR.env.version<8?{dd:1,dt:1}:{};var listBlocks={ol:1,ul:1};var rootDtd=CKEDITOR.tools.extend({},{html:1},CKEDITOR.dtd.html,CKEDITOR.dtd.body,CKEDITOR.dtd.head,{style:1,script:1});CKEDITOR.htmlParser.fragment.fromHtml=function(fragmentHtml,fixForBody,contextNode)
{var parser=new CKEDITOR.htmlParser(),fragment=contextNode||new CKEDITOR.htmlParser.fragment(),pendingInline=[],pendingBRs=[],currentNode=fragment,inPre=false;function checkPending(newTagName)
{var pendingBRsSent;if(pendingInline.length>0)
{for(var i=0;i<pendingInline.length;i++)
{var pendingElement=pendingInline[i],pendingName=pendingElement.name,pendingDtd=CKEDITOR.dtd[pendingName],currentDtd=currentNode.name&&CKEDITOR.dtd[currentNode.name];if((!currentDtd||currentDtd[pendingName])&&(!newTagName||!pendingDtd||pendingDtd[newTagName]||!CKEDITOR.dtd[newTagName]))
{if(!pendingBRsSent)
{sendPendingBRs();pendingBRsSent=1;}
pendingElement=pendingElement.clone();pendingElement.parent=currentNode;currentNode=pendingElement;pendingInline.splice(i,1);i--;}}}}
function sendPendingBRs()
{while(pendingBRs.length)
currentNode.add(pendingBRs.shift());}
function addElement(element,target,moveCurrent)
{if(element.previous!==undefined)
return;target=target||currentNode||fragment;var savedCurrent=currentNode;if(fixForBody&&(!target.type||target.name=='body'))
{var elementName,realElementName;if(element.attributes&&(realElementName=element.attributes['data-cke-real-element-type']))
elementName=realElementName;else
elementName=element.name;if(elementName&&!(elementName in CKEDITOR.dtd.$body||elementName=='body'||element.isOrphan))
{currentNode=target;parser.onTagOpen(fixForBody,{});element.returnPoint=target=currentNode;}}
if(element._.isBlockLike&&element.name!='pre')
{var length=element.children.length,lastChild=element.children[length-1],text;if(lastChild&&lastChild.type==CKEDITOR.NODE_TEXT)
{if(!(text=CKEDITOR.tools.rtrim(lastChild.value)))
element.children.length=length-1;else
lastChild.value=text;}}
target.add(element);if(element.returnPoint)
{currentNode=element.returnPoint;delete element.returnPoint;}
else
currentNode=moveCurrent?target:savedCurrent;}
parser.onTagOpen=function(tagName,attributes,selfClosing,optionalClose)
{var element=new CKEDITOR.htmlParser.element(tagName,attributes);if(element.isUnknown&&selfClosing)
element.isEmpty=true;element.isOptionalClose=tagName in optionalCloseTags||optionalClose;if(CKEDITOR.dtd.$removeEmpty[tagName])
{pendingInline.push(element);return;}
else if(tagName=='pre')
inPre=true;else if(tagName=='br'&&inPre)
{currentNode.add(new CKEDITOR.htmlParser.text('\n'));return;}
while(1)
{var currentName=currentNode.name;var currentDtd=currentName?(CKEDITOR.dtd[currentName]||(currentNode._.isBlockLike?CKEDITOR.dtd.div:CKEDITOR.dtd.span)):rootDtd;if(!element.isUnknown&&!currentNode.isUnknown&&!currentDtd[tagName])
{if(currentNode.isOptionalClose)
parser.onTagClose(currentName);else if(tagName in listBlocks&&currentName in listBlocks)
{var children=currentNode.children,lastChild=children[children.length-1];if(!(lastChild&&lastChild.name=='li'))
addElement((lastChild=new CKEDITOR.htmlParser.element('li')),currentNode);!element.returnPoint&&(element.returnPoint=currentNode);currentNode=lastChild;}
else if(tagName in CKEDITOR.dtd.$listItem&&currentName!=tagName)
parser.onTagOpen(tagName=='li'?'ul':'dl',{},0,1);else if(currentName in nonBreakingBlocks&&currentName!=tagName)
{!element.returnPoint&&(element.returnPoint=currentNode);currentNode=currentNode.parent;}
else
{if(currentName in CKEDITOR.dtd.$inline)
pendingInline.unshift(currentNode);if(currentNode.parent)
addElement(currentNode,currentNode.parent,1);else
{element.isOrphan=1;break;}}}
else
break;}
checkPending(tagName);sendPendingBRs();element.parent=currentNode;if(element.isEmpty)
addElement(element);else
currentNode=element;};parser.onTagClose=function(tagName)
{for(var i=pendingInline.length-1;i>=0;i--)
{if(tagName==pendingInline[i].name)
{pendingInline.splice(i,1);return;}}
var pendingAdd=[],newPendingInline=[],candidate=currentNode;while(candidate!=fragment&&candidate.name!=tagName)
{if(!candidate._.isBlockLike)
newPendingInline.unshift(candidate);pendingAdd.push(candidate);candidate=candidate.returnPoint||candidate.parent;}
if(candidate!=fragment)
{for(i=0;i<pendingAdd.length;i++)
{var node=pendingAdd[i];addElement(node,node.parent);}
currentNode=candidate;if(currentNode.name=='pre')
inPre=false;if(candidate._.isBlockLike)
sendPendingBRs();addElement(candidate,candidate.parent);if(candidate==currentNode)
currentNode=currentNode.parent;pendingInline=pendingInline.concat(newPendingInline);}
if(tagName=='body')
fixForBody=false;};parser.onText=function(text)
{if((!currentNode._.hasInlineStarted||pendingBRs.length)&&!inPre)
{text=CKEDITOR.tools.ltrim(text);if(text.length===0)
return;}
sendPendingBRs();checkPending();if(fixForBody&&(!currentNode.type||currentNode.name=='body')&&CKEDITOR.tools.trim(text))
{this.onTagOpen(fixForBody,{},0,1);}
if(!inPre)
text=text.replace(/[\t\r\n ]{2,}|[\t\r\n]/g,' ');currentNode.add(new CKEDITOR.htmlParser.text(text));};parser.onCDATA=function(cdata)
{currentNode.add(new CKEDITOR.htmlParser.cdata(cdata));};parser.onComment=function(comment)
{sendPendingBRs();checkPending();currentNode.add(new CKEDITOR.htmlParser.comment(comment));};parser.parse(fragmentHtml);sendPendingBRs(!CKEDITOR.env.ie&&1);while(currentNode!=fragment)
addElement(currentNode,currentNode.parent,1);return fragment;};CKEDITOR.htmlParser.fragment.prototype={add:function(node,index)
{isNaN(index)&&(index=this.children.length);var previous=index>0?this.children[index-1]:null;if(previous)
{if(node._.isBlockLike&&previous.type==CKEDITOR.NODE_TEXT)
{previous.value=CKEDITOR.tools.rtrim(previous.value);if(previous.value.length===0)
{this.children.pop();this.add(node);return;}}
previous.next=node;}
node.previous=previous;node.parent=this;this.children.splice(index,0,node);this._.hasInlineStarted=node.type==CKEDITOR.NODE_TEXT||(node.type==CKEDITOR.NODE_ELEMENT&&!node._.isBlockLike);},writeHtml:function(writer,filter)
{var isChildrenFiltered;this.filterChildren=function()
{var writer=new CKEDITOR.htmlParser.basicWriter();this.writeChildrenHtml.call(this,writer,filter,true);var html=writer.getHtml();this.children=new CKEDITOR.htmlParser.fragment.fromHtml(html).children;isChildrenFiltered=1;};!this.name&&filter&&filter.onFragment(this);this.writeChildrenHtml(writer,isChildrenFiltered?null:filter);},writeChildrenHtml:function(writer,filter)
{for(var i=0;i<this.children.length;i++)
this.children[i].writeHtml(writer,filter);}};})();;CKEDITOR.htmlParser.element=function(name,attributes)
{this.name=name;this.attributes=attributes||(attributes={});this.children=[];var tagName=attributes['data-cke-real-element-type']||name||'';var internalTag=tagName.match(/^cke:(.*)/);internalTag&&(tagName=internalTag[1]);var dtd=CKEDITOR.dtd,isBlockLike=!!(dtd.$nonBodyContent[tagName]||dtd.$block[tagName]||dtd.$listItem[tagName]||dtd.$tableContent[tagName]||dtd.$nonEditable[tagName]||tagName=='br'),isEmpty=!!dtd.$empty[name];this.isEmpty=isEmpty;this.isUnknown=!dtd[name];this._={isBlockLike:isBlockLike,hasInlineStarted:isEmpty||!isBlockLike};};CKEDITOR.htmlParser.cssStyle=function()
{var styleText,arg=arguments[0],rules={};styleText=arg instanceof CKEDITOR.htmlParser.element?arg.attributes.style:arg;(styleText||'').replace(/&quot;/g,'"').replace(/\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g,function(match,name,value)
{name=='font-family'&&(value=value.replace(/["']/g,''));rules[name.toLowerCase()]=value;});return{rules:rules,populate:function(obj)
{var style=this.toString();if(style)
{obj instanceof CKEDITOR.dom.element?obj.setAttribute('style',style):obj instanceof CKEDITOR.htmlParser.element?obj.attributes.style=style:obj.style=style;}},toString:function()
{var output=[];for(var i in rules)
rules[i]&&output.push(i,':',rules[i],';');return output.join('');}};};(function()
{var sortAttribs=function(a,b)
{a=a[0];b=b[0];return a<b?-1:a>b?1:0;};CKEDITOR.htmlParser.element.prototype={type:CKEDITOR.NODE_ELEMENT,add:CKEDITOR.htmlParser.fragment.prototype.add,clone:function()
{return new CKEDITOR.htmlParser.element(this.name,this.attributes);},writeHtml:function(writer,filter)
{var attributes=this.attributes;var element=this,writeName=element.name,a,newAttrName,value;var isChildrenFiltered;element.filterChildren=function()
{if(!isChildrenFiltered)
{var writer=new CKEDITOR.htmlParser.basicWriter();CKEDITOR.htmlParser.fragment.prototype.writeChildrenHtml.call(element,writer,filter);element.children=new CKEDITOR.htmlParser.fragment.fromHtml(writer.getHtml(),0,element.clone()).children;isChildrenFiltered=1;}};if(filter)
{while(true)
{if(!(writeName=filter.onElementName(writeName)))
return;element.name=writeName;if(!(element=filter.onElement(element)))
return;element.parent=this.parent;if(element.name==writeName)
break;if(element.type!=CKEDITOR.NODE_ELEMENT)
{element.writeHtml(writer,filter);return;}
writeName=element.name;if(!writeName)
{for(var c=0,length=this.children.length;c<length;c++)
this.children[c].parent=element.parent;this.writeChildrenHtml.call(element,writer,isChildrenFiltered?null:filter);return;}}
attributes=element.attributes;}
writer.openTag(writeName,attributes);var attribsArray=[];for(var i=0;i<2;i++)
{for(a in attributes)
{newAttrName=a;value=attributes[a];if(i==1)
attribsArray.push([a,value]);else if(filter)
{while(true)
{if(!(newAttrName=filter.onAttributeName(a)))
{delete attributes[a];break;}
else if(newAttrName!=a)
{delete attributes[a];a=newAttrName;continue;}
else
break;}
if(newAttrName)
{if((value=filter.onAttribute(element,newAttrName,value))===false)
delete attributes[newAttrName];else
attributes[newAttrName]=value;}}}}
if(writer.sortAttributes)
attribsArray.sort(sortAttribs);var len=attribsArray.length;for(i=0;i<len;i++)
{var attrib=attribsArray[i];writer.attribute(attrib[0],attrib[1]);}
writer.openTagClose(writeName,element.isEmpty);if(!element.isEmpty)
{this.writeChildrenHtml.call(element,writer,isChildrenFiltered?null:filter);writer.closeTag(writeName);}},writeChildrenHtml:function(writer,filter)
{CKEDITOR.htmlParser.fragment.prototype.writeChildrenHtml.apply(this,arguments);}};})();;(function()
{CKEDITOR.htmlParser.filter=CKEDITOR.tools.createClass({$:function(rules)
{this._={elementNames:[],attributeNames:[],elements:{$length:0},attributes:{$length:0}};if(rules)
this.addRules(rules,10);},proto:{addRules:function(rules,priority)
{if(typeof priority!='number')
priority=10;addItemsToList(this._.elementNames,rules.elementNames,priority);addItemsToList(this._.attributeNames,rules.attributeNames,priority);addNamedItems(this._.elements,rules.elements,priority);addNamedItems(this._.attributes,rules.attributes,priority);this._.text=transformNamedItem(this._.text,rules.text,priority)||this._.text;this._.comment=transformNamedItem(this._.comment,rules.comment,priority)||this._.comment;this._.root=transformNamedItem(this._.root,rules.root,priority)||this._.root;},onElementName:function(name)
{return filterName(name,this._.elementNames);},onAttributeName:function(name)
{return filterName(name,this._.attributeNames);},onText:function(text)
{var textFilter=this._.text;return textFilter?textFilter.filter(text):text;},onComment:function(commentText,comment)
{var textFilter=this._.comment;return textFilter?textFilter.filter(commentText,comment):commentText;},onFragment:function(element)
{var rootFilter=this._.root;return rootFilter?rootFilter.filter(element):element;},onElement:function(element)
{var filters=[this._.elements['^'],this._.elements[element.name],this._.elements.$],filter,ret;for(var i=0;i<3;i++)
{filter=filters[i];if(filter)
{ret=filter.filter(element,this);if(ret===false)
return null;if(ret&&ret!=element)
return this.onNode(ret);if(element.parent&&!element.name)
break;}}
return element;},onNode:function(node)
{var type=node.type;return type==CKEDITOR.NODE_ELEMENT?this.onElement(node):type==CKEDITOR.NODE_TEXT?new CKEDITOR.htmlParser.text(this.onText(node.value)):type==CKEDITOR.NODE_COMMENT?new CKEDITOR.htmlParser.comment(this.onComment(node.value)):null;},onAttribute:function(element,name,value)
{var filter=this._.attributes[name];if(filter)
{var ret=filter.filter(value,element,this);if(ret===false)
return false;if(typeof ret!='undefined')
return ret;}
return value;}}});function filterName(name,filters)
{for(var i=0;name&&i<filters.length;i++)
{var filter=filters[i];name=name.replace(filter[0],filter[1]);}
return name;}
function addItemsToList(list,items,priority)
{if(typeof items=='function')
items=[items];var i,j,listLength=list.length,itemsLength=items&&items.length;if(itemsLength)
{for(i=0;i<listLength&&list[i].pri<priority;i++)
{}
for(j=itemsLength-1;j>=0;j--)
{var item=items[j];if(item)
{item.pri=priority;list.splice(i,0,item);}}}}
function addNamedItems(hashTable,items,priority)
{if(items)
{for(var name in items)
{var current=hashTable[name];hashTable[name]=transformNamedItem(current,items[name],priority);if(!current)
hashTable.$length++;}}}
function transformNamedItem(current,item,priority)
{if(item)
{item.pri=priority;if(current)
{if(!current.splice)
{if(current.pri>priority)
current=[item,current];else
current=[current,item];current.filter=callItems;}
else
addItemsToList(current,item,priority);return current;}
else
{item.filter=item;return item;}}}
function callItems(currentEntry)
{var isNode=currentEntry.type||currentEntry instanceof CKEDITOR.htmlParser.fragment;for(var i=0;i<this.length;i++)
{if(isNode)
{var orgType=currentEntry.type,orgName=currentEntry.name;}
var item=this[i],ret=item.apply(window,arguments);if(ret===false)
return ret;if(isNode)
{if(ret&&(ret.name!=orgName||ret.type!=orgType))
{return ret;}}
else
{if(typeof ret!='string')
return ret;}
ret!=undefined&&(currentEntry=ret);}
return currentEntry;}})();;CKEDITOR.htmlParser.basicWriter=CKEDITOR.tools.createClass({$:function()
{this._={output:[]};},proto:{openTag:function(tagName,attributes)
{this._.output.push('<',tagName);},openTagClose:function(tagName,isSelfClose)
{if(isSelfClose)
this._.output.push(' />');else
this._.output.push('>');},attribute:function(attName,attValue)
{if(typeof attValue=='string')
attValue=CKEDITOR.tools.htmlEncodeAttr(attValue);this._.output.push(' ',attName,'="',attValue,'"');},closeTag:function(tagName)
{this._.output.push('</',tagName,'>');},text:function(text)
{this._.output.push(text);},comment:function(comment)
{this._.output.push('<!--',comment,'-->');},write:function(data)
{this._.output.push(data);},reset:function()
{this._.output=[];this._.indent=false;},getHtml:function(reset)
{var html=this._.output.join('');if(reset)
this.reset();return html;}}});;delete CKEDITOR.loadFullCore;CKEDITOR.instances={};CKEDITOR.document=new CKEDITOR.dom.document(document);CKEDITOR.add=function(editor)
{CKEDITOR.instances[editor.name]=editor;editor.on('focus',function()
{if(CKEDITOR.currentInstance!=editor)
{CKEDITOR.currentInstance=editor;CKEDITOR.fire('currentInstance');}});editor.on('blur',function()
{if(CKEDITOR.currentInstance==editor)
{CKEDITOR.currentInstance=null;CKEDITOR.fire('currentInstance');}});};CKEDITOR.remove=function(editor)
{delete CKEDITOR.instances[editor.name];};CKEDITOR.on('instanceDestroyed',function()
{if(CKEDITOR.tools.isEmpty(this.instances))
CKEDITOR.fire('reset');});CKEDITOR.TRISTATE_ON=1;CKEDITOR.TRISTATE_OFF=2;CKEDITOR.TRISTATE_DISABLED=0;;CKEDITOR.dom.comment=CKEDITOR.tools.createClass({base:CKEDITOR.dom.node,$:function(text,ownerDocument)
{if(typeof text=='string')
text=(ownerDocument?ownerDocument.$:document).createComment(text);this.base(text);},proto:{type:CKEDITOR.NODE_COMMENT,getOuterHtml:function()
{return'<!--'+this.$.nodeValue+'-->';}}});;(function()
{var pathBlockElements={address:1,blockquote:1,dl:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1,li:1,dt:1,dd:1,legend:1,caption:1};var pathBlockLimitElements={body:1,div:1,table:1,tbody:1,tr:1,td:1,th:1,form:1,fieldset:1};var checkHasBlock=function(element)
{var childNodes=element.getChildren();for(var i=0,count=childNodes.count();i<count;i++)
{var child=childNodes.getItem(i);if(child.type==CKEDITOR.NODE_ELEMENT&&CKEDITOR.dtd.$block[child.getName()])
return true;}
return false;};CKEDITOR.dom.elementPath=function(lastNode)
{var block=null;var blockLimit=null;var elements=[];var e=lastNode;while(e)
{if(e.type==CKEDITOR.NODE_ELEMENT)
{if(!this.lastElement)
this.lastElement=e;var elementName=e.getName();if(CKEDITOR.env.ie&&CKEDITOR.env.ieVersion<10&&e.$.scopeName!='HTML')
elementName=e.$.scopeName.toLowerCase()+':'+elementName;if(!blockLimit)
{if(!block&&pathBlockElements[elementName])
block=e;if(pathBlockLimitElements[elementName])
{if(!block&&elementName=='div'&&!checkHasBlock(e))
block=e;else
blockLimit=e;}}
elements.push(e);if(elementName=='body')
break;}
e=e.getParent();}
this.block=block;this.blockLimit=blockLimit;this.elements=elements;};})();CKEDITOR.dom.elementPath.prototype={compare:function(otherPath)
{var thisElements=this.elements;var otherElements=otherPath&&otherPath.elements;if(!otherElements||thisElements.length!=otherElements.length)
return false;for(var i=0;i<thisElements.length;i++)
{if(!thisElements[i].equals(otherElements[i]))
return false;}
return true;},contains:function(tagNames)
{var elements=this.elements;for(var i=0;i<elements.length;i++)
{if(elements[i].getName()in tagNames)
return elements[i];}
return null;},isContentEditable:function(){var e=this.elements;var state="true";for(var i=e.length-1;i>=0;i--){if(e[i].$.contentEditable!="inherit")
state=e[i].$.contentEditable;}
return state=="true";}};;CKEDITOR.dom.text=function(text,ownerDocument)
{if(typeof text=='string')
text=(ownerDocument?ownerDocument.$:document).createTextNode(text);this.$=text;};CKEDITOR.dom.text.prototype=new CKEDITOR.dom.node();CKEDITOR.tools.extend(CKEDITOR.dom.text.prototype,{type:CKEDITOR.NODE_TEXT,getLength:function()
{return this.$.nodeValue.length;},getText:function()
{return this.$.nodeValue;},setText:function(text)
{this.$.nodeValue=text;},split:function(offset)
{if(CKEDITOR.env.ie&&offset==this.getLength())
{var next=this.getDocument().createText('');next.insertAfter(this);return next;}
var doc=this.getDocument();var retval=new CKEDITOR.dom.text(this.$.splitText(offset),doc);if(CKEDITOR.env.ie8)
{var workaround=new CKEDITOR.dom.text('',doc);workaround.insertAfter(retval);workaround.remove();}
return retval;},substring:function(indexA,indexB)
{if(typeof indexB!='number')
return this.$.nodeValue.substr(indexA);else
return this.$.nodeValue.substring(indexA,indexB);}});;CKEDITOR.dom.documentFragment=function(ownerDocument)
{ownerDocument=ownerDocument||CKEDITOR.document;this.$=ownerDocument.$.createDocumentFragment();};CKEDITOR.tools.extend(CKEDITOR.dom.documentFragment.prototype,CKEDITOR.dom.element.prototype,{type:CKEDITOR.NODE_DOCUMENT_FRAGMENT,insertAfterNode:function(node)
{node=node.$;node.parentNode.insertBefore(this.$,node.nextSibling);}},true,{'append':1,'appendBogus':1,'getFirst':1,'getLast':1,'appendTo':1,'moveChildren':1,'insertBefore':1,'insertAfterNode':1,'replace':1,'trim':1,'type':1,'ltrim':1,'rtrim':1,'getDocument':1,'getChildCount':1,'getChild':1,'getChildren':1});;(function()
{function iterate(rtl,breakOnFalse)
{if(this._.end)
return null;var node,range=this.range,guard,userGuard=this.guard,type=this.type,getSourceNodeFn=(rtl?'getPreviousSourceNode':'getNextSourceNode');if(!this._.start)
{this._.start=1;range.trim();if(range.collapsed)
{this.end();return null;}}
if(!rtl&&!this._.guardLTR)
{var limitLTR=range.endContainer,blockerLTR=limitLTR.getChild(range.endOffset);this._.guardLTR=function(node,movingOut)
{return((!movingOut||!limitLTR.equals(node))&&(!blockerLTR||!node.equals(blockerLTR))&&(node.type!=CKEDITOR.NODE_ELEMENT||!movingOut||node.getName()!='body'));};}
if(rtl&&!this._.guardRTL)
{var limitRTL=range.startContainer,blockerRTL=(range.startOffset>0)&&limitRTL.getChild(range.startOffset-1);this._.guardRTL=function(node,movingOut)
{return((!movingOut||!limitRTL.equals(node))&&(!blockerRTL||!node.equals(blockerRTL))&&(node.type!=CKEDITOR.NODE_ELEMENT||!movingOut||node.getName()!='body'));};}
var stopGuard=rtl?this._.guardRTL:this._.guardLTR;if(userGuard)
{guard=function(node,movingOut)
{if(stopGuard(node,movingOut)===false)
return false;return userGuard(node,movingOut);};}
else
guard=stopGuard;if(this.current)
node=this.current[getSourceNodeFn](false,type,guard);else
{if(rtl)
{node=range.endContainer;if(range.endOffset>0&&node.getChild)
{node=node.getChild(range.endOffset-1);if(guard(node)===false)
node=null;}
else
node=(guard(node,true)===false)?null:node.getPreviousSourceNode(true,type,guard);}
else
{node=range.startContainer;if(node.getChild){node=node.getChild(range.startOffset);}
if(node)
{if(guard(node)===false)
node=null;}
else
node=(guard(range.startContainer,true)===false)?null:range.startContainer.getNextSourceNode(true,type,guard);}}
while(node&&!this._.end)
{this.current=node;if(!this.evaluator||this.evaluator(node)!==false)
{if(!breakOnFalse)
return node;}
else if(breakOnFalse&&this.evaluator)
return false;node=node[getSourceNodeFn](false,type,guard);}
this.end();return this.current=null;}
function iterateToLast(rtl)
{var node,last=null;while((node=iterate.call(this,rtl)))
last=node;return last;}
CKEDITOR.dom.walker=CKEDITOR.tools.createClass({$:function(range)
{this.range=range;this._={};},proto:{end:function()
{this._.end=1;},next:function()
{return iterate.call(this);},previous:function()
{return iterate.call(this,1);},checkForward:function()
{return iterate.call(this,0,1)!==false;},checkBackward:function()
{return iterate.call(this,1,1)!==false;},lastForward:function()
{return iterateToLast.call(this);},lastBackward:function()
{return iterateToLast.call(this,1);},reset:function()
{delete this.current;this._={};}}});var blockBoundaryDisplayMatch={block:1,'list-item':1,table:1,'table-row-group':1,'table-header-group':1,'table-footer-group':1,'table-row':1,'table-column-group':1,'table-column':1,'table-cell':1,'table-caption':1};CKEDITOR.dom.element.prototype.isBlockBoundary=function(customNodeNames)
{var nodeNameMatches=customNodeNames?CKEDITOR.tools.extend({},CKEDITOR.dtd.$block,customNodeNames||{}):CKEDITOR.dtd.$block;return this.getComputedStyle('float')=='none'&&blockBoundaryDisplayMatch[this.getComputedStyle('display')]||nodeNameMatches[this.getName()];};CKEDITOR.dom.walker.blockBoundary=function(customNodeNames)
{return function(node,type)
{return!(node.type==CKEDITOR.NODE_ELEMENT&&node.isBlockBoundary(customNodeNames));};};CKEDITOR.dom.walker.listItemBoundary=function()
{return this.blockBoundary({br:1});};CKEDITOR.dom.walker.bookmark=function(contentOnly,isReject)
{function isBookmarkNode(node)
{return(node&&node.getName&&node.getName()=='span'&&node.data('cke-bookmark'));}
return function(node)
{var isBookmark,parent;isBookmark=(node&&!node.getName&&(parent=node.getParent())&&isBookmarkNode(parent));isBookmark=contentOnly?isBookmark:isBookmark||isBookmarkNode(node);return!!(isReject^isBookmark);};};CKEDITOR.dom.walker.whitespaces=function(isReject)
{return function(node)
{var isWhitespace=node&&(node.type==CKEDITOR.NODE_TEXT)&&!CKEDITOR.tools.trim(node.getText());return!!(isReject^isWhitespace);};};CKEDITOR.dom.walker.invisible=function(isReject)
{var whitespace=CKEDITOR.dom.walker.whitespaces();return function(node)
{var isInvisible=whitespace(node)||node.is&&!node.$.offsetHeight;return!!(isReject^isInvisible);};};CKEDITOR.dom.walker.nodeType=function(type,isReject)
{return function(node)
{return!!(isReject^(node.type==type));};};var tailNbspRegex=/^[\t\r\n ]*(?:&nbsp;|\xa0)$/,isWhitespaces=CKEDITOR.dom.walker.whitespaces(),isBookmark=CKEDITOR.dom.walker.bookmark(),toSkip=function(node)
{return isBookmark(node)||isWhitespaces(node)||node.type==CKEDITOR.NODE_ELEMENT&&node.getName()in CKEDITOR.dtd.$inline&&!(node.getName()in CKEDITOR.dtd.$empty);};CKEDITOR.dom.element.prototype.getBogus=function()
{var tail=this;do{tail=tail.getPreviousSourceNode();}
while(toSkip(tail))
if(tail&&(!CKEDITOR.env.ie?tail.is&&tail.is('br'):tail.getText&&tailNbspRegex.test(tail.getText())))
{return tail;}
return false;};})();;CKEDITOR.dom.range=function(document)
{this.startContainer=null;this.startOffset=null;this.endContainer=null;this.endOffset=null;this.collapsed=true;this.document=document;};(function()
{var updateCollapsed=function(range)
{range.collapsed=(range.startContainer&&range.endContainer&&range.startContainer.equals(range.endContainer)&&range.startOffset==range.endOffset);};var execContentsAction=function(range,action,docFrag,mergeThen)
{range.optimizeBookmark();var startNode=range.startContainer;var endNode=range.endContainer;var startOffset=range.startOffset;var endOffset=range.endOffset;var removeStartNode;var removeEndNode;if(endNode.type==CKEDITOR.NODE_TEXT)
endNode=endNode.split(endOffset);else
{if(endNode.getChildCount()>0)
{if(endOffset>=endNode.getChildCount())
{endNode=endNode.append(range.document.createText(''));removeEndNode=true;}
else
endNode=endNode.getChild(endOffset);}}
if(startNode.type==CKEDITOR.NODE_TEXT)
{startNode.split(startOffset);if(startNode.equals(endNode))
endNode=startNode.getNext();}
else
{if(!startOffset)
{startNode=startNode.getFirst().insertBeforeMe(range.document.createText(''));removeStartNode=true;}
else if(startOffset>=startNode.getChildCount())
{startNode=startNode.append(range.document.createText(''));removeStartNode=true;}
else
startNode=startNode.getChild(startOffset).getPrevious();}
var startParents=startNode.getParents();var endParents=endNode.getParents();var i,topStart,topEnd;for(i=0;i<startParents.length;i++)
{topStart=startParents[i];topEnd=endParents[i];if(!topStart.equals(topEnd))
break;}
var clone=docFrag,levelStartNode,levelClone,currentNode,currentSibling;for(var j=i;j<startParents.length;j++)
{levelStartNode=startParents[j];if(clone&&!levelStartNode.equals(startNode))
levelClone=clone.append(levelStartNode.clone());currentNode=levelStartNode.getNext();while(currentNode)
{if(currentNode.equals(endParents[j])||currentNode.equals(endNode))
break;currentSibling=currentNode.getNext();if(action==2)
clone.append(currentNode.clone(true));else
{currentNode.remove();if(action==1)
clone.append(currentNode);}
currentNode=currentSibling;}
if(clone)
clone=levelClone;}
clone=docFrag;for(var k=i;k<endParents.length;k++)
{levelStartNode=endParents[k];if(action>0&&!levelStartNode.equals(endNode))
levelClone=clone.append(levelStartNode.clone());if(!startParents[k]||levelStartNode.$.parentNode!=startParents[k].$.parentNode)
{currentNode=levelStartNode.getPrevious();while(currentNode)
{if(currentNode.equals(startParents[k])||currentNode.equals(startNode))
break;currentSibling=currentNode.getPrevious();if(action==2)
clone.$.insertBefore(currentNode.$.cloneNode(true),clone.$.firstChild);else
{currentNode.remove();if(action==1)
clone.$.insertBefore(currentNode.$,clone.$.firstChild);}
currentNode=currentSibling;}}
if(clone)
clone=levelClone;}
if(action==2)
{var startTextNode=range.startContainer;if(startTextNode.type==CKEDITOR.NODE_TEXT)
{startTextNode.$.data+=startTextNode.$.nextSibling.data;startTextNode.$.parentNode.removeChild(startTextNode.$.nextSibling);}
var endTextNode=range.endContainer;if(endTextNode.type==CKEDITOR.NODE_TEXT&&endTextNode.$.nextSibling)
{endTextNode.$.data+=endTextNode.$.nextSibling.data;endTextNode.$.parentNode.removeChild(endTextNode.$.nextSibling);}}
else
{if(topStart&&topEnd&&(startNode.$.parentNode!=topStart.$.parentNode||endNode.$.parentNode!=topEnd.$.parentNode))
{var endIndex=topEnd.getIndex();if(removeStartNode&&topEnd.$.parentNode==startNode.$.parentNode)
endIndex--;if(mergeThen&&topStart.type==CKEDITOR.NODE_ELEMENT)
{var span=CKEDITOR.dom.element.createFromHtml('<span '+'data-cke-bookmark="1" style="display:none">&nbsp;</span>',range.document);span.insertAfter(topStart);topStart.mergeSiblings(false);range.moveToBookmark({startNode:span});}
else
range.setStart(topEnd.getParent(),endIndex);}
range.collapse(true);}
if(removeStartNode)
startNode.remove();if(removeEndNode&&endNode.$.parentNode)
endNode.remove();};var inlineChildReqElements={abbr:1,acronym:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,'var':1};function getCheckStartEndBlockEvalFunction(isStart)
{var hadBr=false,bookmarkEvaluator=CKEDITOR.dom.walker.bookmark(true);return function(node)
{if(bookmarkEvaluator(node))
return true;if(node.type==CKEDITOR.NODE_TEXT)
{if(node.hasAscendant('pre')||CKEDITOR.tools.trim(node.getText()).length)
return false;}
else if(node.type==CKEDITOR.NODE_ELEMENT)
{if(node.$.nodeType==CKEDITOR.NODE_COMMENT){return false;}
if(!inlineChildReqElements[node.getName()])
{if(!isStart&&!CKEDITOR.env.ie&&node.getName()=='br'&&!hadBr)
hadBr=true;else
return false;}}
return true;};}
function elementBoundaryEval(node)
{return node.type!=CKEDITOR.NODE_TEXT&&node.getName()in CKEDITOR.dtd.$removeEmpty||!CKEDITOR.tools.trim(node.getText())||!!node.getParent().data('cke-bookmark');}
var whitespaceEval=new CKEDITOR.dom.walker.whitespaces(),bookmarkEval=new CKEDITOR.dom.walker.bookmark();function nonWhitespaceOrBookmarkEval(node)
{return!whitespaceEval(node)&&!bookmarkEval(node);}
CKEDITOR.dom.range.prototype={clone:function()
{var clone=new CKEDITOR.dom.range(this.document);clone.startContainer=this.startContainer;clone.startOffset=this.startOffset;clone.endContainer=this.endContainer;clone.endOffset=this.endOffset;clone.collapsed=this.collapsed;return clone;},collapse:function(toStart)
{if(toStart)
{this.endContainer=this.startContainer;this.endOffset=this.startOffset;}
else
{this.startContainer=this.endContainer;this.startOffset=this.endOffset;}
this.collapsed=true;},cloneContents:function()
{var docFrag=new CKEDITOR.dom.documentFragment(this.document);if(!this.collapsed)
execContentsAction(this,2,docFrag);return docFrag;},deleteContents:function(mergeThen)
{if(this.collapsed)
return;execContentsAction(this,0,null,mergeThen);},extractContents:function(mergeThen)
{var docFrag=new CKEDITOR.dom.documentFragment(this.document);if(!this.collapsed)
execContentsAction(this,1,docFrag,mergeThen);return docFrag;},createBookmark:function(serializable)
{var startNode,endNode;var baseId;var clone;var collapsed=this.collapsed;startNode=this.document.createElement('span');startNode.data('cke-bookmark',1);startNode.setStyle('display','none');startNode.setHtml('&nbsp;');if(serializable)
{baseId='cke_bm_'+CKEDITOR.tools.getNextNumber();startNode.setAttribute('id',baseId+'S');}
if(!collapsed)
{endNode=startNode.clone();endNode.setHtml('&nbsp;');if(serializable)
endNode.setAttribute('id',baseId+'E');clone=this.clone();clone.collapse();clone.insertNode(endNode);}
clone=this.clone();clone.collapse(true);clone.insertNode(startNode);if(endNode)
{this.setStartAfter(startNode);this.setEndBefore(endNode);}
else
this.moveToPosition(startNode,CKEDITOR.POSITION_AFTER_END);return{startNode:serializable?baseId+'S':startNode,endNode:serializable?baseId+'E':endNode,serializable:serializable,collapsed:collapsed};},createBookmark2:function(normalized)
{var startContainer=this.startContainer,endContainer=this.endContainer;var startOffset=this.startOffset,endOffset=this.endOffset;var collapsed=this.collapsed;var child,previous;if(!startContainer||!endContainer)
return{start:0,end:0};if(normalized)
{if(startContainer.type==CKEDITOR.NODE_ELEMENT)
{child=startContainer.getChild(startOffset);if(child&&child.type==CKEDITOR.NODE_TEXT&&startOffset>0&&child.getPrevious().type==CKEDITOR.NODE_TEXT)
{startContainer=child;startOffset=0;}
if(child&&child.type==CKEDITOR.NODE_ELEMENT)
startOffset=child.getIndex(1);}
while(startContainer.type==CKEDITOR.NODE_TEXT&&(previous=startContainer.getPrevious())&&previous.type==CKEDITOR.NODE_TEXT)
{startContainer=previous;startOffset+=previous.getLength();}
if(!collapsed)
{if(endContainer.type==CKEDITOR.NODE_ELEMENT)
{child=endContainer.getChild(endOffset);if(child&&child.type==CKEDITOR.NODE_TEXT&&endOffset>0&&child.getPrevious().type==CKEDITOR.NODE_TEXT)
{endContainer=child;endOffset=0;}
if(child&&child.type==CKEDITOR.NODE_ELEMENT)
endOffset=child.getIndex(1);}
while(endContainer.type==CKEDITOR.NODE_TEXT&&(previous=endContainer.getPrevious())&&previous.type==CKEDITOR.NODE_TEXT)
{endContainer=previous;endOffset+=previous.getLength();}}}
return{start:startContainer.getAddress(normalized),end:collapsed?null:endContainer.getAddress(normalized),startOffset:startOffset,endOffset:endOffset,normalized:normalized,collapsed:collapsed,is2:true};},moveToBookmark:function(bookmark)
{if(bookmark.is2)
{var startContainer=this.document.getByAddress(bookmark.start,bookmark.normalized),startOffset=bookmark.startOffset;var endContainer=bookmark.end&&this.document.getByAddress(bookmark.end,bookmark.normalized),endOffset=bookmark.endOffset;this.setStart(startContainer,startOffset);if(endContainer)
this.setEnd(endContainer,endOffset);else
this.collapse(true);}
else
{var serializable=bookmark.serializable,startNode=serializable?this.document.getById(bookmark.startNode):bookmark.startNode,endNode=serializable?this.document.getById(bookmark.endNode):bookmark.endNode;this.setStartBefore(startNode);startNode.remove();if(endNode)
{this.setEndBefore(endNode);endNode.remove();}
else
this.collapse(true);}},getBoundaryNodes:function()
{var startNode=this.startContainer,endNode=this.endContainer,startOffset=this.startOffset,endOffset=this.endOffset,childCount;if(startNode.type==CKEDITOR.NODE_ELEMENT)
{childCount=startNode.getChildCount();if(childCount>startOffset)
startNode=startNode.getChild(startOffset);else if(childCount<1)
startNode=startNode.getPreviousSourceNode();else
{startNode=startNode.$;while(startNode.lastChild)
startNode=startNode.lastChild;startNode=new CKEDITOR.dom.node(startNode);startNode=startNode.getNextSourceNode()||startNode;}}
if(endNode.type==CKEDITOR.NODE_ELEMENT)
{childCount=endNode.getChildCount();if(childCount>endOffset)
endNode=endNode.getChild(endOffset).getPreviousSourceNode(true);else if(childCount<1)
endNode=endNode.getPreviousSourceNode();else
{endNode=endNode.$;while(endNode.lastChild)
endNode=endNode.lastChild;endNode=new CKEDITOR.dom.node(endNode);}}
if(startNode.getPosition(endNode)&CKEDITOR.POSITION_FOLLOWING)
startNode=endNode;return{startNode:startNode,endNode:endNode};},getCommonAncestor:function(includeSelf,ignoreTextNode)
{var start=this.startContainer,end=this.endContainer,ancestor;if(start.equals(end))
{if(includeSelf&&start.type==CKEDITOR.NODE_ELEMENT&&this.startOffset==this.endOffset-1)
ancestor=start.getChild(this.startOffset);else
ancestor=start;}
else
ancestor=start.getCommonAncestor(end);return ignoreTextNode&&!ancestor.is?ancestor.getParent():ancestor;},optimize:function()
{var container=this.startContainer;var offset=this.startOffset;if(container.type!=CKEDITOR.NODE_ELEMENT&&container.type!=CKEDITOR.NODE_COMMENT)
{if(!offset)
this.setStartBefore(container);else if(offset>=container.getLength())
this.setStartAfter(container);}
container=this.endContainer;offset=this.endOffset;if(container.type!=CKEDITOR.NODE_ELEMENT&&container.type!=CKEDITOR.NODE_COMMENT)
{if(!offset)
this.setEndBefore(container);else if(offset>=container.getLength())
this.setEndAfter(container);}},optimizeBookmark:function()
{var startNode=this.startContainer,endNode=this.endContainer;if(startNode.is&&startNode.is('span')&&startNode.data('cke-bookmark'))
this.setStartAt(startNode,CKEDITOR.POSITION_BEFORE_START);if(endNode&&endNode.is&&endNode.is('span')&&endNode.data('cke-bookmark'))
this.setEndAt(endNode,CKEDITOR.POSITION_AFTER_END);},trim:function(ignoreStart,ignoreEnd)
{var startContainer=this.startContainer,startOffset=this.startOffset,collapsed=this.collapsed;if((!ignoreStart||collapsed)&&startContainer&&startContainer.type==CKEDITOR.NODE_TEXT)
{if(!startOffset)
{startOffset=startContainer.getIndex();startContainer=startContainer.getParent();}
else if(startOffset>=startContainer.getLength())
{startOffset=startContainer.getIndex()+1;startContainer=startContainer.getParent();}
else
{var nextText=startContainer.split(startOffset);startOffset=startContainer.getIndex()+1;startContainer=startContainer.getParent();if(this.startContainer.equals(this.endContainer))
this.setEnd(nextText,this.endOffset-this.startOffset);else if(startContainer.equals(this.endContainer))
this.endOffset+=1;}
this.setStart(startContainer,startOffset);if(collapsed)
{this.collapse(true);return;}}
var endContainer=this.endContainer;var endOffset=this.endOffset;if(!(ignoreEnd||collapsed)&&endContainer&&endContainer.type==CKEDITOR.NODE_TEXT)
{if(!endOffset)
{endOffset=endContainer.getIndex();endContainer=endContainer.getParent();}
else if(endOffset>=endContainer.getLength())
{endOffset=endContainer.getIndex()+1;endContainer=endContainer.getParent();}
else
{endContainer.split(endOffset);endOffset=endContainer.getIndex()+1;endContainer=endContainer.getParent();}
this.setEnd(endContainer,endOffset);}},enlarge:function(unit,excludeBrs)
{switch(unit)
{case CKEDITOR.ENLARGE_ELEMENT:if(this.collapsed)
return;var commonAncestor=this.getCommonAncestor();var body=this.document.getBody();var startTop,endTop;var enlargeable,sibling,commonReached;var needsWhiteSpace=false;var isWhiteSpace;var siblingText;var container=this.startContainer;var offset=this.startOffset;if(container.type==CKEDITOR.NODE_TEXT)
{if(offset)
{container=!CKEDITOR.tools.trim(container.substring(0,offset)).length&&container;needsWhiteSpace=!!container;}
if(container)
{if(!(sibling=container.getPrevious()))
enlargeable=container.getParent();}}
else
{if(offset)
sibling=container.getChild(offset-1)||container.getLast();if(!sibling)
enlargeable=container;}
while(enlargeable||sibling)
{if(enlargeable&&!sibling)
{if(!commonReached&&enlargeable.equals(commonAncestor))
commonReached=true;if(!body.contains(enlargeable))
break;if(!needsWhiteSpace||enlargeable.getComputedStyle('display')!='inline')
{needsWhiteSpace=false;if(commonReached)
startTop=enlargeable;else
this.setStartBefore(enlargeable);}
sibling=enlargeable.getPrevious();}
while(sibling)
{isWhiteSpace=false;if(sibling.type==CKEDITOR.NODE_TEXT)
{siblingText=sibling.getText();if(/[^\s\ufeff]/.test(siblingText))
sibling=null;isWhiteSpace=/[\s\ufeff]$/.test(siblingText);}
else
{if(sibling.$.nodeType==CKEDITOR.NODE_ELEMENT&&(sibling.$.offsetWidth>0||excludeBrs&&sibling.is('br'))&&!sibling.data('cke-bookmark'))
{if(needsWhiteSpace&&CKEDITOR.dtd.$removeEmpty[sibling.getName()])
{siblingText=sibling.getText();if((/[^\s\ufeff]/).test(siblingText))
sibling=null;else
{var allChildren=sibling.$.all||sibling.$.getElementsByTagName('*');for(var i=0,child;child=allChildren[i++];)
{if(!CKEDITOR.dtd.$removeEmpty[child.nodeName.toLowerCase()])
{sibling=null;break;}}}
if(sibling)
isWhiteSpace=!!siblingText.length;}
else
sibling=null;}}
if(isWhiteSpace)
{if(needsWhiteSpace)
{if(commonReached)
startTop=enlargeable;else if(enlargeable)
this.setStartBefore(enlargeable);}
else
needsWhiteSpace=true;}
if(sibling)
{var next=sibling.getPrevious();if(!enlargeable&&!next)
{enlargeable=sibling;sibling=null;break;}
sibling=next;}
else
{enlargeable=null;}}
if(enlargeable)
enlargeable=enlargeable.getParent();}
container=this.endContainer;offset=this.endOffset;enlargeable=sibling=null;commonReached=needsWhiteSpace=false;if(container.type==CKEDITOR.NODE_TEXT)
{container=!CKEDITOR.tools.trim(container.substring(offset)).length&&container;needsWhiteSpace=!(container&&container.getLength());if(container)
{if(!(sibling=container.getNext()))
enlargeable=container.getParent();}}
else
{sibling=container.getChild(offset);if(!sibling)
enlargeable=container;}
while(enlargeable||sibling)
{if(enlargeable&&!sibling)
{if(!commonReached&&enlargeable.equals(commonAncestor))
commonReached=true;if(!body.contains(enlargeable))
break;if(!needsWhiteSpace||enlargeable.getComputedStyle('display')!='inline')
{needsWhiteSpace=false;if(commonReached)
endTop=enlargeable;else if(enlargeable)
this.setEndAfter(enlargeable);}
sibling=enlargeable.getNext();}
while(sibling)
{isWhiteSpace=false;if(sibling.type==CKEDITOR.NODE_TEXT)
{siblingText=sibling.getText();if(/[^\s\ufeff]/.test(siblingText))
sibling=null;isWhiteSpace=/^[\s\ufeff]/.test(siblingText);}
else
{if(sibling.$.nodeType==CKEDITOR.NODE_ELEMENT&&(sibling.$.offsetWidth>0||excludeBrs&&sibling.is('br'))&&!sibling.data('cke-bookmark'))
{if(needsWhiteSpace&&CKEDITOR.dtd.$removeEmpty[sibling.getName()])
{siblingText=sibling.getText();if((/[^\s\ufeff]/).test(siblingText))
sibling=null;else
{allChildren=sibling.$.all||sibling.$.getElementsByTagName('*');for(i=0;child=allChildren[i++];)
{if(!CKEDITOR.dtd.$removeEmpty[child.nodeName.toLowerCase()])
{sibling=null;break;}}}
if(sibling)
isWhiteSpace=!!siblingText.length;}
else
sibling=null;}}
if(isWhiteSpace)
{if(needsWhiteSpace)
{if(commonReached)
endTop=enlargeable;else
this.setEndAfter(enlargeable);}}
if(sibling)
{next=sibling.getNext();if(!enlargeable&&!next)
{enlargeable=sibling;sibling=null;break;}
sibling=next;}
else
{enlargeable=null;}}
if(enlargeable)
enlargeable=enlargeable.getParent();}
if(startTop&&endTop)
{commonAncestor=startTop.contains(endTop)?endTop:startTop;this.setStartBefore(commonAncestor);this.setEndAfter(commonAncestor);}
break;case CKEDITOR.ENLARGE_BLOCK_CONTENTS:case CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS:var walkerRange=new CKEDITOR.dom.range(this.document);body=this.document.getBody();walkerRange.setStartAt(body,CKEDITOR.POSITION_AFTER_START);walkerRange.setEnd(this.startContainer,this.startOffset);var walker=new CKEDITOR.dom.walker(walkerRange),blockBoundary,tailBr,notBlockBoundary=CKEDITOR.dom.walker.blockBoundary((unit==CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS)?{br:1}:null),boundaryGuard=function(node)
{var retval=notBlockBoundary(node);if(!retval)
blockBoundary=node;return retval;},tailBrGuard=function(node)
{var retval=boundaryGuard(node);if(!retval&&node.is&&node.is('br'))
tailBr=node;return retval;};walker.guard=boundaryGuard;enlargeable=walker.lastBackward();blockBoundary=blockBoundary||body;this.setStartAt(blockBoundary,!blockBoundary.is('br')&&(!enlargeable&&this.checkStartOfBlock()||enlargeable&&blockBoundary.contains(enlargeable))?CKEDITOR.POSITION_AFTER_START:CKEDITOR.POSITION_AFTER_END);walkerRange=this.clone();walkerRange.collapse();walkerRange.setEndAt(body,CKEDITOR.POSITION_BEFORE_END);walker=new CKEDITOR.dom.walker(walkerRange);walker.guard=(unit==CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS)?tailBrGuard:boundaryGuard;blockBoundary=null;enlargeable=walker.lastForward();blockBoundary=blockBoundary||body;this.setEndAt(blockBoundary,(!enlargeable&&this.checkEndOfBlock()||enlargeable&&blockBoundary.contains(enlargeable))?CKEDITOR.POSITION_BEFORE_END:CKEDITOR.POSITION_BEFORE_START);if(tailBr)
this.setEndAfter(tailBr);}},shrink:function(mode,selectContents)
{if(!this.collapsed)
{mode=mode||CKEDITOR.SHRINK_TEXT;var walkerRange=this.clone();var startContainer=this.startContainer,endContainer=this.endContainer,startOffset=this.startOffset,endOffset=this.endOffset,collapsed=this.collapsed;var moveStart=1,moveEnd=1;if(startContainer&&startContainer.type==CKEDITOR.NODE_TEXT)
{if(!startOffset)
walkerRange.setStartBefore(startContainer);else if(startOffset>=startContainer.getLength())
walkerRange.setStartAfter(startContainer);else
{walkerRange.setStartBefore(startContainer);moveStart=0;}}
if(endContainer&&endContainer.type==CKEDITOR.NODE_TEXT)
{if(!endOffset)
walkerRange.setEndBefore(endContainer);else if(endOffset>=endContainer.getLength())
walkerRange.setEndAfter(endContainer);else
{walkerRange.setEndAfter(endContainer);moveEnd=0;}}
var walker=new CKEDITOR.dom.walker(walkerRange),isBookmark=CKEDITOR.dom.walker.bookmark();walker.evaluator=function(node)
{return node.type==(mode==CKEDITOR.SHRINK_ELEMENT?CKEDITOR.NODE_ELEMENT:CKEDITOR.NODE_TEXT);};var currentElement;walker.guard=function(node,movingOut)
{if(isBookmark(node))
return true;if(mode==CKEDITOR.SHRINK_ELEMENT&&node.type==CKEDITOR.NODE_TEXT)
return false;if(movingOut&&node.equals(currentElement))
return false;if(!movingOut&&node.type==CKEDITOR.NODE_ELEMENT)
currentElement=node;return true;};if(moveStart)
{var textStart=walker[mode==CKEDITOR.SHRINK_ELEMENT?'lastForward':'next']();textStart&&this.setStartAt(textStart,selectContents?CKEDITOR.POSITION_AFTER_START:CKEDITOR.POSITION_BEFORE_START);}
if(moveEnd)
{walker.reset();var textEnd=walker[mode==CKEDITOR.SHRINK_ELEMENT?'lastBackward':'previous']();textEnd&&this.setEndAt(textEnd,selectContents?CKEDITOR.POSITION_BEFORE_END:CKEDITOR.POSITION_AFTER_END);}
return!!(moveStart||moveEnd);}},enlargeFormattables:function()
{var node;if(this.startContainer.isReadOnly()){if(node=this.startContainer.findFormattableAncestor()){this.setStartBefore(node);}}
if(this.endContainer.isReadOnly()){if(node=this.endContainer.findFormattableAncestor()){this.setEndAfter(node);}}
return this;},insertNode:function(node)
{this.optimizeBookmark();this.trim(false,true);var startContainer=this.startContainer;var startOffset=this.startOffset;if(typeof startContainer.getChild!='function'){var nextNode=new CKEDITOR.dom.element(startContainer.$.previousSibling);}
else{var nextNode=startContainer.getChild(startOffset);}
if(nextNode)
node.insertBefore(nextNode);else
startContainer.append(node);if(node.getParent().equals(this.endContainer))
this.endOffset++;this.setStartBefore(node);},moveToPosition:function(node,position)
{this.setStartAt(node,position);this.collapse(true);},selectNodeContents:function(node)
{this.setStart(node,0);this.setEnd(node,node.type==CKEDITOR.NODE_TEXT?node.getLength():node.getChildCount());},setStart:function(startNode,startOffset)
{if(startNode.type==CKEDITOR.NODE_ELEMENT&&CKEDITOR.dtd.$empty[startNode.getName()])
startOffset=startNode.getIndex(),startNode=startNode.getParent();this.startContainer=startNode;this.startOffset=startOffset;if(!this.endContainer)
{this.endContainer=startNode;this.endOffset=startOffset;}
updateCollapsed(this);},setEnd:function(endNode,endOffset)
{if(endNode.type==CKEDITOR.NODE_ELEMENT&&CKEDITOR.dtd.$empty[endNode.getName()])
endOffset=endNode.getIndex()+1,endNode=endNode.getParent();this.endContainer=endNode;this.endOffset=endOffset;if(!this.startContainer)
{this.startContainer=endNode;this.startOffset=endOffset;}
updateCollapsed(this);},setStartAfter:function(node)
{this.setStart(node.getParent(),node.getIndex()+1);},setStartBefore:function(node)
{this.setStart(node.getParent(),node.getIndex());},setEndAfter:function(node)
{this.setEnd(node.getParent(),node.getIndex()+1);},setEndBefore:function(node)
{this.setEnd(node.getParent(),node.getIndex());},setStartAt:function(node,position)
{switch(position)
{case CKEDITOR.POSITION_AFTER_START:this.setStart(node,0);break;case CKEDITOR.POSITION_BEFORE_END:if(node.type==CKEDITOR.NODE_TEXT)
this.setStart(node,node.getLength());else
this.setStart(node,node.getChildCount());break;case CKEDITOR.POSITION_BEFORE_START:this.setStartBefore(node);break;case CKEDITOR.POSITION_AFTER_END:this.setStartAfter(node);}
updateCollapsed(this);},setEndAt:function(node,position)
{switch(position)
{case CKEDITOR.POSITION_AFTER_START:this.setEnd(node,0);break;case CKEDITOR.POSITION_BEFORE_END:if(node.type==CKEDITOR.NODE_TEXT)
this.setEnd(node,node.getLength());else
this.setEnd(node,node.getChildCount());break;case CKEDITOR.POSITION_BEFORE_START:this.setEndBefore(node);break;case CKEDITOR.POSITION_AFTER_END:this.setEndAfter(node);}
updateCollapsed(this);},fixBlock:function(isStart,blockTag)
{var bookmark=this.createBookmark(),fixedBlock=this.document.createElement(blockTag);this.collapse(isStart);this.enlargeFormattables();this.enlarge(CKEDITOR.ENLARGE_BLOCK_CONTENTS);this.extractContents().appendTo(fixedBlock);fixedBlock.trim();if(!CKEDITOR.env.ie)
fixedBlock.appendBogus();this.insertNode(fixedBlock);this.moveToBookmark(bookmark);return fixedBlock;},splitBlock:function(blockTag)
{var startPath=new CKEDITOR.dom.elementPath(this.startContainer),endPath=new CKEDITOR.dom.elementPath(this.endContainer);var startBlockLimit=startPath.blockLimit,endBlockLimit=endPath.blockLimit;var startBlock=startPath.block,endBlock=endPath.block;var elementPath=null;if(!startBlockLimit.equals(endBlockLimit))
return null;if(blockTag!='br')
{if(!startBlock)
{startBlock=this.fixBlock(true,blockTag);endBlock=new CKEDITOR.dom.elementPath(this.endContainer).block;}
if(!endBlock)
endBlock=this.fixBlock(false,blockTag);}
var isStartOfBlock=startBlock&&this.checkStartOfBlock(),isEndOfBlock=endBlock&&this.checkEndOfBlock();this.deleteContents();if(startBlock&&startBlock.equals(endBlock))
{if(isEndOfBlock)
{elementPath=new CKEDITOR.dom.elementPath(this.startContainer);this.moveToPosition(endBlock,CKEDITOR.POSITION_AFTER_END);endBlock=null;}
else if(isStartOfBlock)
{elementPath=new CKEDITOR.dom.elementPath(this.startContainer);this.moveToPosition(startBlock,CKEDITOR.POSITION_BEFORE_START);startBlock=null;}
else
{endBlock=this.splitElement(startBlock);if(!CKEDITOR.env.ie&&!startBlock.is('ul','ol'))
startBlock.appendBogus();}}
return{previousBlock:startBlock,nextBlock:endBlock,wasStartOfBlock:isStartOfBlock,wasEndOfBlock:isEndOfBlock,elementPath:elementPath};},splitElement:function(toSplit)
{if(!this.collapsed)
return null;this.setEndAt(toSplit,CKEDITOR.POSITION_BEFORE_END);var documentFragment=this.extractContents();var clone=toSplit.clone(false);documentFragment.appendTo(clone);clone.insertAfter(toSplit);this.moveToPosition(toSplit,CKEDITOR.POSITION_AFTER_END);return clone;},checkBoundaryOfElement:function(element,checkType)
{var checkStart=(checkType==CKEDITOR.START);var walkerRange=this.clone();walkerRange.collapse(checkStart);walkerRange[checkStart?'setStartAt':'setEndAt']
(element,checkStart?CKEDITOR.POSITION_AFTER_START:CKEDITOR.POSITION_BEFORE_END);var walker=new CKEDITOR.dom.walker(walkerRange);walker.evaluator=elementBoundaryEval;return walker[checkStart?'checkBackward':'checkForward']();},checkStartOfBlock:function()
{var startContainer=this.startContainer,startOffset=this.startOffset;if(startOffset&&startContainer.type==CKEDITOR.NODE_TEXT)
{var textBefore=CKEDITOR.tools.ltrim(startContainer.substring(0,startOffset));if(textBefore.length)
return false;}
this.trim();var path=new CKEDITOR.dom.elementPath(this.startContainer);var walkerRange=this.clone();walkerRange.collapse(true);walkerRange.setStartAt(path.block||path.blockLimit,CKEDITOR.POSITION_AFTER_START);var walker=new CKEDITOR.dom.walker(walkerRange);walker.evaluator=getCheckStartEndBlockEvalFunction(true);return walker.checkBackward();},checkEndOfBlock:function()
{var endContainer=this.endContainer,endOffset=this.endOffset;if(endContainer.type==CKEDITOR.NODE_TEXT)
{var textAfter=CKEDITOR.tools.rtrim(endContainer.substring(endOffset));if(textAfter.length)
return false;}
this.trim();var path=new CKEDITOR.dom.elementPath(this.endContainer);var walkerRange=this.clone();walkerRange.collapse(false);walkerRange.setEndAt(path.block||path.blockLimit,CKEDITOR.POSITION_BEFORE_END);var walker=new CKEDITOR.dom.walker(walkerRange);walker.evaluator=getCheckStartEndBlockEvalFunction(false);return walker.checkForward();},checkReadOnly:(function()
{function checkNodesEditable(node,anotherEnd)
{while(node)
{if(node.type==CKEDITOR.NODE_ELEMENT)
{if(node.getAttribute('contentEditable')=='false'&&!node.data('cke-editable'))
{return 0;}
else if(node.is('html')||node.getAttribute('contentEditable')=='true'&&(node.contains(anotherEnd)||node.equals(anotherEnd)))
{break;}}
node=node.getParent();}
return 1;}
return function()
{var startNode=this.startContainer,endNode=this.endContainer;return!(checkNodesEditable(startNode,endNode)&&checkNodesEditable(endNode,startNode));};})(),moveToElementEditablePosition:function(el,isMoveToEnd)
{var isEditable;if(CKEDITOR.dtd.$empty[el.getName()])
return false;while(el&&el.type==CKEDITOR.NODE_ELEMENT)
{isEditable=el.isEditable();if(isEditable)
this.moveToPosition(el,isMoveToEnd?CKEDITOR.POSITION_BEFORE_END:CKEDITOR.POSITION_AFTER_START);else if(CKEDITOR.dtd.$inline[el.getName()])
{this.moveToPosition(el,isMoveToEnd?CKEDITOR.POSITION_AFTER_END:CKEDITOR.POSITION_BEFORE_START);return true;}
if(CKEDITOR.dtd.$empty[el.getName()])
el=el[isMoveToEnd?'getPrevious':'getNext'](nonWhitespaceOrBookmarkEval);else
el=el[isMoveToEnd?'getLast':'getFirst'](nonWhitespaceOrBookmarkEval);if(el&&el.type==CKEDITOR.NODE_TEXT)
{this.moveToPosition(el,isMoveToEnd?CKEDITOR.POSITION_AFTER_END:CKEDITOR.POSITION_BEFORE_START);return true;}}
return isEditable;},moveToElementEditStart:function(target)
{return this.moveToElementEditablePosition(target);},moveToElementEditEnd:function(target)
{return this.moveToElementEditablePosition(target,true);},getEnclosedNode:function()
{var walkerRange=this.clone();walkerRange.optimize();if(walkerRange.startContainer.type!=CKEDITOR.NODE_ELEMENT||walkerRange.endContainer.type!=CKEDITOR.NODE_ELEMENT)
return null;var walker=new CKEDITOR.dom.walker(walkerRange),isNotBookmarks=CKEDITOR.dom.walker.bookmark(true),isNotWhitespaces=CKEDITOR.dom.walker.whitespaces(true),evaluator=function(node)
{return isNotWhitespaces(node)&&isNotBookmarks(node);};walkerRange.evaluator=evaluator;var node=walker.next();walker.reset();return node&&node.equals(walker.previous())?node:null;},getTouchedStartNode:function()
{var container=this.startContainer;if(this.collapsed||container.type!=CKEDITOR.NODE_ELEMENT)
return container;return container.getChild(this.startOffset)||container;},getTouchedEndNode:function()
{var container=this.endContainer;if(this.collapsed||container.type!=CKEDITOR.NODE_ELEMENT)
return container;return container.getChild(this.endOffset-1)||container;}};})();CKEDITOR.POSITION_AFTER_START=1;CKEDITOR.POSITION_BEFORE_END=2;CKEDITOR.POSITION_BEFORE_START=3;CKEDITOR.POSITION_AFTER_END=4;CKEDITOR.ENLARGE_ELEMENT=1;CKEDITOR.ENLARGE_BLOCK_CONTENTS=2;CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS=3;CKEDITOR.START=1;CKEDITOR.END=2;CKEDITOR.STARTEND=3;CKEDITOR.SHRINK_ELEMENT=1;CKEDITOR.SHRINK_TEXT=2;;(function()
{CKEDITOR.dom.rangeList=function(ranges)
{if(ranges instanceof CKEDITOR.dom.rangeList)
return ranges;if(!ranges)
ranges=[];else if(ranges instanceof CKEDITOR.dom.range)
ranges=[ranges];return CKEDITOR.tools.extend(ranges,mixins);};var mixins={createIterator:function()
{var rangeList=this,bookmark=CKEDITOR.dom.walker.bookmark(),guard=function(node){return!(node.is&&node.is('tr'));},bookmarks=[],current;return{getNextRange:function(mergeConsequent)
{current=current==undefined?0:current+1;var range=rangeList[current];if(range&&rangeList.length>1)
{if(!current)
{for(var i=rangeList.length-1;i>=0;i--)
bookmarks.unshift(rangeList[i].createBookmark(true));}
if(mergeConsequent)
{var mergeCount=0;while(rangeList[current+mergeCount+1])
{var doc=range.document,found=0,left=doc.getById(bookmarks[mergeCount].endNode),right=doc.getById(bookmarks[mergeCount+1].startNode),next;while(1)
{next=left.getNextSourceNode(false);if(!right.equals(next))
{if(bookmark(next)||(next.type==CKEDITOR.NODE_ELEMENT&&next.isBlockBoundary()))
{left=next;continue;}}
else
found=1;break;}
if(!found)
break;mergeCount++;}}
range.moveToBookmark(bookmarks.shift());while(mergeCount--)
{next=rangeList[++current];next.moveToBookmark(bookmarks.shift());range.setEnd(next.endContainer,next.endOffset);}}
return range;}};},createBookmarks:function(serializable)
{var retval=[],bookmark;for(var i=0;i<this.length;i++)
{retval.push(bookmark=this[i].createBookmark(serializable,true));for(var j=i+1;j<this.length;j++)
{this[j]=updateDirtyRange(bookmark,this[j]);this[j]=updateDirtyRange(bookmark,this[j],true);}}
return retval;},createBookmarks2:function(normalized)
{var bookmarks=[];for(var i=0;i<this.length;i++)
bookmarks.push(this[i].createBookmark2(normalized));return bookmarks;},moveToBookmarks:function(bookmarks)
{for(var i=0;i<this.length;i++)
this[i].moveToBookmark(bookmarks[i]);}};function updateDirtyRange(bookmark,dirtyRange,checkEnd)
{var serializable=bookmark.serializable,container=dirtyRange[checkEnd?'endContainer':'startContainer'],offset=checkEnd?'endOffset':'startOffset';var bookmarkStart=serializable?dirtyRange.document.getById(bookmark.startNode):bookmark.startNode;var bookmarkEnd=serializable?dirtyRange.document.getById(bookmark.endNode):bookmark.endNode;if(container.equals(bookmarkStart.getPrevious()))
{dirtyRange.startOffset=dirtyRange.startOffset
-container.getLength()
-bookmarkEnd.getPrevious().getLength();container=bookmarkEnd.getNext();}
else if(container.equals(bookmarkEnd.getPrevious()))
{dirtyRange.startOffset=dirtyRange.startOffset-container.getLength();container=bookmarkEnd.getNext();}
container.equals(bookmarkStart.getParent())&&dirtyRange[offset]++;container.equals(bookmarkEnd.getParent())&&dirtyRange[offset]++;dirtyRange[checkEnd?'endContainer':'startContainer']=container;return dirtyRange;}})();;(function()
{if(CKEDITOR.env.webkit)
{CKEDITOR.env.hc=false;return;}
var hcDetect=CKEDITOR.dom.element.createFromHtml('<div style="width:0px;height:0px;position:absolute;left:-10000px;'+'border: 1px solid;border-color: red blue;"></div>',CKEDITOR.document);hcDetect.appendTo(CKEDITOR.document.getHead());try
{CKEDITOR.env.hc=hcDetect.getComputedStyle('border-top-color')==hcDetect.getComputedStyle('border-right-color');}
catch(e)
{CKEDITOR.env.hc=false;}
if(CKEDITOR.env.hc)
CKEDITOR.env.cssClass+=' cke_hc';hcDetect.remove();})();CKEDITOR.plugins.load(CKEDITOR.config.corePlugins.split(','),function()
{CKEDITOR.status='loaded';CKEDITOR.fire('loaded');var pending=CKEDITOR._.pending;if(pending)
{delete CKEDITOR._.pending;for(var i=0;i<pending.length;i++)
CKEDITOR.add(pending[i]);}});if(CKEDITOR.env.ie)
{try
{document.execCommand('BackgroundImageCache',false,true);}
catch(e)
{}};CKEDITOR.plugins.add('basicstyles',{requires:['styles','button'],init:function(editor)
{var addButtonCommand=function(buttonName,buttonLabel,commandName,styleDefiniton)
{var style=new CKEDITOR.style(styleDefiniton);editor.attachStyleStateChange(style,function(state)
{!editor.readOnly&&editor.getCommand(commandName).setState(state);});editor.addCommand(commandName,new CKEDITOR.styleCommand(style));editor.ui.addButton(buttonName,{label:buttonLabel,command:commandName});};var config=editor.config,lang=editor.lang;addButtonCommand('Bold',lang.bold,'bold',config.coreStyles_bold);addButtonCommand('Italic',lang.italic,'italic',config.coreStyles_italic);addButtonCommand('Underline',lang.underline,'underline',config.coreStyles_underline);addButtonCommand('Strike',lang.strike,'strike',config.coreStyles_strike);addButtonCommand('Subscript',lang.subscript,'subscript',config.coreStyles_subscript);addButtonCommand('Superscript',lang.superscript,'superscript',config.coreStyles_superscript);}});CKEDITOR.config.coreStyles_bold={element:'strong',overrides:'b'};CKEDITOR.config.coreStyles_italic={element:'em',overrides:'i'};CKEDITOR.config.coreStyles_underline={element:'u'};CKEDITOR.config.coreStyles_strike={element:'strike'};CKEDITOR.config.coreStyles_subscript={element:'sub'};CKEDITOR.config.coreStyles_superscript={element:'sup'};;CKEDITOR.plugins.add('button',{beforeInit:function(editor)
{editor.ui.addHandler(CKEDITOR.UI_BUTTON,CKEDITOR.ui.button.handler);}});CKEDITOR.UI_BUTTON='button';CKEDITOR.ui.button=function(definition)
{CKEDITOR.tools.extend(this,definition,{title:definition.label,className:definition.className||(definition.command&&'cke_button_'+definition.command)||'',click:definition.click||function(editor)
{editor.execCommand(definition.command);}});this._={};};CKEDITOR.ui.button.handler={create:function(definition)
{return new CKEDITOR.ui.button(definition);}};(function()
{CKEDITOR.ui.button.prototype={render:function(editor,output)
{var env=CKEDITOR.env,id=this._.id=CKEDITOR.tools.getNextId(),classes='',command=this.command,clickFn;this._.editor=editor;var instance={id:id,button:this,editor:editor,focus:function()
{var element=CKEDITOR.document.getById(id);element.focus();},execute:function()
{this.editor.fire('buttonClick',{button:this.button});if(CKEDITOR.env.ie&&CKEDITOR.env.version<7)
CKEDITOR.tools.setTimeout(function(){this.button.click(editor);},0,this);else
this.button.click(editor);}};var keydownFn=CKEDITOR.tools.addFunction(function(ev)
{if(instance.onkey)
{ev=new CKEDITOR.dom.event(ev);return(instance.onkey(instance,ev.getKeystroke())!==false);}});var focusFn=CKEDITOR.tools.addFunction(function(ev)
{var retVal;if(instance.onfocus)
retVal=(instance.onfocus(instance,new CKEDITOR.dom.event(ev))!==false);if(CKEDITOR.env.gecko&&CKEDITOR.env.version<10900)
ev.preventBubble();return retVal;});instance.clickFn=clickFn=CKEDITOR.tools.addFunction(instance.execute,instance);if(this.modes)
{var modeStates={};function updateState()
{var mode=editor.mode;if(mode)
{var state=this.modes[mode]?modeStates[mode]!=undefined?modeStates[mode]:CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED;this.setState(editor.readOnly&&!this.readOnly?CKEDITOR.TRISTATE_DISABLED:state);}}
editor.on('beforeModeUnload',function()
{if(editor.mode&&this._.state!=CKEDITOR.TRISTATE_DISABLED)
modeStates[editor.mode]=this._.state;},this);editor.on('mode',updateState,this);!this.readOnly&&editor.on('readOnly',updateState,this);}
else if(command)
{command=editor.getCommand(command);if(command)
{command.on('state',function()
{if($.inArray(editor,RTE.loaded)<0){this.setState(CKEDITOR.TRISTATE_DISABLED);return;}
this.setState(command.state);},this);classes+='cke_'+(command.state==CKEDITOR.TRISTATE_ON?'on':command.state==CKEDITOR.TRISTATE_DISABLED?'disabled':'off');}}
if(!command)
classes+='cke_off';if(this.className)
classes+=' '+this.className;if(this.wrapperClassName){classes+=' '+this.wrapperClassName;}
output.push('<span class="cke_button '+classes+(this.icon&&this.icon.indexOf('.png')==-1?' cke_noalphafix':'')+'">','<a id="',id,'"'+' class="',classes,'"',env.gecko&&env.version>=10900&&!env.hc?'':'" href="javascript:void(\''+(this.title||'').replace("'",'')+'\')"',' title="',this.title,'"'+' tabindex="-1"'+' hidefocus="true"'+' role="button"'+' aria-labelledby="'+id+'_label"'+
(this.hasArrow?' aria-haspopup="true"':''));if(env.opera||(env.gecko&&env.mac))
{output.push(' onkeypress="return false;"');}
if(env.gecko)
{output.push(' onblur="this.style.cssText = this.style.cssText;"');}
output.push(' onkeydown="return CKEDITOR.tools.callFunction(',keydownFn,', event);"'+' onfocus="return CKEDITOR.tools.callFunction(',focusFn,', event);" '+
(CKEDITOR.env.ie?'onclick="return false;" onmouseup':'onclick')+'="CKEDITOR.tools.callFunction(',clickFn,', this); return false;">');if(this.hasIcon!==false){output.push('<span class="cke_icon"');if(this.icon)
{var offset=(this.iconOffset||0)*-16;output.push(' style="background-image:url(',CKEDITOR.getUrl(this.icon),');background-position:0 '+offset+'px;"');}
output.push('>&nbsp;</span>');}
output.push('<span id="',id,'_label" class="cke_label">',this.label,'</span>');if(this.hasArrow)
{output.push('<span class="cke_buttonarrow">'
+(CKEDITOR.env.hc?'&#9660;':'&nbsp;')
+'</span>');}
output.push('</a>','</span>');if(this.onRender)
this.onRender();return instance;},setState:function(state)
{if(this._.state==state)
return false;this._.state=state;var element=CKEDITOR.document.getById(this._.id);if(element)
{element.setState(state);state==CKEDITOR.TRISTATE_DISABLED?element.setAttribute('aria-disabled',true):element.removeAttribute('aria-disabled');state==CKEDITOR.TRISTATE_ON?element.setAttribute('aria-pressed',true):element.removeAttribute('aria-pressed');return true;}
else
return false;}};})();CKEDITOR.ui.prototype.addButton=function(name,definition)
{this.add(name,CKEDITOR.UI_BUTTON,definition);};;(function()
{var execIECommand=function(editor,command)
{var doc=editor.document,body=doc.getBody();var enabled=0;var onExec=function()
{enabled=1;};body.on(command,onExec);(CKEDITOR.env.version>7?doc.$:doc.$.selection.createRange())['execCommand'](command);body.removeListener(command,onExec);return enabled;};var tryToCutCopy=CKEDITOR.env.ie?function(editor,type)
{return execIECommand(editor,type);}:function(editor,type)
{try
{return editor.document.$.execCommand(type,false,null);}
catch(e)
{return false;}};var cutCopyCmd=function(type)
{this.type=type;this.canUndo=this.type=='cut';this.startDisabled=true;};cutCopyCmd.prototype={exec:function(editor,data)
{this.type=='cut'&&fixCut(editor);var success=tryToCutCopy(editor,this.type);if(!success)
alert(editor.lang.clipboard[this.type+'Error']);return success;}};var pasteCmd={canUndo:false,exec:CKEDITOR.env.ie?function(editor)
{editor.focus();if(!editor.document.getBody().fire('beforepaste')&&!execIECommand(editor,'paste'))
{editor.fire('pasteDialog');return false;}}:function(editor)
{try
{if(!editor.document.getBody().fire('beforepaste')&&!editor.document.$.execCommand('Paste',false,null))
{throw 0;}}
catch(e)
{setTimeout(function()
{editor.fire('pasteDialog');},0);return false;}}};var onKey=function(event)
{if(this.mode!='wysiwyg')
return;switch(event.data.keyCode)
{case CKEDITOR.CTRL+86:case CKEDITOR.SHIFT+45:var body=this.document.getBody();if(body.fire('beforepasteonkey')){event.cancel();return;}
if(!CKEDITOR.env.ie&&body.fire('beforepaste'))
event.cancel();else if(CKEDITOR.env.opera||CKEDITOR.env.gecko&&CKEDITOR.env.version<10900)
body.fire('paste');return;case CKEDITOR.CTRL+88:case CKEDITOR.SHIFT+46:var editor=this;this.fire('saveSnapshot');setTimeout(function()
{editor.fire('saveSnapshot');},0);}};function cancel(evt){evt.cancel();}
function getClipboardData(evt,mode,callback)
{var doc=this.document;if(doc.getById('cke_pastebin'))
return;if(mode=='text'&&evt.data&&evt.data.$.clipboardData)
{var plain=evt.data.$.clipboardData.getData('text/plain');if(plain)
{evt.data.preventDefault();callback(plain);return;}}
var sel=this.getSelection(),range=new CKEDITOR.dom.range(doc);var pastebin=new CKEDITOR.dom.element(mode=='text'?'textarea':CKEDITOR.env.webkit?'body':'div',doc);pastebin.setAttribute('id','cke_pastebin');CKEDITOR.env.webkit&&pastebin.append(doc.createText('\xa0'));doc.getBody().append(pastebin);pastebin.setStyles({position:'absolute',top:sel.getStartElement().getDocumentPosition().y+'px',width:'1px',height:'1px',overflow:'hidden'});pastebin.setStyle(this.config.contentsLangDirection=='ltr'?'left':'right','-1000px');var bms=sel.createBookmarks();this.on('selectionChange',cancel,null,null,0);if(mode=='text')
pastebin.$.focus();else
{range.setStartAt(pastebin,CKEDITOR.POSITION_AFTER_START);range.setEndAt(pastebin,CKEDITOR.POSITION_BEFORE_END);range.select(true);}
var editor=this;window.setTimeout(function()
{mode=='text'&&CKEDITOR.env.gecko&&editor.focusGrabber.focus();pastebin.remove();editor.removeListener('selectionChange',cancel);var bogusSpan;pastebin=(CKEDITOR.env.webkit&&(bogusSpan=pastebin.getFirst())&&(bogusSpan.is&&bogusSpan.hasClass('Apple-style-span'))?bogusSpan:pastebin);sel.selectBookmarks(bms);callback(pastebin['get'+(mode=='text'?'Value':'Html')]());},0);}
function fixCut(editor)
{if(!CKEDITOR.env.ie||CKEDITOR.env.quirks)
return;var sel=editor.getSelection();var control;if((sel.getType()==CKEDITOR.SELECTION_ELEMENT)&&(control=sel.getSelectedElement()))
{var range=sel.getRanges()[0];var dummy=editor.document.createText('');dummy.insertBefore(control);range.setStartBefore(dummy);range.setEndAfter(control);sel.selectRanges([range]);setTimeout(function()
{if(control.getParent())
{dummy.remove();sel.selectElement(control);}},0);}}
var depressBeforeEvent;function stateFromNamedCommand(command,editor)
{CKEDITOR.env.ie&&(depressBeforeEvent=1);var retval=CKEDITOR.TRISTATE_OFF;try{retval=editor.document.$.queryCommandEnabled(command)?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED;}catch(er){}
depressBeforeEvent=0;return retval;}
var inReadOnly;function setToolbarStates()
{if(this.mode!='wysiwyg')
return;this.getCommand('cut').setState(inReadOnly?CKEDITOR.TRISTATE_DISABLED:stateFromNamedCommand('Cut',this));this.getCommand('copy').setState(stateFromNamedCommand('Copy',this));var pasteState=inReadOnly?CKEDITOR.TRISTATE_DISABLED:CKEDITOR.env.webkit?CKEDITOR.TRISTATE_OFF:stateFromNamedCommand('Paste',this);this.fire('pasteState',pasteState);}
CKEDITOR.plugins.add('clipboard',{requires:['dialog','htmldataprocessor'],init:function(editor)
{editor.on('paste',function(evt)
{var data=evt.data;if(data['html'])
editor.insertHtml(data['html']);else if(data['text'])
editor.insertText(data['text']);setTimeout(function(){editor.fire('afterPaste');},0);},null,null,1000);editor.on('pasteDialog',function(evt)
{setTimeout(function()
{editor.openDialog(editor.config.forcePasteAsPlainText?'pastetext':'paste');},0);});editor.on('pasteState',function(evt)
{editor.getCommand('paste').setState(evt.data);});function addButtonCommand(buttonName,commandName,command,ctxMenuOrder)
{var lang=editor.lang[commandName];editor.addCommand(commandName,command);editor.ui.addButton(buttonName,{label:lang,command:commandName});if(editor.addMenuItems)
{editor.addMenuItem(commandName,{label:lang,command:commandName,group:'clipboard',order:ctxMenuOrder});}}
addButtonCommand('Cut','cut',new cutCopyCmd('cut'),1);addButtonCommand('Copy','copy',new cutCopyCmd('copy'),4);addButtonCommand('Paste','paste',pasteCmd,8);CKEDITOR.dialog.add('paste',CKEDITOR.getUrl(this.path+'dialogs/paste.js'));editor.on('key',onKey,editor);var mode=editor.config.forcePasteAsPlainText?'text':'html';editor.on('contentDom',function()
{var body=editor.document.getBody();body.on(CKEDITOR.env.webkit?'paste':'beforepaste',function(evt)
{if(depressBeforeEvent)
return;var eventData={mode:'html'};editor.fire('beforePaste',eventData);});body.on('contextmenu',function()
{depressBeforeEvent=1;setTimeout(function(){depressBeforeEvent=0;},10);});body.on('beforecut',function(){!depressBeforeEvent&&fixCut(editor);});body.on('mouseup',function(){setTimeout(function(){setToolbarStates.call(editor);},0);},editor);body.on('keyup',setToolbarStates,editor);});editor.on('selectionChange',function(evt)
{inReadOnly=evt.data.selection.getRanges()[0].checkReadOnly();setToolbarStates.call(editor);});if(editor.contextMenu)
{editor.contextMenu.addListener(function(element,selection)
{var readOnly=selection.getRanges()[0].checkReadOnly();return{cut:!readOnly&&stateFromNamedCommand('Cut',editor),copy:stateFromNamedCommand('Copy',editor),paste:!readOnly&&(CKEDITOR.env.webkit?CKEDITOR.TRISTATE_OFF:stateFromNamedCommand('Paste',editor))};});}}});})();CKEDITOR.config.forcePasteAsPlainText=false;;CKEDITOR.plugins.add('contextmenu',{requires:['menu'],onLoad:function()
{CKEDITOR.plugins.contextMenu=CKEDITOR.tools.createClass({base:CKEDITOR.menu,$:function(editor)
{this.base.call(this,editor,{panel:{className:editor.skinClass+' cke_contextmenu',attributes:{'aria-label':editor.lang.contextmenu.options}}});},proto:{addTarget:function(element,nativeContextMenuOnCtrl)
{if(CKEDITOR.env.opera&&!('oncontextmenu'in document.body))
{var contextMenuOverrideButton;element.on('mousedown',function(evt)
{evt=evt.data;if(evt.$.button!=2)
{if(evt.getKeystroke()==CKEDITOR.CTRL+1)
element.fire('contextmenu',evt);return;}
if(nativeContextMenuOnCtrl&&(CKEDITOR.env.mac?evt.$.metaKey:evt.$.ctrlKey))
return;var target=evt.getTarget();if(!contextMenuOverrideButton)
{var ownerDoc=target.getDocument();contextMenuOverrideButton=ownerDoc.createElement('input');contextMenuOverrideButton.$.type='button';ownerDoc.getBody().append(contextMenuOverrideButton);}
contextMenuOverrideButton.setAttribute('style','position:absolute;top:'+(evt.$.clientY-2)+'px;left:'+(evt.$.clientX-2)+'px;width:5px;height:5px;opacity:0.01');});element.on('mouseup',function(evt)
{if(contextMenuOverrideButton)
{contextMenuOverrideButton.remove();contextMenuOverrideButton=undefined;element.fire('contextmenu',evt.data);}});}
element.on('contextmenu',function(event)
{var domEvent=event.data;if(nativeContextMenuOnCtrl&&(CKEDITOR.env.webkit?holdCtrlKey:(CKEDITOR.env.mac?domEvent.$.metaKey:domEvent.$.ctrlKey)))
return;this.originalEvent=new CKEDITOR.dom.event(domEvent.$);domEvent.preventDefault();var offsetParent=domEvent.getTarget().getDocument().getDocumentElement(),offsetX=domEvent.$.clientX,offsetY=domEvent.$.clientY;CKEDITOR.tools.setTimeout(function()
{this.open(offsetParent,null,offsetX,offsetY);},0,this);},this);if(CKEDITOR.env.opera)
{element.on('keypress',function(evt)
{var domEvent=evt.data;if(domEvent.$.keyCode===0)
domEvent.preventDefault();});}
if(CKEDITOR.env.webkit)
{var holdCtrlKey,onKeyDown=function(event)
{holdCtrlKey=CKEDITOR.env.mac?event.data.$.metaKey:event.data.$.ctrlKey;},resetOnKeyUp=function()
{holdCtrlKey=0;};element.on('keydown',onKeyDown);element.on('keyup',resetOnKeyUp);element.on('contextmenu',resetOnKeyUp);}},open:function(offsetParent,corner,offsetX,offsetY)
{this.editor.fire('contextMenuOnOpen',{menu:this});this.editor.focus();offsetParent=offsetParent||CKEDITOR.document.getDocumentElement();this.show(offsetParent,corner,offsetX,offsetY);}}});},beforeInit:function(editor)
{editor.contextMenu=new CKEDITOR.plugins.contextMenu(editor);editor.addCommand('contextMenu',{exec:function()
{editor.contextMenu.open(editor.document.getBody());}});var base=editor.contextMenu._;base.onClickOriginal=base.onClick;base.onClick=function(item){editor.fire('contextMenuOnClick',{menu:editor.contextMenu,item:item});base.onClickOriginal(item);};}});;(function()
{CKEDITOR.plugins.add('enterkey',{requires:['keystrokes','indent'],init:function(editor)
{editor.addCommand('enter',{modes:{wysiwyg:1},editorFocus:false,exec:function(editor){enter(editor);}});editor.addCommand('shiftEnter',{modes:{wysiwyg:1},editorFocus:false,exec:function(editor){shiftEnter(editor);}});var keystrokes=editor.keystrokeHandler.keystrokes;keystrokes[13]='enter';keystrokes[CKEDITOR.SHIFT+13]='shiftEnter';keystrokes[CKEDITOR.SHIFT+13]='enter';}});CKEDITOR.plugins.enterkey={enterBlock:function(editor,mode,range,forceMode)
{range=range||getRange(editor);var doc=range.document;var atBlockStart=range.checkStartOfBlock(),atBlockEnd=range.checkEndOfBlock(),path=new CKEDITOR.dom.elementPath(range.startContainer),block=path.block;if(atBlockStart&&atBlockEnd)
{if(block&&(block.is('li')||block.getParent().is('li')))
{editor.execCommand('outdent');return;}}
else if(block&&block.is('pre'))
{if(!atBlockEnd)
{enterBr(editor,mode,range,forceMode);return;}}
else if(block&&CKEDITOR.dtd.$captionBlock[block.getName()])
{enterBr(editor,mode,range,forceMode);return;}
var blockTag=(mode==CKEDITOR.ENTER_DIV?'div':'p');var splitInfo=range.splitBlock(blockTag);if(!splitInfo)
return;var previousBlock=splitInfo.previousBlock,nextBlock=splitInfo.nextBlock;var isStartOfBlock=splitInfo.wasStartOfBlock,isEndOfBlock=splitInfo.wasEndOfBlock;var node;if(nextBlock)
{node=nextBlock.getParent();if(node.is('li'))
{nextBlock.breakParent(node);nextBlock.move(nextBlock.getNext(),1);}}
else if(previousBlock&&(node=previousBlock.getParent())&&node.is('li'))
{previousBlock.breakParent(node);node=previousBlock.getNext();range.moveToElementEditStart(node);previousBlock.move(previousBlock.getPrevious());}
if(!isStartOfBlock&&!isEndOfBlock)
{if(nextBlock.is('li')&&(node=nextBlock.getFirst(CKEDITOR.dom.walker.invisible(true)))&&node.is&&node.is('ul','ol'))
(CKEDITOR.env.ie?doc.createText('\xa0'):doc.createElement('br')).insertBefore(node);if(nextBlock){if(nextBlock.is('p')){var firstChild=nextBlock.getFirst();if(firstChild.$.nodeType!=CKEDITOR.NODE_COMMENT){nextBlock.setAttribute('data-rte-empty-lines-before',1);}
nextBlock.setAttribute('data-rte-fromparser',1);}
range.moveToElementEditStart(nextBlock);}}
else
{var newBlock,newBlockDir;if(previousBlock)
{if(previousBlock.is('li')||!(headerTagRegex.test(previousBlock.getName())||previousBlock.is('pre')))
{newBlock=previousBlock.clone();}
if(previousBlock.hasClass('quote')){newBlock=new CKEDITOR.dom.element('p');}
if(previousBlock.isReadOnly())newBlock=null;}
else if(nextBlock){if(nextBlock.hasClass('quote')){newBlock=new CKEDITOR.dom.element('p');}else{newBlock=nextBlock.clone();}
if(nextBlock.isReadOnly())newBlock=null;}
if(!newBlock)
{if(node&&node.is('li'))
newBlock=node;else
{newBlock=doc.createElement(blockTag);if(previousBlock&&(newBlockDir=previousBlock.getDirection()))
newBlock.setAttribute('dir',newBlockDir);}}
else if(forceMode&&!newBlock.is('li'))
newBlock.renameNode(blockTag);if(newBlock.is('dl')){newBlock=new CKEDITOR.dom.element('p');}
var elementPath=splitInfo.elementPath;if(elementPath)
{var notEditableIndex=-1;for(var i=elementPath.elements.length-1;i>=0;i--){if(elementPath.elements[i].$.contentEditable=="false"){notEditableIndex=i;break;}}
for(var i=0,len=elementPath.elements.length;i<len;i++)
{var element=elementPath.elements[i];if(element.equals(elementPath.block)||element.equals(elementPath.blockLimit))
break;if(i<=notEditableIndex){continue;}
if(CKEDITOR.dtd.$removeEmpty[element.getName()])
{element=element.clone();newBlock.moveChildren(element);newBlock.append(element);}}}
if(!CKEDITOR.env.ie)
newBlock.appendBogus();newBlock.setAttribute('data-rte-new-node',true);newBlock.removeAttribute('data-rte-fromparser');newBlock.removeAttribute('data-rte-empty-lines-before');if(!newBlock.getParent())
range.insertNode(newBlock);newBlock.is('li')&&newBlock.removeAttribute('value');if(CKEDITOR.env.ie&&isStartOfBlock&&(!isEndOfBlock||!previousBlock.getChildCount()))
{range.moveToElementEditStart(isEndOfBlock?previousBlock:newBlock);range.select();}
range.moveToElementEditStart(isStartOfBlock&&!isEndOfBlock?nextBlock:newBlock);}
if(!CKEDITOR.env.ie)
{if(nextBlock)
{var tmpNode=doc.createElement('span');tmpNode.setHtml('&nbsp;');range.insertNode(tmpNode);tmpNode.scrollIntoView();range.deleteContents();}
else
{newBlock.scrollIntoView();}}
range.select();},enterBr:function(editor,mode,range,forceMode)
{range=range||getRange(editor);if(!range)
return;if(!range)
return;var doc=range.document;var blockTag=(mode==CKEDITOR.ENTER_DIV?'div':'p');var isEndOfBlock=range.checkEndOfBlock();var elementPath=new CKEDITOR.dom.elementPath(editor.getSelection().getStartElement());var startBlock=elementPath.block,startBlockTag=startBlock&&elementPath.block.getName();var isPre=false;if(!forceMode&&startBlockTag=='li')
{enterBlock(editor,mode,range,forceMode);return;}
if(!forceMode&&isEndOfBlock&&headerTagRegex.test(startBlockTag))
{var newBlock,newBlockDir;if((newBlockDir=startBlock.getDirection()))
{newBlock=doc.createElement('div');newBlock.setAttribute('dir',newBlockDir);newBlock.insertAfter(startBlock);range.setStart(newBlock,0);}
else
{doc.createElement('br').insertAfter(startBlock);if(CKEDITOR.env.gecko)
doc.createText('').insertAfter(startBlock);range.setStartAt(startBlock.getNext(),CKEDITOR.env.ie?CKEDITOR.POSITION_BEFORE_START:CKEDITOR.POSITION_AFTER_START);}}
else
{var lineBreak;isPre=(startBlockTag=='pre');if(isPre&&!CKEDITOR.env.gecko)
lineBreak=doc.createText(CKEDITOR.env.ie?'\r':'\n');else{lineBreak=doc.createElement('br');lineBreak.setAttribute('data-rte-shift-enter',true);if(headerTagRegex.test(startBlockTag)){return;}}
range.deleteContents();range.insertNode(lineBreak);if(CKEDITOR.env.ie)
range.setStartAt(lineBreak,CKEDITOR.POSITION_AFTER_END);else
{doc.createText('\ufeff').insertAfter(lineBreak);if(isEndOfBlock)
lineBreak.getParent().appendBogus();lineBreak.getNext().$.nodeValue='';range.setStartAt(lineBreak.getNext(),CKEDITOR.POSITION_AFTER_START);var dummy=null;if(!CKEDITOR.env.gecko)
{dummy=doc.createElement('span');dummy.setHtml('&nbsp;');}
else
dummy=doc.createElement('br');dummy.insertBefore(lineBreak.getNext());dummy.scrollIntoView();dummy.remove();}}
range.collapse(true);range.select(isPre);}};var plugin=CKEDITOR.plugins.enterkey,enterBr=plugin.enterBr,enterBlock=plugin.enterBlock,headerTagRegex=/^h[1-6]$/;function shiftEnter(editor)
{if(editor.mode!='wysiwyg')
return false;return enter(editor,editor.config.shiftEnterMode,1);}
function enter(editor,mode,forceMode)
{forceMode=editor.config.forceEnterMode||forceMode;if(editor.mode!='wysiwyg')
return false;if(!mode)
mode=editor.config.enterMode;setTimeout(function()
{editor.fire('saveSnapshot');if(mode==CKEDITOR.ENTER_BR)
enterBr(editor,mode,null,forceMode);else
enterBlock(editor,mode,null,forceMode);},0);return true;}
function getRange(editor)
{var ranges=editor.getSelection().getRanges(true);if(ranges.length==0){ranges=editor.getSelection().getRanges(false);var range=ranges[0];var xStartPath=new CKEDITOR.dom.elementPath(range.startContainer),xEndPath=new CKEDITOR.dom.elementPath(range.endContainer);if(!xEndPath.isContentEditable()){var notEditableParent=range.endContainer.isReadOnly();if(notEditableParent.is('p','div')){range.setEndAt(notEditableParent,CKEDITOR.POSITION_BEFORE_END);}else{range.setEndAfter(notEditableParent);}
range.collapse(false);}else{range.collapse(false);}
ranges=new CKEDITOR.dom.rangeList([range]);editor.getSelection().selectRanges(ranges);editor.getSelection().reset();if(!CKEDITOR.env.ie){ranges=editor.getSelection().getRanges(false);}}
if(ranges.length==0){ranges=editor.getSelection().getRanges(false);var range=ranges[0];var xStartPath=new CKEDITOR.dom.elementPath(range.startContainer),xEndPath=new CKEDITOR.dom.elementPath(range.endContainer);if(!xStartPath.isContentEditable()||!xEndPath.isContentEditable()){var notEditableParent=range.endContainer.isReadOnly();if(notEditableParent.is('p','div')){range.setEndAt(notEditableParent,CKEDITOR.POSITION_BEFORE_END);}else{range.setEndAfter(notEditableParent);}
range.collapse(false);}
editor.getSelection().selectRanges(new CKEDITOR.dom.rangeList([range]));ranges=editor.getSelection().getRanges(false);}
for(var i=ranges.length-1;i>0;i--)
{ranges[i].deleteContents();}
return ranges[0];}})();;CKEDITOR.plugins.add('format',{requires:['richcombo','styles'],init:function(editor)
{var config=editor.config,lang=editor.lang.format;var tags=config.format_tags.split(';');var styles={};for(var i=0;i<tags.length;i++)
{var tag=tags[i];styles[tag]=new CKEDITOR.style(config['format_'+tag]);styles[tag]._.enterMode=editor.config.enterMode;}
var disabledElements=config.format_disabled.split(';');editor.ui.addRichCombo('Format',{label:lang.label,title:lang.panelTitle,className:'cke_format',panel:{css:editor.skin.editor.css.concat(config.contentsCss),multiSelect:false,attributes:{'aria-label':lang.panelTitle}},init:function()
{this.startGroup(lang.panelTitle);for(var tag in styles)
{var label=lang['tag_'+tag];this.add(tag,styles[tag].buildPreview(label),label);}},onClick:function(value)
{editor.focus();editor.fire('saveSnapshot');var style=styles[value],elementPath=new CKEDITOR.dom.elementPath(editor.getSelection().getStartElement());style[style.checkActive(elementPath)?'remove':'apply'](editor.document);setTimeout(function()
{editor.fire('saveSnapshot');},0);},onRender:function()
{editor.on('selectionChange',function(ev)
{var currentTag=this.getValue();var elementPath=ev.data.path;if(jQuery.inArray(currentTag,disabledElements)>-1){this.setState(CKEDITOR.TRISTATE_DISABLED);return;}
else{this.setState(CKEDITOR.TRISTATE_OFF);}
for(var tag in styles)
{if(styles[tag].checkActive(elementPath))
{if(tag!=currentTag)
this.setValue(tag,editor.lang.format['tag_'+tag]);return;}}
this.setValue('');},this);}});}});CKEDITOR.config.format_tags='p;h1;h2;h3;h4;h5;h6;pre;address;div';CKEDITOR.config.format_p={element:'p'};CKEDITOR.config.format_div={element:'div'};CKEDITOR.config.format_pre={element:'pre'};CKEDITOR.config.format_address={element:'address'};CKEDITOR.config.format_h1={element:'h1'};CKEDITOR.config.format_h2={element:'h2'};CKEDITOR.config.format_h3={element:'h3'};CKEDITOR.config.format_h4={element:'h4'};CKEDITOR.config.format_h5={element:'h5'};CKEDITOR.config.format_h6={element:'h6'};CKEDITOR.config.format_disabled='li;dt;dd';;(function()
{var tailNbspRegex=/^[\t\r\n ]*(?:&nbsp;|\xa0)$/;var protectedSourceMarker='{cke_protected}';function isRawBr(node){return node.type==CKEDITOR.NODE_ELEMENT&&node.name=='br'&&(typeof node.attributes['data-rte-washtml']=='undefined');}
function lastNoneSpaceChild(block)
{var lastIndex=block.children.length,last=block.children[lastIndex-1];while(last&&last.type==CKEDITOR.NODE_TEXT&&!CKEDITOR.tools.trim(last.value))
last=block.children[--lastIndex];return last;}
function trimFillers(block,fromSource)
{var children=block.children,lastChild=lastNoneSpaceChild(block);if(lastChild)
{if((fromSource||!CKEDITOR.env.ie)&&isRawBr(lastChild))
children.pop();if(lastChild.type==CKEDITOR.NODE_TEXT&&tailNbspRegex.test(lastChild.value))
children.pop();}}
function blockNeedsExtension(block,fromSource,extendEmptyBlock)
{if(!fromSource&&(!extendEmptyBlock||typeof extendEmptyBlock=='function'&&(extendEmptyBlock(block)===false)))
return false;if(fromSource&&CKEDITOR.env.ie&&(document.documentMode>7||block.name in CKEDITOR.dtd.tr||block.name in CKEDITOR.dtd.$listItem))
return false;var lastChild=lastNoneSpaceChild(block);return!lastChild||lastChild&&(block.name=='form'&&lastChild.name=='input');}
function getBlockExtension(isOutput,emptyBlockFiller)
{return function(node)
{trimFillers(node,!isOutput);if(blockNeedsExtension(node,!isOutput,emptyBlockFiller))
{if(isOutput||CKEDITOR.env.ie)
node.add(new CKEDITOR.htmlParser.text('\xa0'));else
node.add(new CKEDITOR.htmlParser.element('br',{}));}};}
var dtd=CKEDITOR.dtd;var tableOrder=['caption','colgroup','col','thead','tfoot','tbody'];var blockLikeTags=CKEDITOR.tools.extend({},dtd.$block,dtd.$listItem,dtd.$tableContent);for(var i in blockLikeTags)
{if(!('br'in dtd[i]))
delete blockLikeTags[i];}
delete blockLikeTags.pre;var defaultDataFilterRules={elements:{},attributeNames:[[(/^on/),'data-cke-pa-on']]};var defaultDataBlockFilterRules={elements:{}};for(i in blockLikeTags)
defaultDataBlockFilterRules.elements[i]=getBlockExtension();var defaultHtmlFilterRules={elementNames:[[(/^cke:/),''],[(/^\?xml:namespace$/),'']],attributeNames:[[(/^data-cke-(saved|pa)-/),''],[(/^data-cke-.*/),''],['hidefocus','']],elements:{$:function(element)
{var attribs=element.attributes;if(attribs)
{if(attribs['data-cke-temp'])
return false;var attributeNames=['name','href','src'],savedAttributeName;for(var i=0;i<attributeNames.length;i++)
{savedAttributeName='data-cke-saved-'+attributeNames[i];savedAttributeName in attribs&&(delete attribs[attributeNames[i]]);}}
return element;},table:function(element)
{var children=element.children;children.sort(function(node1,node2)
{return node1.type==CKEDITOR.NODE_ELEMENT&&node2.type==node1.type?CKEDITOR.tools.indexOf(tableOrder,node1.name)>CKEDITOR.tools.indexOf(tableOrder,node2.name)?1:-1:0;});},embed:function(element)
{var parent=element.parent;if(parent&&parent.name=='object')
{var parentWidth=parent.attributes.width,parentHeight=parent.attributes.height;parentWidth&&(element.attributes.width=parentWidth);parentHeight&&(element.attributes.height=parentHeight);}},param:function(param)
{param.children=[];param.isEmpty=true;return param;},a:function(element)
{if(!(element.children.length||element.attributes.name||element.attributes['data-cke-saved-name']))
{return false;}},span:function(element)
{if(element.attributes['class']=='Apple-style-span')
delete element.name;},pre:function(element){CKEDITOR.env.ie&&trimFillers(element);},html:function(element)
{delete element.attributes.contenteditable;delete element.attributes['class'];},body:function(element)
{delete element.attributes.spellcheck;delete element.attributes.contenteditable;},style:function(element)
{var child=element.children[0];child&&child.value&&(child.value=CKEDITOR.tools.trim(child.value));if(!element.attributes.type)
element.attributes.type='text/css';},title:function(element)
{var titleText=element.children[0];titleText&&(titleText.value=element.attributes['data-cke-title']||'');}},attributes:{'class':function(value,element)
{return CKEDITOR.tools.ltrim(value.replace(/(?:^|\s+)cke_[^\s]*/g,''))||false;}}};if(CKEDITOR.env.ie)
{defaultHtmlFilterRules.attributes.style=function(value,element)
{return value.replace(/(^|;)([^\:]+)/g,function(match)
{return match.toLowerCase();});};}
function protectReadOnly(element)
{var attrs=element.attributes;if(attrs.contenteditable!="false")
attrs['data-cke-editable']=attrs.contenteditable?'true':1;attrs.contenteditable="false";}
function unprotectReadyOnly(element)
{var attrs=element.attributes;switch(attrs['data-cke-editable'])
{case'true':attrs.contenteditable='true';break;case'1':delete attrs.contenteditable;break;}}
for(i in{input:1,textarea:1})
{defaultDataFilterRules.elements[i]=protectReadOnly;defaultHtmlFilterRules.elements[i]=unprotectReadyOnly;}
var protectElementRegex=/<(a|area|img|input)\b([^>]*)>/gi,protectAttributeRegex=/\b(href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+))/gi;var protectElementsRegex=/(?:<style(?=[ >])[^>]*>[\s\S]*<\/style>)|(?:<(:?link|meta|base)[^>]*>)/gi,encodedElementsRegex=/<cke:encoded>([^<]*)<\/cke:encoded>/gi;var protectElementNamesRegex=/(<\/?)((?:object|embed|param|html|body|head|title)[^>]*>)/gi,unprotectElementNamesRegex=/(<\/?)cke:((?:html|body|head|title)[^>]*>)/gi;var protectSelfClosingRegex=/<cke:(param|embed)([^>]*?)\/?>(?!\s*<\/cke:\1)/gi;function protectAttributes(html)
{return html.replace(protectElementRegex,function(element,tag,attributes)
{return'<'+tag+attributes.replace(protectAttributeRegex,function(fullAttr,attrName)
{if(attributes.indexOf('data-cke-saved-'+attrName)==-1)
return' data-cke-saved-'+fullAttr+' '+fullAttr;return fullAttr;})+'>';});}
function protectElements(html)
{return html.replace(protectElementsRegex,function(match)
{return'<cke:encoded>'+encodeURIComponent(match)+'</cke:encoded>';});}
function unprotectElements(html)
{return html.replace(encodedElementsRegex,function(match,encoded)
{return decodeURIComponent(encoded);});}
function protectElementsNames(html)
{return html.replace(protectElementNamesRegex,'$1cke:$2');}
function unprotectElementNames(html)
{return html.replace(unprotectElementNamesRegex,'$1$2');}
function protectSelfClosingElements(html)
{return html.replace(protectSelfClosingRegex,'<cke:$1$2></cke:$1>');}
function protectPreFormatted(html)
{return html.replace(/(<pre\b[^>]*>)(\r\n|\n)/g,'$1$2$2');}
function protectRealComments(html)
{return html.replace(/<!--(?!{cke_protected})[\s\S]+?-->/g,function(match)
{return'<!--'+protectedSourceMarker+'{C}'+
encodeURIComponent(match).replace(/--/g,'%2D%2D')+'-->';});}
function unprotectRealComments(html)
{return html.replace(/<!--\{cke_protected\}\{C\}([\s\S]+?)-->/g,function(match,data)
{return decodeURIComponent(data);});}
function unprotectSource(html,editor)
{var store=editor._.dataStore;return html.replace(/<!--\{cke_protected\}([\s\S]+?)-->/g,function(match,data)
{return decodeURIComponent(data);}).replace(/\{cke_protected_(\d+)\}/g,function(match,id)
{return store&&store[id]||'';});}
function protectSource(data,editor)
{var protectedHtml=[],protectRegexes=editor.config.protectedSource,store=editor._.dataStore||(editor._.dataStore={id:1}),tempRegex=/<\!--\{cke_temp(comment)?\}(\d*?)-->/g;var regexes=[(/<script[\s\S]*?<\/script>/gi),/<noscript[\s\S]*?<\/noscript>/gi].concat(protectRegexes);data=data.replace((/<!--[\s\S]*?-->/g),function(match)
{return'<!--{cke_tempcomment}'+(protectedHtml.push(match)-1)+'-->';});for(var i=0;i<regexes.length;i++)
{data=data.replace(regexes[i],function(match)
{match=match.replace(tempRegex,function($,isComment,id)
{return protectedHtml[id];});return(/cke_temp(comment)?/).test(match)?match:'<!--{cke_temp}'+(protectedHtml.push(match)-1)+'-->';});}
data=data.replace(tempRegex,function($,isComment,id)
{return'<!--'+protectedSourceMarker+
(isComment?'{C}':'')+
encodeURIComponent(protectedHtml[id]).replace(/--/g,'%2D%2D')+'-->';});return data.replace(/<[^>]*(['"]).*?\1*>/g,function(match)
{return match.replace(/<!--\{cke_protected\}([\s\S]+?)-->/g,function(match,data)
{store[store.id]=decodeURIComponent(data);return'{cke_protected_'+(store.id++)+'}';});});}
CKEDITOR.plugins.add('htmldataprocessor',{requires:['htmlwriter'],init:function(editor)
{var dataProcessor=editor.dataProcessor=new CKEDITOR.htmlDataProcessor(editor);dataProcessor.writer.forceSimpleAmpersand=editor.config.forceSimpleAmpersand;dataProcessor.dataFilter.addRules(defaultDataFilterRules);dataProcessor.dataFilter.addRules(defaultDataBlockFilterRules);dataProcessor.htmlFilter.addRules(defaultHtmlFilterRules);var defaultHtmlBlockFilterRules={elements:{}};for(i in blockLikeTags)
defaultHtmlBlockFilterRules.elements[i]=getBlockExtension(true,editor.config.fillEmptyBlocks);dataProcessor.htmlFilter.addRules(defaultHtmlBlockFilterRules);},onLoad:function()
{!('fillEmptyBlocks'in CKEDITOR.config)&&(CKEDITOR.config.fillEmptyBlocks=1);}});CKEDITOR.htmlDataProcessor=function(editor)
{this.editor=editor;this.writer=new CKEDITOR.htmlWriter();this.dataFilter=new CKEDITOR.htmlParser.filter();this.htmlFilter=new CKEDITOR.htmlParser.filter();};CKEDITOR.htmlDataProcessor.prototype={toHtml:function(data,fixForBody)
{data=protectSource(data,this.editor);data=protectAttributes(data);data=protectElements(data);data=protectElementsNames(data);data=protectSelfClosingElements(data);data=protectPreFormatted(data);var div=new CKEDITOR.dom.element('div');div.setHtml('a'+data);data=div.getHtml().substr(1);data=unprotectElementNames(data);data=unprotectElements(data);data=unprotectRealComments(data);var fragment=CKEDITOR.htmlParser.fragment.fromHtml(data,fixForBody),writer=new CKEDITOR.htmlParser.basicWriter();fragment.writeHtml(writer,this.dataFilter);data=writer.getHtml(true);data=protectRealComments(data);return data;},toDataFormat:function(html,fixForBody)
{var writer=this.writer,fragment=CKEDITOR.htmlParser.fragment.fromHtml(html,fixForBody);writer.reset();fragment.writeHtml(writer,this.htmlFilter);var data=writer.getHtml(true);data=unprotectRealComments(data);data=unprotectSource(data,this.editor);return data;}};})();;(function()
{var listNodeNames={ol:1,ul:1},isNotWhitespaces=CKEDITOR.dom.walker.whitespaces(true),isNotBookmark=CKEDITOR.dom.walker.bookmark(false,true);function onSelectionChange(evt)
{if(evt.editor.readOnly)
return null;var editor=evt.editor;var path=evt.data.path,nodeName=path.block?path.block.getName():'';if((/h\d/).test(nodeName)){return this.setState(CKEDITOR.TRISTATE_DISABLED);}
if(nodeName=='p'){var align=path.block.getStyle('text-align');if((align=='center')||(align=='right')){return this.setState(CKEDITOR.TRISTATE_DISABLED);}}
var elementPath=evt.data.path,list=elementPath&&elementPath.contains(listNodeNames),firstBlock=elementPath.block||elementPath.blockLimit;if(list)
return this.setState(CKEDITOR.TRISTATE_OFF);if(!this.useIndentClasses&&this.name=='indent')
return this.setState(CKEDITOR.TRISTATE_OFF);if(!firstBlock)
return this.setState(CKEDITOR.TRISTATE_DISABLED);if(this.useIndentClasses)
{var indentClass=firstBlock.$.className.match(this.classNameRegex),indentStep=0;if(indentClass)
{indentClass=indentClass[1];indentStep=this.indentClassMap[indentClass];}
if((this.name=='outdent'&&!indentStep)||(this.name=='indent'&&indentStep==editor.config.indentClasses.length))
return this.setState(CKEDITOR.TRISTATE_DISABLED);return this.setState(CKEDITOR.TRISTATE_OFF);}
else
{var indent=parseInt(firstBlock.getStyle(getIndentCssProperty(firstBlock)),10);if(isNaN(indent))
indent=0;if(indent<=0)
return this.setState(CKEDITOR.TRISTATE_DISABLED);return this.setState(CKEDITOR.TRISTATE_OFF);}}
function indentCommand(editor,name)
{this.name=name;this.useIndentClasses=editor.config.indentClasses&&editor.config.indentClasses.length>0;if(this.useIndentClasses)
{this.classNameRegex=new RegExp('(?:^|\\s+)('+editor.config.indentClasses.join('|')+')(?=$|\\s)');this.indentClassMap={};for(var i=0;i<editor.config.indentClasses.length;i++)
this.indentClassMap[editor.config.indentClasses[i]]=i+1;}
this.startDisabled=name=='outdent';}
function getIndentCssProperty(element,dir)
{return(dir||element.getComputedStyle('direction'))=='ltr'?'margin-left':'margin-right';}
function isListItem(node)
{return node.type=CKEDITOR.NODE_ELEMENT&&node.is('li');}
indentCommand.prototype={exec:function(editor)
{var self=this,database={};function indentList(listNode)
{var startContainer=range.startContainer,endContainer=range.endContainer;while(startContainer&&!startContainer.getParent().equals(listNode))
startContainer=startContainer.getParent();while(endContainer&&!endContainer.getParent().equals(listNode))
endContainer=endContainer.getParent();if(!startContainer||!endContainer)
return;var block=startContainer,itemsToMove=[],stopFlag=false;while(!stopFlag)
{if(block.equals(endContainer))
stopFlag=true;itemsToMove.push(block);block=block.getNext();}
if(itemsToMove.length<1)
return;var listParents=listNode.getParents(true);for(var i=0;i<listParents.length;i++)
{if(listParents[i].getName&&listNodeNames[listParents[i].getName()])
{listNode=listParents[i];break;}}
var indentOffset=self.name=='indent'?1:-1,startItem=itemsToMove[0],lastItem=itemsToMove[itemsToMove.length-1];var listArray=CKEDITOR.plugins.list.listToArray(listNode,database);listArray[lastItem.getCustomData('listarray_index')].toIndent=true;var baseIndent=listArray[lastItem.getCustomData('listarray_index')].indent;for(i=startItem.getCustomData('listarray_index');i<=lastItem.getCustomData('listarray_index');i++)
{listArray[i].indent+=indentOffset;var listRoot=listArray[i].parent;listArray[i].parent=new CKEDITOR.dom.element(listRoot.getName(),listRoot.getDocument());}
for(i=lastItem.getCustomData('listarray_index')+1;i<listArray.length&&listArray[i].indent>baseIndent;i++)
listArray[i].indent+=indentOffset;var newList=CKEDITOR.plugins.list.arrayToList(listArray,database,null,editor.config.enterMode,listNode.getDirection());if(self.name=='outdent')
{var parentLiElement;if((parentLiElement=listNode.getParent())&&parentLiElement.is('li'))
{var children=newList.listNode.getChildren(),pendingLis=[],count=children.count(),child;for(i=count-1;i>=0;i--)
{if((child=children.getItem(i))&&child.is&&child.is('li'))
pendingLis.push(child);}}}
if(newList)
newList.listNode.replace(listNode);if(pendingLis&&pendingLis.length)
{for(i=0;i<pendingLis.length;i++)
{var li=pendingLis[i],followingList=li;while((followingList=followingList.getNext())&&followingList.is&&followingList.getName()in listNodeNames)
{if(CKEDITOR.env.ie&&!li.getFirst(function(node){return isNotWhitespaces(node)&&isNotBookmark(node);}))
li.append(range.document.createText('\u00a0'));li.append(followingList);}
li.insertAfter(parentLiElement);}}}
function indentBlock()
{var iterator=range.createIterator(),enterMode=editor.config.enterMode;iterator.enforceRealBlocks=true;iterator.enlargeBr=enterMode!=CKEDITOR.ENTER_BR;var block;while((block=iterator.getNextParagraph(enterMode==CKEDITOR.ENTER_P?'p':'div')))
indentElement(block);}
function indentElement(element,dir)
{if(element.getCustomData('indent_processed'))
return false;if(self.useIndentClasses)
{var indentClass=element.$.className.match(self.classNameRegex),indentStep=0;if(indentClass)
{indentClass=indentClass[1];indentStep=self.indentClassMap[indentClass];}
if(self.name=='outdent')
indentStep--;else
indentStep++;if(indentStep<0)
return false;indentStep=Math.min(indentStep,editor.config.indentClasses.length);indentStep=Math.max(indentStep,0);element.$.className=CKEDITOR.tools.ltrim(element.$.className.replace(self.classNameRegex,''));if(indentStep>0)
element.addClass(editor.config.indentClasses[indentStep-1]);}
else
{var indentCssProperty=getIndentCssProperty(element,dir),currentOffset=parseInt(element.getStyle(indentCssProperty),10);if(isNaN(currentOffset))
currentOffset=0;var indentOffset=editor.config.indentOffset||40;currentOffset+=(self.name=='indent'?1:-1)*indentOffset;if(currentOffset<0)
return false;currentOffset=Math.max(currentOffset,0);currentOffset=Math.ceil(currentOffset/indentOffset)*indentOffset;element.setStyle(indentCssProperty,currentOffset?currentOffset+(editor.config.indentUnit||'px'):'');if(element.getAttribute('style')==='')
element.removeAttribute('style');}
CKEDITOR.dom.element.setMarker(database,element,'indent_processed',1);return true;}
var selection=editor.getSelection(),bookmarks=selection.createBookmarks(1),ranges=selection&&selection.getRanges(1),range;var iterator=ranges.createIterator();while((range=iterator.getNextRange()))
{var rangeRoot=range.getCommonAncestor(),nearestListBlock=rangeRoot;while(nearestListBlock&&!(nearestListBlock.type==CKEDITOR.NODE_ELEMENT&&listNodeNames[nearestListBlock.getName()]))
nearestListBlock=nearestListBlock.getParent();if(!nearestListBlock)
{var selectedNode=range.getEnclosedNode();if(selectedNode&&selectedNode.type==CKEDITOR.NODE_ELEMENT&&selectedNode.getName()in listNodeNames)
{range.setStartAt(selectedNode,CKEDITOR.POSITION_AFTER_START);range.setEndAt(selectedNode,CKEDITOR.POSITION_BEFORE_END);nearestListBlock=selectedNode;}}
if(nearestListBlock&&range.startContainer.type==CKEDITOR.NODE_ELEMENT&&range.startContainer.getName()in listNodeNames)
{var walker=new CKEDITOR.dom.walker(range);walker.evaluator=isListItem;range.startContainer=walker.next();}
if(nearestListBlock&&range.endContainer.type==CKEDITOR.NODE_ELEMENT&&range.endContainer.getName()in listNodeNames)
{walker=new CKEDITOR.dom.walker(range);walker.evaluator=isListItem;range.endContainer=walker.previous();}
if(nearestListBlock)
{var firstListItem=nearestListBlock.getFirst(isListItem),hasMultipleItems=!!firstListItem.getNext(isListItem),rangeStart=range.startContainer,indentWholeList=firstListItem.equals(rangeStart)||firstListItem.contains(rangeStart);if(!(indentWholeList&&(self.name=='indent'||self.useIndentClasses||parseInt(nearestListBlock.getStyle(getIndentCssProperty(nearestListBlock)),10))&&indentElement(nearestListBlock,!hasMultipleItems&&firstListItem.getDirection())))
indentList(nearestListBlock);}
else
indentBlock();}
CKEDITOR.dom.element.clearAllMarkers(database);editor.forceNextSelectionCheck();selection.selectBookmarks(bookmarks);}};CKEDITOR.plugins.add('indent',{init:function(editor)
{var indent=editor.addCommand('indent',new indentCommand(editor,'indent')),outdent=editor.addCommand('outdent',new indentCommand(editor,'outdent'));editor.ui.addButton('Indent',{label:editor.lang.indent,command:'indent'});editor.ui.addButton('Outdent',{label:editor.lang.outdent,command:'outdent'});editor.on('selectionChange',CKEDITOR.tools.bind(onSelectionChange,indent));editor.on('selectionChange',CKEDITOR.tools.bind(onSelectionChange,outdent));if(CKEDITOR.env.ie6Compat||CKEDITOR.env.ie7Compat)
{editor.addCss("ul,ol"+"{"+" margin-left: 0px;"+" padding-left: 40px;"+"}");}
editor.on('dirChanged',function(e)
{var range=new CKEDITOR.dom.range(editor.document);range.setStartBefore(e.data.node);range.setEndAfter(e.data.node);var walker=new CKEDITOR.dom.walker(range),node;while((node=walker.next()))
{if(node.type==CKEDITOR.NODE_ELEMENT)
{if(!node.equals(e.data.node)&&node.getDirection())
{range.setStartAfter(node);walker=new CKEDITOR.dom.walker(range);continue;}
var classes=editor.config.indentClasses;if(classes)
{var suffix=(e.data.dir=='ltr')?['_rtl','']:['','_rtl'];for(var i=0;i<classes.length;i++)
{if(node.hasClass(classes[i]+suffix[0]))
{node.removeClass(classes[i]+suffix[0]);node.addClass(classes[i]+suffix[1]);}}}
var marginLeft=node.getStyle('margin-right'),marginRight=node.getStyle('margin-left');marginLeft?node.setStyle('margin-left',marginLeft):node.removeStyle('margin-left');marginRight?node.setStyle('margin-right',marginRight):node.removeStyle('margin-right');}}});},requires:['domiterator','list']});})();;CKEDITOR.plugins.add('keystrokes',{beforeInit:function(editor)
{editor.keystrokeHandler=new CKEDITOR.keystrokeHandler(editor);editor.specialKeys={};},init:function(editor)
{var keystrokesConfig=editor.config.keystrokes,blockedConfig=editor.config.blockedKeystrokes;var keystrokes=editor.keystrokeHandler.keystrokes,blockedKeystrokes=editor.keystrokeHandler.blockedKeystrokes;for(var i=0;i<keystrokesConfig.length;i++)
keystrokes[keystrokesConfig[i][0]]=keystrokesConfig[i][1];for(i=0;i<blockedConfig.length;i++)
blockedKeystrokes[blockedConfig[i]]=1;}});CKEDITOR.keystrokeHandler=function(editor)
{if(editor.keystrokeHandler)
return editor.keystrokeHandler;this.keystrokes={};this.blockedKeystrokes={};this._={editor:editor};return this;};(function()
{var cancel;var onKeyDown=function(event)
{event=event.data;var keyCombination=event.getKeystroke();var command=this.keystrokes[keyCombination];var editor=this._.editor;cancel=(editor.fire('key',{keyCode:keyCombination})===true);if(!cancel)
{if(command)
{var data={from:'keystrokeHandler'};cancel=(editor.execCommand(command,data)!==false);}
if(!cancel)
{var handler=editor.specialKeys[keyCombination];cancel=(handler&&handler(editor)===true);if(!cancel)
cancel=!!this.blockedKeystrokes[keyCombination];}}
if(cancel)
event.preventDefault(true);return!cancel;};var onKeyPress=function(event)
{if(cancel)
{cancel=false;event.data.preventDefault(true);}};var onKeyUp=function(event)
{this._.editor.fire('keyUp',{keyCode:event.data.getKeystroke()});};CKEDITOR.keystrokeHandler.prototype={attach:function(domObject)
{domObject.on('keyup',onKeyUp,this);domObject.on('keydown',onKeyDown,this);if(CKEDITOR.env.opera||(CKEDITOR.env.gecko&&CKEDITOR.env.mac))
domObject.on('keypress',onKeyPress,this);}};})();CKEDITOR.config.blockedKeystrokes=[CKEDITOR.CTRL+66,CKEDITOR.CTRL+73,CKEDITOR.CTRL+85];CKEDITOR.config.keystrokes=[[CKEDITOR.ALT+121,'toolbarFocus'],[CKEDITOR.ALT+122,'elementsPathFocus'],[CKEDITOR.SHIFT+121,'contextMenu'],[CKEDITOR.CTRL+CKEDITOR.SHIFT+121,'contextMenu'],[CKEDITOR.CTRL+90,'undo'],[CKEDITOR.CTRL+89,'redo'],[CKEDITOR.CTRL+CKEDITOR.SHIFT+90,'redo'],[CKEDITOR.CTRL+76,'link'],[CKEDITOR.CTRL+66,'bold'],[CKEDITOR.CTRL+73,'italic'],[CKEDITOR.CTRL+85,'underline'],[CKEDITOR.ALT+(CKEDITOR.env.ie||CKEDITOR.env.webkit?189:109),'toolbarCollapse'],[CKEDITOR.ALT+48,'a11yHelp']];;(function()
{var listNodeNames={ol:1,ul:1},emptyTextRegex=/^[\n\r\t ]*$/;var whitespaces=CKEDITOR.dom.walker.whitespaces(),bookmarks=CKEDITOR.dom.walker.bookmark(),nonEmpty=function(node){return!(whitespaces(node)||bookmarks(node));};CKEDITOR.plugins.list={listToArray:function(listNode,database,baseArray,baseIndentLevel,grandparentNode)
{if(!listNodeNames[listNode.getName()])
return[];if(!baseIndentLevel)
baseIndentLevel=0;if(!baseArray)
baseArray=[];for(var i=0,count=listNode.getChildCount();i<count;i++)
{var listItem=listNode.getChild(i);if(listItem.type==CKEDITOR.NODE_ELEMENT&&listItem.getName()in CKEDITOR.dtd.$list)
CKEDITOR.plugins.list.listToArray(listItem,database,baseArray,baseIndentLevel+1);if(listItem.$.nodeName.toLowerCase()!='li')
continue;var itemObj={'parent':listNode,indent:baseIndentLevel,element:listItem,contents:[]};if(!grandparentNode)
{itemObj.grandparent=listNode.getParent();if(itemObj.grandparent&&itemObj.grandparent.$.nodeName.toLowerCase()=='li')
itemObj.grandparent=itemObj.grandparent.getParent();}
else
itemObj.grandparent=grandparentNode;if(database)
CKEDITOR.dom.element.setMarker(database,listItem,'listarray_index',baseArray.length);baseArray.push(itemObj);for(var j=0,itemChildCount=listItem.getChildCount(),child;j<itemChildCount;j++)
{child=listItem.getChild(j);if(child.type==CKEDITOR.NODE_ELEMENT&&listNodeNames[child.getName()])
CKEDITOR.plugins.list.listToArray(child,database,baseArray,baseIndentLevel+1,itemObj.grandparent);else
itemObj.contents.push(child);}}
return baseArray;},arrayToList:function(listArray,database,baseIndex,paragraphMode,dir)
{if(!baseIndex)
baseIndex=0;if(!listArray||listArray.length<baseIndex+1)
return null;var doc=listArray[baseIndex].parent.getDocument(),retval=new CKEDITOR.dom.documentFragment(doc),rootNode=null,currentIndex=baseIndex,indentLevel=Math.max(listArray[baseIndex].indent,0),currentListItem=null,orgDir,paragraphName=(paragraphMode==CKEDITOR.ENTER_P?'p':'div');while(1)
{var item=listArray[currentIndex];orgDir=item.element.getDirection(1);if(item.indent==indentLevel)
{if(!rootNode||listArray[currentIndex].parent.getName()!=rootNode.getName())
{rootNode=listArray[currentIndex].parent.clone(false,1);if(item.toIndent){rootNode.removeAttribute('data-rte-empty-lines-before');rootNode.setAttribute('data-rte-new-node',true);}
dir&&rootNode.setAttribute('dir',dir);retval.append(rootNode);}
currentListItem=rootNode.append(item.element.clone(0,1));if(orgDir!=rootNode.getDirection(1))
currentListItem.setAttribute('dir',orgDir);else
currentListItem.removeAttribute('dir');for(var i=0;i<item.contents.length;i++)
currentListItem.append(item.contents[i].clone(1,1));currentIndex++;}
else if(item.indent==Math.max(indentLevel,0)+1)
{var currDir=listArray[currentIndex-1].element.getDirection(1),listData=CKEDITOR.plugins.list.arrayToList(listArray,null,currentIndex,paragraphMode,currDir!=orgDir?orgDir:null);if(!currentListItem.getChildCount()&&CKEDITOR.env.ie&&!(doc.$.documentMode>7))
currentListItem.append(doc.createText('\xa0'));currentListItem.append(listData.listNode);currentIndex=listData.nextIndex;}
else if(item.indent==-1&&!baseIndex&&item.grandparent)
{if(listNodeNames[item.grandparent.getName()])
currentListItem=item.element.clone(false,true);else
{if(dir||item.element.hasAttributes()||paragraphMode!=CKEDITOR.ENTER_BR)
{currentListItem=doc.createElement(paragraphName);item.element.copyAttributes(currentListItem,{type:1,value:1});if(!dir&&paragraphMode==CKEDITOR.ENTER_BR&&!currentListItem.hasAttributes())
currentListItem=new CKEDITOR.dom.documentFragment(doc);}
else
currentListItem=new CKEDITOR.dom.documentFragment(doc);}
if(currentListItem.type==CKEDITOR.NODE_ELEMENT)
{if(item.grandparent.getDirection(1)!=orgDir)
currentListItem.setAttribute('dir',orgDir);else
currentListItem.removeAttribute('dir');}
for(i=0;i<item.contents.length;i++)
currentListItem.append(item.contents[i].clone(1,1));if(currentListItem.type==CKEDITOR.NODE_DOCUMENT_FRAGMENT&&currentIndex!=listArray.length-1)
{var last=currentListItem.getLast();if(last&&last.type==CKEDITOR.NODE_ELEMENT&&last.getAttribute('type')=='_moz')
{last.remove();}
if(!(last=currentListItem.getLast(nonEmpty)&&last.type==CKEDITOR.NODE_ELEMENT&&last.getName()in CKEDITOR.dtd.$block))
{currentListItem.append(doc.createElement('br'));}}
if(currentListItem.type==CKEDITOR.NODE_ELEMENT&&currentListItem.getName()==paragraphName&&currentListItem.$.firstChild)
{currentListItem.trim();var firstChild=currentListItem.getFirst();if(firstChild.type==CKEDITOR.NODE_ELEMENT&&firstChild.isBlockBoundary())
{var tmp=new CKEDITOR.dom.documentFragment(doc);currentListItem.moveChildren(tmp);currentListItem=tmp;}}
var currentListItemName=currentListItem.$.nodeName.toLowerCase();if(!CKEDITOR.env.ie&&(currentListItemName=='div'||currentListItemName=='p'))
currentListItem.appendBogus();retval.append(currentListItem);rootNode=null;currentIndex++;}
else
return null;if(listArray.length<=currentIndex||Math.max(listArray[currentIndex].indent,0)<indentLevel)
break;}
if(database)
{var currentNode=retval.getFirst();while(currentNode)
{if(currentNode.type==CKEDITOR.NODE_ELEMENT)
CKEDITOR.dom.element.clearMarkers(database,currentNode);currentNode=currentNode.getNextSourceNode();}}
return{listNode:retval,nextIndex:currentIndex};}};function onSelectionChange(evt)
{if(evt.editor.readOnly)
return null;var path=evt.data.path,blockLimit=path.blockLimit,elements=path.elements,element,i;var nodeName=path.block?path.block.getName():'';if((/h\d/).test(nodeName)){return this.setState(CKEDITOR.TRISTATE_DISABLED);}
for(i=0;i<elements.length&&(element=elements[i])&&!element.equals(blockLimit);i++)
{if(listNodeNames[elements[i].getName()])
return this.setState(this.type==elements[i].getName()?CKEDITOR.TRISTATE_ON:CKEDITOR.TRISTATE_OFF);}
return this.setState(CKEDITOR.TRISTATE_OFF);}
function changeListType(editor,groupObj,database,listsCreated)
{var listArray=CKEDITOR.plugins.list.listToArray(groupObj.root,database),selectedListItems=[];for(var i=0;i<groupObj.contents.length;i++)
{var itemNode=groupObj.contents[i];itemNode=itemNode.getAscendant('li',true);if(!itemNode||itemNode.getCustomData('list_item_processed'))
continue;selectedListItems.push(itemNode);CKEDITOR.dom.element.setMarker(database,itemNode,'list_item_processed',true);}
var root=groupObj.root,fakeParent=root.getDocument().createElement(this.type);root.copyAttributes(fakeParent,{start:1,type:1});fakeParent.removeStyle('list-style-type');for(i=0;i<selectedListItems.length;i++)
{var listIndex=selectedListItems[i].getCustomData('listarray_index');listArray[listIndex].parent=fakeParent;}
var newList=CKEDITOR.plugins.list.arrayToList(listArray,database,null,editor.config.enterMode);var child,length=newList.listNode.getChildCount();for(i=0;i<length&&(child=newList.listNode.getChild(i));i++)
{if(child.getName()==this.type)
listsCreated.push(child);}
newList.listNode.replace(groupObj.root);}
var headerTagRegex=/^h[1-6]$/;function createList(editor,groupObj,listsCreated)
{var contents=groupObj.contents,doc=groupObj.root.getDocument(),listContents=[];if(contents.length==1&&contents[0].equals(groupObj.root))
{var divBlock=doc.createElement('div');contents[0].moveChildren&&contents[0].moveChildren(divBlock);contents[0].append(divBlock);contents[0]=divBlock;}
var commonParent=groupObj.contents[0].getParent();for(var i=0;i<contents.length;i++)
commonParent=commonParent.getCommonAncestor(contents[i].getParent());var useComputedState=editor.config.useComputedState,listDir,explicitDirection;useComputedState=useComputedState===undefined||useComputedState;for(i=0;i<contents.length;i++)
{var contentNode=contents[i],parentNode;while((parentNode=contentNode.getParent()))
{if(parentNode.equals(commonParent))
{listContents.push(contentNode);if(!explicitDirection&&contentNode.getDirection())
explicitDirection=1;var itemDir=contentNode.getDirection(useComputedState);if(listDir!==null)
{if(listDir&&listDir!=itemDir)
listDir=null;else
listDir=itemDir;}
break;}
contentNode=parentNode;}}
if(listContents.length<1)
return;var insertAnchor=listContents[listContents.length-1].getNext(),listNode=doc.createElement(this.type);editor.fire('listCreated',{listNode:listNode});listsCreated.push(listNode);var contentBlock,listItem;while(listContents.length)
{contentBlock=listContents.shift();listItem=doc.createElement('li');if(contentBlock.is('pre')||headerTagRegex.test(contentBlock.getName()))
contentBlock.appendTo(listItem);else
{contentBlock.copyAttributes(listItem);if(listDir&&contentBlock.getDirection())
{listItem.removeStyle('direction');listItem.removeAttribute('dir');}
contentBlock.moveChildren(listItem);contentBlock.remove();}
listItem.appendTo(listNode);}
if(listDir&&explicitDirection)
listNode.setAttribute('dir',listDir);if(insertAnchor)
listNode.insertBefore(insertAnchor);else
listNode.appendTo(commonParent);}
function removeList(editor,groupObj,database)
{var listArray=CKEDITOR.plugins.list.listToArray(groupObj.root,database),selectedListItems=[];for(var i=0;i<groupObj.contents.length;i++)
{var itemNode=groupObj.contents[i];itemNode=itemNode.getAscendant('li',true);if(!itemNode||itemNode.getCustomData('list_item_processed'))
continue;selectedListItems.push(itemNode);CKEDITOR.dom.element.setMarker(database,itemNode,'list_item_processed',true);}
var lastListIndex=null;for(i=0;i<selectedListItems.length;i++)
{var listIndex=selectedListItems[i].getCustomData('listarray_index');listArray[listIndex].indent=-1;lastListIndex=listIndex;}
for(i=lastListIndex+1;i<listArray.length;i++)
{if(listArray[i].indent>listArray[i-1].indent+1)
{var indentOffset=listArray[i-1].indent+1-listArray[i].indent;var oldIndent=listArray[i].indent;while(listArray[i]&&listArray[i].indent>=oldIndent)
{listArray[i].indent+=indentOffset;i++;}
i--;}}
var newList=CKEDITOR.plugins.list.arrayToList(listArray,database,null,editor.config.enterMode,groupObj.root.getAttribute('dir'));var docFragment=newList.listNode,boundaryNode,siblingNode;function compensateBrs(isStart)
{if((boundaryNode=docFragment[isStart?'getFirst':'getLast']())&&!(boundaryNode.is&&boundaryNode.isBlockBoundary())&&(siblingNode=groupObj.root[isStart?'getPrevious':'getNext']
(CKEDITOR.dom.walker.whitespaces(true)))&&!(siblingNode.is&&siblingNode.isBlockBoundary({br:1})))
editor.document.createElement('br')[isStart?'insertBefore':'insertAfter'](boundaryNode);}
compensateBrs(true);compensateBrs();docFragment.replace(groupObj.root);}
function listCommand(name,type)
{this.name=name;this.type=type;}
listCommand.prototype={exec:function(editor)
{var doc=editor.document,config=editor.config,selection=editor.getSelection(),ranges=selection&&selection.getRanges(CKEDITOR.ONLY_FORMATTABLES);if(!ranges||ranges.length<1)
return;if(this.state==CKEDITOR.TRISTATE_OFF)
{var body=doc.getBody();if(!body.getFirst(nonEmpty))
{config.enterMode==CKEDITOR.ENTER_BR?body.appendBogus():ranges[0].fixBlock(1,config.enterMode==CKEDITOR.ENTER_P?'p':'div');selection.selectRanges(ranges);}
else
{var range=ranges.length==1&&ranges[0],enclosedNode=range&&range.getEnclosedNode();if(enclosedNode&&enclosedNode.is&&this.type==enclosedNode.getName())
this.setState(CKEDITOR.TRISTATE_ON);}}
var bookmarks=selection.createBookmarks(true);var listGroups=[],database={},rangeIterator=ranges.createIterator(),index=0;while((range=rangeIterator.getNextRange())&&++index)
{var boundaryNodes=range.getBoundaryNodes(),startNode=boundaryNodes.startNode,endNode=boundaryNodes.endNode;if(startNode.type==CKEDITOR.NODE_ELEMENT&&startNode.getName()=='td')
range.setStartAt(boundaryNodes.startNode,CKEDITOR.POSITION_AFTER_START);if(endNode.type==CKEDITOR.NODE_ELEMENT&&endNode.getName()=='td')
range.setEndAt(boundaryNodes.endNode,CKEDITOR.POSITION_BEFORE_END);var iterator=range.createIterator(),block;iterator.forceBrBreak=(this.state==CKEDITOR.TRISTATE_OFF);while((block=iterator.getNextParagraph()))
{if(block.getCustomData('list_block'))
continue;else
CKEDITOR.dom.element.setMarker(database,block,'list_block',1);var path=new CKEDITOR.dom.elementPath(block),pathElements=path.elements,pathElementsCount=pathElements.length,listNode=null,processedFlag=0,blockLimit=path.blockLimit,element;for(var i=pathElementsCount-1;i>=0&&(element=pathElements[i]);i--)
{if(listNodeNames[element.getName()]&&blockLimit.contains(element))
{blockLimit.removeCustomData('list_group_object_'+index);var groupObj=element.getCustomData('list_group_object');if(groupObj)
groupObj.contents.push(block);else
{groupObj={root:element,contents:[block]};listGroups.push(groupObj);CKEDITOR.dom.element.setMarker(database,element,'list_group_object',groupObj);}
processedFlag=1;break;}}
if(processedFlag)
continue;var root=blockLimit;if(root.getCustomData('list_group_object_'+index))
root.getCustomData('list_group_object_'+index).contents.push(block);else
{groupObj={root:root,contents:[block]};CKEDITOR.dom.element.setMarker(database,root,'list_group_object_'+index,groupObj);listGroups.push(groupObj);}}}
var listsCreated=[];while(listGroups.length>0)
{groupObj=listGroups.shift();if(this.state==CKEDITOR.TRISTATE_OFF)
{if(listNodeNames[groupObj.root.getName()])
changeListType.call(this,editor,groupObj,database,listsCreated);else
createList.call(this,editor,groupObj,listsCreated);}
else if(this.state==CKEDITOR.TRISTATE_ON&&listNodeNames[groupObj.root.getName()])
removeList.call(this,editor,groupObj,database);}
for(i=0;i<listsCreated.length;i++)
{listNode=listsCreated[i];var mergeSibling,listCommand=this;(mergeSibling=function(rtl){var sibling=listNode[rtl?'getPrevious':'getNext'](CKEDITOR.dom.walker.whitespaces(true));if(sibling&&sibling.getName&&sibling.getName()==listCommand.type)
{sibling.remove();sibling.moveChildren(listNode,rtl);}})();mergeSibling(1);}
CKEDITOR.dom.element.clearAllMarkers(database);selection.selectBookmarks(bookmarks);editor.focus();}};var dtd=CKEDITOR.dtd;var tailNbspRegex=/[\t\r\n ]*(?:&nbsp;|\xa0)$/;function indexOfFirstChildElement(element,tagNameList)
{var child,children=element.children,length=children.length;for(var i=0;i<length;i++)
{child=children[i];if(child.name&&(child.name in tagNameList))
return i;}
return length;}
function getExtendNestedListFilter(isHtmlFilter)
{return function(listItem)
{var children=listItem.children,firstNestedListIndex=indexOfFirstChildElement(listItem,dtd.$list),firstNestedList=children[firstNestedListIndex],nodeBefore=firstNestedList&&firstNestedList.previous,tailNbspmatch;if(nodeBefore&&(nodeBefore.name&&nodeBefore.name=='br'||nodeBefore.value&&(tailNbspmatch=nodeBefore.value.match(tailNbspRegex))))
{var fillerNode=nodeBefore;if(!(tailNbspmatch&&tailNbspmatch.index)&&fillerNode==children[0])
children[0]=(isHtmlFilter||CKEDITOR.env.ie)?new CKEDITOR.htmlParser.text('\xa0'):new CKEDITOR.htmlParser.element('br',{});else if(fillerNode.name=='br')
children.splice(firstNestedListIndex-1,1);else
fillerNode.value=fillerNode.value.replace(tailNbspRegex,'');}};}
var defaultListDataFilterRules={elements:{}};for(var i in dtd.$listItem)
defaultListDataFilterRules.elements[i]=getExtendNestedListFilter();var defaultListHtmlFilterRules={elements:{}};for(i in dtd.$listItem)
defaultListHtmlFilterRules.elements[i]=getExtendNestedListFilter(true);CKEDITOR.plugins.add('list',{init:function(editor)
{var numberedListCommand=editor.addCommand('numberedlist',new listCommand('numberedlist','ol')),bulletedListCommand=editor.addCommand('bulletedlist',new listCommand('bulletedlist','ul'));editor.ui.addButton('NumberedList',{label:editor.lang.numberedlist,command:'numberedlist'});editor.ui.addButton('BulletedList',{label:editor.lang.bulletedlist,command:'bulletedlist'});editor.on('selectionChange',CKEDITOR.tools.bind(onSelectionChange,numberedListCommand));editor.on('selectionChange',CKEDITOR.tools.bind(onSelectionChange,bulletedListCommand));},afterInit:function(editor)
{var dataProcessor=editor.dataProcessor;if(dataProcessor)
{dataProcessor.dataFilter.addRules(defaultListDataFilterRules);dataProcessor.htmlFilter.addRules(defaultListHtmlFilterRules);}},requires:['domiterator']});})();;(function()
{var pasteTextCmd={exec:function(editor)
{var clipboardText=CKEDITOR.tools.tryThese(function()
{var clipboardText=window.clipboardData.getData('Text');if(!clipboardText)
throw 0;return clipboardText;});if(!clipboardText)
{editor.openDialog('pastetext');return false;}
else
editor.fire('paste',{'text':clipboardText});return true;}};CKEDITOR.plugins.add('pastetext',{init:function(editor)
{var commandName='pastetext',command=editor.addCommand(commandName,pasteTextCmd);editor.ui.addButton('PasteText',{label:editor.lang.pasteText.button,command:commandName});CKEDITOR.dialog.add(commandName,CKEDITOR.getUrl(this.path+'dialogs/pastetext.js'));if(editor.config.forcePasteAsPlainText)
{editor.on('beforeCommandExec',function(evt)
{var mode=evt.data.commandData;if(evt.data.name=='paste'&&mode!='html')
{editor.execCommand('pastetext');evt.cancel();}},null,null,0);editor.on('beforePaste',function(evt)
{evt.data.mode='text';});}
editor.on('pasteState',function(evt)
{editor.getCommand('pastetext').setState(evt.data);});},requires:['clipboard']});})();;CKEDITOR.plugins.add('removeformat',{requires:['selection'],init:function(editor)
{editor.addCommand('removeFormat',CKEDITOR.plugins.removeformat.commands.removeformat);editor.ui.addButton('RemoveFormat',{label:editor.lang.removeFormat,command:'removeFormat'});editor._.removeFormat={filters:[]};}});CKEDITOR.plugins.removeformat={commands:{removeformat:{exec:function(editor)
{var tagsRegex=editor._.removeFormatRegex||(editor._.removeFormatRegex=new RegExp('^(?:'+editor.config.removeFormatTags.replace(/,/g,'|')+')$','i'));var removeAttributes=editor._.removeAttributes||(editor._.removeAttributes=editor.config.removeFormatAttributes.split(','));var filter=CKEDITOR.plugins.removeformat.filter;var ranges=editor.getSelection().getRanges(1),iterator=ranges.createIterator(),range;while((range=iterator.getNextRange()))
{if(!range.collapsed)
range.enlarge(CKEDITOR.ENLARGE_ELEMENT);var bookmark=range.createBookmark(),startNode=bookmark.startNode,endNode=bookmark.endNode,currentNode;var breakParent=function(node)
{var path=new CKEDITOR.dom.elementPath(node),pathElements=path.elements;for(var i=1,pathElement;pathElement=pathElements[i];i++)
{if(pathElement.equals(path.block)||pathElement.equals(path.blockLimit))
break;if(tagsRegex.test(pathElement.getName())&&filter(editor,pathElement))
node.breakParent(pathElement);}};breakParent(startNode);if(endNode)
{breakParent(endNode);currentNode=startNode.getNextSourceNode(true,CKEDITOR.NODE_ELEMENT);while(currentNode)
{if(currentNode.equals(endNode))
break;var nextNode=currentNode.getNextSourceNode(false,CKEDITOR.NODE_ELEMENT);if(!(currentNode.getName()=='img'&&currentNode.data('cke-realelement'))&&filter(editor,currentNode))
{if(tagsRegex.test(currentNode.getName()))
currentNode.remove(1);else
{currentNode.removeAttributes(removeAttributes);editor.fire('removeFormatCleanup',currentNode);}}
currentNode=nextNode;}}
range.moveToBookmark(bookmark);}
editor.getSelection().selectRanges(ranges);}}},filter:function(editor,element)
{var filters=editor._.removeFormat.filters;for(var i=0;i<filters.length;i++)
{if(filters[i](element)===false)
return false;}
return true;}};CKEDITOR.editor.prototype.addRemoveFormatFilter=function(func)
{this._.removeFormat.filters.push(func);};CKEDITOR.config.removeFormatTags='b,big,code,del,dfn,em,font,i,ins,kbd,q,samp,small,span,strike,strong,sub,sup,tt,u,var';CKEDITOR.config.removeFormatAttributes='class,style,lang,width,height,align,hspace,valign';;CKEDITOR.plugins.add('sourcearea',{requires:['editingblock'],init:function(editor)
{var sourcearea=CKEDITOR.plugins.sourcearea,win=CKEDITOR.document.getWindow();editor.on('editingBlockReady',function()
{var textarea,onResize;editor.addMode('source',{load:function(holderElement,data)
{if(CKEDITOR.env.ie&&CKEDITOR.env.version<8)
holderElement.setStyle('position','relative');editor.textarea=textarea=new CKEDITOR.dom.element('textarea');textarea.setAttributes({dir:'ltr',tabIndex:CKEDITOR.env.webkit?-1:editor.tabIndex,'role':'textbox','aria-label':editor.lang.editorTitle.replace('%1',editor.name)});textarea.addClass('cke_source');textarea.addClass('cke_enable_context_menu');editor.readOnly&&textarea.setAttribute('readOnly','readonly');var styles={width:CKEDITOR.env.ie7Compat?'99%':'100%',height:'100%',resize:'none',outline:'none','text-align':'left'};if(CKEDITOR.env.ie)
{onResize=function()
{textarea.hide();textarea.setStyle('height',holderElement.$.clientHeight+'px');textarea.setStyle('width',holderElement.$.clientWidth+'px');textarea.show();};editor.on('resize',onResize);win.on('resize',onResize);setTimeout(onResize,0);}
holderElement.setHtml('');holderElement.append(textarea);textarea.setStyles(styles);editor.fire('ariaWidget',textarea);textarea.on('blur',function()
{editor.focusManager.blur();});textarea.on('focus',function()
{editor.focusManager.focus();});editor.mayBeDirty=true;this.loadData(data);var keystrokeHandler=editor.keystrokeHandler;if(keystrokeHandler)
keystrokeHandler.attach(textarea);setTimeout(function()
{editor.mode='source';editor.fire('mode');},(CKEDITOR.env.gecko||CKEDITOR.env.webkit)?100:0);},loadData:function(data)
{textarea.setValue(data);editor.fire('dataReady');},getData:function()
{return textarea.getValue();},getSnapshotData:function()
{return textarea.getValue();},unload:function(holderElement)
{textarea.clearCustomData();editor.textarea=textarea=null;if(onResize)
{editor.removeListener('resize',onResize);win.removeListener('resize',onResize);}
if(CKEDITOR.env.ie&&CKEDITOR.env.version<8)
holderElement.removeStyle('position');},focus:function()
{textarea.focus();}});});editor.on('readOnly',function()
{if(editor.mode=='source')
{if(editor.readOnly)
editor.textarea.setAttribute('readOnly','readonly');else
editor.textarea.removeAttribute('readOnly');}});editor.addCommand('source',sourcearea.commands.source);if(editor.ui.addButton)
{editor.ui.addButton('Source',{label:editor.lang.source,command:'source'});}
editor.on('mode',function()
{editor.getCommand('source').setState(editor.mode=='source'?CKEDITOR.TRISTATE_ON:CKEDITOR.TRISTATE_OFF);});}});CKEDITOR.plugins.sourcearea={commands:{source:{modes:{wysiwyg:1,source:1},editorFocus:false,readOnly:1,exec:function(editor)
{if(editor.mode=='wysiwyg')
editor.fire('saveSnapshot');editor.getCommand('source').setState(CKEDITOR.TRISTATE_DISABLED);editor.setMode(editor.mode=='source'?'wysiwyg':'source');},canUndo:false}}};;CKEDITOR.plugins.add('table',{init:function(editor)
{var table=CKEDITOR.plugins.table,lang=editor.lang.table;editor.addCommand('table',new CKEDITOR.dialogCommand('table'));editor.addCommand('tableProperties',new CKEDITOR.dialogCommand('tableProperties'));editor.ui.addButton('Table',{label:lang.toolbar,title:lang.toolbarTooltip,command:'table'});CKEDITOR.dialog.add('table',this.path+'dialogs/table.js');CKEDITOR.dialog.add('tableProperties',this.path+'dialogs/table.js');var removeSelectedClass=function(){$(editor.document.$).find('.article-table-selected').removeClass('article-table-selected');}
editor.on('selectionChange',function(evt)
{var element=evt.data.element.$,table=$(element).closest('.article-table');removeSelectedClass();if(table.length){console.log('length')
table.addClass('article-table-selected');}});editor.on('switchToSource',function(evt)
{removeSelectedClass();});if(editor.addMenuItems)
{editor.addMenuItems({table:{label:lang.menu,command:'tableProperties',group:'table',order:5},tabledelete:{label:lang.deleteTable,command:'tableDelete',group:'table',order:1}});}
editor.on('doubleclick',function(evt)
{var element=evt.data.element;if(element.is('table'))
evt.data.dialog='tableProperties';});if(editor.contextMenu)
{editor.contextMenu.addListener(function(element,selection)
{if(!element||element.isReadOnly())
return null;var isTable=element.hasAscendant('table',1);if(isTable)
{return{tabledelete:CKEDITOR.TRISTATE_OFF,table:CKEDITOR.TRISTATE_OFF};}
return null;});}}});;(function()
{var cellNodeRegex=/^(?:td|th)$/;function getSelectedCells(selection)
{var bookmarks=selection.createBookmarks();var ranges=selection.getRanges();var retval=[];var database={};function moveOutOfCellGuard(node)
{if(retval.length>0)
return;if(node.type==CKEDITOR.NODE_ELEMENT&&cellNodeRegex.test(node.getName())&&!node.getCustomData('selected_cell'))
{CKEDITOR.dom.element.setMarker(database,node,'selected_cell',true);retval.push(node);}}
for(var i=0;i<ranges.length;i++)
{var range=ranges[i];if(range.collapsed)
{var startNode=range.getCommonAncestor();var nearestCell=startNode.getAscendant('td',true)||startNode.getAscendant('th',true);if(nearestCell)
retval.push(nearestCell);}
else
{var walker=new CKEDITOR.dom.walker(range);var node;walker.guard=moveOutOfCellGuard;while((node=walker.next()))
{var parent=node.getAscendant('td')||node.getAscendant('th');if(parent&&!parent.getCustomData('selected_cell'))
{CKEDITOR.dom.element.setMarker(database,parent,'selected_cell',true);retval.push(parent);}}}}
CKEDITOR.dom.element.clearAllMarkers(database);selection.selectBookmarks(bookmarks);return retval;}
function getFocusElementAfterDelCells(cellsToDelete){var i=0,last=cellsToDelete.length-1,database={},cell,focusedCell,tr;while((cell=cellsToDelete[i++]))
CKEDITOR.dom.element.setMarker(database,cell,'delete_cell',true);i=0;while((cell=cellsToDelete[i++]))
{if((focusedCell=cell.getPrevious())&&!focusedCell.getCustomData('delete_cell')||(focusedCell=cell.getNext())&&!focusedCell.getCustomData('delete_cell'))
{CKEDITOR.dom.element.clearAllMarkers(database);return focusedCell;}}
CKEDITOR.dom.element.clearAllMarkers(database);tr=cellsToDelete[0].getParent();if((tr=tr.getPrevious()))
return tr.getLast();tr=cellsToDelete[last].getParent();if((tr=tr.getNext()))
return tr.getChild(0);return null;}
function insertRow(selection,insertBefore)
{var cells=getSelectedCells(selection),firstCell=cells[0],table=firstCell.getAscendant('table'),doc=firstCell.getDocument(),startRow=cells[0].getParent(),startRowIndex=startRow.$.rowIndex,lastCell=cells[cells.length-1],endRowIndex=lastCell.getParent().$.rowIndex+lastCell.$.rowSpan-1,endRow=new CKEDITOR.dom.element(table.$.rows[endRowIndex]),rowIndex=insertBefore?startRowIndex:endRowIndex,row=insertBefore?startRow:endRow;var map=CKEDITOR.tools.buildTableMap(table),cloneRow=map[rowIndex],nextRow=insertBefore?map[rowIndex-1]:map[rowIndex+1],width=map[0].length;var newRow=doc.createElement('tr');for(var i=0;i<width;i++)
{var cell;if(cloneRow[i].rowSpan>1&&nextRow&&cloneRow[i]==nextRow[i])
{cell=cloneRow[i];cell.rowSpan+=1;}
else
{cell=new CKEDITOR.dom.element(cloneRow[i]).clone();cell.removeAttribute('rowSpan');!CKEDITOR.env.ie&&cell.appendBogus();newRow.append(cell);cell=cell.$;}
i+=cell.colSpan-1;}
insertBefore?newRow.insertBefore(row):newRow.insertAfter(row);}
function deleteRows(selectionOrRow)
{if(selectionOrRow instanceof CKEDITOR.dom.selection)
{var cells=getSelectedCells(selectionOrRow),firstCell=cells[0],table=firstCell.getAscendant('table'),map=CKEDITOR.tools.buildTableMap(table),startRow=cells[0].getParent(),startRowIndex=startRow.$.rowIndex,lastCell=cells[cells.length-1],endRowIndex=lastCell.getParent().$.rowIndex+lastCell.$.rowSpan-1,rowsToDelete=[];for(var i=startRowIndex;i<=endRowIndex;i++)
{var mapRow=map[i],row=new CKEDITOR.dom.element(table.$.rows[i]);for(var j=0;j<mapRow.length;j++)
{var cell=new CKEDITOR.dom.element(mapRow[j]),cellRowIndex=cell.getParent().$.rowIndex;if(cell.$.rowSpan==1)
cell.remove();else
{cell.$.rowSpan-=1;if(cellRowIndex==i)
{var nextMapRow=map[i+1];nextMapRow[j-1]?cell.insertAfter(new CKEDITOR.dom.element(nextMapRow[j-1])):new CKEDITOR.dom.element(table.$.rows[i+1]).append(cell,1);}}
j+=cell.$.colSpan-1;}
rowsToDelete.push(row);}
var rows=table.$.rows;var cursorPosition=new CKEDITOR.dom.element(rows[endRowIndex+1]||(startRowIndex>0?rows[startRowIndex-1]:null)||table.$.parentNode);for(i=rowsToDelete.length;i>=0;i--)
deleteRows(rowsToDelete[i]);return cursorPosition;}
else if(selectionOrRow instanceof CKEDITOR.dom.element)
{table=selectionOrRow.getAscendant('table');if(table.$.rows.length==1)
table.remove();else
selectionOrRow.remove();}
return null;}
function getCellColIndex(cell,isStart)
{var row=cell.getParent(),rowCells=row.$.cells;var colIndex=0;for(var i=0;i<rowCells.length;i++)
{var mapCell=rowCells[i];colIndex+=isStart?1:mapCell.colSpan;if(mapCell==cell.$)
break;}
return colIndex-1;}
function getColumnsIndices(cells,isStart)
{var retval=isStart?Infinity:0;for(var i=0;i<cells.length;i++)
{var colIndex=getCellColIndex(cells[i],isStart);if(isStart?colIndex<retval:colIndex>retval)
retval=colIndex;}
return retval;}
function insertColumn(selection,insertBefore)
{var cells=getSelectedCells(selection),firstCell=cells[0],table=firstCell.getAscendant('table'),startCol=getColumnsIndices(cells,1),lastCol=getColumnsIndices(cells),colIndex=insertBefore?startCol:lastCol;var map=CKEDITOR.tools.buildTableMap(table),cloneCol=[],nextCol=[],height=map.length;for(var i=0;i<height;i++)
{cloneCol.push(map[i][colIndex]);var nextCell=insertBefore?map[i][colIndex-1]:map[i][colIndex+1];nextCell&&nextCol.push(nextCell);}
for(i=0;i<height;i++)
{var cell;if(cloneCol[i].colSpan>1&&nextCol.length&&nextCol[i]==cloneCol[i])
{cell=cloneCol[i];cell.colSpan+=1;}
else
{cell=new CKEDITOR.dom.element(cloneCol[i]).clone();cell.removeAttribute('colSpan');!CKEDITOR.env.ie&&cell.appendBogus();cell[insertBefore?'insertBefore':'insertAfter'].call(cell,new CKEDITOR.dom.element(cloneCol[i]));cell=cell.$;}
i+=cell.rowSpan-1;}}
function deleteColumns(selectionOrCell)
{var cells=getSelectedCells(selectionOrCell),firstCell=cells[0],lastCell=cells[cells.length-1],table=firstCell.getAscendant('table'),map=CKEDITOR.tools.buildTableMap(table),startColIndex,endColIndex,rowsToDelete=[];for(var i=0,rows=map.length;i<rows;i++)
{for(var j=0,cols=map[i].length;j<cols;j++)
{if(map[i][j]==firstCell.$)
startColIndex=j;if(map[i][j]==lastCell.$)
endColIndex=j;}}
for(i=startColIndex;i<=endColIndex;i++)
{for(j=0;j<map.length;j++)
{var mapRow=map[j],row=new CKEDITOR.dom.element(table.$.rows[j]),cell=new CKEDITOR.dom.element(mapRow[i]);if(cell.$)
{if(cell.$.colSpan==1)
cell.remove();else
cell.$.colSpan-=1;j+=cell.$.rowSpan-1;if(!row.$.cells.length)
rowsToDelete.push(row);}}}
var firstRowCells=table.$.rows[0]&&table.$.rows[0].cells;var cursorPosition=new CKEDITOR.dom.element(firstRowCells[startColIndex]||(startColIndex?firstRowCells[startColIndex-1]:table.$.parentNode));if(rowsToDelete.length==rows)
table.remove();return cursorPosition;}
function getFocusElementAfterDelCols(cells)
{var cellIndexList=[],table=cells[0]&&cells[0].getAscendant('table'),i,length,targetIndex,targetCell;for(i=0,length=cells.length;i<length;i++)
cellIndexList.push(cells[i].$.cellIndex);cellIndexList.sort();for(i=1,length=cellIndexList.length;i<length;i++)
{if(cellIndexList[i]-cellIndexList[i-1]>1)
{targetIndex=cellIndexList[i-1]+1;break;}}
if(!targetIndex)
targetIndex=cellIndexList[0]>0?(cellIndexList[0]-1):(cellIndexList[cellIndexList.length-1]+1);var rows=table.$.rows;for(i=0,length=rows.length;i<length;i++)
{targetCell=rows[i].cells[targetIndex];if(targetCell)
break;}
return targetCell?new CKEDITOR.dom.element(targetCell):table.getPrevious();}
function insertCell(selection,insertBefore)
{var startElement=selection.getStartElement();var cell=startElement.getAscendant('td',1)||startElement.getAscendant('th',1);if(!cell)
return;var newCell=cell.clone();if(!CKEDITOR.env.ie)
newCell.appendBogus();if(insertBefore)
newCell.insertBefore(cell);else
newCell.insertAfter(cell);}
function deleteCells(selectionOrCell)
{if(selectionOrCell instanceof CKEDITOR.dom.selection)
{var cellsToDelete=getSelectedCells(selectionOrCell);var table=cellsToDelete[0]&&cellsToDelete[0].getAscendant('table');var cellToFocus=getFocusElementAfterDelCells(cellsToDelete);for(var i=cellsToDelete.length-1;i>=0;i--)
deleteCells(cellsToDelete[i]);if(cellToFocus)
placeCursorInCell(cellToFocus,true);else if(table)
table.remove();}
else if(selectionOrCell instanceof CKEDITOR.dom.element)
{var tr=selectionOrCell.getParent();if(tr.getChildCount()==1)
tr.remove();else
selectionOrCell.remove();}}
function trimCell(cell)
{var bogus=cell.getBogus();bogus&&bogus.remove();cell.trim();}
function placeCursorInCell(cell,placeAtEnd)
{var range=new CKEDITOR.dom.range(cell.getDocument());if(!range['moveToElementEdit'+(placeAtEnd?'End':'Start')](cell))
{range.selectNodeContents(cell);range.collapse(placeAtEnd?false:true);}
range.select(true);}
function cellInRow(tableMap,rowIndex,cell)
{var oRow=tableMap[rowIndex];if(typeof cell=='undefined')
return oRow;for(var c=0;oRow&&c<oRow.length;c++)
{if(cell.is&&oRow[c]==cell.$)
return c;else if(c==cell)
return new CKEDITOR.dom.element(oRow[c]);}
return cell.is?-1:null;}
function cellInCol(tableMap,colIndex,cell)
{var oCol=[];for(var r=0;r<tableMap.length;r++)
{var row=tableMap[r];if(typeof cell=='undefined')
oCol.push(row[colIndex]);else if(cell.is&&row[colIndex]==cell.$)
return r;else if(r==cell)
return new CKEDITOR.dom.element(row[colIndex]);}
return(typeof cell=='undefined')?oCol:cell.is?-1:null;}
function mergeCells(selection,mergeDirection,isDetect)
{var cells=getSelectedCells(selection);var commonAncestor;if((mergeDirection?cells.length!=1:cells.length<2)||(commonAncestor=selection.getCommonAncestor())&&commonAncestor.type==CKEDITOR.NODE_ELEMENT&&commonAncestor.is('table'))
{return false;}
var cell,firstCell=cells[0],table=firstCell.getAscendant('table'),map=CKEDITOR.tools.buildTableMap(table),mapHeight=map.length,mapWidth=map[0].length,startRow=firstCell.getParent().$.rowIndex,startColumn=cellInRow(map,startRow,firstCell);if(mergeDirection)
{var targetCell;try
{var rowspan=parseInt(firstCell.getAttribute('rowspan'),10)||1;var colspan=parseInt(firstCell.getAttribute('colspan'),10)||1;targetCell=map[mergeDirection=='up'?(startRow-rowspan):mergeDirection=='down'?(startRow+rowspan):startRow][mergeDirection=='left'?(startColumn-colspan):mergeDirection=='right'?(startColumn+colspan):startColumn];}
catch(er)
{return false;}
if(!targetCell||firstCell.$==targetCell)
return false;cells[(mergeDirection=='up'||mergeDirection=='left')?'unshift':'push'](new CKEDITOR.dom.element(targetCell));}
var doc=firstCell.getDocument(),lastRowIndex=startRow,totalRowSpan=0,totalColSpan=0,frag=!isDetect&&new CKEDITOR.dom.documentFragment(doc),dimension=0;for(var i=0;i<cells.length;i++)
{cell=cells[i];var tr=cell.getParent(),cellFirstChild=cell.getFirst(),colSpan=cell.$.colSpan,rowSpan=cell.$.rowSpan,rowIndex=tr.$.rowIndex,colIndex=cellInRow(map,rowIndex,cell);dimension+=colSpan*rowSpan;totalColSpan=Math.max(totalColSpan,colIndex-startColumn+colSpan);totalRowSpan=Math.max(totalRowSpan,rowIndex-startRow+rowSpan);if(!isDetect)
{if(trimCell(cell),cell.getChildren().count())
{if(rowIndex!=lastRowIndex&&cellFirstChild&&!(cellFirstChild.isBlockBoundary&&cellFirstChild.isBlockBoundary({br:1})))
{var last=frag.getLast(CKEDITOR.dom.walker.whitespaces(true));if(last&&!(last.is&&last.is('br')))
frag.append('br');}
cell.moveChildren(frag);}
i?cell.remove():cell.setHtml('');}
lastRowIndex=rowIndex;}
if(!isDetect)
{frag.moveChildren(firstCell);if(!CKEDITOR.env.ie)
firstCell.appendBogus();if(totalColSpan>=mapWidth)
firstCell.removeAttribute('rowSpan');else
firstCell.$.rowSpan=totalRowSpan;if(totalRowSpan>=mapHeight)
firstCell.removeAttribute('colSpan');else
firstCell.$.colSpan=totalColSpan;var trs=new CKEDITOR.dom.nodeList(table.$.rows),count=trs.count();for(i=count-1;i>=0;i--)
{var tailTr=trs.getItem(i);if(!tailTr.$.cells.length)
{tailTr.remove();count++;continue;}}
return firstCell;}
else
return(totalRowSpan*totalColSpan)==dimension;}
function verticalSplitCell(selection,isDetect)
{var cells=getSelectedCells(selection);if(cells.length>1)
return false;else if(isDetect)
return true;var cell=cells[0],tr=cell.getParent(),table=tr.getAscendant('table'),map=CKEDITOR.tools.buildTableMap(table),rowIndex=tr.$.rowIndex,colIndex=cellInRow(map,rowIndex,cell),rowSpan=cell.$.rowSpan,newCell,newRowSpan,newCellRowSpan,newRowIndex;if(rowSpan>1)
{newRowSpan=Math.ceil(rowSpan/2);newCellRowSpan=Math.floor(rowSpan/2);newRowIndex=rowIndex+newRowSpan;var newCellTr=new CKEDITOR.dom.element(table.$.rows[newRowIndex]),newCellRow=cellInRow(map,newRowIndex),candidateCell;newCell=cell.clone();for(var c=0;c<newCellRow.length;c++)
{candidateCell=newCellRow[c];if(candidateCell.parentNode==newCellTr.$&&c>colIndex)
{newCell.insertBefore(new CKEDITOR.dom.element(candidateCell));break;}
else
candidateCell=null;}
if(!candidateCell)
newCellTr.append(newCell,true);}
else
{newCellRowSpan=newRowSpan=1;newCellTr=tr.clone();newCellTr.insertAfter(tr);newCellTr.append(newCell=cell.clone());var cellsInSameRow=cellInRow(map,rowIndex);for(var i=0;i<cellsInSameRow.length;i++)
cellsInSameRow[i].rowSpan++;}
if(!CKEDITOR.env.ie)
newCell.appendBogus();cell.$.rowSpan=newRowSpan;newCell.$.rowSpan=newCellRowSpan;if(newRowSpan==1)
cell.removeAttribute('rowSpan');if(newCellRowSpan==1)
newCell.removeAttribute('rowSpan');return newCell;}
function horizontalSplitCell(selection,isDetect)
{var cells=getSelectedCells(selection);if(cells.length>1)
return false;else if(isDetect)
return true;var cell=cells[0],tr=cell.getParent(),table=tr.getAscendant('table'),map=CKEDITOR.tools.buildTableMap(table),rowIndex=tr.$.rowIndex,colIndex=cellInRow(map,rowIndex,cell),colSpan=cell.$.colSpan,newCell,newColSpan,newCellColSpan;if(colSpan>1)
{newColSpan=Math.ceil(colSpan/2);newCellColSpan=Math.floor(colSpan/2);}
else
{newCellColSpan=newColSpan=1;var cellsInSameCol=cellInCol(map,colIndex);for(var i=0;i<cellsInSameCol.length;i++)
cellsInSameCol[i].colSpan++;}
newCell=cell.clone();newCell.insertAfter(cell);if(!CKEDITOR.env.ie)
newCell.appendBogus();cell.$.colSpan=newColSpan;newCell.$.colSpan=newCellColSpan;if(newColSpan==1)
cell.removeAttribute('colSpan');if(newCellColSpan==1)
newCell.removeAttribute('colSpan');return newCell;}
var contextMenuTags={thead:1,tbody:1,tfoot:1,td:1,tr:1,th:1};CKEDITOR.plugins.tabletools={init:function(editor)
{var lang=editor.lang.table;editor.addCommand('cellProperties',new CKEDITOR.dialogCommand('cellProperties'));CKEDITOR.dialog.add('cellProperties',this.path+'dialogs/tableCell.js');editor.addCommand('tableDelete',{exec:function(editor)
{var selection=editor.getSelection(),startElement=selection&&selection.getStartElement(),table=startElement&&startElement.getAscendant('table',1);if(!table)
return;var parent=table.getParent();if(parent.getChildCount()==1&&!parent.is('body','td','th'))
table=parent;var range=new CKEDITOR.dom.range(editor.document);range.moveToPosition(table,CKEDITOR.POSITION_BEFORE_START);table.remove();range.select();}});editor.addCommand('rowDelete',{exec:function(editor)
{var selection=editor.getSelection();placeCursorInCell(deleteRows(selection));}});editor.addCommand('rowInsertBefore',{exec:function(editor)
{var selection=editor.getSelection();insertRow(selection,true);}});editor.addCommand('rowInsertAfter',{exec:function(editor)
{var selection=editor.getSelection();insertRow(selection);}});editor.addCommand('columnDelete',{exec:function(editor)
{var selection=editor.getSelection();var element=deleteColumns(selection);element&&placeCursorInCell(element,true);}});editor.addCommand('columnInsertBefore',{exec:function(editor)
{var selection=editor.getSelection();insertColumn(selection,true);}});editor.addCommand('columnInsertAfter',{exec:function(editor)
{var selection=editor.getSelection();insertColumn(selection);}});editor.addCommand('cellDelete',{exec:function(editor)
{var selection=editor.getSelection();deleteCells(selection);}});editor.addCommand('cellMerge',{exec:function(editor)
{placeCursorInCell(mergeCells(editor.getSelection()),true);}});editor.addCommand('cellMergeRight',{exec:function(editor)
{placeCursorInCell(mergeCells(editor.getSelection(),'right'),true);}});editor.addCommand('cellMergeDown',{exec:function(editor)
{placeCursorInCell(mergeCells(editor.getSelection(),'down'),true);}});editor.addCommand('cellVerticalSplit',{exec:function(editor)
{placeCursorInCell(verticalSplitCell(editor.getSelection()));}});editor.addCommand('cellHorizontalSplit',{exec:function(editor)
{placeCursorInCell(horizontalSplitCell(editor.getSelection()));}});editor.addCommand('cellInsertBefore',{exec:function(editor)
{var selection=editor.getSelection();insertCell(selection,true);}});editor.addCommand('cellInsertAfter',{exec:function(editor)
{var selection=editor.getSelection();insertCell(selection);}});if(editor.addMenuItems)
{editor.addMenuItems({tablecell:{label:lang.cell.menu,group:'tablecell',order:1,getItems:function()
{var selection=editor.getSelection(),cells=getSelectedCells(selection);return{tablecell_insertBefore:CKEDITOR.TRISTATE_OFF,tablecell_insertAfter:CKEDITOR.TRISTATE_OFF,tablecell_delete:CKEDITOR.TRISTATE_OFF,tablecell_merge:mergeCells(selection,null,true)?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED,tablecell_merge_right:mergeCells(selection,'right',true)?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED,tablecell_merge_down:mergeCells(selection,'down',true)?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED,tablecell_split_vertical:verticalSplitCell(selection,true)?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED,tablecell_split_horizontal:horizontalSplitCell(selection,true)?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED,tablecell_properties:cells.length>0?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED};}},tablecell_insertBefore:{label:lang.cell.insertBefore,group:'tablecell',command:'cellInsertBefore',order:5},tablecell_insertAfter:{label:lang.cell.insertAfter,group:'tablecell',command:'cellInsertAfter',order:10},tablecell_delete:{label:lang.cell.deleteCell,group:'tablecell',command:'cellDelete',order:15},tablecell_merge:{label:lang.cell.merge,group:'tablecell',command:'cellMerge',order:16},tablecell_merge_right:{label:lang.cell.mergeRight,group:'tablecell',command:'cellMergeRight',order:17},tablecell_merge_down:{label:lang.cell.mergeDown,group:'tablecell',command:'cellMergeDown',order:18},tablecell_split_horizontal:{label:lang.cell.splitHorizontal,group:'tablecell',command:'cellHorizontalSplit',order:19},tablecell_split_vertical:{label:lang.cell.splitVertical,group:'tablecell',command:'cellVerticalSplit',order:20},tablecell_properties:{label:lang.cell.title,group:'tablecellproperties',command:'cellProperties',order:21},tablerow:{label:lang.row.menu,group:'tablerow',order:1,getItems:function()
{return{tablerow_insertBefore:CKEDITOR.TRISTATE_OFF,tablerow_insertAfter:CKEDITOR.TRISTATE_OFF,tablerow_delete:CKEDITOR.TRISTATE_OFF};}},tablerow_insertBefore:{label:lang.row.insertBefore,group:'tablerow',command:'rowInsertBefore',order:5},tablerow_insertAfter:{label:lang.row.insertAfter,group:'tablerow',command:'rowInsertAfter',order:10},tablerow_delete:{label:lang.row.deleteRow,group:'tablerow',command:'rowDelete',order:15},tablecolumn:{label:lang.column.menu,group:'tablecolumn',order:1,getItems:function()
{return{tablecolumn_insertBefore:CKEDITOR.TRISTATE_OFF,tablecolumn_insertAfter:CKEDITOR.TRISTATE_OFF,tablecolumn_delete:CKEDITOR.TRISTATE_OFF};}},tablecolumn_insertBefore:{label:lang.column.insertBefore,group:'tablecolumn',command:'columnInsertBefore',order:5},tablecolumn_insertAfter:{label:lang.column.insertAfter,group:'tablecolumn',command:'columnInsertAfter',order:10},tablecolumn_delete:{label:lang.column.deleteColumn,group:'tablecolumn',command:'columnDelete',order:15}});}
if(editor.contextMenu)
{editor.contextMenu.addListener(function(element,selection)
{if(!element||element.isReadOnly())
return null;while(element)
{if(element.getName()in contextMenuTags)
{return{tablecell:CKEDITOR.TRISTATE_OFF,tablerow:CKEDITOR.TRISTATE_OFF,tablecolumn:CKEDITOR.TRISTATE_OFF};}
element=element.getParent();}
return null;});}},getSelectedCells:getSelectedCells};CKEDITOR.plugins.add('tabletools',CKEDITOR.plugins.tabletools);})();CKEDITOR.tools.buildTableMap=function(table)
{var aRows=table.$.rows;var r=-1;var aMap=[];for(var i=0;i<aRows.length;i++)
{r++;!aMap[r]&&(aMap[r]=[]);var c=-1;for(var j=0;j<aRows[i].cells.length;j++)
{var oCell=aRows[i].cells[j];c++;while(aMap[r][c])
c++;var iColSpan=isNaN(oCell.colSpan)?1:oCell.colSpan;var iRowSpan=isNaN(oCell.rowSpan)?1:oCell.rowSpan;for(var rs=0;rs<iRowSpan;rs++)
{if(!aMap[r+rs])
aMap[r+rs]=[];for(var cs=0;cs<iColSpan;cs++)
{aMap[r+rs][c+cs]=aRows[i].cells[j];}}
c+=iColSpan-1;}}
return aMap;};;(function()
{var meta={editorFocus:false,modes:{wysiwyg:1,source:1}};var blurCommand={exec:function(editor)
{editor.container.focusNext(true,editor.tabIndex);}};var blurBackCommand={exec:function(editor)
{editor.container.focusPrevious(true,editor.tabIndex);}};function selectNextCellCommand(backward)
{return{editorFocus:false,canUndo:false,modes:{wysiwyg:1},exec:function(editor)
{if(editor.focusManager.hasFocus)
{var sel=editor.getSelection(),ancestor=sel.getCommonAncestor(),cell;if((cell=(ancestor.getAscendant('td',true)||ancestor.getAscendant('th',true))))
{var resultRange=new CKEDITOR.dom.range(editor.document),next=CKEDITOR.tools.tryThese(function()
{var row=cell.getParent(),next=row.$.cells[cell.$.cellIndex+(backward?-1:1)];next.parentNode.parentNode;return next;},function()
{var row=cell.getParent(),table=row.getAscendant('table'),nextRow=table.$.rows[row.$.rowIndex+(backward?-1:1)];return nextRow.cells[backward?nextRow.cells.length-1:0];});if(!(next||backward))
{var table=cell.getAscendant('table').$,cells=cell.getParent().$.cells;var newRow=new CKEDITOR.dom.element(table.insertRow(-1),editor.document);for(var i=0,count=cells.length;i<count;i++)
{var newCell=newRow.append(new CKEDITOR.dom.element(cells[i],editor.document).clone(false,false));!CKEDITOR.env.ie&&newCell.appendBogus();}
resultRange.moveToElementEditStart(newRow);}
else if(next)
{next=new CKEDITOR.dom.element(next);resultRange.moveToElementEditStart(next);if(!(resultRange.checkStartOfBlock()&&resultRange.checkEndOfBlock()))
resultRange.selectNodeContents(next);}
else
return true;resultRange.select(true);return true;}}
return false;}};}
CKEDITOR.plugins.add('tab',{requires:['keystrokes'],init:function(editor)
{var tabTools=editor.config.enableTabKeyTools!==false,tabSpaces=editor.config.tabSpaces||0,tabText='';while(tabSpaces--)
tabText+='\xa0';if(tabText)
{editor.on('key',function(ev)
{if(ev.data.keyCode==9)
{editor.insertHtml(tabText);ev.cancel();}});}
if(tabTools)
{editor.on('key',function(ev)
{if(ev.data.keyCode==9&&editor.execCommand('selectNextCell')||ev.data.keyCode==(CKEDITOR.SHIFT+9)&&editor.execCommand('selectPreviousCell'))
ev.cancel();});}
editor.on('key',function(ev)
{var keyCode=ev.data.keyCode;if(keyCode==9&&!tabText)
{ev.cancel();editor.execCommand('blur');}
if(keyCode==(CKEDITOR.SHIFT+9))
{editor.execCommand('blurBack');ev.cancel();}});editor.addCommand('blur',CKEDITOR.tools.extend(blurCommand,meta));editor.addCommand('blurBack',CKEDITOR.tools.extend(blurBackCommand,meta));editor.addCommand('selectNextCell',selectNextCellCommand());editor.addCommand('selectPreviousCell',selectNextCellCommand(true));}});})();CKEDITOR.dom.element.prototype.focusNext=function(ignoreChildren,indexToUse)
{var $=this.$,curTabIndex=(indexToUse===undefined?this.getTabIndex():indexToUse),passedCurrent,enteredCurrent,elected,electedTabIndex,element,elementTabIndex;if(curTabIndex<=0)
{element=this.getNextSourceNode(ignoreChildren,CKEDITOR.NODE_ELEMENT);while(element)
{if(element.isVisible()&&element.getTabIndex()===0)
{elected=element;break;}
element=element.getNextSourceNode(false,CKEDITOR.NODE_ELEMENT);}}
else
{element=this.getDocument().getBody().getFirst();while((element=element.getNextSourceNode(false,CKEDITOR.NODE_ELEMENT)))
{if(!passedCurrent)
{if(!enteredCurrent&&element.equals(this))
{enteredCurrent=true;if(ignoreChildren)
{if(!(element=element.getNextSourceNode(true,CKEDITOR.NODE_ELEMENT)))
break;passedCurrent=1;}}
else if(enteredCurrent&&!this.contains(element))
passedCurrent=1;}
if(!element.isVisible()||(elementTabIndex=element.getTabIndex())<0)
continue;if(passedCurrent&&elementTabIndex==curTabIndex)
{elected=element;break;}
if(elementTabIndex>curTabIndex&&(!elected||!electedTabIndex||elementTabIndex<electedTabIndex))
{elected=element;electedTabIndex=elementTabIndex;}
else if(!elected&&elementTabIndex===0)
{elected=element;electedTabIndex=elementTabIndex;}}}
if(elected)
elected.focus();};CKEDITOR.dom.element.prototype.focusPrevious=function(ignoreChildren,indexToUse)
{var $=this.$,curTabIndex=(indexToUse===undefined?this.getTabIndex():indexToUse),passedCurrent,enteredCurrent,elected,electedTabIndex=0,elementTabIndex;var element=this.getDocument().getBody().getLast();while((element=element.getPreviousSourceNode(false,CKEDITOR.NODE_ELEMENT)))
{if(!passedCurrent)
{if(!enteredCurrent&&element.equals(this))
{enteredCurrent=true;if(ignoreChildren)
{if(!(element=element.getPreviousSourceNode(true,CKEDITOR.NODE_ELEMENT)))
break;passedCurrent=1;}}
else if(enteredCurrent&&!this.contains(element))
passedCurrent=1;}
if(!element.isVisible()||(elementTabIndex=element.getTabIndex())<0)
continue;if(curTabIndex<=0)
{if(passedCurrent&&elementTabIndex===0)
{elected=element;break;}
if(elementTabIndex>electedTabIndex)
{elected=element;electedTabIndex=elementTabIndex;}}
else
{if(passedCurrent&&elementTabIndex==curTabIndex)
{elected=element;break;}
if(elementTabIndex<curTabIndex&&(!elected||elementTabIndex>electedTabIndex))
{elected=element;electedTabIndex=elementTabIndex;}}}
if(elected)
elected.focus();};;(function()
{CKEDITOR.plugins.add('undo',{requires:['selection','wysiwygarea'],init:function(editor)
{var undoManager=new UndoManager(editor);var undoCommand=editor.addCommand('undo',{exec:function()
{if(undoManager.undo())
{editor.selectionChange();this.fire('afterUndo');}},state:CKEDITOR.TRISTATE_DISABLED,canUndo:false});var redoCommand=editor.addCommand('redo',{exec:function()
{if(undoManager.redo())
{editor.selectionChange();this.fire('afterRedo');}},state:CKEDITOR.TRISTATE_DISABLED,canUndo:false});undoManager.onChange=function()
{undoCommand.setState(undoManager.undoable()?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED);redoCommand.setState(undoManager.redoable()?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED);};function recordCommand(event)
{if(undoManager.enabled&&event.data.command.canUndo!==false)
undoManager.save();}
editor.on('beforeCommandExec',recordCommand);editor.on('afterCommandExec',recordCommand);editor.on('saveSnapshot',function()
{undoManager.save();});editor.on('contentDom',function()
{editor.document.on('keydown',function(event)
{if(!event.data.$.ctrlKey&&!event.data.$.metaKey)
undoManager.type(event);});});editor.on('beforeModeUnload',function()
{editor.mode=='wysiwyg'&&undoManager.save(true);});editor.on('mode',function()
{undoManager.enabled=editor.readOnly?false:editor.mode=='wysiwyg';undoManager.onChange();});editor.ui.addButton('Undo',{label:editor.lang.undo,command:'undo'});editor.ui.addButton('Redo',{label:editor.lang.redo,command:'redo'});editor.resetUndo=function()
{undoManager.reset();editor.fire('saveSnapshot');};editor.on('updateSnapshot',function()
{if(undoManager.currentImage&&new Image(editor).equals(undoManager.currentImage))
setTimeout(function(){undoManager.update();},0);});}});CKEDITOR.plugins.undo={};var Image=CKEDITOR.plugins.undo.Image=function(editor)
{this.editor=editor;editor.fire('beforeUndoImage');editor.fire('beforeCreateUndoSnapshot');var contents=editor.getSnapshot(),selection=contents&&editor.getSelection();CKEDITOR.env.ie&&contents&&(contents=contents.replace(/\s+data-cke-expando=".*?"/g,''));this.contents=contents;this.bookmarks=selection&&selection.createBookmarks2(true);editor.fire('afterCreateUndoSnapshot');editor.fire('afterUndoImage');};var protectedAttrs=/\b(?:href|src|name)="[^"]*?"/gi;Image.prototype={equals:function(otherImage,contentOnly)
{var thisContents=this.contents,otherContents=otherImage.contents;if(CKEDITOR.env.ie&&(CKEDITOR.env.ie7Compat||CKEDITOR.env.ie6Compat))
{thisContents=thisContents.replace(protectedAttrs,'');otherContents=otherContents.replace(protectedAttrs,'');}
if(thisContents!=otherContents)
return false;if(contentOnly)
return true;var bookmarksA=this.bookmarks,bookmarksB=otherImage.bookmarks;if(bookmarksA||bookmarksB)
{if(!bookmarksA||!bookmarksB||bookmarksA.length!=bookmarksB.length)
return false;for(var i=0;i<bookmarksA.length;i++)
{var bookmarkA=bookmarksA[i],bookmarkB=bookmarksB[i];if(bookmarkA.startOffset!=bookmarkB.startOffset||bookmarkA.endOffset!=bookmarkB.endOffset||!CKEDITOR.tools.arrayCompare(bookmarkA.start,bookmarkB.start)||!CKEDITOR.tools.arrayCompare(bookmarkA.end,bookmarkB.end))
{return false;}}}
return true;}};function UndoManager(editor)
{this.editor=editor;this.reset();}
var editingKeyCodes={8:1,46:1},modifierKeyCodes={16:1,17:1,18:1},navigationKeyCodes={37:1,38:1,39:1,40:1};UndoManager.prototype={type:function(event)
{var keystroke=event&&event.data.getKey(),isModifierKey=keystroke in modifierKeyCodes,isEditingKey=keystroke in editingKeyCodes,wasEditingKey=this.lastKeystroke in editingKeyCodes,sameAsLastEditingKey=isEditingKey&&keystroke==this.lastKeystroke,isReset=keystroke in navigationKeyCodes,wasReset=this.lastKeystroke in navigationKeyCodes,isContent=(!isEditingKey&&!isReset),modifierSnapshot=(isEditingKey&&!sameAsLastEditingKey),startedTyping=!(isModifierKey||this.typing)||(isContent&&(wasEditingKey||wasReset));if(startedTyping||modifierSnapshot)
{var beforeTypeImage=new Image(this.editor);CKEDITOR.tools.setTimeout(function()
{var currentSnapshot=this.editor.getSnapshot();if(CKEDITOR.env.ie)
currentSnapshot=currentSnapshot.replace(/\s+data-cke-expando=".*?"/g,'');if(beforeTypeImage.contents!=currentSnapshot)
{this.typing=true;if(!this.save(false,beforeTypeImage,false))
this.snapshots.splice(this.index+1,this.snapshots.length-this.index-1);this.hasUndo=true;this.hasRedo=false;this.typesCount=1;this.modifiersCount=1;this.onChange();}},0,this);}
this.lastKeystroke=keystroke;if(isEditingKey)
{this.typesCount=0;this.modifiersCount++;if(this.modifiersCount>25)
{this.save(false,null,false);this.modifiersCount=1;}}
else if(!isReset)
{this.modifiersCount=0;this.typesCount++;if(this.typesCount>25)
{this.save(false,null,false);this.typesCount=1;}}},reset:function()
{this.lastKeystroke=0;this.snapshots=[];this.index=-1;this.limit=this.editor.config.undoStackSize||20;this.currentImage=null;this.hasUndo=false;this.hasRedo=false;this.resetType();},resetType:function()
{this.typing=false;delete this.lastKeystroke;this.typesCount=0;this.modifiersCount=0;},fireChange:function()
{this.hasUndo=!!this.getNextImage(true);this.hasRedo=!!this.getNextImage(false);this.resetType();this.onChange();},save:function(onContentOnly,image,autoFireChange)
{var snapshots=this.snapshots;RTE.log('undo save');if(!image)
image=new Image(this.editor);if(image.contents===false)
return false;if(this.currentImage&&image.equals(this.currentImage,onContentOnly))
return false;snapshots.splice(this.index+1,snapshots.length-this.index-1);if(snapshots.length==this.limit)
snapshots.shift();this.index=snapshots.push(image)-1;this.currentImage=image;if(autoFireChange!==false)
this.fireChange();return true;},restoreImage:function(image)
{this.editor.loadSnapshot(image.contents);if(image.bookmarks)
this.editor.getSelection().selectBookmarks(image.bookmarks);else if(CKEDITOR.env.ie)
{var $range=this.editor.document.getBody().$.createTextRange();$range.collapse(true);$range.select();}
this.index=image.index;this.update();this.fireChange();this.editor.fire('wysiwygModeReady');},getNextImage:function(isUndo)
{var snapshots=this.snapshots,currentImage=this.currentImage,image,i;if(currentImage)
{if(isUndo)
{for(i=this.index-1;i>=0;i--)
{image=snapshots[i];if(!currentImage.equals(image,true))
{image.index=i;return image;}}}
else
{for(i=this.index+1;i<snapshots.length;i++)
{image=snapshots[i];if(!currentImage.equals(image,true))
{image.index=i;return image;}}}}
return null;},redoable:function()
{return this.enabled&&this.hasRedo;},undoable:function()
{return this.enabled&&this.hasUndo;},undo:function()
{if(this.undoable())
{this.save(true);var image=this.getNextImage(true);if(image)
return this.restoreImage(image),true;}
return false;},redo:function()
{if(this.redoable())
{this.save(true);if(this.redoable())
{var image=this.getNextImage(false);if(image)
return this.restoreImage(image),true;}}
return false;},update:function()
{this.snapshots.splice(this.index,1,(this.currentImage=new Image(this.editor)));}};})();;(function()
{var emptyParagraphRegexp=/(^|<body\b[^>]*>)\s*<(p|div|address|h\d|center|pre)[^>]*>\s*(?:<br[^>]*>|&nbsp;|\u00A0|&#160;)?\s*(:?<\/\2>)?\s*(?=$|<\/body>)/gi;var notWhitespaceEval=CKEDITOR.dom.walker.whitespaces(true);function nonEditable(element)
{return element.isBlockBoundary()&&CKEDITOR.dtd.$empty[element.getName()];}
function onInsert(insertFunc)
{return function(evt)
{if(this.mode=='wysiwyg')
{this.focus();this.fire('saveSnapshot');var selection=this.getSelection();var eventDataEx={selection:selection,ranges:selection&&selection.getRanges(),data:evt.data};this.fire('beforeInsertContent',eventDataEx);insertFunc.call(this,evt.data);CKEDITOR.tools.setTimeout(function()
{this.fire('afterInsertContent',eventDataEx);this.fire('saveSnapshot');},0,this);}};}
function doInsertHtml(data)
{if(this.dataProcessor)
data=this.dataProcessor.toHtml(data);if(!data)
return;var selection=this.getSelection(),range=selection.getRanges()[0];if(range.checkReadOnly())
return;if(CKEDITOR.env.opera)
{var path=new CKEDITOR.dom.elementPath(range.startContainer);if(path.block)
{var nodes=CKEDITOR.htmlParser.fragment.fromHtml(data,false).children;for(var i=0,count=nodes.length;i<count;i++)
{if(nodes[i]._.isBlockLike)
{range.splitBlock(this.enterMode==CKEDITOR.ENTER_DIV?'div':'p');range.insertNode(range.document.createText(''));range.select();break;}}}}
if(CKEDITOR.env.ie)
{var selIsLocked=selection.isLocked;if(selIsLocked)
selection.unlock();var $sel=selection.getNative();if($sel.type=='Control')
$sel.clear();else if(selection.getType()==CKEDITOR.SELECTION_TEXT)
{range=selection.getRanges()[0];var endContainer=range&&range.endContainer;if(endContainer&&endContainer.type==CKEDITOR.NODE_ELEMENT&&endContainer.getAttribute('contenteditable')=='false'&&range.checkBoundaryOfElement(endContainer,CKEDITOR.END))
{range.setEndAfter(range.endContainer);range.deleteContents();}}
try
{$sel.createRange().pasteHTML(data);}
catch(e){}
if(selIsLocked)
this.getSelection().lock();}
else{var self=this;setTimeout(function(){self.document.$.execCommand('inserthtml',false,data);},100);}
if(CKEDITOR.env.webkit)
{selection=this.getSelection();selection.scrollIntoView();}}
function doInsertText(text)
{var selection=this.getSelection(),mode=selection.getStartElement().hasAscendant('pre',true)?CKEDITOR.ENTER_BR:this.config.enterMode,isEnterBrMode=mode==CKEDITOR.ENTER_BR;var html=CKEDITOR.tools.htmlEncode(text.replace(/\r\n|\r/g,'\n'));html=html.replace(/^[ \t]+|[ \t]+$/g,function(match,offset,s)
{if(match.length==1)
return'&nbsp;';else if(!offset)
return CKEDITOR.tools.repeat('&nbsp;',match.length-1)+' ';else
return' '+CKEDITOR.tools.repeat('&nbsp;',match.length-1);});html=html.replace(/[ \t]{2,}/g,function(match)
{return CKEDITOR.tools.repeat('&nbsp;',match.length-1)+' ';});var paragraphTag=mode==CKEDITOR.ENTER_P?'p':'div';if(!isEnterBrMode)
{html=html.replace(/(\n{2})([\s\S]*?)(?:$|\1)/g,function(match,group1,text)
{return'<'+paragraphTag+'>'+text+'</'+paragraphTag+'>';});}
html=html.replace(/\n/g,'<br>');if(!(isEnterBrMode||CKEDITOR.env.ie))
{html=html.replace(new RegExp('<br>(?=</'+paragraphTag+'>)'),function(match)
{return CKEDITOR.tools.repeat(match,2);});}
if(CKEDITOR.env.gecko||CKEDITOR.env.webkit)
{var path=new CKEDITOR.dom.elementPath(selection.getStartElement()),context=[];for(var i=0;i<path.elements.length;i++)
{var tag=path.elements[i].getName();if(tag in CKEDITOR.dtd.$inline)
context.unshift(path.elements[i].getOuterHtml().match(/^<.*?>/));else if(tag in CKEDITOR.dtd.$block)
break;}
html=context.join('')+html;}
doInsertHtml.call(this,html);}
function doInsertElement(element)
{var selection=this.getSelection(),ranges=selection.getRanges(),elementName=element.getName(),isBlock=CKEDITOR.dtd.$block[elementName];var selIsLocked=selection.isLocked;if(selIsLocked)
selection.unlock();var range,clone,lastElement,bookmark;for(var i=ranges.length-1;i>=0;i--)
{range=ranges[i];if(!range.checkReadOnly())
{range.deleteContents(1);clone=!i&&element||element.clone(1);var current,dtd;if(isBlock)
{while((current=range.getCommonAncestor(0,1))&&(dtd=CKEDITOR.dtd[current.getName()])&&!(dtd&&dtd[elementName]))
{if(current.getName()in CKEDITOR.dtd.span)
range.splitElement(current);else if(range.checkStartOfBlock()&&range.checkEndOfBlock())
{range.setStartBefore(current);range.collapse(true);current.remove();}
else
range.splitBlock();}}
var commonAncestor=range.getCommonAncestor(0,1);if((/h\d/i).test(commonAncestor.getName())){var insertBefore=(range.startOffset==0);if(insertBefore){range.setStartBefore(commonAncestor);}
else{range.setStartAfter(commonAncestor);}}
range.insertNode(clone);if(!lastElement)
lastElement=clone;}
else{this.fire('readOnlySelection');}}
if(lastElement)
{range.moveToPosition(lastElement,CKEDITOR.POSITION_AFTER_END);if(isBlock)
{var next=lastElement.getNext(notWhitespaceEval),nextName=next&&next.type==CKEDITOR.NODE_ELEMENT&&next.getName();if(nextName&&CKEDITOR.dtd.$block[nextName]&&CKEDITOR.dtd[nextName]['#'])
range.moveToElementEditStart(next);}}
selection.selectRanges([range]);if(selIsLocked)
this.getSelection().lock();}
function restoreDirty(editor)
{if(!editor.checkDirty())
setTimeout(function(){editor.resetDirty();},0);}
var isNotWhitespace=CKEDITOR.dom.walker.whitespaces(true),isNotBookmark=CKEDITOR.dom.walker.bookmark(false,true);function isNotEmpty(node)
{return isNotWhitespace(node)&&isNotBookmark(node);}
function isNbsp(node)
{return node.type==CKEDITOR.NODE_TEXT&&CKEDITOR.tools.trim(node.getText()).match(/^(?:&nbsp;|\xa0)$/);}
function restoreSelection(selection)
{if(selection.isLocked)
{selection.unlock();setTimeout(function(){selection.lock();},0);}}
function isBlankParagraph(block)
{return block.getOuterHtml().match(emptyParagraphRegexp);}
isNotWhitespace=CKEDITOR.dom.walker.whitespaces(true);function activateEditing(editor)
{var win=editor.window,doc=editor.document,body=editor.document.getBody(),bodyFirstChild=body.getFirst(),bodyChildsNum=body.getChildren().count();if(!bodyChildsNum||bodyChildsNum==1&&bodyFirstChild.type==CKEDITOR.NODE_ELEMENT&&bodyFirstChild.hasAttribute('_moz_editor_bogus_node'))
{restoreDirty(editor);var hostDocument=editor.element.getDocument();var hostDocumentElement=hostDocument.getDocumentElement();var scrollTop=hostDocumentElement.$.scrollTop;var scrollLeft=hostDocumentElement.$.scrollLeft;var keyEventSimulate=doc.$.createEvent("KeyEvents");keyEventSimulate.initKeyEvent('keypress',true,true,win.$,false,false,false,false,0,32);doc.$.dispatchEvent(keyEventSimulate);if(scrollTop!=hostDocumentElement.$.scrollTop||scrollLeft!=hostDocumentElement.$.scrollLeft)
hostDocument.getWindow().$.scrollTo(scrollLeft,scrollTop);bodyChildsNum&&body.getFirst().remove();doc.getBody().appendBogus();var nativeRange=new CKEDITOR.dom.range(doc);nativeRange.setStartAt(body,CKEDITOR.POSITION_AFTER_START);nativeRange.select();}}
function onSelectionChangeFixBody(evt)
{var editor=evt.editor,path=evt.data.path,blockLimit=path.blockLimit,selection=evt.data.selection,range=selection.getRanges()[0],body=editor.document.getBody(),enterMode=editor.config.enterMode;if(CKEDITOR.env.gecko)
{activateEditing(editor);var pathBlock=path.block||path.blockLimit,lastNode=pathBlock&&pathBlock.getLast(isNotEmpty);if(pathBlock&&pathBlock.isBlockBoundary()&&!(lastNode&&lastNode.type==CKEDITOR.NODE_ELEMENT&&lastNode.isBlockBoundary())&&!pathBlock.is('pre')&&!pathBlock.getBogus())
{editor.fire('updateSnapshot');restoreDirty(editor);pathBlock.appendBogus();}}
if(editor.config.autoParagraph!==false&&enterMode!=CKEDITOR.ENTER_BR&&range.collapsed&&blockLimit.getName()=='body'&&!path.block)
{editor.fire('updateSnapshot');restoreDirty(editor);CKEDITOR.env.ie&&restoreSelection(selection);var fixedBlock=range.fixBlock(true,editor.config.enterMode==CKEDITOR.ENTER_DIV?'div':'p');if(CKEDITOR.env.ie)
{var first=fixedBlock.getFirst(isNotEmpty);first&&isNbsp(first)&&first.remove();}
if(isBlankParagraph(fixedBlock))
{var element=fixedBlock.getNext(isNotWhitespace);if(element&&element.type==CKEDITOR.NODE_ELEMENT&&!nonEditable(element))
{range.moveToElementEditStart(element);fixedBlock.remove();}
else
{element=fixedBlock.getPrevious(isNotWhitespace);if(element&&element.type==CKEDITOR.NODE_ELEMENT&&!nonEditable(element))
{range.moveToElementEditEnd(element);fixedBlock.remove();}}}
range.select();evt.cancel();}
var testRange=new CKEDITOR.dom.range(editor.document);testRange.moveToElementEditEnd(editor.document.getBody());var testPath=new CKEDITOR.dom.elementPath(testRange.startContainer);if(!testPath.blockLimit.is('body'))
{editor.fire('updateSnapshot');restoreDirty(editor);CKEDITOR.env.ie&&restoreSelection(selection);var paddingBlock;if(enterMode!=CKEDITOR.ENTER_BR)
paddingBlock=body.append(editor.document.createElement(enterMode==CKEDITOR.ENTER_P?'p':'div'));else
paddingBlock=body;if(!CKEDITOR.env.ie)
paddingBlock.appendBogus();}}
CKEDITOR.plugins.add('wysiwygarea',{requires:['editingblock'],init:function(editor)
{var fixForBody=(editor.config.enterMode!=CKEDITOR.ENTER_BR&&editor.config.autoParagraph!==false)?editor.config.enterMode==CKEDITOR.ENTER_DIV?'div':'p':false;var frameLabel=editor.lang.editorTitle.replace('%1',editor.name);var contentDomReadyHandler;editor.on('editingBlockReady',function()
{var mainElement,iframe,isLoadingData,isPendingFocus,frameLoaded,fireMode;var isCustomDomain=CKEDITOR.env.isCustomDomain();var createIFrame=function(data)
{if(iframe)
iframe.remove();var src='document.open();'+
(isCustomDomain?('document.domain="'+document.domain+'";'):'')+'document.close();';src=CKEDITOR.env.air?'javascript:void(0)':CKEDITOR.env.ie?'javascript:void(function(){'+encodeURIComponent(src)+'}())':'';iframe=CKEDITOR.dom.element.createFromHtml('<iframe'+' style="width:100%;height:100%"'+' frameBorder="0"'+' title="'+frameLabel+'"'+' src="'+src+'"'+' tabIndex="'+(CKEDITOR.env.webkit?-1:editor.tabIndex)+'"'+' allowTransparency="true"'+'></iframe>');if(document.location.protocol=='chrome:')
CKEDITOR.event.useCapture=true;iframe.on('load',function(ev)
{frameLoaded=1;ev.removeListener();var doc=iframe.getFrameDocument();doc.write(data);CKEDITOR.env.air&&contentDomReady(doc.getWindow().$);});if(document.location.protocol=='chrome:')
CKEDITOR.event.useCapture=false;mainElement.append(iframe);};contentDomReadyHandler=CKEDITOR.tools.addFunction(contentDomReady);var activationScript='<script id="cke_actscrpt" type="text/javascript" data-cke-temp="1">'+
(isCustomDomain?('document.domain="'+document.domain+'";'):'')+'window.parent.CKEDITOR.tools.callFunction( '+contentDomReadyHandler+', window );'+'</script>';function contentDomReady(domWindow)
{if(!frameLoaded)
return;frameLoaded=0;editor.fire('ariaWidget',iframe);var domDocument=domWindow.document,body=domDocument.body;var script=domDocument.getElementById("cke_actscrpt");script&&script.parentNode.removeChild(script);body.spellcheck=!editor.config.disableNativeSpellChecker;var editable=!editor.readOnly;if(CKEDITOR.env.ie)
{body.hideFocus=true;body.disabled=true;body.contentEditable=editable;body.removeAttribute('disabled');}
else
{setTimeout(function()
{if(CKEDITOR.env.gecko&&CKEDITOR.env.version>=10900||CKEDITOR.env.opera)
domDocument.$.body.contentEditable=editable;else if(CKEDITOR.env.webkit)
domDocument.$.body.parentNode.contentEditable=editable;else
domDocument.$.designMode=editable?'off':'on';},0);}
editable&&CKEDITOR.env.gecko&&CKEDITOR.tools.setTimeout(activateEditing,0,null,editor);domWindow=editor.window=new CKEDITOR.dom.window(domWindow);domDocument=editor.document=new CKEDITOR.dom.document(domDocument);editable&&domDocument.on('dblclick',function(evt)
{var element=evt.data.getTarget(),data={element:element,dialog:''};editor.fire('doubleclick',data);data.dialog&&editor.openDialog(data.dialog);});CKEDITOR.env.ie&&domDocument.on('click',function(evt)
{var element=evt.data.getTarget();if(element.is('input'))
{var type=element.getAttribute('type');if(type=='submit'||type=='reset')
evt.data.preventDefault();}});if(!(CKEDITOR.env.ie||CKEDITOR.env.opera))
{domDocument.on('mousedown',function(ev)
{var control=ev.data.getTarget();if(control.is('img','hr','input','textarea','select'))
editor.getSelection().selectElement(control);});}
if(CKEDITOR.env.gecko)
{domDocument.on('mouseup',function(ev)
{if(ev.data.$.button==2)
{var target=ev.data.getTarget();if(target.getOuterHtml&&!target.getOuterHtml().replace(emptyParagraphRegexp,''))
{var range=new CKEDITOR.dom.range(domDocument);range.moveToElementEditStart(target);range.select(true);}}});}
domDocument.on('click',function(ev)
{ev=ev.data;if(ev.getTarget().is('a')&&ev.$.button!=2)
ev.preventDefault();});if(CKEDITOR.env.webkit)
{domDocument.on('mousedown',function(){wasFocused=1;});domDocument.on('click',function(ev)
{if(ev.data.getTarget().is('input','select'))
ev.data.preventDefault();});domDocument.on('mouseup',function(ev)
{if(ev.data.getTarget().is('input','textarea'))
ev.data.preventDefault();});}
if(editable&&CKEDITOR.env.ie&&domDocument.$.compatMode=='CSS1Compat'||CKEDITOR.env.gecko||CKEDITOR.env.opera)
{var htmlElement=domDocument.getDocumentElement();htmlElement.on('mousedown',function(evt)
{if(evt.data.getTarget().equals(htmlElement))
editor.focusGrabber&&editor.focusGrabber.focus();});}
var focusTarget=CKEDITOR.env.ie?iframe:domWindow;focusTarget.on('blur',function()
{editor.focusManager.blur();});var wasFocused;focusTarget.on('focus',function()
{var doc=editor.document;if(editable&&CKEDITOR.env.gecko&&CKEDITOR.env.version>=10900)
blinkCursor();else if(CKEDITOR.env.opera)
doc.getBody().focus();else if(CKEDITOR.env.webkit)
{if(!wasFocused)
{editor.document.getDocumentElement().focus();wasFocused=1;}}
editor.focusManager.focus();});var keystrokeHandler=editor.keystrokeHandler;keystrokeHandler.blockedKeystrokes[8]=!editable;keystrokeHandler.attach(domDocument);if(CKEDITOR.env.ie)
{domDocument.getDocumentElement().addClass(domDocument.$.compatMode);editable&&domDocument.on('keydown',function(evt)
{var keyCode=evt.data.getKeystroke();if(keyCode in{8:1,46:1})
{var sel=editor.getSelection(),control=sel.getSelectedElement();if(control)
{editor.fire('saveSnapshot');var bookmark=sel.getRanges()[0].createBookmark();control.remove();sel.selectBookmarks([bookmark]);editor.fire('saveSnapshot');evt.data.preventDefault();}}});if(domDocument.$.compatMode=='CSS1Compat')
{var pageUpDownKeys={33:1,34:1};domDocument.on('keydown',function(evt)
{if(evt.data.getKeystroke()in pageUpDownKeys)
{setTimeout(function()
{editor.getSelection().scrollIntoView();},0);}});}
editor.config.enterMode!=CKEDITOR.ENTER_P&&domDocument.on('selectionchange',function()
{var body=domDocument.getBody(),range=editor.getSelection().getRanges()[0];if(body.getHtml().match(/^<p>&nbsp;<\/p>$/i)&&range.startContainer.equals(body))
{setTimeout(function()
{range=editor.getSelection().getRanges()[0];if(!range.startContainer.equals('body'))
{body.getFirst().remove(1);range.moveToElementEditEnd(body);range.select(1);}},0);}});}
if(editor.contextMenu)
editor.contextMenu.addTarget(domDocument,editor.config.browserContextMenuOnCtrl!==false);setTimeout(function()
{editor.fire('contentDom');if(fireMode)
{editor.mode='wysiwyg';editor.fire('mode');fireMode=false;}
isLoadingData=false;if(isPendingFocus)
{editor.focus();isPendingFocus=false;}
setTimeout(function()
{editor.fire('dataReady');},0);try{editor.document.$.execCommand('enableInlineTableEditing',false,!editor.config.disableNativeTableHandles);}catch(e){}
if(editor.config.disableObjectResizing)
{try
{editor.document.$.execCommand('enableObjectResizing',false,false);}
catch(e)
{editor.document.getBody().on(CKEDITOR.env.ie?'resizestart':'resize',function(evt)
{evt.data.preventDefault();});}}
if(CKEDITOR.env.ie)
{setTimeout(function()
{if(editor.document)
{var $body=editor.document.$.body;$body.runtimeStyle.marginBottom='0px';$body.runtimeStyle.marginBottom='';}},1000);}},0);}
editor.addMode('wysiwyg',{load:function(holderElement,data,isSnapshot)
{mainElement=holderElement;if(CKEDITOR.env.ie&&CKEDITOR.env.quirks)
holderElement.setStyle('position','relative');editor.mayBeDirty=true;fireMode=true;if(isSnapshot)
this.loadSnapshotData(data);else
this.loadData(data);},loadData:function(data)
{isLoadingData=true;editor._.dataStore={id:1};var config=editor.config,fullPage=config.fullPage,docType=config.docType;var headExtra='<style type="text/css" data-cke-temp="1">'+
editor._.styles.join('\n')+'</style>';!fullPage&&(headExtra=CKEDITOR.tools.buildStyleHtml(editor.config.contentsCss)+
headExtra);var baseTag=config.baseHref?'<base href="'+config.baseHref+'" data-cke-temp="1" />':'';if(fullPage)
{data=data.replace(/<!DOCTYPE[^>]*>/i,function(match)
{editor.docType=docType=match;return'';}).replace(/<\?xml\s[^\?]*\?>/i,function(match)
{editor.xmlDeclaration=match;return'';});}
if(editor.dataProcessor)
data=editor.dataProcessor.toHtml(data,fixForBody);if(fullPage)
{if(!(/<body[\s|>]/).test(data))
data='<body>'+data;if(!(/<html[\s|>]/).test(data))
data='<html>'+data+'</html>';if(!(/<head[\s|>]/).test(data))
data=data.replace(/<html[^>]*>/,'$&<head><title></title></head>');else if(!(/<title[\s|>]/).test(data))
data=data.replace(/<head[^>]*>/,'$&<title></title>');baseTag&&(data=data.replace(/<head>/,'$&'+baseTag));data=data.replace(/<\/head\s*>/,headExtra+'$&');data=docType+data;}
else
{data=config.docType+'<html dir="'+config.contentsLangDirection+'"'+' lang="'+(config.contentsLanguage||editor.langCode)+'">'+'<head>'+'<title>'+frameLabel+'</title>'+
baseTag+
headExtra+'</head>'+'<body'+(config.bodyId?' id="'+config.bodyId+'"':'')+
(config.bodyClass?' class="'+config.bodyClass+'"':'')+'>'+
data+'</html>';}
if(CKEDITOR.env.gecko)
data=data.replace(/<br \/>(?=\s*<\/(:?html|body)>)/,'$&<br type="_moz" />');data+=activationScript;this.onDispose();createIFrame(data);},getData:function()
{var config=editor.config,fullPage=config.fullPage,docType=fullPage&&editor.docType,xmlDeclaration=fullPage&&editor.xmlDeclaration,doc=iframe.getFrameDocument();var data=fullPage?doc.getDocumentElement().getOuterHtml():doc.getBody().getHtml();if(CKEDITOR.env.gecko)
data=data.replace(/<br>(?=\s*(:?$|<\/body>))/,'');if(editor.dataProcessor)
data=editor.dataProcessor.toDataFormat(data,fixForBody);if(config.ignoreEmptyParagraph)
data=data.replace(emptyParagraphRegexp,function(match,lookback){return lookback;});if(xmlDeclaration)
data=xmlDeclaration+'\n'+data;if(docType)
data=docType+'\n'+data;return data;},getSnapshotData:function()
{return iframe.getFrameDocument().getBody().getHtml();},loadSnapshotData:function(data)
{iframe.getFrameDocument().getBody().setHtml(data);},onDispose:function()
{if(!editor.document)
return;editor.document.getDocumentElement().clearCustomData();editor.document.getBody().clearCustomData();editor.window.clearCustomData();editor.document.clearCustomData();iframe.clearCustomData();iframe.remove();},unload:function(holderElement)
{this.onDispose();editor.window=editor.document=iframe=mainElement=isPendingFocus=null;editor.fire('contentDomUnload');},focus:function()
{var win=editor.window;if(isLoadingData)
isPendingFocus=true;else if(CKEDITOR.env.opera&&editor.document)
{var iframe=editor.window.$.frameElement;iframe.blur(),iframe.focus();editor.document.getBody().focus();editor.selectionChange();}
else if(!CKEDITOR.env.opera&&win)
{CKEDITOR.env.air?setTimeout(function(){win.focus();},0):win.focus();editor.selectionChange();}}});editor.on('insertHtml',onInsert(doInsertHtml),null,null,20);editor.on('insertElement',onInsert(doInsertElement),null,null,20);editor.on('insertText',onInsert(doInsertText),null,null,20);editor.on('selectionChange',onSelectionChangeFixBody,null,null,1);});var titleBackup;editor.on('contentDom',function()
{var title=editor.document.getElementsByTag('title').getItem(0);title.data('cke-title',editor.document.$.title);editor.document.$.title=frameLabel;});editor.on('readOnly',function()
{if(editor.mode=='wysiwyg')
{var wysiwyg=editor.getMode();wysiwyg.loadData(wysiwyg.getData());}
editor.keystrokeHandler.blockedKeystrokes[8]=editor.readOnly;});if(CKEDITOR.document.$.documentMode>=8)
{editor.addCss('html.CSS1Compat [contenteditable=false]{ min-height:0 !important;}');var selectors=[];for(var tag in CKEDITOR.dtd.$removeEmpty)
selectors.push('html.CSS1Compat '+tag+'[contenteditable=false]');editor.addCss(selectors.join(',')+'{ display:inline-block;}');}
else if(CKEDITOR.env.gecko)
{editor.addCss('html { height: 100% !important; }');editor.addCss('img:-moz-broken { -moz-force-broken-image-icon : 1; width : 24px; height : 24px; }');}
editor.addCss('html { _overflow-y: scroll; cursor: text; *cursor:auto;}');editor.addCss('img, input, textarea { cursor: default;}');function blinkCursor(retry)
{if(editor.readOnly)
return;CKEDITOR.tools.tryThese(function()
{editor.document.$.designMode='on';setTimeout(function()
{editor.document.$.designMode='off';if(CKEDITOR.currentInstance==editor)
editor.document.getBody().focus();},50);},function()
{editor.document.$.designMode='off';var body=editor.document.getBody();body.setAttribute('contentEditable',false);body.setAttribute('contentEditable',true);!retry&&blinkCursor(1);});}
if(CKEDITOR.env.ie||CKEDITOR.env.opera)
{var focusGrabber;editor.on('uiReady',function()
{focusGrabber=editor.container.append(CKEDITOR.dom.element.createFromHtml('<span tabindex="-1" style="position:absolute;" role="presentation"></span>'));focusGrabber.on('focus',function()
{editor.focus();});editor.focusGrabber=focusGrabber;});editor.on('destroy',function()
{CKEDITOR.tools.removeFunction(contentDomReadyHandler);focusGrabber.clearCustomData();delete editor.focusGrabber;});}
editor.on('insertElement',function(evt)
{var element=evt.data;if(element.type==CKEDITOR.NODE_ELEMENT&&(element.is('input')||element.is('textarea')))
{if(!element.isReadOnly())
element.data('cke-editable',element.hasAttribute('contenteditable')?'true':'1');element.setAttribute('contentEditable',false);}});}});if(CKEDITOR.env.gecko)
{(function()
{var body=document.body;if(!body)
window.addEventListener('load',arguments.callee,false);else
{var currentHandler=body.getAttribute('onpageshow');body.setAttribute('onpageshow',(currentHandler?currentHandler+';':'')+'event.persisted && (function(){'+'var allInstances = CKEDITOR.instances, editor, doc;'+'for ( var i in allInstances )'+'{'+' editor = allInstances[ i ];'+' doc = editor.document;'+' if ( doc )'+' {'+'  doc.$.designMode = "off";'+'  doc.$.designMode = "on";'+' }'+'}'+'})();');}})();}})();CKEDITOR.config.disableObjectResizing=false;CKEDITOR.config.disableNativeTableHandles=true;CKEDITOR.config.disableNativeSpellChecker=true;CKEDITOR.config.ignoreEmptyParagraph=true;;CKEDITOR.DIALOG_RESIZE_NONE=0;CKEDITOR.DIALOG_RESIZE_WIDTH=1;CKEDITOR.DIALOG_RESIZE_HEIGHT=2;CKEDITOR.DIALOG_RESIZE_BOTH=3;(function()
{var cssLength=CKEDITOR.tools.cssLength;function isTabVisible(tabId)
{return!!this._.tabs[tabId][0].$.offsetHeight;}
function getPreviousVisibleTab()
{var tabId=this._.currentTabId,length=this._.tabIdList.length,tabIndex=CKEDITOR.tools.indexOf(this._.tabIdList,tabId)+length;for(var i=tabIndex-1;i>tabIndex-length;i--)
{if(isTabVisible.call(this,this._.tabIdList[i%length]))
return this._.tabIdList[i%length];}
return null;}
function getNextVisibleTab()
{var tabId=this._.currentTabId,length=this._.tabIdList.length,tabIndex=CKEDITOR.tools.indexOf(this._.tabIdList,tabId);for(var i=tabIndex+1;i<tabIndex+length;i++)
{if(isTabVisible.call(this,this._.tabIdList[i%length]))
return this._.tabIdList[i%length];}
return null;}
function clearOrRecoverTextInputValue(container,isRecover)
{var inputs=container.$.getElementsByTagName('input');for(var i=0,length=inputs.length;i<length;i++)
{var item=new CKEDITOR.dom.element(inputs[i]);if(item.getAttribute('type').toLowerCase()=='text')
{if(isRecover)
{item.setAttribute('value',item.getCustomData('fake_value')||'');item.removeCustomData('fake_value');}
else
{item.setCustomData('fake_value',item.getAttribute('value'));item.setAttribute('value','');}}}}
function handleFieldValidated(isValid,msg)
{var input=this.getInputElement();if(input)
{isValid?input.removeAttribute('aria-invalid'):input.setAttribute('aria-invalid',true);}
if(!isValid)
{var dialog=this.getDialog();dialog.fire('notvalid',{item:this});if(this.select)
this.select();else
this.focus();}
msg&&alert(msg);this.fire('validated',{valid:isValid,msg:msg});}
function resetField()
{var input=this.getInputElement();input&&input.removeAttribute('aria-invalid');}
CKEDITOR.dialog=function(editor,dialogName)
{var definition=CKEDITOR.dialog._.dialogDefinitions[dialogName],defaultDefinition=CKEDITOR.tools.clone(defaultDialogDefinition),buttonsOrder=editor.config.dialog_buttonsOrder||'OS',dir=editor.lang.dir;if((buttonsOrder=='OS'&&CKEDITOR.env.mac)||(buttonsOrder=='rtl'&&dir=='ltr')||(buttonsOrder=='ltr'&&dir=='rtl'))
defaultDefinition.buttons.reverse();definition=CKEDITOR.tools.extend(definition(editor),defaultDefinition);definition=CKEDITOR.tools.clone(definition);definition=new definitionObject(this,definition);var doc=CKEDITOR.document;var themeBuilt=editor.theme.buildDialog(editor);this._={editor:editor,element:themeBuilt.element,name:dialogName,contentSize:{width:0,height:0},size:{width:0,height:0},contents:{},buttons:{},accessKeyMap:{},tabs:{},tabIdList:[],currentTabId:null,currentTabIndex:null,pageCount:0,lastTab:null,tabBarMode:false,focusList:[],currentFocusIndex:0,hasFocus:false};this.parts=themeBuilt.parts;CKEDITOR.tools.setTimeout(function()
{editor.fire('ariaWidget',this.parts.contents);},0,this);var startStyles={position:CKEDITOR.env.ie6Compat?'absolute':'fixed',top:0,visibility:'hidden'};startStyles[dir=='rtl'?'right':'left']=0;this.parts.dialog.setStyles(startStyles);CKEDITOR.event.call(this);this.definition=definition=CKEDITOR.fire('dialogDefinition',{name:dialogName,definition:definition},editor).definition;var tabsToRemove={};if(!('removeDialogTabs'in editor._)&&editor.config.removeDialogTabs)
{var removeContents=editor.config.removeDialogTabs.split(';');for(i=0;i<removeContents.length;i++)
{var parts=removeContents[i].split(':');if(parts.length==2)
{var removeDialogName=parts[0];if(!tabsToRemove[removeDialogName])
tabsToRemove[removeDialogName]=[];tabsToRemove[removeDialogName].push(parts[1]);}}
editor._.removeDialogTabs=tabsToRemove;}
if(editor._.removeDialogTabs&&(tabsToRemove=editor._.removeDialogTabs[dialogName]))
{for(i=0;i<tabsToRemove.length;i++)
definition.removeContents(tabsToRemove[i]);}
if(definition.onLoad)
this.on('load',definition.onLoad);if(definition.onShow)
this.on('show',definition.onShow);if(definition.onHide)
this.on('hide',definition.onHide);if(definition.onOk)
{this.on('ok',function(evt)
{editor.fire('dialogOk',this);editor.fire('saveSnapshot');setTimeout(function(){editor.fire('saveSnapshot');},0);if(definition.onOk.call(this,evt)===false)
evt.data.hide=false;});}
if(definition.onCancel)
{this.on('cancel',function(evt)
{editor.fire('dialogCancel',this);if(definition.onCancel.call(this,evt)===false)
evt.data.hide=false;});}
var me=this;var iterContents=function(func)
{var contents=me._.contents,stop=false;for(var i in contents)
{for(var j in contents[i])
{stop=func.call(this,contents[i][j]);if(stop)
return;}}};this.on('ok',function(evt)
{iterContents(function(item)
{if(item.validate)
{var retval=item.validate(this),invalid=typeof(retval)=='string'||retval===false;if(invalid)
{evt.data.hide=false;evt.stop();}
handleFieldValidated.call(item,!invalid,typeof retval=='string'?retval:undefined);return invalid;}});},this,null,0);this.on('cancel',function(evt)
{if(this.definition.doNotCheckForChanged){return;}
iterContents(function(item)
{if(item.isChanged())
{if(!confirm(editor.lang.common.confirmCancel))
evt.data.hide=false;return true;}});},this,null,0);this.parts.close.on('click',function(evt)
{this.fire('close',{close:true});editor.fire('dialogClose',this);if(this.fire('cancel',{hide:true}).hide!==false)
this.hide();evt.data.preventDefault();},this);function setupFocus()
{var focusList=me._.focusList;focusList.sort(function(a,b)
{if(a.tabIndex!=b.tabIndex)
return b.tabIndex-a.tabIndex;else
return a.focusIndex-b.focusIndex;});var size=focusList.length;for(var i=0;i<size;i++)
focusList[i].focusIndex=i;}
function changeFocus(forward)
{var focusList=me._.focusList,offset=forward?1:-1;if(focusList.length<1)
return;var current=me._.currentFocusIndex;try
{focusList[current].getInputElement().$.blur();}
catch(e){}
var startIndex=(current+offset+focusList.length)%focusList.length,currentIndex=startIndex;while(!focusList[currentIndex].isFocusable())
{currentIndex=(currentIndex+offset+focusList.length)%focusList.length;if(currentIndex==startIndex)
break;}
focusList[currentIndex].focus();if(focusList[currentIndex].type=='text')
focusList[currentIndex].select();}
this.changeFocus=changeFocus;var processed;function focusKeydownHandler(evt)
{if(me!=CKEDITOR.dialog._.currentTop)
return;var keystroke=evt.data.getKeystroke(),rtl=editor.lang.dir=='rtl';processed=0;if(keystroke==9||keystroke==CKEDITOR.SHIFT+9)
{var shiftPressed=(keystroke==CKEDITOR.SHIFT+9);if(me._.tabBarMode)
{var nextId=shiftPressed?getPreviousVisibleTab.call(me):getNextVisibleTab.call(me);me.selectPage(nextId);me._.tabs[nextId][0].focus();}
else
{changeFocus(!shiftPressed);}
processed=1;}
else if(keystroke==CKEDITOR.ALT+121&&!me._.tabBarMode&&me.getPageCount()>1)
{me._.tabBarMode=true;me._.tabs[me._.currentTabId][0].focus();processed=1;}
else if((keystroke==37||keystroke==39)&&me._.tabBarMode)
{nextId=(keystroke==(rtl?39:37)?getPreviousVisibleTab.call(me):getNextVisibleTab.call(me));me.selectPage(nextId);me._.tabs[nextId][0].focus();processed=1;}
else if((keystroke==13||keystroke==32)&&me._.tabBarMode)
{this.selectPage(this._.currentTabId);this._.tabBarMode=false;this._.currentFocusIndex=-1;changeFocus(true);processed=1;}
if(processed)
{evt.stop();evt.data.preventDefault();}}
function focusKeyPressHandler(evt)
{processed&&evt.data.preventDefault();}
var dialogElement=this._.element;this.on('show',function()
{dialogElement.on('keydown',focusKeydownHandler,this,null,0);if(CKEDITOR.env.opera||(CKEDITOR.env.gecko&&CKEDITOR.env.mac))
dialogElement.on('keypress',focusKeyPressHandler,this);});this.on('hide',function()
{dialogElement.removeListener('keydown',focusKeydownHandler);if(CKEDITOR.env.opera||(CKEDITOR.env.gecko&&CKEDITOR.env.mac))
dialogElement.removeListener('keypress',focusKeyPressHandler);iterContents(function(item){resetField.apply(item);});});this.on('iframeAdded',function(evt)
{var doc=new CKEDITOR.dom.document(evt.data.iframe.$.contentWindow.document);doc.on('keydown',focusKeydownHandler,this,null,0);});this.on('show',function()
{setupFocus();if(editor.config.dialog_startupFocusTab&&me._.pageCount>1)
{me._.tabBarMode=true;me._.tabs[me._.currentTabId][0].focus();}
else if(!this._.hasFocus)
{this._.currentFocusIndex=-1;if(definition.onFocus)
{var initialFocus=definition.onFocus.call(this);initialFocus&&initialFocus.focus();}
else
changeFocus(true);if(this._.editor.mode=='wysiwyg'&&CKEDITOR.env.ie)
{var $selection=editor.document.$.selection,$range=$selection.createRange();if($range)
{if($range.parentElement&&$range.parentElement().ownerDocument==editor.document.$||$range.item&&$range.item(0).ownerDocument==editor.document.$)
{var $myRange=document.body.createTextRange();$myRange.moveToElementText(this.getElement().getFirst().$);$myRange.collapse(true);$myRange.select();}}}}},this,null,0xffffffff);if(CKEDITOR.env.ie6Compat)
{this.on('load',function(evt)
{var outer=this.getElement(),inner=outer.getFirst();inner.remove();inner.appendTo(outer);},this);}
initDragAndDrop(this);initResizeHandles(this);(new CKEDITOR.dom.text(definition.title,CKEDITOR.document)).appendTo(this.parts.title);for(var i=0;i<definition.contents.length;i++)
{var page=definition.contents[i];page&&this.addPage(page);}
this.parts['tabs'].on('click',function(evt)
{var target=evt.data.getTarget();if(target.hasClass('cke_dialog_tab'))
{var id=target.$.id;this.selectPage(id.substring(4,id.lastIndexOf('_')));if(this._.tabBarMode)
{this._.tabBarMode=false;this._.currentFocusIndex=-1;changeFocus(true);}
evt.data.preventDefault();}},this);var buttonsHtml=[],buttons=CKEDITOR.dialog._.uiElementBuilders.hbox.build(this,{type:'hbox',className:'cke_dialog_footer_buttons',widths:[],children:definition.buttons},buttonsHtml).getChild();this.parts.footer.setHtml(buttonsHtml.join(''));for(i=0;i<buttons.length;i++)
this._.buttons[buttons[i].id]=buttons[i];};function Focusable(dialog,element,index)
{this.element=element;this.focusIndex=index;this.tabIndex=0;this.isFocusable=function()
{return!element.getAttribute('disabled')&&element.isVisible();};this.focus=function()
{dialog._.currentFocusIndex=this.focusIndex;this.element.focus();};element.on('keydown',function(e)
{if(e.data.getKeystroke()in{32:1,13:1})
this.fire('click');});element.on('focus',function()
{this.fire('mouseover');});element.on('blur',function()
{this.fire('mouseout');});}
CKEDITOR.dialog.prototype={destroy:function()
{this.hide();this._.element.remove();},resize:(function()
{return function(width,height)
{if(this._.contentSize&&this._.contentSize.width==width&&this._.contentSize.height==height)
return;CKEDITOR.dialog.fire('resize',{dialog:this,skin:this._.editor.skinName,width:width,height:height},this._.editor);this.fire('resize',{skin:this._.editor.skinName,width:width,height:height},this._.editor);if(this._.editor.lang.dir=='rtl'&&this._.position)
this._.position.x=CKEDITOR.document.getWindow().getViewPaneSize().width-
this._.contentSize.width-parseInt(this._.element.getFirst().getStyle('right'),10);this._.contentSize={width:width,height:height};};})(),getSize:function()
{var element=this._.element.getFirst();return{width:element.$.offsetWidth||0,height:element.$.offsetHeight||0};},move:(function()
{var isFixed;return function(x,y,save)
{var element=this._.element.getFirst(),rtl=this._.editor.lang.dir=='rtl';if(isFixed===undefined)
isFixed=element.getComputedStyle('position')=='fixed';if(isFixed&&this._.position&&this._.position.x==x&&this._.position.y==y)
return;this._.position={x:x,y:y};if(!isFixed)
{var scrollPosition=CKEDITOR.document.getWindow().getScrollPosition();x+=scrollPosition.x;y+=scrollPosition.y;}
if(rtl)
{var dialogSize=this.getSize(),viewPaneSize=CKEDITOR.document.getWindow().getViewPaneSize();x=viewPaneSize.width-dialogSize.width-x;}
var styles={'top':(y>0?y:0)+'px'};styles[rtl?'right':'left']=(x>0?x:0)+'px';element.setStyles(styles);save&&(this._.moved=1);};})(),getPosition:function(){return CKEDITOR.tools.extend({},this._.position);},show:function()
{var element=this._.element;var definition=this.definition;if(!(element.getParent()&&element.getParent().equals(CKEDITOR.document.getBody())))
element.appendTo(CKEDITOR.document.getBody());else
element.setStyle('display','block');if(CKEDITOR.env.gecko&&CKEDITOR.env.version<10900)
{var dialogElement=this.parts.dialog;dialogElement.setStyle('position','absolute');setTimeout(function()
{dialogElement.setStyle('position','fixed');},0);}
this.resize(this._.contentSize&&this._.contentSize.width||definition.width||definition.minWidth,this._.contentSize&&this._.contentSize.height||definition.height||definition.minHeight);this.reset();this.selectPage(this.definition.contents[0].id);if(CKEDITOR.dialog._.currentZIndex===null)
CKEDITOR.dialog._.currentZIndex=this._.editor.config.baseFloatZIndex;this._.element.getFirst().setStyle('z-index',CKEDITOR.dialog._.currentZIndex+=10);if(CKEDITOR.dialog._.currentTop===null)
{CKEDITOR.dialog._.currentTop=this;this._.parentDialog=null;showCover(this._.editor);element.on('keydown',accessKeyDownHandler);element.on(CKEDITOR.env.opera?'keypress':'keyup',accessKeyUpHandler);for(var event in{keyup:1,keydown:1,keypress:1})
element.on(event,preventKeyBubbling);}
else
{this._.parentDialog=CKEDITOR.dialog._.currentTop;var parentElement=this._.parentDialog.getElement().getFirst();parentElement.$.style.zIndex-=Math.floor(this._.editor.config.baseFloatZIndex/2);CKEDITOR.dialog._.currentTop=this;}
registerAccessKey(this,this,'\x1b',null,function()
{this.fireOnce('close',{esc:true});this.getButton('cancel')&&this.getButton('cancel').click();});this._.hasFocus=false;CKEDITOR.tools.setTimeout(function()
{this.layout();this.parts.dialog.setStyle('visibility','');this.fireOnce('load',{});CKEDITOR.ui.fire('ready',this);this.fire('show',{});this._.editor.fire('dialogShow',this);this.foreach(function(contentObj){contentObj.setInitValue&&contentObj.setInitValue();});},100,this);},layout:function()
{var viewSize=CKEDITOR.document.getWindow().getViewPaneSize(),dialogSize=this.getSize();this.move(this._.moved?this._.position.x:(viewSize.width-dialogSize.width)/2,this._.moved?this._.position.y:(viewSize.height-dialogSize.height)/2);},foreach:function(fn)
{for(var i in this._.contents)
{for(var j in this._.contents[i])
fn.call(this,this._.contents[i][j]);}
return this;},reset:(function()
{var fn=function(widget){if(widget.reset)widget.reset(1);};return function(){this.foreach(fn);return this;};})(),setupContent:function()
{var args=arguments;this.foreach(function(widget)
{if(widget.setup)
widget.setup.apply(widget,args);});},commitContent:function()
{var args=arguments;this.foreach(function(widget)
{if(CKEDITOR.env.ie&&this._.currentFocusIndex==widget.focusIndex)
widget.getInputElement().$.blur();if(widget.commit)
widget.commit.apply(widget,args);});},hide:function()
{if(!this.parts.dialog.isVisible())
return;this.fire('hide',{});this._.editor.fire('dialogHide',this);var element=this._.element;element.setStyle('display','none');this.parts.dialog.setStyle('visibility','hidden');unregisterAccessKey(this);while(CKEDITOR.dialog._.currentTop!=this)
CKEDITOR.dialog._.currentTop.hide();if(!this._.parentDialog)
hideCover();else
{var parentElement=this._.parentDialog.getElement().getFirst();parentElement.setStyle('z-index',parseInt(parentElement.$.style.zIndex,10)+Math.floor(this._.editor.config.baseFloatZIndex/2));}
CKEDITOR.dialog._.currentTop=this._.parentDialog;if(!this._.parentDialog)
{CKEDITOR.dialog._.currentZIndex=null;element.removeListener('keydown',accessKeyDownHandler);element.removeListener(CKEDITOR.env.opera?'keypress':'keyup',accessKeyUpHandler);for(var event in{keyup:1,keydown:1,keypress:1})
element.removeListener(event,preventKeyBubbling);var editor=this._.editor;editor.focus();if(editor.mode=='wysiwyg'&&CKEDITOR.env.ie)
{var selection=editor.getSelection();selection&&selection.unlock(true);}}
else
CKEDITOR.dialog._.currentZIndex-=10;delete this._.parentDialog;this.foreach(function(contentObj){contentObj.resetInitValue&&contentObj.resetInitValue();});},addPage:function(contents)
{var pageHtml=[],titleHtml=contents.label?' title="'+CKEDITOR.tools.htmlEncode(contents.label)+'"':'',elements=contents.elements,vbox=CKEDITOR.dialog._.uiElementBuilders.vbox.build(this,{type:'vbox',className:'cke_dialog_page_contents',children:contents.elements,expand:!!contents.expand,padding:contents.padding,style:contents.style||'width: 100%;height:100%'},pageHtml);var page=CKEDITOR.dom.element.createFromHtml(pageHtml.join(''));page.setAttribute('role','tabpanel');var env=CKEDITOR.env;var tabId='cke_'+contents.id+'_'+CKEDITOR.tools.getNextNumber(),tab=CKEDITOR.dom.element.createFromHtml(['<a class="cke_dialog_tab"',(this._.pageCount>0?' cke_last':'cke_first'),titleHtml,(!!contents.hidden?' style="display:none"':''),' id="',tabId,'"',env.gecko&&env.version>=10900&&!env.hc?'':' href="javascript:void(0)"',' tabIndex="-1"',' hidefocus="true"',' role="tab">',contents.label,'<img class="chevron" src="'+window.wgBlankImgUrl+'" />','</a>'].join(''));page.setAttribute('aria-labelledby',tabId);this._.tabs[contents.id]=[tab,page];this._.tabIdList.push(contents.id);!contents.hidden&&this._.pageCount++;this._.lastTab=tab;this.updateStyle();var contentMap=this._.contents[contents.id]={},cursor,children=vbox.getChild();while((cursor=children.shift()))
{contentMap[cursor.id]=cursor;if(typeof(cursor.getChild)=='function')
children.push.apply(children,cursor.getChild());}
page.setAttribute('name',contents.id);page.appendTo(this.parts.contents);tab.unselectable();this.parts.tabs.append(tab);if(contents.accessKey)
{registerAccessKey(this,this,'CTRL+'+contents.accessKey,tabAccessKeyDown,tabAccessKeyUp);this._.accessKeyMap['CTRL+'+contents.accessKey]=contents.id;}},selectPage:function(id)
{if(this._.currentTabId==id)
return;if(this.fire('selectPage',{page:id,currentPage:this._.currentTabId})===true)
return;for(var i in this._.tabs)
{var tab=this._.tabs[i][0],page=this._.tabs[i][1];if(i!=id)
{tab.removeClass('cke_dialog_tab_selected');page.hide();}
page.setAttribute('aria-hidden',i!=id);}
var selected=this._.tabs[id];selected[0].addClass('cke_dialog_tab_selected');if(CKEDITOR.env.ie6Compat||CKEDITOR.env.ie7Compat)
{clearOrRecoverTextInputValue(selected[1]);selected[1].show();setTimeout(function()
{clearOrRecoverTextInputValue(selected[1],1);},0);}
else
selected[1].show();this._.currentTabId=id;this._.currentTabIndex=CKEDITOR.tools.indexOf(this._.tabIdList,id);},updateStyle:function()
{this.parts.dialog[(this._.pageCount===1?'add':'remove')+'Class']('cke_single_page');},hidePage:function(id)
{var tab=this._.tabs[id]&&this._.tabs[id][0];if(!tab||this._.pageCount==1||!tab.isVisible())
return;else if(id==this._.currentTabId)
this.selectPage(getPreviousVisibleTab.call(this));tab.hide();this._.pageCount--;this.updateStyle();},showPage:function(id)
{var tab=this._.tabs[id]&&this._.tabs[id][0];if(!tab)
return;tab.show();this._.pageCount++;this.updateStyle();},getElement:function()
{return this._.element;},getName:function()
{return this._.name;},getContentElement:function(pageId,elementId)
{var page=this._.contents[pageId];return page&&page[elementId];},getValueOf:function(pageId,elementId)
{return this.getContentElement(pageId,elementId).getValue();},setValueOf:function(pageId,elementId,value)
{return this.getContentElement(pageId,elementId).setValue(value);},getButton:function(id)
{return this._.buttons[id];},click:function(id)
{return this._.buttons[id].click();},disableButton:function(id)
{return this._.buttons[id].disable();},enableButton:function(id)
{return this._.buttons[id].enable();},getPageCount:function()
{return this._.pageCount;},getParentEditor:function()
{return this._.editor;},getSelectedElement:function()
{return this.getParentEditor().getSelection().getSelectedElement();},addFocusable:function(element,index){if(typeof index=='undefined')
{index=this._.focusList.length;this._.focusList.push(new Focusable(this,element,index));}
else
{this._.focusList.splice(index,0,new Focusable(this,element,index));for(var i=index+1;i<this._.focusList.length;i++)
this._.focusList[i].focusIndex++;}}};CKEDITOR.tools.extend(CKEDITOR.dialog,{add:function(name,dialogDefinition)
{if(!this._.dialogDefinitions[name]||typeof dialogDefinition=='function')
this._.dialogDefinitions[name]=dialogDefinition;},exists:function(name)
{return!!this._.dialogDefinitions[name];},getCurrent:function()
{return CKEDITOR.dialog._.currentTop;},okButton:(function()
{var retval=function(editor,override)
{override=override||{};return CKEDITOR.tools.extend({id:'ok',type:'button',label:editor.lang.common.ok,'class':'cke_dialog_ui_button_ok',onClick:function(evt)
{var dialog=evt.data.dialog;if(dialog.fire('ok',{hide:true}).hide!==false)
dialog.hide();}},override,true);};retval.type='button';retval.override=function(override)
{return CKEDITOR.tools.extend(function(editor){return retval(editor,override);},{type:'button'},true);};return retval;})(),cancelButton:(function()
{var retval=function(editor,override)
{override=override||{};return CKEDITOR.tools.extend({id:'cancel',type:'button',label:editor.lang.common.cancel,'class':'cke_dialog_ui_button_cancel',onClick:function(evt)
{var dialog=evt.data.dialog;dialog.fireOnce('cancelClicked');if(dialog.fire('cancel',{hide:true}).hide!==false)
dialog.hide();}},override,true);};retval.type='button';retval.override=function(override)
{return CKEDITOR.tools.extend(function(editor){return retval(editor,override);},{type:'button'},true);};return retval;})(),addUIElement:function(typeName,builder)
{this._.uiElementBuilders[typeName]=builder;}});CKEDITOR.dialog._={uiElementBuilders:{},dialogDefinitions:{},currentTop:null,currentZIndex:null};CKEDITOR.event.implementOn(CKEDITOR.dialog);CKEDITOR.event.implementOn(CKEDITOR.dialog.prototype,true);var defaultDialogDefinition={resizable:CKEDITOR.DIALOG_RESIZE_NONE,minWidth:600,minHeight:400,buttons:[CKEDITOR.dialog.okButton]};var getById=function(array,id,recurse)
{for(var i=0,item;(item=array[i]);i++)
{if(item.id==id)
return item;if(recurse&&item[recurse])
{var retval=getById(item[recurse],id,recurse);if(retval)
return retval;}}
return null;};var addById=function(array,newItem,nextSiblingId,recurse,nullIfNotFound)
{if(nextSiblingId)
{for(var i=0,item;(item=array[i]);i++)
{if(item.id==nextSiblingId)
{array.splice(i,0,newItem);return newItem;}
if(recurse&&item[recurse])
{var retval=addById(item[recurse],newItem,nextSiblingId,recurse,true);if(retval)
return retval;}}
if(nullIfNotFound)
return null;}
array.push(newItem);return newItem;};var removeById=function(array,id,recurse)
{for(var i=0,item;(item=array[i]);i++)
{if(item.id==id)
return array.splice(i,1);if(recurse&&item[recurse])
{var retval=removeById(item[recurse],id,recurse);if(retval)
return retval;}}
return null;};var definitionObject=function(dialog,dialogDefinition)
{this.dialog=dialog;var contents=dialogDefinition.contents;for(var i=0,content;(content=contents[i]);i++)
contents[i]=content&&new contentObject(dialog,content);CKEDITOR.tools.extend(this,dialogDefinition);};definitionObject.prototype={getContents:function(id)
{return getById(this.contents,id);},getButton:function(id)
{return getById(this.buttons,id);},addContents:function(contentDefinition,nextSiblingId)
{return addById(this.contents,contentDefinition,nextSiblingId);},addButton:function(buttonDefinition,nextSiblingId)
{return addById(this.buttons,buttonDefinition,nextSiblingId);},removeContents:function(id)
{removeById(this.contents,id);},removeButton:function(id)
{removeById(this.buttons,id);}};function contentObject(dialog,contentDefinition)
{this._={dialog:dialog};CKEDITOR.tools.extend(this,contentDefinition);}
contentObject.prototype={get:function(id)
{return getById(this.elements,id,'children');},add:function(elementDefinition,nextSiblingId)
{return addById(this.elements,elementDefinition,nextSiblingId,'children');},remove:function(id)
{removeById(this.elements,id,'children');}};function initDragAndDrop(dialog)
{var lastCoords=null,abstractDialogCoords=null,element=dialog.getElement().getFirst(),editor=dialog.getParentEditor(),magnetDistance=editor.config.dialog_magnetDistance,margins=editor.skin.margins||[0,0,0,0];if(typeof magnetDistance=='undefined')
magnetDistance=20;function mouseMoveHandler(evt)
{var dialogSize=dialog.getSize(),viewPaneSize=CKEDITOR.document.getWindow().getViewPaneSize(),x=evt.data.$.screenX,y=evt.data.$.screenY,dx=x-lastCoords.x,dy=y-lastCoords.y,realX,realY;lastCoords={x:x,y:y};abstractDialogCoords.x+=dx;abstractDialogCoords.y+=dy;if(abstractDialogCoords.x+margins[3]<magnetDistance)
realX=-margins[3];else if(abstractDialogCoords.x-margins[1]>viewPaneSize.width-dialogSize.width-magnetDistance)
realX=viewPaneSize.width-dialogSize.width+(editor.lang.dir=='rtl'?0:margins[1]);else
realX=abstractDialogCoords.x;if(abstractDialogCoords.y+margins[0]<magnetDistance)
realY=-margins[0];else if(abstractDialogCoords.y-margins[2]>viewPaneSize.height-dialogSize.height-magnetDistance)
realY=viewPaneSize.height-dialogSize.height+margins[2];else
realY=abstractDialogCoords.y;dialog.move(realX,realY,1);evt.data.preventDefault();}
function mouseUpHandler(evt)
{CKEDITOR.document.removeListener('mousemove',mouseMoveHandler);CKEDITOR.document.removeListener('mouseup',mouseUpHandler);if(CKEDITOR.env.ie6Compat)
{var coverDoc=currentCover.getChild(0).getFrameDocument();coverDoc.removeListener('mousemove',mouseMoveHandler);coverDoc.removeListener('mouseup',mouseUpHandler);}}
dialog.parts.title.on('mousedown',function(evt)
{lastCoords={x:evt.data.$.screenX,y:evt.data.$.screenY};CKEDITOR.document.on('mousemove',mouseMoveHandler);CKEDITOR.document.on('mouseup',mouseUpHandler);abstractDialogCoords=dialog.getPosition();if(CKEDITOR.env.ie6Compat)
{var coverDoc=currentCover.getChild(0).getFrameDocument();coverDoc.on('mousemove',mouseMoveHandler);coverDoc.on('mouseup',mouseUpHandler);}
evt.data.preventDefault();},dialog);}
function initResizeHandles(dialog)
{var def=dialog.definition,resizable=def.resizable;if(resizable==CKEDITOR.DIALOG_RESIZE_NONE)
return;var editor=dialog.getParentEditor();var wrapperWidth,wrapperHeight,viewSize,origin,startSize,dialogCover;var mouseDownFn=CKEDITOR.tools.addFunction(function($event)
{startSize=dialog.getSize();var content=dialog.parts.contents,iframeDialog=content.$.getElementsByTagName('iframe').length;if(iframeDialog)
{dialogCover=CKEDITOR.dom.element.createFromHtml('<div class="cke_dialog_resize_cover" style="height: 100%; position: absolute; width: 100%;"></div>');content.append(dialogCover);}
wrapperHeight=startSize.height-dialog.parts.contents.getSize('height',!(CKEDITOR.env.gecko||CKEDITOR.env.opera||CKEDITOR.env.ie&&CKEDITOR.env.quirks));wrapperWidth=startSize.width-dialog.parts.contents.getSize('width',1);origin={x:$event.screenX,y:$event.screenY};viewSize=CKEDITOR.document.getWindow().getViewPaneSize();CKEDITOR.document.on('mousemove',mouseMoveHandler);CKEDITOR.document.on('mouseup',mouseUpHandler);if(CKEDITOR.env.ie6Compat)
{var coverDoc=currentCover.getChild(0).getFrameDocument();coverDoc.on('mousemove',mouseMoveHandler);coverDoc.on('mouseup',mouseUpHandler);}
$event.preventDefault&&$event.preventDefault();});dialog.on('load',function()
{var direction='';if(resizable==CKEDITOR.DIALOG_RESIZE_WIDTH)
direction=' cke_resizer_horizontal';else if(resizable==CKEDITOR.DIALOG_RESIZE_HEIGHT)
direction=' cke_resizer_vertical';var resizer=CKEDITOR.dom.element.createFromHtml('<div'+' class="cke_resizer'+direction+' cke_resizer_'+editor.lang.dir+'"'+' title="'+CKEDITOR.tools.htmlEncode(editor.lang.resize)+'"'+' onmousedown="CKEDITOR.tools.callFunction('+mouseDownFn+', event )"></div>');dialog.parts.footer.append(resizer,1);});editor.on('destroy',function(){CKEDITOR.tools.removeFunction(mouseDownFn);});function mouseMoveHandler(evt)
{var rtl=editor.lang.dir=='rtl',dx=(evt.data.$.screenX-origin.x)*(rtl?-1:1),dy=evt.data.$.screenY-origin.y,width=startSize.width,height=startSize.height,internalWidth=width+dx*(dialog._.moved?1:2),internalHeight=height+dy*(dialog._.moved?1:2),element=dialog._.element.getFirst(),right=rtl&&element.getComputedStyle('right'),position=dialog.getPosition();if(position.y+internalHeight>viewSize.height)
internalHeight=viewSize.height-position.y;if((rtl?right:position.x)+internalWidth>viewSize.width)
internalWidth=viewSize.width-(rtl?right:position.x);if((resizable==CKEDITOR.DIALOG_RESIZE_WIDTH||resizable==CKEDITOR.DIALOG_RESIZE_BOTH))
width=Math.max(def.minWidth||0,internalWidth-wrapperWidth);if(resizable==CKEDITOR.DIALOG_RESIZE_HEIGHT||resizable==CKEDITOR.DIALOG_RESIZE_BOTH)
height=Math.max(def.minHeight||0,internalHeight-wrapperHeight);dialog.resize(width,height);if(!dialog._.moved)
dialog.layout();evt.data.preventDefault();}
function mouseUpHandler()
{CKEDITOR.document.removeListener('mouseup',mouseUpHandler);CKEDITOR.document.removeListener('mousemove',mouseMoveHandler);if(dialogCover)
{dialogCover.remove();dialogCover=null;}
if(CKEDITOR.env.ie6Compat)
{var coverDoc=currentCover.getChild(0).getFrameDocument();coverDoc.removeListener('mouseup',mouseUpHandler);coverDoc.removeListener('mousemove',mouseMoveHandler);}}}
var resizeCover;var covers={},currentCover;function cancelEvent(ev)
{ev.data.preventDefault(1);}
function showCover(editor)
{var win=CKEDITOR.document.getWindow();var config=editor.config,backgroundColorStyle=config.dialog_backgroundCoverColor||'white',backgroundCoverOpacity=config.dialog_backgroundCoverOpacity,baseFloatZIndex=config.baseFloatZIndex,coverKey=CKEDITOR.tools.genKey(backgroundColorStyle,backgroundCoverOpacity,baseFloatZIndex),coverElement=covers[coverKey];if(!coverElement)
{var html=['<div tabIndex="-1" style="position: ',(CKEDITOR.env.ie6Compat?'absolute':'fixed'),'; z-index: ',baseFloatZIndex,'; top: 0px; left: 0px; ',(!CKEDITOR.env.ie6Compat?'background-color: '+backgroundColorStyle:''),'" class="cke_dialog_background_cover">'];if(CKEDITOR.env.ie6Compat)
{var isCustomDomain=CKEDITOR.env.isCustomDomain(),iframeHtml='<html><body style=\\\'background-color:'+backgroundColorStyle+';\\\'></body></html>';html.push('<iframe'+' hidefocus="true"'+' frameborder="0"'+' id="cke_dialog_background_iframe"'+' src="javascript:');html.push('void((function(){'+'document.open();'+
(isCustomDomain?'document.domain=\''+document.domain+'\';':'')+'document.write( \''+iframeHtml+'\' );'+'document.close();'+'})())');html.push('"'+' style="'+'position:absolute;'+'left:0;'+'top:0;'+'width:100%;'+'height: 100%;'+'progid:DXImageTransform.Microsoft.Alpha(opacity=0)">'+'</iframe>');}
html.push('</div>');coverElement=CKEDITOR.dom.element.createFromHtml(html.join(''));coverElement.setOpacity(backgroundCoverOpacity!=undefined?backgroundCoverOpacity:0.5);coverElement.on('keydown',cancelEvent);coverElement.on('keypress',cancelEvent);coverElement.on('keyup',cancelEvent);coverElement.appendTo(CKEDITOR.document.getBody());covers[coverKey]=coverElement;}
else
coverElement.show();currentCover=coverElement;var resizeFunc=function()
{var size=win.getViewPaneSize();coverElement.setStyles({width:size.width+'px',height:size.height+'px'});};var scrollFunc=function()
{var pos=win.getScrollPosition(),cursor=CKEDITOR.dialog._.currentTop;coverElement.setStyles({left:pos.x+'px',top:pos.y+'px'});if(cursor)
{do
{var dialogPos=cursor.getPosition();cursor.move(dialogPos.x,dialogPos.y);}while((cursor=cursor._.parentDialog));}};resizeCover=resizeFunc;win.on('resize',resizeFunc);resizeFunc();if(!(CKEDITOR.env.mac&&CKEDITOR.env.webkit))
coverElement.focus();if(CKEDITOR.env.ie6Compat)
{var myScrollHandler=function()
{scrollFunc();arguments.callee.prevScrollHandler.apply(this,arguments);};win.$.setTimeout(function()
{myScrollHandler.prevScrollHandler=window.onscroll||function(){};window.onscroll=myScrollHandler;},0);scrollFunc();}}
function hideCover()
{if(!currentCover)
return;var win=CKEDITOR.document.getWindow();currentCover.hide();win.removeListener('resize',resizeCover);if(CKEDITOR.env.ie6Compat)
{win.$.setTimeout(function()
{var prevScrollHandler=window.onscroll&&window.onscroll.prevScrollHandler;window.onscroll=prevScrollHandler||null;},0);}
resizeCover=null;}
function removeCovers()
{for(var coverId in covers)
covers[coverId].remove();covers={};}
var accessKeyProcessors={};var accessKeyDownHandler=function(evt)
{var ctrl=evt.data.$.ctrlKey||evt.data.$.metaKey,alt=evt.data.$.altKey,shift=evt.data.$.shiftKey,key=String.fromCharCode(evt.data.$.keyCode),keyProcessor=accessKeyProcessors[(ctrl?'CTRL+':'')+(alt?'ALT+':'')+(shift?'SHIFT+':'')+key];if(!keyProcessor||!keyProcessor.length)
return;keyProcessor=keyProcessor[keyProcessor.length-1];keyProcessor.keydown&&keyProcessor.keydown.call(keyProcessor.uiElement,keyProcessor.dialog,keyProcessor.key);evt.data.preventDefault();};var accessKeyUpHandler=function(evt)
{var ctrl=evt.data.$.ctrlKey||evt.data.$.metaKey,alt=evt.data.$.altKey,shift=evt.data.$.shiftKey,key=String.fromCharCode(evt.data.$.keyCode),keyProcessor=accessKeyProcessors[(ctrl?'CTRL+':'')+(alt?'ALT+':'')+(shift?'SHIFT+':'')+key];if(!keyProcessor||!keyProcessor.length)
return;keyProcessor=keyProcessor[keyProcessor.length-1];if(keyProcessor.keyup)
{keyProcessor.keyup.call(keyProcessor.uiElement,keyProcessor.dialog,keyProcessor.key);evt.data.preventDefault();}};var registerAccessKey=function(uiElement,dialog,key,downFunc,upFunc)
{var procList=accessKeyProcessors[key]||(accessKeyProcessors[key]=[]);procList.push({uiElement:uiElement,dialog:dialog,key:key,keyup:upFunc||uiElement.accessKeyUp,keydown:downFunc||uiElement.accessKeyDown});};var unregisterAccessKey=function(obj)
{for(var i in accessKeyProcessors)
{var list=accessKeyProcessors[i];for(var j=list.length-1;j>=0;j--)
{if(list[j].dialog==obj||list[j].uiElement==obj)
list.splice(j,1);}
if(list.length===0)
delete accessKeyProcessors[i];}};var tabAccessKeyUp=function(dialog,key)
{if(dialog._.accessKeyMap[key])
dialog.selectPage(dialog._.accessKeyMap[key]);};var tabAccessKeyDown=function(dialog,key)
{};var preventKeyBubblingKeys={27:1,13:1};var preventKeyBubbling=function(e)
{if(e.data.getKeystroke()in preventKeyBubblingKeys)
e.data.stopPropagation();};(function()
{CKEDITOR.ui.dialog={uiElement:function(dialog,elementDefinition,htmlList,nodeNameArg,stylesArg,attributesArg,contentsArg)
{if(arguments.length<4)
return;var nodeName=(nodeNameArg.call?nodeNameArg(elementDefinition):nodeNameArg)||'div',html=['<',nodeName,' '],styles=(stylesArg&&stylesArg.call?stylesArg(elementDefinition):stylesArg)||{},attributes=(attributesArg&&attributesArg.call?attributesArg(elementDefinition):attributesArg)||{},innerHTML=(contentsArg&&contentsArg.call?contentsArg.call(this,dialog,elementDefinition):contentsArg)||'',domId=this.domId=attributes.id||CKEDITOR.tools.getNextId()+'_uiElement',id=this.id=elementDefinition.id,i;attributes.id=domId;var classes={};if(elementDefinition.type)
classes['cke_dialog_ui_'+elementDefinition.type]=1;if(elementDefinition.className)
classes[elementDefinition.className]=1;if(elementDefinition.disabled)
classes['cke_disabled']=1;var attributeClasses=(attributes['class']&&attributes['class'].split)?attributes['class'].split(' '):[];for(i=0;i<attributeClasses.length;i++)
{if(attributeClasses[i])
classes[attributeClasses[i]]=1;}
var finalClasses=[];for(i in classes)
finalClasses.push(i);attributes['class']=finalClasses.join(' ');if(elementDefinition.title)
attributes.title=elementDefinition.title;var styleStr=(elementDefinition.style||'').split(';');if(elementDefinition.align)
{var align=elementDefinition.align;styles['margin-left']=align=='left'?0:'auto';styles['margin-right']=align=='right'?0:'auto';}
for(i in styles)
styleStr.push(i+':'+styles[i]);if(elementDefinition.hidden)
styleStr.push('display:none');for(i=styleStr.length-1;i>=0;i--)
{if(styleStr[i]==='')
styleStr.splice(i,1);}
if(styleStr.length>0)
attributes.style=(attributes.style?(attributes.style+'; '):'')+styleStr.join('; ');for(i in attributes)
html.push(i+'="'+CKEDITOR.tools.htmlEncode(attributes[i])+'" ');html.push('>',innerHTML,'</',nodeName,'>');htmlList.push(html.join(''));(this._||(this._={})).dialog=dialog;if(typeof(elementDefinition.isChanged)=='boolean')
this.isChanged=function(){return elementDefinition.isChanged;};if(typeof(elementDefinition.isChanged)=='function')
this.isChanged=elementDefinition.isChanged;if(typeof(elementDefinition.setValue)=='function')
{this.setValue=CKEDITOR.tools.override(this.setValue,function(org)
{return function(val){org.call(this,elementDefinition.setValue.call(this,val));};});}
if(typeof(elementDefinition.getValue)=='function')
{this.getValue=CKEDITOR.tools.override(this.getValue,function(org)
{return function(){return elementDefinition.getValue.call(this,org.call(this));};});}
CKEDITOR.event.implementOn(this);this.registerEvents(elementDefinition);if(this.accessKeyUp&&this.accessKeyDown&&elementDefinition.accessKey)
registerAccessKey(this,dialog,'CTRL+'+elementDefinition.accessKey);var me=this;dialog.on('load',function()
{if(me.getInputElement())
{me.getInputElement().on('focus',function()
{dialog._.tabBarMode=false;dialog._.hasFocus=true;me.fire('focus');},me);}});if(this.keyboardFocusable)
{this.tabIndex=elementDefinition.tabIndex||0;this.focusIndex=dialog._.focusList.push(this)-1;this.on('focus',function()
{dialog._.currentFocusIndex=me.focusIndex;});}
CKEDITOR.tools.extend(this,elementDefinition);},hbox:function(dialog,childObjList,childHtmlList,htmlList,elementDefinition)
{if(arguments.length<4)
return;this._||(this._={});var children=this._.children=childObjList,widths=elementDefinition&&elementDefinition.widths||null,height=elementDefinition&&elementDefinition.height||null,styles={},i;var innerHTML=function()
{var html=['<tbody><tr class="cke_dialog_ui_hbox">'];for(i=0;i<childHtmlList.length;i++)
{var className='cke_dialog_ui_hbox_child',styles=[];if(i===0)
className='cke_dialog_ui_hbox_first';if(i==childHtmlList.length-1)
className='cke_dialog_ui_hbox_last';html.push('<td class="',className,'" role="presentation" ');if(widths)
{if(widths[i])
styles.push('width:'+cssLength(widths[i]));}
else
styles.push('width:'+Math.floor(100/childHtmlList.length)+'%');if(height)
styles.push('height:'+cssLength(height));if(elementDefinition&&elementDefinition.padding!=undefined)
styles.push('padding:'+cssLength(elementDefinition.padding));if(CKEDITOR.env.ie&&CKEDITOR.env.quirks&&children[i].align)
styles.push('text-align:'+children[i].align);if(styles.length>0)
html.push('style="'+styles.join('; ')+'" ');html.push('>',childHtmlList[i],'</td>');}
html.push('</tr></tbody>');return html.join('');};var attribs={role:'presentation'};elementDefinition&&elementDefinition.align&&(attribs.align=elementDefinition.align);CKEDITOR.ui.dialog.uiElement.call(this,dialog,elementDefinition||{type:'hbox'},htmlList,'table',styles,attribs,innerHTML);},vbox:function(dialog,childObjList,childHtmlList,htmlList,elementDefinition)
{if(arguments.length<3)
return;this._||(this._={});var children=this._.children=childObjList,width=elementDefinition&&elementDefinition.width||null,heights=elementDefinition&&elementDefinition.heights||null;var innerHTML=function()
{var html=['<table role="presentation" cellspacing="0" border="0" '];html.push('style="');if(elementDefinition&&elementDefinition.expand)
html.push('height:100%;');html.push('width:'+cssLength(width||'100%'),';');html.push('"');html.push('align="',CKEDITOR.tools.htmlEncode((elementDefinition&&elementDefinition.align)||(dialog.getParentEditor().lang.dir=='ltr'?'left':'right')),'" ');html.push('><tbody>');for(var i=0;i<childHtmlList.length;i++)
{var styles=[];html.push('<tr><td role="presentation" ');if(width)
styles.push('width:'+cssLength(width||'100%'));if(heights)
styles.push('height:'+cssLength(heights[i]));else if(elementDefinition&&elementDefinition.expand)
styles.push('height:'+Math.floor(100/childHtmlList.length)+'%');if(elementDefinition&&elementDefinition.padding!=undefined)
styles.push('padding:'+cssLength(elementDefinition.padding));if(CKEDITOR.env.ie&&CKEDITOR.env.quirks&&children[i].align)
styles.push('text-align:'+children[i].align);if(styles.length>0)
html.push('style="',styles.join('; '),'" ');html.push(' class="cke_dialog_ui_vbox_child">',childHtmlList[i],'</td></tr>');}
html.push('</tbody></table>');return html.join('');};CKEDITOR.ui.dialog.uiElement.call(this,dialog,elementDefinition||{type:'vbox'},htmlList,'div',null,{role:'presentation'},innerHTML);}};})();CKEDITOR.ui.dialog.uiElement.prototype={getElement:function()
{return CKEDITOR.document.getById(this.domId);},getInputElement:function()
{return this.getElement();},getDialog:function()
{return this._.dialog;},setValue:function(value,noChangeEvent)
{this.getInputElement().setValue(value);!noChangeEvent&&this.fire('change',{value:value});return this;},getValue:function()
{return this.getInputElement().getValue();},isChanged:function()
{return false;},selectParentTab:function()
{var element=this.getInputElement(),cursor=element,tabId;while((cursor=cursor.getParent())&&cursor.$.className.search('cke_dialog_page_contents')==-1)
{}
if(!cursor)
return this;tabId=cursor.getAttribute('name');if(this._.dialog._.currentTabId!=tabId)
this._.dialog.selectPage(tabId);return this;},focus:function()
{this.selectParentTab().getInputElement().focus();return this;},registerEvents:function(definition)
{var regex=/^on([A-Z]\w+)/,match;var registerDomEvent=function(uiElement,dialog,eventName,func)
{dialog.on('load',function()
{uiElement.getInputElement().on(eventName,func,uiElement);});};for(var i in definition)
{if(!(match=i.match(regex)))
continue;if(this.eventProcessors[i])
this.eventProcessors[i].call(this,this._.dialog,definition[i]);else
registerDomEvent(this,this._.dialog,match[1].toLowerCase(),definition[i]);}
return this;},eventProcessors:{onLoad:function(dialog,func)
{dialog.on('load',func,this);},onShow:function(dialog,func)
{dialog.on('show',func,this);},onHide:function(dialog,func)
{dialog.on('hide',func,this);}},accessKeyDown:function(dialog,key)
{this.focus();},accessKeyUp:function(dialog,key)
{},disable:function()
{var element=this.getElement(),input=this.getInputElement();input.setAttribute('disabled','true');element.addClass('cke_disabled');},enable:function()
{var element=this.getElement(),input=this.getInputElement();input.removeAttribute('disabled');element.removeClass('cke_disabled');},isEnabled:function()
{return!this.getElement().hasClass('cke_disabled');},isVisible:function()
{return this.getInputElement().isVisible();},isFocusable:function()
{if(!this.isEnabled()||!this.isVisible())
return false;return true;}};CKEDITOR.ui.dialog.hbox.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.uiElement,{getChild:function(indices)
{if(arguments.length<1)
return this._.children.concat();if(!indices.splice)
indices=[indices];if(indices.length<2)
return this._.children[indices[0]];else
return(this._.children[indices[0]]&&this._.children[indices[0]].getChild)?this._.children[indices[0]].getChild(indices.slice(1,indices.length)):null;}},true);CKEDITOR.ui.dialog.vbox.prototype=new CKEDITOR.ui.dialog.hbox();(function()
{var commonBuilder={build:function(dialog,elementDefinition,output)
{var children=elementDefinition.children,child,childHtmlList=[],childObjList=[];for(var i=0;(i<children.length&&(child=children[i]));i++)
{var childHtml=[];childHtmlList.push(childHtml);childObjList.push(CKEDITOR.dialog._.uiElementBuilders[child.type].build(dialog,child,childHtml));}
return new CKEDITOR.ui.dialog[elementDefinition.type](dialog,childObjList,childHtmlList,output,elementDefinition);}};CKEDITOR.dialog.addUIElement('hbox',commonBuilder);CKEDITOR.dialog.addUIElement('vbox',commonBuilder);})();CKEDITOR.dialogCommand=function(dialogName)
{this.dialogName=dialogName;};CKEDITOR.dialogCommand.prototype={exec:function(editor)
{editor.openDialog(this.dialogName);},canUndo:false,editorFocus:CKEDITOR.env.ie||CKEDITOR.env.webkit};(function()
{var notEmptyRegex=/^([a]|[^a])+$/,integerRegex=/^\d*$/,numberRegex=/^\d*(?:\.\d+)?$/,htmlLengthRegex=/^(((\d*(\.\d+))|(\d*))(px|\%)?)?$/,cssLengthRegex=/^(((\d*(\.\d+))|(\d*))(px|em|ex|in|cm|mm|pt|pc|\%)?)?$/i;CKEDITOR.VALIDATE_OR=1;CKEDITOR.VALIDATE_AND=2;CKEDITOR.dialog.validate={functions:function()
{var args=arguments;return function()
{var value=this&&this.getValue?this.getValue():args[0];var msg=undefined,relation=CKEDITOR.VALIDATE_AND,functions=[],i;for(i=0;i<args.length;i++)
{if(typeof(args[i])=='function')
functions.push(args[i]);else
break;}
if(i<args.length&&typeof(args[i])=='string')
{msg=args[i];i++;}
if(i<args.length&&typeof(args[i])=='number')
relation=args[i];var passed=(relation==CKEDITOR.VALIDATE_AND?true:false);for(i=0;i<functions.length;i++)
{if(relation==CKEDITOR.VALIDATE_AND)
passed=passed&&functions[i](value);else
passed=passed||functions[i](value);}
if(!passed)
{if(msg!==undefined){var editor=this.getDialog()._.editor;RTE.tools.alert(editor.lang.errorPopupTitle,msg);}
if(this&&(this.select||this.focus))
(this.select||this.focus)();return false;}
return true;};},regex:function(regex,msg)
{return function()
{var value=this&&this.getValue?this.getValue():arguments[0];if(!regex.test(value))
{if(msg!==undefined){var editor=this.getDialog()._.editor;RTE.tools.alert(editor.lang.errorPopupTitle,msg);}
if(this&&(this.select||this.focus))
{if(this.select)
this.select();else
this.focus();}
return false;}
return true;};},notEmpty:function(msg)
{return this.regex(notEmptyRegex,msg);},integer:function(msg)
{return this.regex(integerRegex,msg);},'number':function(msg)
{return this.regex(numberRegex,msg);},'cssLength':function(msg)
{return this.functions(function(val){return cssLengthRegex.test(CKEDITOR.tools.trim(val));},msg);},'htmlLength':function(msg)
{return this.functions(function(val){return htmlLengthRegex.test(CKEDITOR.tools.trim(val));},msg);},equals:function(value,msg)
{return this.functions(function(val){return val==value;},msg);},notEqual:function(value,msg)
{return this.functions(function(val){return val!=value;},msg);}};CKEDITOR.on('instanceDestroyed',function(evt)
{if(CKEDITOR.tools.isEmpty(CKEDITOR.instances))
{var currentTopDialog;while((currentTopDialog=CKEDITOR.dialog._.currentTop))
currentTopDialog.hide();removeCovers();}
var dialogs=evt.editor._.storedDialogs;for(var name in dialogs)
dialogs[name].destroy();});})();CKEDITOR.tools.extend(CKEDITOR.editor.prototype,{openDialog:function(dialogName,callback)
{if(this.mode=='wysiwyg'&&CKEDITOR.env.ie)
{var selection=this.getSelection();selection&&selection.lock();}
var dialogDefinitions=CKEDITOR.dialog._.dialogDefinitions[dialogName],dialogSkin=this.skin.dialog;if(typeof dialogDefinitions=='function'&&dialogSkin._isLoaded)
{var storedDialogs=this._.storedDialogs||(this._.storedDialogs={});var dialog=storedDialogs[dialogName]||(storedDialogs[dialogName]=new CKEDITOR.dialog(this,dialogName));callback&&callback.call(dialog,dialog);dialog.show();return dialog;}
else if(dialogDefinitions=='failed')
{hideCover();throw new Error('[CKEDITOR.dialog.openDialog] Dialog "'+dialogName+'" failed when loading definition.');}
var me=this;function onDialogFileLoaded(success)
{var dialogDefinition=CKEDITOR.dialog._.dialogDefinitions[dialogName],skin=me.skin.dialog;if(!skin._isLoaded||loadDefinition&&typeof success=='undefined')
return;if(typeof dialogDefinition!='function')
CKEDITOR.dialog._.dialogDefinitions[dialogName]='failed';me.openDialog(dialogName,callback);}
if(typeof dialogDefinitions=='string')
{var loadDefinition=1;CKEDITOR.scriptLoader.load(CKEDITOR.getUrl(dialogDefinitions),onDialogFileLoaded,null,0,1);}
CKEDITOR.skins.load(this,'dialog',onDialogFileLoaded);return null;}});})();CKEDITOR.plugins.add('dialog',{requires:['dialogui']});;CKEDITOR.plugins.add('styles',{requires:['selection'],init:function(editor)
{editor.on('contentDom',function()
{editor.document.setCustomData('cke_includeReadonly',!editor.config.disableReadonlyStyling);});}});CKEDITOR.editor.prototype.attachStyleStateChange=function(style,callback)
{var styleStateChangeCallbacks=this._.styleStateChangeCallbacks;if(!styleStateChangeCallbacks)
{styleStateChangeCallbacks=this._.styleStateChangeCallbacks=[];this.on('selectionChange',function(ev)
{for(var i=0;i<styleStateChangeCallbacks.length;i++)
{var callback=styleStateChangeCallbacks[i];var currentState=callback.style.checkActive(ev.data.path)?CKEDITOR.TRISTATE_ON:CKEDITOR.TRISTATE_OFF;callback.fn.call(this,currentState);}});}
styleStateChangeCallbacks.push({style:style,fn:callback});};CKEDITOR.STYLE_BLOCK=1;CKEDITOR.STYLE_INLINE=2;CKEDITOR.STYLE_OBJECT=3;(function()
{var blockElements={address:1,div:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1,section:1,header:1,footer:1,nav:1,article:1,aside:1,figure:1,dialog:1,hgroup:1,time:1,meter:1,menu:1,command:1,keygen:1,output:1,progress:1,details:1,datagrid:1,datalist:1},objectElements={a:1,embed:1,hr:1,img:1,li:1,object:1,ol:1,table:1,td:1,tr:1,th:1,ul:1,dl:1,dt:1,dd:1,form:1,audio:1,video:1};var semicolonFixRegex=/\s*(?:;\s*|$)/,varRegex=/#\((.+?)\)/g;var notBookmark=CKEDITOR.dom.walker.bookmark(0,1),nonWhitespaces=CKEDITOR.dom.walker.whitespaces(1);CKEDITOR.style=function(styleDefinition,variablesValues)
{if(variablesValues)
{styleDefinition=CKEDITOR.tools.clone(styleDefinition);replaceVariables(styleDefinition.attributes,variablesValues);replaceVariables(styleDefinition.styles,variablesValues);}
var element=this.element=styleDefinition.element?(typeof styleDefinition.element=='string'?styleDefinition.element.toLowerCase():styleDefinition.element):'*';this.type=blockElements[element]?CKEDITOR.STYLE_BLOCK:objectElements[element]?CKEDITOR.STYLE_OBJECT:CKEDITOR.STYLE_INLINE;if(typeof this.element=='object')
this.type=CKEDITOR.STYLE_OBJECT;this._={definition:styleDefinition};};CKEDITOR.style.prototype={apply:function(document)
{applyStyle.call(this,document,false);},remove:function(document)
{applyStyle.call(this,document,true);},applyToRange:function(range)
{return(this.applyToRange=this.type==CKEDITOR.STYLE_INLINE?applyInlineStyle:this.type==CKEDITOR.STYLE_BLOCK?applyBlockStyle:this.type==CKEDITOR.STYLE_OBJECT?applyObjectStyle:null).call(this,range);},removeFromRange:function(range)
{return(this.removeFromRange=this.type==CKEDITOR.STYLE_INLINE?removeInlineStyle:this.type==CKEDITOR.STYLE_BLOCK?removeBlockStyle:this.type==CKEDITOR.STYLE_OBJECT?removeObjectStyle:null).call(this,range);},applyToObject:function(element)
{setupElement(element,this);},checkActive:function(elementPath)
{switch(this.type)
{case CKEDITOR.STYLE_BLOCK:return this.checkElementRemovable(elementPath.block||elementPath.blockLimit,true);case CKEDITOR.STYLE_OBJECT:case CKEDITOR.STYLE_INLINE:var elements=elementPath.elements;for(var i=0,element;i<elements.length;i++)
{element=elements[i];if(this.type==CKEDITOR.STYLE_INLINE&&(element==elementPath.block||element==elementPath.blockLimit))
continue;if(this.type==CKEDITOR.STYLE_OBJECT)
{var name=element.getName();if(!(typeof this.element=='string'?name==this.element:name in this.element))
continue;}
if(this.checkElementRemovable(element,true))
return true;}}
return false;},checkApplicable:function(elementPath)
{switch(this.type)
{case CKEDITOR.STYLE_INLINE:case CKEDITOR.STYLE_BLOCK:break;case CKEDITOR.STYLE_OBJECT:return elementPath.lastElement.getAscendant(this.element,true);}
return true;},checkElementRemovable:function(element,fullMatch)
{if(!element||element.isReadOnly())
return false;var def=this._.definition,attribs,name=element.getName();if(typeof this.element=='string'?name==this.element:name in this.element)
{if(!fullMatch&&!element.hasAttributes())
return true;attribs=getAttributesForComparison(def);if(attribs._length)
{for(var attName in attribs)
{if(attName=='_length')
continue;var elementAttr=element.getAttribute(attName)||'';if(attName=='style'?compareCssText(attribs[attName],normalizeCssText(elementAttr,false)):attribs[attName]==elementAttr)
{if(!fullMatch)
return true;}
else if(fullMatch)
return false;}
if(fullMatch)
return true;}
else
return true;}
var override=getOverrides(this)[element.getName()];if(override)
{if(!(attribs=override.attributes))
return true;for(var i=0;i<attribs.length;i++)
{attName=attribs[i][0];var actualAttrValue=element.getAttribute(attName);if(actualAttrValue)
{var attValue=attribs[i][1];if(attValue===null||(typeof attValue=='string'&&actualAttrValue==attValue)||attValue.test(actualAttrValue))
return true;}}}
return false;},buildPreview:function(label)
{var styleDefinition=this._.definition,html=[],elementName=styleDefinition.element;if(elementName=='bdo')
elementName='span';html=['<',elementName];var attribs=styleDefinition.attributes;if(attribs)
{for(var att in attribs)
{html.push(' ',att,'="',attribs[att],'"');}}
var cssStyle=CKEDITOR.style.getStyleText(styleDefinition);if(cssStyle)
html.push(' style="',cssStyle,'"');html.push('>',(label||styleDefinition.name),'</',elementName,'>');return html.join('');}};CKEDITOR.style.getStyleText=function(styleDefinition)
{var stylesDef=styleDefinition._ST;if(stylesDef)
return stylesDef;stylesDef=styleDefinition.styles;var stylesText=(styleDefinition.attributes&&styleDefinition.attributes['style'])||'',specialStylesText='';if(stylesText.length)
stylesText=stylesText.replace(semicolonFixRegex,';');for(var style in stylesDef)
{var styleVal=stylesDef[style],text=(style+':'+styleVal).replace(semicolonFixRegex,';');if(styleVal=='inherit')
specialStylesText+=text;else
stylesText+=text;}
if(stylesText.length)
stylesText=normalizeCssText(stylesText);stylesText+=specialStylesText;return(styleDefinition._ST=stylesText);};function getUnstylableParent(element)
{var unstylable,editable;while((element=element.getParent()))
{if(element.getName()=='body')
break;if(element.getAttribute('data-nostyle'))
unstylable=element;else if(!editable)
{var contentEditable=element.getAttribute('contentEditable');if(contentEditable=='false')
unstylable=element;else if(contentEditable=='true')
editable=1;}}
return unstylable;}
function applyInlineStyle(range)
{var document=range.document;if(range.collapsed)
{var collapsedElement=getElement(this,document);range.insertNode(collapsedElement);range.moveToPosition(collapsedElement,CKEDITOR.POSITION_BEFORE_END);return;}
var elementName=this.element;var def=this._.definition;var isUnknownElement;var includeReadonly=def.includeReadonly;if(includeReadonly==undefined)
includeReadonly=document.getCustomData('cke_includeReadonly');var dtd=CKEDITOR.dtd[elementName]||(isUnknownElement=true,CKEDITOR.dtd.span);range.enlarge(CKEDITOR.ENLARGE_ELEMENT,1);range.trim();var boundaryNodes=range.createBookmark(),firstNode=boundaryNodes.startNode,lastNode=boundaryNodes.endNode;var currentNode=firstNode;var styleRange;var firstUnstylable=getUnstylableParent(firstNode),lastUnstylable=getUnstylableParent(lastNode);if(firstUnstylable)
currentNode=firstUnstylable.getNextSourceNode(true);if(lastUnstylable)
lastNode=lastUnstylable;if(currentNode.getPosition(lastNode)==CKEDITOR.POSITION_FOLLOWING)
currentNode=0;while(currentNode)
{var applyStyle=false;if(currentNode.equals(lastNode))
{currentNode=null;applyStyle=true;}
else
{var nodeType=currentNode.type;var nodeName=nodeType==CKEDITOR.NODE_ELEMENT?currentNode.getName():null;var nodeIsReadonly=nodeName&&(currentNode.getAttribute('contentEditable')=='false');var nodeIsNoStyle=nodeName&&currentNode.getAttribute('data-nostyle');var nodeIsFormatablePlaceholder=nodeIsReadonly&&(currentNode.getAttribute('formateditable')=='true');if(nodeName&&currentNode.data('cke-bookmark'))
{currentNode=currentNode.getNextSourceNode(true);continue;}
if(!nodeName||(dtd[nodeName]&&!nodeIsNoStyle&&(!nodeIsReadonly||includeReadonly)&&(currentNode.getPosition(lastNode)|CKEDITOR.POSITION_PRECEDING|CKEDITOR.POSITION_IDENTICAL|CKEDITOR.POSITION_IS_CONTAINED)==(CKEDITOR.POSITION_PRECEDING+CKEDITOR.POSITION_IDENTICAL+CKEDITOR.POSITION_IS_CONTAINED)&&(!def.childRule||def.childRule(currentNode)))||nodeIsFormatablePlaceholder)
{var currentParent=currentNode.getParent();if(currentParent&&((currentParent.getDtd()||CKEDITOR.dtd.span)[elementName]||isUnknownElement)&&(!def.parentRule||def.parentRule(currentParent)))
{if(!styleRange&&(!nodeName||!CKEDITOR.dtd.$removeEmpty[nodeName]||(currentNode.getPosition(lastNode)|CKEDITOR.POSITION_PRECEDING|CKEDITOR.POSITION_IDENTICAL|CKEDITOR.POSITION_IS_CONTAINED)==(CKEDITOR.POSITION_PRECEDING+CKEDITOR.POSITION_IDENTICAL+CKEDITOR.POSITION_IS_CONTAINED)))
{styleRange=new CKEDITOR.dom.range(document);styleRange.setStartBefore(currentNode);}
if(nodeType==CKEDITOR.NODE_TEXT||nodeIsReadonly||(nodeType==CKEDITOR.NODE_ELEMENT&&!currentNode.getChildCount()))
{var includedNode=currentNode;var parentNode;while((applyStyle=!includedNode.getNext(notBookmark))&&(parentNode=includedNode.getParent(),dtd[parentNode.getName()])&&(parentNode.getPosition(firstNode)|CKEDITOR.POSITION_FOLLOWING|CKEDITOR.POSITION_IDENTICAL|CKEDITOR.POSITION_IS_CONTAINED)==(CKEDITOR.POSITION_FOLLOWING+CKEDITOR.POSITION_IDENTICAL+CKEDITOR.POSITION_IS_CONTAINED)&&(!def.childRule||def.childRule(parentNode)))
{includedNode=parentNode;}
styleRange.setEndAfter(includedNode);}}
else
applyStyle=true;}
else
applyStyle=true;currentNode=currentNode.getNextSourceNode(nodeIsNoStyle||nodeIsReadonly);}
if(applyStyle&&styleRange&&!styleRange.collapsed)
{styleRange.enlargeFormattables();var styleNode=getElement(this,document),styleHasAttrs=styleNode.hasAttributes();var parent=styleRange.getCommonAncestor();var removeList={styles:{},attrs:{},blockedStyles:{},blockedAttrs:{}};var attName,styleName,value;while(styleNode&&parent)
{if(parent.getName()==elementName)
{for(attName in def.attributes)
{if(removeList.blockedAttrs[attName]||!(value=parent.getAttribute(styleName)))
continue;if(styleNode.getAttribute(attName)==value)
removeList.attrs[attName]=1;else
removeList.blockedAttrs[attName]=1;}
for(styleName in def.styles)
{if(removeList.blockedStyles[styleName]||!(value=parent.getStyle(styleName)))
continue;if(styleNode.getStyle(styleName)==value)
removeList.styles[styleName]=1;else
removeList.blockedStyles[styleName]=1;}}
parent=parent.getParent();}
for(attName in removeList.attrs)
styleNode.removeAttribute(attName);for(styleName in removeList.styles)
styleNode.removeStyle(styleName);if(styleHasAttrs&&!styleNode.hasAttributes())
styleNode=null;if(styleNode)
{styleRange.extractContents().appendTo(styleNode);removeFromInsideElement(this,styleNode);styleRange.insertNode(styleNode);styleNode.mergeSiblings();if(!CKEDITOR.env.ie)
styleNode.$.normalize();}
else
{styleNode=new CKEDITOR.dom.element('span');styleRange.extractContents().appendTo(styleNode);styleRange.insertNode(styleNode);removeFromInsideElement(this,styleNode);styleNode.remove(true);}
styleRange=null;}}
range.moveToBookmark(boundaryNodes);range.shrink(CKEDITOR.SHRINK_TEXT);}
function removeInlineStyle(range)
{range.enlarge(CKEDITOR.ENLARGE_ELEMENT,1);var bookmark=range.createBookmark(),startNode=bookmark.startNode;if(range.collapsed)
{var startPath=new CKEDITOR.dom.elementPath(startNode.getParent()),boundaryElement;for(var i=0,element;i<startPath.elements.length&&(element=startPath.elements[i]);i++)
{if(element==startPath.block||element==startPath.blockLimit)
break;if(this.checkElementRemovable(element))
{var isStart;if(range.collapsed&&(range.checkBoundaryOfElement(element,CKEDITOR.END)||(isStart=range.checkBoundaryOfElement(element,CKEDITOR.START))))
{boundaryElement=element;boundaryElement.match=isStart?'start':'end';}
else
{element.mergeSiblings();if(element.getName()==this.element)
removeFromElement(this,element);else
removeOverrides(element,getOverrides(this)[element.getName()]);}}}
if(boundaryElement)
{var clonedElement=startNode;for(i=0;;i++)
{var newElement=startPath.elements[i];if(newElement.equals(boundaryElement))
break;else if(newElement.match)
continue;else
newElement=newElement.clone();newElement.append(clonedElement);clonedElement=newElement;}
clonedElement[boundaryElement.match=='start'?'insertBefore':'insertAfter'](boundaryElement);}}
else
{var endNode=bookmark.endNode,me=this;function breakNodes()
{var startPath=new CKEDITOR.dom.elementPath(startNode.getParent()),endPath=new CKEDITOR.dom.elementPath(endNode.getParent()),breakStart=null,breakEnd=null;for(var i=0;i<startPath.elements.length;i++)
{var element=startPath.elements[i];if(element==startPath.block||element==startPath.blockLimit)
break;if(me.checkElementRemovable(element))
breakStart=element;}
for(i=0;i<endPath.elements.length;i++)
{element=endPath.elements[i];if(element==endPath.block||element==endPath.blockLimit)
break;if(me.checkElementRemovable(element))
breakEnd=element;}
if(breakEnd)
endNode.breakParent(breakEnd);if(breakStart)
startNode.breakParent(breakStart);}
breakNodes();var currentNode=startNode.getNext();while(!currentNode.equals(endNode))
{var nextNode=currentNode.getNextSourceNode();if(currentNode.type==CKEDITOR.NODE_ELEMENT&&this.checkElementRemovable(currentNode))
{if(currentNode.getName()==this.element)
removeFromElement(this,currentNode);else
removeOverrides(currentNode,getOverrides(this)[currentNode.getName()]);if(nextNode.type==CKEDITOR.NODE_ELEMENT&&nextNode.contains(startNode))
{breakNodes();nextNode=startNode.getNext();}}
currentNode=nextNode;}}
range.moveToBookmark(bookmark);}
function applyObjectStyle(range)
{var root=range.getCommonAncestor(true,true),element=root.getAscendant(this.element,true);element&&!element.isReadOnly()&&setupElement(element,this);}
function removeObjectStyle(range)
{var root=range.getCommonAncestor(true,true),element=root.getAscendant(this.element,true);if(!element)
return;var style=this,def=style._.definition,attributes=def.attributes;var styles=CKEDITOR.style.getStyleText(def);if(attributes)
{for(var att in attributes)
{element.removeAttribute(att,attributes[att]);}}
if(def.styles)
{for(var i in def.styles)
{if(!def.styles.hasOwnProperty(i))
continue;element.removeStyle(i);}}}
function applyBlockStyle(range)
{var bookmark=range.createBookmark(true);var iterator=range.createIterator();iterator.enforceRealBlocks=true;if(this._.enterMode)
iterator.enlargeBr=(this._.enterMode!=CKEDITOR.ENTER_BR);var block;var doc=range.document;var previousPreBlock;while((block=iterator.getNextParagraph()))
{if(!block.isReadOnly())
{var newBlock=getElement(this,doc,block);replaceBlock(block,newBlock);}}
range.moveToBookmark(bookmark);}
function removeBlockStyle(range)
{var bookmark=range.createBookmark(1);var iterator=range.createIterator();iterator.enforceRealBlocks=true;iterator.enlargeBr=this._.enterMode!=CKEDITOR.ENTER_BR;var block;while((block=iterator.getNextParagraph()))
{if(this.checkElementRemovable(block))
{if(block.is('pre'))
{var newBlock=this._.enterMode==CKEDITOR.ENTER_BR?null:range.document.createElement(this._.enterMode==CKEDITOR.ENTER_P?'p':'div');newBlock&&block.copyAttributes(newBlock);replaceBlock(block,newBlock);}
else
removeFromElement(this,block,1);}}
range.moveToBookmark(bookmark);}
function replaceBlock(block,newBlock)
{if(!block.$.parentNode)
return;var removeBlock=!newBlock;if(removeBlock)
{newBlock=block.getDocument().createElement('div');block.copyAttributes(newBlock);}
var newBlockIsPre=newBlock&&newBlock.is('pre');var blockIsPre=block.is('pre');var isToPre=newBlockIsPre&&!blockIsPre;var isFromPre=!newBlockIsPre&&blockIsPre;if(isToPre)
newBlock=toPre(block,newBlock);else if(isFromPre)
newBlock=fromPres(removeBlock?[block.getHtml()]:splitIntoPres(block),newBlock);else
block.moveChildren(newBlock);newBlock.replace(block);if(newBlockIsPre)
{mergePre(newBlock);}
else if(removeBlock)
removeNoAttribsElement(newBlock);}
function mergePre(preBlock)
{var previousBlock;if(!((previousBlock=preBlock.getPrevious(nonWhitespaces))&&previousBlock.is&&previousBlock.is('pre')))
return;var mergedHtml=replace(previousBlock.getHtml(),/\n$/,'')+'\n\n'+
replace(preBlock.getHtml(),/^\n/,'');if(CKEDITOR.env.ie)
preBlock.$.outerHTML='<pre>'+mergedHtml+'</pre>';else
preBlock.setHtml(mergedHtml);previousBlock.remove();}
function splitIntoPres(preBlock)
{var duoBrRegex=/(\S\s*)\n(?:\s|(<span[^>]+data-cke-bookmark.*?\/span>))*\n(?!$)/gi,blockName=preBlock.getName(),splitedHtml=replace(preBlock.getOuterHtml(),duoBrRegex,function(match,charBefore,bookmark)
{return charBefore+'</pre>'+bookmark+'<pre>';});var pres=[];splitedHtml.replace(/<pre\b.*?>([\s\S]*?)<\/pre>/gi,function(match,preContent){pres.push(preContent);});return pres;}
function replace(str,regexp,replacement)
{var headBookmark='',tailBookmark='';str=str.replace(/(^<span[^>]+data-cke-bookmark.*?\/span>)|(<span[^>]+data-cke-bookmark.*?\/span>$)/gi,function(str,m1,m2){m1&&(headBookmark=m1);m2&&(tailBookmark=m2);return'';});return headBookmark+str.replace(regexp,replacement)+tailBookmark;}
function fromPres(preHtmls,newBlock)
{var docFrag;if(preHtmls.length>1)
docFrag=new CKEDITOR.dom.documentFragment(newBlock.getDocument());for(var i=0;i<preHtmls.length;i++)
{var blockHtml=preHtmls[i];blockHtml=blockHtml.replace(/(\r\n|\r)/g,'\n');blockHtml=replace(blockHtml,/^[ \t]*\n/,'');blockHtml=replace(blockHtml,/\n$/,'');blockHtml=replace(blockHtml,/^[ \t]+|[ \t]+$/g,function(match,offset,s)
{if(match.length==1)
return'&nbsp;';else if(!offset)
return CKEDITOR.tools.repeat('&nbsp;',match.length-1)+' ';else
return' '+CKEDITOR.tools.repeat('&nbsp;',match.length-1);});blockHtml=blockHtml.replace(/\n/g,'<br>');blockHtml=blockHtml.replace(/[ \t]{2,}/g,function(match)
{return CKEDITOR.tools.repeat('&nbsp;',match.length-1)+' ';});if(docFrag)
{var newBlockClone=newBlock.clone();newBlockClone.setHtml(blockHtml);docFrag.append(newBlockClone);}
else
newBlock.setHtml(blockHtml);}
return docFrag||newBlock;}
function toPre(block,newBlock)
{var bogus=block.getBogus();bogus&&bogus.remove();var preHtml=block.getHtml();preHtml=replace(preHtml,/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g,'');preHtml=preHtml.replace(/[ \t\r\n]*(<br[^>]*>)[ \t\r\n]*/gi,'$1');preHtml=preHtml.replace(/([ \t\n\r]+|&nbsp;)/g,' ');preHtml=preHtml.replace(/<br\b[^>]*>/gi,'\n');if(CKEDITOR.env.ie)
{var temp=block.getDocument().createElement('div');temp.append(newBlock);newBlock.$.outerHTML='<pre>'+preHtml+'</pre>';newBlock.copyAttributes(temp.getFirst());newBlock=temp.getFirst().remove();}
else
newBlock.setHtml(preHtml);return newBlock;}
function removeFromElement(style,element)
{var def=style._.definition,attributes=CKEDITOR.tools.extend({},def.attributes,getOverrides(style)[element.getName()]),styles=def.styles,removeEmpty=CKEDITOR.tools.isEmpty(attributes)&&CKEDITOR.tools.isEmpty(styles);for(var attName in attributes)
{if((attName=='class'||style._.definition.fullMatch)&&element.getAttribute(attName)!=normalizeProperty(attName,attributes[attName]))
continue;removeEmpty=element.hasAttribute(attName);element.removeAttribute(attName);}
for(var styleName in styles)
{if(style._.definition.fullMatch&&element.getStyle(styleName)!=normalizeProperty(styleName,styles[styleName],true))
continue;removeEmpty=removeEmpty||!!element.getStyle(styleName);element.removeStyle(styleName);}
if(removeEmpty)
{!CKEDITOR.dtd.$block[element.getName()]||style._.enterMode==CKEDITOR.ENTER_BR&&!element.hasAttributes()?removeNoAttribsElement(element):element.renameNode(style._.enterMode==CKEDITOR.ENTER_P?'p':'div');}}
function removeFromInsideElement(style,element)
{var def=style._.definition,attribs=def.attributes,styles=def.styles,overrides=getOverrides(style),innerElements=element.getElementsByTag(style.element);for(var i=innerElements.count();--i>=0;)
removeFromElement(style,innerElements.getItem(i));for(var overrideElement in overrides)
{if(overrideElement!=style.element)
{innerElements=element.getElementsByTag(overrideElement);for(i=innerElements.count()-1;i>=0;i--)
{var innerElement=innerElements.getItem(i);removeOverrides(innerElement,overrides[overrideElement]);}}}}
function removeOverrides(element,overrides)
{var attributes=overrides&&overrides.attributes;if(attributes)
{for(var i=0;i<attributes.length;i++)
{var attName=attributes[i][0],actualAttrValue;if((actualAttrValue=element.getAttribute(attName)))
{var attValue=attributes[i][1];if(attValue===null||(attValue.test&&attValue.test(actualAttrValue))||(typeof attValue=='string'&&actualAttrValue==attValue))
element.removeAttribute(attName);}}}
removeNoAttribsElement(element);}
function removeNoAttribsElement(element)
{if(!element.hasAttributes())
{if(CKEDITOR.dtd.$block[element.getName()])
{var previous=element.getPrevious(nonWhitespaces),next=element.getNext(nonWhitespaces);if(previous&&(previous.type==CKEDITOR.NODE_TEXT||!previous.isBlockBoundary({br:1})))
element.append('br',1);if(next&&(next.type==CKEDITOR.NODE_TEXT||!next.isBlockBoundary({br:1})))
element.append('br');element.remove(true);}
else
{var firstChild=element.getFirst();var lastChild=element.getLast();element.remove(true);if(firstChild)
{firstChild.type==CKEDITOR.NODE_ELEMENT&&firstChild.mergeSiblings();if(lastChild&&!firstChild.equals(lastChild)&&lastChild.type==CKEDITOR.NODE_ELEMENT)
lastChild.mergeSiblings();}}}}
function getElement(style,targetDocument,element)
{var el,def=style._.definition,elementName=style.element;if(elementName=='*')
elementName='span';el=new CKEDITOR.dom.element(elementName,targetDocument);if(element)
element.copyAttributes(el);el=setupElement(el,style);if(targetDocument.getCustomData('doc_processing_style')&&el.hasAttribute('id'))
el.removeAttribute('id');else
targetDocument.setCustomData('doc_processing_style',1);return el;}
function setupElement(el,style)
{var def=style._.definition,attributes=def.attributes,styles=CKEDITOR.style.getStyleText(def);if(attributes)
{for(var att in attributes)
{el.setAttribute(att,attributes[att]);}}
if(styles)
el.setAttribute('style',styles);return el;}
function replaceVariables(list,variablesValues)
{for(var item in list)
{list[item]=list[item].replace(varRegex,function(match,varName)
{return variablesValues[varName];});}}
function getAttributesForComparison(styleDefinition)
{var attribs=styleDefinition._AC;if(attribs)
return attribs;attribs={};var length=0;var styleAttribs=styleDefinition.attributes;if(styleAttribs)
{for(var styleAtt in styleAttribs)
{length++;attribs[styleAtt]=styleAttribs[styleAtt];}}
var styleText=CKEDITOR.style.getStyleText(styleDefinition);if(styleText)
{if(!attribs['style'])
length++;attribs['style']=styleText;}
attribs._length=length;return(styleDefinition._AC=attribs);}
function getOverrides(style)
{if(style._.overrides)
return style._.overrides;var overrides=(style._.overrides={}),definition=style._.definition.overrides;if(definition)
{if(!CKEDITOR.tools.isArray(definition))
definition=[definition];for(var i=0;i<definition.length;i++)
{var override=definition[i];var elementName;var overrideEl;var attrs;if(typeof override=='string')
elementName=override.toLowerCase();else
{elementName=override.element?override.element.toLowerCase():style.element;attrs=override.attributes;}
overrideEl=overrides[elementName]||(overrides[elementName]={});if(attrs)
{var overrideAttrs=(overrideEl.attributes=overrideEl.attributes||new Array());for(var attName in attrs)
{overrideAttrs.push([attName.toLowerCase(),attrs[attName]]);}}}}
return overrides;}
function normalizeProperty(name,value,isStyle)
{var temp=new CKEDITOR.dom.element('span');temp[isStyle?'setStyle':'setAttribute'](name,value);return temp[isStyle?'getStyle':'getAttribute'](name);}
function normalizeCssText(unparsedCssText,nativeNormalize)
{var styleText;if(nativeNormalize!==false)
{var temp=new CKEDITOR.dom.element('span');temp.setAttribute('style',unparsedCssText);styleText=temp.getAttribute('style')||'';}
else
styleText=unparsedCssText;styleText=styleText.replace(/(font-family:)(.*?)(?=;|$)/,function(match,prop,val)
{var names=val.split(',');for(var i=0;i<names.length;i++)
names[i]=CKEDITOR.tools.trim(names[i].replace(/["']/g,''));return prop+names.join(',');});return styleText.replace(/\s*([;:])\s*/,'$1').replace(/([^\s;])$/,'$1;').replace(/,\s+/g,',').replace(/\"/g,'').toLowerCase();}
function parseStyleText(styleText)
{var retval={};styleText.replace(/&quot;/g,'"').replace(/\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g,function(match,name,value)
{retval[name]=value;});return retval;}
function compareCssText(source,target)
{typeof source=='string'&&(source=parseStyleText(source));typeof target=='string'&&(target=parseStyleText(target));for(var name in source)
{if(!(name in target&&(target[name]==source[name]||source[name]=='inherit'||target[name]=='inherit')))
{return false;}}
return true;}
function applyStyle(document,remove)
{var selection=document.getSelection(),bookmarks=selection.createBookmarks(1),ranges=selection.getRanges(CKEDITOR.ONLY_FORMATTABLES),func=remove?this.removeFromRange:this.applyToRange,range;document.fire('applyStyle',{style:this.element,remove:remove,selection:selection,ranges:ranges});var iterator=ranges.createIterator();while((range=iterator.getNextRange()))
func.call(this,range);document.fire('afterApplyStyle',{style:this.element,remove:remove,selection:selection,ranges:ranges});if(bookmarks.length==1&&bookmarks[0].collapsed)
{selection.selectRanges(ranges);document.getById(bookmarks[0].startNode).remove();}
else
selection.selectBookmarks(bookmarks);document.removeCustomData('doc_processing_style');}})();CKEDITOR.styleCommand=function(style)
{this.style=style;};CKEDITOR.styleCommand.prototype.exec=function(editor)
{editor.focus();var doc=editor.document;if(doc)
{if(this.state==CKEDITOR.TRISTATE_OFF)
this.style.apply(doc);else if(this.state==CKEDITOR.TRISTATE_ON)
this.style.remove(doc);}
return!!doc;};CKEDITOR.stylesSet=new CKEDITOR.resourceManager('','stylesSet');CKEDITOR.addStylesSet=CKEDITOR.tools.bind(CKEDITOR.stylesSet.add,CKEDITOR.stylesSet);CKEDITOR.loadStylesSet=function(name,url,callback)
{CKEDITOR.stylesSet.addExternal(name,url,'');CKEDITOR.stylesSet.load(name,callback);};CKEDITOR.editor.prototype.getStylesSet=function(callback)
{if(!this._.stylesDefinitions)
{var editor=this,configStyleSet=editor.config.stylesCombo_stylesSet||editor.config.stylesSet||'default';if(configStyleSet instanceof Array)
{editor._.stylesDefinitions=configStyleSet;callback(configStyleSet);return;}
var partsStylesSet=configStyleSet.split(':'),styleSetName=partsStylesSet[0],externalPath=partsStylesSet[1],pluginPath=CKEDITOR.plugins.registered.styles.path;CKEDITOR.stylesSet.addExternal(styleSetName,externalPath?partsStylesSet.slice(1).join(':'):pluginPath+'styles/'+styleSetName+'.js','');CKEDITOR.stylesSet.load(styleSetName,function(stylesSet)
{editor._.stylesDefinitions=stylesSet[styleSetName];callback(editor._.stylesDefinitions);});}
else
callback(this._.stylesDefinitions);};;CKEDITOR.plugins.add('domiterator');(function()
{function iterator(range)
{if(arguments.length<1)
return;this.range=range;this.forceBrBreak=0;this.enlargeBr=1;this.enforceRealBlocks=0;this._||(this._={});}
var beginWhitespaceRegex=/^[\r\n\t ]+$/,bookmarkGuard=CKEDITOR.dom.walker.bookmark(false,true),whitespacesGuard=CKEDITOR.dom.walker.whitespaces(true),skipGuard=function(node){return bookmarkGuard(node)&&whitespacesGuard(node);};function getNextSourceNode(node,startFromSibling,lastNode)
{var next=node.getNextSourceNode(startFromSibling,null,lastNode);while(!bookmarkGuard(next))
next=next.getNextSourceNode(startFromSibling,null,lastNode);return next;}
iterator.prototype={getNextParagraph:function(blockTag)
{var block;var range;var isLast;var touchPre;var removePreviousBr,removeLastBr;if(!this._.lastNode)
{range=this.range.clone();range.shrink(CKEDITOR.NODE_ELEMENT,true);touchPre=range.endContainer.hasAscendant('pre',true)||range.startContainer.hasAscendant('pre',true);range.enlarge(this.forceBrBreak&&!touchPre||!this.enlargeBr?CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS:CKEDITOR.ENLARGE_BLOCK_CONTENTS);var walker=new CKEDITOR.dom.walker(range),ignoreBookmarkTextEvaluator=CKEDITOR.dom.walker.bookmark(true,true);walker.evaluator=ignoreBookmarkTextEvaluator;this._.nextNode=walker.next();walker=new CKEDITOR.dom.walker(range);walker.evaluator=ignoreBookmarkTextEvaluator;var lastNode=walker.previous();this._.lastNode=lastNode.getNextSourceNode(true);if(this._.lastNode&&this._.lastNode.type==CKEDITOR.NODE_TEXT&&!CKEDITOR.tools.trim(this._.lastNode.getText())&&this._.lastNode.getParent().isBlockBoundary())
{var testRange=new CKEDITOR.dom.range(range.document);testRange.moveToPosition(this._.lastNode,CKEDITOR.POSITION_AFTER_END);if(testRange.checkEndOfBlock())
{var path=new CKEDITOR.dom.elementPath(testRange.endContainer);var lastBlock=path.block||path.blockLimit;this._.lastNode=lastBlock.getNextSourceNode(true);}}
if(!this._.lastNode)
{this._.lastNode=this._.docEndMarker=range.document.createText('');this._.lastNode.insertAfter(lastNode);}
range=null;}
var currentNode=this._.nextNode;lastNode=this._.lastNode;this._.nextNode=null;while(currentNode)
{var closeRange=0,parentPre=currentNode.hasAscendant('pre');var includeNode=(currentNode.type!=CKEDITOR.NODE_ELEMENT),continueFromSibling=0;if(!includeNode)
{var nodeName=currentNode.getName();if(currentNode.isBlockBoundary(this.forceBrBreak&&!parentPre&&{br:1}))
{if(nodeName=='br')
includeNode=1;else if(!range&&!currentNode.getChildCount()&&nodeName!='hr')
{block=currentNode;isLast=currentNode.equals(lastNode);break;}
if(range)
{range.setEndAt(currentNode,CKEDITOR.POSITION_BEFORE_START);if(nodeName!='br')
this._.nextNode=currentNode;}
closeRange=1;}
else
{if(currentNode.getFirst())
{if(!range)
{range=new CKEDITOR.dom.range(this.range.document);range.setStartAt(currentNode,CKEDITOR.POSITION_BEFORE_START);}
currentNode=currentNode.getFirst();continue;}
includeNode=1;}}
else if(currentNode.type==CKEDITOR.NODE_TEXT)
{if(beginWhitespaceRegex.test(currentNode.getText()))
includeNode=0;}
if(includeNode&&!range)
{range=new CKEDITOR.dom.range(this.range.document);range.setStartAt(currentNode,CKEDITOR.POSITION_BEFORE_START);}
isLast=((!closeRange||includeNode)&&currentNode.equals(lastNode));if(range&&!closeRange)
{while(!currentNode.getNext(skipGuard)&&!isLast)
{var parentNode=currentNode.getParent();if(parentNode.isBlockBoundary(this.forceBrBreak&&!parentPre&&{br:1}))
{closeRange=1;includeNode=0;isLast=isLast||(parentNode.equals(lastNode));range.setEndAt(parentNode,CKEDITOR.POSITION_BEFORE_END);break;}
currentNode=parentNode;includeNode=1;isLast=(currentNode.equals(lastNode));continueFromSibling=1;}}
if(includeNode)
range.setEndAt(currentNode,CKEDITOR.POSITION_AFTER_END);currentNode=getNextSourceNode(currentNode,continueFromSibling,lastNode);isLast=!currentNode;if(isLast||(closeRange&&range))
break;}
if(!block)
{if(!range)
{this._.docEndMarker&&this._.docEndMarker.remove();this._.nextNode=null;return null;}
range.enlargeFormattables();var startPath=new CKEDITOR.dom.elementPath(range.startContainer);var startBlockLimit=startPath.blockLimit,checkLimits={div:1,th:1,td:1};block=startPath.block;if(!block&&!this.enforceRealBlocks&&checkLimits[startBlockLimit.getName()]&&range.checkStartOfBlock()&&range.checkEndOfBlock())
block=startBlockLimit;else if(!block||(this.enforceRealBlocks&&block.getName()=='li'))
{block=this.range.document.createElement(blockTag||'p');range.extractContents().appendTo(block);block.trim();range.insertNode(block);removePreviousBr=removeLastBr=true;}
else if(block.getName()!='li')
{if(!range.checkStartOfBlock()||!range.checkEndOfBlock())
{block=block.clone(false);range.extractContents().appendTo(block);block.trim();var splitInfo=range.splitBlock();removePreviousBr=!splitInfo.wasStartOfBlock;removeLastBr=!splitInfo.wasEndOfBlock;range.insertNode(block);}}
else if(!isLast)
{this._.nextNode=(block.equals(lastNode)?null:getNextSourceNode(range.getBoundaryNodes().endNode,1,lastNode));}}
if(removePreviousBr)
{var previousSibling=block.getPrevious();if(previousSibling&&previousSibling.type==CKEDITOR.NODE_ELEMENT)
{if(previousSibling.getName()=='br')
previousSibling.remove();else if(previousSibling.getLast()&&previousSibling.getLast().$.nodeName.toLowerCase()=='br')
previousSibling.getLast().remove();}}
if(removeLastBr)
{var lastChild=block.getLast();if(lastChild&&lastChild.type==CKEDITOR.NODE_ELEMENT&&lastChild.getName()=='br')
{if(CKEDITOR.env.ie||lastChild.getPrevious(bookmarkGuard)||lastChild.getNext(bookmarkGuard))
lastChild.remove();}}
if(!this._.nextNode)
{this._.nextNode=(isLast||block.equals(lastNode))?null:getNextSourceNode(block,1,lastNode);}
return block;}};CKEDITOR.dom.range.prototype.createIterator=function()
{return new iterator(this);};})();;CKEDITOR.plugins.add('panelbutton',{requires:['button'],onLoad:function()
{function clickFn(editor)
{var _=this._;if(_.state==CKEDITOR.TRISTATE_DISABLED)
return;this.createPanel(editor);if(_.on)
{_.panel.hide();return;}
_.panel.showBlock(this._.id,this.document.getById(this._.id),4);}
CKEDITOR.ui.panelButton=CKEDITOR.tools.createClass({base:CKEDITOR.ui.button,$:function(definition)
{var panelDefinition=definition.panel;delete definition.panel;this.base(definition);this.document=(panelDefinition&&panelDefinition.parent&&panelDefinition.parent.getDocument())||CKEDITOR.document;panelDefinition.block={attributes:panelDefinition.attributes};this.hasArrow=true;this.click=clickFn;this._={panelDefinition:panelDefinition};},statics:{handler:{create:function(definition)
{return new CKEDITOR.ui.panelButton(definition);}}},proto:{createPanel:function(editor)
{var _=this._;if(_.panel)
return;var panelDefinition=this._.panelDefinition||{},panelBlockDefinition=this._.panelDefinition.block,panelParentElement=panelDefinition.parent||CKEDITOR.document.getBody(),panel=this._.panel=new CKEDITOR.ui.floatPanel(editor,panelParentElement,panelDefinition),block=panel.addBlock(_.id,panelBlockDefinition),me=this;panel.onShow=function()
{if(me.className)
this.element.getFirst().addClass(me.className+'_panel');me.setState(CKEDITOR.TRISTATE_ON);_.on=1;if(me.onOpen)
me.onOpen();};panel.onHide=function(preventOnClose)
{if(me.className)
this.element.getFirst().removeClass(me.className+'_panel');me.setState(me.modes&&me.modes[editor.mode]?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED);_.on=0;if(!preventOnClose&&me.onClose)
me.onClose();};panel.onEscape=function()
{panel.hide();me.document.getById(_.id).focus();};if(this.onBlock)
this.onBlock(panel,block);block.onHide=function()
{_.on=0;me.setState(CKEDITOR.TRISTATE_OFF);};}}});},beforeInit:function(editor)
{editor.ui.addHandler(CKEDITOR.UI_PANELBUTTON,CKEDITOR.ui.panelButton.handler);}});CKEDITOR.UI_PANELBUTTON='panelbutton';;CKEDITOR.plugins.add('floatpanel',{requires:['panel']});(function()
{var panels={};var isShowing=false;function getPanel(editor,doc,parentElement,definition,level)
{var key=CKEDITOR.tools.genKey(doc.getUniqueId(),parentElement.getUniqueId(),editor.skinName,editor.lang.dir,editor.uiColor||'',definition.css||'',level||'');var panel=panels[key];if(!panel)
{panel=panels[key]=new CKEDITOR.ui.panel(doc,definition);panel.element=parentElement.append(CKEDITOR.dom.element.createFromHtml(panel.renderHtml(editor),doc));panel.element.setStyles({display:'none',position:'absolute'});}
return panel;}
CKEDITOR.ui.floatPanel=CKEDITOR.tools.createClass({$:function(editor,parentElement,definition,level)
{definition.forceIFrame=1;var doc=parentElement.getDocument(),panel=getPanel(editor,doc,parentElement,definition,level||0),element=panel.element,iframe=element.getFirst().getFirst();this.element=element;this._={editor:editor,panel:panel,parentElement:parentElement,definition:definition,document:doc,iframe:iframe,children:[],dir:editor.lang.dir};editor.on('mode',function(){this.hide();},this);},proto:{addBlock:function(name,block)
{return this._.panel.addBlock(name,block);},addListBlock:function(name,multiSelect)
{return this._.panel.addListBlock(name,multiSelect);},getBlock:function(name)
{return this._.panel.getBlock(name);},showBlock:function(name,offsetParent,corner,offsetX,offsetY)
{var panel=this._.panel,block=panel.showBlock(name);this.allowBlur(false);isShowing=1;this._.returnFocus=this._.editor.focusManager.hasFocus?this._.editor:new CKEDITOR.dom.element(CKEDITOR.document.$.activeElement);var element=this.element,iframe=this._.iframe,definition=this._.definition,position=offsetParent.getDocumentPosition(element.getDocument()),rtl=this._.dir=='rtl';var left=position.x+(offsetX||0),top=position.y+(offsetY||0);if(rtl&&(corner==1||corner==4))
left+=offsetParent.$.offsetWidth;else if(!rtl&&(corner==2||corner==3))
left+=offsetParent.$.offsetWidth-1;if(corner==3||corner==4)
top+=offsetParent.$.offsetHeight-1;this._.panel._.offsetParentId=offsetParent.getId();element.setStyles({top:top+'px',left:0,display:''});element.setOpacity(0);element.getFirst().removeStyle('width');if(!this._.blurSet)
{var focused=CKEDITOR.env.ie?iframe:new CKEDITOR.dom.window(iframe.$.contentWindow);CKEDITOR.event.useCapture=true;focused.on('blur',function(ev)
{if(!this.allowBlur())
return;var target=ev.data.getTarget();if(target.getName&&target.getName()!='iframe')
return;if(this.visible&&!this._.activeChild&&!isShowing)
{delete this._.returnFocus;this.hide();}},this);focused.on('focus',function()
{this._.focused=true;this.hideChild();this.allowBlur(true);},this);CKEDITOR.event.useCapture=false;this._.blurSet=1;}
panel.onEscape=CKEDITOR.tools.bind(function(keystroke)
{if(this.onEscape&&this.onEscape(keystroke)===false)
return false;},this);CKEDITOR.tools.setTimeout(function()
{if(rtl)
left-=element.$.offsetWidth;var panelLoad=CKEDITOR.tools.bind(function()
{var target=element.getFirst();if(block.autoSize)
{var widthNode=block.element.$;if(CKEDITOR.env.gecko||CKEDITOR.env.opera)
widthNode=widthNode.parentNode;if(CKEDITOR.env.ie)
widthNode=widthNode.document.body;var width=widthNode.scrollWidth;if(CKEDITOR.env.ie&&CKEDITOR.env.quirks&&width>0)
width+=(target.$.offsetWidth||0)-(target.$.clientWidth||0)+3;width+=4;target.setStyle('width',width+'px');block.element.addClass('cke_frameLoaded');var height=block.element.$.scrollHeight;if(CKEDITOR.env.ie&&CKEDITOR.env.quirks&&height>0)
height+=(target.$.offsetHeight||0)-(target.$.clientHeight||0)+3;target.setStyle('height',height+'px');panel._.currentBlock.element.setStyle('display','none').removeStyle('display');}
else
target.removeStyle('height');var panelElement=panel.element,panelWindow=panelElement.getWindow(),windowScroll=panelWindow.getScrollPosition(),viewportSize=panelWindow.getViewPaneSize(),panelSize={'height':panelElement.$.offsetHeight,'width':panelElement.$.offsetWidth};if(rtl?left<0:left+panelSize.width>viewportSize.width+windowScroll.x)
left+=(panelSize.width*(rtl?1:-1));if(top+panelSize.height>viewportSize.height+windowScroll.y)
top-=panelSize.height;if(CKEDITOR.env.ie)
{var offsetParent=new CKEDITOR.dom.element(element.$.offsetParent),scrollParent=offsetParent;if(scrollParent.getName()=='html')
scrollParent=scrollParent.getDocument().getBody();if(scrollParent.getComputedStyle('direction')=='rtl')
{if(CKEDITOR.env.ie8Compat)
left-=element.getDocument().getDocumentElement().$.scrollLeft*2;else
left-=(offsetParent.$.scrollWidth-offsetParent.$.clientWidth);}}
var innerElement=element.getFirst(),activePanel;if((activePanel=innerElement.getCustomData('activePanel')))
activePanel.onHide&&activePanel.onHide.call(this,1);innerElement.setCustomData('activePanel',this);element.setStyles({top:top+'px',left:left+'px'});element.setOpacity(1);},this);panel.isLoaded?panelLoad():panel.onLoad=panelLoad;CKEDITOR.tools.setTimeout(function()
{iframe.$.contentWindow.focus();this.allowBlur(true);},0,this);},CKEDITOR.env.air?200:0,this);this.visible=1;if(this.onShow)
this.onShow.call(this);isShowing=0;},hide:function(returnFocus)
{if(this.visible&&(!this.onHide||this.onHide.call(this)!==true))
{this.hideChild();CKEDITOR.env.gecko&&this._.iframe.getFrameDocument().$.activeElement.blur();this.element.setStyle('display','none');this.visible=0;this.element.getFirst().removeCustomData('activePanel');var focusReturn=returnFocus!==false&&this._.returnFocus;if(focusReturn)
{if(CKEDITOR.env.webkit&&focusReturn.type)
focusReturn.getWindow().$.focus();focusReturn.focus();}}},allowBlur:function(allow)
{var panel=this._.panel;if(allow!=undefined)
panel.allowBlur=allow;return panel.allowBlur;},showAsChild:function(panel,blockName,offsetParent,corner,offsetX,offsetY)
{if(this._.activeChild==panel&&panel._.panel._.offsetParentId==offsetParent.getId())
return;this.hideChild();panel.onHide=CKEDITOR.tools.bind(function()
{CKEDITOR.tools.setTimeout(function()
{if(!this._.focused)
this.hide();},0,this);},this);this._.activeChild=panel;this._.focused=false;panel.showBlock(blockName,offsetParent,corner,offsetX,offsetY);if(CKEDITOR.env.ie7Compat||(CKEDITOR.env.ie8&&CKEDITOR.env.ie6Compat))
{setTimeout(function()
{panel.element.getChild(0).$.style.cssText+='';},100);}},hideChild:function()
{var activeChild=this._.activeChild;if(activeChild)
{delete activeChild.onHide;delete activeChild._.returnFocus;delete this._.activeChild;activeChild.hide();}}}});CKEDITOR.on('instanceDestroyed',function()
{var isLastInstance=CKEDITOR.tools.isEmpty(CKEDITOR.instances);for(var i in panels)
{var panel=panels[i];if(isLastInstance)
panel.destroy();else
panel.element.hide();}
isLastInstance&&(panels={});});})();;CKEDITOR.plugins.add('menu',{beforeInit:function(editor)
{var groups=editor.config.menu_groups.split(','),groupsOrder=editor._.menuGroups={},menuItems=editor._.menuItems={};for(var i=0;i<groups.length;i++)
groupsOrder[groups[i]]=i+1;editor.addMenuGroup=function(name,order)
{groupsOrder[name]=order||100;};editor.addMenuItem=function(name,definition)
{if(groupsOrder[definition.group])
menuItems[name]=new CKEDITOR.menuItem(this,name,definition);};editor.addMenuItems=function(definitions)
{for(var itemName in definitions)
{this.addMenuItem(itemName,definitions[itemName]);}};editor.getMenuItem=function(name)
{return menuItems[name];};editor.removeMenuItem=function(name)
{delete menuItems[name];};},requires:['floatpanel']});(function()
{CKEDITOR.menu=CKEDITOR.tools.createClass({$:function(editor,definition)
{definition=this._.definition=definition||{};this.id=CKEDITOR.tools.getNextId();this.editor=editor;this.items=[];this._.listeners=[];this._.level=definition.level||1;var panelDefinition=CKEDITOR.tools.extend({},definition.panel,{css:editor.skin.editor.css,level:this._.level-1,block:{}});var attrs=panelDefinition.block.attributes=(panelDefinition.attributes||{});!attrs.role&&(attrs.role='menu');this._.panelDefinition=panelDefinition;},_:{onShow:function()
{var selection=this.editor.getSelection();if(CKEDITOR.env.ie)
selection&&selection.lock();var element=selection&&selection.getStartElement(),listeners=this._.listeners,includedItems=[];this.removeAll();for(var i=0;i<listeners.length;i++)
{var listenerItems=listeners[i](element,selection);if(listenerItems)
{for(var itemName in listenerItems)
{var item=this.editor.getMenuItem(itemName);if(item&&(!item.command||this.editor.getCommand(item.command).state))
{item.state=listenerItems[itemName];this.add(item);}}}}},onClick:function(item)
{this.hide(false);if(item.onClick)
item.onClick();else if(item.command)
this.editor.execCommand(item.command);},onEscape:function(keystroke)
{var parent=this.parent;if(parent)
{parent._.panel.hideChild();var parentBlock=parent._.panel._.panel._.currentBlock,parentFocusIndex=parentBlock._.focusIndex;parentBlock._.markItem(parentFocusIndex);}
else if(keystroke==27)
this.hide();return false;},onHide:function()
{if(CKEDITOR.env.ie)
{var selection=this.editor.getSelection();selection&&selection.unlock();}
this.onHide&&this.onHide();},showSubMenu:function(index)
{var menu=this._.subMenu,item=this.items[index],subItemDefs=item.getItems&&item.getItems();if(!subItemDefs)
{this._.panel.hideChild();return;}
var block=this._.panel.getBlock(this.id);block._.focusIndex=index;if(menu)
menu.removeAll();else
{menu=this._.subMenu=new CKEDITOR.menu(this.editor,CKEDITOR.tools.extend({},this._.definition,{level:this._.level+1},true));menu.parent=this;menu._.onClick=CKEDITOR.tools.bind(this._.onClick,this);}
for(var subItemName in subItemDefs)
{var subItem=this.editor.getMenuItem(subItemName);if(subItem)
{subItem.state=subItemDefs[subItemName];menu.add(subItem);}}
var element=this._.panel.getBlock(this.id).element.getDocument().getById(this.id+String(index));menu.show(element,2);}},proto:{add:function(item)
{if(!item.order)
item.order=this.items.length;this.items.push(item);},removeAll:function()
{this.items=[];},show:function(offsetParent,corner,offsetX,offsetY)
{if(!this.parent)
{this._.onShow();if(!this.items.length)
return;}
corner=corner||(this.editor.lang.dir=='rtl'?2:1);var items=this.items,editor=this.editor,panel=this._.panel,element=this._.element;if(!panel)
{panel=this._.panel=new CKEDITOR.ui.floatPanel(this.editor,CKEDITOR.document.getBody(),this._.panelDefinition,this._.level);panel.onEscape=CKEDITOR.tools.bind(function(keystroke)
{if(this._.onEscape(keystroke)===false)
return false;},this);panel.onHide=CKEDITOR.tools.bind(function()
{this._.onHide&&this._.onHide();},this);var block=panel.addBlock(this.id,this._.panelDefinition.block);block.autoSize=true;var keys=block.keys;keys[40]='next';keys[9]='next';keys[38]='prev';keys[CKEDITOR.SHIFT+9]='prev';keys[(editor.lang.dir=='rtl'?37:39)]=CKEDITOR.env.ie?'mouseup':'click';keys[32]=CKEDITOR.env.ie?'mouseup':'click';CKEDITOR.env.ie&&(keys[13]='mouseup');element=this._.element=block.element;element.addClass(editor.skinClass);var elementDoc=element.getDocument();elementDoc.getBody().setStyle('overflow','hidden');elementDoc.getElementsByTag('html').getItem(0).setStyle('overflow','hidden');this._.itemOverFn=CKEDITOR.tools.addFunction(function(index)
{clearTimeout(this._.showSubTimeout);this._.showSubTimeout=CKEDITOR.tools.setTimeout(this._.showSubMenu,editor.config.menu_subMenuDelay||400,this,[index]);},this);this._.itemOutFn=CKEDITOR.tools.addFunction(function(index)
{clearTimeout(this._.showSubTimeout);},this);this._.itemClickFn=CKEDITOR.tools.addFunction(function(index)
{var item=this.items[index];if(item.state==CKEDITOR.TRISTATE_DISABLED)
{this.hide();return;}
if(item.getItems)
this._.showSubMenu(index);else
this._.onClick(item);},this);}
sortItems(items);var chromeRoot=editor.container.getChild(1),mixedContentClass=(chromeRoot&&chromeRoot.hasClass('cke_mixed_dir_content'))?' cke_mixed_dir_content':'';var output=['<div class="cke_menu'+mixedContentClass+'" role="presentation">'];var length=items.length,lastGroup=length&&items[0].group;for(var i=0;i<length;i++)
{var item=items[i];if(lastGroup!=item.group)
{output.push('<div class="cke_menuseparator" role="separator"></div>');lastGroup=item.group;}
item.render(this,i,output);}
output.push('</div>');element.setHtml(output.join(''));CKEDITOR.ui.fire('ready',this);if(this.parent)
this.parent._.panel.showAsChild(panel,this.id,offsetParent,corner,offsetX,offsetY);else
panel.showBlock(this.id,offsetParent,corner,offsetX,offsetY);editor.fire('menuShow',[panel]);},addListener:function(listenerFn)
{this._.listeners.push(listenerFn);},hide:function(returnFocus)
{this._.onHide&&this._.onHide();this._.panel&&this._.panel.hide(returnFocus);}}});function sortItems(items)
{items.sort(function(itemA,itemB)
{if(itemA.group<itemB.group)
return-1;else if(itemA.group>itemB.group)
return 1;return itemA.order<itemB.order?-1:itemA.order>itemB.order?1:0;});}
CKEDITOR.menuItem=CKEDITOR.tools.createClass({$:function(editor,name,definition)
{CKEDITOR.tools.extend(this,definition,{order:0,className:'cke_button_'+name});this.group=editor._.menuGroups[this.group];this.editor=editor;this.name=name;},proto:{render:function(menu,index,output)
{var id=menu.id+String(index),state=(typeof this.state=='undefined')?CKEDITOR.TRISTATE_OFF:this.state;var classes=' cke_'+(state==CKEDITOR.TRISTATE_ON?'on':state==CKEDITOR.TRISTATE_DISABLED?'disabled':'off');var htmlLabel=this.label;if(this.className)
classes+=' '+this.className;var hasSubMenu=this.getItems;output.push('<span class="cke_menuitem'+(this.icon&&this.icon.indexOf('.png')==-1?' cke_noalphafix':'')+'">'+'<a id="',id,'"'+' class="',classes,'" href="javascript:void(\'',(this.label||'').replace("'",''),'\')"'+' title="',this.label,'"'+' tabindex="-1"'+'_cke_focus=1'+' hidefocus="true"'+' role="menuitem"'+
(hasSubMenu?'aria-haspopup="true"':'')+
(state==CKEDITOR.TRISTATE_DISABLED?'aria-disabled="true"':'')+
(state==CKEDITOR.TRISTATE_ON?'aria-pressed="true"':''));if(CKEDITOR.env.opera||(CKEDITOR.env.gecko&&CKEDITOR.env.mac))
{output.push(' onkeypress="return false;"');}
if(CKEDITOR.env.gecko)
{output.push(' onblur="this.style.cssText = this.style.cssText;"');}
var offset=(this.iconOffset||0)*-16;output.push(' onmouseover="CKEDITOR.tools.callFunction(',menu._.itemOverFn,',',index,');"'+' onmouseout="CKEDITOR.tools.callFunction(',menu._.itemOutFn,',',index,');" '+
(CKEDITOR.env.ie?'onclick="return false;" onmouseup':'onclick')+'="CKEDITOR.tools.callFunction(',menu._.itemClickFn,',',index,'); return false;"'+'>'+'<span class="cke_icon_wrapper"><span class="cke_icon"'+
(this.icon?' style="background-image:url('+CKEDITOR.getUrl(this.icon)+');background-position:0 '+offset+'px;"':'')+'></span></span>'+'<span class="cke_label">');if(hasSubMenu)
{output.push('<span class="cke_menuarrow">','<span>&#',(this.editor.lang.dir=='rtl'?'9668':'9658'),';</span>','</span>');}
output.push(htmlLabel,'</span>'+'</a>'+'</span>');}}});})();CKEDITOR.config.menu_groups='clipboard,'+'form,'+'tablecell,tablecellproperties,tablerow,tablecolumn,table,'+'anchor,link,image,flash,'+'checkbox,radio,textfield,hiddenfield,imagebutton,button,select,textarea,div';;(function()
{var isHandlingData;CKEDITOR.plugins.add('editingblock',{init:function(editor)
{if(!editor.config.editingBlock)
return;editor.on('themeSpace',function(event)
{if(event.data.space=='contents')
event.data.html+='<br>';});editor.on('themeLoaded',function()
{editor.fireOnce('editingBlockReady');});editor.on('uiReady',function()
{editor.setMode(editor.config.startupMode);});editor.on('afterSetData',function()
{if(!isHandlingData)
{function setData()
{isHandlingData=true;editor.getMode().loadData(editor.getData());isHandlingData=false;}
if(editor.mode)
setData();else
{editor.on('mode',function()
{if(editor.mode)
{setData();editor.removeListener('mode',arguments.callee);}});}}});editor.on('beforeGetData',function()
{if(!isHandlingData&&editor.mode)
{isHandlingData=true;editor.setData(editor.getMode().getData(),null,1);isHandlingData=false;}});editor.on('getSnapshot',function(event)
{if(editor.mode)
event.data=editor.getMode().getSnapshotData();});editor.on('loadSnapshot',function(event)
{if(editor.mode)
editor.getMode().loadSnapshotData(event.data);});editor.on('mode',function(event)
{event.removeListener();CKEDITOR.env.webkit&&editor.container.on('focus',function()
{editor.focus();});if(editor.config.startupFocus){var focusEditor=function(){editor.focus();if(editor.mode==='source'){editor.textarea.$.scrollTop=0;editor.textarea.$.setSelectionRange(0,0);}};if(CKEDITOR.env.gecko){setTimeout(focusEditor,500);}else{focusEditor();}}
setTimeout(function(){editor.fireOnce('instanceReady');CKEDITOR.fire('instanceReady',null,editor);},0);});editor.on('destroy',function()
{if(this.mode)
this._.modes[this.mode].unload(this.getThemeSpace('contents'));});}});CKEDITOR.editor.prototype.mode='';CKEDITOR.editor.prototype.addMode=function(mode,modeEditor)
{modeEditor.name=mode;(this._.modes||(this._.modes={}))[mode]=modeEditor;};CKEDITOR.editor.prototype.setMode=function(mode)
{this.fire('beforeSetMode',{newMode:mode});var data,holderElement=this.getThemeSpace('contents'),isDirty=this.checkDirty();if(this.mode)
{if(mode==this.mode)
return;this.fire('beforeModeUnload');var currentMode=this.getMode();data=currentMode.getData();currentMode.unload(holderElement);this.mode='';}
holderElement.setHtml('');var modeEditor=this.getMode(mode);if(!modeEditor)
throw'[CKEDITOR.editor.setMode] Unknown mode "'+mode+'".';if(!isDirty)
{this.on('mode',function()
{this.resetDirty();this.removeListener('mode',arguments.callee);});}
modeEditor.load(holderElement,(typeof data)!='string'?this.getData():data);};CKEDITOR.editor.prototype.getMode=function(mode)
{return this._.modes&&this._.modes[mode||this.mode];};CKEDITOR.editor.prototype.focus=function()
{this.forceNextSelectionCheck();var mode=this.getMode();if(mode)
mode.focus();};})();CKEDITOR.config.startupMode='wysiwyg';CKEDITOR.config.editingBlock=true;;(function()
{function checkSelectionChange()
{try
{var sel=this.getSelection();if(!sel||!sel.document.getWindow().$)
return;var firstElement=sel.getStartElement();var currentPath=new CKEDITOR.dom.elementPath(firstElement);if(!currentPath.compare(this._.selectionPreviousPath))
{this._.selectionPreviousPath=currentPath;this.fire('selectionChange',{selection:sel,path:currentPath,element:firstElement});}}
catch(e)
{}}
var checkSelectionChangeTimer,checkSelectionChangeTimeoutPending;function checkSelectionChangeTimeout()
{checkSelectionChangeTimeoutPending=true;if(checkSelectionChangeTimer)
return;checkSelectionChangeTimeoutExec.call(this);checkSelectionChangeTimer=CKEDITOR.tools.setTimeout(checkSelectionChangeTimeoutExec,200,this);}
function checkSelectionChangeTimeoutExec()
{checkSelectionChangeTimer=null;if(checkSelectionChangeTimeoutPending)
{CKEDITOR.tools.setTimeout(checkSelectionChange,0,this);checkSelectionChangeTimeoutPending=false;}}
function rangeRequiresFix(range)
{function isInlineCt(node)
{return node&&node.type==CKEDITOR.NODE_ELEMENT&&node.getName()in CKEDITOR.dtd.$removeEmpty;}
function singletonBlock(node)
{var body=range.document.getBody();return!node.is('body')&&body.getChildCount()==1;}
var start=range.startContainer,offset=range.startOffset;if(start.type==CKEDITOR.NODE_TEXT)
return false;return!CKEDITOR.tools.trim(start.getHtml())?isInlineCt(start)||singletonBlock(start):isInlineCt(start.getChild(offset-1))||isInlineCt(start.getChild(offset));}
var selectAllCmd={modes:{wysiwyg:1,source:1},readOnly:CKEDITOR.env.ie||CKEDITOR.env.webkit,exec:function(editor)
{switch(editor.mode)
{case'wysiwyg':editor.document.$.execCommand('SelectAll',false,null);editor.forceNextSelectionCheck();editor.selectionChange();break;case'source':var textarea=editor.textarea.$;if(CKEDITOR.env.ie)
textarea.createTextRange().execCommand('SelectAll');else
{textarea.selectionStart=0;textarea.selectionEnd=textarea.value.length;}
textarea.focus();}},canUndo:false};function createFillingChar(doc)
{removeFillingChar(doc);var fillingChar=doc.createText('\u200B');doc.setCustomData('cke-fillingChar',fillingChar);return fillingChar;}
function getFillingChar(doc)
{return doc&&doc.getCustomData('cke-fillingChar');}
function checkFillingChar(doc)
{var fillingChar=doc&&getFillingChar(doc);if(fillingChar)
{if(fillingChar.getCustomData('ready'))
removeFillingChar(doc);else
fillingChar.setCustomData('ready',1);}}
function removeFillingChar(doc)
{var fillingChar=doc&&doc.removeCustomData('cke-fillingChar');if(fillingChar)
{var bm,sel=doc.getSelection().getNative(),range=sel&&sel.type!='None'&&sel.getRangeAt(0);if(fillingChar.getLength()>1&&range&&range.intersectsNode(fillingChar.$))
{bm=[sel.anchorOffset,sel.focusOffset];var startAffected=sel.anchorNode==fillingChar.$&&sel.anchorOffset>0,endAffected=sel.focusNode==fillingChar.$&&sel.focusOffset>0;startAffected&&bm[0]--;endAffected&&bm[1]--;isReversedSelection(sel)&&bm.unshift(bm.pop());}
fillingChar.setText(fillingChar.getText().replace(/\u200B/g,''));if(bm)
{var rng=sel.getRangeAt(0);rng.setStart(rng.startContainer,bm[0]);rng.setEnd(rng.startContainer,bm[1]);sel.removeAllRanges();sel.addRange(rng);}}}
function isReversedSelection(sel)
{if(!sel.isCollapsed)
{var range=sel.getRangeAt(0);range.setStart(sel.anchorNode,sel.anchorOffset);range.setEnd(sel.focusNode,sel.focusOffset);return range.collapsed;}}
CKEDITOR.plugins.add('selection',{init:function(editor)
{if(CKEDITOR.env.webkit)
{editor.on('selectionChange',function(){checkFillingChar(editor.document);});editor.on('beforeSetMode',function(){removeFillingChar(editor.document);});var fillingCharBefore,resetSelection;function beforeData()
{var doc=editor.document,fillingChar=getFillingChar(doc);if(fillingChar)
{var sel=doc.$.defaultView.getSelection();if(sel.type=='Caret'&&sel.anchorNode==fillingChar.$)
resetSelection=1;fillingCharBefore=fillingChar.getText();fillingChar.setText(fillingCharBefore.replace(/\u200B/g,''));}}
function afterData()
{var doc=editor.document,fillingChar=getFillingChar(doc);if(fillingChar)
{fillingChar.setText(fillingCharBefore);if(resetSelection)
{doc.$.defaultView.getSelection().setPosition(fillingChar.$,fillingChar.getLength());resetSelection=0;}}}
editor.on('beforeUndoImage',beforeData);editor.on('afterUndoImage',afterData);editor.on('beforeGetData',beforeData,null,null,0);editor.on('getData',afterData);}
editor.on('contentDom',function()
{var doc=editor.document,body=doc.getBody(),html=doc.getDocumentElement();if(CKEDITOR.env.ie)
{var savedRange,saveEnabled,restoreEnabled=1;body.on('focusin',function(evt)
{if(evt.data.$.srcElement.nodeName!='BODY')
return;var lockedSelection=doc.getCustomData('cke_locked_selection');if(lockedSelection)
{lockedSelection.unlock(1);lockedSelection.lock();}
else if(savedRange&&restoreEnabled)
{try{savedRange.select();}catch(e){}
savedRange=null;}});body.on('focus',function()
{saveEnabled=1;saveSelection();});body.on('beforedeactivate',function(evt)
{if(evt.data.$.toElement)
return;saveEnabled=0;restoreEnabled=1;});if(CKEDITOR.env.ie&&CKEDITOR.env.version<8)
{editor.on('blur',function(evt)
{try
{editor.document&&editor.document.$.selection.empty();}
catch(e){}});}
html.on('mousedown',function()
{restoreEnabled=0;});html.on('mouseup',function()
{restoreEnabled=1;});var scroll;body.on('mousedown',function(evt)
{if(evt.data.$.button==2)
{var sel=editor.document.$.selection;if(sel.type=='None')
scroll=editor.window.getScrollPosition();}
disableSave();});body.on('mouseup',function(evt)
{if(evt.data.$.button==2&&scroll)
{editor.document.$.documentElement.scrollLeft=scroll.x;editor.document.$.documentElement.scrollTop=scroll.y;}
scroll=null;saveEnabled=1;setTimeout(function()
{saveSelection(true);},0);});body.on('keydown',disableSave);body.on('keyup',function()
{saveEnabled=1;saveSelection();});if((CKEDITOR.env.ie7Compat||CKEDITOR.env.ie6Compat)&&doc.$.compatMode!='BackCompat')
{html.on('mousedown',function(evt)
{evt=evt.data.$;function onHover(evt)
{evt=evt.data.$;if(textRng)
{var rngEnd=body.$.createTextRange();rngEnd.moveToPoint(evt.x,evt.y);textRng.setEndPoint(textRng.compareEndPoints('StartToStart',rngEnd)<0?'EndToEnd':'StartToStart',rngEnd);textRng.select();}}
if(evt.y<html.$.clientHeight&&evt.y>body.$.offsetTop+body.$.clientHeight&&evt.x<html.$.clientWidth)
{var textRng=body.$.createTextRange();textRng.moveToPoint(evt.x,evt.y);textRng.select();html.on('mousemove',onHover);html.on('mouseup',function(evt)
{html.removeListener('mousemove',onHover);evt.removeListener();textRng.select();textRng=null;});}});}
if(CKEDITOR.env.ie8)
{html.on('mouseup',function(evt)
{if(evt.data.getTarget().getName()=='html')
{var sel=CKEDITOR.document.$.selection,range=sel.createRange();if(sel.type!='None'&&range.parentElement().ownerDocument==doc.$)
range.select();}});}
doc.on('selectionchange',saveSelection);function disableSave()
{saveEnabled=0;}
function saveSelection(testIt)
{if(saveEnabled)
{var doc=editor.document,sel=editor.getSelection(),nativeSel=sel&&sel.getNative();if(testIt&&nativeSel&&nativeSel.type=='None')
{if(!doc.$.queryCommandEnabled('InsertImage'))
{CKEDITOR.tools.setTimeout(saveSelection,50,this,true);return;}}
var parentTag;if(nativeSel&&nativeSel.type&&nativeSel.type!='Control'&&(parentTag=nativeSel.createRange())&&(parentTag=parentTag.parentElement())&&(parentTag=parentTag.nodeName)&&parentTag.toLowerCase()in{input:1,textarea:1})
{return;}
savedRange=nativeSel&&sel.getRanges()[0];checkSelectionChangeTimeout.call(editor);}}}
else
{doc.on('mouseup',checkSelectionChangeTimeout,editor);doc.on('keyup',checkSelectionChangeTimeout,editor);doc.on('selectionchange',checkSelectionChangeTimeout,editor);}
if(CKEDITOR.env.webkit)
{doc.on('keydown',function(evt)
{var key=evt.data.getKey();switch(key)
{case 13:case 33:case 34:case 35:case 36:case 37:case 39:case 8:case 45:case 46:removeFillingChar(editor.document);}},null,null,10);}});editor.on('contentDomUnload',editor.forceNextSelectionCheck,editor);editor.addCommand('selectAll',selectAllCmd);editor.ui.addButton('SelectAll',{label:editor.lang.selectAll,command:'selectAll'});editor.selectionChange=checkSelectionChangeTimeout;CKEDITOR.env.ie9Compat&&editor.on('destroy',function()
{var sel=editor.getSelection();sel&&sel.getNative().clear();},null,null,9);}});CKEDITOR.editor.prototype.getSelection=function()
{return this.document&&this.document.getSelection();};CKEDITOR.editor.prototype.forceNextSelectionCheck=function()
{delete this._.selectionPreviousPath;};CKEDITOR.dom.document.prototype.getSelection=function()
{var sel=new CKEDITOR.dom.selection(this);return(!sel||sel.isInvalid)?null:sel;};CKEDITOR.SELECTION_NONE=1;CKEDITOR.SELECTION_TEXT=2;CKEDITOR.SELECTION_ELEMENT=3;CKEDITOR.dom.selection=function(document)
{var lockedSelection=document.getCustomData('cke_locked_selection');if(lockedSelection)
return lockedSelection;this.document=document;this.isLocked=0;this._={cache:{}};if(CKEDITOR.env.ie)
{var range=this.getNative().createRange();if(!range||(range.item&&range.item(0).ownerDocument!=this.document.$)||(range.parentElement&&range.parentElement().ownerDocument!=this.document.$))
{this.isInvalid=true;}}
return this;};var styleObjectElements={img:1,hr:1,li:1,table:1,tr:1,td:1,th:1,embed:1,object:1,ol:1,ul:1,a:1,input:1,form:1,select:1,textarea:1,button:1,fieldset:1,thead:1,tfoot:1};CKEDITOR.dom.selection.prototype={getNative:CKEDITOR.env.ie?function()
{return this._.cache.nativeSel||(this._.cache.nativeSel=this.document.$.selection);}:function()
{return this._.cache.nativeSel||(this._.cache.nativeSel=this.document.getWindow().$.getSelection());},getType:CKEDITOR.env.ie?function()
{var cache=this._.cache;if(cache.type)
return cache.type;var type=CKEDITOR.SELECTION_NONE;try
{var sel=this.getNative(),ieType=sel.type;if(ieType=='Text')
type=CKEDITOR.SELECTION_TEXT;if(ieType=='Control')
type=CKEDITOR.SELECTION_ELEMENT;if(sel.createRange().parentElement)
type=CKEDITOR.SELECTION_TEXT;}
catch(e){}
return(cache.type=type);}:function()
{var cache=this._.cache;if(cache.type)
return cache.type;var type=CKEDITOR.SELECTION_TEXT;var sel=this.getNative();if(!sel)
type=CKEDITOR.SELECTION_NONE;else if(sel.rangeCount==1)
{var range=sel.getRangeAt(0),startContainer=range.startContainer;if(startContainer==range.endContainer&&startContainer.nodeType==1&&(range.endOffset-range.startOffset)==1&&styleObjectElements[startContainer.childNodes[range.startOffset].nodeName.toLowerCase()])
{type=CKEDITOR.SELECTION_ELEMENT;}}
return(cache.type=type);},getRanges:(function()
{var func=CKEDITOR.env.ie?(function()
{function getNodeIndex(node){return new CKEDITOR.dom.node(node).getIndex();}
var getBoundaryInformation=function(range,start)
{range=range.duplicate();range.collapse(start);var parent=range.parentElement(),doc=parent.ownerDocument;if(!parent.hasChildNodes())
return{container:parent,offset:0};var siblings=parent.children,child,sibling,testRange=range.duplicate(),startIndex=0,endIndex=siblings.length-1,index=-1,position,distance;while(startIndex<=endIndex)
{index=Math.floor((startIndex+endIndex)/2);child=siblings[index];testRange.moveToElementText(child);position=testRange.compareEndPoints('StartToStart',range);if(position>0)
endIndex=index-1;else if(position<0)
startIndex=index+1;else
{if(CKEDITOR.env.ie9Compat&&child.tagName=='BR')
{var sel=doc.defaultView.getSelection();return{container:sel[start?'anchorNode':'focusNode'],offset:sel[start?'anchorOffset':'focusOffset']};}
else
return{container:parent,offset:getNodeIndex(child)};}}
if(index==-1||index==siblings.length-1&&position<0)
{testRange.moveToElementText(parent);testRange.setEndPoint('StartToStart',range);distance=testRange.text.replace(/(\r\n|\r)/g,'\n').length;siblings=parent.childNodes;if(!distance)
{child=siblings[siblings.length-1];if(child.nodeType==CKEDITOR.NODE_ELEMENT)
return{container:parent,offset:siblings.length};else
return{container:child,offset:child.nodeValue.length};}
var i=siblings.length;while(distance>0)
distance-=siblings[--i].nodeValue.length;return{container:siblings[i],offset:-distance};}
else
{testRange.collapse(position>0?true:false);testRange.setEndPoint(position>0?'StartToStart':'EndToStart',range);distance=testRange.text.replace(/(\r\n|\r)/g,'\n').length;if(!distance)
return{container:parent,offset:getNodeIndex(child)+(position>0?0:1)};while(distance>0)
{try
{sibling=child[position>0?'previousSibling':'nextSibling'];distance-=sibling.nodeValue.length;child=sibling;}
catch(e)
{return{container:parent,offset:getNodeIndex(child)};}}
return{container:child,offset:position>0?-distance:child.nodeValue.length+distance};}};return function()
{var sel=this.getNative(),nativeRange=sel&&sel.createRange(),type=this.getType(),range;if(!sel)
return[];if(type==CKEDITOR.SELECTION_TEXT)
{range=new CKEDITOR.dom.range(this.document);var boundaryInfo=getBoundaryInformation(nativeRange,true);range.setStart(new CKEDITOR.dom.node(boundaryInfo.container),boundaryInfo.offset);boundaryInfo=getBoundaryInformation(nativeRange);range.setEnd(new CKEDITOR.dom.node(boundaryInfo.container),boundaryInfo.offset);if(range.endContainer.getPosition(range.startContainer)&CKEDITOR.POSITION_PRECEDING&&range.endOffset<=range.startContainer.getIndex())
{range.collapse();}
return[range];}
else if(type==CKEDITOR.SELECTION_ELEMENT)
{var retval=[];for(var i=0;i<nativeRange.length;i++)
{var element=nativeRange.item(i),parentElement=element.parentNode,j=0;range=new CKEDITOR.dom.range(this.document);for(;j<parentElement.childNodes.length&&parentElement.childNodes[j]!=element;j++)
{}
range.setStart(new CKEDITOR.dom.node(parentElement),j);range.setEnd(new CKEDITOR.dom.node(parentElement),j+1);retval.push(range);}
return retval;}
return[];};})():function()
{var ranges=[],range,doc=this.document,sel=this.getNative();if(!sel)
return ranges;if(!sel.rangeCount)
{range=new CKEDITOR.dom.range(doc);range.moveToElementEditStart(doc.getBody());ranges.push(range);}
for(var i=0;i<sel.rangeCount;i++)
{var nativeRange=sel.getRangeAt(i);range=new CKEDITOR.dom.range(doc);range.setStart(new CKEDITOR.dom.node(nativeRange.startContainer),nativeRange.startOffset);range.setEnd(new CKEDITOR.dom.node(nativeRange.endContainer),nativeRange.endOffset);ranges.push(range);}
return ranges;};return function(onlyEditables)
{var cache=this._.cache;if(cache.ranges&&!onlyEditables)
return cache.ranges;else if(!cache.ranges)
cache.ranges=new CKEDITOR.dom.rangeList(func.call(this));if(onlyEditables)
{var ranges=cache.ranges;for(var i=0;i<ranges.length;i++)
{var range=ranges[i];var parent=range.getCommonAncestor();if(parent.isReadOnly())
ranges.splice(i,1);if(range.collapsed)
continue;if(range.startContainer.isReadOnly())
{var current=range.startContainer;while(current)
{if(current.is('body')||!current.isReadOnly())
break;if(current.type==CKEDITOR.NODE_ELEMENT&&current.getAttribute('contentEditable')=='false')
range.setStartAfter(current);current=current.getParent();}}
var startContainer=range.startContainer,endContainer=range.endContainer,startOffset=range.startOffset,endOffset=range.endOffset,walkerRange=range.clone();if(startContainer&&startContainer.type==CKEDITOR.NODE_TEXT)
{if(startOffset>=startContainer.getLength())
walkerRange.setStartAfter(startContainer);else
walkerRange.setStartBefore(startContainer);}
if(endContainer&&endContainer.type==CKEDITOR.NODE_TEXT)
{if(!endOffset)
walkerRange.setEndBefore(endContainer);else
walkerRange.setEndAfter(endContainer);}
var walker=new CKEDITOR.dom.walker(walkerRange);walker.evaluator=function(node)
{if(node.type==CKEDITOR.NODE_ELEMENT&&node.isReadOnly())
{var newRange=range.clone();range.setEndBefore(node);if(range.collapsed)
ranges.splice(i--,1);if(!(node.getPosition(walkerRange.endContainer)&CKEDITOR.POSITION_CONTAINS))
{newRange.setStartAfter(node);if(!newRange.collapsed)
ranges.splice(i+1,0,newRange);}
return true;}
return false;};walker.next();}}
return cache.ranges;};})(),getStartElement:function()
{var cache=this._.cache;if(cache.startElement!==undefined)
return cache.startElement;var node,sel=this.getNative();switch(this.getType())
{case CKEDITOR.SELECTION_ELEMENT:return this.getSelectedElement();case CKEDITOR.SELECTION_TEXT:var range=this.getRanges()[0];if(range)
{if(!range.collapsed)
{range.optimize();while(1)
{var startContainer=range.startContainer,startOffset=range.startOffset;if(startOffset==(startContainer.getChildCount?startContainer.getChildCount():startContainer.getLength())&&!startContainer.isBlockBoundary())
range.setStartAfter(startContainer);else break;}
node=range.startContainer;if(node.type!=CKEDITOR.NODE_ELEMENT)
return node.getParent();node=node.getChild(range.startOffset);if(!node||node.type!=CKEDITOR.NODE_ELEMENT)
node=range.startContainer;else
{var child=node.getFirst();while(child&&child.type==CKEDITOR.NODE_ELEMENT)
{node=child;child=child.getFirst();}}}
else
{node=range.startContainer;if(node.type!=CKEDITOR.NODE_ELEMENT)
node=node.getParent();}
node=node.$;}}
return cache.startElement=(node?new CKEDITOR.dom.element(node):null);},getSelectedElement:function()
{var cache=this._.cache;if(cache.selectedElement!==undefined)
return cache.selectedElement;var self=this;var node=CKEDITOR.tools.tryThese(function()
{return self.getNative().createRange().item(0);},function()
{var root,retval,range=self.getRanges()[0],ancestor=range.getCommonAncestor(1,1),tags={table:1,ul:1,ol:1,dl:1};for(var t in tags)
{if(root=ancestor.getAscendant(t,1))
break;}
if(root)
{var testRange=new CKEDITOR.dom.range(this.document);testRange.setStartAt(root,CKEDITOR.POSITION_AFTER_START);testRange.setEnd(range.startContainer,range.startOffset);var enlargeables=CKEDITOR.tools.extend(tags,CKEDITOR.dtd.$listItem,CKEDITOR.dtd.$tableContent),walker=new CKEDITOR.dom.walker(testRange),guard=function(walker,isEnd)
{return function(node,isWalkOut)
{if(node.type==CKEDITOR.NODE_TEXT&&(!CKEDITOR.tools.trim(node.getText())||node.getParent().data('cke-bookmark')))
return true;var tag;if(node.type==CKEDITOR.NODE_ELEMENT)
{tag=node.getName();if(tag=='br'&&isEnd&&node.equals(node.getParent().getBogus()))
return true;if(isWalkOut&&tag in enlargeables||tag in CKEDITOR.dtd.$removeEmpty)
return true;}
walker.halted=1;return false;};};walker.guard=guard(walker);if(walker.checkBackward()&&!walker.halted)
{walker=new CKEDITOR.dom.walker(testRange);testRange.setStart(range.endContainer,range.endOffset);testRange.setEndAt(root,CKEDITOR.POSITION_BEFORE_END);walker.guard=guard(walker,1);if(walker.checkForward()&&!walker.halted)
retval=root.$;}}
if(!retval)
throw 0;return retval;},function()
{var range=self.getRanges()[0],enclosed,selected;for(var i=2;i&&!((enclosed=range.getEnclosedNode())&&(enclosed.type==CKEDITOR.NODE_ELEMENT)&&styleObjectElements[enclosed.getName()]&&(selected=enclosed));i--)
{range.shrink(CKEDITOR.SHRINK_ELEMENT);}
return selected.$;});return cache.selectedElement=(node?new CKEDITOR.dom.element(node):null);},getSelectedText:function()
{var cache=this._.cache;if(cache.selectedText!==undefined)
return cache.selectedText;var text='',nativeSel=this.getNative();if(this.getType()==CKEDITOR.SELECTION_TEXT)
text=CKEDITOR.env.ie?nativeSel.createRange().text:nativeSel.toString();return(cache.selectedText=text);},lock:function()
{this.getRanges();this.getStartElement();this.getSelectedElement();this.getSelectedText();this._.cache.nativeSel={};this.isLocked=1;this.document.setCustomData('cke_locked_selection',this);},unlock:function(restore)
{var doc=this.document,lockedSelection=doc.getCustomData('cke_locked_selection');if(lockedSelection)
{doc.setCustomData('cke_locked_selection',null);if(restore)
{var selectedElement=lockedSelection.getSelectedElement(),ranges=!selectedElement&&lockedSelection.getRanges();this.isLocked=0;this.reset();doc.getBody().focus();if(selectedElement)
this.selectElement(selectedElement);else
this.selectRanges(ranges);}}
if(!lockedSelection||!restore)
{this.isLocked=0;this.reset();}},reset:function()
{this._.cache={};},selectElement:function(element)
{if(this.isLocked)
{var range=new CKEDITOR.dom.range(this.document);range.setStartBefore(element);range.setEndAfter(element);this._.cache.selectedElement=element;this._.cache.startElement=element;this._.cache.ranges=new CKEDITOR.dom.rangeList(range);this._.cache.type=CKEDITOR.SELECTION_ELEMENT;return;}
range=new CKEDITOR.dom.range(element.getDocument());range.setStartBefore(element);range.setEndAfter(element);range.select();this.document.fire('selectionchange');this.reset();},selectRanges:function(ranges)
{if(this.isLocked)
{this._.cache.selectedElement=null;this._.cache.startElement=ranges[0]&&ranges[0].getTouchedStartNode();this._.cache.ranges=new CKEDITOR.dom.rangeList(ranges);this._.cache.type=CKEDITOR.SELECTION_TEXT;return;}
if(CKEDITOR.env.ie)
{if(ranges.length>1)
{var last=ranges[ranges.length-1];ranges[0].setEnd(last.endContainer,last.endOffset);ranges.length=1;}
if(ranges[0])
ranges[0].select();this.reset();}
else
{var sel=this.getNative();if(!sel)
return;if(ranges.length)
{sel.removeAllRanges();CKEDITOR.env.webkit&&removeFillingChar(this.document);}
for(var i=0;i<ranges.length;i++)
{if(i<ranges.length-1)
{var left=ranges[i],right=ranges[i+1],between=left.clone();between.setStart(left.endContainer,left.endOffset);between.setEnd(right.startContainer,right.startOffset);if(!between.collapsed)
{between.shrink(CKEDITOR.NODE_ELEMENT,true);var ancestor=between.getCommonAncestor(),enclosed=between.getEnclosedNode();if(ancestor.isReadOnly()||enclosed&&enclosed.isReadOnly())
{right.setStart(left.startContainer,left.startOffset);ranges.splice(i--,1);continue;}}}
var range=ranges[i];var nativeRange=this.document.$.createRange();var startContainer=range.startContainer;if(range.collapsed&&(CKEDITOR.env.opera||(CKEDITOR.env.gecko&&CKEDITOR.env.version<10900))&&startContainer.type==CKEDITOR.NODE_ELEMENT&&!startContainer.getChildCount())
{startContainer.appendText('');}
if(range.collapsed&&CKEDITOR.env.webkit&&rangeRequiresFix(range))
{var fillingChar=createFillingChar(this.document);range.insertNode(fillingChar);var next=fillingChar.getNext();if(next&&!fillingChar.getPrevious()&&next.type==CKEDITOR.NODE_ELEMENT&&next.getName()=='br')
{removeFillingChar(this.document);range.moveToPosition(next,CKEDITOR.POSITION_BEFORE_START);}
else
range.moveToPosition(fillingChar,CKEDITOR.POSITION_AFTER_END);}
nativeRange.setStart(range.startContainer.$,range.startOffset);try
{nativeRange.setEnd(range.endContainer.$,range.endOffset);}
catch(e)
{if(e.toString().indexOf('NS_ERROR_ILLEGAL_VALUE')>=0)
{range.collapse(1);nativeRange.setEnd(range.endContainer.$,range.endOffset);}
else
throw e;}
sel.addRange(nativeRange);}
this.document.fire('selectionchange');this.reset();}},createBookmarks:function(serializable)
{return this.getRanges().createBookmarks(serializable);},createBookmarks2:function(normalized)
{return this.getRanges().createBookmarks2(normalized);},selectBookmarks:function(bookmarks)
{var ranges=[];for(var i=0;i<bookmarks.length;i++)
{var range=new CKEDITOR.dom.range(this.document);range.moveToBookmark(bookmarks[i]);ranges.push(range);}
this.selectRanges(ranges);return this;},getCommonAncestor:function()
{var ranges=this.getRanges(),startNode=ranges[0].startContainer,endNode=ranges[ranges.length-1].endContainer;return startNode.getCommonAncestor(endNode);},scrollIntoView:function()
{var start=this.getStartElement();start.scrollIntoView();}};})();(function()
{var notWhitespaces=CKEDITOR.dom.walker.whitespaces(true),fillerTextRegex=/\ufeff|\u00a0/,nonCells={table:1,tbody:1,tr:1};CKEDITOR.dom.range.prototype.select=CKEDITOR.env.ie?function(forceExpand)
{var collapsed=this.collapsed,isStartMarkerAlone,dummySpan,ieRange;var selected=this.getEnclosedNode();if(selected)
{try
{ieRange=this.document.$.body.createControlRange();ieRange.addElement(selected.$);ieRange.select();return;}
catch(er){}}
if(this.startContainer.type==CKEDITOR.NODE_ELEMENT&&this.startContainer.getName()in nonCells||this.endContainer.type==CKEDITOR.NODE_ELEMENT&&this.endContainer.getName()in nonCells)
{this.shrink(CKEDITOR.NODE_ELEMENT,true);}
var bookmark=this.createBookmark();var startNode=bookmark.startNode;var endNode;if(!collapsed)
endNode=bookmark.endNode;ieRange=this.document.$.body.createTextRange();ieRange.moveToElementText(startNode.$);ieRange.moveStart('character',1);if(endNode)
{var ieRangeEnd=this.document.$.body.createTextRange();ieRangeEnd.moveToElementText(endNode.$);ieRange.setEndPoint('EndToEnd',ieRangeEnd);ieRange.moveEnd('character',-1);}
else
{var next=startNode.getNext(notWhitespaces);isStartMarkerAlone=(!(next&&next.getText&&next.getText().match(fillerTextRegex))&&(forceExpand||!startNode.hasPrevious()||(startNode.getPrevious().is&&startNode.getPrevious().is('br'))));dummySpan=this.document.createElement('span');dummySpan.setHtml('&#65279;');dummySpan.insertBefore(startNode);if(isStartMarkerAlone)
{this.document.createText('\ufeff').insertBefore(startNode);}}
this.setStartBefore(startNode);startNode.remove();if(collapsed)
{if(isStartMarkerAlone)
{ieRange.moveStart('character',-1);ieRange.select();this.document.$.selection.clear();}
else
ieRange.select();this.moveToPosition(dummySpan,CKEDITOR.POSITION_BEFORE_START);dummySpan.remove();}
else
{this.setEndBefore(endNode);endNode.remove();ieRange.select();}
this.document.fire('selectionchange');}:function()
{this.document.getSelection().selectRanges([this]);};})();;(function()
{var cssStyle=CKEDITOR.htmlParser.cssStyle,cssLength=CKEDITOR.tools.cssLength;var cssLengthRegex=/^((?:\d*(?:\.\d+))|(?:\d+))(.*)?$/i;function replaceCssLength(length1,length2)
{var parts1=cssLengthRegex.exec(length1),parts2=cssLengthRegex.exec(length2);if(parts1)
{if(!parts1[2]&&parts2[2]=='px')
return parts2[1];if(parts1[2]=='px'&&!parts2[2])
return parts2[1]+'px';}
return length2;}
var htmlFilterRules={elements:{$:function(element)
{var attributes=element.attributes,realHtml=attributes&&attributes['data-cke-realelement'],realFragment=realHtml&&new CKEDITOR.htmlParser.fragment.fromHtml(decodeURIComponent(realHtml)),realElement=realFragment&&realFragment.children[0];if(realElement&&element.attributes['data-cke-resizable'])
{var styles=new cssStyle(element).rules,realAttrs=realElement.attributes,width=styles.width,height=styles.height;width&&(realAttrs.width=replaceCssLength(realAttrs.width,width));height&&(realAttrs.height=replaceCssLength(realAttrs.height,height));}
return realElement;}}};CKEDITOR.plugins.add('fakeobjects',{requires:['htmlwriter'],afterInit:function(editor)
{var dataProcessor=editor.dataProcessor,htmlFilter=dataProcessor&&dataProcessor.htmlFilter;if(htmlFilter)
htmlFilter.addRules(htmlFilterRules);}});CKEDITOR.editor.prototype.createFakeElement=function(realElement,className,realElementType,isResizable)
{var lang=this.lang.fakeobjects,label=lang[realElementType]||lang.unknown;var attributes={'class':className,src:CKEDITOR.getUrl('images/spacer.gif'),'data-cke-realelement':encodeURIComponent(realElement.getOuterHtml()),'data-cke-real-node-type':realElement.type,alt:label,title:label,align:realElement.getAttribute('align')||''};if(realElementType)
attributes['data-cke-real-element-type']=realElementType;if(isResizable)
{attributes['data-cke-resizable']=isResizable;var fakeStyle=new cssStyle();var width=realElement.getAttribute('width'),height=realElement.getAttribute('height');width&&(fakeStyle.rules.width=cssLength(width));height&&(fakeStyle.rules.height=cssLength(height));fakeStyle.populate(attributes);}
return this.document.createElement('img',{attributes:attributes});};CKEDITOR.editor.prototype.createFakeParserElement=function(realElement,className,realElementType,isResizable)
{var lang=this.lang.fakeobjects,label=lang[realElementType]||lang.unknown,html;var writer=new CKEDITOR.htmlParser.basicWriter();realElement.writeHtml(writer);html=writer.getHtml();var attributes={'class':className,src:CKEDITOR.getUrl('images/spacer.gif'),'data-cke-realelement':encodeURIComponent(html),'data-cke-real-node-type':realElement.type,alt:label,title:label,align:realElement.attributes.align||''};if(realElementType)
attributes['data-cke-real-element-type']=realElementType;if(isResizable)
{attributes['data-cke-resizable']=isResizable;var realAttrs=realElement.attributes,fakeStyle=new cssStyle();var width=realAttrs.width,height=realAttrs.height;width!=undefined&&(fakeStyle.rules.width=cssLength(width));height!=undefined&&(fakeStyle.rules.height=cssLength(height));fakeStyle.populate(attributes);}
return new CKEDITOR.htmlParser.element('img',attributes);};CKEDITOR.editor.prototype.restoreRealElement=function(fakeElement)
{if(fakeElement.data('cke-real-node-type')!=CKEDITOR.NODE_ELEMENT)
return null;var element=CKEDITOR.dom.element.createFromHtml(decodeURIComponent(fakeElement.data('cke-realelement')),this.document);if(fakeElement.data('cke-resizable'))
{var width=fakeElement.getStyle('width'),height=fakeElement.getStyle('height');width&&element.setAttribute('width',replaceCssLength(element.getAttribute('width'),width));height&&element.setAttribute('height',replaceCssLength(element.getAttribute('height'),height));}
return element;};})();;CKEDITOR.plugins.add('richcombo',{requires:['floatpanel','listblock','button'],beforeInit:function(editor)
{editor.ui.addHandler(CKEDITOR.UI_RICHCOMBO,CKEDITOR.ui.richCombo.handler);}});CKEDITOR.UI_RICHCOMBO='richcombo';CKEDITOR.ui.richCombo=CKEDITOR.tools.createClass({$:function(definition)
{CKEDITOR.tools.extend(this,definition,{title:definition.label,modes:{wysiwyg:1}});var panelDefinition=this.panel||{};delete this.panel;this.id=CKEDITOR.tools.getNextNumber();this.document=(panelDefinition&&panelDefinition.parent&&panelDefinition.parent.getDocument())||CKEDITOR.document;panelDefinition.className=(panelDefinition.className||'')+' cke_rcombopanel';panelDefinition.block={multiSelect:panelDefinition.multiSelect,attributes:panelDefinition.attributes};this._={panelDefinition:panelDefinition,items:{},state:CKEDITOR.TRISTATE_OFF};},statics:{handler:{create:function(definition)
{return new CKEDITOR.ui.richCombo(definition);}}},proto:{renderHtml:function(editor)
{var output=[];this.render(editor,output);return output.join('');},render:function(editor,output)
{var env=CKEDITOR.env;var id='cke_'+this.id;var clickFn=CKEDITOR.tools.addFunction(function($element)
{var _=this._;if(_.state==CKEDITOR.TRISTATE_DISABLED)
return;if(_.justHidden==true)
return;this.createPanel(editor);if(_.on)
{_.panel.hide();return;}
this.commit();var value=this.getValue();if(value)
_.list.mark(value);else
_.list.unmarkAll();_.panel.showBlock(this.id,new CKEDITOR.dom.element($element),4);},this);var instance={id:id,combo:this,focus:function()
{var element=CKEDITOR.document.getById(id).getChild(1);element.focus();},clickFn:clickFn};function updateState()
{var state=this.modes[editor.mode]?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED;this.setState(editor.readOnly&&!this.readOnly?CKEDITOR.TRISTATE_DISABLED:state);this.setValue('');}
editor.on('mode',updateState,this);!this.readOnly&&editor.on('readOnly',updateState,this);var keyDownFn=CKEDITOR.tools.addFunction(function(ev,element)
{ev=new CKEDITOR.dom.event(ev);var keystroke=ev.getKeystroke();switch(keystroke)
{case 13:case 32:case 40:CKEDITOR.tools.callFunction(clickFn,element);break;default:instance.onkey(instance,keystroke);}
ev.preventDefault();});var focusFn=CKEDITOR.tools.addFunction(function(){instance.onfocus&&instance.onfocus();});instance.keyDownFn=keyDownFn;output.push('<span class="cke_rcombo" role="presentation">','<span id=',id);if(this.className)
output.push(' class="',this.className,' cke_off"');output.push(' role="presentation">','<span id="'+id+'_label" class=cke_label>',this.label,'</span>','<a hidefocus=true title="',this.title,'" tabindex="-1"',env.gecko&&env.version>=10900&&!env.hc?'':' href="javascript:void(\''+this.label+'\')"',' role="button" aria-labelledby="',id,'_label" aria-describedby="',id,'_text" aria-haspopup="true"');if(CKEDITOR.env.opera||(CKEDITOR.env.gecko&&CKEDITOR.env.mac))
{output.push(' onkeypress="return false;"');}
if(CKEDITOR.env.gecko)
{output.push(' onblur="this.style.cssText = this.style.cssText;"');}
output.push(' onkeydown="CKEDITOR.tools.callFunction( ',keyDownFn,', event, this );"'+' onfocus="return CKEDITOR.tools.callFunction(',focusFn,', event);" '+
(CKEDITOR.env.ie?'onclick="return false;" onmouseup':'onclick')+'="CKEDITOR.tools.callFunction(',clickFn,', this); return false;">'+'<span>'+'<span id="'+id+'_text" class="cke_text cke_inline_label">'+this.label+'</span>'+'</span>'+'<span class=cke_openbutton><span class=cke_icon>'+(CKEDITOR.env.hc?'&#9660;':CKEDITOR.env.air?'&nbsp;':'')+'</span></span>'+'</a>'+'</span>'+'</span>');if(this.onRender)
this.onRender();return instance;},createPanel:function(editor)
{if(this._.panel)
return;if(editor.config.richcomboCss!=''){this._.panelDefinition.css=[editor.config.richcomboCss];}
var panelDefinition=this._.panelDefinition,panelBlockDefinition=this._.panelDefinition.block,panelParentElement=panelDefinition.parent||CKEDITOR.document.getBody(),panel=new CKEDITOR.ui.floatPanel(editor,panelParentElement,panelDefinition),list=panel.addListBlock(this.id,panelBlockDefinition),me=this;panel.onShow=function()
{editor.fire('panelShow',{panel:this,me:me});me.document.getById('cke_'+me.id).getParent().addClass('cke_opened');if(me.className)
this.element.getFirst().addClass(me.className+'_panel');me.setState(CKEDITOR.TRISTATE_ON);list.focus(!me.multiSelect&&me.getValue());me._.on=1;if(me.onOpen)
me.onOpen();};panel.onHide=function(preventOnClose)
{me.document.getById('cke_'+me.id).getParent().removeClass('cke_opened');if(me.className)
this.element.getFirst().removeClass(me.className+'_panel');me.setState(me.modes&&me.modes[editor.mode]?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED);me._.on=0;if(!preventOnClose&&me.onClose)
me.onClose();me._.justHidden=true;setTimeout(function(){me._.justHidden=false;},400);};panel.onEscape=function()
{panel.hide();};list.onClick=function(value,marked)
{editor.fire('panelClick',{panel:this,me:me,value:value});me.document.getWindow().focus();if(me.onClick)
me.onClick.call(me,value,marked);if(marked)
me.setValue(value,me._.items[value]);else
me.setValue('');panel.hide(false);};this._.panel=panel;this._.list=list;panel.getBlock(this.id).onHide=function()
{me._.on=0;me.setState(CKEDITOR.TRISTATE_OFF);};editor.on('toolbartabswitch',function(){if(me._.on){panel.hide();}});if(this.init)
this.init();},setValue:function(value,text)
{this._.value=value;var textElement=this.document.getById('cke_'+this.id+'_text');if(textElement)
{if(!(value||text))
{text=this.label;textElement.addClass('cke_inline_label');}
else
textElement.removeClass('cke_inline_label');textElement.setHtml(typeof text!='undefined'?text:value);}},getValue:function()
{return this._.value||'';},unmarkAll:function()
{this._.list.unmarkAll();},mark:function(value)
{this._.list.mark(value);},hideItem:function(value)
{this._.list.hideItem(value);},hideGroup:function(groupTitle)
{this._.list.hideGroup(groupTitle);},showAll:function()
{this._.list.showAll();},add:function(value,html,text)
{this._.items[value]=text||value;this._.list.add(value,html,text);},startGroup:function(title)
{this._.list.startGroup(title);},commit:function()
{if(!this._.committed)
{this._.list.commit();this._.committed=1;CKEDITOR.ui.fire('ready',this);}
this._.committed=1;},setState:function(state)
{if(this._.state==state)
return;this.document.getById('cke_'+this.id).setState(state);this._.state=state;}}});CKEDITOR.ui.prototype.addRichCombo=function(name,definition)
{this.add(name,CKEDITOR.UI_RICHCOMBO,definition);};CKEDITOR.config.richcomboCss='';;CKEDITOR.plugins.add('htmlwriter');CKEDITOR.htmlWriter=CKEDITOR.tools.createClass({base:CKEDITOR.htmlParser.basicWriter,$:function()
{this.base();this.indentationChars='\t';this.selfClosingEnd=' />';this.lineBreakChars='\n';this.forceSimpleAmpersand=0;this.sortAttributes=1;this._.indent=0;this._.indentation='';this._.inPre=0;this._.rules={};var dtd=CKEDITOR.dtd;for(var e in CKEDITOR.tools.extend({},dtd.$nonBodyContent,dtd.$block,dtd.$listItem,dtd.$tableContent))
{this.setRules(e,{indent:1,breakBeforeOpen:1,breakAfterOpen:1,breakBeforeClose:!dtd[e]['#'],breakAfterClose:1});}
this.setRules('br',{breakAfterOpen:1});this.setRules('title',{indent:0,breakAfterOpen:0});this.setRules('style',{indent:0,breakBeforeClose:1});this.setRules('pre',{indent:0});},proto:{openTag:function(tagName,attributes)
{var rules=this._.rules[tagName];if(this._.indent)
this.indentation();else if(rules&&rules.breakBeforeOpen)
{this.lineBreak();this.indentation();}
this._.output.push('<',tagName);},openTagClose:function(tagName,isSelfClose)
{var rules=this._.rules[tagName];if(isSelfClose)
this._.output.push(this.selfClosingEnd);else
{this._.output.push('>');if(rules&&rules.indent)
this._.indentation+=this.indentationChars;}
if(rules&&rules.breakAfterOpen)
this.lineBreak();tagName=='pre'&&(this._.inPre=1);},attribute:function(attName,attValue)
{if(typeof attValue=='string')
{this.forceSimpleAmpersand&&(attValue=attValue.replace(/&amp;/g,'&'));attValue=CKEDITOR.tools.htmlEncodeAttr(attValue);}
this._.output.push(' ',attName,'="',attValue,'"');},closeTag:function(tagName)
{var rules=this._.rules[tagName];if(rules&&rules.indent)
this._.indentation=this._.indentation.substr(this.indentationChars.length);if(this._.indent)
this.indentation();else if(rules&&rules.breakBeforeClose)
{this.lineBreak();this.indentation();}
this._.output.push('</',tagName,'>');tagName=='pre'&&(this._.inPre=0);if(rules&&rules.breakAfterClose)
this.lineBreak();},text:function(text)
{if(this._.indent)
{this.indentation();!this._.inPre&&(text=CKEDITOR.tools.ltrim(text));}
this._.output.push(text);},comment:function(comment)
{if(this._.indent)
this.indentation();this._.output.push('<!--',comment,'-->');},lineBreak:function()
{if(!this._.inPre&&this._.output.length>0)
this._.output.push(this.lineBreakChars);this._.indent=1;},indentation:function()
{if(!this._.inPre)
this._.output.push(this._.indentation);this._.indent=0;},setRules:function(tagName,rules)
{var currentRules=this._.rules[tagName];if(currentRules)
CKEDITOR.tools.extend(currentRules,rules,true);else
this._.rules[tagName]=rules;}}});;CKEDITOR.plugins.add('menubutton',{requires:['button','menu'],beforeInit:function(editor)
{editor.ui.addHandler(CKEDITOR.UI_MENUBUTTON,CKEDITOR.ui.menuButton.handler);}});CKEDITOR.UI_MENUBUTTON='menubutton';(function()
{var clickFn=function(editor)
{var _=this._;if(_.state===CKEDITOR.TRISTATE_DISABLED)
return;_.previousState=_.state;var menu=_.menu;if(!menu)
{menu=_.menu=new CKEDITOR.menu(editor,{panel:{className:editor.skinClass+' cke_contextmenu',attributes:{'aria-label':editor.lang.common.options}}});menu.onHide=CKEDITOR.tools.bind(function()
{this.setState(this.modes&&this.modes[editor.mode]?_.previousState:CKEDITOR.TRISTATE_DISABLED);},this);if(this.onMenu)
menu.addListener(this.onMenu);}
if(_.on)
{menu.hide();return;}
this.setState(CKEDITOR.TRISTATE_ON);menu.show(CKEDITOR.document.getById(this._.id),4);};CKEDITOR.ui.menuButton=CKEDITOR.tools.createClass({base:CKEDITOR.ui.button,$:function(definition)
{var panelDefinition=definition.panel;delete definition.panel;this.base(definition);this.hasArrow=true;this.click=clickFn;},statics:{handler:{create:function(definition)
{return new CKEDITOR.ui.menuButton(definition);}}}});})();;CKEDITOR.plugins.add('dialogui');(function()
{var initPrivateObject=function(elementDefinition)
{this._||(this._={});this._['default']=this._.initValue=elementDefinition['default']||'';this._.required=elementDefinition['required']||false;var args=[this._];for(var i=1;i<arguments.length;i++)
args.push(arguments[i]);args.push(true);CKEDITOR.tools.extend.apply(CKEDITOR.tools,args);return this._;},textBuilder={build:function(dialog,elementDefinition,output)
{return new CKEDITOR.ui.dialog.textInput(dialog,elementDefinition,output);}},commonBuilder={build:function(dialog,elementDefinition,output)
{return new CKEDITOR.ui.dialog[elementDefinition.type](dialog,elementDefinition,output);}},containerBuilder={build:function(dialog,elementDefinition,output)
{var children=elementDefinition.children,child,childHtmlList=[],childObjList=[];for(var i=0;(i<children.length&&(child=children[i]));i++)
{var childHtml=[];childHtmlList.push(childHtml);childObjList.push(CKEDITOR.dialog._.uiElementBuilders[child.type].build(dialog,child,childHtml));}
return new CKEDITOR.ui.dialog[elementDefinition.type](dialog,childObjList,childHtmlList,output,elementDefinition);}},commonPrototype={isChanged:function()
{return this.getValue()!=this.getInitValue();},reset:function(noChangeEvent)
{this.setValue(this.getInitValue(),noChangeEvent);},setInitValue:function()
{this._.initValue=this.getValue();},resetInitValue:function()
{this._.initValue=this._['default'];},getInitValue:function()
{return this._.initValue;}},commonEventProcessors=CKEDITOR.tools.extend({},CKEDITOR.ui.dialog.uiElement.prototype.eventProcessors,{onChange:function(dialog,func)
{if(!this._.domOnChangeRegistered)
{dialog.on('load',function()
{this.getInputElement().on('change',function()
{if(!dialog.parts.dialog.isVisible())
return;this.fire('change',{value:this.getValue()});},this);},this);this._.domOnChangeRegistered=true;}
this.on('change',func);}},true),eventRegex=/^on([A-Z]\w+)/,cleanInnerDefinition=function(def)
{for(var i in def)
{if(eventRegex.test(i)||i=='title'||i=='type')
delete def[i];}
return def;};CKEDITOR.tools.extend(CKEDITOR.ui.dialog,{labeledElement:function(dialog,elementDefinition,htmlList,contentHtml)
{if(arguments.length<4)
return;var _=initPrivateObject.call(this,elementDefinition);_.labelId=CKEDITOR.tools.getNextId()+'_label';var children=this._.children=[];var innerHTML=function()
{var html=[],requiredClass=elementDefinition.required?' cke_required':'';if(elementDefinition.labelLayout!='horizontal')
html.push('<label class="cke_dialog_ui_labeled_label'+requiredClass+'" ',' id="'+_.labelId+'"',' for="'+_.inputId+'"',(elementDefinition.labelStyle?' style="'+elementDefinition.labelStyle+'"':'')+'>',elementDefinition.label,'</label>','<div class="cke_dialog_ui_labeled_content"'+(elementDefinition.controlStyle?' style="'+elementDefinition.controlStyle+'"':'')+' role="presentation">',contentHtml.call(this,dialog,elementDefinition),'</div>');else
{var hboxDefinition={type:'hbox',widths:elementDefinition.widths,padding:0,children:[{type:'html',html:'<label class="cke_dialog_ui_labeled_label'+requiredClass+'"'+' id="'+_.labelId+'"'+' for="'+_.inputId+'"'+
(elementDefinition.labelStyle?' style="'+elementDefinition.labelStyle+'"':'')+'>'+
CKEDITOR.tools.htmlEncode(elementDefinition.label)+'</span>'},{type:'html',html:'<span class="cke_dialog_ui_labeled_content"'+(elementDefinition.controlStyle?' style="'+elementDefinition.controlStyle+'"':'')+'>'+
contentHtml.call(this,dialog,elementDefinition)+'</span>'}]};CKEDITOR.dialog._.uiElementBuilders.hbox.build(dialog,hboxDefinition,html);}
return html.join('');};CKEDITOR.ui.dialog.uiElement.call(this,dialog,elementDefinition,htmlList,'div',null,{role:'presentation'},innerHTML);},textInput:function(dialog,elementDefinition,htmlList)
{if(arguments.length<3)
return;initPrivateObject.call(this,elementDefinition);var domId=this._.inputId=CKEDITOR.tools.getNextId()+'_textInput',attributes={'class':'cke_dialog_ui_input_'+elementDefinition.type,id:domId,type:'text'},i;if(elementDefinition.validate)
this.validate=elementDefinition.validate;if(elementDefinition.maxLength)
attributes.maxlength=elementDefinition.maxLength;if(elementDefinition.size)
attributes.size=elementDefinition.size;if(elementDefinition.inputStyle)
attributes.style=elementDefinition.inputStyle;var me=this,keyPressedOnMe=false;dialog.on('load',function()
{me.getInputElement().on('keydown',function(evt)
{if(evt.data.getKeystroke()==13)
keyPressedOnMe=true;});me.getInputElement().on('keyup',function(evt)
{if(evt.data.getKeystroke()==13&&keyPressedOnMe)
{dialog.getButton('ok')&&setTimeout(function()
{dialog.getButton('ok').click();},0);keyPressedOnMe=false;}},null,null,1000);});var innerHTML=function()
{var html=['<div class="cke_dialog_ui_input_',elementDefinition.type,'" role="presentation"'];if(elementDefinition.width)
html.push('style="width:'+elementDefinition.width+'" ');html.push('><input ');attributes['aria-labelledby']=this._.labelId;this._.required&&(attributes['aria-required']=this._.required);for(var i in attributes)
html.push(i+'="'+attributes[i]+'" ');html.push(' /></div>');return html.join('');};CKEDITOR.ui.dialog.labeledElement.call(this,dialog,elementDefinition,htmlList,innerHTML);},textarea:function(dialog,elementDefinition,htmlList)
{if(arguments.length<3)
return;initPrivateObject.call(this,elementDefinition);var me=this,domId=this._.inputId=CKEDITOR.tools.getNextId()+'_textarea',attributes={};if(elementDefinition.validate)
this.validate=elementDefinition.validate;attributes.rows=elementDefinition.rows||5;attributes.cols=elementDefinition.cols||20;if(typeof elementDefinition.inputStyle!='undefined')
attributes.style=elementDefinition.inputStyle;var innerHTML=function()
{attributes['aria-labelledby']=this._.labelId;this._.required&&(attributes['aria-required']=this._.required);var html=['<div class="cke_dialog_ui_input_textarea" role="presentation"><textarea class="cke_dialog_ui_input_textarea" id="',domId,'" '];for(var i in attributes)
html.push(i+'="'+CKEDITOR.tools.htmlEncode(attributes[i])+'" ');html.push('>',CKEDITOR.tools.htmlEncode(me._['default']),'</textarea></div>');return html.join('');};CKEDITOR.ui.dialog.labeledElement.call(this,dialog,elementDefinition,htmlList,innerHTML);},checkbox:function(dialog,elementDefinition,htmlList)
{if(arguments.length<3)
return;var _=initPrivateObject.call(this,elementDefinition,{'default':!!elementDefinition['default']});if(elementDefinition.validate)
this.validate=elementDefinition.validate;var innerHTML=function()
{var myDefinition=CKEDITOR.tools.extend({},elementDefinition,{id:elementDefinition.id?elementDefinition.id+'_checkbox':CKEDITOR.tools.getNextId()+'_checkbox'},true),html=[];var labelId=CKEDITOR.tools.getNextId()+'_label';var attributes={'class':'cke_dialog_ui_checkbox_input',type:'checkbox','aria-labelledby':labelId};cleanInnerDefinition(myDefinition);if(elementDefinition['default'])
attributes.checked='checked';if(typeof myDefinition.inputStyle!='undefined')
myDefinition.style=myDefinition.inputStyle;_.checkbox=new CKEDITOR.ui.dialog.uiElement(dialog,myDefinition,html,'input',null,attributes);html.push(' <label id="',labelId,'" for="',attributes.id,'"'+(elementDefinition.labelStyle?' style="'+elementDefinition.labelStyle+'"':'')+'>',CKEDITOR.tools.htmlEncode(elementDefinition.label),'</label>');return html.join('');};CKEDITOR.ui.dialog.uiElement.call(this,dialog,elementDefinition,htmlList,'span',null,null,innerHTML);},radio:function(dialog,elementDefinition,htmlList)
{if(arguments.length<3)
return;initPrivateObject.call(this,elementDefinition);if(!this._['default'])
this._['default']=this._.initValue=elementDefinition.items[0][1];if(elementDefinition.validate)
this.validate=elementDefinition.valdiate;var children=[],me=this;var innerHTML=function()
{var inputHtmlList=[],html=[],commonAttributes={'class':'cke_dialog_ui_radio_item','aria-labelledby':this._.labelId},commonName=elementDefinition.id?elementDefinition.id+'_radio':CKEDITOR.tools.getNextId()+'_radio';for(var i=0;i<elementDefinition.items.length;i++)
{var item=elementDefinition.items[i],title=item[2]!==undefined?item[2]:item[0],value=item[1]!==undefined?item[1]:item[0],inputId=CKEDITOR.tools.getNextId()+'_radio_input',labelId=inputId+'_label',inputDefinition=CKEDITOR.tools.extend({},elementDefinition,{id:inputId,title:null,type:null},true),labelDefinition=CKEDITOR.tools.extend({},inputDefinition,{title:title},true),inputAttributes={type:'radio','class':'cke_dialog_ui_radio_input',name:commonName,value:value,'aria-labelledby':labelId},inputHtml=[];if(me._['default']==value)
inputAttributes.checked='checked';cleanInnerDefinition(inputDefinition);cleanInnerDefinition(labelDefinition);if(typeof inputDefinition.inputStyle!='undefined')
inputDefinition.style=inputDefinition.inputStyle;children.push(new CKEDITOR.ui.dialog.uiElement(dialog,inputDefinition,inputHtml,'input',null,inputAttributes));inputHtml.push(' ');new CKEDITOR.ui.dialog.uiElement(dialog,labelDefinition,inputHtml,'label',null,{id:labelId,'for':inputAttributes.id},item[0]);inputHtmlList.push(inputHtml.join(''));}
new CKEDITOR.ui.dialog.hbox(dialog,[],inputHtmlList,html);return html.join('');};CKEDITOR.ui.dialog.labeledElement.call(this,dialog,elementDefinition,htmlList,innerHTML);this._.children=children;},button:function(dialog,elementDefinition,htmlList)
{if(!arguments.length)
return;if(typeof elementDefinition=='function')
elementDefinition=elementDefinition(dialog.getParentEditor());initPrivateObject.call(this,elementDefinition,{disabled:elementDefinition.disabled||false});CKEDITOR.event.implementOn(this);var me=this;dialog.on('load',function(eventInfo)
{var element=this.getElement();(function()
{element.on('click',function(evt)
{me.fire('click',{dialog:me.getDialog()});evt.data.preventDefault();});element.on('keydown',function(evt)
{if(evt.data.getKeystroke()in{32:1})
{me.click();evt.data.preventDefault();}});})();element.unselectable();},this);if(typeof elementDefinition['class']!='undefined'){elementDefinition['class']=elementDefinition['class'].replace(/cke_dialog_ui_button_cancel/,'secondary').replace(/cke_dialog_ui_button_(\w+)/,'')
+' wikia-button';}
if(typeof elementDefinition['className']!='undefined'){elementDefinition['className']+=' wikia-button';if(typeof elementDefinition['buttonType']!='undefined'){elementDefinition['className']+=' '+elementDefinition['buttonType'];}}
else{elementDefinition['className']='wikia-button';}
var outerDefinition=CKEDITOR.tools.extend({},elementDefinition);delete outerDefinition.style;var labelId=CKEDITOR.tools.getNextId()+'_label';CKEDITOR.ui.dialog.uiElement.call(this,dialog,outerDefinition,htmlList,'a',null,{style:elementDefinition.style,href:'javascript:void(0)',title:elementDefinition.label,hidefocus:'true','class':elementDefinition['class'],role:'button','aria-labelledby':labelId},'<span id="'+labelId+'" class="cke_dialog_ui_button">'+
CKEDITOR.tools.htmlEncode(elementDefinition.label)+'</span>');},select:function(dialog,elementDefinition,htmlList)
{if(arguments.length<3)
return;var _=initPrivateObject.call(this,elementDefinition);if(elementDefinition.validate)
this.validate=elementDefinition.validate;_.inputId=CKEDITOR.tools.getNextId()+'_select';var innerHTML=function()
{var myDefinition=CKEDITOR.tools.extend({},elementDefinition,{id:elementDefinition.id?elementDefinition.id+'_select':CKEDITOR.tools.getNextId()+'_select'},true),html=[],innerHTML=[],attributes={'id':_.inputId,'class':'cke_dialog_ui_input_select','aria-labelledby':this._.labelId};if(elementDefinition.size!=undefined)
attributes.size=elementDefinition.size;if(elementDefinition.multiple!=undefined)
attributes.multiple=elementDefinition.multiple;cleanInnerDefinition(myDefinition);for(var i=0,item;i<elementDefinition.items.length&&(item=elementDefinition.items[i]);i++)
{innerHTML.push('<option value="',CKEDITOR.tools.htmlEncode(item[1]!==undefined?item[1]:item[0]).replace(/"/g,'&quot;'),'" /> ',CKEDITOR.tools.htmlEncode(item[0]));}
if(typeof myDefinition.inputStyle!='undefined')
myDefinition.style=myDefinition.inputStyle;_.select=new CKEDITOR.ui.dialog.uiElement(dialog,myDefinition,html,'select',null,attributes,innerHTML.join(''));return html.join('');};CKEDITOR.ui.dialog.labeledElement.call(this,dialog,elementDefinition,htmlList,innerHTML);},file:function(dialog,elementDefinition,htmlList)
{if(arguments.length<3)
return;if(elementDefinition['default']===undefined)
elementDefinition['default']='';var _=CKEDITOR.tools.extend(initPrivateObject.call(this,elementDefinition),{definition:elementDefinition,buttons:[]});if(elementDefinition.validate)
this.validate=elementDefinition.validate;var innerHTML=function()
{_.frameId=CKEDITOR.tools.getNextId()+'_fileInput';var isCustomDomain=CKEDITOR.env.isCustomDomain();var html=['<iframe'+' frameborder="0"'+' allowtransparency="0"'+' class="cke_dialog_ui_input_file"'+' id="',_.frameId,'"'+' title="',elementDefinition.label,'"'+' src="javascript:void('];html.push(isCustomDomain?'(function(){'+'document.open();'+'document.domain=\''+document.domain+'\';'+'document.close();'+'})()':'0');html.push(')">'+'</iframe>');return html.join('');};dialog.on('load',function()
{var iframe=CKEDITOR.document.getById(_.frameId),contentDiv=iframe.getParent();contentDiv.addClass('cke_dialog_ui_input_file');});CKEDITOR.ui.dialog.labeledElement.call(this,dialog,elementDefinition,htmlList,innerHTML);},fileButton:function(dialog,elementDefinition,htmlList)
{if(arguments.length<3)
return;var _=initPrivateObject.call(this,elementDefinition),me=this;if(elementDefinition.validate)
this.validate=elementDefinition.validate;var myDefinition=CKEDITOR.tools.extend({},elementDefinition);var onClick=myDefinition.onClick;myDefinition.className=(myDefinition.className?myDefinition.className+' ':'')+'cke_dialog_ui_button';myDefinition.onClick=function(evt)
{var target=elementDefinition['for'];if(!onClick||onClick.call(this,evt)!==false)
{dialog.getContentElement(target[0],target[1]).submit();this.disable();}};dialog.on('load',function()
{dialog.getContentElement(elementDefinition['for'][0],elementDefinition['for'][1])._.buttons.push(me);});CKEDITOR.ui.dialog.button.call(this,dialog,myDefinition,htmlList);},html:(function()
{var myHtmlRe=/^\s*<[\w:]+\s+([^>]*)?>/,theirHtmlRe=/^(\s*<[\w:]+(?:\s+[^>]*)?)((?:.|\r|\n)+)$/,emptyTagRe=/\/$/;return function(dialog,elementDefinition,htmlList)
{if(arguments.length<3)
return;var myHtmlList=[],myHtml,theirHtml=elementDefinition.html,myMatch,theirMatch;if(theirHtml.charAt(0)!='<')
theirHtml='<span>'+theirHtml+'</span>';var focus=elementDefinition.focus;if(focus)
{var oldFocus=this.focus;this.focus=function()
{oldFocus.call(this);typeof focus=='function'&&focus.call(this);this.fire('focus');};if(elementDefinition.isFocusable)
{var oldIsFocusable=this.isFocusable;this.isFocusable=oldIsFocusable;}
this.keyboardFocusable=true;}
CKEDITOR.ui.dialog.uiElement.call(this,dialog,elementDefinition,myHtmlList,'span',null,null,'');myHtml=myHtmlList.join('');myMatch=myHtml.match(myHtmlRe);theirMatch=theirHtml.match(theirHtmlRe)||['','',''];if(emptyTagRe.test(theirMatch[1]))
{theirMatch[1]=theirMatch[1].slice(0,-1);theirMatch[2]='/'+theirMatch[2];}
htmlList.push([theirMatch[1],' ',myMatch[1]||'',theirMatch[2]].join(''));};})(),fieldset:function(dialog,childObjList,childHtmlList,htmlList,elementDefinition)
{var legendLabel=elementDefinition.label;var innerHTML=function()
{var html=[];legendLabel&&html.push('<legend>'+legendLabel+'</legend>');for(var i=0;i<childHtmlList.length;i++)
html.push(childHtmlList[i]);return html.join('');};this._={children:childObjList};CKEDITOR.ui.dialog.uiElement.call(this,dialog,elementDefinition,htmlList,'fieldset',null,null,innerHTML);}},true);CKEDITOR.ui.dialog.html.prototype=new CKEDITOR.ui.dialog.uiElement;CKEDITOR.ui.dialog.labeledElement.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.uiElement,{setLabel:function(label)
{var node=CKEDITOR.document.getById(this._.labelId);if(node.getChildCount()<1)
(new CKEDITOR.dom.text(label,CKEDITOR.document)).appendTo(node);else
node.getChild(0).$.nodeValue=label;return this;},getLabel:function()
{var node=CKEDITOR.document.getById(this._.labelId);if(!node||node.getChildCount()<1)
return'';else
return node.getChild(0).getText();},eventProcessors:commonEventProcessors},true);CKEDITOR.ui.dialog.button.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.uiElement,{click:function()
{if(!this._.disabled)
return this.fire('click',{dialog:this._.dialog});this.getElement().$.blur();return false;},enable:function()
{this._.disabled=false;var element=this.getElement();element&&element.removeClass('cke_disabled');},disable:function()
{this._.disabled=true;this.getElement().addClass('cke_disabled');},isVisible:function()
{return this.getElement().getFirst().isVisible();},isEnabled:function()
{return!this._.disabled;},eventProcessors:CKEDITOR.tools.extend({},CKEDITOR.ui.dialog.uiElement.prototype.eventProcessors,{onClick:function(dialog,func)
{this.on('click',func);}},true),accessKeyUp:function()
{this.click();},accessKeyDown:function()
{this.focus();},keyboardFocusable:true},true);CKEDITOR.ui.dialog.textInput.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.labeledElement,{getInputElement:function()
{return CKEDITOR.document.getById(this._.inputId);},focus:function()
{var me=this.selectParentTab();setTimeout(function()
{var element=me.getInputElement();element&&element.$.focus();},0);},select:function()
{var me=this.selectParentTab();setTimeout(function()
{var e=me.getInputElement();if(e)
{e.$.focus();e.$.select();}},0);},accessKeyUp:function()
{this.select();},setValue:function(value)
{!value&&(value='');return CKEDITOR.ui.dialog.uiElement.prototype.setValue.apply(this,arguments);},keyboardFocusable:true},commonPrototype,true);CKEDITOR.ui.dialog.textarea.prototype=new CKEDITOR.ui.dialog.textInput();CKEDITOR.ui.dialog.select.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.labeledElement,{getInputElement:function()
{return this._.select.getElement();},add:function(label,value,index)
{var option=new CKEDITOR.dom.element('option',this.getDialog().getParentEditor().document),selectElement=this.getInputElement().$;option.$.text=label;option.$.value=(value===undefined||value===null)?label:value;if(index===undefined||index===null)
{if(CKEDITOR.env.ie)
selectElement.add(option.$);else
selectElement.add(option.$,null);}
else
selectElement.add(option.$,index);return this;},remove:function(index)
{var selectElement=this.getInputElement().$;selectElement.remove(index);return this;},clear:function()
{var selectElement=this.getInputElement().$;while(selectElement.length>0)
selectElement.remove(0);return this;},keyboardFocusable:true},commonPrototype,true);CKEDITOR.ui.dialog.checkbox.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.uiElement,{getInputElement:function()
{return this._.checkbox.getElement();},setValue:function(checked,noChangeEvent)
{this.getInputElement().$.checked=checked;!noChangeEvent&&this.fire('change',{value:checked});},getValue:function()
{return this.getInputElement().$.checked;},accessKeyUp:function()
{this.setValue(!this.getValue());},eventProcessors:{onChange:function(dialog,func)
{if(!CKEDITOR.env.ie)
return commonEventProcessors.onChange.apply(this,arguments);else
{dialog.on('load',function()
{var element=this._.checkbox.getElement();element.on('propertychange',function(evt)
{evt=evt.data.$;if(evt.propertyName=='checked')
this.fire('change',{value:element.$.checked});},this);},this);this.on('change',func);}
return null;}},keyboardFocusable:true},commonPrototype,true);CKEDITOR.ui.dialog.radio.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.uiElement,{setValue:function(value,noChangeEvent)
{var children=this._.children,item;for(var i=0;(i<children.length)&&(item=children[i]);i++)
item.getElement().$.checked=(item.getValue()==value);!noChangeEvent&&this.fire('change',{value:value});},getValue:function()
{var children=this._.children;for(var i=0;i<children.length;i++)
{if(children[i].getElement().$.checked)
return children[i].getValue();}
return null;},accessKeyUp:function()
{var children=this._.children,i;for(i=0;i<children.length;i++)
{if(children[i].getElement().$.checked)
{children[i].getElement().focus();return;}}
children[0].getElement().focus();},eventProcessors:{onChange:function(dialog,func)
{if(!CKEDITOR.env.ie)
return commonEventProcessors.onChange.apply(this,arguments);else
{dialog.on('load',function()
{var children=this._.children,me=this;for(var i=0;i<children.length;i++)
{var element=children[i].getElement();element.on('propertychange',function(evt)
{evt=evt.data.$;if(evt.propertyName=='checked'&&this.$.checked)
me.fire('change',{value:this.getAttribute('value')});});}},this);this.on('change',func);}
return null;}},keyboardFocusable:true},commonPrototype,true);CKEDITOR.ui.dialog.file.prototype=CKEDITOR.tools.extend(new CKEDITOR.ui.dialog.labeledElement,commonPrototype,{getInputElement:function()
{var frameDocument=CKEDITOR.document.getById(this._.frameId).getFrameDocument();return frameDocument.$.forms.length>0?new CKEDITOR.dom.element(frameDocument.$.forms[0].elements[0]):this.getElement();},submit:function()
{this.getInputElement().getParent().$.submit();return this;},getAction:function()
{return this.getInputElement().getParent().$.action;},registerEvents:function(definition)
{var regex=/^on([A-Z]\w+)/,match;var registerDomEvent=function(uiElement,dialog,eventName,func)
{uiElement.on('formLoaded',function()
{uiElement.getInputElement().on(eventName,func,uiElement);});};for(var i in definition)
{if(!(match=i.match(regex)))
continue;if(this.eventProcessors[i])
this.eventProcessors[i].call(this,this._.dialog,definition[i]);else
registerDomEvent(this,this._.dialog,match[1].toLowerCase(),definition[i]);}
return this;},reset:function()
{var _=this._,frameElement=CKEDITOR.document.getById(_.frameId),frameDocument=frameElement.getFrameDocument(),elementDefinition=_.definition,buttons=_.buttons,callNumber=this.formLoadedNumber,unloadNumber=this.formUnloadNumber,langDir=_.dialog._.editor.lang.dir,langCode=_.dialog._.editor.langCode;if(!callNumber)
{callNumber=this.formLoadedNumber=CKEDITOR.tools.addFunction(function()
{this.fire('formLoaded');},this);unloadNumber=this.formUnloadNumber=CKEDITOR.tools.addFunction(function()
{this.getInputElement().clearCustomData();},this);this.getDialog()._.editor.on('destroy',function()
{CKEDITOR.tools.removeFunction(callNumber);CKEDITOR.tools.removeFunction(unloadNumber);});}
function generateFormField()
{frameDocument.$.open();if(CKEDITOR.env.isCustomDomain())
frameDocument.$.domain=document.domain;var size='';if(elementDefinition.size)
size=elementDefinition.size-(CKEDITOR.env.ie?7:0);frameDocument.$.write(['<html dir="'+langDir+'" lang="'+langCode+'"><head><title></title></head><body style="margin: 0; overflow: hidden; background: transparent;">','<form enctype="multipart/form-data" method="POST" dir="'+langDir+'" lang="'+langCode+'" action="',CKEDITOR.tools.htmlEncode(elementDefinition.action),'">','<input type="file" name="',CKEDITOR.tools.htmlEncode(elementDefinition.id||'cke_upload'),'" size="',CKEDITOR.tools.htmlEncode(size>0?size:""),'" />','</form>','</body></html>','<script>window.parent.CKEDITOR.tools.callFunction('+callNumber+');','window.onbeforeunload = function() {window.parent.CKEDITOR.tools.callFunction('+unloadNumber+')}</script>'].join(''));frameDocument.$.close();for(var i=0;i<buttons.length;i++)
buttons[i].enable();}
if(CKEDITOR.env.gecko)
setTimeout(generateFormField,500);else
generateFormField();},getValue:function()
{return this.getInputElement().$.value||'';},setInitValue:function()
{this._.initValue='';},eventProcessors:{onChange:function(dialog,func)
{if(!this._.domOnChangeRegistered)
{this.on('formLoaded',function()
{this.getInputElement().on('change',function(){this.fire('change',{value:this.getValue()});},this);},this);this._.domOnChangeRegistered=true;}
this.on('change',func);}},keyboardFocusable:true},true);CKEDITOR.ui.dialog.fileButton.prototype=new CKEDITOR.ui.dialog.button;CKEDITOR.ui.dialog.fieldset.prototype=CKEDITOR.tools.clone(CKEDITOR.ui.dialog.hbox.prototype);CKEDITOR.dialog.addUIElement('text',textBuilder);CKEDITOR.dialog.addUIElement('password',textBuilder);CKEDITOR.dialog.addUIElement('textarea',commonBuilder);CKEDITOR.dialog.addUIElement('checkbox',commonBuilder);CKEDITOR.dialog.addUIElement('radio',commonBuilder);CKEDITOR.dialog.addUIElement('button',commonBuilder);CKEDITOR.dialog.addUIElement('select',commonBuilder);CKEDITOR.dialog.addUIElement('file',commonBuilder);CKEDITOR.dialog.addUIElement('fileButton',commonBuilder);CKEDITOR.dialog.addUIElement('html',commonBuilder);CKEDITOR.dialog.addUIElement('fieldset',containerBuilder);})();;CKEDITOR.plugins.add('panel',{beforeInit:function(editor)
{editor.ui.addHandler(CKEDITOR.UI_PANEL,CKEDITOR.ui.panel.handler);}});CKEDITOR.UI_PANEL='panel';CKEDITOR.ui.panel=function(document,definition)
{if(definition)
CKEDITOR.tools.extend(this,definition);CKEDITOR.tools.extend(this,{className:'',css:[]});this.id=CKEDITOR.tools.getNextId();this.document=document;this._={blocks:{}};};CKEDITOR.ui.panel.handler={create:function(definition)
{return new CKEDITOR.ui.panel(definition);}};CKEDITOR.ui.panel.prototype={renderHtml:function(editor)
{var output=[];this.render(editor,output);return output.join('');},render:function(editor,output)
{var id=this.id;output.push('<div class="',editor.skinClass,'"'+' lang="',editor.langCode,'"'+' role="presentation"'+' style="display:none;z-index:'+(editor.config.baseFloatZIndex+1)+'">'+'<div'+' id=',id,' dir=',editor.lang.dir,' role="presentation"'+' class="cke_panel cke_',editor.lang.dir);if(this.className)
output.push(' ',this.className);output.push('">');if(this.forceIFrame||this.css.length)
{output.push('<iframe id="',id,'_frame"'+' frameborder="0"'+' role="application" src="javascript:void(');output.push(CKEDITOR.env.isCustomDomain()?'(function(){'+'document.open();'+'document.domain=\''+document.domain+'\';'+'document.close();'+'})()':'0');output.push(')"></iframe>');}
output.push('</div>'+'</div>');return id;},getHolderElement:function()
{var holder=this._.holder;if(!holder)
{if(this.forceIFrame||this.css.length)
{var iframe=this.document.getById(this.id+'_frame'),parentDiv=iframe.getParent(),dir=parentDiv.getAttribute('dir'),className=parentDiv.getParent().getAttribute('class'),langCode=parentDiv.getParent().getAttribute('lang'),doc=iframe.getFrameDocument();var onLoad=CKEDITOR.tools.addFunction(CKEDITOR.tools.bind(function(ev)
{this.isLoaded=true;if(this.onLoad)
this.onLoad();},this));var data='<!DOCTYPE html>'+'<html dir="'+dir+'" class="'+className+'_container" lang="'+langCode+'">'+'<head>'+'<style>.'+className+'_container{visibility:hidden}</style>'+'</head>'+'<body class="cke_'+dir+' cke_panel_frame '+CKEDITOR.env.cssClass+'" style="margin:0;padding:0"'+' onload="( window.CKEDITOR || window.parent.CKEDITOR ).tools.callFunction('+onLoad+');"></body>'+
CKEDITOR.tools.buildStyleHtml(this.css)+'<\/html>';doc.write(data);var win=doc.getWindow();win.$.CKEDITOR=CKEDITOR;doc.on('key'+(CKEDITOR.env.opera?'press':'down'),function(evt)
{var keystroke=evt.data.getKeystroke(),dir=this.document.getById(this.id).getAttribute('dir');if(this._.onKeyDown&&this._.onKeyDown(keystroke)===false)
{evt.data.preventDefault();return;}
if(keystroke==27||keystroke==(dir=='rtl'?39:37))
{if(this.onEscape&&this.onEscape(keystroke)===false)
evt.data.preventDefault();}},this);holder=doc.getBody();holder.unselectable();CKEDITOR.env.air&&CKEDITOR.tools.callFunction(onLoad);}
else
holder=this.document.getById(this.id);this._.holder=holder;}
return holder;},addBlock:function(name,block)
{block=this._.blocks[name]=block instanceof CKEDITOR.ui.panel.block?block:new CKEDITOR.ui.panel.block(this.getHolderElement(),block);if(!this._.currentBlock)
this.showBlock(name);return block;},getBlock:function(name)
{return this._.blocks[name];},showBlock:function(name)
{var blocks=this._.blocks,block=blocks[name],current=this._.currentBlock,holder=this.forceIFrame?this.document.getById(this.id+'_frame'):this._.holder;holder.getParent().getParent().disableContextMenu();if(current)
{holder.removeAttributes(current.attributes);current.hide();}
this._.currentBlock=block;holder.setAttributes(block.attributes);CKEDITOR.fire('ariaWidget',holder);block._.focusIndex=-1;this._.onKeyDown=block.onKeyDown&&CKEDITOR.tools.bind(block.onKeyDown,block);block.onMark=function(item)
{holder.setAttribute('aria-activedescendant',item.getId()+'_option');};block.onUnmark=function()
{holder.removeAttribute('aria-activedescendant');};block.show();return block;},destroy:function()
{this.element&&this.element.remove();}};CKEDITOR.ui.panel.block=CKEDITOR.tools.createClass({$:function(blockHolder,blockDefinition)
{this.element=blockHolder.append(blockHolder.getDocument().createElement('div',{attributes:{'tabIndex':-1,'class':'cke_panel_block','role':'presentation'},styles:{display:'none'}}));if(blockDefinition)
CKEDITOR.tools.extend(this,blockDefinition);if(!this.attributes.title)
this.attributes.title=this.attributes['aria-label'];this.keys={};this._.focusIndex=-1;this.element.disableContextMenu();},_:{markItem:function(index)
{if(index==-1)
return;var links=this.element.getElementsByTag('a');var item=links.getItem(this._.focusIndex=index);if(CKEDITOR.env.webkit||CKEDITOR.env.opera)
item.getDocument().getWindow().focus();item.focus();this.onMark&&this.onMark(item);}},proto:{show:function()
{this.element.setStyle('display','');},hide:function()
{if(!this.onHide||this.onHide.call(this)!==true)
this.element.setStyle('display','none');},onKeyDown:function(keystroke)
{var keyAction=this.keys[keystroke];switch(keyAction)
{case'next':var index=this._.focusIndex,links=this.element.getElementsByTag('a'),link;while((link=links.getItem(++index)))
{if(link.getAttribute('_cke_focus')&&link.$.offsetWidth)
{this._.focusIndex=index;link.focus();break;}}
return false;case'prev':index=this._.focusIndex;links=this.element.getElementsByTag('a');while(index>0&&(link=links.getItem(--index)))
{if(link.getAttribute('_cke_focus')&&link.$.offsetWidth)
{this._.focusIndex=index;link.focus();break;}}
return false;case'click':case'mouseup':index=this._.focusIndex;link=index>=0&&this.element.getElementsByTag('a').getItem(index);if(link)
link.$[keyAction]?link.$[keyAction]():link.$['on'+keyAction]();return false;}
return true;}}});;CKEDITOR.plugins.add('listblock',{requires:['panel'],onLoad:function()
{CKEDITOR.ui.panel.prototype.addListBlock=function(name,definition)
{return this.addBlock(name,new CKEDITOR.ui.listBlock(this.getHolderElement(),definition));};CKEDITOR.ui.listBlock=CKEDITOR.tools.createClass({base:CKEDITOR.ui.panel.block,$:function(blockHolder,blockDefinition)
{blockDefinition=blockDefinition||{};var attribs=blockDefinition.attributes||(blockDefinition.attributes={});(this.multiSelect=!!blockDefinition.multiSelect)&&(attribs['aria-multiselectable']=true);!attribs.role&&(attribs.role='listbox');this.base.apply(this,arguments);var keys=this.keys;keys[40]='next';keys[9]='next';keys[38]='prev';keys[CKEDITOR.SHIFT+9]='prev';keys[32]=CKEDITOR.env.ie?'mouseup':'click';CKEDITOR.env.ie&&(keys[13]='mouseup');this._.pendingHtml=[];this._.items={};this._.groups={};},_:{close:function()
{if(this._.started)
{this._.pendingHtml.push('</ul>');delete this._.started;}},getClick:function()
{if(!this._.click)
{this._.click=CKEDITOR.tools.addFunction(function(value)
{var marked=true;if(this.multiSelect)
marked=this.toggle(value);else
this.mark(value);if(this.onClick)
this.onClick(value,marked);},this);}
return this._.click;}},proto:{add:function(value,html,title)
{var pendingHtml=this._.pendingHtml,id=CKEDITOR.tools.getNextId();if(!this._.started)
{pendingHtml.push('<ul role="presentation" class=cke_panel_list>');this._.started=1;this._.size=this._.size||0;}
this._.items[value]=id;pendingHtml.push('<li id=',id,' class=cke_panel_listItem role=presentation>'+'<a id="',id,'_option" _cke_focus=1 hidefocus=true'+' title="',title||value,'"'+' href="javascript:void(\'',value,'\')" '+
(CKEDITOR.env.ie?'onclick="return false;" onmouseup':'onclick')+'="CKEDITOR.tools.callFunction(',this._.getClick(),',\'',value,'\'); return false;"',' role="option"'+' aria-posinset="'+(++this._.size)+'">',html||value,'</a>'+'</li>');},startGroup:function(title)
{this._.close();var id=CKEDITOR.tools.getNextId();this._.groups[title]=id;this._.pendingHtml.push('<h1 role="presentation" id=',id,' class=cke_panel_grouptitle>',title,'</h1>');},commit:function()
{this._.close();this.element.appendHtml(this._.pendingHtml.join(''));var items=this._.items,doc=this.element.getDocument();for(var value in items)
doc.getById(items[value]+'_option').setAttribute('aria-setsize',this._.size);delete this._.size;this._.pendingHtml=[];},toggle:function(value)
{var isMarked=this.isMarked(value);if(isMarked)
this.unmark(value);else
this.mark(value);return!isMarked;},hideGroup:function(groupTitle)
{var group=this.element.getDocument().getById(this._.groups[groupTitle]),list=group&&group.getNext();if(group)
{group.setStyle('display','none');if(list&&list.getName()=='ul')
list.setStyle('display','none');}},hideItem:function(value)
{this.element.getDocument().getById(this._.items[value]).setStyle('display','none');},showAll:function()
{var items=this._.items,groups=this._.groups,doc=this.element.getDocument();for(var value in items)
{doc.getById(items[value]).setStyle('display','');}
for(var title in groups)
{var group=doc.getById(groups[title]),list=group.getNext();group.setStyle('display','');if(list&&list.getName()=='ul')
list.setStyle('display','');}},mark:function(value)
{if(!this.multiSelect)
this.unmarkAll();var itemId=this._.items[value],item=this.element.getDocument().getById(itemId);item.addClass('cke_selected');this.element.getDocument().getById(itemId+'_option').setAttribute('aria-selected',true);this.element.setAttribute('aria-activedescendant',itemId+'_option');this.onMark&&this.onMark(item);},unmark:function(value)
{var doc=this.element.getDocument(),itemId=this._.items[value],item=doc.getById(itemId);item.removeClass('cke_selected');doc.getById(itemId+'_option').removeAttribute('aria-selected');this.onUnmark&&this.onUnmark(item);},unmarkAll:function()
{var items=this._.items,doc=this.element.getDocument();for(var value in items)
{var itemId=items[value];doc.getById(itemId).removeClass('cke_selected');doc.getById(itemId+'_option').removeAttribute('aria-selected');}
this.onUnmark&&this.onUnmark();},isMarked:function(value)
{return this.element.getDocument().getById(this._.items[value]).hasClass('cke_selected');},focus:function(value)
{this._.focusIndex=-1;if(value)
{var selected=this.element.getDocument().getById(this._.items[value]).getFirst();var links=this.element.getElementsByTag('a'),link,i=-1;while((link=links.getItem(++i)))
{if(link.equals(selected))
{this._.focusIndex=i;break;}}
setTimeout(function()
{selected.focus();},0);}}}});}});;(function($,window,undefined){var WE=window.WikiaEditor=window.WikiaEditor||(new Observable());var RTE={config:{alignableElements:{div:true,p:true,td:true,th:true},baseFloatZIndex:5000101,bodyClass:'WikiaArticle',bodyId:'bodyContent',contentsCss:[$.getSassLocalURL('extensions/wikia/RTE/css/content.scss'),window.RTESiteCss],coreStyles_bold:{element:'b',overrides:'strong'},coreStyles_italic:{element:'i',overrides:'em'},customConfig:'',dialog_backgroundCoverColor:'#000',dialog_backgroundCoverOpacity:0.8,disableDragDrop:false,disableObjectResizing:true,entities:false,format_tags:'p;h2;h3;h4;h5;pre',height:400,indentOffset:24,language:window.wgUserLanguage,plugins:'basicstyles,'+'button,'+'clipboard,'+'contextmenu,'+'dialog,'+'enterkey,'+'format,'+'htmldataprocessor,'+'indent,'+'keystrokes,'+'list,'+'pastetext,'+'removeformat,'+'sourcearea,'+'tab,'+'table,'+'tabletools,'+'undo,'+'wysiwygarea',extraPlugins:'rte-accesskey,'+'rte-comment,'+'rte-dialog,'+'rte-dragdrop,'+'rte-entities,'+'rte-gallery,'+'rte-justify,'+'rte-link,'+'rte-linksuggest,'+'rte-media,'+'rte-modeswitch,'+'rte-overlay,'+'rte-paste,'+'rte-placeholder,'+'rte-signature,'+'rte-spellchecker,'+'rte-template,'+'rte-temporary-save,'+'rte-toolbar,'+'rte-tools',resize_enabled:false,richcomboCss:$.getSassCommonURL('extensions/wikia/RTE/css/richcombo.scss'),skin:'wikia',startupFocus:true,theme:'wikia'},instanceId:null,loaded:[],loadTime:false,overlayNode:$('<div id="RTEOverlay" class="rte-overlay">'),log:function(msg){$().log(msg,'RTE');},ajax:function(method,params,callback){if(typeof params!='object'){params={};}
params.method=method;jQuery.post(window.wgScript+'?action=ajax&rs=RTEAjax',params,function(data){if(typeof callback=='function'){callback(data);}},'json');},getContentsCss:function(editor){if(typeof WikiaEnableAutoPageCreate!='undefined'){RTE.config.contentsCss.push(wgServer+'/extensions/wikia/AutoPageCreate/AutoPageCreate.css');}
var contentsCss='',index=0,length=RTE.config.contentsCss.length;(function load(){$.get(RTE.config.contentsCss[index],function(css){contentsCss+=css,index++;if(index<length){load();}else{RTE.config.contentsCss=contentsCss;RTE.initCk(editor);}});}());},init:function(editor){if(CKEDITOR.instances[editor.instanceId]){return;}
if($.isArray(RTE.config.contentsCss)){RTE.getContentsCss(editor);}else{RTE.initCk(editor);}},initCk:function(editor){if(editor.config.minHeight){RTE.config.height=editor.config.minHeight;}
if(typeof editor.config.tabIndex!='undefined'){RTE.config.tabIndex=editor.config.tabIndex;}
if(typeof editor.config.startupFocus!='undefined'){RTE.config.startupFocus=editor.config.startupFocus;}
RTE.config.startupMode=editor.config.mode;editor.ck=CKEDITOR.replace(editor.instanceId,RTE.config);RTE.loadExtraCss(editor.ck);editor.ck.on('getData',RTE.filterHtml);GlobalTriggers.fire('rteinit',editor.ck);},loadExtraCss:function(editor){var css=[];GlobalTriggers.fire('rterequestcss',css);for(var n=0;n<css.length;n++){if(typeof(css[n])!='undefined'){var cb=((css[n].indexOf('?')>-1||css[n].indexOf('__am')>-1)?'':('?'+CKEDITOR.timestamp));editor.addCss('@import url('+css[n]+cb+');');}}
if(CKEDITOR.env.ie&&RTE.config.disableObjectResizing){editor.addCss('img {behavior:url('+RTE.constants.localPath+'/css/behaviors/disablehandles.htc)}');}},onEditorReady:function(event){var editor=event.editor,instanceId=editor.instanceId;RTE.tools.getThemeColors();editor.dataProcessor.writer.indentationChars='';editor.dataProcessor.writer.lineBreakChars='';CKEDITOR.plugins.sourcearea.commands.source.exec=function(editor){if(editor.mode=='wysiwyg'){editor.fire('saveSnapshot');}
editor.fire('modeSwitch');}
RTE.loaded.push(editor);RTE.loadTime=(new Date()-window.wgNow)/1000;RTE.log('CKEditor v'+CKEDITOR.version+
(window.RTEDevMode?' (in development mode)':'')+' is ready in "'+editor.mode+'" mode (loaded in '+RTE.loadTime+' s)');$(window).trigger('rteready',editor);GlobalTriggers.fire('rteready',editor);var formatDropdown=editor.ui.create('Format');if(formatDropdown){formatDropdown.createPanel(editor);}
var editform=$(editor.element.$.form).bind('submit',$.proxy(function(){editor.fire('submit',{form:editform},editor);},this));editor.dataProcessor.htmlFilter.addRules({attributes:{'data-rte-instance':function(value,element){return false;}}});$(window).resize(RTE.repositionRTEOverlay).resize();},repositionRTEOverlay:function(){RTE.overlayNode.css({left:0,top:0});var wikiaEditor=WikiaEditor.getInstance(),editorWrapper=wikiaEditor.getEditboxWrapper(),bodyPadding=RTE.overlayNode.offset(),editorPosition=editorWrapper.offset();RTE.overlayNode.css({'left':parseInt(editorPosition.left-bodyPadding.left)+'px','top':parseInt(editorPosition.top-bodyPadding.top)+'px'});},getEditor:function(instanceId){return $(RTE.getInstance(instanceId).document.$.body);},getInstance:function(instanceId){return CKEDITOR.instances[instanceId||WE.instanceId];},getInstanceEditor:function(instanceId){return WE.instances[instanceId||WE.instanceId];},getInstanceElement:function(instanceId){return $('#'+instanceId||WE.instanceId);},filterHtml:function(ev){if(ev.editor.mode=='wysiwyg'){ev.data.dataValue=ev.data.dataValue.replace(/<div firebug[^>]+>[^<]+<\/div>/g,'');}},constants:{localPath:window.RTELocalPath,urlProtocols:window.RTEUrlProtocols,validTitleChars:window.RTEValidTitleChars},messages:window.RTEMessages};$(function(){RTE.overlayNode.appendTo('body');});window.RTE=RTE;})(jQuery,window);if($.browser.msie&&typeof RTEDevMode!='undefined'){CKEDITOR.on('loaded',function(event){var i,l,plugin,extraPlugins=RTE.config.extraPlugins.split(',');for(var plugin,i=0,l=extraPlugins.length;i<l,plugin=extraPlugins[i];i++){CKEDITOR.plugins.addExternal(plugin,RTE.constants.localPath+'/js/plugins/'+plugin.replace('rte-','')+'/');}});}
CKEDITOR.on('instanceCreated',function(event){WikiaEditor.instances[event.editor.name].fire('ckInstanceCreated',event.editor);});CKEDITOR.on('instanceReady',RTE.onEditorReady);CKEDITOR.dtd.pre.img=1;CKEDITOR.dtd.p=$.extend({},CKEDITOR.dtd.p,{center:1});CKEDITOR.dtd.table.img=1;CKEDITOR.dtd.dt=$.extend({},CKEDITOR.dtd.dt,{ul:1,ol:1});CKEDITOR.dtd.ol=$.extend({},CKEDITOR.dtd.ol,{img:1});CKEDITOR.dtd.ul=$.extend({},CKEDITOR.dtd.ul,{img:1});RTE.config.disableDragDrop=(CKEDITOR.env.gecko&&(CKEDITOR.env.geckoRelease=="1.9.2.9"||CKEDITOR.env.geckoRelease=="1.9.2.10"));CKEDITOR.config.bodyId='';CKEDITOR.config.baseBackgroundColor='#ddd';CKEDITOR.config.baseColor='#000';CKEDITOR.dom.element.prototype.hasAttributesOriginal=CKEDITOR.dom.element.prototype.hasAttributes;CKEDITOR.dom.element.prototype.hasAttributes=function(){var ret=this.hasAttributesOriginal();if(ret==true){var internalAttribs=['data-rte-washtml','data-rte-line-start','data-rte-empty-lines-before'];for(i=0;i<internalAttribs.length;i++){if(this.hasAttribute(internalAttribs[i])){ret=false;}}}
return ret;}
CKEDITOR.langRegExp=/lang\/([\w\-]+).js/;CKEDITOR.getUrl=function(resource){if(CKEDITOR.langRegExp.test(resource)){var matches=resource.match(CKEDITOR.langRegExp);var lang=matches[1];RTE.log('language "'+lang+'" requested');var url=window.wgServer+'/wikia.php?controller=RTE&method=i18n&uselang='+lang+'&cb='+window.wgJSMessagesCB;return url;}
if(resource.indexOf('://')==-1&&resource.indexOf('/')!==0){if(resource.indexOf('_source')==-1){resource='_source/'+resource;}
resource=this.basePath+resource;}
if(this.timestamp&&resource.charAt(resource.length-1)!='/'){resource+=(resource.indexOf('?')>=0?'&':'?')+this.timestamp;}
return resource;}
CKEDITOR.editor.prototype.switchMode=function(mode){if(this.mode==mode){return;}
RTE.log('switchMode("'+mode+'")');CKEDITOR.plugins.sourcearea.commands.source.exec(this);}
CKEDITOR.dom.element.prototype.setState=function(state){var node=this.getParent();switch(state)
{case CKEDITOR.TRISTATE_ON:node.addClass('cke_on');node.removeClass('cke_off');node.removeClass('cke_disabled');break;case CKEDITOR.TRISTATE_DISABLED:node.addClass('cke_disabled');node.removeClass('cke_off');node.removeClass('cke_on');break;default:node.addClass('cke_off');node.removeClass('cke_on');node.removeClass('cke_disabled');break;}};CKEDITOR.timestamp=window.wgStyleVersion;CKEDITOR.ONLY_FORMATTABLES=2;;jQuery.fn.getData=function(){var json=this.attr('data-rte-meta');if(!json){return{};}
json=decodeURIComponent(json);var data=JSON.parse(json)||{};return data;};jQuery.fn.setData=function(key,value){var data={};if(typeof key=='object'){data=key;}
else if(typeof key=='string'){data[key]=value;}
data=jQuery().extend(true,this.getData(),data);var json=JSON.stringify(data);this.attr('data-rte-meta',encodeURIComponent(json));return data;};jQuery.fn.setPlaceholderType=function(type){$(this).attr('class','placeholder placeholder-'+type).setData('type',type);};;CKEDITOR.plugins.add('rte-accesskey',{init:function(editor){if(CKEDITOR.env.ie){var accessibleElements=[];$('*[accesskey]').each(function(ev){accessibleElements[$(this).attr('accesskey').toUpperCase()]=$(this);});editor.on('wysiwygModeReady',function(){RTE.getEditor().unbind('.accesskey').bind('keydown.accesskey',function(e){var key=String.fromCharCode(e.keyCode).toUpperCase();if(e.altKey&&accessibleElements[key]){accessibleElements[key].click();}});});}}});;CKEDITOR.plugins.add('rte-comment',{init:function(editor){CKEDITOR.dialog.add('rte-comment',this.path+'dialogs/comment.js');}});RTE.commentEditor={placeholder:{},dialog:{},showCommentEditor:function(placeholder){RTE.log('calling comment editor...');RTE.commentEditor.placeholder=placeholder;RTE.getInstance().openDialog('rte-comment');}};;CKEDITOR.dialog.add('rte-comment',function(editor)
{return{title:editor.lang.commentEditor.title,resizable:CKEDITOR.DIALOG_RESIZE_NONE,minWidth:400,minHeight:150,contents:[{id:'comment',label:'Comment',elements:[{type:'textarea',id:'content'}]}],onOk:function(){var content=this.getValueOf('comment','content');var placeholder=RTE.commentEditor.placeholder;if(content==''){RTE.log('removing comment');placeholder.remove();return;}
RTE.log('storing modified comment data: '+content);var wikitext='<!-- '+content+' -->';placeholder.setData({wikitext:wikitext});placeholder.removeData('preview');},onShow:function(){this._.element.addClass('wikiaEditorDialog');this._.element.addClass('commentEditorDialog');var data=RTE.commentEditor.placeholder.getData();var wikitext=data.wikitext.replace(/^<!--\s+/,'').replace(/\s+-->$/,'');this.setValueOf('comment','content',wikitext);}};});;CKEDITOR.plugins.add('rte-dialog',{init:function(editor){CKEDITOR.dialog.prototype.getActiveTab=function(){return this._.currentTabId;};CKEDITOR.dialog.prototype.enableSuggesionsOn=function(field,namespaces){var self=this,fieldId=field._.inputId,node=$('#'+fieldId),promise=$.Deferred();if(!node.exists()||node.data('suggestSetUp')){if(node.exists()){promise.resolveWith(this,[node]);}
return promise.promise();}
RTE.log('enabling MW suggest on #'+fieldId);mw.loader.using('jquery.ui.autocomplete').then(function(){node.autocomplete({minLength:2,source:function(request,response){$.getJSON(mw.util.wikiScript('api'),{format:'json',action:'opensearch',search:request.term,namespace:namespaces?namespaces.join('|'):''},function(arr){if(arr&&arr.length>1){response(arr[1]);}
else{response([]);}});},open:function(event,ui){$(this).autocomplete('widget').css('z-index',100000000);}});node.data('suggestSetUp',true);var element=new CKEDITOR.dom.element(node[0]),ev;for(ev in{keyup:1,keydown:1,keypress:1}){element.on(ev,function(e){var preventKeyBubblingKeys={27:1,13:1};if(e.data.getKeystroke()in preventKeyBubblingKeys){e.data.stopPropagation();}});}
promise.resolveWith(self,[node]);});return promise.promise();};CKEDITOR.dialog.prototype.setLoading=function(loading){var wrapper=this.getElement();wrapper.removeClass('wikiaEditorLoading');if(loading){wrapper.addClass('wikiaEditorLoading');}};editor.on('dialogShow',function(ev){$(document.body).addClass('modalShown');});editor.on('dialogHide',function(ev){$(document.body).removeClass('modalShown');});}});;CKEDITOR.plugins.add('rte-dragdrop',{timeout:250,onDrop:function(ev){var editor=this;RTE.log('drag&drop finished');setTimeout(function(){editor.fire('wysiwygModeReady');var droppedElement=RTE.getEditor().find('[data-rte-dragged]').removeAttr('data-rte-dragged');RTE.log('dropped element:');RTE.log(droppedElement);editor.fire('droppedElements',droppedElement);editor.fire('saveSnapshot');var content=editor.getData();if(content==''){RTE.log('undoing drag&drop');editor.execCommand('undo');}
editor.fire('editorResize');var extra={pageX:(ev.pageX?ev.pageX:ev.clientX),pageY:(ev.pageY?ev.pageY:ev.clientY)};if(!CKEDITOR.env.ie){droppedElement.trigger('dropped',[extra]);}},this.timeout);},onDrag:function(ev){if(typeof(ev.target.tagName)=='undefined'){return true;}
this.fire('saveSnapshot');RTE.log('drag&drop: undo point');var target=$(ev.target);target.attr('data-rte-dragged',true);target.trigger('dragged');},onDuringDragDrop:function(ev){var scrollStep=15;var scrollSpace=50;var editorHeight=parseInt($('#cke_contents_'+RTE.getInstance().name).height());var editorWindow=this.window.$;var scrollY=(CKEDITOR.env.ie?editorWindow.document.body.parentNode.scrollTop:editorWindow.scrollY);var cursorY=(ev.pageY?ev.pageY:ev.clientY)-scrollY;if(cursorY<scrollSpace){editorWindow.scrollBy(0,-scrollStep);}
else if(cursorY>=editorHeight-scrollSpace){editorWindow.scrollBy(0,scrollStep);}},init:function(editor){var self=this;editor.on('wysiwygModeReady',function(){$(editor.document.$).unbind('.dnd').bind('dragstart.dnd',$.proxy(self.onDrag,editor)).bind('drop.dnd',$.proxy(self.onDrop,editor)).bind('dragdrop.dnd',$.proxy(self.onDrop,editor)).bind('mousedown.dnd',$.proxy(self.onDrag,editor)).bind('mouseup.dnd',function(ev){var target=$(ev.target);target.removeAttr('data-rte-dragged');if(CKEDITOR.env.ie){ev.preventDefault();}}).bind('dblclick.dnd',function(ev){if(CKEDITOR.env.gecko){var target=$(ev.target);if(!!target.filter('img').attr('type')){RTE.tools.removeResizeBox();}}}).bind('dragover.dnd',$.proxy(self.onDuringDragDrop));if(CKEDITOR.env.ie){RTE.getEditor().unbind('.dnd').bind('drop.dnd',$.proxy(self.onDrop,editor)).bind('dragover.dnd',$.proxy(self.onDuringDragDrop));}});}});;CKEDITOR.plugins.add('rte-entities',{insideEntitySpan:false,init:function(editor){var self=this;editor.on('selectionChange',function(ev){var selection=ev.data.selection;var element=selection.getStartElement();if(element.hasAttribute('data-rte-entity')){var entity=element.getAttribute('data-rte-entity');RTE.log('entity span: &'+entity+';');self.insideEntitySpan=true;}
else{if(self.insideEntitySpan){RTE.log('entity span: leaving...');}
self.insideEntitySpan=false;}});}});;CKEDITOR.plugins.add('rte-gallery',{init:function(editor){var self=this;editor.on('wysiwygModeReady',function(){var gallery=RTE.getEditor().find('.image-gallery');self.setupGallery(gallery);if($.browser.msie){var firstGallery=gallery.eq(0),firstGalleryParent=firstGallery.parent();if(firstGallery.hasClass('alignCenter')&&firstGalleryParent.parent().is('body')&&firstGalleryParent.is(':first-child')){firstGallery.parent().prepend("&nbsp;");}}});if(typeof window.WikiaPhotoGallery!='undefined'){self.addButton(editor,{type:WikiaPhotoGallery.TYPE_GALLERY,commandName:'addgallery',buttonName:'Gallery',buttonLabel:editor.lang.photoGallery.gallery,buttonTooltip:editor.lang.photoGallery.addGallery,buttonClass:'RTEGalleryButton'});self.addButton(editor,{type:WikiaPhotoGallery.TYPE_SLIDESHOW,commandName:'addslideshow',buttonName:'Slideshow',buttonLabel:editor.lang.photoGallery.slideshow,buttonTooltip:editor.lang.photoGallery.addSlideshow,buttonClass:'RTESlideshowButton'});self.addButton(editor,{type:WikiaPhotoGallery.TYPE_SLIDER,commandName:'addslider',buttonName:'Slider',buttonLabel:editor.lang.photoGallery.slider,buttonTooltip:editor.lang.photoGallery.addSlider,buttonClass:'RTESliderButton'});}
else{RTE.log('WikiaPhotoGallery is not enabled here - disabling "Gallery" button');return;}},addButton:function(editor,params){editor.addCommand(params.commandName,{exec:function(editor){WikiaPhotoGallery.showEditor({from:'wysiwyg',type:params.type});}});editor.ui.addButton(params.buttonName,{label:params.buttonLabel,title:params.buttonTooltip,className:params.buttonClass,command:params.commandName});},setupGallery:function(gallery){gallery.unbind('.gallery').bind('click.gallery edit.gallery',function(ev){var gallery=$(this);if((wgUserName==null)&&(UserLogin)){UserLogin.rteForceLogin();}
if(!window.wgEnableMediaGalleryExt){WikiaPhotoGallery.showEditor({from:'wysiwyg',gallery:gallery});}}).attr('title',function(){var data=$(this).getData();var key='';switch(data.type){case 1:key='tooltip';break;case 2:key='tooltipSlideshow';break;case 3:key='tooltipSlider';break;default:break;}
return RTE.getInstance().lang.photoGallery[key];});}});;(function()
{function isAlignable(editor,firstBlock){var alignableElements=editor.config.alignableElements;return firstBlock&&alignableElements[firstBlock.getName()]===true;}
function getState(editor,path)
{var firstBlock=path.block||path.blockLimit;if(!firstBlock||firstBlock.getName()=='body'){return CKEDITOR.TRISTATE_OFF;}
if(!isAlignable(editor,firstBlock)){return CKEDITOR.TRISTATE_DISABLED;}
return(getAlignment(firstBlock,editor.config.useComputedState)==this.value)?CKEDITOR.TRISTATE_ON:CKEDITOR.TRISTATE_OFF;}
function getAlignment(element,useComputedState)
{useComputedState=useComputedState===undefined||useComputedState;var align;if(useComputedState){align=element.getComputedStyle('text-align');}
else
{while(!element.hasAttribute||!(element.hasAttribute('align')||element.getStyle('text-align')))
{var parent=element.getParent();if(!parent){break;}
element=parent;}
align=element.getStyle('text-align')||element.getAttribute('align')||'';}
align&&(align=align.replace(/-moz-|-webkit-|start|auto/i,''));!align&&useComputedState&&(align=element.getComputedStyle('direction')=='rtl'?'right':'left');return align;}
function onSelectionChange(evt)
{if(evt.editor.readOnly)
return;var command=evt.editor.getCommand(this.name);command.state=getState.call(this,evt.editor,evt.data.path);command.fire('state');}
function justifyCommand(editor,name,value)
{this.name=name;this.value=value;var classes=editor.config.justifyClasses;if(classes)
{switch(value)
{case'left':this.cssClassName=classes[0];break;case'center':this.cssClassName=classes[1];break;case'right':this.cssClassName=classes[2];break;case'justify':this.cssClassName=classes[3];break;}
this.cssClassRegex=new RegExp('(?:^|\\s+)(?:'+classes.join('|')+')(?=$|\\s)');}}
function onDirChanged(e)
{var editor=e.editor;var range=new CKEDITOR.dom.range(editor.document);range.setStartBefore(e.data.node);range.setEndAfter(e.data.node);var walker=new CKEDITOR.dom.walker(range),node;while((node=walker.next()))
{if(node.type==CKEDITOR.NODE_ELEMENT)
{if(!node.equals(e.data.node)&&node.getDirection())
{range.setStartAfter(node);walker=new CKEDITOR.dom.walker(range);continue;}
var classes=editor.config.justifyClasses;if(classes)
{if(node.hasClass(classes[0]))
{node.removeClass(classes[0]);node.addClass(classes[2]);}
else if(node.hasClass(classes[2]))
{node.removeClass(classes[2]);node.addClass(classes[0]);}}
var style='text-align';var align=node.getStyle(style);if(align=='left')
node.setStyle(style,'right');else if(align=='right')
node.setStyle(style,'left');}}}
justifyCommand.prototype={exec:function(editor)
{var selection=editor.getSelection(),enterMode=editor.config.enterMode;if(!selection)
return;var bookmarks=selection.createBookmarks(),ranges=selection.getRanges(true);var cssClassName=this.cssClassName,iterator,block;var useComputedState=editor.config.useComputedState;useComputedState=useComputedState===undefined||useComputedState;for(var i=ranges.length-1;i>=0;i--)
{iterator=ranges[i].createIterator();iterator.enlargeBr=enterMode!=CKEDITOR.ENTER_BR;while((block=iterator.getNextParagraph(enterMode==CKEDITOR.ENTER_P?'p':'div')))
{block.removeAttribute('align');block.removeStyle('text-align');block.removeAttribute('data-rte-style');block.removeAttribute('data-rte-attribs');if(block.getName()=='p'){block.removeAttribute('data-rte-washtml');}
if(block.getName()=='th'){this.isDefaultAlign=(this.value=='center');}
var className=cssClassName&&(block.$.className=CKEDITOR.tools.ltrim(block.$.className.replace(this.cssClassRegex,'')));var apply=(this.state==CKEDITOR.TRISTATE_OFF)&&(!useComputedState||(getAlignment(block,true)!=this.value));if(cssClassName)
{if(apply)
block.addClass(cssClassName);else if(!className)
block.removeAttribute('class');}
else if(apply)
block.setStyle('text-align',this.value);}}
editor.focus();editor.forceNextSelectionCheck();selection.selectBookmarks(bookmarks);}};CKEDITOR.plugins.add('rte-justify',{init:function(editor)
{var left=new justifyCommand(editor,'justifyleft','left'),center=new justifyCommand(editor,'justifycenter','center'),right=new justifyCommand(editor,'justifyright','right'),justify=new justifyCommand(editor,'justifyblock','justify');editor.addCommand('justifyleft',left);editor.addCommand('justifycenter',center);editor.addCommand('justifyright',right);editor.addCommand('justifyblock',justify);editor.ui.addButton('JustifyLeft',{label:editor.lang.justify.left,command:'justifyleft'});editor.ui.addButton('JustifyCenter',{label:editor.lang.justify.center,command:'justifycenter'});editor.ui.addButton('JustifyRight',{label:editor.lang.justify.right,command:'justifyright'});editor.ui.addButton('JustifyBlock',{label:editor.lang.justify.block,command:'justifyblock'});editor.on('selectionChange',CKEDITOR.tools.bind(onSelectionChange,left));editor.on('selectionChange',CKEDITOR.tools.bind(onSelectionChange,right));editor.on('selectionChange',CKEDITOR.tools.bind(onSelectionChange,center));editor.on('selectionChange',CKEDITOR.tools.bind(onSelectionChange,justify));editor.on('dirChanged',onDirChanged);},requires:['domiterator']});})();CKEDITOR.tools.extend(CKEDITOR.config,{alignableElements:{}});;CKEDITOR.plugins.add('rte-link',{init:function(editor){editor.addCommand('link',new CKEDITOR.dialogCommand('link'));editor.addCommand('unlink',new CKEDITOR.unlinkCommand());editor.ui.addButton('Link',{label:editor.lang.link.add,command:'link'});editor.ui.addButton('Unlink',{label:editor.lang.unlink,command:'unlink'});CKEDITOR.dialog.add('link',this.path+'dialogs/link.js');if(editor.addMenuItems){editor.addMenuItems({link:{label:editor.lang.link.menu,command:'link',group:'link',order:1},unlink:{label:editor.lang.unlink,command:'unlink',group:'link',order:5}});}
editor.on('selectionChange',function(ev){var elements=ev.data.path.elements,len=elements.length,state=false;for(var i=0,element;i<len;i++){if(elements[i].is('a')){state=true;break;}}
editor.getCommand('link').setState(state?CKEDITOR.TRISTATE_ON:CKEDITOR.TRISTATE_OFF);});if(editor.contextMenu)
{editor.contextMenu.addListener(function(element,selection)
{if(!element)
return null;var isAnchor=(element.is('img')&&element.getAttribute('_cke_real_element_type')=='anchor');if(!isAnchor)
{if(!(element=CKEDITOR.plugins.link.getSelectedLink(editor)))
return null;isAnchor=(element.getAttribute('name')&&!element.getAttribute('href'));}
return isAnchor?{anchor:CKEDITOR.TRISTATE_OFF}:{link:CKEDITOR.TRISTATE_OFF,unlink:CKEDITOR.TRISTATE_OFF};});}
editor.on('afterPaste',function(){var pastedLinks=RTE.getEditor().find('a').not('a[data-rte-meta]');if(!pastedLinks.exists()){return;}
RTE.log('pasted links');RTE.log(pastedLinks);pastedLinks.each(function(){var link=$(this);var href=link.attr('href');if(RTE.tools.isExternalLink(href)){return;}
var pageName="";if(href.indexOf('&action=edit')==-1){pageName=link.attr('title');}
else{var matches=href.match('title=(.*)&action=edit');if(matches){pageName=matches[1];pageName=decodeURIComponent(pageName);pageName=pageName.replace(/_/g,' ');}}
if(pageName==""){return;}
RTE.log('local link pointing to "'+pageName+'" found');var data={type:'internal',link:pageName,text:link.text(),noforce:true,wasblank:false};link.setData(data);});});}});CKEDITOR.plugins.link={getSelectedLink:function(editor)
{var range;try{range=editor.getSelection().getRanges()[0];}
catch(e){return null;}
range.shrink(CKEDITOR.SHRINK_TEXT);var root=range.getCommonAncestor();return root.getAscendant('a',true);}};CKEDITOR.unlinkCommand=function(){};CKEDITOR.unlinkCommand.prototype={exec:function(editor)
{var selection=editor.getSelection(),bookmarks=selection.createBookmarks(),ranges=selection.getRanges(),rangeRoot,element;for(var i=0;i<ranges.length;i++)
{rangeRoot=ranges[i].getCommonAncestor(true);element=rangeRoot.getAscendant('a',true);if(!element)
continue;this.removeLink(editor,element,ranges[i]);}
selection.selectBookmarks(bookmarks);},removeLink:function(editor,element)
{element.remove(true);}};CKEDITOR.tools.extend(CKEDITOR.config,{linkShowAdvancedTab:true,linkShowTargetTab:true});;CKEDITOR.dialog.add('link',function(editor)
{var plugin=CKEDITOR.plugins.link,linkTextDirty=false,existsTimeout;function checkStatus(){var pageName=CKEDITOR.dialog.getCurrent().getContentElement('internal','name').getValue();if(pageName){$(".link-type-note span").html(editor.lang.link.status.checking);$(".link-type-note img").show()[0].className='sprite progress';RTE.ajax('checkInternalLink',{title:pageName},function(data){setLinkExistance(data.exists);});}
existsTimeout=null;}
function setLinkExistance(exists){if(exists){$(".link-type-note span").html(editor.lang.link.status.exists);$(".link-type-note img").show()[0].className='link-icon link-yes';}else{$(".link-type-note span").html(editor.lang.link.status.notexists);$(".link-type-note img").show()[0].className='link-icon link-no';}}
var setMode=function(mode){var linkDialog=CKEDITOR.dialog.getCurrent(),radios;if(mode=='external'){radios=linkDialog.getContentElement('internal','linktype');if(radios.getValue()!='ext'){radios.setValue('ext');}
$(".link-type-note span").html(editor.lang.link.status.external);$(".link-type-note img").show()[0].className='sprite external';}else if(mode=='internal'){radios=linkDialog.getContentElement('internal','linktype');if(radios.getValue()!='wiki'){radios.setValue('wiki');}
checkStatus();linkDialog.enableSuggesionsOn(linkDialog.getContentElement('internal','name')).then(function(node){var dialog=this;node.autocomplete({select:function(ev,ui){var value=ui.item&&ui.item.label,labelField=dialog.getContentElement('internal','label');if(typeof value!=='undefined'&&dialog.method=='new'){labelField.setValue(value);setLinkExistance(true);}}});});}};var setupDialog=function(editor,element){function setValues(tab,link,label){var dialog=CKEDITOR.dialog.getCurrent();dialog.setValueOf('internal','name',link);dialog.setValueOf('internal','label',label||'');}
RTE.log('opening link dialog');linkTextDirty=false;var data=element?$(element.$).getData():null,linkTextField;if(data){if(typeof data.type=='undefined'){RTE.log('pasted link detected');var href=element.getAttribute('href');if(RTE.tools.isExternalLink(href)){data={type:'external',link:href,text:element.getText()};setMode('external');}}else{switch(data.type){case'internal':setMode('internal');setTimeout(checkStatus,200);break;case'external':case'external-raw':setMode('external');break;}}
RTE.log(data);linkTextField=this.getContentElement('internal','label');switch(data.type){case'external':setValues('internal',data.link);if(data.linktype!='autonumber'){this.setValueOf('internal','label',data.text);linkTextDirty=true;}
break;case'external-raw':setValues('external',data.link);break;case'internal':setValues('internal',data.link,data.text);linkTextDirty=true;break;}
this.method='existing';}else{linkTextField=this.getContentElement('internal','label');var selectionContent=RTE.tools.getSelectionContent(),tab='internal';setMode('internal');if(selectionContent){if(RTE.tools.isExternalLink(selectionContent)){setMode('external');tab='external';}
linkTextDirty=true;setValues(tab,selectionContent,selectionContent);setTimeout(checkStatus,200);this.method='new-from-selection';RTE.log('link: using selected text "'+selectionContent+'" for new '+tab+' link');}else{this.method='new';RTE.log('link: fresh link');}}
this._.selectedElement=element;};var createNewLink=function(editor){var selection=editor.getSelection(),ranges=selection.getRanges();if(ranges.length==1&&ranges[0].collapsed){var text=new CKEDITOR.dom.text('',editor.document);ranges[0].insertNode(text);ranges[0].selectNodeContents(text);selection.selectRanges(ranges);}
var style=new CKEDITOR.style({element:'a',attributes:{'data-rte-new-link-temporary':true}});style.type=CKEDITOR.STYLE_INLINE;style.apply(editor.document);var node=RTE.getEditor().find('a[data-rte-new-link-temporary]');node.removeAttr('data-rte-new-link-temporary');var link=new CKEDITOR.dom.element(node[0]);if(CKEDITOR.env.gecko||CKEDITOR.env.webkit){var dirty=new CKEDITOR.dom.text(' ',editor.document);dirty.insertAfter(link);selection.selectElement(dirty);if(CKEDITOR.env.gecko){dirty.remove();}}
return link;};var lang=editor.lang.link;return{title:editor.lang.link.title,minWidth:500,minHeight:185,doNotCheckForChanged:true,contents:[{id:'internal',label:lang.internal.tab,title:lang.internal.tab,elements:[{'type':'html','html':'<p class="link-type-note"><span>...</span><img alt="Link Status" class="" src="'+wgBlankImgUrl+'" /></p>','id':'linkdisplay'},{'type':'text','label':editor.lang.link.label.target,'id':'name',onKeyUp:function(){var linkTextField=this.getDialog().getContentElement('internal','label');if(RTE.tools.isExternalLink(this.getValue())){setMode('external');}
var linktype=this.getDialog().getContentElement('internal','linktype').getValue();if(linktype=='wiki'){if(existsTimeout){clearTimeout(existsTimeout);}
$(".link-type-note span").html(editor.lang.link.status.checking);$(".link-type-note img").show()[0].className='sprite progress';existsTimeout=setTimeout(checkStatus,1000);}
if(linkTextField.getValue()==''){linkTextDirty=false;}
if(!linkTextDirty&&linkTextField.isEnabled()){linkTextField.setValue(this.getValue());}},validate:function(){var linktype=this.getDialog().getContentElement('internal','linktype').getValue(),re,isValid;if(linktype=='wiki'){re=new RegExp('^(#(.+))|['+RTE.constants.validTitleChars+']+$');var validPageNameFunc=CKEDITOR.dialog.validate.regex(re,editor.lang.link.error.badPageTitle);isValid=validPageNameFunc.apply(this);}else{re=new RegExp('^('+RTE.constants.urlProtocols+')');if(!this.getValue().match(re)){this.setValue('http://'+this.getValue());}
var validUrlFunc=CKEDITOR.dialog.validate.regex(re,editor.lang.link.error.badUrl);isValid=validUrlFunc.apply(this);}
return isValid;}},{'type':'text','label':editor.lang.link.label.display,'id':'label',onFocus:function()
{linkTextDirty=true;}},{'type':'radio','items':[[editor.lang.link.label.internal,'wiki'],[editor.lang.link.label.external,'ext']],'default':'wiki','id':'linktype','onChange':function(e)
{if(CKEDITOR.dialog.getCurrent()){RTE.log("mode changed to "+e.data.value);if(e.data&&e.data.value=='ext'){setMode('external');}else{setMode('internal');}}}}]}],onShow:function()
{this._.element.addClass('wikiaEditorDialog');this._.element.addClass('linkEditorDialog');this.fakeObj=false;var editor=this.getParentEditor(),selection=editor.getSelection(),ranges=selection.getRanges(),element=null,me=this;element=plugin.getSelectedLink(editor);if(element&&element.getAttribute('href')){selection.selectElement(element);}else{element=null;}
$(".link-type-note span").html('...');$(".link-type-note img").hide()[0].className='sprite';setupDialog.apply(this,[editor,element]);},onOk:function()
{if(this._.dontHide){return;}
var currentType=this.getContentElement('internal','linktype').getValue(),element;if(!this._.selectedElement){RTE.log('creating new link...');element=createNewLink.apply(this,[editor]);}else{element=this._.selectedElement;}
if(!element){return;}
element.removeClass('external');element.removeClass('autonumber');var data={};if(currentType=='wiki'){var href=this.getValueOf('internal','name');if(href.indexOf(window.wgServer)==0){var re=new RegExp(window.wgArticlePath.replace(/\$1/,'(.*)'));var matches=href.match(re);if(matches){var pageName=matches[1];pageName=decodeURIComponent(pageName);pageName=pageName.replace(/_/g,' ');this.setValueOf('internal','name',pageName);this.setValueOf('internal','label',this.getValueOf('external','label'));RTE.log('internal full URL detected: '+href+' > '+pageName);}}}
switch(currentType){case'ext':data={'type':'external','link':this.getValueOf('internal','name'),'text':this.getValueOf('internal','label'),'wikitext':null};if(data.text==''){data.linktype='autonumber';data.text='[1]';element.addClass('autonumber');}
element.setAttribute('href',data.link);element.addClass('external');element.removeClass('new');break;case'wiki':data={'type':'internal','link':this.getValueOf('internal','name'),'text':this.getValueOf('internal','label'),'noforce':true,'wikitext':null};RTE.tools.checkInternalLink(element,data.link);break;}
var linkContent=(data.text!='')?data.text:data.link;element.setHtml(linkContent);$(element.$).setData(data);RTE.log('updating link data');RTE.log([element,$(element.$).getData()]);RTE.log(linkContent);RTE.tools.renumberExternalLinks();if(typeof this._.suggestContainer!='undefined'){this._.suggestContainer.css('visibility','hidden');}
RTE.getInstanceEditor().fire('editorAddLink');}};});;CKEDITOR.plugins.add('rte-linksuggest',{init:function(editor){if(typeof jQuery.fn.linksuggest==='function'){editor.on('mode',function(ev){if(editor.mode==='source'){$(editor.textarea.$).linksuggest();}});}}});;CKEDITOR.plugins.add('rte-media',{init:function(editor){'use strict';var self=this;editor.on('wysiwygModeReady',function(){var media,placeholders;media=RTE.tools.getMedia();self.setupMedia(media);placeholders=RTE.getEditor().find('.media-placeholder');self.setupPlaceholder(placeholders);});editor.addCommand('addimage',{exec:function(){WikiaEditor.load('WikiaMiniUpload').done(function(){RTE.tools.callFunction(window.WMU_show);});}});editor.ui.addButton('Image',{label:editor.lang.image.photo,title:editor.lang.image.add,className:'RTEImageButton',command:'addimage'});if(window.wgEnableVideoToolExt){editor.addCommand('addvideo',{exec:function(){WikiaEditor.load('VideoEmbedTool').done(function(){RTE.tools.callFunction(window.vetWikiaEditor);});}});editor.ui.addButton('Video',{label:editor.lang.video.video,title:editor.lang.video.add,className:'RTEVideoButton',command:'addvideo'});}else{RTE.log('VET is not enabled here - disabling "Video" button');}
RTE.mediaEditor.plugin=self;},setupMedia:function(media){'use strict';var self=this,editor=RTE.getInstance(),msgs,getTrackingCategory,standardButtons,mediaWithCaption,image,video;if(!media.exists()){return;}
media.attr('data-rte-instance',RTE.instanceId);msgs=RTE.getInstance().lang.media;getTrackingCategory=function(node){var type;switch(node.attr('type')){case'image':case'image-placeholder':{type=node.hasClass('video')?'vet':'photo-tool';break;}
case'image-gallery':{type=(node.hasClass('image-slideshow')?'slideshow':node.hasClass('image-gallery-slider')?'slider':'gallery')+'-tool';break;}}
return type;};standardButtons=[{label:msgs.edit,'class':'RTEMediaOverlayEdit',callback:function(node){var category=getTrackingCategory(node);if(category){WikiaEditor.track({category:category,label:'modify'});}
node.trigger('edit');}},{label:msgs.delete,'class':'RTEMediaOverlayDelete',callback:function(node){var msgMediaType,category,title,msg;msgMediaType=self.getMediaTypeForMsg(node);category=getTrackingCategory(node);if(category){WikiaEditor.track({category:category,label:'remove'});}
title=RTE.getInstance().lang[msgMediaType].confirmDeleteTitle;msg=RTE.getInstance().lang[msgMediaType].confirmDelete;RTE.tools.confirm(title,msg,function(){var wikiaEditor=RTE.getInstanceEditor();RTE.tools.removeElement(node);wikiaEditor.fire('editorResize');wikiaEditor.editorFocus();}).data('tracking',{category:category});}}];if(window.wgEnableMediaGalleryExt&&$(media).attr('type')==='image-gallery'){standardButtons.shift();}
RTE.overlay.add(media,standardButtons);media.unbind('.media');RTE.tools.unselectable(media);RTE.getEditor().unbind('dropped.media').bind('dropped.media',function(ev,extra){var target=$(ev.target),parentNode,editorX,editorWidth,data,newAlign,oldAlign,wikitext,re;if(!target.hasClass('image')&&!target.hasClass('video')&&!target.hasClass('media-placeholder')){return;}
parentNode=target.parent();if((/h\d/i).test(parentNode.attr('nodeName'))){parentNode.after(target);RTE.log('image moved outside the header');}
editorX=parseInt(extra.pageX-$(this).offset().left);editorWidth=parseInt($(this).width());data=target.getData();newAlign=false;oldAlign=data.params.align;if(!oldAlign){oldAlign=(target.hasClass('thumb')||target.hasClass('frame'))?'right':'left';if(target.hasClass('alignNone')){oldAlign='left';}}
switch(oldAlign){case'left':if(editorX>parseInt(editorWidth*0.66)){newAlign='right';}
break;case'right':if(editorX<parseInt(editorWidth*0.33)){newAlign='left';}
break;}
if(!newAlign){RTE.log('media alignment detected: '+oldAlign+' (no change)');return;}
RTE.log('media alignment: '+oldAlign+' -> '+newAlign);wikitext=data.wikitext;re=new RegExp('\\|'+oldAlign+'(\\||])');if(re.test(wikitext)){wikitext=wikitext.replace(re,'|'+newAlign+'$1');}else{wikitext=wikitext.replace(/(\||\])/,'|'+newAlign+'$1');}
RTE.log('new wikitext: '+wikitext);data.params.align=newAlign;data.wikitext=wikitext;target.setData(data);target.removeClass('alignNone alignLeft alignRight').addClass(newAlign==='left'?'alignLeft':'alignRight');});mediaWithCaption=media.filter('.withCaption');mediaWithCaption.each(function(){$(this).css('backgroundPosition','5px '+parseInt($(this).attr('height')+10)+'px');});image=media.filter('img.image');self.setupImage(image);video=media.filter('img.video');self.setupVideo(video);if(RTE.config.disableDragDrop){RTE.tools.disableDragDrop(media);}
editor.resetDirty();},setupImage:function(image){'use strict';image.bind('edit.media',function(){RTE.log('image clicked');if(!UserLogin.isForceLogIn()){var self=this;WikiaEditor.load('WikiaMiniUpload').done(function(){RTE.tools.callFunction(window.WMU_show,$(self));});}});},addWikiText:function(wikiText,editedElement){'use strict';if(typeof editedElement!=='undefined'&&editedElement!==false){RTE.mediaEditor.update(editedElement,wikiText);}else{RTE.mediaEditor.addVideo(wikiText,{});}},setupVideo:function(video){'use strict';video.bind('edit.media',function(){RTE.log('video clicked');if(!UserLogin.isForceLogIn()){var self=this;WikiaEditor.load('VideoEmbedTool').done(function(){RTE.tools.callFunction(window.vetWikiaEditor,$(self));});}});},setupPlaceholder:function(placeholder){'use strict';var images,videos,self=this;if(!placeholder.exists()){return;}
this.setupMedia(placeholder);placeholder.unbind('.placeholder');placeholder.bind('contextmenu.placeholder',function(ev){ev.stopPropagation();});RTE.getEditor().unbind('dropped.placeholder').bind('dropped.placeholder',function(ev){var target=$(ev.target);target=target.filter('.media-placeholder');self.setupPlaceholder(target);});images=placeholder.filter('.image-placeholder');images.attr('title',RTE.getInstance().lang.imagePlaceholder.tooltip);images.bind('click.placeholder edit.placeholder',function(){var self=this;WikiaEditor.load('WikiaMiniUpload').done(function(){RTE.tools.callFunction(window.WMU_show,$(self),{isPlaceholder:true,track:{action:Wikia.Tracker.ACTIONS.CLICK,category:'image-placeholder',label:'edit-mode',method:'analytics'}});});});videos=placeholder.filter('.video-placeholder');videos.attr('title',RTE.getInstance().lang.videoPlaceholder.tooltip);videos.bind('click.placeholder edit.placeholder',function(){var self=this;WikiaEditor.load('VideoEmbedTool').done(function(){RTE.tools.callFunction(window.vetWikiaEditor,$(self),{isPlaceholder:true,track:{action:Wikia.Tracker.ACTIONS.CLICK,category:'video-placeholder',label:'edit-mode',method:'analytics'}});});});if(RTE.config.disableDragDrop){RTE.tools.disableDragDrop(placeholder);}},getMediaTypeForMsg:function(media){'use strict';var type;switch($(media).attr('type')){case'image':type='image';break;case'video':type='video';break;case'image-placeholder':type='imagePlaceholder';break;case'video-placeholder':type='videoPlaceholder';break;case'image-gallery':type='photoGallery';break;}
return type;}});RTE.mediaEditor={plugin:false,addImage:function(wikitext,params){'use strict';var wikitextParams,data;RTE.log('adding an image');wikitextParams=wikitext.substring(2,wikitext.length-2).split('|');data={type:'image',title:wikitextParams.shift().replace(/^[^:]+:/,''),params:params,wikitext:wikitext};this._add(wikitext,data);},addVideo:function(wikitext,params){'use strict';RTE.log('adding a video');var data={type:'video',params:params,wikitext:wikitext};this._add(wikitext,data);},_add:function(wikitext,data){'use strict';var self=this;RTE.tools.parseRTE(wikitext,function(html){var editor=RTE.getInstance(),newMedia;newMedia=$(html,editor.document.$).children('img');if(!newMedia.exists()){newMedia=$(html,editor.document.$);}
newMedia.setData(data);RTE.tools.insertElement(newMedia,true);self.plugin.setupMedia(newMedia);RTE.getInstanceEditor().fire('editorAddMedia');editor.focus();});},update:function(media,wikitext){'use strict';var self=this;RTE.tools.parseRTE(wikitext,function(html){var editor=RTE.getInstance(),newMedia=$(html).children('img');newMedia.insertAfter(media);newMedia.setData('wikitext',wikitext);media.remove();self.plugin.setupMedia(newMedia);editor.focus();});}};;CKEDITOR.plugins.add('rte-modeswitch',{sourceButton:false,messages:{},init:function(editor){this.messages=editor.lang.modeSwitch;this.addCommands(editor);editor.on('instanceReady',$.proxy(this.updateModeInfo,this));editor.on('mode',$.proxy(this.updateModeInfo,this));editor.on('modeSwitch',$.proxy(function(ev){ev.editor.getCommand('ModeSource').disable();ev.editor.getCommand('ModeWysiwyg').disable();},this));editor.on('modeSwitchCancelled',$.proxy(function(ev){if(ev.editor.mode=='source'){ev.editor.getCommand('ModeWysiwyg').enable();}
else{ev.editor.getCommand('ModeSource').enable();}},this));editor.on('mode',$.proxy(this.updateTooltips,this));editor.on('mode',$.proxy(this.mode,this));editor.on('modeSwitch',$.proxy(this.modeSwitch,this));editor.on('dataReady',$.proxy(this.dataReady,this));editor.on('wysiwygModeReady',$.proxy(this.wysiwygModeReady,this));editor.on('sourceModeReady',$.proxy(this.sourceModeReady,this));},modeSwitch:function(ev){var editor=ev.editor,wikiaEditor=WikiaEditor.getInstance(editor.name),content=editor.getData();if(!wikiaEditor.ready){RTE.log('cannot switch modes until editor is ready');editor.fire('modeSwitchCancelled');return;}
RTE.log('switching from "'+editor.mode+'" mode');var onError=function(){RTE.log('error occured during mode switch');editor.fire('modeSwitchCancelled');$.showModal(editor.lang.errorPopupTitle,editor.lang.modeSwitch.error,{width:400});};switch(editor.mode){case'wysiwyg':RTE.ajax('html2wiki',{html:content,title:window.wgPageName},function(data){if(!data){onError();return;}
editor.setMode('source');editor.setData(data.wikitext,function(){editor.textarea.$.scrollTop=0;editor.textarea.$.setSelectionRange(0,0);});});break;case'source':RTE.ajax('wiki2html',{wikitext:content,title:window.wgPageName},function(data){if(!data){onError();return;}
if((typeof window.RTEEdgeCase!='undefined')&&(window.RTEEdgeCase=='nowysiwyg')){RTE.log('article contains __NOWYSIWYG__ magic word');data.edgecase={type:window.RTEEdgeCase,info:{title:window.RTEMessages.edgecase.title,content:window.RTEMessages.edgecase.content}};}
if(data.edgecase){RTE.log('edgecase found!');RTE.tools.alert(data.edgecase.info.title,data.edgecase.info.content);editor.fire('modeSwitchCancelled');return;}
editor.setData(data.html);editor.setMode('wysiwyg');RTE.instanceId=data.instanceId;});break;}},mode:function(ev){var editor=ev.editor;RTE.log('mode "'+editor.mode+'" is loaded');if(editor.config.startupFocus){editor.focus();}},dataReady:function(ev){var editor=ev.editor;if(editor.mode=='wysiwyg'){editor.fire('wysiwygModeReady');}else if(editor.mode=='source'){editor.fire('sourceModeReady');}},wysiwygModeReady:function(ev){RTE.log('wysiwygModeReady');var editor=ev.editor,body=jQuery(editor.document.$.body);body.attr('id',editor.config.bodyId).addClass('lang-'+window.wgContentLanguage);setTimeout(function(){if(CKEDITOR.env.opera){var firstChild=jQuery(editor.document.$.body).children().eq(0);if(firstChild.is('br')){firstChild.remove();}}},750);},sourceModeReady:function(ev){RTE.log('sourceModeReady');},updateModeInfo:function(ev){$('body').removeClass('rte_wysiwyg').removeClass('rte_source').addClass('rte_'+ev.editor.mode);$('#RTEMode').attr('value',ev.editor.mode);},updateTooltips:function(ev){var mode=ev.editor.mode,sourceTabLabel=this.messages['toSource'+(mode=='source'?'':'Tooltip')],wysiwygTabLabel=this.messages['toWysiwyg'+(mode=='wysiwyg'?'':'Tooltip')];this.getSwitchTab(ev.editor,'ModeSource').attr('title',sourceTabLabel);this.getSwitchTab(ev.editor,'ModeWysiwyg').attr('title',wysiwygTabLabel);},getSwitchTab:function(editor,commandName){var nodeId=editor.getCommand(commandName).uiItems[0]._.id;return $('#'+nodeId);},addCommands:function(editor){editor.addCommand('ModeSource',{modes:{wysiwyg:1},editorFocus:editor.config.isMiniEditor,canUndo:false,exec:function(){if(editor.mode!='source'){editor.fire('switchToSource');editor.execCommand('source');}}});editor.addCommand('ModeWysiwyg',{modes:{source:1},exec:function(){if(editor.mode=='source'){editor.execCommand('source');}}});editor.ui.addButton('ModeSource',{label:this.messages.toSource,hasIcon:editor.config.isMiniEditor,command:'ModeSource'});editor.ui.addButton('ModeWysiwyg',{label:this.messages.toWysiwyg,hasIcon:editor.config.isMiniEditor,command:'ModeWysiwyg'});}});;CKEDITOR.plugins.add('rte-overlay',{overlays:false,currentOverlay:false,init:function(editor){var self=this;RTE.overlay.plugin=this;editor.on('instanceReady',function(){self.overlays=$('<div>',{id:'RTEMediaOverlays','class':'rte-media-overlays'}).appendTo(RTE.overlayNode);});editor.on('wysiwygModeReady',function(){if(typeof self.overlays=='object'){self.overlays.html('');}});setInterval(function(){self.checkCurrentOverlay();},1000);},checkCurrentOverlay:function(){if(this.currentOverlay){var node=this.currentOverlay.data('node');if(node&&!node.hasParent('body')){this.currentOverlay.remove();this.currentOverlay=false;}}},showOverlay:function(node){var overlay=this.getOverlay(node),position=this.getOverlayPositon(node);var rightMargin=Math.max((position.left+overlay.width())-RTE.getEditor().width(),0);overlay.children('div').css('right',rightMargin+'px');var origTopPosition=position.top;position.top=Math.max(position.top,0);overlay.css({'left':position.left,'top':position.top});var menu=overlay.children().eq(0);menu.show();var caption=overlay.children().eq(1),positionCaption=parseInt(position.top)+parseInt(caption.css('top'))+16;var captionMarginTop=Math.min(parseInt(origTopPosition),0);caption.css('margin-top',captionMarginTop+'px');if(positionCaption+captionMarginTop<RTE.tools.getEditorHeight()){caption.show();}
this.overlays.children().hide();this.currentOverlay=overlay.show();var timeoutId=node.data('hideTimeout');if(timeoutId){clearTimeout(timeoutId);}},hideOverlay:function(node){var overlay=this.getOverlay(node);node.data('hideTimeout',setTimeout(function(){overlay.children().hide();overlay.hide();this.currentOverlay=false;node.removeData('hideTimeout');},100));},getOverlay:function(node,items){var self=this;if(!this.overlays){return false;}
var overlay=node.data('overlay');if(overlay){return overlay;}
overlay=$('<div>',{'class':'RTEMediaOverlay','type':node.attr('type'),'width':this.getImageWidth(node)});var overlayMenu=$('<div>').addClass('RTEMediaMenu color1').appendTo(overlay);var items=node.data('items');$(items).each(function(){var item=this;$('<span>').addClass(item['class']).html(item.label).bind('click',function(ev){self.hideOverlay(node);item.callback(node);}).appendTo(overlayMenu);});var caption=this.getCaption(node);if(caption){caption.appendTo(overlay);}
overlay.bind({'mouseover':function(){self.showOverlay(node);}});overlay.data('node',node);this.overlays.append(overlay);node.data('overlay',overlay);return overlay;},getCaption:function(node){var data=node.getData();var isFramed=node.hasClass('thumb')||node.hasClass('frame');var captionContent=(typeof data.params!='undefined')&&(data.params.captionParsed||data.params.caption);if(captionContent&&isFramed){var caption=$('<div>').addClass('RTEMediaCaption').html(captionContent).css({'top':node.outerHeight(false)-23,'width':node.width()}).click(function(ev){ev.preventDefault();});if(node.hasClass('alignCenter')){caption.css('left','1px');}
return caption;}
else{return false;}},getOverlayPositon:function(node){var position=RTE.tools.getPlaceholderPosition(node);if(node.hasClass('media-placeholder')){position.top+=2;position.left+=2;}
return position;},getImageWidth:function(node){var isFramed=node.hasClass('thumb')||node.hasClass('frame');var width=node.is('img')?parseInt(node.attr('width')):node.innerWidth();if(isFramed){if(CKEDITOR.env.ie&&CKEDITOR.env.version<=7){width+=2;}
else{width+=8;}}
return width+'px';}});RTE.overlay={plugin:false,add:function(node,items){var self=this.plugin;if(node.hasClass('video')&&!window.showAddVideoBtn){return;}
node.data('items',items);node.each(function(){var node=$(this).removeData('overlay').unbind('.overlay').bind({'mouseover.overlay':function(ev){self.showOverlay(node);},'mouseout.overlay':function(ev){self.hideOverlay(node);},'contextmenu.overlay':function(ev){ev.preventDefault();ev.stopPropagation();}});});}};;CKEDITOR.plugins.add('rte-paste',{htmlBeforePaste:'',getHtml:function(){return RTE.getInstance().document.getBody().getHtml();},init:function(editor){var self=this;editor.on('dataReady',function(ev){if(editor.mode!='wysiwyg'){return;}
editor.document.getBody().on('beforepasteonkey',function(ev){if(editor.config.forcePasteInDialog){RTE.log('"direct" paste prevented');ev.cancel();editor.fire('pasteDialog');}});});if(!editor.config.forcePasteAsPlainText){editor.on('beforePaste',function(ev){self.htmlBeforePaste=self.getHtml();setTimeout(function(){self.handlePaste(editor);},250);});}
editor.on('pastedRemoveBG',function(ev){RTE.tmpPasted=self.removeBG(ev.data);});if(CKEDITOR.env.webkit){var badStyles=['border-top-width:0px;','border-right-width:0px;','border-style:initial;','border-color:initial;','font-style:normal;']
editor.dataProcessor.htmlFilter.addRules({elements:{meta:function(element){return false;}},attributes:{style:function(value,element){value=value.split(' ').join('');for(i=0;i<badStyles.length;i++){if(!value.length){break;}
value=value.replace(badStyles[i],"");}
return value.length?value:false;}}});}},handlePaste:function(editor){RTE.log('paste detected');var afterPasteScheduled=false;var newHTML=this.getHtml();editor.fire('wysiwygModeReady');var diff=this.diff(this.htmlBeforePaste,newHTML);if(typeof diff!='object'||typeof diff.pasted!='string'){return;}
var pasted=diff.pasted;var html;if(typeof pasted=='string'){if((/<br>/).test(pasted)){RTE.log('paste: detected line breaks in pasted content');html=diff['new'].replace(/([^>])<br>([^<])/g,'$1<br data-rte-washtml="1" />$2');editor.setData(html,function(){editor.fire('afterPaste');});afterPasteScheduled=true;}
var newPasted=this.removeBG(pasted);if(newPasted!=pasted){html=diff.prefix+newPasted+diff.suffix;editor.setData(html,function(){editor.fire('afterPaste');});afterPasteScheduled=true;}}
if(!afterPasteScheduled){setTimeout(function(){editor.fire('afterPaste');},250);}},diff:function(o,n){if(o==n){return false;}
var lenDiff=o.length-n.length;var idx={start:0,end:n.length-1};while(o.charAt(idx.start)==n.charAt(idx.start)){if(idx.start>=o.length){return false;}
idx.start++;}
while(o.charAt(idx.end+lenDiff)==n.charAt(idx.end)){if(idx.end<=idx.start){return false;}
idx.end--;}
var prefix=n.substring(0,idx.start+1);var suffix=n.substring(idx.end,n.length);if(/<[^>]*$/.test(prefix)){idx.start=prefix.lastIndexOf('<');}
if(/^[^<]*>/.test(suffix)){idx.end+=suffix.indexOf('>');}
var pasted=n.substring(idx.start,idx.end+1);prefix=n.substring(0,idx.start);suffix=n.substring(idx.end+1,n.length);return{pasted:pasted,prefix:prefix,suffix:suffix,'new':n,'old':o,'start':idx.start,'end':idx.end};},removeBG:function(pasted){var doRemove=function(content){var bgIndex=content.indexOf('background-color');if(bgIndex>-1){var startPos=bgIndex,endPos=content.indexOf(";",bgIndex)+1,newContent=content.substring(0,startPos)+content.substring(endPos,content.length);return doRemove(newContent);}else{return content;}}
return doRemove(pasted);}});CKEDITOR.config.forcePasteInDialog=false;RTE.tmpPasted='';;CKEDITOR.plugins.add('rte-placeholder',{previews:false,init:function(editor){var self=this;editor.on('instanceReady',function(){self.previews=$('<div>',{id:'RTEPlaceholderPreviews','class':'rte-placeholder-previews'}).appendTo(RTE.overlayNode);});editor.on('wysiwygModeReady',function(){if(typeof self.previews=='object'){self.previews.html('');}
var placeholders=RTE.tools.getPlaceholders();placeholders.removeData('preview').removeData('info');self.setupPlaceholder(placeholders);});},getPreview:function(placeholder){var self=this;if(!this.previews){return;}
var chevron='<img class="chevron chevronBackground" src="'+wgBlankImgUrl+'" />'
+'<img class="chevron" src="'+wgBlankImgUrl+'" />';var preview=placeholder.data('preview');if(typeof preview=='undefined'){preview=$('<div>').addClass('RTEPlaceholderPreview RTEPlaceholderPreviewLoading');preview.html(chevron+'<div class="RTEPlaceholderPreviewInner">&nbsp;</div>');preview.bind('mouseover',function(){self.showPreview(placeholder);});preview.bind('mouseout',function(){self.hidePreview(placeholder);});this.previews.append(preview);placeholder.data('preview',preview);var data=placeholder.getData();var renderPreview=function(info){var title,intro;var className='RTEPlaceholderPreviewOther';var preformattedCode=true;var isEditable=false;var code=data.wikitext.replace(/</g,'&lt;').replace(/>/g,'&gt;');var lang=RTE.getInstance().lang.hoverPreview;switch(info.type){case'tpl':className='RTEPlaceholderPreviewTemplate';title=info.title.replace(/_/g,' ').replace(/^Template:/,window.RTEMessages.template+':');intro=info.exists?lang.template.intro:lang.template.notExisting;code=info.exists?info.html:data.wikitext;preformattedCode=!info.exists;isEditable=(typeof info.availableParams!='undefined'&&info.availableParams.length);break;case'comment':title=lang.comment.title;intro=lang.comment.intro;code=data.wikitext.replace(/^<!--\s+/,'').replace(/\s+-->$/,'');isEditable=true;break;case'broken-image':className='RTEPlaceholderPreviewBrokenImage';var imageName=data.wikitext.replace(/^\[\[/,'').replace(/\]\]$/,'').split('|').shift();title=imageName;intro=lang.media.notExisting;break;default:title=lang.codedElement.title;intro=lang.codedElement.intro;break;}
if(title.length>40){title=title.substr(0,40)+RTEMessages.ellipsis;}
if(preformattedCode&&CKEDITOR.env.ie){code=code.replace(/\n/g,'<br />');}
var intro='<div class="RTEPlaceholderPreviewIntro">'+intro+'</div>';var tools='',showEdit=true;if(showEdit&&isEditable){tools+='<img class="sprite edit" src="'+wgBlankImgUrl+'" />'+'<a class="RTEPlaceholderPreviewToolsEdit">'+lang.edit+'</a>';}
tools+='<img class="sprite remove" src="'+wgBlankImgUrl+'" />'+'<a class="RTEPlaceholderPreviewToolsDelete">'+
lang['delete']+'</a>';var html=chevron;html+='<div class="RTEPlaceholderPreviewInner '+className+'">';html+='<div class="RTEPlaceholderPreviewTitleBar color1"><span />'+title+'</div>';html+=intro;html+='<div class="RTEPlaceholderPreviewCode '+
(preformattedCode?'RTEPlaceholderPreviewPreformatted ':'')+'reset">'+code+'</div>';html+='<div class="RTEPlaceholderPreviewTools neutral">'+tools+'</div>';html+='</div>';preview.removeClass('RTEPlaceholderPreviewLoading').html(html).attr('type',info.type);preview.find('.RTEPlaceholderPreviewToolsDelete').bind('click',function(ev){self.track('button-delete');RTE.tools.confirm(title,lang.confirmDelete,function(){RTE.tools.removeElement(placeholder);preview.remove();}).data('tracking',{category:'placeholder'});});if(showEdit&&isEditable){preview.find('.RTEPlaceholderPreviewToolsEdit').bind('click',function(ev){preview.hide();self.track('button-edit');$(placeholder).trigger('edit');});}
preview.find('.RTEPlaceholderPreviewCode').bind('click',function(ev){ev.preventDefault();});preview.find('.RTEPlaceholderPreviewTitleBar').children('span').bind('click',function(ev){self.track('button-close');self.hidePreview(placeholder,true);});if(data.type=='double-brackets'){placeholder.data('info',info);}
self.expandPlaceholder(placeholder);};switch(data.type){case'double-brackets':RTE.tools.resolveDoubleBrackets(data.wikitext,renderPreview);break;default:renderPreview({type:data.type});}}
return preview;},showPreview:function(placeholder){var preview=this.getPreview(placeholder);var position=RTE.tools.getPlaceholderPosition(placeholder);var tempTop,freeBottomSpace=$(RTE.getInstance().getThemeSpace('contents').$).height()-position.top;if(freeBottomSpace<=preview.height()){tempTop=position.top-preview.height()-placeholder.height();preview.addClass('bottom');}else{tempTop=position.top+placeholder.height()+6;preview.removeClass('bottom');}
preview.css({'left':position.left+'px','top':parseInt(tempTop)+'px'});this.previews.children().not(preview).each(function(){$(this).hide();});var self=this;placeholder.data('showTimeout',setTimeout(function(){if(!preview.is(':visible')){preview.fadeIn();self.track({action:Wikia.Tracker.ACTIONS.HOVER,label:'show'});}
self.expandPlaceholder(placeholder);},150));var timeoutId=placeholder.data('hideTimeout');if(timeoutId){clearTimeout(timeoutId);}},hidePreview:function(placeholder,hideNow){var preview=this.getPreview(placeholder),showTimeout=placeholder.data('showTimeout')
if(showTimeout){clearTimeout(showTimeout);}
if(hideNow){preview.hide();}
else{placeholder.data('hideTimeout',setTimeout(function(){preview.fadeOut();placeholder.removeData('hideTimeout');},1000));}},setupPlaceholder:function(placeholder){var self=this;placeholder=placeholder.not('.placeholder-image-placeholder').not('.placeholder-video-placeholder');if(!placeholder.exists()){return;}
placeholder.unbind('.placeholder');placeholder.bind('mouseover.placeholder',function(){self.showPreview($(this));});placeholder.bind('mouseout.placeholder',function(){self.hidePreview($(this));});placeholder.bind('contextmenu.placeholder',function(ev){ev.stopPropagation();});RTE.tools.unselectable(placeholder);placeholder.bind('edit.placeholder',function(ev){var data=$(this).getData();switch(data.type){case'double-brackets':RTE.templateEditor.showTemplateEditor($(this));break;case'comment':RTE.commentEditor.showCommentEditor($(this));break;}});RTE.getEditor().unbind('dropped.placeholder').bind('dropped.placeholder',function(ev){var target=$(ev.target);target=target.filter('img.placeholder');self.setupPlaceholder(target);});if(RTE.config.disableDragDrop){RTE.tools.disableDragDrop(placeholder);}},expandPlaceholder:function(placeholder){var preview=this.getPreview(placeholder);var previewArea=preview.find('.RTEPlaceholderPreviewCode');if(previewArea.exists()){var domNode=previewArea[0];var scrollBarIsShown=(domNode.scrollHeight>domNode.clientHeight)||(domNode.scrollWidth>domNode.clientWidth);if(scrollBarIsShown){var height=domNode.scrollHeight;var width=domNode.scrollWidth;var x=parseInt(preview.offset().left)+width+16;var y=parseInt(preview.offset().top)+height+100;var editarea=$('#cke_contents_wpTextbox1');var maxX=parseInt(editarea.offset().left)+editarea.width();var maxY=parseInt(editarea.offset().top)+editarea.height();if(maxX<x){width-=(x-maxX);}
if(maxY<y){height-=(y-maxY);}
width=Math.max(width,350);height=Math.max(height,60);preview.children('.RTEPlaceholderPreviewInner').width(width);previewArea.height(height);previewArea.addClass('RTEPlaceholderPreviewExpanded');}
else{previewArea.removeClass('RTEPlaceholderPreviewExpanded');}}},track:(function(){var config={category:'placeholder'},slice=[].slice,track=WikiaEditor.track;return function(){track.apply(track,[config].concat(slice.call(arguments)));};})()});;CKEDITOR.plugins.add('rte-signature',{init:function(editor){editor.addCommand('addsignature',{exec:function(editor){var sig=RTE.getInstance().document.createText(editor.config.signature_markup);RTE.tools.insertElement($(sig.$));}});editor.ui.addButton('Signature',{title:editor.lang.signature.add,label:editor.lang.signature.label,className:'cke_label_button cke_button_signature',command:'addsignature'});}});CKEDITOR.config.signature_markup='~~~~';;CKEDITOR.plugins.add('rte-spellchecker',{beforeInit:function(editor){editor.config.menu_groups='spellchecker,spellcheckermore,'+editor.config.menu_groups;},init:function(editor){var enabled=false,langCode=window.wgContentLanguage;if(typeof window.wgSpellCheckerLangIsSupported!='undefined'){if(window.wgSpellCheckerLangIsSupported){RTE.log('spell checking enabled for "'+langCode+'"');enabled=true;}
else{RTE.log('spell checking is not supported for "'+langCode+'"');}}
else{RTE.log('spell checking disabled');}
if(enabled){editor.spellchecker=new CKEDITOR.spellchecker(editor,langCode);}}});CKEDITOR.spellchecker=function(editor,langCode){var self=this;this.editor=editor;this.langCode=langCode;this.parser=new CKEDITOR.htmlParser();editor.on('wysiwygModeReady',function(){self.checkEditbox();});editor.on('instanceReady',function(){var menu=editor.contextMenu;menu.addListener(function(node,selection){if(CKEDITOR.env.webkit){node=menu.originalEvent.getTarget();}
return self.showSuggestions(node);});});this.setupScayt();var dataProcessor=editor.dataProcessor,htmlFilter=dataProcessor&&dataProcessor.htmlFilter,spanRegExp=/^spellchecker/;if(htmlFilter){htmlFilter.addRules({elements:{span:function(element){if(spanRegExp.test(element.attributes['class'])){delete element.name;return element;}}}});}
this.nodeRunner=new CKEDITOR.nodeRunner();this.nodeRunner.isSkipped=this.isIgnoredNode;};CKEDITOR.spellchecker.prototype={wordsCache:{},CORRECT:1,MISSPELLED:0,SUGGESTIONS_LIMIT:6,SCAYT_DELAY_TIME:1000,SCAYT_DELAY_CHARS:20,recentText:'',nodeRunner:false,ajax:function(method,params,callback){params=params||{};params.method=method;jQuery.post(window.wgSpellCheckerUrl,params,function(data){if(typeof callback=='function'){callback(data);}},'json');},isMarkedNode:function(node){return node.hasClass('spellchecker-misspell');},isIgnoredNode:function(node){if(node.is('a')){if(node.hasClass('extiw')){return true;}
if(node.getAttribute('rel')=='nofollow'&&(node.getAttribute('href')==node.getText())){return true;}}
return false;},getTextFromEditor:function(){var separators=this.getSeparators(),text='';this.nodeRunner.walkTextNodes(this.editor.document.getBody(),function(node){text+=node.getText()+' ';});text=text.replace(/&[^;]+;/g,' ').replace(new RegExp('([0-9]|['+separators+'])','g'),' ').replace(/\s+/g,' ');text=$.trim(text);return text;},getWords:function(text){var words=[],index=[],raw=text.split(' ');$.each(raw,function(i,word){if(!index[word]){index[word]=1;words.push(word);}});return words;},getSeparators:function(){var i,re='',str='\\s!"#$%&()*+,-./:;<=>?@[]^_{|}\xA7\xA9\xAB\xAE\xB1\xB6\xB7\xB8\xBB\xBC\xBD\xBE\xBF\xD7\xF7\xA4\u201d\u201c';for(i=0;i<str.length;i++){re+='\\'+str.charAt(i);}
return re;},getSuggestions:function(word){var data=this.wordsCache[word];if(data&&data.length){return data;}},checkWords:function(words,callback){var self=this,w,wordsList=[];RTE.log('found '+words.length+' unique word(s)');for(w=0;w<words.length;w++){if(typeof this.wordsCache[words[w]]=='undefined'){wordsList.push(words[w]);}}
if(wordsList.length==0){RTE.log('spell checking data already in cache');callback.call();return;}
RTE.log('checking '+wordsList.length+' unique word(s)');var params={lang:this.langCode,words:wordsList.join(',')};this.ajax('checkWords',params,function(data){if(data.info){RTE.log(data['correct']+' word(s) spelled correctly ('+data['info']['provider']+')');self.updateWordsCache(wordsList,data.suggestions);if(typeof callback=='function'){callback.call();}}
else{RTE.log('spell checking request has failed!');}});},updateWordsCache:function(words,suggestions){var wordsCache=this.wordsCache,CORRECT=this.CORRECT;$.each(words,function(i,word){if(suggestions[word]){wordsCache[word]=suggestions[word];}
else{wordsCache[word]=CORRECT;}});},getMisspelledWords:function(){var CORRECT=this.CORRECT,misspelled=[];$.each(this.wordsCache,function(word,data){if(data!=CORRECT){misspelled.push(word);}});return misspelled;},highlightWords:function(){this.removeHighlight();var misspelledList=this.getMisspelledWords().join('|'),textNodes=[],self=this;if(misspelledList==''){return;}
this.nodeRunner.walkTextNodes(this.editor.document.getBody(),function(node){if(!self.isMarkedNode(node.getParent())){textNodes.push(node);}});var separators=this.getSeparators(),re=new RegExp('(^|['+separators+'])('+misspelledList+')($|['+separators+'])','g');$.each(textNodes,function(i,node){var value=node.getText(),parentNode=false;if(re.test(value)){value=value.replace(re,'$1<span class="spellchecker-misspell">$2</span>$3');parentNode=node.getParent();if(parentNode.hasClass('spellchecker-wrapper')&&parentNode.getChildCount()==1){parentNode.setHtml(value);}
else{var wrapper=new CKEDITOR.dom.element('span');wrapper.setHtml(value);wrapper.addClass('spellchecker-wrapper');wrapper.replace(node);}}});},removeHighlight:function(node){var self=this;if(!node){node=this.editor.document.getBody();}
this.nodeRunner.walk(node,function(node){if(node.type==CKEDITOR.NODE_ELEMENT&&self.isMarkedNode(node)){var newNode=new CKEDITOR.dom.text(node.getText());newNode.replace(node);}});},checkEditbox:function(){if(this.editor.mode!='wysiwyg'){return;}
var text=this.getTextFromEditor();if(text==''){return;}
if(text==this.recentText){RTE.log('text already checked');return;}
this.recentText=text;var words=this.getWords(text);var self=this;this.checkWords(words,function(){self.highlightWords();});},showSuggestions:function(node){if(this.isMarkedNode(node)){var commands={},subCommands={},n,word=node.getText(),self=this,suggestions=this.getSuggestions(word);if(!suggestions){RTE.log('no suggestions for "'+word+'"');return;}
RTE.log('showing '+suggestions.length+' suggestion(s) for "'+word+'"');for(n=0;n<suggestions.length;n++){var commandName=this.addSuggestItem(n+1,suggestions[n],function(suggestion){self.applySuggestion(node,suggestion);});if(n<this.SUGGESTIONS_LIMIT){commands[commandName]=CKEDITOR.TRISTATE_OFF;}
else{subCommands[commandName]=CKEDITOR.TRISTATE_OFF;}}
if(suggestions.length>this.SUGGESTIONS_LIMIT){this.editor.addMenuItem('spellcheckerMore',{label:this.editor.lang.spellchecker.moreSuggestions,group:'spellcheckermore',getItems:function(){return subCommands;}});commands['spellcheckerMore']=CKEDITOR.TRISTATE_OFF;}
return commands;}},addSuggestItem:function(index,suggestion,callback){var commandName='spellcheckerSuggest'+suggestion.replace(/[^\w]/g,'_');this.editor.addCommand(commandName,{exec:function(){callback(suggestion);}});this.editor.addMenuItem(commandName,{command:commandName,group:'spellchecker',label:suggestion,order:index});return commandName;},applySuggestion:function(node,suggestion){this.editor.fire('saveSnapshot');var newNode=new CKEDITOR.dom.text(suggestion);newNode.replace(node);this.editor.fire('saveSnapshot');},scaytCharacters:0,scaytTimeout:false,setupScayt:function(){var self=this;this.editor.on('key',function(ev){var keyCode=ev.data.keyCode;if(self.scaytTimeout){clearTimeout(self.scaytTimeout);self.scaytTimeout=false;}
self.scaytTimeout=setTimeout(function(){self.performScayt();},self.SCAYT_DELAY_TIME);self.scaytCharacters++;if(self.scaytCharacters>self.SCAYT_DELAY_CHARS){self.performScayt();}});},performScayt:function(){clearTimeout(this.scaytTimeout);this.scaytTimeout=false;this.scaytCharacters=0;this.checkEditbox();}};;CKEDITOR.plugins.add('rte-template',{init:function(editor){var self=this;CKEDITOR.dialog.add('rte-template',this.path+'dialogs/template.js');editor.ui.addRichCombo('Template',{label:editor.lang.templateDropDown.label,title:editor.lang.templateDropDown.title,className:'cke_template',multiSelect:false,panel:{css:[CKEDITOR.getUrl(editor.skinPath+'editor.css')].concat(editor.config.contentsCss)},init:function(){this.startGroup(editor.lang.templateDropDown.title);var templates=window.RTETemplatesDropdown;for(var t=0;t<templates.length;t++){var value=templates[t].replace(/_/g,' ');var label=window.RTEMessages.template+':'+value;this.add(templates[t],label,value);}
this.add('--other--','<strong>'+editor.lang.templateDropDown.chooseAnotherTpl+'</strong>',editor.lang.templateDropDown.chooseAnotherTpl);this.add('--list--','<strong>'+editor.lang.templateDropDown.showUsedList+'</strong>',editor.lang.templateDropDown.showUsedList);this.add('--make-layout--','<strong>'+editor.lang.templateDropDown.makeLayout+'</strong>',editor.lang.templateDropDown.makeLayout);},onClick:function(value){RTE.log('template dropdown: "'+value+'"');switch(value){case'--other--':RTE.templateEditor.createTemplateEditor(false);break;case'--list--':RTE.templateHelpers.showUsedList(editor);break;case'--make-layout--':RTE.templateHelpers.makeLayout(editor);break;default:RTE.templateEditor.createTemplateEditor(value);}
var dropdown=this;setTimeout(function(){dropdown.setValue(false);},50);}});editor.addCommand('InsertTemplate',{exec:function(editor,data){editor.fire('insertTemplate',data);if(data&&data.templateName)
RTE.templateEditor.createTemplateEditor(data.templateName);}});}});RTE.templateHelpers={showUsedList:function(editor){editor=editor||RTE.getInstance();var el=$('#editform > .templatesUsed');if(el.exists()){var list=$('<div>');list.html(el.html());list.children().not('ul').remove();list.find('a').attr('target','_blank');$.showModal(editor.lang.templateEditor.usedTemplates.title,list.html(),{width:400});}},makeLayout:function(){if(typeof window.PLBMakeLayoutUrl!='undefined'){$("#editform").attr("action",window.PLBMakeLayoutUrl).submit();}else{}}};RTE.templateEditor={placeholder:false,data:{},dialog:{},doPreview:function(callback){RTE.log('generating preview...');$('#templatePreview').html('').addClass('loading');var params={};$('#templateParameters').find('textarea').each(function(){var key=$(this).attr('rel');var value=$(this).attr('value');params[key]=value;});var wikitext=this.data.wikitext=this.generateWikitext(this.data.title,params);RTE.tools.parse(wikitext,function(html){$('#templatePreview').html(html).removeClass('loading');$('#templatePreview').bind('click',function(ev){ev.preventDefault();});if(typeof callback=='function'){callback();}});},generateWikitext:function(name,params){var wikitext,paramsCount=0,currentData=this.placeholder?this.placeholder.getData():false,bracketPattern=/\[\[(.*?)\]\]/g;if(bracketPattern.test(currentData.wikitext)){var results=currentData.wikitext.match(bracketPattern),i=0,replacement;for(i=0;i<results.length;i++){replacement=results[i].replace(/\|/g,'\x7f');currentData.wikitext=currentData.wikitext.replace(results[i],replacement);}}
var wikitextParts=currentData.wikitext.substring(2,currentData.wikitext.length-2).split('|');var partsStack=[wikitextParts.shift()];var unnamedCounter=0;var lineBreakInTail=false;if(wikitextParts.length==0){partsStack=[name+"\n"];lineBreakInTail=true;}
$.each(wikitextParts,function(i,part){var parsedPart=part.match(/([^=]+)( *\= *)(.*)(\n?)/);if(parsedPart){var partName=$.trim(parsedPart[1]);var partSeparator=parsedPart[2];var partValue=parsedPart[3];var partTail=parsedPart[4];if(partTail!=''){lineBreakInTail=true;}
if(typeof params[partName]!='undefined'){partsStack.push(parsedPart[1]+partSeparator+params[partName]+partTail);delete params[partName];}}
else{parsedPart=part.match(/(.*)(\n?)/);var partName=++unnamedCounter;var partValue=parsedPart[1];var partTail=parsedPart[2];if(partTail!=''){lineBreakInTail=true;}
if(typeof params[partName]!='undefined'){partsStack.push(params[partName]+partTail);}
else if($.trim(partValue)){partsStack.push(partValue+partTail);}
else{partsStack.push('');}
delete params[partName];}});$.each(params,function(key,value){if(typeof value=='undefined'){return;}
if(parseInt(key)&&parseInt(key)==key){partsStack.push(value!=''?value:'');if(wikitextParts.length==0){partsStack[0]=$.trim(partsStack[0]);}}
else{if(value!=''){partsStack.push(key+' = '+value+(lineBreakInTail?'\n':''));}}});wikitext='{{';wikitext+=partsStack.join('|').replace('\x7f','|').replace(/[\n|]+$/g,'').replace(/\n+$/g,'');wikitext+='}}';$().log(currentData.wikitext,'RTE: old wikitext');$().log(wikitext,'RTE: new wikitext');return wikitext;},selectStep:function(stepId){RTE.log('showing step #'+stepId);RTE.log(this.placeholder);var dialog=this.dialog;dialog.selectPage('step'+stepId);var info=this.placeholder.data('info');var data=this.placeholder.getData();$('.templateEditorDialog').find('.cke_dialog_footer').hide();switch(stepId){case 1:var renderFirstStep=function(){var html='';$(window.RTEHotTemplates).each(function(i,template){html+='<li><a rel="'+template+'">'+template.replace(/_/g,' ')+'</a></li>';});$('#templateEditorHotTemplates').html(html);var html='';$(window.RTEMagicWords.magicWords).each(function(i,magic){html+='<li><a rel="'+magic+'">'+magic.toUpperCase()+'</a></li>';});$('#templateEditorMagicWords').html(html);var self=this;$('#templateEditorHotTemplates').find('a').click(function(ev){var templateName=$(this).attr('rel');RTE.templateEditor.selectTemplate(dialog,templateName);});$('#templateEditorMagicWords').find('a').click(function(ev){var name=$(this).attr('rel');RTE.log('adding magic word: '+name);var data={};var isDoubleUnderscore=RTEMagicWords.doubleUnderscores.indexOf(name)>-1;if(isDoubleUnderscore){data.type='double-underscore';data.wikitext='__'+name.toUpperCase()+'__';}
else{data.type='double-brackets';data.title=name.toUpperCase();data.wikitext='{{'+name.toUpperCase()+'}}';}
RTE.log(data);var placeholder=RTE.templateEditor.placeholder;placeholder.setPlaceholderType(data.type);placeholder.setData(data);RTE.templateEditor.usePlaceholder(placeholder);dialog.hide();RTE.templateEditor.commitChanges();});dialog.enableSuggesionsOn(dialog.getContentElement('step1','templateSearchQuery'),[10]);}
if(typeof window.RTEHotTemplates=='undefined'){dialog.setLoading(true);RTE.ajax('getHotTemplates',{},function(hotTemplates){dialog.setLoading(false);window.RTEHotTemplates=hotTemplates;renderFirstStep();});}
else{renderFirstStep();}
break;case 2:$('.templateEditorDialog').find('.cke_dialog_footer').show();var templateName=info.title.replace(/_/g,' ');templateName=templateName.replace(/^Template:/,window.RTEMessages.template+':');$('#templateEditorTemplateName').html(templateName);var viewHref=window.wgServer+window.wgArticlePath.replace(/\$1/,encodeURI(info.title.replace(/ /g,'_')));$('#templateEditorViewLink').attr('href',viewHref);var html='';$.each(info.availableParams,function(i,key){var value=(info.passedParams&&typeof info.passedParams[key]!='undefined')?info.passedParams[key]:'';value=value.replace(/&/g,'&amp;');var keyLabel=!!parseInt(key)?('#'+parseInt(i+1)):key;html+='<dt><label for="templateEditorParameter'+i+'">'+keyLabel+'</label></dt>';html+='<dd><textarea rel="'+key+'" id="templateEditorParameter'+i+'">'+value+'</textarea></dd>';});$('#templateParameters').html(html).find('dd > textarea').keydown(this.onTextareaKeyDown);this.doPreview();break;case 3:$('#templateAdvEditorSource').attr('value',data.wikitext);RTE.tools.parse(data.wikitext,function(html){$('#templateAdvPreview').html(html);});break;}},onTextareaKeyDown:function(ev){if(ev.which==9){var next=$(this).parent('dd').next('dt').next('dd').children('textarea').first();if(next.size()==1){next.focus();ev.stopPropagation();ev.preventDefault();}}},selectTemplate:function(dialog,templateName){RTE.log('selecting template: '+templateName);var data={title:templateName,wikitext:'{{'+templateName+'}}'};this.placeholder.setPlaceholderType('double-brackets');this.placeholder.setData(data);RTE.templateEditor.usePlaceholder(this.placeholder);dialog.setLoading(true);var self=this;RTE.tools.resolveDoubleBrackets(data.wikitext,function(info){dialog.setLoading(false);self.placeholder.data('info',info);if((typeof info.availableParams!='undefined')&&(info.availableParams.length>0)){RTE.templateEditor.selectStep(2);}
else{RTE.log('given template contains no params - inserting / updating...');RTE.templateEditor.commitChanges();dialog.hide();return;}});},usePlaceholder:function(placeholder){this.placeholder=placeholder;this.data=placeholder.getData();},commitChanges:function(){RTE.log('storing modified template data');RTE.log(this.data);this.placeholder.setData(RTE.templateEditor.data);this.placeholder.removeData('preview');this.placeholder.removeData('info');if(!this.placeholder.parent().exists()){RTE.tools.insertElement(this.placeholder);}
this.placeholder=false;this.data={};},showTemplateEditor:function(placeholder){RTE.log('calling template editor...');RTE.templateEditor.usePlaceholder(placeholder);RTE.getInstance().openDialog('rte-template');},createTemplateEditor:function(templateName){if(RTE.getInstance().mode=='source'){if(templateName){insertTags('{{'+templateName,'}}','');}
return}
var placeholder=RTE.tools.createPlaceholder('double-brackets');if(templateName==false){RTE.log('calling template editor to choose a template...');this.showTemplateEditor(placeholder);return;}
RTE.log('calling template editor for new template "'+templateName+'"');var wikitext='{{'+templateName+'}}';placeholder.setData({title:templateName,wikitext:wikitext});var self=this;RTE.tools.resolveDoubleBrackets(wikitext,function(info){placeholder.data('info',info);if((typeof info.availableParams!='undefined')&&(info.availableParams.length>0)){self.showTemplateEditor(placeholder);}
else{RTE.log('given template contains no params - inserting...');RTE.tools.insertElement(placeholder);return;}});}};;CKEDITOR.dialog.add('rte-template',function(editor)
{var lang=editor.lang.templateEditor;var magicWordsLink=window.wgArticlePath.replace(/\$1/,lang.dialog.magicWordsLink.replace(/ /g,'_'))
return{title:lang.title,minWidth:760,minHeight:365,buttons:[{id:'chooseAnotherTpl',type:'button',label:lang.editor.chooseAnotherTpl,className:'cke_dialog_choose_another_tpl',buttonType:'secondary',onClick:function(ev){WikiaEditor.track('dialog-rte-template-button-choose-another');RTE.templateEditor.selectStep(1);}},CKEDITOR.dialog.okButton,CKEDITOR.dialog.cancelButton],contents:[{id:'step1',label:'Step 1',elements:[{type:'hbox',widths:['300px','300px','30px'],children:[{type:'html',className:'templateEditorHeader dark_text_2',html:lang.dialog.search},{id:'templateSearchQuery',style:'margin-top: 7px',type:'text'},{id:'templateDoSearch',type:'button',label:lang.dialog.insert,style:'position: relative; top: 6px',onClick:function(){var dialog=this.getDialog();var templateName=dialog.getValueOf('step1','templateSearchQuery');if(templateName==''){return;}
WikiaEditor.track('dialog-rte-template-button-insert');RTE.templateEditor.selectTemplate(dialog,templateName);}}]},{type:'html',html:'<hr />'},{type:'html',className:'templateEditorHeader',html:lang.dialog.browse},{type:'hbox',widths:['510px','250px'],children:[{type:'html',html:'<h2>'+lang.dialog.mostFrequentlyUsed+'</h2>'+'<ul id="templateEditorHotTemplates"></ul>'},{type:'html',html:'<h2><a id="templateLinkToHelp" target="_blank" href="'+magicWordsLink+'">'+lang.dialog.magicWords+'</a></h2>'+'<ul id="templateEditorMagicWords"></ul>'}]}]},{id:'step2',label:'Step 2',elements:[{type:'html',html:'<div id="templateEditorIntro">'+'<h1 id="templateEditorTemplateName" class="dark_text_2"></h1>'+'<a id="templateEditorViewLink" href="#" target="_blank">'+lang.editor.viewTemplate+'</a>'+'<p>'+lang.editor.intro+'</p>'+'</div>'},{type:'hbox',widths:['330px','100px','330px'],children:[{type:'html',html:'<h2>'+lang.editor.parameters+'</h2>'+'<dl id="templateParameters"></dl>'},{type:'button',label:lang.editor.previewButton,onClick:function(){var self=this;WikiaEditor.track('dialog-rte-template-button-preview');this.disable();RTE.templateEditor.doPreview.apply(RTE.templateEditor,[function(){self.enable();}]);}},{type:'html',html:'<h2>'+lang.editor.previewTitle+'</h2>'+'<div id="templatePreview" class="reset"></div>'}]}]}],onOk:function(){var step=parseInt(this.getActiveTab().charAt(4));switch(step){case 1:this.getContentElement('step1','templateDoSearch').fire('click');return false;case 2:RTE.templateEditor.doPreview(function(){RTE.templateEditor.commitChanges();});break;case 3:RTE.templateEditor.data.wikitext=$('#templateAdvEditorSource').attr('value');RTE.templateEditor.commitChanges();break;}},onShow:function(){this._.element.addClass('wikiaEditorDialog');this._.element.addClass('templateEditorDialog');RTE.templateEditor.dialog=this;RTE.templateEditor.data=RTE.templateEditor.placeholder.getData();var info=RTE.templateEditor.placeholder.data('info');var step=1;if(info){RTE.log(info);step=2;}
RTE.templateEditor.selectStep(step);},onFocus:function(){}};});;CKEDITOR.plugins.add('rte-temporary-save',{init:function(editor){editor.on('instanceReady',function(){var mode=$('#RTETemporarySaveType').attr('value');if(mode){RTE.log('restoring temporary save (using "'+mode+'" mode)');var content=$('#RTETemporarySaveContent').attr('value');editor.setMode(mode);editor.setData(content);}});$(window).bind('beforeunload',function(ev){RTE.log('onbeforeunload: performing temporary save');$('#RTETemporarySaveType').attr('value',RTE.getInstance().mode);$('#RTETemporarySaveContent').attr('value',RTE.getInstance().getData());});}});;CKEDITOR.plugins.add('rte-toolbar',{beforeInit:function(editor){editor.ui.addHandler(CKEDITOR.UI_SEPARATOR,CKEDITOR.ui.separator.handler);editor.ui.add('|',CKEDITOR.UI_SEPARATOR,{});}});CKEDITOR.UI_SEPARATOR=10;CKEDITOR.ui.separator=function(){};CKEDITOR.ui.separator.handler={create:function(definition){return new CKEDITOR.ui.separator();}};CKEDITOR.ui.separator.prototype={render:function(editor,output){output.push('<span class="cke_separator">&nbsp;</span>');}};;CKEDITOR.plugins.add('rte-tools',{});window.RTE.tools={'alert':function(title,content){'use strict';require(['wikia.ui.factory'],function(uiFactory){uiFactory.init(['modal']).then(function(modal){var modalConfig={vars:{id:'RTEAlertModal',content:'<p>'+content+'</p>',size:'small',title:title}};modal.createComponent(modalConfig,function(RTEAlertModal){RTEAlertModal.show();});});});},callFunction:function(fn,element,data){if(typeof fn!='function'){return;}
var ev=jQuery.Event('rte');ev.data=(typeof data=='object')?data:{};ev.data.element=element||false;ev.target=window.document.createElement('div');fn.call(window,ev);},checkInternalLink:function(element,pageName){var anchor='';if(/^#(.+)/.test(pageName)){anchor=pageName;pageName=window.wgPageName;}
RTE.ajax('checkInternalLink',{title:pageName},function(data){if(!data.exists){element.addClass('new');}
else{element.removeClass('new');}
element.setAttribute('href',data.href+anchor);element.setAttribute('title',data.title);});},"confirm":function(title,question,callback){var html='<p>'+question+'</p>'+'<div class="RTEConfirmButtons neutral">'+'<a id="RTEConfirmCancel" class="wikia-button secondary"><span>'+RTE.getInstance().lang.common.cancel+'</span></a>'+'<a id="RTEConfirmOk" class="wikia-button"><span>'+RTE.getInstance().lang.common.ok+'</span></a>'+'</div>';function track(label){var data=$('#RTEConfirm').data('tracking');if(data){WikiaEditor.track(data,label);}}
var wrapper=$.showModal(title,html,{id:'RTEConfirm',className:'RTEModal',width:500,onClose:function(){track('rte-confirm-close');},callbackBefore:function(){$('#RTEConfirmOk').click(function(){track('button-rte-confirm-ok');$('#RTEConfirm').closeModal();if(typeof callback=='function'){callback();}});$('#RTEConfirmCancel').click(function(){track('button-rte-confirm-cancel');$('#RTEConfirm').closeModal();});}});return wrapper;},createPlaceholder:function(type,data){var placeholder=$('<img />',RTE.getInstance().document.$);placeholder.addClass('placeholder placeholder-'+type);placeholder.attr('src',wgBlankImgUrl).attr('type',type).attr('data-rte-instance',RTE.instanceId);data=data&&(typeof data=='object')?data:{};data.type=type;data.placeholder=true;placeholder.setData(data);RTE.log('creating new placeholder for "'+type+'"');RTE.log(placeholder);return placeholder;},disableDragDrop:function(nodes){nodes.bind('mousedown',function(ev){ev.preventDefault();});},getEditorHeight:function(){return $('#cke_contents_'+WikiaEditor.instanceId).height();},getEditorScrollOffsets:function(){var scrollLeft,scrollTop;if(CKEDITOR.env.webkit){scrollLeft=RTE.getInstance().document.$.body.scrollLeft;scrollTop=RTE.getInstance().document.$.body.scrollTop;}
else{scrollLeft=RTE.getInstance().document.$.documentElement.scrollLeft;scrollTop=RTE.getInstance().document.$.documentElement.scrollTop;}
return{left:scrollLeft,top:scrollTop};},getThemeColors:function(){var colorPicker=$('#RTEColorPicker');if(!colorPicker.exists()){colorPicker=$('<div id="RTEColorPicker">').addClass('color1').appendTo(RTE.overlayNode).hide();}
RTE.config.baseBackgroundColor=colorPicker.css('backgroundColor');RTE.config.baseColor=colorPicker.css('color');},getImages:function(){var images=RTE.getEditor().find('img.image');return images;},getMedia:function(){var media=RTE.getEditor().find('img.image,img.video');return media;},getPlaceholderPosition:function(placeholder){var position=placeholder.offset(),scrollOffsets=this.getEditorScrollOffsets();return{left:parseInt(position.left-scrollOffsets.left),top:parseInt(position.top-scrollOffsets.top)};},getPlaceholders:function(type){var query=type?('img[type='+type+']'):'img.placeholder';var placeholders=RTE.getEditor().find(query);return placeholders;},getSelectionContent:function(){var text;if(CKEDITOR.env.ie){text=RTE.getInstance().document.$.selection.createRange().text;}
else{text=RTE.getInstance().window.$.getSelection().toString();}
return text;},getVideos:function(){var videos=RTE.getEditor().find('img.video');return videos;},insertElement:function(element,dontReinitialize){var CKelement=new CKEDITOR.dom.element($(element).get(0));RTE.getInstance().insertElement(CKelement);if(!dontReinitialize){RTE.getInstance().fire('wysiwygModeReady');}},isExternalLink:function(href){return this.isExternalLinkRegExp.test(href);},isExternalLinkRegExp:new RegExp('^'+window.RTEUrlProtocols),parseCache:{},parse:function(wikitext,callback){var cache=RTE.tools.parseCache;if(typeof cache[wikitext]!='undefined'){RTE.log('RTE.tools.parse() - cache hit');if(typeof callback=='function'){callback(cache[wikitext]);}
return;}
RTE.ajax('parse',{wikitext:wikitext,title:window.wgPageName},function(json){cache[wikitext]=json.html;if(typeof callback=='function'){callback(json.html);}});},parseRTE:function(wikitext,callback){RTE.ajax('rteparse',{wikitext:wikitext,title:window.wgPageName},function(json){if(typeof callback=='function'){callback(json.html);}});},renumberExternalLinks:function(){RTE.getEditor().find('a.autonumber').each(function(i){$(this).text('['+(i+1)+']');});},removeElement:function(elem){RTE.getInstance().fire('saveSnapshot');$(elem).remove();RTE.getInstance().fire('saveSnapshot');},removeResizeBox:function(){setTimeout(function(){if(CKEDITOR.env.gecko){var documentNode=RTE.getInstance().document.$;documentNode.designMode='off';documentNode.designMode='on';}},50);},resolveDoubleBracketsCache:{},resolveDoubleBrackets:function(wikitext,callback){var cache=RTE.tools.resolveDoubleBracketsCache;if(typeof cache[wikitext]!='undefined'){RTE.log('RTE.tools.resolveDoubleBrackets() - cache hit');if(typeof callback=='function'){callback(cache[wikitext]);}
return;}
RTE.ajax('resolveDoubleBrackets',{wikitext:wikitext,title:window.wgPageName},function(json){cache[wikitext]=json;if(typeof callback=='function'){callback(json);}});},unselectable:function(elem){}}
CKEDITOR.nodeRunner=function(){};CKEDITOR.nodeRunner.prototype={walk:function(node,callback){if((node.type!=CKEDITOR.NODE_ELEMENT)||node.isReadOnly()||this.isSkipped(node)){return;}
var childNode,childNodes=node.getChildren();for(var n=0,len=childNodes.count();n<len;n++){childNode=childNodes.getItem(n);callback(childNode);this.walk(childNode,callback);}},walkTextNodes:function(node,callback){this.walk(node,function(node){if(node.type==CKEDITOR.NODE_TEXT){callback(node);}});},isSkipped:function(node){return false;}};;CKEDITOR.themes.add('wikia',(function()
{return{build:function(editor,themePath)
{var name=editor.name,element=editor.element,elementMode=editor.elementMode;if(!element||elementMode==CKEDITOR.ELEMENT_MODE_NONE)
return;if(elementMode==CKEDITOR.ELEMENT_MODE_REPLACE)
element.addClass('replaced');var contentsHtml=editor.fire('themeSpace',{space:'contents',html:'',elements:[]}).html;var height=contentsHtml&&editor.config.height;var tabIndex=editor.config.tabIndex||editor.element.getAttribute('tabindex')||0;if(!contentsHtml)
height='auto';else if(!isNaN(height))
height+='px';var style='';var width=editor.config.width;if(width)
{if(!isNaN(width))
width+='px';style+="width: "+width+";";}
var container=CKEDITOR.dom.element.createFromHtml(['<div'+' id="cke_',name,'"'+' class="',editor.skinClass,'"'+' dir="',editor.lang.dir,'"'+' title="',(CKEDITOR.env.gecko?' ':''),'"'+' lang="',editor.langCode,'"'+' tabindex="'+tabIndex+'"'+
(style?' style="'+style+'"':'')+'>'+'<div class="',CKEDITOR.env.cssClass,'">'+'<div class="cke_wrapper cke_',editor.lang.dir,'">'+'<div id="cke_contents_',name,'" class="cke_contents" style="height:',height,'">',contentsHtml,'</div>'+'<style>.',editor.skinClass,'{visibility:hidden;}</style>'+'</div>'+'</div>'+'</div>'].join(''));if(elementMode==CKEDITOR.ELEMENT_MODE_REPLACE)
container.insertAfter(element);else
element.append(container);editor.container=container;container.disableContextMenu();editor.fireOnce('themeLoaded');editor.fireOnce('uiReady');RTE.log('theme is ready');},buildDialog:function(editor)
{var baseIdNumber=CKEDITOR.tools.getNextNumber();var element=CKEDITOR.dom.element.createFromHtml(['<div id="cke_'+editor.name.replace('.','\\.')+'_dialog" class="cke_skin_',editor.skinName,'" dir="',editor.lang.dir,'"'+' lang="',editor.langCode,'"'+'>'+'<div class="cke_dialog modalWrapper',' '+CKEDITOR.env.cssClass,' cke_',editor.lang.dir,'" style="position:absolute">'+'<div class="%body">'+'<div id="%title#" class="%title"></div>'+'<div id="%close_button#" class="%close_button close wikia-chiclet-button"><img src="'+window.stylepath+'/oasis/images/icon_close.png" /></div>'+'<div id="%tabs#" class="%tabs accent tabs"></div>'+'<div id="%contents#" class="%contents"></div>'+'<div id="%footer#" class="%footer"></div>'+'</div>'+'<div id="%tl#" class="%tl"></div>'+'<div id="%tc#" class="%tc"></div>'+'<div id="%tr#" class="%tr"></div>'+'<div id="%ml#" class="%ml"></div>'+'<div id="%mr#" class="%mr"></div>'+'<div id="%bl#" class="%bl"></div>'+'<div id="%bc#" class="%bc"></div>'+'<div id="%br#" class="%br"></div>'+'</div>',(CKEDITOR.env.ie?'':'<style>.cke_dialog{visibility:hidden;}</style>'),'</div>'].join('').replace(/#/g,'_'+baseIdNumber).replace(/%/g,'cke_dialog_'));var body=element.getChild([0,0]);body.getChild(0).unselectable();body.getChild(1).unselectable();body.getChild(0).setStyles({backgroundColor:RTE.config.baseBackgroundColor,color:RTE.config.baseColor});return{element:element,parts:{dialog:element.getChild(0),title:body.getChild(0),close:body.getChild(1),tabs:body.getChild(2),contents:body.getChild(3),footer:body.getChild(4)}};},destroy:function(editor)
{var container=editor.container,panels=editor.panels;if(CKEDITOR.env.ie)
{container.setStyle('display','none');var $range=document.body.createTextRange();$range.moveToElementText(container.$);try
{$range.select();}
catch(e){}}
if(container)
container.remove();for(var i=0;panels&&i<panels.length;i++)
panels[i].remove();if(editor.elementMode==CKEDITOR.ELEMENT_MODE_REPLACE)
{editor.element.show();delete editor.element;}}};})());CKEDITOR.editor.prototype.getThemeSpace=function(spaceName)
{var elementId=WikiaEditor.instanceId,getSpaceId=function(editorName,spaceName){switch(spaceName){case'tabs':return elementId+'Tabs';case'toolbar':return elementId+'Toolbar';case'contents':return spacePrefix+'_'+editorName;case'rail':return elementId+'Rail';}};var spacePrefix='cke_'+spaceName;var space=this._[spacePrefix]||(this._[spacePrefix]=CKEDITOR.document.getById(getSpaceId(this.name,spaceName)));return space;};CKEDITOR.editor.prototype.resize=function(width,height,isContentHeight,resizeInner)
{var numberRegex=/^\d+$/;if(numberRegex.test(width)){width+='px';}
var contents=CKEDITOR.document.getById('cke_contents_'+this.name);var outer=resizeInner?contents.getAscendant('table').getParent():contents.getAscendant('table').getParent().getParent().getParent();CKEDITOR.env.webkit&&outer.setStyle('display','none');outer.setStyle('width',width);if(CKEDITOR.env.webkit)
{outer.$.offsetWidth;outer.setStyle('display','');}
var delta=isContentHeight?0:(outer.$.offsetHeight||0)-(contents.$.clientHeight||0);contents.setStyle('height',Math.max(height-delta,0)+'px');this.fire('resize');};CKEDITOR.editor.prototype.getResizable=function()
{return this.container.getChild([0,0]);};;CKEDITOR.skins.add('wikia',(function()
{var preload=[];if(CKEDITOR.env.ie&&CKEDITOR.env.version<7)
{preload.push('icons.png','images/sprites_ie6.png','images/dialog_sides.gif');}
return{preload:preload,editor:{css:[$.getSassCommonURL('/extensions/wikia/RTE/ckeditor/_source/skins/wikia/editor.scss')]},dialog:{},templates:{css:['templates.css']},margins:[0,0,0,0],init:function(editor)
{if(editor.config.width&&!isNaN(editor.config.width))
editor.config.width-=12;var uiColorMenus=[];var uiColorRegex=/\$color/g;var uiColorMenuCss="/* UI Color Support */\
.cke_skin_wikia .cke_menuitem .cke_icon_wrapper\
{\
 background-color: $color !important;\
 border-color: $color !important;\
}\
\
.cke_skin_wikia .cke_menuitem a:hover .cke_icon_wrapper,\
.cke_skin_wikia .cke_menuitem a:focus .cke_icon_wrapper,\
.cke_skin_wikia .cke_menuitem a:active .cke_icon_wrapper\
{\
 background-color: $color !important;\
 border-color: $color !important;\
}\
\
.cke_skin_wikia .cke_menuitem a:hover .cke_label,\
.cke_skin_wikia .cke_menuitem a:focus .cke_label,\
.cke_skin_wikia .cke_menuitem a:active .cke_label\
{\
 background-color: $color !important;\
}\
\
.cke_skin_wikia .cke_menuitem a.cke_disabled:hover .cke_label,\
.cke_skin_wikia .cke_menuitem a.cke_disabled:focus .cke_label,\
.cke_skin_wikia .cke_menuitem a.cke_disabled:active .cke_label\
{\
 background-color: transparent !important;\
}\
\
.cke_skin_wikia .cke_menuitem a.cke_disabled:hover .cke_icon_wrapper,\
.cke_skin_wikia .cke_menuitem a.cke_disabled:focus .cke_icon_wrapper,\
.cke_skin_wikia .cke_menuitem a.cke_disabled:active .cke_icon_wrapper\
{\
 background-color: $color !important;\
 border-color: $color !important;\
}\
\
.cke_skin_wikia .cke_menuitem a.cke_disabled .cke_icon_wrapper\
{\
 background-color: $color !important;\
 border-color: $color !important;\
}\
\
.cke_skin_wikia .cke_menuseparator\
{\
 background-color: $color !important;\
}\
\
.cke_skin_wikia .cke_menuitem a:hover,\
.cke_skin_wikia .cke_menuitem a:focus,\
.cke_skin_wikia .cke_menuitem a:active\
{\
 background-color: $color !important;\
}";if(CKEDITOR.env.webkit)
{uiColorMenuCss=uiColorMenuCss.split('}').slice(0,-1);for(var i=0;i<uiColorMenuCss.length;i++)
uiColorMenuCss[i]=uiColorMenuCss[i].split('{');}
function addStylesheet(document)
{var node=document.getHead().append('style');node.setAttribute("id","cke_ui_color");node.setAttribute("type","text/css");return node;}
function updateStylesheets(styleNodes,styleContent,replace)
{var r,i,content;for(var id=0;id<styleNodes.length;id++)
{if(CKEDITOR.env.webkit)
{for(i=0;i<styleNodes[id].$.sheet.rules.length;i++)
styleNodes[id].$.sheet.removeRule(i);for(i=0;i<styleContent.length;i++)
{content=styleContent[i][1];for(r=0;r<replace.length;r++)
content=content.replace(replace[r][0],replace[r][1]);styleNodes[id].$.sheet.addRule(styleContent[i][0],content);}}
else
{content=styleContent;for(r=0;r<replace.length;r++)
content=content.replace(replace[r][0],replace[r][1]);if(CKEDITOR.env.ie)
styleNodes[id].$.styleSheet.cssText=content;else
styleNodes[id].setHtml(content);}}}
var uiColorRegexp=/\$color/g;CKEDITOR.tools.extend(editor,{uiColor:null,getUiColor:function()
{return this.uiColor;},setUiColor:function(color)
{var cssContent,uiStyle=addStylesheet(CKEDITOR.document),cssId='#cke_'+editor.name.replace('.','\\.');var cssSelectors=[cssId+" .cke_wrapper",cssId+"_dialog .cke_dialog_contents",cssId+"_dialog a.cke_dialog_tab",cssId+"_dialog .cke_dialog_footer"].join(',');var cssProperties="background-color: $color !important;";if(CKEDITOR.env.webkit)
cssContent=[[cssSelectors,cssProperties]];else
cssContent=cssSelectors+'{'+cssProperties+'}';return(this.setUiColor=function(color)
{var replace=[[uiColorRegexp,color]];editor.uiColor=color;updateStylesheets([uiStyle],cssContent,replace);updateStylesheets(uiColorMenus,uiColorMenuCss,replace);})(color);}});editor.on('menuShow',function(event)
{var panel=event.data[0];var iframe=panel.element.getElementsByTag('iframe').getItem(0).getFrameDocument();if(!iframe.getById('cke_ui_color'))
{var node=addStylesheet(iframe);uiColorMenus.push(node);var color=editor.getUiColor();if(color)
updateStylesheets([node],uiColorMenuCss,[[uiColorRegexp,color]]);}});if(editor.config.uiColor)
editor.setUiColor(editor.config.uiColor);}};})());if(CKEDITOR.dialog)
{CKEDITOR.dialog.on('resize',function(evt)
{var data=evt.data,width=data.width,height=data.height,dialog=data.dialog,contents=dialog.parts.contents,standardsMode=!CKEDITOR.env.quirks;if(data.skin!='wikia')
return;contents.setStyles((CKEDITOR.env.ie||CKEDITOR.env.opera||(CKEDITOR.env.gecko&&CKEDITOR.env.version<10900))?{width:width+'px',height:height+'px'}:{'min-width':width+'px','min-height':height+'px'});if(!CKEDITOR.env.ie)
return;setTimeout(function()
{var body=contents.getParent(),innerDialog=body.getParent();var el=innerDialog.getChild(2);el.setStyle('width',(body.$.offsetWidth)+'px');el=innerDialog.getChild(7);el.setStyle('width',(body.$.offsetWidth-28)+'px');el=innerDialog.getChild(4);el.setStyle('height',(body.$.offsetHeight-31-14)+'px');el=innerDialog.getChild(5);el.setStyle('height',(body.$.offsetHeight-31-14)+'px');},100);});};