	if (document.all && window.attachEvent)
	{
		window.attachEvent("onload", init);
	}

	function init()
	{
		if (document.getElementById("bedrooms") != null)
		{
			var bedrooms = document.getElementById("bedrooms").value;
									
			if (bedrooms != null && bedrooms.length > 0)
			{
				var id = "bedrooms" + bedrooms;
				document.getElementById(id).className = "selected";
			}
		}

		if (document.getElementById("bathrooms") != null)
		{
			var bathrooms = document.getElementById("bathrooms").value;
			
			if (bathrooms != null && bathrooms.length > 0)
			{
				var id = "bathrooms" + bathrooms;
				document.getElementById(id).className = "selected";
			}
		}
	}
	
	function selector_Click(parentID, item)
	{
		var parent = document.getElementById(parentID);
		
		if (parent != null)
		{
			var items = parent.getElementsByTagName("a");
			
			for(var i = 0; i < items.length; i++)
			{
				items[i].className = "";
			}
			
			item.className = "selected";
		}
	}

	function bedroomsSelector_Click(item, value)
	{
		selector_Click("bedroomsSelector", item);
		
		var bedrooms = document.getElementById("bedrooms");
		
		if (bedrooms != null)
		{
			bedrooms.value = value;
		}
	}
	
	function bathroomsSelector_Click(item, value)
	{
		selector_Click("bathroomsSelector", item);
		
		var bathrooms = document.getElementById("bathrooms");
		
		if (bathrooms != null)
		{
			bathrooms.value = value;
		}
	} 
	
	var locations = new Array();
					
	function toggleVisibility(containerID, toggleSwitchID)
	{
		var container = document.getElementById(containerID);
		var toggle = document.getElementById(toggleSwitchID);
		
		if (container.style.display == "none")
		{
			container.style.display = "block";
			toggle.src = "http://mysitedb.ultraitsolutions.com/images/minus.gif";
		}
		else
		{
			container.style.display = "none";
			toggle.src = "http://mysitedb.ultraitsolutions.com/images/plus.gif";
		}
	}
	
	function town_Click(locationElementID, locationCheckBoxID, locationID)
	{
		var locationElement = document.getElementById(locationElementID);
		var locationCheckBox = document.getElementById(locationCheckBoxID);
		
		if (locationElement.className.indexOf("selected") != -1)
		{
			locationElement.className = "level3";
			locationCheckBox.checked = false;
			removeLocation(locationID);
		}
		else
		{
			locationElement.className = "level3 levelselected";
			locationCheckBox.checked = true;
			addLocation(locationID);
		}
	}

	function addLocation(locationID)
	{
		var found = false;
		
		for(var i = 0; i < locations.length; i++)
		{
			if (locations[i] == locationID)
			{
				found = true;
			}
		}
		
		if (!found)
		{
			locations[locations.length] = locationID;
		}
		
		updateField();
	}
	
	function removeLocation(locationID)
	{
		for (var i = 0; i < locations.length; i++)
		{
			if (locations[i] == locationID)
			{
				locations[i] = "";
			}
		}
		
		updateField();
	}
	
	function updateField()
	{
		var locationsField = document.getElementById("locations");
		
		locationsField.value = "";
		
		for(var i = 0; i < locations.length; i++)
		{
			if (locations[i].length > 0)
			{
				locationsField.value = locationsField.value + locations[i] + ",";
			}
		}
	}
