$(document).ready(function(){


	// display the correct form to which method the customer made their booking.
	$('#bookingmethod').change(function(){
	
		$('.option').hide();
	
		if ($(this).val() == 'Internet'){
			
			$('#method_internet').show();
			
		} else if ($(this).val() == 'Telephone') {
			
			$('#method_tphone').show();
		
		} else if ($(this).val() == 'iPhone/iPad') {
			
			$('#method_iphone').show();
		
		} else if ($(this).val() == 'Email') {
			
			$('#method_email').show();
		
		}
	
	});
	
	
	$('#sendfeedback').click(function(){
		
		
		$('input').removeClass('required');
		count = 0;
		
		if ($('#fname').val() == ''){
			$('#fname').addClass('required');	
			count = count + 1;
		}
		
		if ($('#femail').val() == ''){
			$('#femail').addClass('required');	
			count = count + 1;
		}		
		
		if ($('#pickup').val() == ''){
			$('#pickup').addClass('required');	
			count = count + 1;
		}
		
		
		if (count > 0){
			alert('Fields marked with a red asterix are required.');
			$(window).scrollTop(0);
		}
		
		if (count == 0){

			$(this).closest("form").submit();
						
		}
		
		
		
	});
	
	$('input[type="radio"]').live('click', function(){
	
		if ($(this).val() == 'other'){
			
			if ($(this).is(':checked')){
			
				$('#reason_other').removeAttr('disabled');
			
			} else {
			
				$('#reason_other').attr('disabled', 'disabled');
			
			}
			
		} else {
			
			$('#reason_other').attr('disabled', 'disabled');
			
		}
	
	});
	

});
