$(document).ready(function()
{
	$('#zipcode').keyup(function(e) {
		if($(this).val().length > 0 && $('#note_notempty').is(':visible'))
		{
			$('#note_notempty').slideUp('fast');
		}
	});
	
	$('#find_retailer').click(function(e) {
		// If zipcode is empty, don't do anything.
		var zipcode = $('#zipcode').val();

		if(zipcode.length > 0)
		{
			$('#note_notempty').slideUp('fast');
			
			// Get radius selection.
			var radius = $('#radius').val();
			
			// Create map. It will center and zoom to defaults.
			// But they wont be seen.
			$("#map").bMap({
				mapType: G_NORMAL_MAP,
				loadMsg: '<div id="searching"><p>Searching for stores in requested area.</p><img src="./media/images/loading_hor.gif" /></div>'
			});
			
			// Load markers.
			$('#map').data('bMap').AJAXMarkers({	
				serviceURL: 'store_locator/search',
				action: "Markers",			
				vars: [zipcode, radius]
			});
		}
		else
		{
			$('#note_notempty').slideDown('fast');
		}
	});
});
