function isAlphaNumeric(aChar)
{
	aChar = aChar.toUpperCase();
	var strValidChars = "0123456789ABCDEFGHIJKLMNOPRSTUVWXYZ";
	if (aChar.length == 0) return false;
	if (strValidChars.indexOf(aChar) == -1)
	{
		return false;
	}
	else
	{
		return true;
	}
}

function updateNumberGrid(number)
{
	i = 0;
	while(i < 5)
	{
		if (isAlphaNumeric(number.charAt(i)) == true)
		{
			newChar = number.charAt(i);
		}
		else if(number.charAt(i) == ' ')
		{
			newChar = '_';
		}
		else
		{
			newChar = 'spacer';
		}
		if(newChar != 'spacer')
		{
			newChar = newChar.toUpperCase();
		}
		if(newChar == 'I' || newChar == '1' || newChar == '_')
		{
			newWidth = 11;
		}
		else if(newChar == '' || newChar == 'spacer')
		{
			newWidth = 1;
		}
		else
		{
			newWidth = 27;
		}
		switch (i)
		{
		case 0:
			document.images.char_1.src = 'http://www.carreg.co.uk/images/plates/' + newChar + '.gif';
			document.images.char_1.width = newWidth;
			break;
		case 1:
			document.images.char_2.src = 'http://www.carreg.co.uk/images/plates/' + newChar + '.gif';
			document.images.char_2.width = newWidth;
			break;
		case 2:
			document.images.char_3.src = 'http://www.carreg.co.uk/images/plates/' + newChar + '.gif';
			document.images.char_3.width = newWidth;
			break;
		case 3:
			document.images.char_4.src = 'http://www.carreg.co.uk/images/plates/' + newChar + '.gif';
			document.images.char_4.width = newWidth;
			break;
		}
		i++;
	}
}

function updateNumber(number)
{
	i = 0;
	while(i < 8)
	{
		if (isAlphaNumeric(number.charAt(i)) == true)
		{
			newChar = number.charAt(i);
		}
		else if(number.charAt(i) == ' ')
		{
			newChar = '_';
		}
		else
		{
			newChar = 'spacer';
		}
		if(newChar != 'spacer')
		{
			newChar = newChar.toUpperCase();
		}
		if(newChar == 'I' || newChar == '1' || newChar == '_')
		{
			newWidth = 11;
		}
		else if(newChar == '' || newChar == 'spacer')
		{
			newWidth = 1;
		}
		else
		{
			newWidth = 27;
		}
		switch (i)
		{
		case 0:
			document.getElementById("char_1").src = 'http://www.carreg.co.uk/images/plates/' + newChar + '.gif';
			document.getElementById("char_1").width = newWidth;
			break;
		case 1:
			document.getElementById("char_2").src = 'http://www.carreg.co.uk/images/plates/' + newChar + '.gif';
			document.getElementById("char_2").width = newWidth;
			break;
		case 2:
			document.getElementById("char_3").src = 'http://www.carreg.co.uk/images/plates/' + newChar + '.gif';
			document.getElementById("char_3").width = newWidth;
			break;
		case 3:
			document.getElementById("char_4").src = 'http://www.carreg.co.uk/images/plates/' + newChar + '.gif';
			document.getElementById("char_4").width = newWidth;
			break;
		case 4:
			document.getElementById("char_5").src = 'http://www.carreg.co.uk/images/plates/' + newChar + '.gif';
			document.getElementById("char_5").width = newWidth;
			break;
		case 5:
			document.getElementById("char_6").src = 'http://www.carreg.co.uk/images/plates/' + newChar + '.gif';
			document.getElementById("char_6").width = newWidth;
			break;
		case 6:
			document.getElementById("char_7").src = 'http://www.carreg.co.uk/images/plates/' + newChar + '.gif';
			document.getElementById("char_7").width = newWidth;
			break;
		case 7:
			document.getElementById("char_8").src = 'http://www.carreg.co.uk/images/plates/' + newChar + '.gif';
			document.getElementById("char_8").width = newWidth;
			break;
		}
		i++;
	}
}