//<script language="javascript">
	function ValidateCCNumberBox(sTitle, oInput)
	{
		// Purpose:	Simple validation of Credit card number
		// Version:	1.4.148
		// Comments: Supports VISA and MasterCard.
		//				If value is empty, will return true
		var sCCNumber;
		
		// Credit cards: Name, digits, prefix
		// AmEx, 15, 34/37
		// DC-CB, 14, 300-305
		// DC-Int, 14, 36
		// DC-UC, 16, 55
		// Disc, 16, 6011/65
		// JCB, 16, 35
		// JCB, 15, 1800/2131
		// Maes, 16, 5020/5038/6759
		// MC, 16, 51-55
		// Solo, 16/18/19, 6334/6767
		// Swch, 16/18/19, 4903/4905/4911/4936/564182/633110/6333/6759
		// Visa, 13/16, 4
		// Visa, 16, 	417500/4917/4913
		
		if (oInput)
		{
			if (!oInput.value)
			{
				alert(sTitle + ' cannot be empty');
				oInput.focus();
				oInput.select();
				return false;
			}
			sCCNumber = oInput.value;
			return ValidateCCNumber(sTitle, sCCNumber, oInput);
		}
	}
	
	function ValidateCCNumber(sTitle, sString, oInput)
	{		
		var lCCNumberLength = 0;
		var lSum = 0;
		var regEx;
		var bOddEven;
		var i;
		var lDigit;
		if (sString.length == 0)
		{
			alert(sTitle + ' has no value. Please enter the number and try again');
			oInput.focus();
			oInput.select();
			return false;
		}
		// Remove all non-numeric chars
		regEx = new RegExp(/\D*/g);
		sString = sString.replace(regEx, "");
		lCCNumberLength = sString.length;
			
		// check for length
		if (lCCNumberLength < 13)
		{
			alert(sTitle + ' does not have enough digits. Please check the number and try again');
			oInput.focus();
			oInput.select();
			return false;				
		}
		if (lCCNumberLength > 19)
		{
			alert(sTitle + ' has too many digits. Please check the number and try again');
			oInput.focus();
			oInput.select();
			return false;				
		}

		// Check Mod10
		var bOddEven = lCCNumberLength & 1;

		for (var i = 0; i < lCCNumberLength; i++) 
		{
			var lDigit = parseInt(sString.charAt(i));
			if (!((i & 1) ^ bOddEven)) 
			{
				lDigit *= 2;
				if (lDigit > 9)
				lDigit -= 9;
			}
			lSum += lDigit;
		}
		if (lSum % 10 == 0)
		{
			return true;
		}
		else
		{
			alert('Card number is not valid. Please check the number and try again');
			oInput.focus();
			oInput.select();
			return false;
		}
	}

	function ValidateSelect(sTitle, oSelect)
	{
		return ValidateSelectBox(sTitle, oSelect);
	}

	function ValidateSelectBox(sTitle, oSelect)
	{
		// Purpose:	Check a select to make sure that an item is selected.
		// Version:	1.0.107
		// Comments:	Checks the value to see if it has been set
								
		if (oSelect)
		{	
			if (oSelect.value == '')
			{
				alert('Please select a ' + sTitle + '.');
				oSelect.focus();
				return false;
			}
		}
		return true;				
	}

	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 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;
		}
	}

	// Validate box has given minimum and maximum length constraints
	function kxValidateBoxLength(sName, oTextBox, iMinLen, iMaxLen)
	{
		try 
		{
			var bError = false;
			var sTxt;
			if (sName) sTxt = oTextBox.value;
			else sTxt = "";
			if (iMinLen != null) if (sTxt.length < iMinLen) bError = true;
			if (iMaxLen != null) if (sTxt.length > iMaxLen) bError = true;
			if (bError)
			{
				var sAlert;
				if (iMinLen != null && iMinLen == iMaxLen)
				{
					sAlert = sName + " must be " + iMinLen + " characters long";
				}
				else
				{
					sAlert = sName + " must have a";
					if (iMinLen != null) 
					{
						sAlert = sAlert + " minimum length of " + iMinLen;
						if (iMaxLen != null) sAlert = sAlert + " and a";
					}
					if (iMaxLen != null)
					{
						sAlert = sAlert + " maximum length of " + iMaxLen;
					}
				}
				alert(sAlert);
				oTextBox.select();
				return false;
			}
		}
		catch(e) { }
		return true;
	}

	// Validate format is {12345678-1234-1234-1234-1234567890ab} where characters may be 1-9, a-f, A-F
	function kxValidateGUID(sGuid)
	{
		try
		{
			if (sGuid.length != 38) return false;
			if (sGuid.charAt(0) != '{' && sGuid.charAt(37) != '}') return false;
			if (sGuid.charAt(9) != '-' && sGuid.charAt(14) != '-' && sGuid.charAt(19) != '-' && sGuid.charAt(24) != '-') return false;
			sGuid = sGuid.replace(/[a-fA-F0-9]/g, '');
			if (sGuid == "{----}") return true;
			return false;
		}
		catch(e) { return false; }
	}
	
	// Validate text is numeric
	function kxValidateNumeric(sName, oTextBox)
	{
		try
		{
			var val = oTextBox.value;
			if (((val / val) != 1) && (val != 0)) 
			{
				var sAlert = sName + " must be numeric";
				alert(sAlert);
				oTextBox.focus();
				oTextBox.select();
				return false;
			}
		}
		catch(e) {}
		return true;
	}
	
	// Ensures that a checkbox is checked
	function kxValidateCheckboxTicked(sName, oCheckbox)
	{
		try
		{
			if (oCheckbox.checked == false)
			{
				var sAlert = sName + " must be ticked";
				alert(sAlert);
				oCheckbox.focus();
				oCheckbox.select();
				return false;
			}
		}
		catch(e) {}
		return true;
	}

	function kxValidateRadioButtonSelected(sName, oElements)
	{
	   // Validates a collection of Radio buttons (oElements) to ensure that at
	   //  least one has been selected. If not, shows an alert and returns false
		try
		{
			for (i = 0; i < oElements.length; i++)
				if (oElements[i].checked == true) return true;
			// Nothing checked
			var sAlert = "Please choose one option for \"" + sName + "\"";
			alert(sAlert);
			oElements[0].focus();
			return false;			
		}
		catch(e) {}
		return true;
	}

	function kxValidateRadioboxSelected(sName, oRadiobox)
	{
    // This version has been superceded by kxValidateRadioButtonSelected. This
    //  version accepts one element in parameter oRadiobox. See also:
    //  kxValidateRadioButtonSelected
		try
		{
			// Find all elements for this group
			var eles = document.getElementsByName(oRadiobox.name);
			return kxValidateRadioButtonSelected(sName, eles);
		}
		catch(e) {}
		return true;
	}

//</script>
