var map = null;
var defaultzoom = 7;
var localzoom = 15;
var baseicon = '';
var personicon = '';


function create_map(element, center, zoom, enabled, satelite)
{
  map = new GMap2(element);
  zoom = zoom || defaultzoom;
  satelite = satelite || false;

  if(satelite)
  {
    map.setMapType (G_SATELLITE_MAP);
  }

  if (enabled == true)
  {
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    map.enableScrollWheelZoom();
  }
  else
  {
    map.disableDoubleClickZoom();
    map.disableDragging();
    map.disableInfoWindow();
  }

  map.setCenter(center, zoom);
}

function create_icon()
{
  var icon = new GIcon();
  icon.image = 'resources/images/styles/marker.png';
  icon.shadow = '/resources/images/styles/marker_shadow.png';
  icon.iconSize = new GSize(12, 12);
  icon.shadowSize = new GSize(20, 12);
  icon.iconAnchor = new GPoint(6, 12);
  icon.infoWindowAnchor = new GPoint(5, 1);
  return icon;
}

function create_person_icon()
{
  var icon = new GIcon();
  icon.image = '/resources/images/styles/marker_person.png';
  icon.shadow = '/resources/images/styles/marker_shadow.png';
  icon.iconSize = new GSize(11, 24);
  icon.shadowSize = new GSize(20, 12);
  icon.iconAnchor = new GPoint(6, 12);
  icon.infoWindowAnchor = new GPoint(5, 1);
  return icon;
}

function createMarker(lat,long,txt,person)
{
  var point  = new GLatLng(lat,long);
  var marker = person
               ? new GMarker(point, {icon:personicon})
               : new GMarker(point, {icon:baseicon});
  
  GEvent.addListener(marker, "click", function()
  {
    marker.openInfoWindowHtml(txt);
  });
  return marker;
}
