function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}
$(document).ready(function() {
  $('#slideshow')
  .after('<ul id="slideshow-nav">')
  .cycle({
    fx: 'fade',
    pager:  '#slideshow-nav',
    timeout: 0,
    pagerAnchorBuilder: function(idx, slide) {
      return '<li><a href="#">' + (idx + 1) + '</a></li>';
    }
  });
  function submitForm(formButton) {
    $.post("/wp-content/themes/purpose/email-form.php", $('#mailing-list-form').serialize(),
    function(data) {
      if(data.valid) {
        $('.error').remove();
        $('.notice').remove();
        $('#ml-form-go-button').after('<p class="notice">Thank you!</p>');
      }
      else {
        $('.error').remove();
        $('.notice').remove();
        $('#ml-form-go-button').after('<p class="error">Please enter a valid email address.</p>');
      }
    }, "json");
    return false;
  }
  $('#ml-form-go-button').click(function() {
    submitForm();
  });
  $('#mailing-list-form').submit(function() {
    submitForm();
    return false;
  });
});
