// Check to see if this browser can run the Google API
if (GBrowserIsCompatible()) {

var sidebar_html = "";
var gmarkers = [];
var htmls = [];
var i=0;
           
// this variable will collect the html which will eventually be placed in the sidebar
var sidebar_html = "";


// Create our "tiny" map marker icon
var icon = new GIcon();
icon.image = "http://maps.google.com/mapfiles/kml/pal5/icon13.png";
icon.shadow = "http://maps.google.com/mapfiles/kml/pal5/icon13s.png";
icon.iconSize=new GSize(32,32);
icon.shadowSize=new GSize(56,32);
icon.iconAnchor=new GPoint(16,32);
icon.infoWindowAnchor=new GPoint(16,0);
//icon.infoshadowAnchor = new GPoint (15,32);


// A function to create the marker and prepare the event window
function createMarker(point,name,html) {
	var marker = new GMarker(point,icon);
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(html);
	});
       
        
// save the info we need to use later for the sidebar
	gmarkers[i] = marker;
	htmls[i] = html;
	// add a line to the sidebar html
	sidebar_html += '<a href="javascript:myclick(' + i + ')">' + name + '</a>';
	i++;
	return marker;
	}


// This function picks up the click and opens the corresponding info window
	function myclick(i) {
	map.panTo(gmarkers[i].getLatLng());
	}


// Display the map, with some controls and set the initial location 
	var map = new GMap2(document.getElementById("map"));
	//map.addControl(new GLargeMapControl());
	//map.addControl(new GMapTypeControl());
	map.addMapType(G_PHYSICAL_MAP);
	map.setCenter
	(new GLatLng(33.999996,-118.476314),13);
    

// Set up markers 
	var point = new GLatLng(33.999996,-118.476314);
	var marker = createMarker(point,"brandbuero USA","<h3>brandbuero USA</h3><a href=\"http://www.brandbuero.com\" title=\"Jump to brandbuero USA\" class=\"tooltip\">Visit website (english)</a>")
	map.addOverlay(marker);
      
	var point = new GLatLng(50.956477,6.918022);
	var marker = createMarker(point,'brandbuero Germany',"<h3>brandbuero Germany</h3><a href=\"http://www.brandbuero.de\" title=\"Jump to brandbuero Germany\" class=\"tooltip\">Visit website (german)</a>")
	map.addOverlay(marker);


// put the assembled sidebar_html contents into the sidebar div
	document.getElementById("sidebar").innerHTML = sidebar_html;
	}
    
// display a warning if the browser was not compatible
else {
	alert("Sorry, the Google Maps API is not compatible with the browser you are using");
}
