<!-- HIDE SCRIPT FROM BROWSERS WHICH DON'T SUPPORT IT

// # Code written by:-
// # Phil Parker
// # author: http://misterharold.net/contact.htm
// # Started Feb 06 2002
// # Last updated Feb 06 2002
//
// # Copyright (c) Philip J Parker (NE88) 2002
// # No part of this file or code may be used for any
// # purpose whatsoever, without the written permission
// # of the author.
// # Any use should retain this banner,
// # and copyright notice.
// # The author does not, under any circumstances,
// # relinquish his copyright, or intellectual property rights.
//

// ============================================================================
// ======================== GLOBAL SCOPE VARIABLES ============================
// ============================================================================

var bingoClientVersion = 1;
var formSubmitted = false;

var alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var numbers = "0123456789";
var specialChars = "- ()[]'/_!";

var maxTitleLen = 50;

var displayedOptionValue = "violet"; // default game border color
var currentOptionValue   = null;
var tickTimerId      = null;
var tickMilliSeconds = 100;


// ============================================================================
// ============================= FUNCTIONS ====================================
// ============================================================================

	function isAlphabeticChar (c)
	{
		// ASSUME string of length 1 passed in

		var idx;

		idx = alphabet.indexOf(c, 0);
		if((idx == null) || (idx < 0) || (idx > 51))
			return(false);

		return(true);

	}

	function isSpecialChar (c)
	{
		// ASSUME string of length 1 passed in

		var idx;

		idx = specialChars.indexOf(c, 0);
		if((idx == null) || (idx < 0) || (idx > (specialChars.length -1)))
			return(false);

		return(true);

	}

	function isValidChar (c)
	{
		if(isAlphabeticChar(c))
			return(true);
		else if(isSpecialChar(c))
			return(true);

		return(false);
	}


	function isNumericChar (c)
	{
		// ASSUME string of length 1 passed in

		var idx;

		idx = numbers.indexOf(c, 0);
		if((idx == null) || (idx < 0) || (idx > 9))
			return(false);

		return(true);

	}

	function validString(str, maxLen)
	{

		var len = str.length;
		var c, i;
		var len;

		// Following characters are OK, a..z, A..Z, 0..9, "-", " ", "(", ")", "[", "]" "'" "/"

		if((str == "") || (str == null))
			return(false);

		len = str.length;
		if((len < 1) || (len > maxLen))
			return(false);

		for(i=0; i<len; i++)
		{
			if(isValidChar(str.charAt(i)) != true)
			{
				if(isNumericChar(str.charAt(i)) != true)
				{
					return(false);
				}
			}
		}

		return(true);

	}

	function validateGameColor(currentOptionValue)
	{
		var colorValid = false;

		if(currentOptionValue == "violet")
		{
			colorValid = true;
		}
		else if(currentOptionValue == "yellow")
		{
			colorValid = true;
		}
		else if(currentOptionValue == "pink")
		{
			colorValid = true;
		}
		else if(currentOptionValue == "grey")
		{
			colorValid = true;
		}
		else if(currentOptionValue == "orange")
		{
			colorValid = true;
		}
		else if(currentOptionValue == "blue")
		{
			colorValid = true;
		}
		else if(currentOptionValue == "red")
		{
			colorValid = true;
		}
		else if(currentOptionValue == "white")
		{
			colorValid = true;
		}

		return(colorValid);

	}

	function submitUserForm(tform)
	{
		var currentOptionValue;

		// alert("Game Title = " + tform.game_title.value);
		if(validString(tform.game_title.value, maxTitleLen) != true)
		{
			alert("Your title contains disallowed characters,\nis absent, or is longer than " + maxTitleLen + " characters!");
			return;
		}

		currentOptionValue = tform.color_selection.options[document.bingoForm.color_selection.selectedIndex].value;

		// alert("Game Color = " + currentOptionValue);
		if(validateGameColor(currentOptionValue) != true)
		{
			alert("The Game Color is invalid.");
			return;
		}

		tform.client_version.value = bingoClientVersion;

		if(formSubmitted != true)
		{
			formSubmitted = true;

			// alert("validated OK");
			tform.submit();

		}
		else
		{
			alert("Form already submitted!");
		}

	}

// ========================================

function setTableBgColor()
{

	// alert("Setting Table Bg Color");
	// alert("document.all.bingoFormTable.className= " + document.all.bingoFormTable.className);

	if(currentOptionValue == "violet")
	{
		document.all.bingoFormTable.className="violetBgClass";
	}
	else if(currentOptionValue == "yellow")
	{
		document.all.bingoFormTable.className="yellowBgClass";
	}
	else if(currentOptionValue == "pink")
	{
		document.all.bingoFormTable.className="pinkBgClass";
	}
	else if(currentOptionValue == "grey")
	{
		document.all.bingoFormTable.className="greyBgClass";
	}
	else if(currentOptionValue == "orange")
	{
		document.all.bingoFormTable.className="orangeBgClass";
	}
	else if(currentOptionValue == "blue")
	{
		document.all.bingoFormTable.className="blueBgClass";
	}
	else if(currentOptionValue == "red")
	{
		document.all.bingoFormTable.className="redBgClass";
	}
	else if(currentOptionValue == "white")
	{
		document.all.bingoFormTable.className="whiteBgClass";
	}
	else
	{
		// alert("currentOptionValue unrecognised");
	}

}

function checkTableColor()
{
	currentOptionValue = document.bingoForm.color_selection.options[document.bingoForm.color_selection.selectedIndex].value;

	if(currentOptionValue != displayedOptionValue)
	{
		// alert("currentOptionValue = " + currentOptionValue + "\ndisplayedOptionValue = " + displayedOptionValue);

		setTableBgColor();
		displayedOptionValue = currentOptionValue;
	}
}

function iTickTimeout()
{

	checkTableColor();
	startTickTimer();

}

function startTickTimer()
{
	// Start a timer, used to update remaining time
	tickTimerId = setTimeout("iTickTimeout();", tickMilliSeconds);
}

function stopTickTimer()
{
	if(tickTimerId != null)
	{
		clearTimeout(tickTimerId);
		tickTimerId = null;
	}
}

function startFn()
{
	startTickTimer();
}

// # STOP HIDING SCRIPT FROM OTHER BROWSERS -->
