
var citiesPageNames = {};
var propertiesPageNames = {};
var propertiesOfCity = {};

var selectCityBegin; // remove later
var selectPropertyBegin;

var noCityOptionValue;
var noPropertyOptionValue;
var allPropertiesOptionValue;



function cityChanged() {
	updatePropertyDropdown();
	updateFormAction();
}

function updatePropertyDropdown() {
	var cityCode = document.getElementById("selectcity").value;
		
	var options = propertiesOfCity[cityCode];
	var propertiesSelect = selectPropertyBegin + options + "</select>";
	document.getElementById("our_location_select_property_container").innerHTML = propertiesSelect;	
}

function propertyChanged() {
	updateFormAction();
}

function updateFormAction() {
	var propertyCode = document.getElementById("selectproperty").value;
		
	if (propertyCode != 0 && propertyCode != noPropertyOptionValue && propertyCode != allPropertiesOptionValue)
		document.getElementById("select_form").action = propertiesPageNames[propertyCode];
	else {
		var cityCode = document.getElementById("selectcity").value;
		document.getElementById("select_form").action = citiesPageNames[cityCode];	
	}
}
