function submitForm() {
  return true;
}
var prompt_start        = 'Enter the text to be formatted';
var text_enter_url      = 'Enter the complete URL for the hyperlink';
var image_enter_url     = 'Enter the complete URL to the image';
var text_enter_url_name = 'Enter the title of the webpage';
var text_enter_email    = 'Enter the email address';
var error_no_url        = 'You must enter a URL';
var error_no_image      = 'You must enter a URL for the image';
var error_no_title      = 'You must enter a title';
var error_no_subject    = 'You must enter a subject';
var error_no_comments   = 'You must enter your comments';
var help_bold           = 'Inserts Bold Text';
var help_italic         = 'Inserts Italic Text';
var help_under          = 'Inserts Underlined Text';
var help_url            = 'Inserts Hyperlink';
var help_email          = 'Inserts Email Address';
var help_quote          = 'Inserts Quoted Text';
var help_image          = 'Inserts an image';
var help_break 					= 'Inserts a break tag, everything above the tag will be shown on the main page, and a link to more added';

	function helpmsg(msg)
  {
    msg=eval( "help_" + msg );
    write_html(msg,'help');
  }

  function do_tag(thetag) {
    doInsert("[" + thetag + "]","[/" + thetag + "]",thetag);
  }
  function tag_break() {
    doInsert("[break]","",'');
  }
  function tag_url()
  {
    var FoundErrors = '';
    var enterURL   = prompt(text_enter_url, "http://");
    var enterTITLE = prompt(text_enter_url_name, "My Website");

    if (!enterURL) {
      FoundErrors += " " + error_no_url;
    }
    if (!enterTITLE) {
      FoundErrors += " " + error_no_title;
    }
    if (FoundErrors) {
      alert("Error!"+FoundErrors);
      return;
    }
    doInsert("[URL="+enterURL+"]","[/URL]",enterTITLE);
  }
  function tag_email()
  {
    var emailAddress = prompt(text_enter_email, "");
    if (!emailAddress) {
      alert(error_no_email);
      return;
    }
    doInsert("[EMAIL]",'[/EMAIL]',emailAddress);
  }
  function tag_image()
  {
    var imageAddress = prompt(image_enter_url, "");
    if (!imageAddress) {
      alert(error_no_image);
      return;
    }
    doInsert("[IMG]",'[/IMG]',imageAddress);
  }
// Determine browser type and stuff.
// Borrowed from http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html

var myAgent   = navigator.userAgent.toLowerCase();
var myVersion = parseInt(navigator.appVersion);

var is_ie   = ((myAgent.indexOf("msie") != -1)  && (myAgent.indexOf("opera") == -1));
var is_nav  = ((myAgent.indexOf('mozilla')!=-1) && (myAgent.indexOf('spoofer')==-1)
                && (myAgent.indexOf('compatible') == -1) && (myAgent.indexOf('opera')==-1)
                && (myAgent.indexOf('webtv') ==-1)       && (myAgent.indexOf('hotjava')==-1));

var is_win   =  ((myAgent.indexOf("win")!=-1) || (myAgent.indexOf("16bit")!=-1));
var is_mac    = (myAgent.indexOf("mac")!=-1);
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var is_gecko = ((clientPC.indexOf('gecko')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('khtml') == -1) && (clientPC.indexOf('netscape/7.0')==-1));
var is_safari = ((clientPC.indexOf('applewebkit')!=-1) && (clientPC.indexOf('spoofer')==-1));
var is_khtml = (navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled ));
if (clientPC.indexOf('opera') != -1) {
    var is_opera = true;
    var is_opera_preseven = (window.opera && !document.childNodes);
       var is_opera_seven = (window.opera && document.childNodes);
}
function doInsert(tagOpen, tagClose, sampleText) {
  if (document.getElementById('p_profile'))
		var txtarea = document.getElementById('p_profile');
  else if (document.getElementById('b_body'))
		var txtarea = document.getElementById('b_body');
  else if (document.getElementById('c_comments'))
		var txtarea = document.getElementById('c_comments');
  else if (document.getElementById('c_comment'))
		var txtarea = document.getElementById('c_comment');
  tagClose+=' ';
	// IE
	if (document.selection  && !is_gecko) {
		var theSelection = document.selection.createRange().text;
		if (!theSelection)
			theSelection=sampleText;
		txtarea.focus();
		if (theSelection.charAt(theSelection.length - 1) == " ") { // exclude ending space char, if any
			theSelection = theSelection.substring(0, theSelection.length - 1);
			document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
		} else {
			document.selection.createRange().text = tagOpen + theSelection + tagClose;
		}

	// Mozilla
	} else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
		var replaced = false;
		var startPos = txtarea.selectionStart;
		var endPos = txtarea.selectionEnd;
		if (endPos-startPos)
			replaced = true;
		var scrollTop = txtarea.scrollTop;
		var myText = (txtarea.value).substring(startPos, endPos);
		if (!myText)
			myText=sampleText;
		if (myText.charAt(myText.length - 1) == " ") { // exclude ending space char, if any
			subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
		} else {
			subst = tagOpen + myText + tagClose;
		}
		txtarea.value = txtarea.value.substring(0, startPos) + subst +
			txtarea.value.substring(endPos, txtarea.value.length);
		txtarea.focus();
		//set new selection
		if (replaced) {
			var cPos = startPos+(tagOpen.length+myText.length+tagClose.length);
			txtarea.selectionStart = cPos;
			txtarea.selectionEnd = cPos;
		} else {
			txtarea.selectionStart = startPos+tagOpen.length;
			txtarea.selectionEnd = startPos+tagOpen.length+myText.length;
		}
		txtarea.scrollTop = scrollTop;

	}
	// reposition cursor if possible
	if (txtarea.createTextRange)
		txtarea.caretPos = document.selection.createRange().duplicate();
}
function quote_post(elId,name)
{
  var contents=document.getElementById(elId).innerHTML;
  var display_contents="<blockquote><b>"+name+"</b> wrote:<br />"+contents+"</blockquote>";
	var rawtext=document.getElementById('a'+elId).innerHTML;
  var quote_contents="[quote][bold]"+name+"[/bold] wrote:\n"+rawtext+"[/quote]";
  var element=document.getElementById('inv_quote')
	element.value=quote_contents;
  write_html(display_contents,'com_quote');
  document.getElementById('c_comment').focus();
}
