// walidacja formularza
$(document).ready(function() {
	$("form").submit(function() {
		error = 0;
		$(this).find(".required").each(function() {
			if($(this).hasClass("checkboxes")) {
				checkbox_error = 1;
				$(this).find("input[type=checkbox]").each(function() {
					if($(this).is(":checked")) {
						checkbox_error = 0;
					}
				});
				if(checkbox_error == 1) {
					$(this).css("background-color", "#350f0f");
					error = 1;
				}
				else {
					$(this).css("background-color", "inherit");
				}
			}
			else 
			if($(this).val() == "") {
				error = 1;
				$(this).css("background-color", "#350f0f");
			}
			else {
				$(this).css("background-color", "inherit");
			}
		});
		if(error == 1) {
			alert("Musisz wypełnić wszystkie wymagane pola!");
			return false;
		}
		else {
			return true;
		}
	});
});
