/*
Part of the code for the article "Use Ajax and PHP to Build Your Mailing List"
by Aarron Walter (aarron@aarronwalter.com)
http://www.sitepoint.com/article/use-ajax-php-build-mailing-list
*/

// Attach handler to window load event

//alert('put Notify');
Event.observe(window, 'load', init, false);

function init() {
  // Attach handler to form's submit event
  Event.observe('Notifyform', 'submit', putNotify);
}

function putNotify(e) {
  // Update user interface
 //alert('in the function');
  $('response').innerHTML = 'Saving...';



  // Prepare query string and send AJAX request
 var pars = 'notify_email=' + escape($F('notify_email')) +'&notify_text=' + escape($F('notify_text'))    +'&ev_id=' + escape($F('ev_id'))  +'&notify_days=' + escape($F('notify_days')) +'&notify_type=' + escape($F('notify_type'));
 // alert('in the function');
 var myAjax = new Ajax.Updater('response', 'storeNotify.php', {method: 'get', parameters: pars});
  // Stop form from submitting when JavaScript is enabled
  Event.stop(e);
}
