CKEDITOR.dialog.add("smiley",function(B){var T=B.config,U=B.lang.smiley,Q=window.vBulletin.smilieInfo,A=T.smiley_columns||8,O;var P;var C=function(W){var Z=W.data.getTarget(),Y=Z.getName();if(Y=="a"){Z=Z.getChild(0)}else{if(Y!="img"){return }}var b=Z.getAttribute("cke_src"),a=Z.getAttribute("title"),V=Z.getAttribute("smilieid");var X=B.document.createElement("img",{attributes:{src:b,"data-cke-saved-src":b,title:a,alt:a,width:Z.$.width,height:Z.$.height,smilieid:V,"class":"inlineimg"}});B.insertElement(X);P.hide();W.data.preventDefault()};var S=CKEDITOR.tools.addFunction(function(W,V){W=new CKEDITOR.dom.event(W);V=new CKEDITOR.dom.element(V);var Y,X;var a=W.getKeystroke(),Z=B.lang.dir=="rtl";switch(a){case 38:if((Y=V.getParent().getParent().getPrevious())){X=Y.getChild([V.getParent().getIndex(),0]);X.focus()}W.preventDefault();break;case 40:if((Y=V.getParent().getParent().getNext())){X=Y.getChild([V.getParent().getIndex(),0]);if(X){X.focus()}}W.preventDefault();break;case 32:C({data:W});W.preventDefault();break;case Z?37:39:case 9:if((Y=V.getParent().getNext())){X=Y.getChild(0);X.focus();W.preventDefault(true)}else{if((Y=V.getParent().getParent().getNext())){X=Y.getChild([0,0]);if(X){X.focus()}W.preventDefault(true)}}break;case Z?39:37:case CKEDITOR.SHIFT+9:if((Y=V.getParent().getPrevious())){X=Y.getChild(0);X.focus();W.preventDefault(true)}else{if((Y=V.getParent().getParent().getPrevious())){X=Y.getLast().getChild(0);X.focus();W.preventDefault(true)}}break;default:return }});var R=CKEDITOR.tools.getNextId()+"_smiley_emtions_label";var I=['<div><span id="'+R+'" class="cke_voice_label">'+U.options+"</span>",'<table role="listbox" aria-labelledby="'+R+'" style="width:100%;height:100%" cellspacing="2" cellpadding="2"',CKEDITOR.env.ie&&CKEDITOR.env.quirks?' style="position:absolute;"':"","><tbody>"];var K=-1;$.each(Q,function(V,W){K++});var L=0;var H="";var E=0;for(desc in Q){if(!desc){continue}var N=Q[desc].c;var F=Q[desc].s;var J=Q[desc].id;if(L==0){I.push("<tr>")}if(N){if(L!=0){I.push('<td colspan="'+(A-L)+'"></td>');I.push("</tr><tr>")}I.push('<td colspan="'+A+'" class="smiley_category">'+N+"</td></tr>");I.push("<tr>");L=0}L++;var G="cke_smile_label_"+J+"_"+CKEDITOR.tools.getNextNumber();var D=(!F.match(/^https?:\/\//))?T.smiley_path+F:F;I.push('<td class="cke_dark_background cke_centered" style="vertical-align: middle;"><a href="javascript:void(0)" role="option"',' aria-posinset="'+(E+1)+'"',' aria-setsize="'+K+'"',' aria-labelledby="'+G+'"',' class="cke_smile cke_hand" tabindex="-1" onkeydown="CKEDITOR.tools.callFunction( ',S,', event, this );">','<img class="cke_hand" title="',desc,'" cke_src="',CKEDITOR.tools.htmlEncode(D),'" alt="',desc,'"',' smilieid="',J,'"',' src="',CKEDITOR.tools.htmlEncode(D),'"',(CKEDITOR.env.ie?" onload=\"this.setAttribute('width', 2); this.removeAttribute('width');\" ":""),'><span id="'+G+'" class="cke_voice_label">'+desc+"</span></a>","</td>");if(L==A){I.push("</tr>");L=0}E++}if(L<A){I.push('<td colspan="'+(A-L)+'"></td>');I.push("</tr>")}I.push("</tbody></table></div>");var M={type:"html",id:"smileySelector",html:I.join(""),onLoad:function(V){P=V.sender},focus:function(){var V=this;setTimeout(function(){var W=V.getElement().getElementsByTag("a").getItem(0);if(W){W.focus()}},0)},onClick:C,style:"width: 100%; border-collapse: separate;"};return{onShow:function(){var V=this.parts.contents.getChildren().getItem(0);V.addClass("smiley_page")},title:B.lang.smiley.title,minWidth:270,minHeight:120,contents:[{id:"tab1",label:"",title:"",expand:true,padding:0,elements:[M]}],buttons:[CKEDITOR.dialog.cancelButton]}});