   function BBCbold (object_name) {
      BBCode(object_name,"b");
   }

   function BBCitalic (object_name) {
      BBCode(object_name,"i");
   }

   function BBCunder (object_name) {
      BBCode(object_name,"u");
   }

   function BBCfont (object_name) {
      BBCode1(object_name,"font");
   }

   function BBCcolor(object_name) {
      BBCode1(object_name,"color");
   }

   function BBCode_Single (object_name,code) {
      BBCode(object_name,code);
   }

   function BBCurl (object_name) {
      var object1 = document.getElementById(object_name);
      var theSelection = "";
      var $doc_selection;

      if (document.selection) {
         // Works in IE and Opera
         theSelection = document.selection.createRange().text;
         $doc_selection = 1;
      }

      if ( theSelection.indexOf("http://") == 0 ) {
      	var enterURL = prompt( "Enter the URL", theSelection );
      } else {
      	var enterURL = prompt( "Enter the URL", "http://" );
      }
   	if ( !enterURL ) {
   		alert("Error : You need to enter in a URL");
   		return;
   	}
      var enterTITLE = prompt("Enter the page name or leave blank", theSelection);
      if ( enterTITLE && theSelection ) {
         document.selection.createRange().text = "[url=" + enterURL + "]" + enterTITLE + "[/url]";
      } else if ( enterTITLE ) {
         object1.value += "[url=" + enterURL + "]" + enterTITLE + "[/url]";
      } else {
         object1.value += "[url]" + enterURL + "[/url]";
      }
      object1.focus();
      return;
   }

   function BBCimg (object_name) {
      var object1 = document.getElementById(object_name);
      var theSelection = "";
      var $doc_selection;

      if (document.selection) {
         // Works in IE and Opera
         theSelection = document.selection.createRange().text;
         $doc_selection = 1;
      }

      if ( theSelection.indexOf("http://") == 0 ) {
      	var enterURL = prompt( "Enter the URL", theSelection );
      } else {
      	var enterURL = prompt( "Enter the URL", "http://" );
      }
   	if ( !enterURL ) {
   		alert("Error : You need to enter in a URL");
   		return;
   	}
      if ( $doc_selection ) {
         document.selection.createRange().text = "[img]" + enterURL + "[/img]";
      } else {
         object1.value += "[img]" + enterURL + "[/img]";
      }
      object1.focus();
      return;
   }

   function BBCode (object_name,code) {
      var object1 = document.getElementById(object_name);
      var $doc_selection = "";

      if ( document.selection ) {
         // Works in IE and Opera
         var theSelection = document.selection.createRange().text;
         document.selection.createRange().text = "[" + code + "]" + theSelection + "[/" + code + "]";
      } else if ( navigator.userAgent.toLowerCase().indexOf('gecko')!=-1 ) {
         // Works for Mozilla
		   objectValue = object1.value;

		   deb = object1.selectionStart;
		   fin = object1.selectionEnd;

		   objectValueDeb = objectValue.substring( 0 , object1.selectionStart );
		   objectValueFin = objectValue.substring( object1.selectionEnd , object1.textLength );
		   objectSelected = objectValue.substring( object1.selectionStart ,object1.selectionEnd );

   		object1.value = objectValueDeb + "[" + code + "]" + objectSelected + "[/" + code + "]" + objectValueFin;
   		// Reselects text
   		// object1.selectionStart = strlen(objectValueDeb);
   		// object1.selectionEnd = strlen(objectValueDeb + "[" + code + "]" + objectSelected + "[/" + code + "]");
      } else {
         object1.value += "[" + code + "][/" + code + "]";
      }
      object1.focus();
      return;
   }

   function BBCode1 (object_name,code) {
      var object1 = document.getElementById(object_name);
      var $doc_selection;

      if (document.selection) {
         // Works in IE and Opera
         var theSelection = document.selection.createRange().text;
         document.selection.createRange().text = "[" + code + "=]" + theSelection + "[/" + code + "]";
      } else {
         object1.value += "[" + code + "=][/" + code + "]";
      }
      object1.focus();
      return;
   }

   function BBCode_Single (object_name,code) {
      var object1 = document.getElementById(object_name);
      var $doc_selection = "";

      if ( document.selection ) {
         // Works in IE and Opera
         var theSelection = document.selection.createRange().text;
         document.selection.createRange().text = "[" + code + "]" + theSelection;
      } else if ( navigator.userAgent.toLowerCase().indexOf('gecko')!=-1 ) {
         // Works for Mozilla
		   objectValue = object1.value;

		   deb = object1.selectionStart;
		   fin = object1.selectionEnd;

		   objectValueDeb = objectValue.substring( 0 , object1.selectionStart );
		   objectValueFin = objectValue.substring( object1.selectionEnd , object1.textLength );
		   objectSelected = objectValue.substring( object1.selectionStart ,object1.selectionEnd );

   		object1.value = objectValueDeb + "[" + code + "]" + objectSelected + objectValueFin;
   		// Reselects text
   		// object1.selectionStart = strlen(objectValueDeb);
   		// object1.selectionEnd = strlen(objectValueDeb + "[" + code + "]" + objectSelected + "[/" + code + "]");
      } else {
         object1.value += "[" + code + "]";
      }
      object1.focus();
      return;
   }