/* site variables
-------------------------------------------------- */
var map;
var centerLatitude = 43.5;
var centerLongitude = -80.5;
var startZoom = 7;

// create the overlay icon
var defaultIcon = new GIcon();
defaultIcon.image = "/theme/myhood/i/pins/red_pin.png";
defaultIcon.iconSize = new GSize(19, 32);
defaultIcon.iconAnchor = new GPoint(6, 20);
defaultIcon.infoWindowAnchor = new GPoint(6, 1);

/* site functions
-------------------------------------------------- */
function createmarker(lat,lng){
  // clear icons on map
  map.clearOverlays();
  
  // plot a point using the lat and lng
  var location = new GLatLng(lat, lng);
  map.setCenter(location,16);
  
  var marker = new GMarker(location,defaultIcon);
  
  map.addOverlay(marker);
} // end createmarker function


function init(){
  map = new GMap2($("small_map"));
  //map.addControl(new GSmallMapControl());
  map.setCenter(new GLatLng(centerLatitude, centerLongitude), startZoom);
  
  var lat, lng;
  
  if($('lat')){
    if($('lat').value != ''){
      lat = $('lat').value;
    } // end if
  } // end if
  
  if($('lng')){
    if($('lng').value != ''){
      lng = $('lng').value;
    } // end if
  } // end if
  
  // add marker
  if(lat != "" && lng != ""){
    createmarker(lat,lng);
  } //end if

}

addEvent(window,'load',init);
addEvent(window,'unload',EventCache.flush);