if (typeof TN === "undefined") {
    TN = {};
}

TN.visibility = function() {
  $$('.toggleButton').each(function(title){
    Event.observe(title,'click',function(e) {
      e.stop();
      title.next('.toggleDescription').toggle();
    });
  });
};

Event.observe(window,'load',TN.visibility);

Event.observe(window,'load',function() {
  $('pdfForm').observe('submit',function(e){
    e.stop();
    $('pdf_form_note').update('Sending...');
    new Ajax.Request('/host/pricing/',{
      method: 'post',
      parameters: $('pdfForm').serialize(),
      onSuccess: function(transport) {
        var response = transport.responseJSON || "ERROR";
        if (response == 'ERROR') { alert('An Unknown Tranport Error Occurred. Please Contact Telenect Support.'); }
        else {
          var note = $('pdf_form_note');
          if (response.error_flag) {
            note.addClassName('errors');
            note.update(response.errors);          
          }
          else {
            note.addClassName('attention');
            note.update('Thanks. The file is now loading...');
            document.location = response.file_path;
          }          
        }
      }
    });
  });
});
