function findValue(li) {
	if( li == null ) return alert("No match!");
	if( !!li.extra ) var sValue = li.extra[0];
	else var sValue = li.selectValue;

	//window.location='/zoeken/'+$('#footersearch').val();
}

function selectItem(li) {
	findValue(li);
}

function formatItem(row) {
	return row[0];
}


$(document).ready(function() {	
	$('input[type="text"], textarea')
	.focus(function() {
		if (this.value === this.defaultValue) {
			this.value = '';
		}
	})
	.blur(function() {
		if (this.value === '') {
			this.value = this.defaultValue;
		}
	});
	
	var colofonOpen = false;
	$('#colofon-toggle').click(function() {
		if (colofonOpen) {
			colofonOpen = false;
			$('.footer-colofon').stop().animate({'bottom':'-113'},500);
		}
		else {
			colofonOpen = true;
			$('.footer-colofon').stop().animate({'bottom':'0'},500);
		}
		
		return false;
	});
	
	$('#footersearch').keyup(function(event){
 
		if(event.keyCode == '13'){
			
			if($('#footersearch').val() == '') {
			}
			else {
				window.location='/zoeken/'+$('#footersearch').val();
			}
		}
	});
	$("#footersearch").autocomplete("/autocomplete.php", {
		delay:10,
		minChars:2,
		matchSubset:1,
		matchContains:1,
		cacheLength:10,
		onItemSelect:selectItem,
		onFindValue:findValue,
		formatItem:formatItem,
		autoFill:true,
		resultsClass: 'ac_results_footer',
		width: 167
	});

});

