function insertSimpleTag(type,steps,foso) {	//foso stands for 'fail on step one'
	
	var message = '';
	var message2 = '';
	var tagf = '';
	var tagb = '';
	
	//set all types
	if(type == 'B') {
		message = "<@Enter the text that should be displayed bold@>";
		tagf = '[B';
		tagb = '[/B]';
	} else if(type == 'U') {
		message = "<@Enter the text that should be underlined@>";
		tagf = '[U';
		tagb = '[/U]';
	} else if(type == 'I') {
		message = "<@Enter the text that should be italic@>";
		tagf = '[I';
		tagb = '[/I]';
	} else if(type == 'CENTER') {
		message = "<@Enter the text that should be centered@>";
		tagf = '[CENTER';
		tagb = '[/CENTER]';
	} else if(type == 'RIGHT') {
		message = "<@Enter the text that should be aligned to the right@>";
		tagf = "[RIGHT";
		tagb = "[/RIGHT]";
	} else if(type == "LEFT") {
		message = "<@Enter the text that should be aligned to the left@>";
		tagf = "[LEFT";
		tagb = "[/LEFT]";
	} else if(type == "IMG") {
		message = "<@Enter the URL to your image@>";
		tagf = "[IMG";
		tagb = "[/IMG]";
	} else if(type == "QUOTE") {
		message = "<@Enter the text to quote@>";
		tagf = "[QUOTE";
		tagb = "[/QUOTE]";
	}  else if(type == "EMAIL") {
		message = "<@Enter the text to be linked (optional)@>";
		message2 = "<@Enter the e-mail address@>";
		tagf = "[EMAIL";
		tagb = "[/EMAIL]";
	} else if(type == "URL") {
		message = "<@Enter the text to be linked (optional)@>";
		message2 = "<@Enter the URL@>";
		tagf = "[URL";
		tagb = "[/URL]";
	} 
	else if(type == "HIDDEN") {
		message = "<@Insert hidden text, this will only be visible to registered members@>";
		tagf = "[HIDDEN";
		tagb = "[/HIDDEN]";
	} 
	
	text = prompt(message, "");
	
	if(steps == 1) {
		if (!text) {return false}
		else {insertValue(tagf + "]" + text + tagb);}
	} else {
		if ((!text) && (foso == 0)) {
			text2 = prompt(message2, "");
			if (!text2) {return false}
			else {insertValue(tagf + "]" + text2 + tagb);}
		}
		else if((!text) && (foso == 1)) {
			return false
		}
		else {
			text2 = prompt(message2, "");
			if (!text2) {return false}
			else {insertValue(tagf + "=" + text2 + "]" + text + tagb);}
		}
	}
	
}
function insertColor(color) {
	var where = document.getElementById("message");

	if(color == "Custom") {
		thecolor = prompt("<@Please enter the hex value of your color@>", "");
		if (!thecolor) {return false}
		else {
			text = prompt("<@Enter your text that should have the following color@>: " + thecolor, "");
			if (!text) {return false}
			else {insertValue("[COLOR=" + thecolor + "]" + text + "[/COLOR]");}
		}
	} else {
		text = prompt("<@Enter your text that should have the following color@>: " + color, "");
		if (!text) {return false}
		else {insertValue("[COLOR=" + color + "]" + text + "[/COLOR]");}
	}
	
}
function insertFont(font) {

	text = prompt("<@Enter the text that should be formatted with the following font@> " + font, "");
	if (!text) {return false}
	else {insertValue("[FONT=" + font + "]" + text + "[/FONT]");}
}
function insertValue(Value) {
	//IE support
	var Field = document.getElementById("message");
	if (document.selection) {
		var temp;
		Field.focus();
		sel = document.selection.createRange();
		temp = sel.text.lenght;
		sel.text = Value;
		
		if (Value.length == 0) {
			sel.moveStart("character", Value.length);
			sel.moveEnd("character", Value.length);
		} else {
			sel.moveStart("character", -Value.length + temp);
		}
	sel.select();
	}
	//MOZILLA/NETSCAPE support
	else if (Field.selectionStart || Field.selectionStart == "0") {
		var startPos = Field.selectionStart;
		var endPos = Field.selectionEnd;
		Field.value = Field.value.substring(0, startPos) + Value + Field.value.substring(endPos, Field.value.length);
		Field.selectionStart = startPos + Value.length;
		Field.selectionEnd = startPos + Value.length;
	} else {
		Field.value += Value;
	}
}

function insertFlag(country) {
   insertValue("[FLAG:" + country + "]");
} 

function showFlag(country)
{
 document.getElementById("flag").src = "flags/" + country + ".gif";
}
