$().ready(function() {
	$("#tx_htdig_search").autocomplete(
		'fileadmin/scripts/searchsuggest.php',
		{
			width: 265,
			max: 5,
			cacheLength: 0,
			selectFirst: false,
			formatItem: function(row) {
				return row[0] + " <span class=\"results\">(" + row[1] + "x)</span>";
			},
			formatResult: function(row) {
				return row[0].replace(/(<.+?>)/gi, '');
			}
		}
	);
	
	$("#tx_htdig_search").focus(function() {
		if (this.value == this.defaultValue) {
			this.value = '';
			$("#tx_htdig_search").addClass('focus');
		}
	});
	
	
	$("#tx_htdig_search").blur(function() {
		if (this.value == '') {
			this.value = this.defaultValue;
			$("#tx_htdig_search").removeClass('focus');
		}
	});
	
	/* input element on search page */
	$("#tx-htdig-pi1-searchbox-sword").autocomplete(
		'fileadmin/scripts/searchsuggest.php',
		{
			width: 265,
			max: 5,
			cacheLength: 0,
			selectFirst: false,
			formatItem: function(row) {
				return row[0] + " <span class=\"results\">(" + row[1] + "x)</span>";
			},
			formatResult: function(row) {
				return row[0].replace(/(<.+?>)/gi, '');
			}
		}
	);
	
	$("#tx-htdig-pi1-searchbox-sword").focus(function() {
		if (this.value == this.defaultValue) {
			this.value = '';
			$("#tx-htdig-pi1-searchbox-sword").addClass('focus');
		}
	});
	
	
	$("#tx-htdig-pi1-searchbox-sword").blur(function() {
		if (this.value == '') {
			this.value = this.defaultValue;
			$("#tx-htdig-pi1-searchbox-sword").removeClass('focus');
		}
	});

	
});