var CBClassic = {
areas: '',
area: '',
init: function() {
this.area = ($('#town').length > 0) ? '#town' : '#city';
this.setAreas(this.area);
this.setDependentSelect('#county', this.area);
this.setupEventListeners();
},
setAreas: function(select) {
var that = this;
$(select+' option').each(function() {
that.areas+='<option class="'+$(this).attr('className')+'">'+$(this).html()+'</option>';
});
},
setDependentSelect: function(master, slave) {
$(slave).html(this.areas);
$(slave+' option').each(function() {
if ($(master).val() != $(this).attr('className')) {
$(this).remove();
}
});
},
setupEventListeners: function() {
var that = this;
$('#county').change(function(e) {
that.setDependentSelect('#county', that.area);
});
}
};
