jQuery(function(){ $('div.map-container').data('searchMap', { cached: { }, map: $('div.map-container'), select: function(params){ var filter = $('#search-filter').val(); if(filter) params.filter = filter; var multiple = $('#search-multiple').val(); if(multiple === undefined) multiple = true; params.multiple = multiple; var key = $.param(params); if(this.cached[key]){ this.map.html(this.cached[key]); } else { this.loadMap(params); } }, loadMap: function(params){ var key = jQuery.param(params); params.act = 'loadMap'; this.map.load(window.location.href, params, function(response, status, request){ $(this).data('searchMap').cached[key] = response; }); } }); $('div.searchmap a:not(mapinactive)').live('click', function(e){ e.preventDefault(e); var params = $.queryParams(this.href); $('div.map-container').data('searchMap').select(params); }); $('input.select-region').live('click', function(){ $('div.search-map select.suburb').attr('disabled', this.checked); }); $('div.search-map a.back').live('click', function(e){ e.preventDefault(); var params = $.queryParams(this.href); $('div.map-container').data('searchMap').select(params); }); $('div.search-map select.state').live('change', function(){ if($(this).val()){ var state = $(this).val(); var country = $('input[name="country-map"]').val(); var params = { map: country+'-'+state.toLowerCase(), state: state, mode: 'map' }; $('div.map-container').data('searchMap').select(params); } }); $('div.search-map select.region').live('change', function(){ if($(this).val()){ var state = $('div.search-map select.state').val(); var country = $('input[name="country-map"]').val(); var params = { map: country+'-'+state.toLowerCase(), state: state, region: $(this).val(), mode: 'map' }; $('div.map-container').data('searchMap').select(params); } }); });