
	//Stuff to put smilies etc. into forum posts... Doesn't work right in opera, unfortunately :(
	//least not when it's set to identify as IE - required for overlib - still, I prefer overlib to this.
	//Kinda took this from vbulletin, but then, they took it from somewhere else, and it's really (c) of
	//that person, they have credited him/them, but I'm not sure who it was, so credit generally not
	//mine here, although it was adapted by me for my use. Oh well, anyway, enough with the comments.

	var thetext = "0";
	var formname = "custom";

	function storeCaret(textEl) {
		if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
	}

	function addText(thetext, formname) {
		if (!formname) {
			formname=custom;
		}
		if (document.forms[formname].post) {
			var obj = document.forms[formname].post;
			if (obj.caretPos) {
				var caretPos = obj.caretPos;
				caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? thetext + ' ' : thetext;
				obj.focus();
			} else {
				obj.value += thetext;
			}
			storeCaret(obj);
			obj.focus();
		}
	}

	//this stuff wasn't taken from anywhere...
	function addImg(formname) {
		var txt = prompt("Enter the URL of the image you wish to link to - including http://");
		txt = "[img]"+txt+"[/img]";
		if (txt) {
			addText(txt, formname);
		}
	}
	function addLink(formname) {
		var aUrl = prompt("Enter the URL of the page you wish to link to - including http://");
		if (aUrl) {
			var aTxt = prompt("Enter the text you wish to use to describe the link, or leave blank.");
			if (!aTxt) {
				aTxt = aUrl;
			}
			var txt = "<a href='"+aUrl+"' target='_blank'\>"+aTxt+"</a>";
			addText(txt, formname);
		}
	}
	function addUser(formname) {
		var user = prompt("Enter the username of the user to link to");
		if (user) {
			user = "[user]"+user+"[/user]";
			addText(user, formname);
		}
	}
	function addFile(formname) {
		var file = prompt("Enter the *ID* of the file to link to");
		if (file) {
			file = "[file]"+file+"[/file]";
			addText(file, formname);
		}
	}
	function addBold(formname) {
		var txt = prompt("Enter the text to make bold");
		if (txt) {
			txt = "<b>"+txt+"</b>";
			addText(txt, formname);
		}
	}
	function addItalic(formname) {
		var txt = prompt("Enter the text to make italic");
		if (txt) {
			txt = "<i>"+txt+"</i>";
			addText(txt, formname);
		}
	}
	function addUnderlined(formname) {
		var txt = prompt("Enter the text to underline");
		if (txt) {
			txt = "<u>"+txt+"</u>";
			addText(txt, formname);
		}
	}
	function addStrike(formname) {
		var txt = prompt("Enter the text to strike through");
		if (txt) {
			txt = "<s>"+txt+"</s>";
			addText(txt, formname);
		}
	}


	var spoilid = 0;
	function showSpoiler(spoilid) {
		var spoil = document.getElementById("spoiler"+spoilid);
		if (spoil.style.display != 'none') {
			spoil.style.display = 'none';
		} else {
			spoil.style.display = 'block';
		}
	}