$(function(){

	// faq and special offers boxes
	$(".promo-box").addClass('js-enabled').click(function(){
		window.location = $(this).find('a').attr("href");
	});

	// ajax submit of question form
	$("#ask-submit img").click(function(){

		// validate (a bit)
		e = $("#ask-email").val();
		q = $("#ask-question").val();

		if(!e || !q) {
			alert("Please complete the form");
			$("#ask-email").focus();
			return;
		}

		// show waiting
		$("#ask-submit").hide();
		$("#ask-wait").show();

		$.ajax({
			type: "POST",
			url: "/ask/",
			data: "email="+e+"&question="+q,
			dataType: 'json',
			success: function(res){

				if(res.error) {
					alert(res.error);
				} else {
					alert("Thank you, your question has been sent");
					$("#ask-email").val("");
					$("#ask-question").val("");
				}
				$("#ask-submit").show();
				$("#ask-wait").hide();

			}
		});

	})

})