﻿/* firstone_template */
function showGoogleMapByLatLon(lat, lon, mapEl, streetViewEl) 
{
    var loc = new GLatLng(lat, lon);
    showGoogleMap(loc, mapEl, streetViewEl);
}
function showGoogleMapByAddress(address, mapEl, streetViewEl)
{
    var geocoder = new GClientGeocoder();
    if (geocoder) {
        geocoder.getLatLng(address, function(point) {
            if (!point)
            {
                //not found error
                alert('no point');   
            }
            else
            {
                showGoogleMap(point, mapEl, streetViewEl);
            }
        }
        )};
}
function showGoogleMap(loc, mapEl, streetViewEl) 
{
  if (GBrowserIsCompatible()) 
  {
    var map = new GMap2(document.getElementById(mapEl));
    map.setCenter(loc, 13);
    map.setUIToDefault();
    var marker = new GMarker(loc, G_DEFAULT_ICON, true);
    map.addOverlay(marker);

    streetviewOptions = { latlng:loc };
    streetview = new GStreetviewPanorama(document.getElementById(streetViewEl), streetviewOptions);
    GEvent.addListener(streetview, "error", handleNoFlash);
  }
}
  function handleNoFlash(errorCode) {
  if (errorCode == FLASH_UNAVAILABLE) {
      alert("Error: Flash doesn't appear to be supported by your browser");
      return;
      }
}

function coalesceForAddress(newValue)
{
    if (newValue != null && newValue != "")
    {
        return ", " + newValue;
    }
    else
        return "";
}