$(function() {
	$("#feedback-tab").click(function() {
		$("#feedback-form").toggle("slide");
	});

	$('#feedBackSubmit').click(function(e){
		if (document.getElementById('emailInput').value != "" && document.getElementById('feedBackInput').value != "") {
			var link = "mailto:info@globatime.com"
				+ "&subject=" + escape("Feedback from " + document.getElementById('emailInput').value)
				+ "&body=" + escape(document.getElementById('feedBackInput').value)
				;

			window.location.href = link;
		}

	});

	$("#feedback-form form").on('submit', function(event) {
		var $form = $(this);
		$.ajax({
			type: $form.attr('method'),
			url: $form.attr('action'),
			data: $form.serialize(),
			success: function() {
				$("#feedback-form").toggle("slide").find("textarea").val('');
			}
		});
		event.preventDefault();
	});
});

