$(function(){
	
$("#bt_send").click(function(e){e.preventDefault();
	
	var P1 = ($("#tx_1").attr("value") != "");
	var P2 = ($("#tx_2").attr("value") != "");
	var P3 = ($("#tx_3").attr("value") != "");
		var $criteriu_email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var P4 = (($("#tx_4").attr("value") != "") && $("#tx_4").attr("value").match($criteriu_email));
	var P5 = ($("#tx_5").attr("value") != "");
	var P6 = ($("#tx_6").attr("value") != "");
	var P7 = ($("#tx_7a").attr("checked") || $("#tx_7b").attr("checked"));
	var P8 = ($("#tx_8").attr("value") != "");
	var P9 = ($("#tx_9").val() != "");
	var P10 = ($("#tx_10a").attr("checked") || $("#tx_10b").attr("checked") || $("#tx_10c").attr("checked"));
		if ($("#tx_10c").attr("checked")) {P10 = ($("#tx_10cx").val() != "");}
	var P11 = $("#tx_11").attr("checked");
	
	
	if (!P1) {$("#tx_1").focus();return;}
	if (!P2) {$("#tx_2").focus();return;}
	if (!P3) {$("#tx_3").focus();return;}
	if (!P4) {$("#tx_4").css("color","red").focus();return;}
	if (!P5) {$("#tx_5").focus();return;}
	if (!P7) {$("#tx_7a").focus();return;}
	if (!P8) {$("#tx_8").focus();return;}
	if (!P9) {$("#tx_9").focus();return;}
	if (!P10 && $("#tx_10c").attr("checked")) {$("#tx_10cx").focus();return;}
	if (!P10) {$("#tx_10a").focus();return;}
	if (!P11) {$("#tx_11").focus();return;}	
	
	$(this).hide();
	$("#bt_load").fadeIn("fast");

	$fisier = "simpozion2010-form.php";
	$.post($fisier, {
		tx_1 : $("#tx_1").attr("value"), 
		tx_2 : $("#tx_2").attr("value"), 
		tx_3 : $("#tx_3").attr("value"), 
		tx_4 : $("#tx_4").attr("value"), 
		tx_5 : $("#tx_5").attr("value"), 
		tx_6 : $("#tx_6").attr("value"),
		tx_7 : ($("#tx_7").attr("checked"))?"x":" ", 
		tx_7a : ($("#tx_7a").attr("checked"))?"x":" ", 
		tx_7b : ($("#tx_7b").attr("checked"))?"x":" ", 
		tx_8 : $("#tx_8").attr("value"), 
		tx_9 : $("#tx_9").attr("value"), 
		tx_10a : ($("#tx_10a").attr("checked"))?"x":" ", 
		tx_10b : ($("#tx_10b").attr("checked"))?"x":" ", 
		tx_10c : ($("#tx_10c").attr("checked"))?"x":" ", 
		tx_10cx : $("#tx_10cx").attr("value"), 
		tx_11 : ($("#tx_11").attr("checked"))?"x":" "
		},function(data){
			if (data=="Succes!"){
				msg = (window.location.pathname.search("/en/") == -1)?"Your registration form was successfully sent!\n\nThank you!":"Your registration form was successfully sent!\n\nThank you!";
				alert(msg);
				$("#bt_load").hide();
				$("#bt_load_ok").fadeIn("slow");
			}else{
				msg = (window.location.pathname.search("/en/") == -1)?"Error!\n\nPlease try again later.":"Error!\n\nPlease try again later.";
				alert(msg);
			}
		 });


	});
	
});
