  tags = new Array()

  tags['b_prompttext'] = 'Type your text to be formated as Bold'
  tags['b_start']      = '[b]'
  tags['b_end']        = '[/b]'

  tags['i_prompttext'] = 'Type your text to be formated as Italic'
  tags['i_start']      = '[i]'
  tags['i_end']        = '[/i]'

  tags['u_prompttext'] = 'Type your text to be formated as Underline'
  tags['u_start']      = '[u]'
  tags['u_end']        = '[/u]'

  tags['email_prompttext'] = 'Type your text to be formated as Email'
  tags['email_start']      = '[email]'
  tags['email_end']        = '[/email]'

  tags['url_prompttext_1'] = 'Type your link name (optional)'
  tags['url_prompttext_2'] = 'Type your URL Address'

  tags['email_prompttext_1'] = 'Name of the Email owner'
  tags['email_prompttext_2'] = 'The Email Address'

  function getcode_email () {
    emailname  = prompt (tags['email_prompttext_1'], '')
    emailaddr  = prompt (tags['email_prompttext_2'], '')
    if (emailaddr > '') {
      if (emailname > '') {
        document.shoutform.message.value += '[email='+ emailaddr +']'+ emailname +'[/email]'
      } else {
        document.shoutform.message.value += '[email]'+ emailaddr +'[/email]'
      }
    }
  }

  function getcode_url () {
    linkurl  = prompt (tags['url_prompttext_2'], 'http://')
    linkname = prompt (tags['url_prompttext_1'], '')
    if (linkurl > '') {
      if (linkname > '') {
        document.shoutform.message.value += '[url='+ linkurl +']'+ linkname +'[/url]'
      } else {
        document.shoutform.message.value += '[url]'+ linkurl +'[/url]'
      }
    }
  }

  function getcode (what) {
    text = prompt (tags[what+'_prompttext'], '')
    if (text > '') {
      document.shoutform.message.value += tags[what+'_start']+ text +tags[what+'_end']
    }
  }

  function put_smilies (code) {
    window.opener.document.shoutform.message.value += code
  }


  
  
  

bbcode = new Array();
bbtags = new Array('[b]','[/b] ','[i]','[/i] ','[u]','[/u] ');


// Replacement for arrayname.length property
function getarraysize(thearray) {
	for (i = 0; i < thearray.length; i++) {
		if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
			return i;
		}
	return thearray.length;
}

// Replacement for arrayname.push(value) not implemented in IE until version 5.5
// Appends element to the array
 function arraypush(thearray,value) {
	thearray[ getarraysize(thearray) ] = value;
}

// Replacement for arrayname.pop() not implemented in IE until version 5.5
// Removes and returns the last element of an array
function arraypop(thearray) {
	thearraysize = getarraysize(thearray);
	retval = thearray[thearraysize - 1];
	delete thearray[thearraysize - 1];
	return retval;
}


function bbstyle(bbnumber) {
	var txtarea = document.shoutform.message;

	txtarea.focus();
	donotinsert = false;
	theSelection = false;
	bblast = 0;

	// Find last occurance of an open tag the same as the one just clicked
	for (i = 0; i < bbcode.length; i++) {
		if (bbcode[i] == bbnumber+1) {
			bblast = i;
			donotinsert = true;
		}
	}

	if (donotinsert) {		// Close all open tags up to the one just clicked & default button names
		while (bbcode[bblast]) {
				butnumber = arraypop(bbcode) - 1;
				txtarea.value += bbtags[butnumber + 1];
				buttext = eval('document.shoutform.bbcode' + butnumber + '.value');
				eval('document.shoutform.bbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
			}
			txtarea.focus();
			return;
	} else {
		// Open tag
		txtarea.value += bbtags[bbnumber];
		arraypush(bbcode,bbnumber+1);
		eval('document.shoutform.bbcode'+bbnumber+'.value += "*"');
		txtarea.focus();
		return;
	}
}



  
  var submitcount = 0;
  function submitOnce() {
    if (submitcount == 0)
    {
      submitcount++;
      return true;
    }
    else 
    {
      return false;
    }
  }


  var msgLimit = 120;
  var alertColor = '#FF0000';
  var preColor = '';
  function messageCounter()
  {
    var old = document.shoutform.counter.value;
    document.shoutform.counter.value = msgLimit - document.shoutform.message.value.length;
    if(document.shoutform.counter.value < 0 && old >= 0)
    {
      if(document.styleSheets)
      {
        preColor = document.shoutform.counter.style.color;
        document.shoutform.counter.style.color = alertColor;
      }
    }
    else if(document.shoutform.counter.value >= 0 && old < 0 && document.styleSheets )
    {
       document.shoutform.counter.style.color = preColor;
    } 
  }









  