var bodytext = ""; 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_moz = 0; var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1)); var is_mac = (clientPC.indexOf("mac")!=-1); function mozWrap(txtareat, open, close) { var selLength = txtareat.textLength; var selStart = txtareat.selectionStart; var selEnd = txtareat.selectionEnd; if (selEnd == 1 || selEnd == 2) selEnd = selLength; var s1 = (txtareat.value).substring(0,selStart); var s2 = (txtareat.value).substring(selStart, selEnd) var s3 = (txtareat.value).substring(selEnd, selLength); txtareat.value = s1 + open + s2 + close + s3; return; } function setfocus() { document.postform.body.focus(); } function addQuote() { if (document.postform.quote.value!="") { AddText(document.postform.quote.value); document.postform.quote.value = ""; } } function getActiveText(selectedtext) { var dob = document.postform.body bodytext = (document.selection) ? document.selection.createRange().text : ""; if (selectedtext.createTextRange) { selectedtext.caretPos = document.selection.createRange().duplicate(); } else if (dob.setSelectionRange) { bodytext = dob.value.substring(dob.selectionStart,dob.selectionEnd); } } function AddText(NewCode) { var dob = document.postform.body; if (dob.createTextRange && dob.caretPos) { var caretPos = dob.caretPos; caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? NewCode + ' ' : NewCode; } else if (dob.setSelectionRange) { dob.value = dob.value.substring(0,dob.selectionStart) + NewCode + dob.value.substring(dob.selectionEnd,dob.value.length); } else { dob.value += NewCode; } setfocus(); bodytext = ""; } function bold() { //blackcodes start here var txtarea = document.postform.body; if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection) { document.selection.createRange().text = "[b]" + theSelection + "[/b]"; txtarea.focus(); theSelection = ''; return; } } else //if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) { mozWrap(txtarea, "[b]", "[/b]"); return; } //blackcodes ends here //AddTxt="[b]"+bodytext+"[/b]"; //AddText(AddTxt); } function italicize() { //blackcodes start here var txtarea = document.postform.body; if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection) { document.selection.createRange().text = "[i]" + theSelection + "[/i]"; txtarea.focus(); theSelection = ''; return; } } else //if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) { mozWrap(txtarea, "[i]", "[/i]"); return; } //blackcodes ends here //AddTxt="[i]"+bodytext+"[/i]"; //AddText(AddTxt); } function underline() { //blackcodes start here var txtarea = document.postform.body; if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection) { document.selection.createRange().text = "[u]" + theSelection + "[/u]"; txtarea.focus(); theSelection = ''; return; } } else //if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) { mozWrap(txtarea, "[u]", "[/u]"); return; } //blackcodes ends here //AddTxt="[u]"+bodytext+"[/u]"; //AddText(AddTxt); } function quotte() { //blackcodes start here var txtarea = document.postform.body; if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection) { document.selection.createRange().text = "[quote]" + theSelection + "[/quote]"; txtarea.focus(); theSelection = ''; return; } } else //if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) { mozWrap(txtarea, "[quote]", "[/quote]"); return; } //blackcodes ends here //AddTxt="[quote]"+bodytext+"[/quote]"; //AddText(AddTxt); } function showcolor(bs216) { //new changes in here //AddTxt="[color="+bs216+"]"+bodytext+"[/color]"; //AddText(AddTxt); //blackcodes start here var txtarea = document.postform.body; if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection) { document.selection.createRange().text = "[color="+bs216+"]" + theSelection + "[/color]"; txtarea.focus(); theSelection = ''; return; } } else //if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) { mozWrap(txtarea, "[color="+bs216+"]", "[/color]"); return; } //blackcodes ends here } /* function hyperlink() { //blackcodes start here var txtarea = document.postform.body; if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection) { document.selection.createRange().text = "[link=]" + theSelection + "[/link]"; txtarea.focus(); theSelection = ''; return; } } else //if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) { mozWrap(txtarea, "[link=]", "[/link]"); return; } //blackcodes ends here //AddTxt="[link=]"+bodytext+"[/link]"; //AddText(AddTxt); } */ function image() { //blackcodes start here var txtarea = document.postform.body; if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection) { document.selection.createRange().text = "[image]" + theSelection + "[/image]"; txtarea.focus(); theSelection = ''; return; } } else //if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) { mozWrap(txtarea, "[image]", "[/image]"); return; } //blackcodes ends here //AddTxt="[image]"+bodytext+"[/image]"; //AddText(AddTxt); } function showcode() { //blackcodes start here var txtarea = document.postform.body; if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection) { document.selection.createRange().text = "[code]" + theSelection + "[/code]"; txtarea.focus(); theSelection = ''; return; } } else //if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) { mozWrap(txtarea, "[code]", "[/code]"); return; } //blackcodes ends here //AddTxt="[code]"+bodytext+"[/code]"; //AddText(AddTxt); } function list() { //blackcodes start here var txtarea = document.postform.body; if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection) { document.selection.createRange().text = "[ul]\r[*] " + theSelection + "\r[*] \r[*] \r[/ul]"; txtarea.focus(); theSelection = ''; return; } } else //if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) { mozWrap(txtarea, "[ul]\r[*] ", "\r[*] \r[*] \r[/ul]"); return; } //blackcodes ends here //AddTxt = "[ul]\r[*] "+bodytext+"\r[*] \r[*] \r[/ul]"; //AddText(AddTxt); } function changesize(s) { //blackcodes start here var txtarea = document.postform.body; if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection) { document.selection.createRange().text = "[size="+s+"]" + theSelection + "[/size]"; txtarea.focus(); theSelection = ''; return; } } else //if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) { mozWrap(txtarea, "[size="+s+"]", "[/size]"); return; } //blackcodes ends here //AddTxt="[size="+s+"]"+bodytext+"[/size]"; //AddText(AddTxt); } function adjustright() { //blackcodes start here var txtarea = document.postform.body; if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection) { document.selection.createRange().text = "[right]" + theSelection + "[/right]"; txtarea.focus(); theSelection = ''; return; } } else //if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) { mozWrap(txtarea, "[right]", "[/right]"); return; } //blackcodes ends here //AddTxt="[right]"+bodytext+"[/right]"; //AddText(AddTxt); } function adjustcenter() { //blackcodes start here var txtarea = document.postform.body; if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection) { document.selection.createRange().text = "[center]" + theSelection + "[/center]"; txtarea.focus(); theSelection = ''; return; } } else //if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) { mozWrap(txtarea, "[center]", "[/center]"); return; } //blackcodes ends here //AddTxt="[center]"+bodytext+"[/center]"; //AddText(AddTxt); } function adjustleft() { //blackcodes start here var txtarea = document.postform.body; if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection) { document.selection.createRange().text = "[left]" + theSelection + "[/left]"; txtarea.focus(); theSelection = ''; return; } } else //if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) { mozWrap(txtarea, "[left]", "[/left]"); return; } //blackcodes ends here //AddTxt="[left]"+bodytext+"[/left]"; //AddText(AddTxt); } /* New changes starts here */ function fontface() { //blackcodes start here var txtarea = document.postform.body; if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection) { document.selection.createRange().text = "[font=\"\"]" + theSelection + "[/font]"; txtarea.focus(); theSelection = ''; return; } } else //if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) { mozWrap(txtarea, "[font=\"\"]", "[/font]"); return; } //blackcodes ends here //AddTxt="[font=\"\"]"+bodytext+"[/font]"; //AddText(AddTxt); } function embeding() { //blackcodes start here var txtarea = document.postform.body; if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection) { document.selection.createRange().text = "[embed]" + theSelection + "[/embed]"; txtarea.focus(); theSelection = ''; return; } } else //if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) { mozWrap(txtarea, "[embed]", "[/embed]"); return; } //blackcodes ends here //AddTxt="[embed]"+bodytext+"[/embed]"; //AddText(AddTxt); } function changeface(s) { //blackcodes start here var txtarea = document.postform.body; if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection) { document.selection.createRange().text = "[font=\""+s+"\"]" + theSelection + "[/font]"; txtarea.focus(); theSelection = ''; return; } } else //if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) { mozWrap(txtarea, "[font=\""+s+"\"]", "[/font]"); return; } //blackcodes ends here //AddTxt="[font=\""+s+"\"]"+bodytext+"[/font]"; //AddText(AddTxt); } /* Additional Helper functions - don't change below this line */ function changefontsize(s) { if (s.selectedIndex != 0) { changesize(s.options[s.selectedIndex].value); s.selectedIndex = 0; return false; } } function changefontface(s) { if (s.selectedIndex != 0) { changeface(s.options[s.selectedIndex].value); s.selectedIndex = 0; return false; } }