// 2.1.1	 1 May 02
// 2.1.2	 1 May 02
// 3.0.0	10 Jul 03
// 4.0.0	25 Mar 04
//			27 Mar 04
//			31 Mar 04
//			 1 Apr 04
//			 3 Apr 04
//			 6 Apr 04
//			16 Apr 04
//			18 Apr 04
//			20 Apr 04
//			27 Apr 04
//			23 May 0
//			24 May 04
//			 1 Jun 04
//			 3 Jun 04
//			21 Jun 04
//			28 Jun 04
//			 3 Jul 04
//			 9 Jul 04
//			21 Jul 04
//			23 Aug 04
//			 7 Sep 04
//			12 Sep 04
//			 1 Jan 05

// Include this line before any other code:
//<script src = "../GenSubs.js">	</script> (but make sure the level is right)

//Deb ("GS", 0);
var _				= null;
var __				= "undefined";
var SP				= "&nbsp;";
var SP2				= SP + SP;
var SP3				= SP2 + SP;
var GAP				= SP + SP + SP + SP;
var GAP2			= GAP + GAP;			//   8 spaces
var GAP3			= GAP2 + GAP;			//  12 spaces
var GAP4			= GAP2 + GAP2;			//  16 spaces
var GAP5			= GAP4 + GAP;			//  20 spaces
var GAP6			= GAP4 + GAP2;			//  24 spaces
var GAP8			= GAP4 + GAP4;			//  32 spaces
var GAP16			= GAP8 + GAP8;			//  64 spaces
var GAP24			= GAP16 + GAP8;			//  96 spaces
var GAP32			= GAP16 + GAP16;		// 128 spaces
var NL				= "<br>";
var NL2				= "<br><br>";
var NL3				= "<br><br><br>";
var NL4				= NL2 + NL2;

var FALSE			= 0;
var TRUE			= 1;

// Measurements should never be normalised in initialisation. Use PxH and PxW at point of final assignment. This allows arithmetic to be done with any declared dimension.
var UNIT_BASE		= 1000;
var USEABLE_HEIGHT	= screen.availHeight * .82;
var USEABLE_WIDTH	= screen.availWidth  * .98;

//var USEABLE_HEIGHT	= .body.clientHeight;
//var USEABLE_WIDTH	= .body.clientWidth;

var HEIGHT_UNIT		= USEABLE_HEIGHT / UNIT_BASE;
var WIDTH_UNIT		= USEABLE_WIDTH  / UNIT_BASE;

var WIDTH_AS_HEIGHT	= WIDTH_UNIT / HEIGHT_UNIT;

var AILURL			= "http://www.anywareinlondon.demon.co.uk/";
var UK2URL			= "http://www.bevrowe.info/";
var CurrentURL		= location.href;

var AIL_CVURL		= AILURL + "CV/";
var UK2_CVURL		= UK2URL + "CV/";

var AILAddress		= AILURL;
var UK2Address		= UK2URL;

var HomeURL			= UK2URL + "index.html";
var MainURL			= UK2URL;

// Key codes
var BACKSPACE		=   8;
var DIGIT_0			=  48;
var DIGIT_9			=  57;
var DOLLAR			=  52;
var DOWN_ARROW		=  40;
var ESCAPE			=  27;
var F4				= 115;
var F9				= 120;
var F10				= 121;
var F11				= 122;
var F12				= 123;
var HASH			= 222;
var HYPHEN			= 189;
var LEFT_ARROW		=  37;
var LETTER_A		=  65;
var LETTER_Z		=  90;
var MINUS			= 189;
var MINUS_NUM		= 109;
var PAGE_DOWN		=  34;
var PAGE_UP			=  33;
var PLUS			= 187;
var PLUS_NUM		= 107;
var RETURN			=  13;
var RIGHT_ARROW		=  39;
var SPACE			=  32;
var SHIFT_KEY		=  16;
var UP_ARROW		=  38;

var MINUTE			= 60 * 1000;
var HOUR			= MINUTE * 60;
var DAY				= HOUR * 24;
var WEEK			= DAY * 7;


var Browser			= new BrowserDetector (navigator.userAgent);
var BrowserType		= Sniffer ();

var iH				= new Array ();							// Stores values of innerHTML against raw ids
var iHDefined;
var iEonmouseover	= new Array ();							// Stores values of onclick events against raw ids

var LeftHeight		= UNIT_BASE;
var LeftWidth		= 180;
var RightHeight		= UNIT_BASE;

var RightWidth		= UNIT_BASE - LeftWidth;

var RightWidth1		= RightWidth2	= RightWidth / 2;

var	FontSize1		= Math.max (25, 50);
var	FontSize1_5		= 40;
var	FontSize2		= 30;
var	FontSize2_5		= 25;
var	FontSize2_7		= 22;
var	FontSize3		= 19;
var	FontSize3_5		= 17;
var	FontSize4		= 15;
var	FontSize5		= 10;
var MinFontSize		= 9;

var Light			= 0;
var Dark			= 1;
var Strip			= 2;
var MaxC			= 4;
var ColorsToUse		= [["whitesmoke", "mistyrose", "lavenderblush", "aliceblue", "blanchedalmond", "cornsilk", "seashell", "lightyellow"],["black", "seagreen", "sienna"],["orange", "lightblue",	"yellowgreen", "plum"]];

var ColorsInUse		= new Array ();

ColorsInUse[0]		= new Array ();
ColorsInUse[1]		= new Array ();
ColorsInUse[2]		= new Array ();
for (var c = 0; c < ColorsToUse[0].length; c++) ColorsInUse[0][c]	= false;
for (var c = 0; c < ColorsToUse[1].length; c++) ColorsInUse[1][c]	= false;
for (var c = 0; c < ColorsToUse[2].length; c++) ColorsInUse[2][c]	= false;

var BodyBackground	= ColorText (Light);
var GlobalBackground= ColorText (Light);
var GlobalTextColor	= "black";	//ColorText (Dark);
var StripBackground	= ColorText (Strip);

var StripTextColor	= GlobalTextColor;

var JobsLeft		= 20;
var PadLeft			= 50;
var PadRight		= 50;

var ButtonAlignment	= "center";
var ButtonColor		= GlobalTextColor;
var	ButtonBackground= ColorText (Light);
//var ButtonBackground= StripBackground;
//var ButtonBackground= ["wheat",			"skyblue",		"silver",			"pink"		][RF (MaxC)];
var ButtonOverColor	= "black";
var ButtonOverBGC	= "silver";
var ButtonStayColor	= "white";			//"yellow";
var ButtonStayBGC	= StripBackground;	//"gray";

var ButtonInc		= 75;
var ButtonTop		= 100;
var ButtonHeight	= 50;	//40;
var ButtonText;					// Set inside DrawButton each time
var ButtonWidth		= 130;

var ButtonLeft		= (LeftWidth - ButtonWidth) / 2;

var ThisButton		= ButtonColor;

//var ButtonsFound	= new Array();	// Added to by DrawButton in order of creation, not order down the page
//var ButtonCurrent	= _;			// id of button with focus

var ClickEvent		= new Array();
var DblClickEvent	= new Array();
var OutEvent		= new Array();
var OverEvent		= new Array();
var ActualColor		= new Array();
var ActualBGC		= new Array();
var OverColour		= new Array();
var OverBGC			= new Array();
var StayColor		= new Array();
var StayBGC			= new Array();
var LastButton		= new Array();

var LeftPanelBackground		= StripBackground;
var RightPanelBackground	= GlobalBackground;

var LeftPanelStyle	= ["LeftPanel", "BACKGROUND", LeftPanelBackground, "HEIGHT", UNIT_BASE, "LEFT", 0,
						"TOP", 0, "WIDTH", LeftWidth ];
var RightPanelStyle	= ["RightPanel", "BACKGROUND", RightPanelBackground, "HEIGHT", RightHeight, "LEFT", LeftWidth,
						"TOP", 0, "WIDTH", RightWidth];
var RPInc			= 50;
var	RPLeft			= PadLeft;
var RPPR			= 40;
var	RPTop			= ButtonTop;

for (var b = 0; b <= 1; b++)
	{
	LastButton[b]		= _;
	}

//Deb ("GS", 5);
for (var b = 0; b < document.all.length; b++)
	{
	with (document.all(b))
		{
		if (tagName == "BODY")
			{

// If a body has its own onload, it should handle the # effect
			if (onload == _) onload	= function () {Setup ()};

// If a body has its own ondown, it should include a call to setup
			if (! onkeydown)
				{
//Debug ("GS", document.all.length);
				onkeydown	= function () {GetKeyCode ();};
				}

			if (! id) id = "oBody";
			with (style)
				{
				color		= GlobalTextColor;
//				fontFamily	= "Helvetica, Arial, sans-serif";
//				fontFamily	= "'Times New Roman', Arial, sans-serif";
				fontFamily	= "'Verdana, Times New Roman', Arial, sans-serif";
				}
			break;
			}
		}
	}


//Deb ("GS", 10);
var dragObj		= new Object();
dragObj.zIndex	= 0;

//-------------------------------------------------------------------------------
function Bottom (obj) 
//-------------------------------------------------------------------------------
{

//Debug (3, xPH (obj.offsetTop), xPH (obj.offsetHeight));
return (xPH (obj.offsetTop) + xPH (obj.offsetHeight));
}


