$(document).ready(function() {

   $('#ft_location').formStyler('Postcode or Town');

   $('form#fast_track_form').submit(function() {
       $(this).attr('response_action','not_submit');

       // For all select elements with a class of b1ock
       $('select.b1ock', this).each(function() {
            if ($(this).val() != "") {
                // If "Contact" is selected
                if ($(this).val() == "banking_manager" || $(this).val() == "insurance_agent" || $(this).val() == "financial_planner" || $(this).val() == "not_sure") {
                    // Location and State must be set
                    if ($('#state_select').val() == "" || $('#ft_location').val() == "" || $('#ft_location').val() == "Postcode   or Town") {
                        $(this).parents('#fast_track_form').attr('response_action','location_message');
                    } else {
                        $(this).parents('#fast_track_form').attr('response_action','submit');
                    }
                } else {
                    // Option has been selected: submit form
                    $(this).parents('#fast_track_form').attr('response_action','submit');
                }
            }
        });

       switch ($(this).attr('response_action')) {
           case 'not_submit':
               alert('Please select an option');
               break;
           case 'location_message':
               alert('Both "State" and "Postcode or Town" fields must be entered');
               break;
           case 'submit':
               return true;
               break;
       }
       return false;
    });
});

