
<!--
// Startup variables
var theSelection = false;

// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version

var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
                && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_moz = 0;

var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);

function setColour(selColour,textarea)
{
	var txtarea = textarea
	var sColour = selColour
	var divElement = document.getElementById('cDiv'); divElement.style.display = 'none';
	
	txtarea.value += '[colour=' + sColour.value + '] [/colour]';
	


}
function insertBB(code,textarea)
{
		var txtarea = textarea;
		
		if(code == "url")
		{
			var url = prompt("Please enter a web address","http://");
			txtarea.value += '[' + code + ']' + url + '[/' + code + ']';
			return
		
		}
		
		if(code == "img")
		{
			var url = prompt("Please enter the location of your image","http://");
			txtarea.value += '[' + code + ']' + url + '[/' + code + ']';
			return
		
		}
		
		if(code == "size")
		{
			var size = prompt("Please enter a font size","12");
			opencode = code + "=" + size;
			closecode = code;
		
		}
		
		
		else
		{
			opencode = code;
			closecode = code;
		
		}
		
		if(code == "colour")
		{
			
			var divElement = document.getElementById('cDiv');
			
			divElement.style.position = 'absolute';
			divElement.style.top = '20%';
			divElement.style.left = '50%';
			divElement.style.display = 'block';
			
		}
		
		else if ((clientVer >= 4) && is_ie && is_win)
		{
			theSelection = document.selection.createRange().text; // Get text selection
			if(code == "url"){theSelection = prompt("Please enter a web address","http://");}
			if(code == "img"){theSelection = prompt("Please enter the location of your image","http://");}
			
			if (theSelection) {
				document.selection.createRange().text = '[' + opencode + ']' + theSelection + '[/' + closecode + ']';
				txtarea.focus();
				theSelection = '';
				return;
			}
			else
			{
				txtarea.value += '[' + opencode + ']' + '[/' + closecode + ']';
			
			}
		}
		else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
		{
			
			mozWrap(txtarea, '[' + opencode + ']', '[/' + closecode + ']');
			return;
		}
		else				
		{
			txtarea.value += '[' + opencode + ']' + '[/' + closecode + ']';
		}
}


// From http://www.massless.org/mozedit/
function mozWrap(txtarea, open, close)
{
	var selLength = txtarea.textLength;
	var selStart = txtarea.selectionStart;
	var selEnd = txtarea.selectionEnd;
	if (selEnd == 1 || selEnd == 2)
		selEnd = selLength;

	var s1 = (txtarea.value).substring(0,selStart);
	var s2 = (txtarea.value).substring(selStart, selEnd)
	var s3 = (txtarea.value).substring(selEnd, selLength);
	txtarea.value = s1 + open + s2 + close + s3;
	return;
}

 

