$(document).ready(
	function()
	{
		searchBox();
		checkFilters();
	}
);

function expandAttributes(strAttribute)
{
	intElements = $("#"+strAttribute+" li a[class=more]").attr("id");

	if ($("#"+strAttribute+" li[class=hiddenAttribute]").css("display") == "none")
	{
		$("#"+strAttribute+" li[class=hiddenAttribute]").css("display", "block");
		$("#"+strAttribute+" li a[class=more]").text("View Less");
	}
	else
	{
		$("#"+strAttribute+" li[class=hiddenAttribute]").css("display", "none");
		$("#"+strAttribute+" li a[class=more]").text("View More ("+intElements+")");
	}
}

function searchBox()
{
	$("#searchButton").click(
		function()
		{
			if($("#searchBox").val()=='Keyword / Item#')
			{
				$("#searchBox").val('');
			}
		}
	);

	$("#subQuery").focus(
		function()
		{
			if(this.value=='Refine your results')
			{
				this.value='';
			}
		}
	);

	$("#subQueryButton").click(
		function()
		{
			if($("#subQuery").val()=='Refine your results')
			{
				$("#subQuery").val('');
			}
		}
	);

	$("#subQuery").blur(
		function()
		{
			if(this.value=='')
			{
				this.value='Refine your results';
			};
		}
	);
}

function checkFilters()
{
	var catExpanded = new Array();
	$('#storeNav a[class=removeSingleFilter]').each(function(index) {
		if ($(this).is(":hidden"))
		{
			var catId = $(this).parent().parent().attr('id');
			expandAttributes( catId );
			
			if (catExpanded[catId])
			{
				return false;
			}
			catExpanded[catId] = true;
		}
	});
}
