	/* ---------------------------------------------------- */
	/*	Countdown											*/
	/* ---------------------------------------------------- */
	
	$(document).ready( function(){

		// Create a countdown instance. Change the launchDay according to your needs.
		// The month ranges from 0 to 11. I specify the month from 1 to 12 and manually subtract the 1.
		// Thus the launchDay below denotes 8 October, 2016.
		var launchDay = new Date(2016, 10-1, 8);
		$('#timer').countdown({
			until: launchDay
		});
	});
	
	/* ---------------------------------------------------- */
	/*	Newsletter											*/
	/* ---------------------------------------------------- */
	
	// Invoke the Placeholder plugin
	$('input, textarea').placeholder();

	// Validate newsletter form
	$('<div class="loading"><span class="bounce1"></span><span class="bounce2"></span><span class="bounce3"></span></div>').hide().appendTo('.form-wrap');
	$('<div class="success"></div>').hide().appendTo('.form-wrap');
	$('#newsletter-form').validate({
		rules: {
			newsletter_email: { required: true, email: true }
		},
		messages: {
			newsletter_email: {
				required: 'Email address is required',
				email: 'Email address is not valid'
			}
		},
		errorElement: 'span',
		errorPlacement: function(error, element){
			error.appendTo(element.parent());
		},
		submitHandler: function(form){
			$(form).hide();
			$('#newsletter .loading').css({ opacity: 0 }).show().animate({ opacity: 1 });
			$.post($(form).attr('action'), $(form).serialize(), function(data){
				$('#newsletter .loading').animate({opacity: 0}, function(){
					$(this).hide();
					$('#newsletter .success').show().html('<p>Thank you for subscribing!</p>').animate({opacity: 1});
				});
			});
			return false;
		}
	});

