I am using jQuery simple modal to bring up an email subscription dialog when someone first visits a site. The modal window pops up just fine and I have it so that when someone clicks "no thanks" the window closes.

What I am having trouble with is

  1. When someone clicks outside of the modal window it does not close.
  2. Once the form is submitted I would like to have the window close as well.

Here is my code

jQuery(function($) {
      if ($.cookie("newsletter") != 1) {
          onClose: function() { 
            $.cookie("newsletter", "1", { expires: 7 });
		  $('form').submit(function(e) {
			$.cookie('newsletter', '1', { path: '/', expires: 999999 });
Any help is appreciated!