bName = navigator.appName;
bVer = parseInt(navigator.appVersion);
ver="n2";
if (bName == "Netscape" && bVer >= 3) ver = "n3";
else if (bName == "Netscape" && bVer == 2) ver = "n2";
else if (bName == "Microsoft Internet Explorer" && bVer >= 4) ver = "n3";
else if (bName == "Microsoft Internet Explorer" && bVer == 2) ver = "n2";

if (ver != "n2") {
	format_b = new Image();
	format_b.src = "img/formatbuttons_b.gif";
	format_b_over = new Image();
	format_b_over.src = "img/formatbuttons_b-over.gif";
	format_b_press = new Image();
	format_b_press.src = "img/formatbuttons_b-press.gif";
	format_i = new Image();
	format_i.src = "img/formatbuttons_i.gif";
	format_i_over = new Image();
	format_i_over.src = "img/formatbuttons_i-over.gif";
	format_i_press = new Image();
	format_i_press.src = "img/formatbuttons_i-press.gif";
	format_u = new Image();
	format_u.src = "img/formatbuttons_u.gif";
	format_u_over = new Image();
	format_u_over.src = "img/formatbuttons_u-over.gif";
	format_u_press = new Image();
	format_u_press.src = "img/formatbuttons_u-press.gif";
	format_quote = new Image();
	format_quote.src = "img/formatbuttons_quote.gif";
	format_quote_over = new Image();
	format_quote_over.src = "img/formatbuttons_quote-over.gif";
	format_quote_press = new Image();
	format_quote_press.src = "img/formatbuttons_quote-press.gif";
	format_img = new Image();
	format_img.src = "img/formatbuttons_img.gif";
	format_img_over = new Image();
	format_img_over.src = "img/formatbuttons_img-over.gif";
	format_img_press = new Image();
	format_img_press.src = "img/formatbuttons_img-press.gif";	
	format_happy = new Image();
	format_happy.src = "img/formatbuttons_happy.gif";
	format_happy_over = new Image();
	format_happy_over.src = "img/formatbuttons_happy-over.gif";
	format_happy_press = new Image();
	format_happy_press.src = "img/formatbuttons_happy-press.gif";
	format_sad = new Image();
	format_sad.src = "img/formatbuttons_sad.gif";
	format_sad_over = new Image();
	format_sad_over.src = "img/formatbuttons_sad-over.gif";
	format_sad_press = new Image();
	format_sad_press.src = "img/formatbuttons_sad-press.gif";
	format_laugh = new Image();
	format_laugh.src = "img/formatbuttons_laugh.gif";
	format_laugh_over = new Image();
	format_laugh_over.src = "img/formatbuttons_laugh-over.gif";
	format_laugh_press = new Image();
	format_laugh_press.src = "img/formatbuttons_laugh-press.gif";
	format_wink = new Image();
	format_wink.src = "img/formatbuttons_wink.gif";
	format_wink_over = new Image();
	format_wink_over.src = "img/formatbuttons_wink-over.gif";
	format_wink_press = new Image();
	format_wink_press.src = "img/formatbuttons_wink-press.gif";
	format_razz = new Image();
	format_razz.src = "img/formatbuttons_razz.gif";
	format_razz_over = new Image();
	format_razz_over.src = "img/formatbuttons_razz-over.gif";
	format_razz_press = new Image();
	format_razz_press.src = "img/formatbuttons_razz-press.gif";
	format_angry = new Image();
	format_angry.src = "img/formatbuttons_angry.gif";
	format_angry_over = new Image();
	format_angry_over.src = "img/formatbuttons_angry-over.gif";
	format_angry_press = new Image();
	format_angry_press.src = "img/formatbuttons_angry-press.gif";
	format_shocked = new Image();
	format_shocked.src = "img/formatbuttons_shocked.gif";
	format_shocked_over = new Image();
	format_shocked_over.src = "img/formatbuttons_shocked-over.gif";
	format_shocked_press = new Image();
	format_shocked_press.src = "img/formatbuttons_shocked-press.gif";
	
} else {
	format_b = "";
	format_b_over = "";
	format_b_press = "";
	format_i = "";
	format_i_over = "";
	format_i_press = "";
	format_u = "";
	format_u_over = "";
	format_u_press = "";
	format_quote = "";
	format_quote_over = "";
	format_quote_press = "";
	format_img = "";
	format_img_over = "";
	format_img_press = "";
	format_happy = "";
	format_happy_over = "";
	format_happy_press = "";
	format_sad = "";
	format_sad_over = "";
	format_sad_press = "";
	format_laugh = "";
	format_laugh_over = "";
	format_laugh_press = "";
	format_wink = "";
	format_wink_over = "";
	format_wink_press = "";
	format_razz = "";
	format_razz_over = "";
	format_razz_press = "";
	format_laugh_press = "";
	format_angry = "";
	format_angry_over = "";
	format_angry_press = "";
	format_shocked = "";
	format_shocked_over = "";
	format_shocked_press = "";
}

function changeImage(imagename,imagesrc) {
	if (ver == "n2") return false;
	document.images[imagename].src=imagesrc.src;
	return true;
}

		
function getActiveText(textEl) {
	if (textEl.createTextRange)
	textEl.caretPos = document.selection.createRange().duplicate();
	textE1 = (document.all) ? document.selection.createRange().text : document.getSelection();
}

function formatText(textEl, tagstart, tagend) {
	if (textEl.createTextRange && textEl.caretPos) {
	var caretPos = textEl.caretPos;
	caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? tagstart + textE1 + tagend : tagstart + textE1 + tagend;
	document.topicform.message.focus();
	getActiveText(textEl);
    }
}

function smileyInsert(textEl, smileyType) {
	if (textEl.createTextRange && textEl.caretPos) {
	var caretPos = textEl.caretPos;
	caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? smileyType : smileyType;
	document.topicform.message.focus();
	}
}
