function isValidEmail(email) {
	var mail_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	return mail_filter.test(email);
}

// CONTACT
function checkContactForm() {
	var lastname = $("#lastname").val();
	var firstname = $("#firstname").val();
	var shop = $("#boutique").val();
	var siret = $("#siret").val();
	var vat = $("#vat").val();
	var city = $("#city").val();
	var postcode = $("#postcode").val();
	var email = $("#email").val();
	var phone = $("#phone").val();
	var question = $("#question").val();
	
	var flag = lastname != "" && firstname != "" && shop != "" && siret != "" && vat != "" && city != "" && postcode != "" && isValidEmail(email) && phone != "" && question != "";
	
	if( flag ) {
		$("#submit_passive").hide();
		$("#submit_active").show();
	} else {
		$("#submit_active").hide();
		$("#submit_passive").show();
	}
}


function submitContactForm() {
	var lastname = $("#lastname").val();
	var firstname = $("#firstname").val();
	var shop = $("#boutique").val();
	var siret = $("#siret").val();
	var vat = $("#vat").val();
	var city = $("#city").val();
	var postcode = $("#postcode").val();
	var email = $("#email").val();
	var phone = $("#phone").val();
	var question = $("#question").val();
	
	var lang = $("#lang").val();
	
	$.post("assets/scripts/contactForm.php", {lang:lang, lastname:lastname, firstname:firstname, shop:shop, siret:siret, vat:vat, city:city, postcode:postcode, email:email, phone:phone, question:question}, function(data) {
		if( data == "1" || data == 1 ) {
			$("#content_form").hide();
			$("#content_form_success").show();
			
			$("#lastname").val("");
			$("#firstname").val("");
			$("#boutique").val("");
			$("#siret").val("");
			$("#vat").val("");
			$("#city").val("");
			$("#postcode").val("");
			$("#email").val("");
			$("#phone").val("");
			$("#question").val("");
		}
	});
}

// CONCEPT
function checkConceptForm() {
	var lastname = $("#lastname").val();
	var firstname = $("#firstname").val();
	var shop = $("#boutique").val();
	var city = $("#city").val();
	var postcode = $("#postcode").val();
	var email = $("#email").val();
	var phone = $("#phone").val();
	var have_you_got_a_shop = $("#have_you_got_a_shop").val();
	var where_to_open = $("#where_to_open").val();
	var which_city = $("#which_city").val();
	var what_size = $("#what_size").val();
	var when_to_open = $("#when_to_open").val();
	var shop_or_corner = $("#shop_or_corner").val();
	var what_budget = $("#what_budget").val();
	
	var flag = lastname != "" && firstname != "" && shop != "" && city != "" && postcode != "" && isValidEmail(email) && phone != "" && have_you_got_a_shop != "" && where_to_open != "" && which_city != "" && what_size != "" && when_to_open != "" && shop_or_corner != "" && what_budget != "";
	
	if( flag ) {
		$("#submit_passive").hide();
		$("#submit_active").show();
	} else {
		$("#submit_active").hide();
		$("#submit_passive").show();
	}
}


function submitConceptForm() {
	var lastname = $("#lastname").val();
	var firstname = $("#firstname").val();
	var shop = $("#boutique").val();
	var city = $("#city").val();
	var postcode = $("#postcode").val();
	var email = $("#email").val();
	var phone = $("#phone").val();
	var have_you_got_a_shop = $("#have_you_got_a_shop").val();
	var where_to_open = $("#where_to_open").val();
	var which_city = $("#which_city").val();
	var what_size = $("#what_size").val();
	var when_to_open = $("#when_to_open").val();
	var shop_or_corner = $("#shop_or_corner").val();
	var what_budget = $("#what_budget").val();
	
	var lang = $("#lang").val();
	
	$.post("assets/scripts/conceptForm.php", {lang:lang, lastname:lastname, firstname:firstname, shop:shop, city:city, postcode:postcode, email:email, phone:phone, haveYouGotAShop:have_you_got_a_shop, where:where_to_open, whichCity:which_city, surface:what_size, date:when_to_open, shopOrCorner:shop_or_corner, budget:what_budget}, function(data) {
		if( data == "1" || data == 1 ) {
			$("#content_form").hide();
			$("#content_form_success").show();
			
			$("#lastname").val("");
			$("#firstname").val("");
			$("#boutique").val("");
			$("#siret").val("");
			$("#vat").val("");
			$("#city").val("");
			$("#postcode").val("");
			$("#email").val("");
			$("#phone").val("");
			$("#question").val("");
		}
	});
}
