$(function() {
	
	inputtext = $('input#keyword-delimit').val();
	
	// create search tracker
	//var searchTracker = pageTracker._createEventTracker("Search");

	// focus input
	$('input#keyword-delimit')[0].value = "";
	// delimiting search event
	
	// show hide default text on button
	$('input#keyword-delimit').focus( function() {
		if ($(this).val() == inputtext) {
			$(this).val('');
		}
	});
	$('input#keyword-delimit').blur( function() {
		if ($(this).val() == '') {
			$(this).val(inputtext);
		}
	});
	
	// clear input to counter form content caching
	$('input#keyword-delimit').keyup(function () {
		// setup target and regular expression for search term
		var target = $('.delimit li');
		var search_term = new RegExp(this.value.replace(/\\/g, ''), "ig");
		
		// hide all delimitable elements
		target.hide();
		// show elements which contain search term
		target.filter(function() {
			return $(this).text().match(search_term);
		}).show();
		// change results number display
		//$('span.count')[0].innerHTML = ($('.delimit li:visible').length > 0) ? $('.delimit li:visible').length : "0";
		
		// above processes lose focus of the input, so refocus it
		this.focus();
	});
	
	$(inputtext).parents('form').submit( function () {
		return false;
	});
});