CKEDITOR.dialog.add("smiley",function(s){for(var t=s.config,v=s.lang.smiley,o=t.smiley_images,r=t.smiley_columns||8,l,j=function(f){var g=f.data.getTarget(),d=g.getName();if("a"==d){g=g.getChild(0)}else{if("img"!=d){return}}var d=g.getAttribute("cke_src"),e=g.getAttribute("title"),g=s.document.createElement("img",{attributes:{src:d,"data-cke-saved-src":d,title:e,alt:e,width:g.$.width,height:g.$.height}});s.insertElement(g);l.hide();f.data.preventDefault()},b=CKEDITOR.tools.addFunction(function(f,h){f=new CKEDITOR.dom.event(f);h=new CKEDITOR.dom.element(h);var e;e=f.getKeystroke();var g="rtl"==s.lang.dir;switch(e){case 38:if(e=h.getParent().getParent().getPrevious()){e=e.getChild([h.getParent().getIndex(),0]),e.focus()}f.preventDefault();break;case 40:(e=h.getParent().getParent().getNext())&&(e=e.getChild([h.getParent().getIndex(),0]))&&e.focus();f.preventDefault();break;case 32:j({data:f});f.preventDefault();break;case g?37:39:if(e=h.getParent().getNext()){e=e.getChild(0),e.focus(),f.preventDefault(!0)}else{if(e=h.getParent().getParent().getNext()){(e=e.getChild([0,0]))&&e.focus(),f.preventDefault(!0)}}break;case g?39:37:if(e=h.getParent().getPrevious()){e=e.getChild(0),e.focus(),f.preventDefault(!0)}else{if(e=h.getParent().getParent().getPrevious()){e=e.getLast().getChild(0),e.focus(),f.preventDefault(!0)}}}}),u=CKEDITOR.tools.getNextId()+"_smiley_emtions_label",u=['<div><span id="'+u+'" class="cke_voice_label">'+v.options+"</span>",'<table role="listbox" aria-labelledby="'+u+'" style="width:100%;height:100%;border-collapse:separate;" cellspacing="2" cellpadding="2"',CKEDITOR.env.ie&&CKEDITOR.env.quirks?' style="position:absolute;"':"","><tbody>"],i=o.length,v=0;v<i;v++){0===v%r&&u.push('<tr role="presentation">');var c="cke_smile_label_"+v+"_"+CKEDITOR.tools.getNextNumber();u.push('<td class="cke_dark_background cke_centered" style="vertical-align: middle;" role="presentation"><a href="javascript:void(0)" role="option"',' aria-posinset="'+(v+1)+'"',' aria-setsize="'+i+'"',' aria-labelledby="'+c+'"',' class="cke_smile cke_hand" tabindex="-1" onkeydown="CKEDITOR.tools.callFunction( ',b,', event, this );">','<img class="cke_hand" title="',t.smiley_descriptions[v],'" cke_src="',CKEDITOR.tools.htmlEncode(t.smiley_path+o[v]),'" alt="',t.smiley_descriptions[v],'"',' src="',CKEDITOR.tools.htmlEncode(t.smiley_path+o[v]),'"',CKEDITOR.env.ie?" onload=\"this.setAttribute('width', 2); this.removeAttribute('width');\" ":"",'><span id="'+c+'" class="cke_voice_label">'+t.smiley_descriptions[v]+"</span></a>","</td>");v%r==r-1&&u.push("</tr>")}if(v<r-1){for(;v<r-1;v++){u.push("<td></td>")}u.push("</tr>")}u.push("</tbody></table></div>");t={type:"html",id:"smileySelector",html:u.join(""),onLoad:function(d){l=d.sender},focus:function(){var d=this;setTimeout(function(){d.getElement().getElementsByTag("a").getItem(0).focus()},0)},onClick:j,style:"width: 100%; border-collapse: separate;"};return{title:s.lang.smiley.title,minWidth:270,minHeight:120,contents:[{id:"tab1",label:"",title:"",expand:!0,padding:0,elements:[t]}],buttons:[CKEDITOR.dialog.cancelButton]}});