function show_purchase_form() {
  $('#purchase-button').toggle();
  $('#purchase-form').toggle();
  $('#submit').click(function() {
                       $('#submit').toggle();
                       $('#submitting-text').toggle();
                       return true;
                     });
}

// ================ Initialization ================

$(document).ready(function() {
                    var button = $('#purchase-button');
                    if ($('#offset-table').length > 0 && $('#thankyou').length == 0)
                      button.show();
                    else
                      button.hide();
                    $('#purchase-form').hide();
                    $('#show-purchase-form').click(function() { show_purchase_form(); });
                    $('#submitting-text').hide();
                    if ($('#purchase-errors').length > 0)
                      show_purchase_form();
                  });
