
	function checkCheckBox(f)
	{
		if (f.agree.checked == false)
		{
			alert('You must agree to the Booking Enquiry terms and conditions to continue.');
			return false;
		}

		// Parse error eg a null or invalid character.
		var holidayNum = isInteger(f.tot_price.value);
        var holidayPartNum = isInteger(f.paynow_price.value);

		if (holidayNum == false)
		{
			alert('The confirmed holiday price is non numeric and therefore submision cannot continue.');
			f.tot_price.value = "0"
			return false;
		}

        if (holidayPartNum == false)
		{
			alert('The holiday price payable now is non numeric and therefore submision cannot continue.');
			f.paynow_price.value = "0"
			return false;
		}
        
		//calc_cost();

 		if (f.tot_price.value <= 0)
		{
			alert('The confirmed holiday price is 0 and therefore submission cannot continue.');
			return false;
		}
        
		if (f.paynow_price.value <= 0)
		{
			alert('The amount payable now is 0 and therefore submission cannot continue.');
			return false;
		}

		if (f.sel_weeks.value == 0)
		{
			alert('You have choosen to stay for 0 weeks and therefore submission cannot continue.');
			return false;
		}
        
		if (f.sel_from_day.value == "-")
		{
			alert('You must select the day the holiday will commence to continue.');
			return false;
		}
        
        if (f.sel_from_month.value == "-")
		{
			alert('You must select the month the holiday will commence to continue.');
			return false;
		}
        
		if (f.txt_email.value != f.txt_email_confirm.value)
		{
			alert('Your email and confirmed email addresses do not match and therefore submission cannot continue.');
			return false;
		}

		return true;
	}



	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	// Do the cost calculation
	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	function calc_cost()
	{
		var total_cost = 0.0;

		var theForm = document.frmpurchase;


		// Parse error eg a null or invalid character.
		var rentNum = isInteger(theForm.txt_tot_rent.value);

		if (rentNum == false)
		{
			alert('The total rent is non numeric and the amount payable cannot be calculated.');
			theForm.txt_tot_rent.value = "0"
			return;
		}

		// Cot or folding bed additional charge
		if (theForm.chk_cot.checked==true)
		{
			total_cost += (20.0 * parseFloat(theForm.txt_tot_weeks.value));
		}

		// if < 2 months then total payment else
		if (theForm.chk_two_months.checked==true)
		{
			total_cost += parseFloat(theForm.txt_tot_rent.value);
		}
		else // 1/3 cost as > 2 months
		{
			//total_cost += (parseFloat(theForm.txt_tot_rent.value) ));

			total_cost += (parseFloat(theForm.txt_tot_rent.value) / 3.0);

		}

		// Credit card so 1.5% charge
		if (theForm.chk_credit_card.checked==true)
		{
			total_cost *= 1.015;
		}

		theForm.txt_total_amount.value = Math.round(total_cost);

		//alert("done calc");
	}

	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	// Is it a number?
	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	function isInteger(s)
	{
		var i;
		for (i = 0; i < s.length; i++)
		{
			// Check that current character is number.
			var c = s.charAt(i);
			if ( ((c < "0") || (c > "9")) && (c != ".") )
			{
				return false;
			}
		}
		// All characters are numbers.
		return true;
	}

	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	// Mirror the number of weeks in the calculator from the top selection box
	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	function mirror_weeks()
	{
		var selbox = document.frmpurchase.sel_weeks;

		document.frmpurchase.txt_tot_weeks.value = selbox.options[selbox.selectedIndex].value;

		calc_cost();
	}

