var imageTag = false; var theSelection = false; var clientPC = navigator.userAgent.toLowerCase(); var clientVer = parseInt(navigator.appVersion); var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1)); var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1) && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1) && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1)); var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1)); var is_mac = (clientPC.indexOf("mac")!=-1); b_help = "Bold text: [b]text[/b] (alt+b)"; i_help = "Italic text: [i]text[/i] (alt+i)"; u_help = "Underline text: [u]text[/u] (alt+u)"; q_help = "Quote text: [quote]text[/quote] or [quote=username]text[/quote] (alt+q)"; c_help = "Code display: [code]code[/code] (alt+c)"; l_help = "List: [list]text[/list] (alt+l)"; o_help = "Ordered list: [list=]text[/list] (alt+o)"; p_help = "Insert image: [img]http://image_url[/img] (alt+p)"; w_help = "Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url] (alt+w)"; a_help = "Close all open bbCode tags"; s_help = "Font color: [color=red]text[/color] Tip: you can also use color=#FF0000"; f_help = "Font size: [size=x-small]small text[/size]"; bbcode = new Array(); bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]'); imageTag = false; function tips(help) { document.post.hints.value = eval(help + "_help"); } function getarraysize(thearray) { for (i = 0; i < thearray.length; i++) { if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null)) return i; } return thearray.length; } function arraypush(thearray,value) { thearray[ getarraysize(thearray) ] = value; } function arraypop(thearray) { thearraysize = getarraysize(thearray); retval = thearray[thearraysize - 1]; delete thearray[thearraysize - 1]; return retval; } function checkForm() { formErrors = false; if (document.post.message.value.length < 2) { formErrors = "You must enter a message when posting"; } if (document.post.subject.value.length < 2) { formErrors = "All threads must have subjects"; } if (formErrors) { alert(formErrors); return false; } else { bzstyle(-1); return true; } } function emoticon(text) { text = ' ' + text + ' '; if (document.post.message.createTextRange && document.post.message.caretPos) { var caretPos = document.post.message.caretPos; caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text; document.post.message.focus(); } else { document.post.message.value += text; document.post.message.focus(); } } function thefont(bbopen, bbclose) { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (!theSelection) { document.post.message.value += bbopen + bbclose; document.post.message.focus(); return; } document.selection.createRange().text = bbopen + theSelection + bbclose; document.post.message.focus(); return; } else { document.post.message.value += bbopen + bbclose; document.post.message.focus(); return; } beefcake(document.post.message); } function bzstyle(bbnumber) { donotinsert = false; theSelection = false; bblast = 0; if (bbnumber == -1) { while (bbcode[0]) { butnumber = arraypop(bbcode) - 1; document.post.message.value += bbtags[butnumber + 1]; buttext = eval('document.post.quickcode' + butnumber + '.value'); eval('document.post.quickcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"'); } imageTag = false; document.post.message.focus(); return; } if ((clientVer >= 4) && is_ie && is_win) theSelection = document.selection.createRange().text; if (theSelection) { document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1]; document.post.message.focus(); theSelection = ''; return; } for (i = 0; i < bbcode.length; i++) { if (bbcode[i] == bbnumber+1) { bblast = i; donotinsert = true; } } if (donotinsert) { while (bbcode[bblast]) { butnumber = arraypop(bbcode) - 1; document.post.message.value += bbtags[butnumber + 1]; buttext = eval('document.post.quickcode' + butnumber + '.value'); eval('document.post.quickcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"'); imageTag = false; } document.post.message.focus(); return; } else { if (imageTag && (bbnumber != 14)) { document.post.message.value += bbtags[15]; lastValue = arraypop(bbcode) - 1; document.post.quickcode14.value = "Img"; imageTag = false; } document.post.message.value += bbtags[bbnumber]; if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; arraypush(bbcode,bbnumber+1); eval('document.post.quickcode'+bbnumber+'.value += "*"'); document.post.message.focus(); return; } beefcake(document.post.message); } function beefcake(textEl) { if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate(); }