	//----------------------------------------------------------
	// Name		: ltrim
	// Purpose	: Removes leading spaces from start of string
	//----------------------------------------------------------
	//
	function ltrim(strText)
	{
		while (strText.charAt(0)==" ")
		{
			strText = strText.substring(1);
		}
		return strText;
	}

	//----------------------------------------------------------
	// Name		: rtrim
	// Purpose	: Remove trailing spaces from end of string
	//----------------------------------------------------------
	//
	function rtrim(strText)
	{
		while (strText.charAt( strText.length-1 )==" ")
		{
			strText = strText.substring(0, strText.length-1);
		}
		return strText;
	}

	//----------------------------------------------------------
	// Name		: trim
	// Purpose	: Removes any leading or trailing spaces from a string.
	//----------------------------------------------------------
	//
	function trim(strText)
	{
		strText = ltrim(strText);
		strText = rtrim(strText);
		return strText;
	}

	//----------------------------------------------------------
	// Name		: isEmailAddr
	// Purpose	: Checks for correct email syntax
	//----------------------------------------------------------
	//
	function isEmailAddr(email)
	{
		var result = false;
		var theStr = new String(email)
		var index = theStr.indexOf("@");
		if (index > 0)
		{
			var pindex = theStr.indexOf(".",index);
			if ((pindex > index+1) && (theStr.length > pindex+1))
				result = true;
		}
		return result;
	}

	//----------------------------------------------------------
	// Name		: validateNumberTextBox
	// Purpose	: Standard Form Numeric Textbox Validation
	//----------------------------------------------------------
	//
	function isNumeric(number)
	{
		var theStr = new String(number);

		var checkOK = "£,.0123456789 \t\r\n\f";
		var allValid = true;
		for (i = 0;  i < theStr.length;  i++)
		{
			ch = theStr.charAt(i);
			for (j = 0;  j < checkOK.length;  j++)
				if (ch == checkOK.charAt(j))
					break;
					if (j == checkOK.length)
					{
						allValid = false;
						break;
					}
		}	
		return allValid;
	}

	//----------------------------------------------------------
	// Name		: validateRadioButtons
	// Purpose	: Standard Radio Button Form Validation
	//----------------------------------------------------------
	//
	function validateRadioButtons(name)
	{
		var radioSelected = false;
		for (i = 0;  i < name.length;  i++)
		{
			if (name[i].checked)
			radioSelected = true;
		}

		return radioSelected;
	}
	
	//----------------------------------------------------------
	// Name		: validateCommercialLocator
	// Purpose	: Validation for Commercial Locator
	//----------------------------------------------------------
	//
	function validateCommercialLocator(theForm)
	{
		var checkStr = new String(trim(theForm.search.value));
		
		var checkOK = "£,.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒšœŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ0123456789- \t\r\n\f";
		var allValid = true;
		for (i = 0;  i < checkStr.length;  i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0;  j < checkOK.length;  j++)
				if (ch == checkOK.charAt(j))
					break;
					if (j == checkOK.length)
					{
						allValid = false;
						break;
					}
		}
	
		if (!allValid)
		{
			alert("Please enter only letters or numbers.");
			theForm.search.focus();
			return (false);
		}
		return true;
	}

	//----------------------------------------------------------
	// Name		: validateBreakeven
	// Purpose	: Validation for Business - Breakeven Calculator
	//----------------------------------------------------------
	//
	function validateBreakeven(theForm)
	{
		var strSales = new String(trim(theForm.txtSales.value));
		var strVariableCosts = new String(trim(theForm.txtVariableCosts.value));
		var strFixedCosts = new String(trim(theForm.txtFixedCosts.value));
		
		if ((strSales.length == "") || (!isNumeric(strSales)) || (parseFloat(strSales) <= 0))
		{
			alert("Please enter a numeric sales amount greater than £0.");
			theForm.txtSales.focus();
			return false;
		}
		
		if ((strVariableCosts.length == "") || (!isNumeric(strVariableCosts)) || (parseFloat(strVariableCosts) <= 0))

		{
			alert("Please enter a numeric variable costs amount greater than £0.");
			theForm.txtVariableCosts.focus();
			return false;
		}
		
		if ((strFixedCosts.length == "") || (!isNumeric(strFixedCosts)) || (parseFloat(strFixedCosts) <= 0))

		{
			alert("Please enter a numeric fixed costs amount greater than £0.");
			theForm.txtFixedCosts.focus();
			return false;
		}
		
		return true;	
	}

	//----------------------------------------------------------
	// Name		: validateDeposit
	// Purpose	: Validation for Business - Deposit Account Calculator
	//----------------------------------------------------------
	//
	function validateDeposit(theForm)
	{
		var strAccountType = new String(trim(theForm.txtAccountType.value));
		var strAmount = new String(trim(theForm.txtAmount.value));
		var strPeriod = new String(trim(theForm.txtPeriod.value));
		
		if (strAccountType.length == "")
		{
			alert("Please select an account type.");
			theForm.txtAccountType.focus();
			return false;
		}
		
		if ((strAmount.length == "") || (!isNumeric(strAmount)) || (parseFloat(strAmount) <= 0))
		{
			alert("Please enter a numeric deposit amount greater than £0.");
			theForm.txtAmount.focus();
			return false;
		}
		
		if (strPeriod.length == "")
		{
			alert("Please select a deposit period.");
			theForm.txtPeriod.focus();
			return false;
		}
		
		if ((strAccountType == "2") && (parseFloat(strAmount) < 10000))
		{
			alert("The minimum deposit amount for this account is £10,000. Please enter a numeric deposit amount equal to or greater than £10,000.");
			theForm.txtAmount.focus();
			return false;
		}
		
		if ((strAccountType == "1") && (parseFloat(strAmount) > 1000000))
		{
			alert("The maximum deposit amount for this account is £1,000,000. Please enter a numeric deposit amount less than or equal to £1,000,000.");
			theForm.txtAmount.focus();
			return false;
		}		
		
		return true;	
	}	
	
	//----------------------------------------------------------
	// Name		: validateCurrency
	// Purpose	: Validation for Personal - Currency Converter
	//----------------------------------------------------------
	//
	function validateCurrency(theForm)
	{
		var strRates = new String(trim(theForm.txtRates.value));
		var strValue = new String(trim(theForm.txtValue.value));
		
		if (strRates.length == "")
		{
			alert("Please select a foreign currency.");
			theForm.txtRates.focus();
			return false;
		}
		
		if ((strValue.length == "") || (!isNumeric(strValue)) || (parseFloat(strValue) <= 0))
		{
			alert("Please enter a numeric amount to convert, greater than £0.");
			theForm.txtValue.focus();
			return false;
		}
		
		return true;	
	}