//<script language="javascript">
	function txtBox_OnFocus()
	{
		// Purpose:	Selects the text inside of a textbox ready to be overtyped
		// Version:	1.0.107
		// Date:	16-Oct-2002
		// Author:	daniel
		// Comments:	
		//			Call this from the OnFocus event of Password Input controls
		//			to facilitate easier user input when using the keyboard.
		//			TODO: Make this a behaviour (for IE)	
		try
		{
			if (event.srcElement)
			{
				event.srcElement.select();
			}
		}
		catch(e)
		{
			//
		}
	}

	function ValidateNumberBox(sName, oTextBox)
	{
		if (isNaN(oTextBox.value) == true)
		{
			alert(sName + " must be a number. Please check and try again");
			oTextBox.select();
			return false;			
		}
		else
		{
			return true;
		}
	}

	function ValidateCCBox(sName, oTextBox)
	{
		var oRE = /[^\d ]/;
		var sValue;
		var sCCNumber;
		var lLength = 0;
		var i = 0;
		var j = 0;
		var lCheckSum = 0;
		var sProduct = 0;
		var bReturn = false;
				  
		sValue = oTextBox.value;
				  
		if (oRE.test(sValue))
		{
			alert(sName + " is not valid. Please check and try again.");
			oTextBox.select();
			return false;
		}
		else
		{
			sCCNumber = sValue.replace(/ /g,"");
			lLength = sCCNumber.length;
			
			if (lLength == 0)
			{
				// don't validate a blank CC Number
				return true;
			}
			
			if (lLength == 15 || lLength == 16)
			{
				for (i = lLength - 1; i >= 0; i--)
				{
					lCheckSum += parseInt(sCCNumber.charAt(i));
					i--;
					sProduct = String((sCCNumber.charAt(i) * 2));
					
					for (j = 0; j < sProduct.length; j++)
					{
						lCheckSum += parseInt(sProduct.charAt(j));
					}
				}
			}
			else
			{
				alert(sName + " is not valid. Please check and try again.");
				oTextBox.select();
				return false;
			}
		}
		  
		if (lCheckSum % 10 == 0)
		{
			return true;
		}
		else
		{
				alert(sName + " is not valid. Please check and try again.");
				oTextBox.select();
				return false;			
		}
	}

	function ValidatePasswordBoxes(sName, oTextBox1, oTextBox2)
	{
		// Purpose:	Validate Password boxes
		// Version:	1.0.107
		// Date:	08-Nov-2002
		// Author:	daniel
		// Comments:
		//			Checks the password and confirm password text boxes to ensure that they
		//			match and returns true if OK, displays an alert and return false if not.
		if (oTextBox1)
		{
			if (oTextBox2)
			{
				if (oTextBox1.value == oTextBox2.value)
				{
					// no worries
				}
				else
				{
					alert(sName + 's do not match.');
					oTextBox1.select();
					return false;
				}
			}
		}
		
		return true;
	}
		
	function ValidateNoSpacesInBox(sName, oTextBox)
	{
		// Purpose:	Checks for spaces in textbox
		// Version:	1.0.107
		// Date:	08-Nov-2002
		// Author:	daniel
		// Comments:

		try
		{

			if (oTextBox)
			{
				if (oTextBox.value.search(/\s/g) >= 0)
				{
					alert(sName + ' cannot contain any spaces.');
					oTextBox.select();
					return false;
				}
			}

			return true;
		}
		catch(e)
		{
			return true;
		}	
	}
		
	function ValidateEmailBox(sName, oTextBox)
	{
		// Purpose:	Validate An Email TextBox
		// Version:	1.0.107
		// Date:	07-Nov-2002
		// Author:	daniel
		// Comments:
		//			Ensure that the textbox is not empty and that 
		//			the email address uses correct syntax.
		var sTemp = '';
	
		try
		{
			if (oTextBox)
			{
				if (ValidateTextBox(sName, oTextBox))
				{
					if (ValidateNoSpacesInBox(sName, oTextBox))
					{
						// email address must have at least one at sign (@) and one fullstop(.)
						sTemp = oTextBox.value;
					
						if ((sTemp.search(/\@/g) < 0) || (sTemp.search(/\./g) < 0))
						{
							alert('Please enter a valid ' + sName);
							oTextBox.select();
							return false;
						}
					}
					else
					{
						return false;
					}
				}
				else
				{
					return false;
				}
			}
			else
			{
				//throw oTextBox.id + ' does not exist.'
			}

			return true;
		}
		catch(e)
		{
			return true;
		}
	}
	
	function ValidateTextBox(sName, oTextBox)
	{
		// Purpose:	Validate A TextBox
		// Version:	1.0.107
		// Date:	07-Nov-2002
		// Author:	daniel
		// Comments:
		//			Ensure that the textbox is not empty
		var sTemp = '';

		try
		{
		
			// No validation takes place if TextBox is not found
			if (oTextBox)
			{		
				sTemp = oTextBox.value.replace(/\s/g, '');
		
				if(sTemp.length == 0)
				{
					alert(sName + ' cannot be blank.');
					oTextBox.select();
					return false;
				}
			}
			else
			{
				//throw oTextBox.id + ' does not exist.'
			}

			return true;
		}
		catch(e)
		{
			return true;
		}
	}
	
//</script>