//-------------------------------------------------------------------------------
function BrowserDetector(ua) {
//-------------------------------------------------------------------------------

/*
Parses User-Agent string into useful info.
Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)
Author: Richard Blaylock
Author Email: blaylock@wired.com

Usage: var bd = new BrowserDetector(navigator.userAgent);
*/
//Debug ("SS", ua);
// Defaults
this.browser		= "Unknown";
this.platform		= "Unknown";
this.version		= "";
this.majorver		= "";
this.minorver		= "";

if (document.URL.match(/index.html/) == _) return;
//Debug("SS", "YES");
// Split into stuff before parens and stuff in parens

var preparens		= "";
var parenthesized	= "";

var i				= ua.indexOf("(");
if (i >= 0)
	{
	preparens		= Trim(ua.substring(0,i));
	parenthesized	= ua.substring(i+1, ua.length);
	j				= parenthesized.indexOf(")");
	if (j >= 0)
		{
		parenthesized	= parenthesized.substring(0, j);
		}
	}
else
	{
	preparens = ua;
	}

// First assume browser and version are in preparens. Override later if we find them in the parenthesized stuff

var browver	= preparens;
var tokens	= parenthesized.split(";");
var token	= "";

// Now go through parenthesized tokens

for (var i = 0; i < tokens.length; i++)
	{
	token = Trim (tokens[i]); 								// compatible - might want to reset from Netscape
	if (token == "compatible")
		{
		//## One might want to reset browver to a null string
		//## here, but instead, we'll assume that if we don't
		//## find out otherwise, then it really is Mozilla
		//## (or whatever showed up before the parens).
		//## browser - try for Opera or IE
		}
	else if (token.indexOf("MSIE") >= 0)
		{
		browver = token;
		}
	else if (token.indexOf("Opera") >= 0)
		{
		browver = token;
		}
		//'## platform - try for X11, SunOS, Win, Mac, PPC
	else if ((token.indexOf("X11") >= 0) || (token.indexOf("SunOS") >= 0) || (token.indexOf("Linux") >= 0))
		{
		this.platform = "Unix";
		}
	else if (token.indexOf("Win") >= 0)
		{
		this.platform = token;
		}
	else if ((token.indexOf("Mac") >= 0) || (token.indexOf("PPC") >= 0))
		{
		this.platform = token;
		}
	}

var msieIndex	= browver.indexOf("MSIE");
if (msieIndex >= 0)
	{
	browver	= browver.substring(msieIndex, browver.length);
	}

var leftover	= "";
if (browver.substring(0, "Mozilla".length) == "Mozilla")
	{
	this.browser	= "Netscape";
	leftover		= browver.substring("Mozilla".length+1, browver.length);
	}
else if (browver.substring(0, "Lynx".length) == "Lynx")
	{
	this.browser	= "Lynx";
	leftover		= browver.substring("Lynx".length + 1, browver.length);
	}
else if (browver.substring(0, "MSIE".length) == "MSIE")
	{
	this.browser	= "IE";
	leftover		= browver.substring("MSIE".length+1, browver.length);
	}
else if (browver.substring(0, "Microsoft Internet Explorer".length) == "Microsoft Internet Explorer")
	{
    this.browser	= "IE"
	leftover		= browver.substring("Microsoft Internet Explorer".length+1, browver.length);
	}
else if (browver.substring(0, "Opera".length) == "Opera")
	{
	this.browser	= "Opera"
	leftover		= browver.substring("Opera".length + 1, browver.length);
	}

leftover = Trim (leftover);

// # Try to get version info out of leftover stuff
i	= leftover.indexOf(" ");
if (i >= 0)
	{
	this.version	= leftover.substring(0, i);
	}
else
	{
	this.version	= leftover;
	}
j = this.version.indexOf(".");
if (j >= 0)
	{
	this.majorver	= this.version.substring(0,j);
	this.minorver	= this.version.substring(j+1, this.version.length);
	}
else
	{
	this.majorver = this.version;
	}

//Debug ("WW", this.platform);
//if (!((this.browser == "IE"			&& this.version == "6.0" 
//	|| this.browser == "Navigator"	&& this.version == "7.0") && (this.platform == "Windows 98" || this.platform == "Windows NT 5.0")))
//	if (document.URL.search (/.*index.html/) != -1)
//		alert ("Warning: you may be using a browser (or version or platform) on which this site has not been tested.");

}																		// BrowserDetector

//-------------------------------------------------------------------------------
function ButtonClick (level, idin)
//-------------------------------------------------------------------------------
{
var objevent	= GetObjectEvent(idin);

//Debug ("BC", idin, objevent.onclick);
GetObject(idin).style.color				= ButtonStayColor;
GetObject(idin).style.backgroundColor	= ButtonStayBGC;

if (idin != "B1")
	{
	objevent.onclick						= "";
	objevent.onmouseover					= "";
	objevent.onmouseout						= "";
	}

if (LastButton[level] != _)
	{
	var objs				= GetObject (LastButton[level]).style;
	var objevent			= GetObjectEvent(LastButton[level]);

	objs.color				= ActualColor[LastButton[level]];
	objs.backgroundColor	= ActualBGC[LastButton[level]];
	objevent.onclick		= new Function(ClickEvent[LastButton[level]]);
	objevent.ondblclick		= new Function(DblClickEvent[LastButton[level]]);
	objevent.onmouseover	= new Function (OverEvent[LastButton[level]]);
	objevent.onmouseout		= new Function (OutEvent[LastButton[level]]);
	}
LastButton[level]						= idin;
}																	// ButtonClick


//-------------------------------------------------------------------------------
function ButtonMouseOut (idin)
//-------------------------------------------------------------------------------
{
OutEvent[idin];
//	DivStyle (GetObject (idin), "BACKGROUND", ActualBGC[idin], "TEXT_COLOR", ActualColor[idin]);
//	mouseoutstring		= "GetObject('" + idin + "').style.color = "
//							+ "ActualColor['" + idin + "'];"
//							+ "GetObject ('" + idin + "').style.backgroundColor = "
//							+ "ActualBGC['" + idin + "'];";

}																	// ButtonMouseOut

//-------------------------------------------------------------------------------
//function ButtonNext ()
//-------------------------------------------------------------------------------
//	{
//	var b;
//	var k	= window.event.keyCode;
//	var up;

//	Debug ("G", k);
//	return;
//	for (b = 0; b < ButtonsFound.length; b++)
//		if (ButtonsFound[b] == ButtonCurrent) break;

//	switch (k)
//		{
//		case RETURN:
//			GetObject (ButtonsFound[b]).click;
//			Debug ("X", ClickEvent[ButtonsFound[b]]);
//			eval (ClickEvent[ButtonsFound[b]]);
//			break;

//		case DOWN_ARROW:
//			var bb	= b == ButtonsFound.length - 1 ? 0 : b + 1;
//			DivStyle (ButtonsFound[b], "BACKGROUND", ButtonBackground, "TEXT_COLOR", ButtonColor)
//			DivStyle (ButtonsFound[bb], "BACKGROUND", ButtonOverBGC)
//			ButtonCurrent	= ButtonsFound[bb];
//			break;
//
//		case UP_ARROW:
//			var bb	= b == 0 ? ButtonsFound.length - 1 : b - 1;
//			DivStyle (ButtonsFound[b], "BACKGROUND", ButtonBackground, "TEXT_COLOR", ButtonColor)
//			DivStyle (ButtonsFound[bb], "BACKGROUND", ButtonOverBGC)
//			ButtonCurrent	= ButtonsFound[bb];
//			break;
//		
//		}
//	}

//-------------------------------------------------------------------------------
function ColorFree (shade, c)
//-------------------------------------------------------------------------------
{
ColorsInUse[shade, c]	= false;
return;
}																	// ColorFree

//-------------------------------------------------------------------------------
function ColorNo (shade)
//-------------------------------------------------------------------------------
{
var c;
var n	= ColorsToUse[shade].length - 1;

while (ColorsInUse[shade][c = RF (n)]);

ColorsInUse[shade][c]	= true;

return c;
}																	// ColorNo


//-------------------------------------------------------------------------------
function ColorText (shade)
//-------------------------------------------------------------------------------
{
var c;
var n	= ColorsToUse[shade].length - 1;
var x	= 0;

while (ColorsInUse[shade][c = RF (n)] && x++ < 5);

if (x == 4) for (var j = 0; j < ColorsToUse[shade].length; j++) ColorsInUse[shade][j]	= false;

ColorsInUse[shade][c]	= true;

return ColorsToUse[shade][c];
}																	// ColorText

//-------------------------------------------------------------------------------
function Deb (id)
//-------------------------------------------------------------------------------
{
var texttoshow	= id + ": ";
var q;

if (typeof Debug.DebugIds == "undefined")
	Debug.DebugIds		= new Array ();

if (typeof Debug.DebugIds[id] != "undefined")
	q		= Debug.DebugIds[id];
else
	Debug.DebugIds[id]		= q		= true;

if (q)
	{
	for (var a = 1; a < arguments.length; a++)
		{
		var val	= arguments[a];
		if (a > 1) texttoshow	+= ", ";
		texttoshow	+= arguments[a] + " = ";
		texttoshow	+= eval (val);
		}
	Debug.DebugIds[id]	= confirm (texttoshow);
	}																// Deb

}//-------------------------------------------------------------------------------
function Debug (id)
//-------------------------------------------------------------------------------
{
var texttoshow	= id + ": ";
var q;

if (typeof Debug.DebugIds == "undefined")
	Debug.DebugIds		= new Array ();

if (typeof Debug.DebugIds[id] != "undefined")
	q		= Debug.DebugIds[id];
else
	Debug.DebugIds[id]		= q		= true;

if (q)
	{
	for (var a = 1; a < arguments.length; a++)
		{
		if (a > 1) texttoshow	+= ", ";
		texttoshow	+= arguments[a];
		}
	Debug.DebugIds[id]	= confirm (texttoshow);
	}
}																	// Debug

