<!--

function validate_customer_input()
{
	var mTitle     = document.getElementById('title');
	var mForename  = document.getElementById('forename');
	var mSurname   = document.getElementById('surname');
	var mAddress   = document.getElementById('address_1');
	var mTown      = document.getElementById('town');
	var mCounty    = document.getElementById('county');
	var mPostcode  = document.getElementById('postcode');
	var mTelephone = document.getElementById('telephone');
	var mEmail     = document.getElementById('email');

	var mMessage = '';

	if (mTitle.value == '')
		mMessage += 'Please enter your title\n';

	if (mForename.value == '')
		mMessage += 'Please enter your Forename\n';

	if (mSurname.value == '')
		mMessage += 'Please enter your Surname\n';

	if (mAddress.value == '')
		mMessage += 'Please enter your the first line of your address\n';

	if (mTown.value == '')
		mMessage += 'Please enter your town\n';

	if (mCounty.value == '')
		mMessage += 'Please enter your County\n';

	if (mPostcode.value == '' || !isValidUKPostcodePatternMatch(mPostcode.value, 'partial'))
		mMessage += 'Please enter a valid UK Postcode\n';

	if (mTelephone.value == '' || !isValidPhoneNumber(mTelephone.value))
		mMessage += 'Please enter a valid Telephone number\n';

	if (mEmail.value == '' || !isValidEmailAddress(mEmail.value))
		mMessage += 'Please enter a valid email address for your confirmation\n';

	if (!validate_request_flags())
		mMessage += 'Please enter your all essential details for your car or flight\n';

	if (mMessage != '')
	{
		mMessage = 'Before continuing with your booking the following need to be dealt with:\n' + mMessage;
		alert(mMessage);

		return false;
	}

	return true;
}

function validate_request_flags()
{
	var mRegistration   = document.getElementById('request_flags[registration]');
	var mCarColour      = document.getElementById('request_flags[car-colour]');
	var mCarMake        = document.getElementById('request_flags[car-make]');
	var mCarModel       = document.getElementById('request_flags[car-model]');
	var mReturnFlight   = document.getElementById('request_flags[return-flight]');
	var mOutFlight      = document.getElementById('request_flags[out-flight]');
	var mReturnTerminal = document.getElementById('request_flags[return-terminal]');
	var mOutTerminal    = document.getElementById('request_flags[out-terminal]');
	var mDestination    = document.getElementById('request_flags[destination]');

	if (mRegistration)
	{
		if (mRegistration.value == '')
			return false;
	}

	if (mCarColour)
	{
		if (mCarColour.value == '')
			return false;
	}

	if (mCarMake)
	{
		if (mCarMake.value == '')
			return false;
	}

	if (mCarModel)
	{
		if (mCarModel.value == '')
			return false;
	}

	if (mReturnFlight)
	{
		if (mReturnFlight.value == '')
			return false;
	}

	if (mOutFlight)
	{
		if (mOutFlight.value == '')
			return false;
	}

	if (mReturnTerminal)
	{
		if (mReturnTerminal.value == '')
			return false;
	}

	if (mOutTerminal)
	{
		if (mOutTerminal.value == '')
			return false;
	}

	if (mDestination)
	{
		if (mDestination.value == '')
			return false;
	}

	return true;
}

function validate_payment()
{
	var mCard        = document.getElementById('card_type');
	var mCardNumber  = document.getElementById('card_number');
	var mCardHolder  = document.getElementById('cardholder');
	var mExpiryMonth = document.getElementById('expiry_month');
	var mExpiryYear  = document.getElementById('expiry_year');
	var mIssueNumber = document.getElementById('issue_number');
	var mTerms       = document.getElementById('agree_to_terms');

	var mMessage = '';

	if (mCard.value == '')
		mMessage += 'Please enter your payment card\n';

	if (mCardNumber.value == '')
		mMessage += 'Please enter your card number\n';

	if (mCardHolder.value == '')
		mMessage += 'Please enter the name on the card\n';

	if (mExpiryMonth.value == '' || mExpiryYear.value == '')
		mMessage += 'Please enter the cards expiry date\n';

	if (!mTerms.checked)
		mMessage += 'Please agree to the terms and conditions\n';

	if (mMessage != '')
	{
		mMessage = 'Before Your Booking can be completed please deal with the following:\n' + mMessage;
		alert(mMessage);
		return false;
	}

	return true;
}

