function routing_setupRoutingLogic(parentId) {

	var parent = "#" + parentId + " ";
	
	if (!$.browser.msie) {
		$(parent + '#departFrom').change(function() {
			var departure = cities[$(this).val()];
			var previouslySelected = $(parent + '#arriveAt').val();
			$(parent + '#arriveAt').empty().each(function() {
				var arrivals = $(this);
				$.each(departure._arrivals, function() {
					arrivals.append(this.option());
				});
			});
			$(parent + '#arriveAt').val(previouslySelected);
		});
	} else {
		$(parent + '#departFrom option:disabled, ' + parent + '#arriveAt option:disabled').each(function() {
			$(this).attr('disabled', 'true').css('color', 'graytext');
		});
		$(parent + '#departFrom .indented_option, ' + parent + '#arriveAt .indented_option').each(function() {
			var text = $(this).text();
			$(this).text(String.fromCharCode(160, 160, 160, 160) + text);
		});
		$(parent + '#departFrom, ' + parent + '#arriveAt').each(function() {
			this._lastSelectedIndex = function() {
				var firstEnabled = $(this).find('option:enabled:first');
				this.selectedIndex = firstEnabled ? firstEnabled.index : 0;
				return this.selectedIndex;
			}.call(this);
			this.emulateDisabled = function() {
				if (this.options[this.selectedIndex].disabled) {
					this.selectedIndex = this._lastSelectedIndex;
				} else {
					this._lastSelectedIndex = this.selectedIndex;
				}
			};
			$(this).change(function() {
				this.emulateDisabled();
				if ($(this).attr('id') == 'departFrom') {
					$(this).find('option:selected').each(function() {
						var departure = cities[$(this).val()];
						var previouslySelected = $(parent + '#arriveAt').val();
						$(parent + '#arriveAt').empty().each(function() {
							var arrivals = $(this);
							$.each(departure._arrivals, function() {
								arrivals.append(this.option());
							});
						}).find('option:disabled').each(function() {
							$(this).attr('disabled', 'true').css('color', 'graytext');
						}).end().find('.indented_option').each(function() {
							var text = $(this).text();
							$(this).text(String.fromCharCode(160, 160, 160, 160) + text);
						}).end().val(previouslySelected);
					});
				}
			});
		});
	}

	if (!$.browser.msie) {
		$(parent + '#s0m3valu3').change(function() {
			var departure = detailCities[$(this).val()];
			var previouslySelected = $(parent + '#out_arr_airport').val();
			$(parent + '#out_arr_airport').empty().each(function() {
				var arrivals = $(this);
				$.each(departure._arrivals, function() {
					arrivals.append(this.option());
				});
			});
			$(parent + '#out_arr_airport').val(previouslySelected);
		});
	} else {
		$(parent + '#s0m3valu3 option:disabled, ' + parent + '#out_arr_airport option:disabled').each(function() {
			$(this).attr('disabled', 'true').css('color', 'graytext');
		});
		$(parent + '#s0m3valu3 .indented_option, ' + parent + '#out_arr_airport .indented_option').each(function() {
			var text = $(this).text();
			$(this).text(String.fromCharCode(160, 160, 160, 160) + text);
		});
		$(parent + '#s0m3valu3, ' + parent + '#out_arr_airport').each(function() {
			this._lastSelectedIndex = function() {
				var firstEnabled = $(this).find('option:enabled:first');
				// note: the following line was causing issues in ie6/7
				// and seems to be unnecessary.
				// if you know more about the code and are confident enough
				// to delete it, please do...
//				this.selectedIndex = firstEnabled ? firstEnabled.index : 0;
				return this.selectedIndex;
			}.call(this);
			this.emulateDisabled = function() {
				if (this.options[this.selectedIndex].disabled) {
					this.selectedIndex = this._lastSelectedIndex;
				} else {
					this._lastSelectedIndex = this.selectedIndex;
				}
			};
			$(this).change(function() {
				this.emulateDisabled();
				if ($(this).attr('id') == 's0m3valu3') {
					$(this).find('option:selected').each(function() {
						var departure = detailCities[$(this).val()];
						var previouslySelected = $(parent + '#out_arr_airport').val();
						$(parent + '#out_arr_airport').empty().each(function() {
							var arrivals = $(this);
							$.each(departure._arrivals, function() {
								arrivals.append(this.option());
							});
						}).find('option:disabled').each(function() {
							$(this).attr('disabled', 'true').css('color', 'graytext');
						}).end().find('.indented_option').each(function() {
							var text = $(this).text();
							$(this).text(String.fromCharCode(160, 160, 160, 160) + text);
						}).end().val(previouslySelected);
					});
				}
			});
		});
	}

}

