$(document).ready(function(){
	// Podpięcie kalendarzy pod stronę wyszukiwania targów
	if ($("#iStartDate").length && $("#iStartDateTrigger").length) {
		Calendar.setup({
			inputField : "iStartDate",
			ifFormat : "%Y-%m-%d",
			button : "iStartDateTrigger",
			firstDay : 1,
			weekNumbers : false,
			cache : true,
			showOthers : true
		});
	}
	if ($("#iStopDate").length && $("#iStopDateTrigger").length) {
		Calendar.setup({
			inputField : "iStopDate",
			ifFormat : "%Y-%m-%d",
			button : "iStopDateTrigger",
			firstDay : 1,
			weekNumbers : false,
			cache : true,
			showOthers : true
		});
	}
	// Rozszerzenie obiektu jQuery o metodę do czyszczenia formularza.
	$.fn.extend({
		reset : function() {
			return this.each(function() {
				$(this).is("form") && this.reset();
			});
		}
	});
	// Czyszczenie formularza wyszukiwania targów
	$("#Clear").click(function() {
		$("#searchFairsForm").reset();
		return false;
	});
});