var map;
var baseIcon;

//This function initiates the map and calls the marker placement function
//The info box for the first location is then displayed
function load() {

if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(markersX[0],markersY[0]), 15);

// Create a base icon for all of our markers that specifies the
// shadow, icon dimensions, etc.
baseIcon = new GIcon();
baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
baseIcon.infoShadowAnchor = new GPoint(18, 25);

addmarkerlist();
addinfobox(0);
enClick();

}
}



// Creates a marker whose info window displays the letter corresponding
// to the given index.
function createMarker(point, index) {
// Create a lettered icon for this point using our icon class
var letter = String.fromCharCode("A".charCodeAt(0) + index);
var letteredIcon = new GIcon(baseIcon);
letteredIcon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
// Set up our GMarkerOptions object
markerOptions = { icon:letteredIcon };
var marker = new GMarker(point, markerOptions);
return marker;
}


//This function adds a marker at specified co-ords and returns the marker object
function addmarkerToMap(xcord,ycord,letter) {
point = new GLatLng(xcord,ycord);
if (letter == 0 ) {markerID = new GMarker(point);}
else {markerID = new createMarker(point,letter-1);}
map.addOverlay(markerID);
return markerID;
}

//This function adds the markers to the Map - called by the load function
function addmarkerlist() {
for(var i = 0; i < locCount; i++) {
markers[i] = addmarkerToMap(markersX[i],markersY[i],i);
}
//gevents were here
}


//This function pops up the infobox for the indexed marker
function addinfobox(locator) {
markers[locator].openInfoWindowHtml(captions[locator]);
}

function showShrtname(locator) {
document.write(String.fromCharCode('A'.charCodeAt(0) + locator -1)+'.  '+shrtname[locator]);
}

function showMaptitle() {
document.write("<h2>" + shrtname[0]+ " Location Map <h2>");
}

function showDescription() {
document.write("<span style='FONT-SIZE:14px'><strong>" + longname + "</strong></span><br>" + postadd + "<br>" + fone + "<br>" + descrip);
//document.write("<strong>longname + "</strong><br>" + postadd + "<br>" + fone + "<br>" + descrip);
}

function showlandmarks() {
for(var i = 1; i < locCount; i++) {
document.write("<a href='javascript:void(0);' onclick='addinfobox("+String.fromCharCode('0'.charCodeAt(0) + i)+");return false'>");
showShrtname(i);
document.write("</a><br>");
}
}