// function to initialise the main list
function initialiseList()
{
	for (var element in items)
	{
		addOption("selectList", items[element], items[element]);
	}// end for
}// end function initialiseList()
	
function initialiseList2()
{
	for (var element in items)
	{
		addOption("selectList2", items[element], items[element]);
	}// end for
}// end function initialiseList()		
// function to set the content of the object once the state has changed
function setList()
{
	// remove any existing options from the select element
	removeAllOptions("subList"); // "subCategories" should be replaced with the id of the required select element
		
	for(var l = 0; l < options.length; l++)
	{
		if(l == document.getElementById("selectList").value)
		{
			for(var i = 0; i < options[l].length; i++) 
			{ 
				// add options to the select element
				addOption("subList", i, options[l][i]); // "subCategories should be replaced with the id of the required select element
			}// end for i 
		}// end if
	}// end for l
}// end function setList
	
function setList2()
{
	// remove any existing options from the select element
	removeAllOptions("subList2"); // "subCategories" should be replaced with the id of the required select element
		
	for(var l = 0; l < options.length; l++)
	{
		if(l == document.getElementById("selectList2").value)
		{
			for(var i = 0; i < options[l].length; i++) 
			{ 
				// add options to the select element
				addOption("subList2", i, options[l][i]); // "subCategories should be replaced with the id of the required select element
			}// end for i 
		}// end if
	}// end for l
}// end function setList
		
// function to add option items to a select element
function addOption(selectId, val, txt) 
{
	var objOption = new Option(txt, val);
	document.getElementById(selectId).options.add(objOption);
}// end function addOption

// function to remove items from a select menu
function removeAllOptions(selectName)
{
	for (var element in document.getElementById(selectName))
	{
		document.getElementById(selectName).remove(element);
	}// end for
}// end function removeAllOptions
