/***********************************\
|           DanPHPSupport           |
|  A Support System written in PHP  |
|-----------------------------------|
|   Written by Daniel Lo Nigro of   |
|         DanSoft Australia         |
| http://www.dansoftaustralia.net/  |
|-----------------------------------|
|   Please feel free to distribute  |
|    this script, as long as this   |
|       header stays attached.      |
\***********************************/

// VERSION: 0.5 (Build 6)
// DATE: 20th March 2006 

//Variables for controlling opening and closing tags (function tag)

var b = 2;
var i = 2;
var u = 2;
var q = 2;
var c = 2;
var url = 2;
var img = 2;

//Function for creating non-font tags
function tag(v, tagadd, newbut, tagclose, oldbut, name) {

	var r = document.selection.createRange().text;
	
	if(r != ""){
		rr = tagadd + r + tagclose;
		document.selection.createRange().text = rr;
	} else {
		if (eval(v)%2 == 0) {
			eval("window.document.adminForm."+name+".value = newbut;");
			var post = window.document.adminForm.message.value;
			window.document.adminForm.message.value = post + tagadd;
			window.document.adminForm.message.focus();
		} else {
			eval("window.document.adminForm."+name+".value = oldbut;");
			var post = window.document.adminForm.message.value;
			window.document.adminForm.message.value = post + tagclose;
			window.document.adminForm.message.focus();
		}
		eval(v+"++;");
	}
}

//Function for adding font color and size tags
function font(bbopen, bbclose) {
	
	var r = document.selection.createRange().text;
	
	if(r != ""){
		rr = bbopen + r + bbclose;
		document.selection.createRange().text = rr;
	} else {
		var post = document.adminForm.message;
		post.value += bbopen + bbclose;
		post.focus();
		return;
	}
}

//Function for adding smilies
function smilie (smilie) {
        var post = document.adminForm.message;
        post.value += smilie;
        post.focus();
        return;
}

//Helpbox messages
bold_help = "Bold text: [b]text[/b]";
italic_help = "Italic text: [i]text[/i]";
underline_help = "Underline text: [u]text[/u]";
quote_help = "Quote text: [quote]text[/quote] or [quote=name]text[/quote]";
code_help = "Code display: [code]code[/code]";
img_help = "Insert image: [img]http://image_url[/img]";
url_help = "Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url]";
fontcolor_help = "Font color: [color=red]text[/color]  Tip: you can also use color=#FF0000";
fontsize_help = "Font size: [size=50%]small text[/size]";

//Function for displaying help information
// Shows the help messages in the helpline window
function helpline(help) {
	//var helpbox = document.adminForm.helpbox;
	var helpbox = document.adminForm.helpbox;
	helpbox.value = eval(help + "_help");
}