if (typeof actionAttacher == 'undefined') {
    var actionAttacher = pDomApi.getActionAttacher();
}

pDomApi.addEvent(window, 'load',  function() {

	if (typeof jQuery != 'undefined') {
		$(function() {
			var now = new Date();

			$.datepicker.setDefaults($.datepicker.regional[language]);

			$("#arrival").datepicker({
				minDate: now,
				dateFormat: 'dd-mm-yy',
				onClose: function (date) {
					$("#departure").datepicker("option", "defaultDate", date);
				}
			});

			$("#departure").datepicker({
				minDate: now,
				dateFormat: 'dd-mm-yy'
			});
		});
	}
});

actionAttacher.addTagEvent(new PrezentDomApi.TagEvent('input', 'filterSubmitButton', 'click',
	function (e) {
		if (document.forms['filters'].elements['search'].value == translation.label_search_by_text + '...') {
			document.forms['filters'].elements['search'].value = '';
		}

		if (document.forms['filters'].elements['arrival'].value == translation.label_choose_date + '...') {
			document.forms['filters'].elements['arrival'].value = '';
		}

		if (document.forms['filters'].elements['departure'].value == translation.label_choose_date + '...') {
			document.forms['filters'].elements['departure'].value = '';
		}

//		if (document.forms['filters'].elements['category'].value == 'Kies gebied...') {
//			document.forms['filters'].elements['category'].value = '';
//		}
	}
));

actionAttacher.addTagEvent(new PrezentDomApi.TagEvent('input', 'prefillField', 'focus',
	function (e) {
		if (this.name == 'search' && this.value == translation.label_search_by_text + '...') {
			this.value = '';
		} else if ((this.name == 'arrival' || this.name == 'departure') &&
				this.value == translation.label_choose_date + '...') {
			this.value = '';
		}
	}
));

actionAttacher.addTagEvent(new PrezentDomApi.TagEvent('input', 'prefillField', 'blur',
	function (e) {
		if (this.value == '') {
			if (this.name == 'search') {
				this.value = translation.label_search_by_text + '...';
			} else if (this.name == 'arrival' || this.name == 'departure') {
				this.value = translation.label_choose_date + '...';
			}
		}
	}
));
