﻿var map = null;
var geocoder = null;
var lastMap;

function showAddress(address, container, url) {
    var newAddy = address.replace(",", "<br />");
    var webSite = url;
    if (webSite.length > 0) {
        newAddy += "<br />" + '<a target="_blank" href="' + url + '">Store Website</a>';
    }
    newAddy += "<br />" + '<a target="_blank" href="http://maps.google.com/?daddr=' + address + '">Directions</a>';
    var canvas = document.getElementById(container);
    if (lastMap != null) {
        lastMap.style.display = "none";
    }
    lastMap = canvas;
    if (GBrowserIsCompatible()) {
        map = new GMap2(canvas);
        geocoder = new GClientGeocoder();
    }
    if (geocoder) {
        geocoder.getLatLng(
  address,
  function(point) {
            if (!point) {
                alert(address + " not found");
            } else {
                map.setCenter(point);
                //create icon
                var plIcon = new GIcon(G_DEFAULT_ICON);
                plIcon.image = "http://www.prolite.com/img/pl-logo.gif";
                var iSize = new GSize(50, 22);
                plIcon.iconSize = iSize;
                markerOptions = { icon: plIcon };
                var marker = new GMarker(point, markerOptions);
                map.addOverlay(marker);
                map.addControl(new GSmallMapControl());
                map.addControl(new GMapTypeControl());
                marker.openInfoWindowHtml(newAddy);
                map.setZoom(13);
                map.setCenter(point);
                map.checkResize();
            }
        }
);
    }

    canvas.style.display = "";
    canvas.focus();
}




        
   
