/*
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
*/
//alert('in the script');
// Attach handler to window load event
Event.observe(window, 'load', init, false);

function init() {
  // Attach handler to form's submit event
  Event.observe('form1', 'submit', storeAddress2);
}

function storeAddress2(e) {
  // Update user interface
 // alert('in the function');
  $('response').innerHTML = '<font color=\"#FFFFFF\">Adding Sign Up...</font>';
  // Prepare query string and send AJAX request
  var pars = 'name=' + escape($F('name')) + '&email=' + escape($F('email')) + '&phone=' + escape($F('phone')) + '&address=' + escape($F('address')) + '&city=' + escape($F('city')) + '&state=' + escape($F('state')) + '&zip=' + escape($F('zip'));

  var myAjax = new Ajax.Updater('response', 'storeAddress3.php', {method: 'get', parameters: pars});
  
  // Stop form from submitting when JavaScript is enabled
  Event.stop(e);
}