var map;
var geocoder;
var storage_info;
var mylocations=new Array();
mylocations[0]={'loc_id':'twofriends', 'coordinates':'30.881086,-83.296194', 'lat':'30.881086', 'lng':'-83.296194', 'address':'Summit Pointe 3338-B Country Club Rd.<br>Valdosta, GA', 'bubble':'<h4>Two Friends Cafe and Market</h4>Summit Pointe 3338-B Country Club Rd.<br>Valdosta, GA<br /><br />(229)242.3282<br /><br />'};


function initialize_add_all() {
	var map = new GMap2(document.getElementById("map_canvas"));
	map.setCenter(new GLatLng(33.490766,-84.432378), 8);
	geocoder = new GClientGeocoder();
	map.addControl(new GLargeMapControl());
	var mapControl = new GMapTypeControl();
	map.addControl(mapControl);

	for (var i=0; i<mylocations.length; i++) {
		storage_info = mylocations[i].bubble;
        var point = new GLatLng(mylocations[i].lat, mylocations[i].lng);
		marker = new GMarker(point);
		var address = '<div id="location_info"' +  storage_info  + 'Enter your address to get directions to this location:' + '<form action="http://maps.google.com/maps" method="get" target="_blank">' +
                     	'<input type="text" size=40 maxlength=40 name="saddr" id="saddr" value="" /><br /><br />' +
                     	'<INPUT value="Get Directions" TYPE="SUBMIT">' +
                     	'<input type="hidden" name="daddr" value="' + mylocations[i].coordinates + '" /></form></div>';
     	map.addOverlay(marker);
	}
}

function showLocationByLocID(locid) {
	var map = new GMap2(document.getElementById("map_canvas"));
	map.setCenter(new GLatLng(32.53109,-84.96502), 8);
	geocoder = new GClientGeocoder();
	map.addControl(new GLargeMapControl());
	var mapControl = new GMapTypeControl();
	map.addControl(mapControl);

	for (var i=0; i<mylocations.length; i++) {
		if(mylocations[i].loc_id == locid) {
			storage_info = mylocations[i].bubble;
			var point = new GLatLng(mylocations[i].lat, mylocations[i].lng);
			map.setCenter(new GLatLng(mylocations[i].lat, mylocations[i].lng), 15);
			marker = new GMarker(point);
			var address = '<div id="location_info"' +  storage_info  + 'Enter you address to get directions to this location:' + '<form action="http://maps.google.com/maps" method="get" target="_blank">' +
	      	              	'<input type="text" size=40 maxlength=40 name="saddr" id="saddr" value="" /><br /><br />' +
	      	              	'<INPUT value="Get Directions" TYPE="SUBMIT">' +
	      	              	'<input type="hidden" name="daddr" value="' + mylocations[i].coordinates + '" /></form></div>';
			map.addOverlay(marker);
			marker.openInfoWindowHtml(address);
		}
	}
 }
