function bbcode_ins(fieldId, tag, close, promptText, promptDefault, tagParam)
{
	field=document.getElementById(fieldId);
	if (promptText) {
		/*
		var param = prompt(promptText, promptDefault);
		if(!param)
		{
			field.focus();
			return;
		}
		*/
		var param = promptDefault;
	}
	if (document.selection) 
	{
		field.focus();
		var selected = document.selection.createRange().text;
		sel = document.selection.createRange();
		if (tagParam == true && selected.length > 0) {
			sel.text = '[' + tag + (param != null ? '=' + param : '') + ']' + selected + (close == true ? '[/' + tag+']' : '');
		} else {
			sel.text = '[' + tag + ']' + (selected.length > 0 ? selected : (param ? param : '')) + (close == true ? '[/' + tag+']' : '');
		} 
	}

	//MOZILLA/NETSCAPE/SAFARI support
	else if (field.selectionStart || field.selectionStart == 0) 
	{
		field.focus();
		var startPos = field.selectionStart;
		var endPos = field.selectionEnd;
		var selected = field.value.substring(startPos, endPos);
		if (tagParam == true && selected.length > 0) {
			field.value = field.value.substring(0, startPos) + '[' + tag + (param != null ? '=' + param : '') + ']' + selected + (close == true ? '[/' + tag +']' : '') + field.value.substring(endPos, field.value.length);
			field.selectionStart = startPos + tag.length + 2 + (param ? param.length : 0);
			field.selectionEnd = startPos + tag.length + 2 + (param ? param.length : 0);
		} else {
			field.value = field.value.substring(0, startPos) + '[' + tag + ']' + (selected.length > 0 ? selected : (param ? param : '')) + (close == true ? '[/' + tag +']' : '') + field.value.substring(endPos, field.value.length);
			field.selectionStart = startPos + tag.length + 2 + (selected.length > 0 ? selected.length + (close == true ? tag.length + 3 : 0) : (param ? param.length : 0));
			field.selectionEnd = startPos + tag.length + 2 + (selected.length > 0 ? selected.length + (close == true ? tag.length + 3 : 0) : (param ? param.length : 0));
		}
	} 
}