$(function(){

$('#tourform #sendbutton').click(function() { 
	var res = true;
	$("#tourform input").each(function(){
		if($(this).val() == ""){
			res = false;
			$(this).css({"background-color":"rgba(246,146,152,0.3)"});
		}
	});

    // submit the form 
    if(res) ajaxSubmit(); 
    // return false to prevent normal browser submit and page navigation 
    return false; 
});

	function ajaxSubmit(){
		$('#tourform #sendbutton').attr("disabled","disabled");
		
		$('.wait-snake').show();
		
		var queryString = $('#tourform').serialize(); 
		 
		// the data could now be submitted using $.get, $.post, $.ajax, etc 
		$.post('_sendMail.php', queryString, function(res){
			if(res == 0) {
				$('#tourform').hide();
				$('.afterMessage').show();
				
				return;
			}
			$('#tourform #sendbutton').removeAttr("disabled");
		});
	}
});