//-------------------------------------------------------------------------------
function DebugOff (id)
//-------------------------------------------------------------------------------
{
// Use $ to turn all current debugs on again

if (typeof Debug.DebugIds == "undefined")
	Debug.DebugIds		= new Array ();

Debug.DebugIds[id]	= false;
}																	// DebugOff


//-------------------------------------------------------------------------------
function DebugOn (id)
//-------------------------------------------------------------------------------
{
if (typeof Debug.DebugIds == "undefined")
	Debug.DebugIds		= new Array ();

Debug.DebugIds[id]	= true;
}																	// DebugOn

//-------------------------------------------------------------------------------
function DivStyle (idin)
//-------------------------------------------------------------------------------
{
// idin should be a main id, not a .style. It can be a string name or an object.
// position is set absolute as default.
	
var fixedargs		= 1;
var mouseout		= _;
var mouseover		= _;
var statustext		= _;

// The test for the definition of id is to allow for calls that use an already assigned object for idin.
if (typeof arguments[0] == "object")
	if (typeof arguments[0].id == "undefined")
		{
		var y	= new Array ();
		for (var i = 0; i < arguments[0].length; i++) y[i]	= arguments[0][i];
		for (var i = 1; i < arguments.length; i++) y[y.length]	= arguments[i];

		arguments	= y;
		idin		= y[0];
		}

var al				= arguments.length;
//Debug ("DS", idin, typeof idin);

if (typeof idin == "string")
	{
	var obj			= GetObject (idin);
	var objevent	= GetObjectEvent (idin);
	}
else
	{
	var obj			= idin;
	var objevent	= GetObjectEvent (obj.id);
	}

//Debug ("DS", 2);
var objstyle		= obj.style;

objstyle.position	= "absolute";

if (al > fixedargs)
	{
	var	argnum		= fixedargs;

	while (argnum < al)
		{
		var inc	= 2;
		var key	= arguments[argnum];
		var val	= arguments[argnum + 1];
//Debug("DS", obj.innerHTML);

		if (typeof val == "string" && key != "HTML")
			if (val.search (/px/) != -1) val = parseFloat (val.substr (0, val.length - 2));

		switch (key)
			{
			case "ALIGN":
				objstyle.textAlign		= val;
				break;

			case "BACKGROUND":
				if (typeof val == "string")
					{
//					objstyle.backgroundColor	= val;
					objstyle.background	= val;
					}
				else
					objstyle.backgroundColor	= ColorsToUse[Light][val < 0 ? ColorNo (Light) : val];
				break;

			case "BOLD":
				objstyle.fontWeight		= "bold";
				inc						= 1;
				break;

			case "BORDER":
// Use BORDERWIDTH in preference
				objstyle.borderStyle	= "solid";
				objstyle.borderWidth	= PxW (val);
				break;

			case "BORDER_COLOR":
				objstyle.borderColor	= val;
				break;

			case "BORDER_LEFT":
				objstyle.borderLeftStyle= val;
				break;

			case "BORDER_LINE":
				objstyle.border			= val;
				break;

			case "BORDER_RIGHT":
				objstyle.borderRightStyle	= val;
				break;

			case "BORDER_TOP":
				objstyle.borderTopStyle	= val;
				break;

			case "BORDER_WIDTH":
//Seems to be reset by other border features, so use last if there is trouble
				objstyle.borderWidth	= PxW (val);
				break;

			case "CENTER":
				objstyle.textAlign		= "center";
				inc						= 1;
				break;

			case "CLASS":
				obj.className			= val;
				break;

			case "CLICK":
				objevent.onclick		= new Function (val);
				break;

			case "CURSOR":
//Debug (0, val);
				objstyle.cursor			= val;
				break;

			case "DBLCLICK":
				objevent.ondblclick		= new Function (val);
				break;
					
			case "DOWN":
				objevent.onmousedown	= new Function (val);
				break;

			case "FAMILY":
				objstyle.fontFamily		= val;
				break;

			case "HEIGHT":
				objstyle.height			= PxH (val);
				break;

			case "HIDDEN":
				objstyle.visibility		= "hidden";
				inc						= 1;
				break;

			case "HTML":
				obj.innerHTML			= val;
				break;

			case "INDENT":
				objstyle.textIndent		= PxW (val);
				break;

			case "LEFT":
//				Debug ("DS", val);
				objstyle.left			= PxW (val);
				break;

			case "NAME":
//				obj.name				= val;
				alert ("'NAME' cannot be assigned in DivStyle");
				break;

			case "NOW":
				shownow					= true;
				inc						= 1;
				break;

			case "OUT":
				mouseout				= val;
				break;

			case "OVER":
				mouseover				= val;
				break;

			case "PAD":
				objstyle.padding		= PxW (val);
				break;

			case "PAD_LEFT":
				objstyle.paddingLeft	= PxW (val);
				break;

			case "PAD_RIGHT":
				objstyle.paddingRight	= PxW (val);
				break;

			case "POSITION":
				objstyle.position		= val;
				break;

			case "RELATIVE":
				objstyle.position		= "relative";
				inc						= 1;
				break;

			case "RIGHT":
				objstyle.marginRight	= PxW (val);
				break;

			case "SIZE":
				objstyle.fontSize		= PxH (val);
				break;

			case "SRC":
				obj.src					= val;
				break;

			case "STATUS":
				// Status line text must not be more than 128 chars
				statustext	= StatusLine (val);
				break;

			case "STYLE":
				objstyle.fontStyle		= val;
				break;

			case "TEXT_COLOR":
				objstyle.color			= val;
				break;

			case "TOP":
				objstyle.top			= PxH (val);
				break;

			case "UL":
				objstyle.textDecorationUnderline	= "true";
				inc						= 1;
				break;
                                        
			case "VISIBLE":
				objstyle.visibility		= "visible";
				inc						= 1;
				break;
                                        
			case "VISIBILITY":
				objstyle.visibility		= val;
				break;
                                        
			case "WEIGHT":
				objstyle.fontWeight		= val;
				break;

			case "WIDTH":
				objstyle.width			= PxW (val);
				break;

			case "Z":
				objstyle.zIndex			= val;
				break;

			default:
				Debug ("Error", "Unrecognised key word in DivStyle - " + arguments[argnum]);
				return;
			}                                        
		argnum		+= inc;
		}
	}                                        
	if (statustext != _)
		{
		if (mouseover != _)
			mouseover	=+ ";window.status=\"" + statustext + "\"";
		else
			mouseover	= "window.status=\"" + statustext + "\"";
		if (mouseout != _)
			mouseout	+= ";window.status=\"\"";
		else
			mouseout	= "window.status=\"\"";
		}

	if (mouseover != _) objevent.onmouseover	= new Function (mouseover);
	if (mouseout  != _) objevent.onmouseout		= new Function (mouseout);
//Debug ("DS", Bottom (obj));
	return Bottom (obj);
}																		// DivStyle

//-------------------------------------------------------------------------------
function DragStart()
//-------------------------------------------------------------------------------

