function showBrands()
{
	(document.advanceSearch.skateType[0].checked == true) ? brandArr = iceArr : brandArr = rollerArr;
	
	var selectedSize = document.advanceSearch.availableSizes.value;
	var brandField = document.advanceSearch.availableBrands;
	brandField.options.length = 0;
	brandField.options[0] = new Option('All Brands','-');
	
	//check to see if "All Sizes" is chosen again. If so, do not continue
	if(selectedSize == "-")
	{
		resetSearch();
		return;
	}
	
	for(var i = 0; i < brandArr[selectedSize].length; i++)
	{
		brandField.options[i + 1] = new Option(brandArr[selectedSize][i],brandArr[selectedSize][i]);
		if(brandArr[selectedSize][i] == chosenBrand)
		{
			brandField.options[i + 1].selected = true;
		}
	}
	
	//setting the length back to the number of elements removes the extra "blank" option at the bottom of the select box
	brandField.options.length = brandArr[selectedSize].length + 1;
	
	return;
}

function showSizes()
{
	if(document.advanceSearch.skateType[0].checked == true)
	{
		arr = iceSizesArr;
		brandArr = iceArr;
	}
	else
	{
		arr = rollerSizesArr;
		brandArr = rollerArr;
	}

	var sizeField = document.advanceSearch.availableSizes;
	sizeField.options.length = 0;
	sizeField.options[0] = new Option('All Sizes','-');
	
	for(var i = 0; i < arr.length; i++)
	{
		sizeField.options[i + 1] = new Option(arr[i],arr[i]);
	  if(arr[i] == chosenSize)
		{
			sizeField.options[i + 1].selected = true;
			showBrands();
		}
	}
	
	//setting the length back to the number of elements removes the extra "blank" option at the bottom of the select box
	sizeField.options.length = arr.length + 1;
}

function resetSearch()
{
	document.advanceSearch.availableBrands.selectedIndex = "-";
	document.advanceSearch.availableBrands.options.length = 1;
	chosenSize = "-";
	showSizes();
}


//handle defaults
function checkForSkateType()
{
	if(chosenType == "Ice")
	{
		document.advanceSearch.skateType[0].checked = true;
	}
	else
	{
		document.advanceSearch.skateType[1].checked = true;
	}
	
	
	if(chosenOrder == "DESC")
	{
		document.advanceSearch.priceOrder.options[0].selected = true;
	}
	else
	{
		document.advanceSearch.priceOrder.options[1].selected = true;
	}
}

checkForSkateType();
showSizes();
		
