function display_correct_form(question_type) {
    // Display the correct form based on what has been selected in the dropdown
    if ((question_type == 'billing') || (question_type == 'technical')) {
        $('#contact_login-form').show();
        $('#contact_contact-form').hide();
        $('#messagetext').html("For " + question_type + " enquires please log into our customer support centre.");
    }
    else {
        $('#contact_login-form').hide();
        $('#contact_contact-form').show();
    }
}

$(document).ready(function() {
    jQuery.ajaxSetup({cache: false});
    $.getJSON('/contact/session/?key=question_choice', 
        function(data) {
            display_correct_form(data.question_choice);
            $('#id_question_type').val(data.question_choice);
        });
    $('#contact_contact-form').show();
    $('#contact_login-form').hide();
    $("#id_question_type").change(function () {
        jQuery.get('/contact/session/add/?question_choice=' + $(this).val());
        display_correct_form($(this).val());
    });
    $('#contact_question-choice-form').show();
    $('#contact_messagetext').hide();
    $('#billing_message').hide();
    
    $('#login_problem').click(function() {
        // Send login problem to 'other' enquiry
        display_correct_form('other');
        jQuery.get('/contact/session/add/?question_choice=other');
        return false;
    });
});
