/*requires jquery-1.3.2.min.js*/

/*
	Requires the jQuery library
*/
$(function() {
	var topDDLs = $("select[id$='TopRegionDropDownList']");
	var subDDLs = $("select[id$='SubRegionDropDownList']");
	
	topDDLs.each(function() {
		$(this).change(function() {
			var topRegionID = $(this).selectedValues();
			
			// change topregion for all topregion selectors
			topDDLs.each(function() {
				$(this).selectOptions(topRegionID);
			});
			
			// add subregions under current topregion to all subregion selectors
			subDDLs.each(function() {
				$(this).removeOption(/./);
				$(this).addOption(regionOptions[topRegionID]);
				
				// set default subregion
				$(this).selectOptions(defaultSubRegions[topRegionID]);
			});
		});
	});
	
	subDDLs.each(function() {
		$(this).change(function() {
			var subRegionID = $(this).selectedValues();
			
			// change subregion for all subregion selectors
			subDDLs.each(function() {
				$(this).selectOptions(subRegionID);
			});
		});
	});
});