function initValueGuide()
{
	var vg = $('form.value-guide');

	$('select', vg[0]).change(function(s){
		if( $('#guide', vg[0]).val() != 'select' )
		{
			vg.submit();
		}
	});

	$('input[type=submit]', vg[0]).hide();
}

function initInputWithDefaultText(field)
{
	var searchBox = $(field)
		.focus(function(s){
			if( $(this).val() == this.defaultValue )
			{
				$(this).val('');
			}
			$(this).css('color', '#000');
		})
		.blur(function(s){
			if( $(this).val() == '' )
			{
				$(this).val(this.defaultValue);
			}
			$(this).css('color', '#999');
		})
		.blur();
}

function initSearchEndecaSubmit()
{
	// The Endeca search form needs a little processing when it gets submitted
	$('form.search').submit(function(s){
		// Focus the search box to clear default text if nothing else was entered
		$(this).find('input.search').focus();

		// NVals select sets multiple parameters, so we add it to the URL separately.
		// TODO: Make the form work properly w/o Javascript.
		var $url = $(this).attr('action') + '?';

		var $searchText = $.trim($(this).find('input.search').val());

		// Only include search text if the User provided any.
		var $inputs = $(this).find('input');
		if( $searchText == '' )
		{
			$inputs = $inputs.not('form.search input.search').not('#center-col-searchform-ntk');
		}

		$url += $inputs.serialize() + '&' + $(this).find('select[name=NVals]').val();

		// Add boolean search capability.
		if( /\b(and|or|not)\b/i.test($searchText) )
		{
			$url += '&Ntx=mode+matchboolean&D=' + encodeURIComponent($searchText);
		}

		location.href = $url;
		return false;
	 });
}

function initSearchNormalSubmit()
{
	$('form.search').submit(function(s){
		// Focus the search box to clear default text if nothing else was entered
		$(this).find('input.search').focus();
	});
}