// TEXT FOR POP-UP PROMPTS
b_prompt = "Insert the text to make BOLD";
i_prompt = "Insert the text to ITALICIZE";
img_prompt = "Enter the FULL URL of the image:\n(e.g. http://yoursite.com/image.jpg)";
link_url_prompt = "Enter the FULL URL for the link (keep the http://)";
quote_prompt = "Enter or paste the text to QUOTE";

// *******************************************************

function wrap(bb,FormElement) 
{
	if( document.selection ) {
		// for IE
		var str = document.selection.createRange().text;
		//document.getElementById(FormElement).focus();
		var sel = document.selection.createRange();
		sel.text = "[" + bb + "]" + str + "[/" + bb + "]";
  }
	else {
		// browsers other than IE
		var s = document.getElementById(FormElement);
		if( s.selectionEnd ) {
			// Mozilla 1.3b+ 
			var s1 = (s.value).substring(0,s.selectionStart)
			var s2 = (s.value).substring(s.selectionEnd,s.textLength)
			selection = (s.value).substring(s.selectionStart, s.selectionEnd)
			s.value = s1 + "[" + bb + "]" + selection + "[/" + bb + "]" + s2
		}
		else {
			// everything else
			s.value += "[" + bb + "][/" + bb + "]";
		}
	}
	return;
}

// *******************************************************

function textprompt(bbcode,FormElement) {
// insert [bbcode]yyy[/bbcode]
	inserttext = prompt(eval(bbcode+"_prompt"));
	if ((inserttext != null) && (inserttext != ""))
		document.getElementById(FormElement).value += "["+bbcode+"]"+inserttext+"[/"+bbcode+"]";
	//document.getElementById(FormElement).focus();
}

// *******************************************************

function wrappedlink(FormElement) {
// inserts named url link around selected text- [url=mylink]text[/url]
	var prompttext;
	prompt_text = link_url_prompt;
	prompt_contents = "http://";
	linkurl = prompt(prompt_text,prompt_contents);
	if ((linkurl != null) && (linkurl != "")) {
		if( document.selection ) {
			// for IE
			var str = document.selection.createRange().text;
			//document.getElementById(FormElement).focus();
			var sel = document.selection.createRange();
			sel.text = "[l="+linkurl+"]" + str + "[/l] ";
  	}
		else {
			// browsers other than IE
			var s = document.getElementById(FormElement);
			if( s.selectionEnd ) {
				// Mozilla 1.3b+ 
				var s1 = (s.value).substring(0,s.selectionStart)
				var s2 = (s.value).substring(s.selectionEnd,s.textLength)
				selection = (s.value).substring(s.selectionStart, s.selectionEnd)
				s.value = s1 + "[l="+linkurl+"]" + selection + "[/l] " + s2
			}
			else {
				// everything else
				s.value += "[l="+linkurl+"]"+linkurl+"[/l] ";
			}
		}
	}
	return;
}

// increase or decrease textbox size

function increaserows(textarea) {
	var rows = document.getElementById(textarea).getAttribute("rows");
	var newrows = eval(rows) + 5;
	if (eval(newrows) > 25) { newrows = 25; }
	document.getElementById(textarea).setAttribute("rows", newrows);
}
function decreaserows(textarea) {
	var rows = document.getElementById(textarea).getAttribute("rows");
	var newrows = eval(rows) - 5;
	if (eval(newrows) < 5) { newrows = 5; }
	document.getElementById(textarea).setAttribute("rows", newrows);
}

////////////////
/// buttons
///////////////
function mouseover(el) {
  el.className = "button_raised";
}

function mouseout(el) {
  el.className = "button";
}

function mousedown(el) {
  el.className = "button_pressed";
}

function mouseup(el) {
  el.className = "button_raised";
}

