//Thanks to Dave Sabol for the following functions

function confirmSubmit()
 {
 var agree=confirm("Are you sure you want to delete this record?");
 if (agree)
	return true ;
 else
	return false ;
 }

function wOpen(url, w, h)
 {
    // Fudge factors for window decoration space.
	// In my tests these work well on all platforms & browsers.
        w += 32;
        h += 96;
	var win = window.open(url,
		'popup', 
		'width=' + w + ', height=' + h + ', ' +
		'location=no, menubar=no, ' +
		'status=no, toolbar=no, scrollbars=yes, resizable=no');
	win.resizeTo(w, h);
	win.focus();
 }

function hrule(form)
	{insertAtCursor(document.form.HtmlTextArea, "[hr]");}

function underlineText(ul)
{
 var ulText=prompt("enter text", "");
	if (ulText !=null && ulText !="" && ulText !=" ")
	{
	insertAtCursor(document.form.HtmlTextArea, '[u]'+ulText+'[/u]');}
}

function boldText(bt)
{
 var boldText=prompt("enter bold text", "");
	if (boldText !=null && boldText !="" && boldText !=" ")
	{
	insertAtCursor(document.form.HtmlTextArea, '[b]'+boldText+'[/b]');}
}

function italicText(em)
{
 var italText=prompt("italicize text", "");
	if (italText !=null && italText !="" && italText !=" ")
	{
	insertAtCursor(document.form.HtmlTextArea, '[i]'+italText+'[/i]');}
}

function quoteText(qt)
{
 var quotText=prompt("Enter quote text", "");
	if (quotText !=null && quotText !="" && quotText !=" ")
	{
	insertAtCursor(document.form.HtmlTextArea, '[quote]'+quotText+'[/quote]');}
}

function alignleft(al)
{
 var leftText=prompt("Enter text to align", "");
	if (leftText !=null && leftText !="" && leftText !=" ")
	{
	insertAtCursor(document.form.HtmlTextArea, '[l]'+leftText+'[/l]');}
}

function alignright(ar)
{
 var rightText=prompt("Enter text to align", "");
	if (rightText !=null && rightText !="" && rightText !=" ")
	{
	insertAtCursor(document.form.HtmlTextArea, '[r]'+rightText+'[/r]');}
}

function aligncenter(ac)
{
 var centerText=prompt("Enter text to align", "");
	if (centerText !=null && centerText !="" && centerText !=" ")
	{
	insertAtCursor(document.form.HtmlTextArea, '[c]'+centerText+'[/c]');}
}

function addImage(a2)
{
 var addImg=prompt("Enter image name", "");
	if (addImg !=null && addImg !="" && addImg !=" ")
	{
	insertAtCursor(document.form.HtmlTextArea, '[img]'+addImg+'[/img]');}
}

function addLink(lt)
{
var urllink = prompt("Url for the link:", "http://");
var linktext = prompt("Text for the link:", "");
	if (linktext !=null && linktext !="" && linktext !=" " && urllink !=null && urllink !="" && urllink !="http://")
	{insertAtCursor(document.form.HtmlTextArea, '[link='+urllink+']'+linktext+'[/link]');}
}

function addEmail(eml)
{
var mllink = prompt("Email Address:", "");
var linktext = prompt("Text for the link:", "");
	if (linktext !=null && linktext !="" && linktext !=" " && mllink !=null && mllink !="" && mllink !=" ")
	{insertAtCursor(document.form.HtmlTextArea, '[mail='+mllink+']'+linktext+'[/mail]');}
}
//end of Dave's Functions


//thanks www.alexking.org
function insertAtCursor(myField, myValue) {
  //IE support
  if (document.selection) {
    myField.focus();
    sel = document.selection.createRange();
    sel.text = myValue;
  }
  //MOZILLA/NETSCAPE support
  else if (myField.selectionStart && myField.selectionStart != '0') {
    var startPos = myField.selectionStart;
    var endPos = myField.selectionEnd;
    myField.value = myField.value.substring(0, startPos)
                  + myValue 
                  + myField.value.substring(endPos, myField.value.length);
  } else {
    myField.value += myValue;
  }
}
//end www.alexking.org