hide overlay on click outside modal

Hide an overlay when the user clicks outside the modal.

$('.overlay').mousedown(function(e) {
	var clicked = $(e.target);  get the element clicked
	if (clicked.is('.modal') || clicked.parents().is('.modal')) {
		return;  click happened within the dialog, do nothing here
   } else {  click was outside the dialog, so close it
     $('.overlay').hide();
   }
});