//  JavaScript Library for popUps

var layer = "popUps";	// name used for popup layer

// popUps configuration
if (typeof fcolor == 'undefined') var fcolor = "#d3d3ff";		// Main background colour
if (typeof backcolor == 'undefined') var backcolor = "#333399";	// Border and caption colour
if (typeof textcolor == 'undefined') var textcolor = "#000000";	// Body text colour
if (typeof capcolor == 'undefined') var capcolor = "#FFFFFF";	// Caption text colour
if (typeof width == 'undefined') var width = "200";		// Popup width (pixels)
if (typeof border == 'undefined') var border = "1";		// Border thickness in pixels
if (typeof offsety == 'undefined') var offsety = 10;	// Popup distance below cursor (pixels)
if (typeof offsetx == 'undefined') var offsetx = 10;	// Popup horizontal distance from cursor (pixels)

// browser identification
var IE5up = document.getElementById && document.all;
var NS6up = document.getElementById && !document.all;
var NS4 = document.layers;
var IE4 = document.all && !window.print;

if (NS4) document.captureEvents(Event.MOUSEMOVE);

document.onmousemove = follow;

var x = 0;
var y = 0;
var dir = 1;		// popup direction
var showing = 0;	// showing now

// Public functions

function plc(text, title) {	// Popup - left caption
	pxc(0, text, title);
}

function prc(text, title) {	// Popup - right caption
	pxc(1, text, title);
}

function pcc(text, title) {	// Popup - centre caption
	pxc(2, text, title);
}

function px() {				// Hide popup
	showing = 0;
	if (IE5up||NS6up) document.getElementById(layer).style.visibility = "hidden";
	else if (NS4) document.layers[layer].visibility = "hide";
	else if (IE4) document.all(layer).style.visibility = "hidden";
}

// Non-public functions

// Write captions and show popup
function pxc(d, text, title) {
	layerWrite("<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+backcolor+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><SPAN ID=\"PTT\"><B><FONT COLOR=\""+capcolor+"\">"+title+"</FONT></B></SPAN></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+fcolor+"\"><TR><TD><SPAN ID=\"PST\"><FONT COLOR=\""+textcolor+"\">"+text+"</FONT><SPAN></TD></TR></TABLE></TD></TR></TABLE>");
	dir = d;
	if (!showing) {
		move(x, y);
		showing = 1;
		if (IE5up||NS6up) document.getElementById(layer).style.visibility = "visible";
		else if (NS4) document.layers[layer].visibility = "show";
		else if (IE4) document.all(layer).style.visibility = "visible";
}	}

// Follow mouse movements (update coordinates)
function follow(e) {
    if (!e) var e = window.event;
    if (e.pageX || e.pageY) {
        x = e.pageX;
        y = e.pageY;
    } else if (e.clientX || e.clientY) {
        x = e.clientX + document.body.scrollLeft;
        y = e.clientY + document.body.scrollTop;
    }
	if (showing) move(x, y);
}

// Move the layer
function move(x, y) {
	if (dir == 2)		// centre
		moveIt(x+offsetx-(width/2), y+offsety);
	else if (dir == 1)	// right
		moveIt(x+offsetx, y+offsety);
	else if (dir == 0)	// left
		moveIt(x-offsetx-width, y+offsety);
}

// Really move the layer
function moveIt(xL, yL) {
if (IE5up || NS6up) {
		document.getElementById(layer).style.left = xL;
		document.getElementById(layer).style.top = yL;
	} else if (IE4) {
		popUps.style.left = xL + document.body.scrollLeft;
		popUps.style.top = yL + document.body.scrollTop;
	} else if (NS4) {
		document.popUps.left = xL + window.pageXOffset;
		document.popUps.top = yL + window.pageYOffset;
}	}

// Write to the layer
function layerWrite(txt) {
	if (IE5up || NS6up) document.getElementById(layer).innerHTML = txt;
	else if (IE4) document.all[layer].innerHTML = txt;
	else if (NS4) {
		var lyr = document.popUps.document;
		lyr.write(txt);
		lyr.close();
}	}

