var states = new Array(); states.push(new Array(11, 'Sport & Fitness', 11)); states.push(new Array(1, 'Entertainment', 1)); states.push(new Array(10, 'Motoring & Transport', 10)); states.push(new Array(9, 'Other Business Services', 9)); states.push(new Array(8, 'Money & Finance', 8)); states.push(new Array(7, 'Shopping', 7)); states.push(new Array(6, 'Property', 6)); states.push(new Array(5, 'Peoples Websites', 5)); states.push(new Array(4, 'Society & Culture', 4)); states.push(new Array(2, 'News & Reference', 2)); states.push(new Array(12, 'Travel & Holidays', 12)); states.push(new Array(13, 'Home & Garden', 13)); states.push(new Array(14, 'Health & Body', 14)); states.push(new Array(15, 'Kids & Family', 15)); states.push(new Array(16, 'Education', 16)); states.push(new Array(9, 'Photographers', 17)); states.push(new Array(12, 'Hotels & Accommodation', 18)); states.push(new Array(9, 'Business Consultancy', 19)); states.push(new Array(9, 'IT, Computers and Website Design', 20)); states.push(new Array(9, 'Legal', 21)); states.push(new Array(9, 'Advertising, Design, Marketing', 22)); states.push(new Array(9, 'Manufacturing & Engineering', 23)); states.push(new Array(1, 'Food & Restaurants', 24)); states.push(new Array(1, 'Bands & Performers', 25)); states.push(new Array(1, 'Venues & Places', 26)); states.push(new Array(1, 'Pubs & Clubs', 27)); states.push(new Array(1, 'Entertainment Services', 28)); states.push(new Array(2, 'X Broken Links', 29)); states.push(new Array(9, 'Recruitment', 30)); states.push(new Array(8, 'Accounting', 31)); states.push(new Array(6, 'Estate Agents', 32)); states.push(new Array(6, 'Commercial Property', 33)); states.push(new Array(6, 'Property Rental & Management', 34)); states.push(new Array(8, 'Insurance', 35)); states.push(new Array(2, 'X Rubber Dragon Websites', 36)); states.push(new Array(16, 'Training', 37)); states.push(new Array(16, 'Schools', 38)); states.push(new Array(9, 'Print & Packaging', 39)); states.push(new Array(11, 'Swindon Town Football Club', 40)); function countrySelected() { country_id = $('category_id').getValue(); options = $('subcategory_id').options; options.length = 1; states.each(function(state) { if (state[0] == country_id) { options[options.length] = new Option(state[1], state[2]); } }); if (options.length == 1) { $('state_field').hide(); } else { $('state_field').show(); } } document.observe('dom:loaded', function() { countrySelected(); $('category_id').observe('change', countrySelected); });