$(function() {
	/* Zoekformulier */
	$('.zoekknop').click(function() {
		searchSubmit($(this));
		return false;
	});
	var searchSubmit = function(sNode) {
		var theForm = $(sNode).parent();
		var searchInputText = $(theForm).find('input:text');
		var searchInputHidden = $(theForm).find('input:hidden');
		searchTerm = encodeURIComponent(searchInputText.val());
		if (searchTerm.length > 1) {
			$("form").submit(function() { return false });
			var searchUrl = searchInputHidden.val();
			searchUrl += searchTerm;
			window.location = searchUrl;
		} else {
			alert('Vul minstens twee tekens in om te zoeken.');
			return false;
		}
	}
	$("#zoek input:text").each(function() {
		$(this).keydown(
			function(e) {
				if (e.keyCode == 13) {
					searchSubmit($(this));
					return false;
				}
			}
		);
		$(this).focus(
			function() {
				this.value = '';
			}
		);
		$(this).blur(
			function() {
				if (this.value == '') {
					this.value = 'Zoek op trefwoord...';
					//					this.className = 'zoekveld';
				}
			}
		)
	});
});
