
function initialize(){if(GBrowserIsCompatible()){var map=new GMap2(document.getElementById(opt.map.id));var geocoder=new GClientGeocoder();geocoder.getLocations(opt.map.centerAddress,setCenter);map.addControl(new GSmallMapControl());map.addControl(new GMapTypeControl());geocoder.getLocations(opt.markers[0].address,addToMapCall(0));}
function addWindowCall(i)
{return(function(data,response){addWindow(data,response,i)})}
function addWindow(gcode,response,i){var p=gcode.Placemark[0];var point=new GLatLng(p.Point.coordinates[1],p.Point.coordinates[0]);map.openInfoWindow(point,document.createTextNode(opt.infoWindows[i].content));}
function addToMapCall(i)
{return(function(data,response){addToMap(data,response,i)})}
function addToMap(gcode,response,i){if(gcode.Placemark==undefined){geocoder.getLocations(opt.markers[i].address,addToMapCall(i));return;}else var p=gcode.Placemark[0];var point=new GLatLng(p.Point.coordinates[1],p.Point.coordinates[0]);var myIcon=new GIcon(G_DEFAULT_ICON);if(opt.markers[i].icon!=null)myIcon.image=opt.markers[i].icon;markerOptions={icon:myIcon};var marker=new GMarker(point,markerOptions);if(opt.markers[i].infoWindow!=null&&opt.markers[i].event!=null){GEvent.addListener(marker,opt.markers[i].event,function(){map.openInfoWindowHtml(point,opt.markers[i].infoWindow);});}
map.addOverlay(marker);var s=(i+1);try{if(opt.markers[s].address!=undefined){geocoder.getLocations(opt.markers[s].address,addToMapCall(s));}}catch(e){}}
function setCenter(gcode)
{var p=gcode.Placemark[0];map.setCenter(new GLatLng(p.Point.coordinates[1],p.Point.coordinates[0]),opt.map.zoom);}}