function update_price(pSelect, pOriginalPrice, pMinSurcharge)
{
	var mPrice     = document.getElementById('total_price');
	var mCardPrice = document.getElementById('total_price_card');

	if (mPrice && pSelect && mCardPrice)
	{
		var mPriceVal = Number(mPrice.innerHTML);
		var mCard     = pSelect.value;

		var mArrCard = new Array();

		mArrCard = mCard.split('@');

		if (mArrCard.length == 2)
		{
			var mSurcharge = mArrCard[1];
			var mSurchargeAmount = 0;

			if (mSurcharge > 0)
			{
				mSurchargeAmount = pOriginalPrice / 100 * mSurcharge;

				if (mSurchargeAmount < pMinSurcharge)
					mSurchargeAmount = pMinSurcharge;

				mPriceVal = pOriginalPrice + mSurchargeAmount;
			}
			else
			{
				mPriceVal = pOriginalPrice;
			}

			mPriceVal = mPriceVal.toFixed(2);
		}

		var mIssueNum      = document.getElementById('issue_number');
		var mIssueNumLabel = document.getElementById('issue_number_label');

		var mValidFromMonth  = document.getElementById('valid_from_month');
		var mValidFromYear   = document.getElementById('valid_from_year');
		var mValidFromLabel  = document.getElementById('valid_from_month_label');

		if (mIssueNum && mIssueNumLabel)
		{
			if (mArrCard[0] == 'MSTRO')
			{
				mIssueNumLabel.style.display = 'block';
				mIssueNum.style.display = 'inline';
			}
			else
			{
				mIssueNumLabel.style.display = 'none';
				mIssueNum.style.display = 'none';
			}
		}

		if (mValidFromMonth && mValidFromYear && mValidFromLabel)
		{
			if (mArrCard[0] == 'MSTRO')
			{
				mValidFromMonth.style.display = 'inline';
				mValidFromYear.style.display  = 'inline';
				mValidFromLabel.style.display = 'block';
			}
			else
			{
				mValidFromMonth.style.display = 'none';
				mValidFromYear.style.display  = 'none';
				mValidFromLabel.style.display = 'none';
			}
		}

		mPrice.innerHTML = mPriceVal;
		mCardPrice.innerHTML = mPriceVal;

		var mCancellation = document.getElementById('cancellation');

		if (mCancellation)
			add_cancellation_waiver(mCancellation, mPriceVal);

		// Pad with 0 if not got at end
		var mPriceToFormat = mPrice.innerHTML;

		if (mPriceToFormat.indexOf('.') > -1)
		{
			var mArrPrice = mPriceToFormat.split('.');

			if (mArrPrice[1].length == 1)
			{
				mPrice.innerHTML = mPrice.innerHTML + '0';
				mCardPrice.innerHTML = mCardPrice.innerHTML + '0';
			}
		}
	}
}

function add_cancellation_waiver(pCancellation, pOriginalPrice)
{
	var mPrice     = document.getElementById('total_price');
	var mCardPrice = document.getElementById('total_price_card');

	if (mPrice && pCancellation && mCardPrice)
	{
		var mPriceVal = Number(mPrice.innerHTML);
		var mCancellationFee = Number(pCancellation.value);

		if (pCancellation.checked)
		{
			mPriceVal = mPriceVal + mCancellationFee;
		}
		else
		{
			mPriceVal = mPriceVal - mCancellationFee;
		}

		if (mPriceVal < pOriginalPrice)
			mPriceVal = pOriginalPrice;

		mPriceVal = Math.round(mPriceVal * 100) / 100;
		var mPriceValTxt = mPriceVal.toString();

		if (mPriceValTxt.indexOf(".") > -1)
		{
			var mArrPrice = mPriceValTxt.split('.');

			if (mArrPrice[1].length == 1)
			{
				mPriceValTxt = mPriceValTxt + '0';
			}

			mPriceVal = mPriceValTxt;
		}
		else
		{
			mPriceVal = mPriceValTxt + ".00";
		}

		mPrice.innerHTML = mPriceVal;
		mCardPrice.innerHTML = mPriceVal;
	}
}

function open_more_info(pHost, pCode, pComponent)
{
	window.open('http://' + pHost + '/index.phtml?command=information&type=' + pComponent + '&id=' + pCode,'MoreInfo','width=650,height=550,resizable=yes,scrollbars=yes');
}

//-->
