function formatSelection (textarea, openTag, closeTag) 
{
  	var str = document.selection.createRange ().text;
  	textarea.focus ();
  	var sel = document.selection.createRange ();
	sel.text = "<" + openTag +">" + str + "</" + closeTag + ">";
	return;
}

function applyFont (textarea, font)
{
	if (font != 'No font')
	{
		var str = document.selection.createRange ().text;
		textarea.focus ();
		var sel = document.selection.createRange ();
		sel.text = "<span style=\"font-family:" + font + "\">" + str + "</span>";
	}
	return;	
}

function formatFontSize (textarea, fontSize)
{
	if (fontSize != 'No font size')
	{
		var str = document.selection.createRange ().text;
		textarea.focus ();
		var sel = document.selection.createRange ();
		sel.text = "<span style=\"font-size:" + fontSize + "px\">" + str + "</span>";	
	}
	return;
}

function insertLink (textarea) 
{
 	var str = document.selection.createRange ().text;
  	textarea.focus ();
  	var myLink = prompt ("Enter URL:", "http://");
  	if (myLink != null) 
	{
		var sel = document.selection.createRange ();
		sel.text = "<a target=\"_blank\" href=\"" + myLink + "\">" + str + "</a>";
  	}
  	return;
}

function mouseOver (el) 
{
  	el.className = "raised";
}

function mouseOut (el) 
{
  	el.className = "button";
}

function mouseDown (el) 
{
  	el.className = "pressed";
}

function mouseUp (el) 
{
  	el.className = "raised";
}