//
// clears text fields on mouse click
//
function clearText(thefield) {
  if (thefield.defaultValue==thefield.value)
  thefield.value = ""
}

//
// checks length of text area fields
//
var text1;
function checklength(i) {
  var txt;
  txt=document.postedit.topic_body.value;
  n=txt.length;
  if (n>i) {
    alert('Max length for signatures is 200 characters.');
    document.postedit.topic_body.value=text1;
    return;
  }
  text1=document.postedit.topic_body.value;
}


//
// various functions for inserting bb code into textarea on button click
//
function bbbold() {
  var val = document.postedit.topic_body.value;
	val += "[b][/b]";
	document.postedit.topic_body.value = val;
}
function bbitalic() {
  var val = document.postedit.topic_body.value;
	val += "[i][/i]";
	document.postedit.topic_body.value = val;
}
function bbunderline() {
  var val = document.postedit.topic_body.value;
	val += "[u][/u]";
	document.postedit.topic_body.value = val;
}
function bbcolor() {
  var val = document.postedit.topic_body.value;
	val += "[color=][/color]";
	document.postedit.topic_body.value = val;
}
function bbimage() {
  var val = document.postedit.topic_body.value;
	val += "[img][/img]";
	document.postedit.topic_body.value = val;
}
function bburl() {
  var val = document.postedit.topic_body.value;
	val += "[url=http:\/\/][/url]";
	document.postedit.topic_body.value = val;
}
function bbquote() {
  var val = document.postedit.topic_body.value;
	val += "[quote][/quote]";
	document.postedit.topic_body.value = val;
}

//
// various functions for inserting smiley code into textarea
//
function biggrin() {
  var val = document.postedit.topic_body.value;
	val += ":D";
	document.postedit.topic_body.value = val;
}
function confused() {
  var val = document.postedit.topic_body.value;
	val += ":?";
	document.postedit.topic_body.value = val;
}
function cool() {
  var val = document.postedit.topic_body.value;
	val += "8)";
	document.postedit.topic_body.value = val;
}
function cry() {
  var val = document.postedit.topic_body.value;
	val += ":cry:";
	document.postedit.topic_body.value = val;
}
function eek() {
  var val = document.postedit.topic_body.value;
	val += "8O";
	document.postedit.topic_body.value = val;
}
function evil() {
  var val = document.postedit.topic_body.value;
	val += ":evil:";
	document.postedit.topic_body.value = val;
}
function lol() {
  var val = document.postedit.topic_body.value;
	val += ":lol:";
	document.postedit.topic_body.value = val;
}
function mad() {
  var val = document.postedit.topic_body.value;
	val += ":x";
	document.postedit.topic_body.value = val;
}
function mrgreen() {
  var val = document.postedit.topic_body.value;
	val += ":mrgreen:";
	document.postedit.topic_body.value = val;
}
function neutral() {
  var val = document.postedit.topic_body.value;
	val += ":|";
	document.postedit.topic_body.value = val;
}
function razz() {
  var val = document.postedit.topic_body.value;
	val += ":P";
	document.postedit.topic_body.value = val;
}
function redface() {
  var val = document.postedit.topic_body.value;
	val += ":oops:";
	document.postedit.topic_body.value = val;
}
function rolleyes() {
  var val = document.postedit.topic_body.value;
	val += ":roll:";
	document.postedit.topic_body.value = val;
}
function sad() {
  var val = document.postedit.topic_body.value;
	val += ":(";
	document.postedit.topic_body.value = val;
}
function smile() {
  var val = document.postedit.topic_body.value;
	val += ":)";
	document.postedit.topic_body.value = val;
}
function surprised() {
  var val = document.postedit.topic_body.value;
	val += ":o";
	document.postedit.topic_body.value = val;
}
function twisted() {
  var val = document.postedit.topic_body.value;
	val += ":twisted:";
	document.postedit.topic_body.value = val;
}
function wink() {
  var val = document.postedit.topic_body.value;
	val += ":wink:";
	document.postedit.topic_body.value = val;
}

//
// for the bbcode explanation line
//
z_help = "Mouse over a button or smiley for an explanation.";
b_help = "[b]text[/b]";
i_help = "[i]text[/i]";
u_help = "[u]text[/u]";
color_help = "[color=red]text[/color]";
image_help = "[img]http://www.website.com/image.jpg[/img]";
url_help = "[url=http://www.website.com]Website[/url]";
quote_help = "[quote]text[/quote]";
sm1_help = ":D";
sm2_help = ":?";
sm3_help = "8)";
sm4_help = ":cry:";
sm5_help = "8O";
sm6_help = ":evil:";
sm7_help = ":lol:";
sm8_help = ":x";
sm9_help = ":mrgreen:";
sm10_help = ":|";
sm11_help = ":P";
sm12_help = ":oops:";
sm13_help = ":roll:";
sm14_help = ":(";
sm15_help = ":)";
sm16_help = ":o";
sm17_help = ":twisted:";
sm18_help = ":wink:";
function bbexplain(expl) {
	document.postedit.bbexp.value = eval(expl + "_help");
}
