
	if (GBrowserIsCompatible()) {


		function DumpMarkers(){ 
			// alert(clusterer.markers.length)
			for (var i = 0; i < clusterer.markers.length; i++) { 
				clusterer.RemoveMarker(clusterer.markers[i]); 
			} 
			clusterer.markers.length=0;
		} 


		// load new
		
		function loadMap(){
			DumpMarkers();
			GDownloadUrl("/locator_data.php?locations=1&type=c", process_it);				 
		}
		

	  // Display the map, with some controls
	  var map = new GMap(document.getElementById("map"));
	  map.setUIToDefault();
	  map.addControl(new GLargeMapControl());
	  map.addControl(new GMapTypeControl());

	  map.setCenter(new GLatLng(start_lat, start_lon), 11);

	    var bounds = new GLatLngBounds();


	  // ================================================================
	  // Location Marker Function

	  function createMarker(data,winetab,locationtab) {
		
					
		var storeIcon = new GIcon(G_DEFAULT_ICON);

		if(data.type == 'c') {
	    	storeIcon.image = "/img/marker_red_c.png";
		}else if (data.type == 'bm'){
	    	storeIcon.image = "/img/marker_green.png";
		}else if (data.type == 's'){
	    	storeIcon.image = "/img/marker_blue_s.png";
		}else if (data.type == 'sw'){
	    	storeIcon.image = "/img/marker_orange_s.png";
		}else if (data.type == 'vo'){
	    	storeIcon.image = "/img/marker_orange_v.png";
		}
		markerOptions = { icon:storeIcon };		

	    var marker = new GMarker(data.point,markerOptions);
	    GEvent.addListener(marker, "click", function() {
	  		marker.openInfoWindowTabsHtml([new GInfoWindowTab("Wine",winetab), new GInfoWindowTab("Store",locationtab)]);
	    });

	    return marker;
	  }


	function createWineHTML(data){
	
		w_html = "<div class=\"tab_wine\">";
	
		if(data.type == 'c') {
	    	w_html += '<img src="/img/logo_costco.gif" alt="Costco" class="icon"><strong>'+data.storename+'</strong>';
		}else if (data.type == 'bm'){
			w_html += '<strong>' + data.storename + '</strong>';
		}else if (data.type == 's'){
	    	w_html += '<img src="/img/logo_sams.gif" alt="Sam\'s Club" class="icon"><strong>'+data.storename+'</strong>';
		}else if (data.type == 'sw'){
	    	w_html += "<strong>Safeway</strong>";
		}else if (data.type == 'vo'){
	    	w_html += "<strong>Von's</strong>";
		}
		
		if(data.lots){
			w_html += "<ul>";
			for ( var m in data.lots ){
				w_html += '<li><a href="/wine/lot/' + data.lots[m] + '/">Lot ' + data.lots[m] + '</a> ' + wineData[data.lots[m]] + '</li>';
			}
			w_html += '</ul>';
			w_html += "Please call retailer at "+data.storephone+" to ensure availability.";
	
		} else {
			if(data.type != 'c' && data.type != 's'){
				w_html += '<br><br>Please contact the location for wines available:<br><br> <strong>' + data.storephone + '</strong>';
			} else {
				w_html += '<br><br>More Cameron Hughes Wine deliveries coming soon to this location!';
				w_html += '<br><br>You can also buy online now in our <a href="http://store.chwine.com/" target="_blank">Web Store</a>.';
			}
		}
	
		return w_html;
	}

	function createLocationHTML(data){
	
		loc_html = "<div class=\"tab_location\">";
	
		if(data.type == 'c') {
	    	loc_html += '<img src="/img/logo_costco.gif" alt="Costco" class="icon"><strong>Costco</strong>';
		}else if (data.type == 'bm'){
			loc_html += '<strong>' + data.storename + '</strong>';
		}else if (data.type == 's'){
	    	loc_html += '<img src="/img/logo_sams.gif" alt="Sam\'s Club" class="icon"><strong>Sam\'s Club</strong>';
		}else if (data.type == 'sw'){
	    	loc_html += "<strong>Safeway</strong>";
		}else if (data.type == 'vo'){
	    	loc_html += "<strong>Von's</strong>";
		}
	
		loc_html += "<br>" + data.address + "<br>";
		loc_html += data.city + ", " + data.state + " " + data.zipcode; 
		loc_html += '<br><br><strong>Phone:</strong> ' + data.storephone;
		loc_html += '<br><br><a href="http://maps.google.com/maps?q='+ data.address +'+'+data.city+'+'+data.state+'+'+data.zipcode+'" title="View on Google Maps" target="_blank">Directions</a>';
		loc_html += "</div>";
		return loc_html;
	
	}



	  // ================================================================
	  // === Define the function thats going to process the JSON file ===
	  function process_it(doc) {
		
	    var jsonData = eval('(' + doc + ')');

	    for (var i=0; i<jsonData.markers.length; i++) {
			locationtab = createLocationHTML(jsonData.markers[i]);
			winetab = createWineHTML(jsonData.markers[i]);

			var marker = createMarker(jsonData.markers[i],winetab,locationtab);
			
				map.addOverlay(marker);
			
	    }

	  }          

	  // ================================================================
	  // === Fetch the JSON data file ====    
	  GDownloadUrl("/wine/locator/zip:"+zip+"?lot="+lot+"&type="+type+"&data=1", process_it);
	  // ================================================================




	}

	else {
	  alert("Sorry, the Google Maps API is not compatible with this browser");
	}
