bbtags = new Array(); //-------------------------------------------- // Get stack size //-------------------------------------------- function stacksize(thearray) { for (i = 0 ; i < thearray.length; i++ ) { if ( (thearray[i] == "") || (thearray[i] == null) || (thearray == 'undefined') ) { return i; } } return thearray.length; } //-------------------------------------------- // Push stack //-------------------------------------------- function pushstack(thearray, newval) { arraysize = stacksize(thearray); thearray[arraysize] = newval; } //-------------------------------------------- // Pop stack //-------------------------------------------- function popstack(thearray) { arraysize = stacksize(thearray); theval = thearray[arraysize - 1]; delete thearray[arraysize - 1]; return theval; } //-------------------------------------------- // Close current open tag //-------------------------------------------- function closelast() { if (bbtags[0]) { document.REPLIER.Post.value += "[/" + popstack(bbtags) + "]"; } document.REPLIER.Post.focus(); } //-------------------------------------------- // Close all tags //-------------------------------------------- function closeall() { if (bbtags[0]) { while (bbtags[0]) { document.REPLIER.Post.value += "[/" + popstack(bbtags) + "]"; } document.REPLIER.Post.value += " "; } document.REPLIER.Post.focus(); } //-------------------------------------------- // EMOTICONS //-------------------------------------------- function emoticon(theSmilie) { if (document.REPLIER.Post.caretPos && document.REPLIER.Post.createTextRange) { var caretPos = document.REPLIER.Post.caretPos; caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? theSmilie + ' ' : theSmilie; } else { document.REPLIER.Post.value += ' ' + theSmilie + ' '; } document.REPLIER.Post.focus(); } //-------------------------------------------- // ADD CODE //-------------------------------------------- function add_code(NewCode) { document.REPLIER.Post.value += NewCode; document.REPLIER.Post.focus(); return; } //-------------------------------------------- // ALTER FONT //-------------------------------------------- function alterfont(theval, thetag) { if (theval == 0) { return; } else { document.REPLIER.Post.value += "[" + thetag + "=" + theval + "]"; pushstack(bbtags, thetag); } document.REPLIER.ffont.selectedIndex = 0; document.REPLIER.fsize.selectedIndex = 0; document.REPLIER.fcolor.selectedIndex = 0; document.REPLIER.Post.focus(); } //-------------------------------------------- // SIMPLE TAGS (such as B, I U, etc) //-------------------------------------------- function simpletag(thetag) { document.REPLIER.Post.value += "[" + thetag + "]"; pushstack(bbtags, thetag); document.REPLIER.Post.focus(); } function tag_url() { var FoundErrors = ''; var enterURL = prompt(text_enter_url, "http://"); var enterTITLE = prompt(text_enter_url_name, "My Webpage"); if (!enterURL) { FoundErrors += " " + error_no_url; } if (!enterTITLE) { FoundErrors += " " + error_no_title; } if (FoundErrors) { alert("Error!"+FoundErrors); return; } var ToAdd = "[URL="+enterURL+"]"+enterTITLE+"[/URL]"; document.REPLIER.Post.value+=ToAdd; document.REPLIER.Post.focus(); } function tag_image() { var FoundErrors = ''; var enterURL = prompt(text_enter_image, "http://"); if (!enterURL) { FoundErrors += " " + error_no_url; } if (FoundErrors) { alert("Error!"+FoundErrors); return; } var ToAdd = "[IMG]"+enterURL+"[/IMG]"; document.REPLIER.Post.value+=ToAdd; document.REPLIER.Post.focus(); } function tag_email() { var emailAddress = prompt(text_enter_email,""); if (!emailAddress) { alert(error_no_email); return; } var ToAdd = "[EMAIL]"+emailAddress+"[/EMAIL]"; document.REPLIER.Post.value+=ToAdd; document.REPLIER.Post.focus(); }