var $j = jQuery.noConflict();

$j(document).ready(function()
{
	// Search Box Default Text
	var qDefault = 'Keyword or Item #';
	
	// Remove Default Text
	$j('#q').focus(function(){
		if($j(this).attr("value") == qDefault)
		{
			$j(this).attr("value", "");
		}
	});
	
	// Append Default Test
	$j('#q').blur(function(){  
	    if($j(this).attr("value") == "")
	    {
	    	$j(this).attr("value", qDefault);
	    }
	    else
	    {
	    	var thisValue = $j(this).attr("value");
	    	
	    	// Fill Search Bat
			$j('#q').val(thisValue);
			setTimeout("$j('#suggestions').hide();", 200);
			
			// Redirect Page
			$j(window.location).attr('href', 'http://www.familyleisure.com/search&q='+thisValue);
	    }
	});
	
	// Suggestion Box
	$j('#q').keyup(function(){
		var inputString = $j(this).attr("value");
		
		if(inputString.length == 0)
		{
			// Hide the suggestion box.
			$j('#suggestions').hide();
		}
		else
		{
			$j.post("../templating/pages/suggestions.php", {queryString: ""+inputString+""}, function(data)
			{
				if(data.length >0)
				{
					$j('#suggestions').show();
					$j('#autoSuggestionsList').html(data);
				}
			});
		}
	});
	
});

function fill(thisValue)
{
	if(thisValue != undefined)
	{
		// Fill Search Bat
		$j('#q').val(thisValue);
		setTimeout("$j('#suggestions').hide();", 200);
		
		// Redirect Page
		$j(window.location).attr('href', 'http://www.familyleisure.com/search&q='+thisValue);
	}
}
