<script type="text/javascript">
//<![CDATA[
	/* Make sure all credit card details have been provided and are valid */
	function check_eway_payment_form() {
		var eway_name = g("eway_name");
		var eway_ccno = g("eway_ccno");
		var eway_ccexpm = g("eway_ccexpm");
		var eway_ccexpy = g("eway_ccexpy");
		var eway_cvn = g("eway_cvn");

		if(eway_name.value == "") {
			alert("%%LNG_EWayEnterName%%");
			eway_name.focus();
			return false;
		}

		if(isNaN(eway_ccno.value) || eway_ccno.value == "") {
			alert("%%LNG_EWayEnterCardNumber%%");
			eway_ccno.focus();
			eway_ccno.select();
			return false;
		}

		if(eway_ccexpm.selectedIndex == 0) {
			alert("%%LNG_EWayEnterCreditCardMonth%%");
			eway_ccexpm.focus();
			return false;
		}

		if(eway_ccexpy.selectedIndex == 0) {
			alert("%%LNG_EWayEnterCreditCardYear%%");
			eway_ccexpy.focus();
			return false;
		}

		if(requiresCVN() && ($('#eway_cvn').val() == '' || isNaN($('#eway_cvn').val()) || $('#eway_cvn').val().length > 4)) {
			alert("%%LNG_EWayEnterCardCode%%");
			eway_cvn.focus();
			return false;
		}

		return true;
	}

	function requiresCVN() {
		if($('#CardCodeInput').css('display') != 'none') {
			return true;
		}
		else {
			return false;
		}
	}

	$(document).ready(function() {
		$('#CVV2Help').click(function() {
			alert('%%LNG_CreditCardCVV2Help%%');
			return false;
		});
	});

//]]>
</script>