	function valueChangedEvent(elementName, controlledElementName)
	{
		var townSelect = document.getElementById(elementName);
		
		clearSelectItems(controlledElementName);
		addSelectItem(controlledElementName, "--any suburb--", -1);
		for(var i = 0; i < townSuburbArrayId.length; i = i + 1)//check each [town, suburb] pair
		{
			if(townSelect.options[townSelect.selectedIndex].value == townSuburbArrayId[i][0])//see if the town is the one selected
			{
				addSelectItem(controlledElementName, townSuburbArray[i][1], townSuburbArrayId[i][1]);
			}
		}
	}
	
	function addSelectItem(elementName, sName, sValue)
	{
  		var select = document.getElementById(elementName);
  		select.options[select.length] = new Option(sName, sValue);
	}

	function clearSelectItems(elementName)
	{
  		var select = document.getElementById(elementName);
 		 select.length = 0;
	}
	
	function preselectTownAndSuburb(elementName, controlledElementName)
	{
		var townSelect = document.getElementById(elementName);
		var suburbSelect = document.getElementById(controlledElementName);
		
		
		
		for(var i = 0; i < townSelect.length;  i = i + 1)
		{
			if(townSelect.options[i].value == townPreselect)
			{
				townSelect.selectedIndex = i;
			}
		}
		
		valueChangedEvent(elementName, controlledElementName);

		for(var j = 0; j < suburbSelect.length;  j = j + 1)
		{
			if(suburbSelect.options[j].value == suburbPreselect)
			{
				suburbSelect.selectedIndex = j;
			}
		}
	}
