$(function(){
	$("#first-print #other-services").click(function(){
		if($("[name='other-details']").attr("disabled")){
			$("[name='other-details']").removeAttr("disabled");
		}else{
			$("[name='other-details']").attr("disabled","disabled").val("");
		}
	});
	
	$("#first-print form").submit(function(){
		var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		var hasError = false;
		
		if(!filter.test($("[name='email']").val())){
			alert('You forgot to precise your email or it was not well formated.');
			$("[name='email']").focus();
			hasError = true;
		} else if($("#other-services").attr("checked") == true && $("[name='other-details']").val() == ""){
			alert('You forgot to precise what other Buzzinbees services you are interested in.');
			$("[name='other-details']").focus();
			hasError = true;
		}
		
		if($(":checkbox:checked").length == 0){
			alert('You have to choose at least one area you are most interested in.');
			hasError = true;
		}
		
		return !hasError;
	});
});