$(document).ready(function(){
    
    // do not hide fields if form errors are present
    if ($('.form_error').size() == 0) {
        $('div.squeeze .form_table').find('.last_name, .primary_phone').hide();
        $('div.squeeze form[name=prospect_form] .submit').one('click', function() {
            var parentForm = $(this).parents('form');
            $('tr.email', parentForm).after('<tr class="message"><td colspan="2"><div>Please also provide us with your last name and phone number to receive the audio book.</div></td></tr>');
            $(parentForm).find('.last_name, .primary_phone').show();
            $('.last_name input', parentForm).focus();
            
            return false;
        });
    }
    
    // billing form
    if ($('.form_error').size() == 0) {
        $('div.form.billing').hide();
        $('.rush-shipping-buttons .yes a').one('click', function() {
            $('div.form.billing').slideDown('slow', function() { $('.card_number input').focus(); });
            return false;
        });
    }
    
    // re-type email ;)
    if ($('input[name=email_again]').size() == 1) {
        $('input[name=email_again]').val($('input[name=email]').val());
    }

    
    $.each(['ON', 'QC', 'NS', 'NB', 'MB', 'BC', 'PE', 'SK', 'AB', 'NL', 'AK', 'HI'], function(index, value) {
        $('select[name=state] option[value=' + value + ']').hide();
        $('select[name=billing_state] option[value=' + value + ']').hide();
    });
    $('select[name=country] option[value=CA]').hide();
    $('select[name=billing_country] option[value=CA]').hide();
});