{
var el;
var x, y;

if (BrowserType == "M")
	dragObj.elNode = window.event.srcElement;
if (BrowserType == "N")
	dragObj.elNode = event.target;

// Get cursor position with respect to the page.

  if (BrowserType == "M") {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (BrowserType == "N") {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (BrowserType == "M") {
    document.attachEvent("onmousemove", DragGo);
    document.attachEvent("onmouseup",   DragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (BrowserType == "N") {
    document.addEventListener("mousemove", DragGo,   true);
    document.addEventListener("mouseup",   DragStop, true);
    event.preventDefault();
  }
}																		// DragStart

//-------------------------------------------------------------------------------
function DragGo(event) {
//-------------------------------------------------------------------------------

  var x, y;

  // Get cursor position with respect to the page.

  if (BrowserType == "M") {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (BrowserType == "N") {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (BrowserType == "M") {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (BrowserType == "N")
    event.preventDefault();
}																		// DragGo

//-------------------------------------------------------------------------------
function DragStop(event) {
//-------------------------------------------------------------------------------

  // Stop capturing mousemove and mouseup events.

  if (BrowserType == "M") {
    document.detachEvent("onmousemove", DragGo);
    document.detachEvent("onmouseup",   DragStop);
  }
  if (BrowserType == "N") {
    document.removeEventListener("mousemove", DragGo,   true);
    document.removeEventListener("mouseup",   DragStop, true);
  }	
}																	// DragStop

//-------------------------------------------------------------------------------
function DrawButton (idinx, leftin, topin, textin, heightin, widthin, bgcin, overbgcin, colorin, urlinx)
//-------------------------------------------------------------------------------
{
// 23 Jan 02
// 17 Jun 02

//Debug ("DB10", bgcin);

// Co-ordinated buttons: where buttons are to remain but current page is disabled, use STAY with the first screen INITIAL.

var al				= arguments.length;
var bgctouse		= bgcin		== _ ? ButtonBackground	: bgcin;
var blinkinc;
var blinkinct;
var clickstring		= "";
var colortouse		= colorin	== _ ? ButtonColor		: colorin;
var dblclickstring	= "";
var fixedargs		= 10;
var heighttouse		= heightin	== _ ? ButtonHeight		: heightin;
var idin			= idinx.replace (/'/, /$/);
var idintouse		= idinx;
var initial			= FALSE;
var initial1		= FALSE;
var innertextalign	= ButtonAlignment;
var makeblink		= false;
var makeblinkt		= false;
var mouseoutstring	= _;
var mouseoverstring	= _;
var overbgctouse	= overbgcin	== _ ? ButtonOverBGC	: overbgcin;
var overcolortouse	= ButtonOverColor;
var sizestring		= _;
var stay			= FALSE;
var stay1			= FALSE;
var staybgctouse	= ButtonStayBGC;
var staycolortouse	= ButtonStayColor;
var texttouse		= textin;
var urlin			= urlinx == _ ? _ : urlinx.replace (/'/, /$/);
var visibleness		= "visible";
var widthtouse		= widthin	== _ ? ButtonWidth		: widthin;
var z				= _;

var textsizetouse	= ButtonText	= (heighttouse / 5) * 2;

//	ButtonsFound[ButtonsFound.length]	= idinx;

if (al > fixedargs)
	{
	var	argnum		= fixedargs;
	var inc			= 2;

	while (argnum < al)
		{
		var val	= arguments[argnum + 1];

		if (typeof val == "string")
			if (val.search (/px/) != -1) val = parseFloat (val.substr (0, val.length - 2));

		switch (arguments[argnum])
			{
			case "ALIGN":
				innertextalign			= val;
				break;

			case "BLINKALL":
				makeblink				= true;
				blinkinc				= val;
				break;

			case "BLINKTEXT":
				makeblinkt				= true;
				blinkinct				= val;
				break;

			case "CLICK":
				clickstring				= val;
				break;
			
			case "DBLCLICK":
				dblclickstring			= val;
				break;

			case "HIDE":
			case "HIDDEN":
				visibleness				= "hidden";
				inc						= 1;
				break;

			case "INITIAL":			// Special version of STAY that causes the button to be set.
				initial					= TRUE;
				stay					= TRUE;
				inc						= 1;
				break;

			case "INITIAL1":			// Special version of STAY that causes the button to be set.
				initial1				= TRUE;
				stay1					= TRUE;
				inc						= 1;
				break;

			case "OUT":
				mouseoutstring			= val;
				break;

			case "OVER":
				mouseoverstring			= val;
				break;

			case "OVERCOLOR":
				overcolortouse			= val;
				break;

			case "SIZE":
				ButtonText				= val;
				sizestring				= val;
				break;

			case "STAY":
				stay					= TRUE;
				inc						= 1;
				break;

			case "STAY1":
				stay1					= TRUE;
				inc						= 1;
				break;

			case "WORDS":
				var nw					= arguments[argnum + 2];
				var p1				= 0;
				var p2;
				var s				= "";

				inc					= 3;
				for (var w = val; w <= nw; w++)
					{
					p2	= texttouse.substr (p1).search (/ /);
					s	+= " " + texttouse.substr (p1).substr (0, p2);
					p1	+= p2 + 1;
					}
				texttouse			= s;
				break;

			case "Z":
				z					= val;
				break;

			default:
				Debug ("Error", "Unrecognised key word in DrawButton - " + arguments[argnum]);
				return;
			}
		argnum		+= inc;
		inc			= 2;
		}
	}

//	document.write ("<div id = '" + idintouse + "'>" + texttouse + "</div>");
document.write ("<span id = '" + idintouse + "' style='cursor:hand'>" + texttouse + " </span>");

var obj					= GetObject(idintouse);
var objs				= obj.style;
var objevent			= GetObjectEvent (idintouse);

//	obj.innerHTML			= texttouse;
objs.color				= colortouse;
objs.backgroundColor	= bgctouse;
//Debug ("DB30", bgctouse, bgcin, objs.backgroundcolor);
objs.fontFamily			= "Arial";
objs.fontSize			= PxH (textsizetouse);
objs.fontWeight			= "normal";
objs.height				= PxH ((heighttouse));
objs.left				= PxW (leftin);
objs.position			= "absolute";
objs.textAlign			= innertextalign;
objs.top				= PxH (topin);
objs.width				= PxW (widthtouse);

//	objs.paddingTop			= PxH ((heighttouse / 3) * .80);
objs.paddingTop			= PxH ((heighttouse - textsizetouse) / 2);
objs.visibility			= visibleness;

if (z != _) objs.zIndex	= z;

if (stay)
	clickstring		+= ";ButtonClick (0, '" + idin + "');";
if (stay1)
	clickstring		+= ";ButtonClick (1, '" + idin + "');";

if (urlin != _)
	{
	if (urlin.search (/;/) == 0)
		clickstring		+= urlin.substr (1);
	else
		clickstring		+= ";window.location ='" + urlin + "'";
	}

objevent.onclick	= new Function (clickstring);
objevent.ondblclick	= new Function (dblclickstring);

if (mouseoverstring == _)
	{
	mouseoverstring		= "var os = GetObject('" + idin + "').style; os.color="
							+ "OverColour['" + idin +"'];"
							+ "os.backgroundColor = "
							+ "OverBGC['" + idin + "'];"
	if (urlin != _)
		mouseoverstring	+= "window.status = '" + urlin + "'";
	}
objevent.onmouseover	= new Function (mouseoverstring);

if (mouseoutstring == _)
	{
//	mouseoutstring		= "ButtonMouseOut(" + idin + ");";
	mouseoutstring		= "GetObject('" + idin + "').style.color = "
							+ "ActualColor['" + idin + "'];"
							+ "GetObject ('" + idin + "').style.backgroundColor = "
							+ "ActualBGC['" + idin + "'];";
	if (urlin != _)
		mouseoutstring	+= "window.status = ''";
	}
		
objevent.onmouseout		= new Function (mouseoutstring);

//objevent.onfocus		= new Function ("ButtonCurrent='" + idinx + "';");
//objevent.onkeydown		= new Function ("ButtonNext ()");

if (sizestring != _)
	{
	objs.fontSize		= PxH (sizestring);
	objs.paddingTop		= PxH ((xPx (objs.height) - xPx (objs.fontSize)) / 2);
	}

while (xPx (objs.fontSize) < MinFontSize)
	objs.fontSize	= PxH (++ButtonText);

ClickEvent[idin]		= clickstring;
DblClickEvent[idin]		= dblclickstring;
OverEvent[idin]			= mouseoverstring;
OutEvent[idin]			= mouseoutstring;
ActualColor[idin]		= objs.color;
ActualBGC[idin]			= objs.backgroundColor;
OverColour[idin]		= overcolortouse;
OverBGC[idin]			= overbgctouse;
StayColor[idin]			= staycolortouse;
StayBGC[idin]			= staybgctouse;

if (initial)
	{
	obj.focus;
	ButtonClick (0, idin);
	}
if (initial1)
	ButtonClick (1, idin);

if (makeblink)
	{
	objs.visibility		= "hidden";
	setInterval ("GetObject(" + idin + ").style.visibility = GetObject(" + idin + ").style.visibility == 'visible' ? 'hidden' : 'visible'", blinkinc)
	}

if (makeblinkt)
	{
	setInterval ("GetObject(" + idin + ").innerHTML = GetObject(" + idin + ").innerHTML == '" + SP + "' ? '" + textin + "' : '" + SP + "'", blinkinct)
	}
}																	// DrawButton

//-------------------------------------------------------------------------------
function DrawLine (id, orientation)
//-------------------------------------------------------------------------------
{
var bottomu		= _;
var heightu		= _;
var leftu		= _;
var lengthu		= _;
var rightu		= _;
var topu		= _;
var widthu		= _;

var al			= arguments.length;
var fixedargs	= 2

if (al > fixedargs)
	{
	var	argnum		= fixedargs;
	var inc			= 2;

	while (argnum < al)
		{
		var val	= arguments[argnum + 1];

		switch (arguments[argnum])
			{
			case "BOTTOM":
				bottomu		= val;
				break;

			case "HEIGHT":
				leftu		= val;
				break;

			case "LEFT":
				leftu		= val;
				break;

			case "LENGTH":
				lengthu		= val;
				break;

			case "RIGHT":
				rightu		= val;
				break;

			case "TOP":
				topu		= val;
				break;

			case "WIDTH":
				widthu		= val;
				break;
			}
		argnum	+= inc;
		}
	}

document.write ("<div id='" + id + "'></div>");
var lines	= GetObject (id).style;

lines.borderWidth	= "1px";
lines.position		= "absolute";

switch (orientation)

	{
	case "V":
		if (leftu != _)
			lines.pixelLeft		= leftu;
		else
			lines.pixelRight	= rightu;
		if (heightu != _)
			lines.pixelHeight	= heightu;
		else
			lines.pixelHeight	= lengthu;
		if (topu != _)
			lines.pixelTop	= topu;
		else
			lines.pixelBottom	= bottomu;

		lines.borderLeftStyle	= "solid";
		lines.width				= 0;

	}
//	MultiAlert (lines.height);

}																		// DrawLine

//-------------------------------------------------------------------------------
function Even (n)
//-------------------------------------------------------------------------------
{
return n % 2 == 0;
}

//-------------------------------------------------------------------------------
function GetArgs ()
//-------------------------------------------------------------------------------
{
// Returns an array with the arguments of the url. ? is the leading character.
var args	= new Array();
var query	= location.search.substr(1);			// Get query string
var pairs	= query.split (",");					// Break at comma

for (var i = 0; i < pairs.length; i++)
	{
	var argname;
	var pos		= pairs[i].indexOf('=');			// Look for "name=value"
	var value;
	if	(pos == -1)
		{
		if (pairs[i].length > 0)
			{
			argname	= i;
			value	= pairs[i];
			}
		else
			continue;
		}
	else
		{
		argname		= pairs[i].substring(0, pos);		// Extract the name
		value		= pairs[i].substring(pos + 1);
		}
	args[argname]	= unescape(value);
	}

return args;
}																		// GetArgs

//-------------------------------------------------------------------------------
function GetKeyCode ()
//-------------------------------------------------------------------------------
{
var c	= LeftPanelBackground;
var k	= window.event.keyCode;

// Keep these lines in (commented out) to find out the code values for different keys:
//	if (k == 16) return;
//	Debug ("K", k);
//	return;

if (k == DOLLAR && typeof Debug.DebugIds != "undefined")
	for (var d in Debug.DebugIds)
		Debug.Ids[d]	= true;

if (k == HASH)
	{
//	oBody.background	= "red";//ColorText (Light);
//	while (c == LeftPanelBackground) c	= ColorText (Strip);
//Debug(99, c);
	DivStyle ("LeftPanel", "BACKGROUND", ColorText (Strip));
	DivStyle ("RightPanel", "BACKGROUND", ColorText (Light));
	}

return k;
}																		// GetKeyCode

//-------------------------------------------------------------------------------
function GetObject (name)
//-------------------------------------------------------------------------------
{
//		alert(BrowserType);
//Debug ("A", name, BrowserType == "N" ? document.getElementById (name) : eval (name));
return BrowserType == "N" ? document.getElementById (name) : eval (name);
}																		// GetObject

//-------------------------------------------------------------------------------
function GetObjectEvent (name)
//-------------------------------------------------------------------------------
{
return BrowserType == "N" ? document.getElementById (name) : document.all[name];
}																		// GetObjectEvent
	
//-------------------------------------------------------------------------------
function Hide (obj)
//-------------------------------------------------------------------------------
{
obj.visibility	= "hidden";
}																		// Hide

//-------------------------------------------------------------------------------
function HTMLString (s)
//-------------------------------------------------------------------------------
{
var al				= arguments.length;
var fixedargs		= 1;
var clickstring		= _;
var	idstring		= _;
var mouseout		= _;
var mouseover		= _;
var setposition		= false;
var skipafter		= 0;
var skipbefore		= 0;
var statustext		= _;
var stylestring		= "";
var tag				= "span";
var textout;
var texttouse		= s;

//Debug (4, 0, s);
if (al > fixedargs)
	{
	var	argnum		= fixedargs;

	while (argnum < al)
		{
		var inc	= 2;
		var val	= arguments[argnum + 1];

		switch (arguments[argnum])
			{
			case "ALIGN":
				stylestring	+= "align: " + val + ";";
				break;

			case "BACKGROUND":
				if (typeof val == "string")
					stylestring	+= "background-color: " + val + ";";
				else
					stylestring	+= "background-color: " + ColorsToUse[Light][val < 0 ? ColorNo (Light) : val] + "; ";
				break;

			case "BOLD":
				stylestring	+= "font-weight: bold;";
				inc						= 1;
				break;

			case "BORDER":
				stylestring	+= "border-style: solid;";
				stylestring	+= "border-width: " + val + "; ";
				break;

			case "BORDER_COLOR":
				stylestring	+= "border-color: " + val + "; ";
				break;
																		// HTMLString
			case "BOTTOM":
				stylestring	+= "bottom: " + PxH (val) + "; ";
				setposition				= true;
				break;

			case "CENTER":
				texttouse				= "<center>" + texttouse + "</center>";
				inc						= 1;
				break;

			case "CLICK":
				clickstring				= val;
				break;

//			case "DBLCLICK":
//				objevent.ondblclick		= new Function (val);
//				break;
//					
			case "FAMILY":
				stylestring	+= "font-family: " + val +"; ";
				break;

			case "HEIGHT":
				stylestring				+= "height: " + PxH (val) + "; ";
				setposition				= true;
				break;

//			case "HIDDEN":
//				objstyle.visibility		= "hidden";
//				inc						= 1;
//				break;

			case "ID":
				idstring				= val;
				break;

//			case "INDENT":
//				objstyle.textIndent		= PxW (val);
//				break;

			case "ITALIC":
				texttouse				= "<i>" + texttouse + "</i>";
				inc						= 1;
				break;
																		// HTMLString
			case "LEFT":
				stylestring				+= "left: " + PxW (val) + "; ";
				setposition				= true;
				break;

			case "OUT":
				mouseout				= val;
				break;

			case "OVER":
				mouseover				= val;
				break;

//			case "PAD":
//				objstyle.padding		= PxW (val);
//				break;
//
//			case "PAD_LEFT":
//				objstyle.paddingLeft	= PxW (val);
//				break;
//
//			case "PAD_RIGHT":
//				objstyle.paddingRight	= PxW (val);
//				break;
//
//			case "POSITION":
//				objstyle.position		= val;
//				break;
//
//			case "RIGHT":
//				objstyle.marginRight	= PxW (val);
//				break;
//
			case "SIZE":
				stylestring				+= "font-size: " + PxH (val) + "; ";
				break;
																		// HTMLString
			case "SKIP_AFTER":
				skipafter				= val;
				break;

			case "SKIP_BEFORE":
				skipbefore				= val;
				break;

			case "STATUS":
				// Status line text must not be more than 128 chars
				statustext	= StatusLine (val);
				break;

			case "STYLE":
				stylestring				+= "font-style: " + val + "; ";
				break;

			case "TAG":
				tag						= val;
				break;

			case "TEXT_COLOR":
				stylestring	+= "color: " + val + ";";
				break;

			case "TOP":
				stylestring				+= "top: " + PxH (val) + ";";
				setposition				= true;
				break;

			case "UL":
				stylestring	+= "text-decoration: underline; ";
				inc						= 1;
				break;

			case "VERTICAL":
				objstyle.verticalAlign	= val;
				break;

			case "WEIGHT":
				stylestring	+= "font-weight: " + val + "; ";
				break;

			case "WIDTH":
				stylestring	+= "width: " + PxW (val) + "; ";
				break;

//			case "Z":
//				objstyle.zIndex			= val;
//				break;
																		// HTMLString
			default:
				Debug ("Error", "Unrecognised key word in HTMLString - " + arguments[argnum]);
				return;
			}
		argnum		+= inc;
		}
	}

//	var fs = xPx (objstyle.fontSize);
//	while (xPx (objstyle.fontSize) < MinFontSize)
//		objstyle.fontSize	= PxH (++fs);

	textout	= "<" + tag;

	if (setposition) stylestring	+= "position: absolute;";
																			// HTMLString
	if (idstring != _)		textout	+= " id = '"		+ idstring		+ "'"; 
	if (stylestring != "")	textout	+= " style = '"		+ stylestring	+ "'";
	if (clickstring != _)	textout	+= " onclick ='"	+ clickstring	+ "'"; 

	if (statustext != _)
		{
//Debug ("H", statustext, mouseout, mouseover);
		if (mouseout != _)
			mouseout	+= ";window.status=''";
		else
			mouseout	= "window.status=''";

		if (mouseover != _)
			mouseover	=+ ";window.status='" + statustext + "'";
		else
			mouseover	= "window.status='" + statustext + "'";
//Debug ("H", 80);
		}

	if (mouseout != _) textout	+= " onmouseout =\""	+ mouseout		+ "\"";
	if (mouseover != _) textout+= " onmouseover =\""	+ mouseover		+ "\"";
//Debug ("I", mouseover, textout);

	textout		+= ">" + texttouse + "</" + tag + ">";
	for (var s = 1; s <= skipbefore; s++) textout	= "<br>" + textout;
	for (var s = 1; s <= skipafter; s++) textout	+= "<br>";
//Debug (4, textout);
	return	textout;
}																	// HTMLString

//-------------------------------------------------------------------------------
function Job (idin, where, when, what, top)
//-------------------------------------------------------------------------------
{
var entry	= "<table width='100%'><tr><td style='width:80%;font-size:"+PxH(FontSize2-5)+";font-weight:bold'>" + where + "</td>"
+ "<td style='width:20%;font-size:"+PxH(FontSize3+1)+";font-style:italic;font-weight:normal'>" + when + "</td></tr></table>";

WriteText (idin, JobsLeft, top, entry, "SPAN", "RELATIVE", "SIZE", FontSize2 - 5, "WEIGHT", "bold");
WriteText (idin + "bb", PadLeft + 30, top, what, "PAD_RIGHT", 10, "RELATIVE", "SIZE", FontSize3 + 1);
}																	// Job

//-------------------------------------------------------------------------------
function MultiAlert ()
//-------------------------------------------------------------------------------
{
var texttoshow	= arguments[0];
for (var a = 1; a < arguments.length; a++)
	{
	texttoshow	+= " - " + arguments[a];
	}
alert (texttoshow);
}																	// MultiAlert

//-------------------------------------------------------------------------------
function NewColors ()
//-------------------------------------------------------------------------------
{
BodyBackground	= ColorText (Light);
GlobalBackground= ColorText (Light);
StripBackground	= ColorText (Strip);

}
//-------------------------------------------------------------------------------
function Node (idin)
//-------------------------------------------------------------------------------
{
// idin should be a main id, not a .style. It must be a string name.

var al			= arguments.length;
var argnum		= 1;
//var fixedargs	= 1;
var htmltag		= "span";
var inc;
var key;
var obj;
var objstyle;
var objtext;
var val;

if (typeof idin == "string")
	{
	obj			= document.getElementById (idin);
	}
else
	{
	obj			= idin;
	}

if (! obj)
	{
//	if (al > 1)
//		{
//		switch (arguments[1])
//			{
//			case "INPUT":
//				htmltag		= "form";
//				argnum		= 2;
//				break;
//			}
//		}

	obj		= document.createElement (htmltag);
	obj.id	= idin;
	document.body.appendChild (obj);
	}

if (! obj.childNodes.length)
	{
	obj.appendChild (document.createTextNode ());
	}		

objstyle			= obj.style
objtext				= obj.childNodes[0];

objstyle.position	= "absolute";
																		// Node
if (al > argnum)
	{
//	var	argnum		= argtouse;

	while (argnum < al)
		{
//Debug ("N", argnum, arguments[argnum]);
		inc		= 2;
		key		= arguments[argnum];
		val		= arguments[argnum + 1];

		switch (key)
			{
// Overall values:
			case "HEIGHT":
				objstyle.height			= PxH (val);
				break;

			case "LEFT":
				objstyle.left			= PxW (val);
				break;

			case "PARENT":
				GetObject (val).appendChild (obj);
				break;

			case "TEXT":
				if (! val) val	= "";
				obj.innerHTML			= val;
				break;

			case "TOP":
				objstyle.top			= PxH (val);
				break;

			case "WIDTH":
				objstyle.width			= PxW (val);
				break;

// Non-border, non-event values:
			case "ALIGN":
				objstyle.textAlign		= val;
				break;

			case "BACKGROUND":
				if (typeof val == "string")
					{
//					objstyle.backgroundColor	= val;
					objstyle.background	= val;
					}
				else
					objstyle.backgroundColor	= ColorsToUse[Light][val < 0 ? ColorNo (Light) : val];
				break;

			case "BOLD":
				objstyle.fontWeight		= "bold";
				inc						= 1;
				break;


			case "CENTER":
				objstyle.textAlign		= "center";
				inc						= 1;
				break;

			case "CLASS":
				obj.className			= val;
				break;

			case "CURSOR":
//Debug (0, val);
				objstyle.cursor			= val;
				break;
																		// Node
			case "DBLCLICK":
				objevent.ondblclick		= new Function (val);
				break;
					
			case "DOWN":
				objevent.onmousedown	= new Function (val);
				break;

			case "FAMILY":
				objstyle.fontFamily		= val;
				break;


			case "HIDDEN":
				objstyle.visibility		= "hidden";
				inc						= 1;
				break;

			case "INDENT":
				objstyle.textIndent		= PxW (val);
				break;

			case "ITALIC":
				objstyle.fontStyle		= "italic";
				inc						= 1;
				break;

			case "NAME":
//				obj.name				= val;
				alert ("'NAME' cannot be assigned in DivStyle");
				break;

			case "NOW":
				shownow					= true;
				inc						= 1;
				break;

			case "PAD":
				objstyle.padding		= PxW (val);
				break;
																		// Node
			case "PAD_LEFT":
				objstyle.paddingLeft	= PxW (val);
				break;

			case "PAD_RIGHT":
				objstyle.paddingRight	= PxW (val);
				break;

			case "POSITION":
				objstyle.position		= val;
				break;

			case "RELATIVE":
				objstyle.position		= "relative";
				inc						= 1;
				break;

			case "RIGHT":
				objstyle.marginRight	= PxW (val);
				break;

			case "SIZE":
				objstyle.fontSize		= PxH (val);
				break;

			case "SRC":
				obj.src					= val;
				break;

			case "STATUS":
				// Status line text must not be more than 128 chars
				statustext	= StatusLine (val);
				break;

			case "STYLE":
				objstyle.fontStyle		= val;
				break;

			case "TEXT_COLOR":
				objstyle.color			= val;
				break;

			case "UL":
				objstyle.textDecorationUnderline	= "true";
				inc						= 1;
				break;
                                        
			case "VISIBLE":
				objstyle.visibility		= "visible";
				inc						= 1;
				break;
                                        
			case "VISIBILITY":
				objstyle.visibility		= val;
				break;
                                        
			case "WEIGHT":
				objstyle.fontWeight		= val;
				break;

			case "Z":
				objstyle.zIndex			= val;
				break;

// Event values:
			case "CLICK":
				obj.onclick				= new Function (val);
				break;

			case "OUT":
				obj.onmouseout			= new Function (val);
				break;

			case "OVER":
				obj.onmouseover			= new Function (val);
				break;

// Border values:
			case "BORDER":
				// Use BORDERWIDTH in preference
				objstyle.borderStyle		= "solid";
				objstyle.borderWidth		= PxW (val);
				break;

			case "BORDER_COLOR":
				objstyle.borderColor		= val;
				break;

			case "BORDER_LEFT":
				objstyle.borderLeftStyle	= val;
				break;

			case "BORDER_LINE":
				objstyle.border				= val;
				break;

			case "BORDER_RIGHT":
				objstyle.borderRightStyle	= val;
				break;

			case "BORDER_TOP":
				objstyle.borderTopStyle		= val;
				break;

			case "BORDER_WIDTH":
//Seems to be reset by other border features, so use last if there is trouble
				objstyle.borderWidth		= PxW (val);
				break;

// Input values:
//			case "TYPE":
//				obj.type					= val;

			default:
				Debug ("Error", "Unrecognised key word in Node - " + arguments[argnum]);
				return;
			}                                        
		argnum		+= inc;
		}
	}                                        
//	if (statustext != _)
//		{
//		if (mouseover != _)
//			mouseover	=+ ";window.status=\"" + statustext + "\"";
//		else
//			mouseover	= "window.status=\"" + statustext + "\"";
//		if (mouseout != _)
//			mouseout	+= ";window.status=\"\"";
//		else
//			mouseout	= "window.status=\"\"";
//		}
//
//	if (mouseover != _) objevent.onmouseover	= new Function (mouseover);
//	if (mouseout  != _) objevent.onmouseout		= new Function (mouseout);
//Debug ("DS", Bottom (obj));
	return obj;
}																		// Node

//-------------------------------------------------------------------------------
function OpenWindow(url)
//-------------------------------------------------------------------------------
{
var w			= screen.availWidth - 10;
var h			= screen.availHeight - 20;
var features	= "";

features		= "toolbar=yes";
features		+= ",width=" + w + ",height="+h;
features		+= ",left=0,top=0,screenX=0,screenY=0";

//Debug ("OW", features);

window.open(url, "", features);
}

//-------------------------------------------------------------------------------
function Pause ()
//-------------------------------------------------------------------------------
{
Debug ("Pause", "");
}																		// Pause

//-------------------------------------------------------------------------------
function PxH (xin)
//-------------------------------------------------------------------------------
// Use a negative argument to get a scaled value without 'px'
{
var x	= xin * HEIGHT_UNIT;
return x > 0 ? Math.round (x) + "px" : Math.round (-x);
}																		// PxH

//-------------------------------------------------------------------------------
function PxW (xin)
//-------------------------------------------------------------------------------
// Use a negative argument to get a scaled value without 'px'
{
var x	= xin * WIDTH_UNIT;
return x > 0 ? Math.round (x) + "px" : Math.round (-x);
}																		// PxW

//-------------------------------------------------------------------------------
function xPH (x)
//-------------------------------------------------------------------------------
{
return parseInt (x) / HEIGHT_UNIT;
}																		// xPH



//-------------------------------------------------------------------------------
function xPW (x)
//-------------------------------------------------------------------------------
{
return parseInt (x) / WIDTH_UNIT;
}																		// xPW



//-------------------------------------------------------------------------------
function xPx (x)
//-------------------------------------------------------------------------------
{
return parseInt (x);
}																		// xPx

//-------------------------------------------------------------------------------
function R (n)
//-------------------------------------------------------------------------------
{
if (typeof n == "undefined")
	return Math.random ();
else
	return Math.random () * n;
}																		// R
	
//-------------------------------------------------------------------------------
function RF (n)
//-------------------------------------------------------------------------------
{
return Math.floor (Math.random () * n);
}																		// RF
		
//-------------------------------------------------------------------------------
function RR (n)
//-------------------------------------------------------------------------------
{
return Math.round (Math.random () * n);
}																		// RR

//-------------------------------------------------------------------------------
function Show (obj)
//-------------------------------------------------------------------------------
{
obj.visibility	= "visible";
}																		// Show
	
//-------------------------------------------------------------------------------
function SetGlobalAttributes ()
//-------------------------------------------------------------------------------
{
for (var a in document.all)
	{
	if (eval(a).tagName == "BODY")
		{
		var b = eval(a).currentStyle;
		GlobalBGC	= b.backgroundColor;
		GlobalColor	= b.color;
		break;
		}
	}
}																		// SetGlobalAttributes
	
	
//-------------------------------------------------------------------------------
function Setup ()
//-------------------------------------------------------------------------------
// This function must be used **only** as the handler for window.onload event in the body tag
{
//Debug ("Su", 0);
for (var h in iH)
	{
	if (iH[h] != _) GetObject (h).innerHTML		= iH[h];
	iHDefined		= true;
	}
//Debug ("Su", 4);

for (var e in iEonmouseover)
	{
	if (iEonmouseover[e] != _) GetObjectEvent (e).onmouseover		= iEonmouseover[e];
//	iHDefined		= true;
	}			
//if (ButtonsFound.length)
//	{
//	var ob	= GetObject ("oBody");
	
//	b.onkeydown	= "ButtonNext ()";
//	b.click;
//	}
//Debug ("Su", 9);

}																	// Setup
	
//-------------------------------------------------------------------------------
function Sniffer ()
//-------------------------------------------------------------------------------
{
var browser	= new Object();
var s		= "" + document.location;

window.status		= navigator.appName;

if (navigator.appName.indexOf ("Microsoft") != -1)
	browser.type	= "M";
else if (navigator.appName.indexOf ("Netscape") != -1)
	browser.type	= "N";
else
	browser.type	= "O";

browser.version	= parseInt (navigator.appVersion);

if (browser.type == "O" || browser.type == "M" && (browser.version < 4 || navigator.appVersion.search (/MSIE [56]/) == -1) || browser.type == "N" && browser.version < 5)
	{
	browser.type	= "O";
//	if (s.match (/.*index.htm|.*QueneauHome.htm/) != _)
//		alert ("You are not using a browser than can handle this website. It is designed for PCs with IE5 or IE6 and mostly works with NS6.1");
	}
return browser.type;
}																	// Sniffer
//-------------------------------------------------------------------------------
function StatusLine (t, use)
//-------------------------------------------------------------------------------
// Creates a right justified status message with stars on each side.

{

var nstars		= 5;
var stars		= "";
var template	= "                                                                                                                                "			// 128 spaces
if (t != _)
	{
	while (t.length + 2 * nstars + 2 > template.len && nstars > 1) nstars--;
	for (var n = 1; n <= nstars; n++) stars	+= "*";
	template	= template.substr (1, template.length - t.length - 2 * stars.length - 2) + stars + " " + t + " " + stars;
	}
else
	template	= "";

if (typeof use != "undefined") if (use) window.status	= template;

return template;

}																		// StatusLine

//-------------------------------------------------------------------------------
function TestColors ()
//-------------------------------------------------------------------------------
{
var x1		= 30;
var y1		= 30;

var h		= 80;
var n		= 0;
var w0		= 80;
var w2		= 30;
var x		= x1;
var xinc	= 150;
var y		= y1;
var yinc	= 100;

for (var c0 in ColorsToUse[0])
	{
	for (var c2 in ColorsToUse[2])
		{
//Debug ("C", c1, c2);
		WriteText ("CT" + n, x, y, "", "BACKGROUND", ColorsToUse[2][c2], "HEIGHT", h, "WIDTH", w2);
		WriteText ("CU" + n + 1, x + w2, y, "", "BACKGROUND", ColorsToUse[0][c0], "HEIGHT", h, "WIDTH", w0);
		WriteText ("CV" + n + 2, x + w2 / 2, y + yinc / 2, "X", "TEXT_COLOR", ButtonStayColor);
		n	+= 3;
		x	+= xinc;
		}
	x		= x1;
	y		+= yinc;
	}
}																		// TestColors

//-------------------------------------------------------------------------------
function Timer (val)
//-------------------------------------------------------------------------------

{
var now	= new Date ().getTime ();

if (arguments.length == 1)
	{
	switch (val)
		{
		case "Start":
			Timer.times	= new Array ();
			Timer.starttime	= now;
			break;

		case "Show":
			Timer.times.push (now - Timer.starttime);
			Debug ("Show times", Timer.times);
//			for (var t in Timer.times) Debug ("Show times", Timer.times[t]);
			return;
		}
	}
//Debug (0, starttime, now);
Timer.times.push (now - Timer.starttime);

}

//-------------------------------------------------------------------------------
function Trim (inString)
//-------------------------------------------------------------------------------
// Trims spaces from both ends of a string

{
var end		= inString.length;
var start	= 0;

while ((start < end) && (inString.charAt(start) == ' ')) ++start;
while ((end > 0) && (inString.charAt(end - 1) == ' ')) --end;

return	inString.substring(start, end);
}																	// Trim

//-------------------------------------------------------------------------------
function WritePoem (objh, objv1, objv2, verse)
//-------------------------------------------------------------------------------
{
var ce	= ""; 
var m			= typeof verse[2] == "undefined" ? verse[1].length : Math.max (verse[1].length, verse[2].length);
//Debug ("WP", typeof verse[2]);
	
var t			= typeof arguments[4] == "undefined" ? (250 - m) / 2 : arguments[4];

objh.style.top	= PxH (t);
objv1.style.top	= objv2.style.top	= PxH (t + 50);

//Debug ("", verse[1].length, t, objh.style.top, objv1.style.top);

objh.innerHTML	= "<b>" + verse[0][0] + "</b><br>"; 

for (var v = 0; v < verse[1].length; v++)
	ce	+= "<br>" + verse[1][v];
objv1.innerHTML	= ce;

if (verse.length == 3)
	{
	ce	= "";
	for (var v = 0; v < verse[2].length; v++)
		ce	+= "<br>" + verse[2][v];
	objv2.innerHTML	= ce;
	}
else
	objv2.innerHTML	= "";
}																		// WritePoem

//-------------------------------------------------------------------------------
function WriteText (idin, leftin, topin, textin)
//-------------------------------------------------------------------------------
{
// If idin is a string, this is a new object and is later created. If it is already an object, then the new text either overwrites
// the old one, or ("APPEND") is appended. 
	
// NB a tagname (eg "SPAN" or "H1") must *always* be the first supernumary parameter.
//    If there is a NAME parameter, that must come next

//Debug (4, 0, textin);
var al				= arguments.length;
var append			= false;
var doctouse		= _;
var fixedargs		= 4;
//var heighttouse		= 0;
var htmltag			= _;
var lefttouse;
var mousedown		= "";
var mouseout		= "";
var mouseover		= "";
var nametouse		= _;
var openonly		= false;
var shownow			= false;
var statustext		= _;
var textintouse		= textin;
var toptouse;
//var useh1			= false;
//var useimg			= false;
//var usespan			= false;

//Debug ("WT", idin);

if (typeof WriteText.privateid == "undefined")
	WriteText.privateid	= 0;

if (al > fixedargs)
	{
	switch (arguments[fixedargs])
		{
		case "A":
			htmltag		= "a"
			break;

		case "H1":
			htmltag		= "h1";
			break;

		case "IMG":
			htmltag		= "img";
			textintouse	= _;
			break;

		case "SPAN":
			htmltag		= "span";
			break;

		case "TD":
			htmltag		= "td";
			break;

		case "TEXTAREA":
			htmltag		= "textarea";
			textintouse	= _;
			break;
		}

	if (htmltag) fixedargs++;

	if (arguments[fixedargs] == "NAME")
		{
		nametouse	= arguments[fixedargs + 1];
		fixedargs	+= 2;
		}
	}

if (typeof leftin == "string")
	{
	if (leftin.match (/px/) != -1)
		{
		lefttouse = leftin;
		}
	else
		{
		alert ("Error in WriteText");
		}
	}
else
	lefttouse	= leftin;

if (typeof topin == "string")
	{
	if (topin.match (/px/) != -1)
		{
		toptouse = topin;
		}
	else
		{
		alert ("Error in WriteText");
		}
	}
else
	toptouse	= topin;

if (typeof idin == "string")
	{
	var tag			= htmltag == _ ? "div" : htmltag;
	var divtext		= "<" + tag
					+ " id ='" + idin + "'";

	if (nametouse) divtext	+= " name='" + nametouse + "'";

	divtext			+=  " style='"
						+ "position: absolute;"
						+ "left:" + PxW (lefttouse) + ";"
						+ "top:"  + PxH (toptouse) + ";'>"
						+ "</" + tag + ">";
//Debug ("WT", divtext);
	document.write (divtext);

	var obj				= GetObject (idin);
	var objevent		= GetObjectEvent (idin);

	obj.style.fontSize	= PxH (FontSize3);
	}
else
	{
	var obj				= idin;
	var objevent		= GetObjectEvent (obj.id);
	}
var objstyle		= obj.style;

if (al > fixedargs)
	{
	var	argnum		= fixedargs;

	while (argnum < al)
		{
		var inc	= 2;
		var val	= arguments[argnum + 1];

		if (typeof val == "string")
			if (val.search (/px/) != -1) val = parseFloat (val.substr (0, val.length - 2));

		switch (arguments[argnum])
			{
			case "APPEND":
				append					= true;
				inc						= 1;
				break;

			case "ALIGN":
				objstyle.textAlign		= val;
				break;

			case "BACKGROUND":
				if (typeof val == "string")
					{
//					Debug ("WT", val);
					objstyle.backgroundColor	= val;
					}
				else
					objstyle.backgroundColor	= ColorsToUse[Light][val < 0 ? ColorNo (Light) : val];
				break;

			case "BOLD":
				objstyle.fontWeight		= "bold";
				inc						= 1;
				break;

			case "BORDER":
				objstyle.border			= val.toString () + "px";
				objstyle.borderStyle	= "solid";
				break;

			case "BORDER_COLOR":
				objstyle.borderColor	= val;
				break;

			case "BORDER_STYLE":
				objstyle.borderStyle	= val;
				break;

			case "BORDER_TOP":
				objstyle.borderTopStyle	= "solid";
				objstyle.borderTopWidth	= val;
				break;

			case "BOTTOM":
				objstyle.bottom			= PxH (val);
				break;

			case "CENTER":
				textintouse				= "<center>" + textintouse + "</center>";
				inc						= 1;
				break;

			case "CLASS":
				obj.className			= val;
				break;

			case "CLICK":
				objevent.onclick		= new Function (val);
				break;

			case "DBLCLICK":
				objevent.ondblclick		= new Function (val);
				break;
					
			case "DOWN":
				mousedown				= val;
				objevent.onmousedown	= new Function (mousedown);
				break;

			case "FAMILY":
				objstyle.fontFamily		= val;
				break;

			case "HEIGHT":
			objstyle.height			= PxH (val);				// Amended from PxW 4 Sep 03. Look out for trouble!!!
		//		heighttouse			= val;
				break;

			case "HIDDEN":
				objstyle.visibility		= "hidden";
				inc						= 1;
				break;

			case "HREF":
				obj.href				= val;
				break;

			case "INDENT":
				objstyle.textIndent		= PxW (val);
				break;

			case "ITALIC":
				objstyle.fontStyle		= "italic";
				inc						= 1;
				break;

			case "NAME":
				alert ("NAME used wrongly in WriteText");
//				obj.name				= val;
				break;

			case "NOW":
				shownow					= true;
				inc						= 1;
				break;

			case "OUT":
				mouseout				= val;
				objevent.onmouseout		= new Function (mouseout);
				break;

			case "OUT_COLOR":
				mouseout				= "GetObject(" + idin + ").style.backgroundColor='" + val + "';";
				objevent.onmouseout		= new Function (mouseout);
				break;

			case "OVER":
				mouseover				= val;
				objevent.onmouseover	= new Function (mouseover);
				break;

			case "OVER_COLOR":
				mouseover				= "GetObject(" + idin + ").style.backgroundColor='" + val + "';";
				objevent.onmouseover	= new Function (mouseover);
				break;

			case "PAD":
				objstyle.padding		= PxW (val);
				break;

			case "PAD_LEFT":
				objstyle.paddingLeft	= PxW (val);
				break;

			case "PAD_RIGHT":
				objstyle.paddingRight	= PxW (val);
				break;

			case "POSITION":
				objstyle.position		= val;
				break;

			case "RELATIVE":
				objstyle.position		= "relative";
				inc						= 1;
				break;

			case "RIGHT":
				objstyle.marginRight	= PxW (val);
				break;

			case "SIZE":
				objstyle.fontSize		= PxH (val);
				break;

			case "SKIP":												// Deprecated
			case "SKIP_AFTER":
				var br	= "";
				for (var b = 1; b <= val; b++) br	+= "<br>";
				textintouse				= br + textintouse;
				break;
																		// WriteText
			case "SRC":
				obj.src					= val;
				break;

			case "STATUS":
				statustext				= StatusLine (val);
				break;

			case "STYLE":
				objstyle.fontStyle		= val;
				break;n

			case "TEXT_COLOR":
				objstyle.color			= val;
				break;

			case "UL":
				objstyle.textDecorationUnderline	= "true";
				inc						= 1;
				break;

			case "VERTICAL":
				objstyle.verticalAlign	= val;
				break;

			case "VISIBILITY":
				objstyle.visibility		= val;
				break;

			case "WEIGHT":
				objstyle.fontWeight		= val;
				break;

			case "WIDTH":
				objstyle.width			= PxW (val);
				break;

			case "Z":
				objstyle.zIndex			= val;
				break;

			default:
				Debug ("Error", "Unrecognised key word in WriteText - " + arguments[argnum] + " for " + idin);
				return;
			}
		argnum		+= inc;
		}
	}
//Debug ("N", idin, mouseover, objevent.onmouseover);
	if (append)
		{
		iH[idin.id]		+= textintouse;
		}
	else
		{
		if (typeof idin == "string" || ! shownow)
			iH[idin]		= textintouse;
		else
			{
			obj.innerHTML	= textintouse;
			}
		}

	var fs = xPx (objstyle.fontSize);
	while (xPx (objstyle.fontSize) < MinFontSize)
		objstyle.fontSize	= PxH (++fs);

//	objstyle.height		= PxH (heighttouse);		// Late addition: look out for trouble (15/9/04)

	if (statustext != _)
		{
//		objevent.onmouseover	= new Function (mouseover + ";window.status='" + statustext +"'");
		objevent.onmouseout		= new Function (mouseout + ";window.status=''");
		}
	if (statustext != _)
		{
		if (mouseout != _)
			objevent.onmouseout		= new Function (mouseout + ";window.status=''");
		else
			mouseout	= "window.status=\"\"";
		objevent.onmouseout		= new Function (mouseout + ";window.status=''");

//		if (mouseover != _)
//			mouseover	=+ ";window.status=\"" + statustext + "\"";
//		else
//			mouseover	= "window.status=\"" + statustext + "\"";
//			objevent.onmouseover	= new Function (mouseover);
		}
//	return textintouse != _ ? Bottom (obj) : _;
	return textintouse != _ ? Math.ceil (textintouse.length / 100) : _;
	}	 																// WriteText


//-------------------------------------------------------------------------------
//						SOUNDEX ROUTINES
//-------------------------------------------------------------------------------

//-------------------------------------------------------------------------------
function Soundex (namein)
//-------------------------------------------------------------------------------
// Compute the SOUNDEX code for the surname
// BR version 1.2	18 Jul 03
	{

	// create object listing the SOUNDEX values for each letter
	// -1 indicates that the letter is not coded, but is used for coding
	//  0 indicates that the letter is omitted for modern census archives
	//                              but acts like -1 for older census archives
	//  1 is for BFPV
	//  2 is for CGJKQSXZ
	//  3 is for DT
	//  4 is for L
	//  5 is for MN my home state
	//  6 is for R

	// Get results with the function Soundex (name)

	//-------------------------------------------------------------------------------
	function makesoundex()
	//-------------------------------------------------------------------------------
		{
		this.a = -1;
		this.b =  1;
		this.c =  2;
		this.d =  3;
		this.e = -1;
		this.f =  1;
		this.g =  2;
		this.h =  0;
		this.i = -1;
		this.j =  2;
		this.k =  2;
		this.l =  4;
		this.m =  5;
		this.n =  5;
		this.o = -1;
		this.p =  1;
		this.q =  2;
		this.r =  6;
		this.s =  2;
		this.t =  3;
		this.u = -1;
		this.v =  1;
		this.w =  0;
		this.x =  2;
		this.y = -1;
		this.z =  2;
		}																//Soundex - makesoundex

	var sndx	= new makesoundex();


	//-------------------------------------------------------------------------------
	function isSurname(name)
	//-------------------------------------------------------------------------------
	// check to see that the input is valid
		{
		if (name == "" || name == null)
			{
			Debug ("Soundex coding", "Please enter surname for which to generate SOUNDEX code.", name);
			return false;
			}
		else
			{
			for (var i = 0; i < name.length; i++)
				{
				var letter= name.charAt(i);
				if (!(letter >= 'a' && letter <= 'z' || letter >= 'A' && letter <='Z'))
					{
					Debug("Soundex coding", "Please enter only letters in the surname.", name);
					return false;
					}
				}
			}
		return true
		}																	//Soundex - isSurname

	//-------------------------------------------------------------------------------
	function collapse (surname)
	//-------------------------------------------------------------------------------
	// Collapse out directly adjacent sounds
	// 1. Assume that surname.length>=1
	// 2. Assume that surname contains only lowercase letters
		{
		if (surname.length == 1)
			return surname;

		var right	= collapse (surname.substring (1, surname.length));

		if (sndx[surname.charAt(0)] == sndx[right.charAt(0)])
			return surname.charAt(0) + right.substring (1, right.length);

		return surname.charAt(0) + right;
		}																// Soundex - surname

	//-------------------------------------------------------------------------------
	function omit (surname)
	//-------------------------------------------------------------------------------
	// Collapse out directly adjacent sounds using the new National Archives method
	// 1. Assume that surname.length>=1
	// 2. Assume that surname contains only lowercase letters
	// 3. H and W are completely ignored
		{
		if (surname.length == 1)
			return surname;

		var right	= omit (surname.substring (1, surname.length));

		if (!sndx[right.charAt(0)])
			return surname.charAt(0) + right.substring (1, right.length);

		return surname.charAt(0) + right;
		}																// Soundex - omit

	//-------------------------------------------------------------------------------
	function output_sequence (seq)
	//-------------------------------------------------------------------------------
	// Output the coded sequence
		{
		var output	= seq.charAt(0).toUpperCase();		// Retain first letter
		var stage2	= seq.substring(1, seq.length);
		var count	= 0;

//		output		+= "-";								// Separate letter with a dash

		for (var i = 0; i < stage2.length && count < 3; i++)
			{
			if (sndx[stage2.charAt(i)] > 0)
				{
				output	+= sndx[stage2.charAt(i)];
				count++;
				}
			}

		for (; count < 3; count++)
			output	+= "0";

		return output;
		}																

	//	if (!isSurname(namein))
	//		{
	//		return;
	//		}

		var stage1			= collapse (namein.toLowerCase())

	//  form.result.value	= output_sequence(stage1);
	//  var stage1			= omit(form.surname.value.toLowerCase())

		var stage2			= collapse (stage1);						// stage2 always seems the same as stage1 so I have skipped this.

	//  form.result_na.value= output_sequence (stage2);

	//	return output_sequence (stage2);
		return output_sequence (stage1);

	//function Soundex2 (namein)
	//	{
	//	return output_sequence (collapse (namein.toLowerCase ()));
	//	}

	}																	// Soundex - output_sequence
