function filter_actualize(input) {
	change_style(input);
	f = $("#filter_form").serializeForm();
	$.ajax({
		type: "POST",
		url: "/modules/tours/filter.php",
		data: (typeof(input.name) == 'undefined' ? 'i=all&' : 'i='+input.name+'&')+f,
		dataType: "text",
		success: function(res){
			//alert(res);
			 var reg = /^[0-9]+$/;
 			if(res.match(reg)) {
 				if (parseInt(res) == 1) {
 					cnt = "(nájdený "+res+" záznam)";
				} else if (parseInt(res) >= 2 && parseInt(res) <= 4) {
 					cnt = "(nájdené "+res+" záznamy)";
				} else {
 					cnt = "(nájdených "+res+" záznamov)";
				}
 				 
 				$('#button_search > SPAN').html(cnt);
			}
		},
		beforeSend: function(){
			//
		}
	});
}
function submit_filter(frm) {
	f = $("#filter_form").serializeForm() + "&order=" + $("#sel_order").val();
	document.location = frm.action+"?"+f;
}

function change_style(input){
	if($('#'+input.id).attr('checked') == true) {
		$('#l_'+input.id).addClass('selected');
	}
	else {
		$('#l_'+input.id).removeClass('selected');
	}	
}

$(document).ready(function() {
	filter_actualize(false);
});
