jQuery(document).ready(function($){

	"use strict";

	/**
	* ----------------------------------------------------------------------------------------
	*    Globals
	* ----------------------------------------------------------------------------------------
	*/

	$('.notice-subsolar-welcome-mailchimp-form').on('submit', function(e){

		e.preventDefault();

		var $form = $(this);

		$form.find('#signup-button').attr("disabled", "disabled");

		var email = $form.find('#email').val();

		$.ajax({
  			dataType: 'jsonp',
			url: 'http://subsolardesigns.com/subscribe',
			jsonpCallback: 'callback',
    		type: 'GET',
			data: {
				email: email
			},
			success: function(response) {
				if ( response['error'] ) {
					$('.subsolar-welcome-mailchimp-message').removeClass('ssd-alert ssd-alert-success');
					$('.subsolar-welcome-mailchimp-message').addClass('ssd-alert ssd-alert-error');
					$('.subsolar-welcome-mailchimp-message').html(response['html']);
				} else {
					$('.subsolar-welcome-mailchimp-message').removeClass('ssd-alert ssd-alert-error');
					$('.subsolar-welcome-mailchimp-message').addClass('ssd-alert ssd-alert-success');
					$('.subsolar-welcome-mailchimp-message').html(response['html']);
					$('.notice-subsolar-welcome-mailchimp-form input').fadeOut();

					$.ajax({
			        	type: "post",
			        	url: couponhut.ajaxurl,
			        	data: "action=_action_ssd_subsolar_welcome_subscribed&nonce="+couponhut.nonce,
			        });


				}
				$form.find('#signup-button').removeAttr("disabled");
			}
		});

		// return false;
	})
})