// Form validation
jQuery(document).ready(function($j){
	$j("#contactForm").submit(function(e) {
		$j("#contactForm .req").each(function() {
			if( $j(this).val() == '' )
			{
				e.preventDefault();
				alert('Please complete all required fields.');
				return false;
			}
		});
	});
	$j("#paymentForm.payment").submit(function(e) {
		$j("#paymentForm.payment .req").each(function() {
			if( $j(this).val() == '' )
			{
				e.preventDefault();
				alert('Please complete all required fields.');
				return false;
			}
			if(! $j('#termsCheck').is(':checked')) {
			  // terms not checked
			  e.preventDefault();
				alert('Please complete all required fields: Terms & Conditions');
				return false;
			}
		});
		var amountCheck = /^((\d*)|(\d*\.\d{2}))$/;
		var amount = $j('.amount').val();
		console.log(amount);
		if(! amount.match(amountCheck) ) {
		  e.preventDefault();
			alert('Please input a dollar amount ie. 100.00 or 10');
			return false;
		}
	});	
  /*$j('#checking').click(function() 
  {
      $j('#pay_with_checking').toggle('height');
      $j('#pay_with_card').css('display', 'none').find('input').val('');
  });
  $j('#card').click(function() 
  {
      $j('#pay_with_card').toggle('height');
      $j('#pay_with_checking').css('display', 'none').find('input').val('');
  });*/
	$j('#termsAccept').colorbox({ inline:true, href:"#termsConditions"});
	$j('#billPayerIdHelp').colorbox({ inline:true, href:"#billPayerIdContent"});
	$('#checkHelp').colorbox({ inline:true, href:"#checkHelpContent"});
});
