﻿if (window.attachEvent)
{
    window.attachEvent("onload", 
        function() {
          window.attachEvent("onunload", GUnload);
        });
}
else
{
    window.addEventListener("load", 
        function() {
            
         window.addEventListener("unload", GUnload, false);
        }, 
        false);
}


var googlemap_pos;
var googlemap_marker;
var googlemap_loaded = false;
var map = null;


function showMap(latitude,longitude,office,address,address2, phone)
{
	
	googlemap_loaded = false;
	if (GBrowserIsCompatible()) {
	
    var map = new GMap2(document.getElementById("map"));

	    map.setCenter(new GLatLng(latitude,longitude), 16);

    	
        // Creates a marker whose info window displays the letter corresponding
        // to the given index.
        function createMarker(point, index) {
          // Create a lettered icon for this point using our icon class
          var letter = String.fromCharCode("X".charCodeAt(0) + index);
            // Create a base icon for all of our markers that specifies the
            // shadow, icon dimensions, etc.
            var baseIcon = new GIcon();
            baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
            baseIcon.iconSize = new GSize(20, 34);
            baseIcon.shadowSize = new GSize(37, 34);
            baseIcon.iconAnchor = new GPoint(9, 34);
            baseIcon.infoWindowAnchor = new GPoint(9, 2);
            baseIcon.infoShadowAnchor = new GPoint(18, 25);
                
          var icon = new GIcon(baseIcon);
          icon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
          var marker = new GMarker(point, icon);

          GEvent.addListener(marker, "mouseover", function() {
                
            marker.openInfoWindowHtml("<strong>" + office + "</strong><br/><br/>" + address + "<br/>" +  address2 + "<br/><br/><strong> Tel. </strong>" + phone);
            
          });
          return marker;
        }
	
        // Add 1 markers to the map at the location ]]>
	    var point = new GLatLng(latitude,longitude);
	    map.addOverlay(createMarker(point, 0));
    	
	    googlemap_loaded = true;
        map_open("map");
      
	}
}

