function bbcodeBasic(textarea_id, tag, action, msg, prompt_text) {
	if(!msg) {
		msg = 'Please enter the text you would like ' + action;
	}
	if(typeof prompt_text == 'undefined') prompt_text = '';
	textarea = document.getElementById(textarea_id);
	text = prompt(msg, prompt_text);
	if(text) {
		textarea.value += '[' + tag + ']' + text + '[/' + tag + ']';
	}
	textarea.focus();
	return false;
}
function bbcodeBold(id) {
	return bbcodeBasic(id, 'b', 'in bold');
}
function bbcodeItalic(id) {
	return bbcodeBasic(id, 'i', 'in italics');
}
function bbcodeUnderline(id) {
	return bbcodeBasic(id, 'u', 'underlined');
}
function bbcodeLeft(id) {
	return bbcodeBasic(id, 'left', 'left-aligned');
}
function bbcodeCenter(id) {
	return bbcodeBasic(id, 'center', 'centre-aligned');
}
function bbcodeRight(id) {
	return bbcodeBasic(id, 'right', 'right-aligned');
}
function bbcodeImg(id) {
	return bbcodeBasic(id, 'img', '', 'Please enter the URL of the image', 'http://');
}
function bbcodeLink(id) {
	textarea = document.getElementById(id);
	url = prompt('Please enter the URL of the page you would like to link to', 'http://');
	if(url) {
		text = prompt('Please enter the text you would like to display for the link', url);
		if(text) {
			textarea.value += '[url=' + url + ']' + text + '[/url]';
		}
	}
	textarea.focus();
	return false;
}
function bbcodeFont(id, font) {
	textarea = document.getElementById(id);
	text = prompt('Please enter the text you would like in ' + font);
	if(text) {
		textarea.value += '[font=' + font + ']' + text + '[/font]';
	}
	document.getElementById('_bbcode_font_select').value = '';
	textarea.focus();
	return false;
}
function bbcodeSize(id, size) {
	textarea = document.getElementById(id);
	text = prompt('Please enter the text you would like in size ' + size);
	if(text) {
		textarea.value += '[size=' + size + ']' + text + '[/size]';
	}
	document.getElementById('_bbcode_size_select').value = '';
	textarea.focus();
	return false;
}
function bbcodeColor(id, color) {
	textarea = document.getElementById(id);
	text = prompt('Please enter the text you would like in this colour');
	if(text) {
		textarea.value += '[color=' + color + ']' + text + '[/color]';
	}
	document.getElementById('_bbcode_color_select').value = '';
	textarea.focus();
	return false;
}