if(!Liferay.Editor.bbCode){Liferay.Editor.bbCode=new Liferay.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();if(Liferay.Browser.isIe()){n._setSelectionRange();if(i!=null){n._selectionRange.text=g+i+e}else{n._selectionRange.text=g+n._selectionRange.text+e}n._selectionRange.moveEnd("character",-e.length);n._selectionRange.select();n._selectionRange=null}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}}m.trigger("focus")},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(o,q){var m=" "+(this.className||"");var p=Liferay.Language.get(this.text)||"";if(o!="insert"&&!this.options){var l=themeDisplay.getPathThemeImages()+"/"+this.image;g+='<a buttonId="'+o+'" class="lfr-button '+m+'" href="javascript: ;" title="'+p+'"><img alt="'+p+'" buttonId="'+o+'" src="'+l+'" ></a>'}else{if(this.options&&this.options.length){g+='<select class="'+m+'" selectId="'+o+'" title="'+p+'">';jQuery.each(this.options,function(r,n){g+='<option value="'+n+'">'+n+"</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.isFirefox()){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){k._setSelectionRange();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.isIe()){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.isIe()){d.focus();var c=document.selection.createRange();c.collapse(false);c.select()}else{if(d.selectionStart){d.selectionEnd=d.selectionStart}}},_setSelectionRange:function(){var a=this;if(Liferay.Browser.isIe()&&(a._selectionRange==null)){a._textarea.trigger("focus");a._selectionRange=document.selection.createRange()}}})};