if(!Liferay.Editor.bbCode){Liferay.Editor.bbCode=new Class({initialize:function(B){var A=this;B=B||{};A._textarea=jQuery(B.textarea);A._location=jQuery(B.location||[]);A._createEmoticons();A._createToolbar();if(B.onLoad){B.onLoad()}},getHTML:function(B){var A=this;return A._textarea.val()},insertTag:function(O,C,I){var N=this;var G;if(C){G="["+O+"="+C+"]"}else{G="["+O+"]"}var E="[/"+O+"]";var M=N._textarea;var K=M[0];var L=M.val();M.trigger("focus");if(Liferay.Browser.is_ie){var B=document.selection.createRange();if(I!=null){B.text=G+I+E}else{B.text=G+B.text+E}B.moveEnd("character",-E.length);B.select()}else{if(K.selectionStart||K.selectionStart==0){var H=K.selectionStart;var A=K.selectionEnd;var D=L.substring(0,H);var B=L.substring(H,A);var J=L.substring(A,K.value.length);var F=H+G.length;if(I!=null){K.value=D+G+I+E+J}else{K.value=D+G+B+E+J;K.setSelectionRange(F,F)}}else{K.value+=G+I+E}}},setHTML:function(B){var A=this;A._textarea.val(B)},_createEmoticons:function(){var A=this;var D=jQuery.ajax({url:themeDisplay.getPathMain()+"/portal/emoticons",async:false});var B=D.responseText;var C=jQuery("<div class=\"lfr-emoticon-container\"></div>").appendTo("body");A._emoticons=C.append(B);A._emoticons.find(".emoticon").click(function(F){var E=this.getAttribute("emoticonCode");if(E){A._insertEmoticon(E)}})},_createToolbar:function(){var K=this;var G="";K._buttons={fontType:{options:[Liferay.Language.get("font"),"Arial","Comic Sans","Courier New","Tahoma","Times New Roman","Verdana","Wingdings"],onChange:function(L){var M=this[this.selectedIndex].value;if(M!=Liferay.Language.get("font")){K.insertTag("font",this[this.selectedIndex].value);this.selectedIndex=0}}},fontSize:{options:[Liferay.Language.get("size"),1,2,3,4,5,6,7],onChange:function(L){var M=this[this.selectedIndex].value;if(M!=Liferay.Language.get("size")){K.insertTag("size",this[this.selectedIndex].value);this.selectedIndex=0}},groupEnd:true},b:{text:"bold",image:"message_boards/bold.png",onClick:function(L){K.insertTag("b")}},i:{text:"italic",image:"message_boards/italic.png",onClick:function(L){K.insertTag("i")}},u:{text:"underline",image:"message_boards/underline.png",onClick:function(L){K.insertTag("u")}},s:{text:"strikethrough",image:"message_boards/strike.png",onClick:function(L){K.insertTag("s")}},fontColor:{className:"use-colorpicker",text:"font-color",image:"message_boards/color.png",groupEnd:true},url:{text:"url",image:"message_boards/hyperlink.png",onClick:function(L){K._insertURL()}},email:{text:"email-address",image:"message_boards/email.png",onClick:function(L){K._insertEmail()}},image:{text:"image",image:"message_boards/image.png",onClick:function(L){K._insertImage()}},ol:{text:"ordered-list",image:"message_boards/ordered_list.png",onClick:function(L){K._insertList("1")}},ul:{text:"unordered-list",image:"message_boards/unordered_list.png",onClick:function(L){K._insertList("")}},left:{text:"left",image:"message_boards/justify_left.png",onClick:function(L){K.insertTag("left")}},center:{text:"center",image:"message_boards/justify_center.png",onClick:function(L){K.insertTag("center")}},right:{text:"right",image:"message_boards/justify_right.png",onClick:function(L){K.insertTag("right")}},indent:{text:"indent",image:"message_boards/indent.png",onClick:function(L){K.insertTag("indent")}},quote:{text:"quote",image:"message_boards/quote.png",onClick:function(L){K.insertTag("quote")}},code:{text:"code",image:"message_boards/code.png",onClick:function(L){K.insertTag("code")}},emoticons:{text:"emoticons",image:"emoticons/smile.gif"}};jQuery.each(K._buttons,function(N,P){var M=" "+(this.className||"");var O=Liferay.Language.get(this.text)||"";if(N!="insert"&&!this.options){var L=themeDisplay.getPathThemeImages()+"/"+this.image;G+="<a buttonId=\""+N+"\" class=\"lfr-button "+M+"\" href=\"javascript: ;\" title=\""+O+"\"><img alt=\""+O+"\" buttonId=\""+N+"\" src=\""+L+"\" ></a>"}else{if(this.options&&this.options.length){G+="<select class=\""+M+"\" selectId=\""+N+"\" title=\""+O+"\">";jQuery.each(this.options,function(R,Q){G+="<option value=\""+Q+"\">"+Q+"</option>"});G+="</select>"}}if(this.groupEnd){G+="<span class=\"lfr-separator\"></span>"}});if(!K._location.length){K._location=jQuery("<div class=\"lfr-toolbar\">"+G+"</div>");K._textarea.before(K._location)}else{K._location.html(G)}var E=K._location.find(".lfr-button[@buttonId=emoticons]");var D=false;var C=0;var I=0;var F=0;E.hoverIntent({interval:0,timeout:250,over:function(L){var O=E.offset({lite:true});if(C==0){C=this.offsetHeight}if(I==0){I=this.offsetWidth}K._emoticons.show();if(F==0){F=K._emoticons.width()}var N=O.left-(F-I);var M=O.top+C;K._emoticons.css({left:N,top:M})},out:function(L){if(!D){K._emoticons.hide()}}});K._emoticons.hoverIntent({interval:0,timeout:250,over:function(L){D=true;K._emoticons.show()},out:function(L){K._emoticons.hide();D=false}});if(Liferay.Browser.is_firefox){var H=K._emoticons[0];var A;H.onmouseover=function(L){if(A){clearTimeout(A)}};H.onmouseout=function(L){A=setTimeout(function(){K._emoticons.hide()},250)}}K._location.click(function(M){var N=M.target;var L=M.target.getAttribute("buttonId");if(L&&K._buttons[L].onClick){K._buttons[L].onClick.apply(N,[M])}});var J=K._location.find("select");J.change(function(M){var L=this.getAttribute("selectId");if(L&&K._buttons[L].onChange){K._buttons[L].onChange.apply(this,[M])}});K._fontColorInput=jQuery("<input type=\"hidden\" val=\"\" />");K._location.find(".use-colorpicker").before(K._fontColorInput);var B=new Liferay.ColorPicker({hasImage:true,onClose:function(){K._insertColor()}})},_insertColor:function(){var A=this;var B=A._fontColorInput.val();A.insertTag("color",B)},_insertEmail:function(){var A=this;var C=prompt(Liferay.Language.get("enter-an-email-address"),"");if(C){var B=prompt(Liferay.Language.get("enter-a-name-for-the-email-address"),"");A._resetSelection();if(!B){B=C;C=null}A.insertTag("email",C,B)}},_insertEmoticon:function(F){var I=this;var H=I._textarea;var G=H[0];H.trigger("focus");if(Liferay.Browser.is_ie){G.focus();var B=document.selection.createRange();B.text=F}else{if(G.selectionStart||G.selectionStart=="0"){var D=G.selectionStart;var A=G.selectionEnd;var C=G.value.substring(0,D);var E=G.value.substring(A,G.value.length);G.value=C+F+E}else{G.value+=F}}},_insertImage:function(){var A=this;var B=prompt(Liferay.Language.get("enter-an-address-for-the-image"),"http://");if(B){A._resetSelection();A.insertTag("img",null,B)}},_insertList:function(B){var A=this;var D="\n";var C;while(C=prompt(Liferay.Language.get("enter-a-list-item-click-cancel-or-leave-blank-to-end-the-list"),"")){if(!C){break}D+="[*]"+C+"\n"}if(D!="\n"){A._resetSelection();A.insertTag("list",B,D)}},_insertURL:function(){var A=this;var B=prompt(Liferay.Language.get("enter-an-address"),"http://");if(B!=null){var C=prompt(Liferay.Language.get("enter-a-title-for-the-address"),"");if(C){A._resetSelection();A.insertTag("url",B,C)}else{A.insertTag("url",B)}}},_resetSelection:function(){var A=this;var B=A._textarea;var D=B[0];if(Liferay.Browser.is_ie){D.focus();var C=document.selection.createRange();C.collapse(false);C.select()}else{if(D.selectionStart){D.selectionEnd=D.selectionStart}}}})}