﻿// JScript File


var map = null;
var geocoder = null;
var address = "";
var showmap = 1;

window.onload = function() {
    if (showmap == 1) {
        address = document.getElementById("address").innerHTML;
        var getdir = document.getElementById("getdirlink");

        if (address != ", " && address.substring(0, address.lastIndexOf(',')).length > 9) {

            document.getElementById("address").style.display = "block";
            document.getElementById("gmap").style.display = "block";
            showAddress();
        } else {
            getdir.setAttribute("style", "display:none;");
        }
    }
}

function showAddress() {
    address = document.getElementById("address").innerHTML;
           
	//map.addControl(new GSmallMapControl());
    
            if (GBrowserIsCompatible() && map == null) {
                map = new GMap2(document.getElementById("gmap"));
         //       map.setCenter(new GLatLng(21.279457309948135,-157.82727241516113 ), 13);
                geocoder = new GClientGeocoder();
            }
  
  if (geocoder) {
  
    geocoder.getLatLng(
      address,
      function(point) {
         if (!point) {
          //alert(address + " not found");
        } else {
		  map.setCenter(point, 13);
          var marker = new GMarker(point);
          map.addOverlay(marker);
          marker.openInfoWindowHtml(address);/**/
          
        }
      }
    );
  }
   map.setUIToDefault();
}
 
