function addMarkers(){
mySelect = document.getElementById('selection');
Albuquerque = [];Truth_Or_Consequences = [];Bosque_Farms = [];Brimhall = [];Santa_Fe = [];Rio_Rancho = [];Eunice = [];Grants = [];Hobbs = [];Los_Lunas = [];Mountainair = [];Farmington = [];Espanola = [];Cuba = [];Roswell = [];Gallup = [];mySelect.options[mySelect.options.length] = new Option("Albuquerque schools",'all=Albuquerque');
mySelect.options[mySelect.options.length] = new Option("Bosque Farms schools",'all=Bosque_Farms');
mySelect.options[mySelect.options.length] = new Option("Brimhall schools",'all=Brimhall');
mySelect.options[mySelect.options.length] = new Option("Cuba schools",'all=Cuba');
mySelect.options[mySelect.options.length] = new Option("Espanola schools",'all=Espanola');
mySelect.options[mySelect.options.length] = new Option("Eunice schools",'all=Eunice');
mySelect.options[mySelect.options.length] = new Option("Farmington schools",'all=Farmington');
mySelect.options[mySelect.options.length] = new Option("Gallup schools",'all=Gallup');
mySelect.options[mySelect.options.length] = new Option("Grants schools",'all=Grants');
mySelect.options[mySelect.options.length] = new Option("Hobbs schools",'all=Hobbs');
mySelect.options[mySelect.options.length] = new Option("Los Lunas schools",'all=Los_Lunas');
mySelect.options[mySelect.options.length] = new Option("Mountainair schools",'all=Mountainair');
mySelect.options[mySelect.options.length] = new Option("Rio Rancho schools",'all=Rio_Rancho');
mySelect.options[mySelect.options.length] = new Option("Roswell schools",'all=Roswell');
mySelect.options[mySelect.options.length] = new Option("Santa Fe schools",'all=Santa_Fe');
mySelect.options[mySelect.options.length] = new Option("Truth Or Consequences schools",'all=Truth_Or_Consequences');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.70368300,35.05135600),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Abundant Life Christian School",'Albuquerque=' + Albuquerque.length);
Truth_Or_Consequences[Truth_Or_Consequences.length] = createMarker(new GPoint(-107.26695100,33.12195200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Apple Tree Educational Center",'Truth_Or_Consequences=' + Truth_Or_Consequences.length);
Bosque_Farms[Bosque_Farms.length] = createMarker(new GPoint(-106.69360700,34.86246300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bosque Farms Christian Academy",'Bosque_Farms=' + Bosque_Farms.length);
Brimhall[Brimhall.length] = createMarker(new GPoint(-108.59460000,35.80180000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Indian Mission School",'Brimhall=' + Brimhall.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.95299200,35.65213700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Life Academy",'Santa_Fe=' + Santa_Fe.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.59399100,35.14874400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cornerstone Christian Academy",'Albuquerque=' + Albuquerque.length);
Rio_Rancho[Rio_Rancho.length] = createMarker(new GPoint(-106.65421600,35.23279800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Covenant School Of Rio Rancho",'Rio_Rancho=' + Rio_Rancho.length);
Eunice[Eunice.length] = createMarker(new GPoint(-103.16250000,32.44460000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eunice Holiness Academy",'Eunice=' + Eunice.length);
Grants[Grants.length] = createMarker(new GPoint(-107.84560000,35.25530000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grants Christian Academy",'Grants=' + Grants.length);
Hobbs[Hobbs.length] = createMarker(new GPoint(-103.16236700,32.72078200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hobbs Holiness Academy",'Hobbs=' + Hobbs.length);
Los_Lunas[Los_Lunas.length] = createMarker(new GPoint(-106.69220000,34.77610000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Miracle Center",'Los_Lunas=' + Los_Lunas.length);
Mountainair[Mountainair.length] = createMarker(new GPoint(-106.24250000,34.50020000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Beginnings Christian Academy",'Mountainair=' + Mountainair.length);
Farmington[Farmington.length] = createMarker(new GPoint(-108.20530500,36.72186300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Haven Christian Academy",'Farmington=' + Farmington.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.71515800,35.19389700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Paradise Christian School",'Albuquerque=' + Albuquerque.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.69597400,35.01203700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rio Grande Christian Academy",'Albuquerque=' + Albuquerque.length);
Espanola[Espanola.length] = createMarker(new GPoint(-106.07780000,35.98800000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rock Christian Academy",'Espanola=' + Espanola.length);
Cuba[Cuba.length] = createMarker(new GPoint(-107.22090000,35.89440000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rock Springs Holiness School",'Cuba=' + Cuba.length);
Roswell[Roswell.length] = createMarker(new GPoint(-104.51398800,33.43777500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Roswell Baptist Academy",'Roswell=' + Roswell.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.97396800,35.65159000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Temple Baptist Christian School",'Santa_Fe=' + Santa_Fe.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.69893200,35.15273700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Christian Academy",'Albuquerque=' + Albuquerque.length);
Espanola[Espanola.length] = createMarker(new GPoint(-106.03122400,35.96983700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Valley Baptist Academy",'Espanola=' + Espanola.length);
Hobbs[Hobbs.length] = createMarker(new GPoint(-103.13372600,32.69660200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Victory Center Chris",'Hobbs=' + Hobbs.length);
Gallup[Gallup.length] = createMarker(new GPoint(-108.79760000,35.46030000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wildcat Christian Academy",'Gallup=' + Gallup.length);
map.removeOverlays(Albuquerque);
map.removeOverlays(Bosque_Farms);
map.removeOverlays(Brimhall);
map.removeOverlays(Cuba);
map.removeOverlays(Espanola);
map.removeOverlays(Eunice);
map.removeOverlays(Farmington);
map.removeOverlays(Gallup);
map.removeOverlays(Grants);
map.removeOverlays(Hobbs);
map.removeOverlays(Los_Lunas);
map.removeOverlays(Mountainair);
map.removeOverlays(Rio_Rancho);
map.removeOverlays(Roswell);
map.removeOverlays(Santa_Fe);
map.removeOverlays(Truth_Or_Consequences);
setTimeout(function(){map.addOverlays(Albuquerque)},1000);
setTimeout(function(){map.addOverlays(Bosque_Farms)},1000);
setTimeout(function(){map.addOverlays(Brimhall)},1000);
setTimeout(function(){map.addOverlays(Cuba)},1000);
setTimeout(function(){map.addOverlays(Espanola)},1000);
setTimeout(function(){map.addOverlays(Eunice)},1000);
setTimeout(function(){map.addOverlays(Farmington)},1000);
setTimeout(function(){map.addOverlays(Gallup)},1000);
setTimeout(function(){map.addOverlays(Grants)},1000);
setTimeout(function(){map.addOverlays(Hobbs)},1000);
setTimeout(function(){map.addOverlays(Los_Lunas)},1000);
setTimeout(function(){map.addOverlays(Mountainair)},1000);
setTimeout(function(){map.addOverlays(Rio_Rancho)},1000);
setTimeout(function(){map.addOverlays(Roswell)},1000);
setTimeout(function(){map.addOverlays(Santa_Fe)},1000);
setTimeout(function(){map.addOverlays(Truth_Or_Consequences)},1000);
maxLng = -103.13372600;
maxLat = 36.72186300;
minLng = -108.79760000;
minLat = 32.44460000;
reCenterMap();
} // End addStateMarkers JavaScript Function
// Takes an array of markers and centers/zooms map based on marker range
function centerByArray(myArray, recenter, newMaxMin)
{
if (newMaxMin == true)
reMaxMin(myArray);
for (var i = 0; i < myArray.length; i++)
{
var markLng = myArray[i].getPoint().x;
var markLat = myArray[i].getPoint().y;
if (markLat > maxLat) maxLat = markLat;
if (markLng > maxLng) maxLng = markLng;
if (markLat < minLat) minLat = markLat;
if (markLng < minLng) minLng = markLng;
}
if (recenter)
reCenterMap();
}
// Reinit max/mins
function reMaxMin(myArray)
{
maxLng = myArray[0].getPoint().x;
maxLat = myArray[0].getPoint().y;
minLng = myArray[0].getPoint().x;
minLat = myArray[0].getPoint().y;
}
// Recenter map based on global max/mins
function reCenterMap()
{
var bounds = new GLatLngBounds();
bounds.extend(new GLatLng(minLat, minLng));
bounds.extend(new GLatLng(maxLat, maxLng));
var center_lat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) / 2.0;
var center_lng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) / 2.0;
var center = new GLatLng(center_lat, center_lng);
var zoom = map.getBoundsZoomLevel(bounds);
map.setCenter(center,zoom);
//map.setCenter(center,11);
/*
var center = new GPoint( (maxLng + minLng)/2, (maxLat+minLat)/2 );
var delta = new GSize(maxLng - minLng, maxLat - minLat);
var minZoom = map.spec.getLowestZoomLevel(center, delta, map.viewSize);
if (minZoom < 4) minZoom = 4; // Lowest possible zoom is 4
map.centerAndZoom(center, minZoom);
*/
}
// Fires when drop down list of schools changes
function selectChange(selection)
{
var myVal = selection.options[selection.selectedIndex].value;
map.closeInfoWindow();
// Add entire array based on variable type
if (myVal.indexOf('all') != -1 && myVal != 'all')
{
var temp = myVal.split('=');
var showArray = temp[1];
// If Array is > X amount of markers, then open in a new page
if (eval(showArray).length > 20)
// New window depends on whether or not we're on the search page
if (location.href.indexOf('nearby_schools.php') == -1)
window.open(location.href + '/map/' + showArray);
else
window.open('/search//////' + showArray);
map.removeOverlays(Albuquerque);
map.removeOverlays(Bosque_Farms);
map.removeOverlays(Brimhall);
map.removeOverlays(Cuba);
map.removeOverlays(Espanola);
map.removeOverlays(Eunice);
map.removeOverlays(Farmington);
map.removeOverlays(Gallup);
map.removeOverlays(Grants);
map.removeOverlays(Hobbs);
map.removeOverlays(Los_Lunas);
map.removeOverlays(Mountainair);
map.removeOverlays(Rio_Rancho);
map.removeOverlays(Roswell);
map.removeOverlays(Santa_Fe);
map.removeOverlays(Truth_Or_Consequences);
map.addOverlays(eval(showArray));
centerByArray(eval(showArray), true, true); // Center and zoom on set of markers
}
// Add individual markers
if (myVal.indexOf('all') == -1 && myVal != 'all' && myVal.length)
{
var temp = myVal.split('=');
var myArray = temp[0];
var myIndex = parseInt(temp[1]) - 1;
document.getElementById('map').width = "750";
map.removeOverlay(eval(myArray)[myIndex]);
map.addOverlay(eval(myArray)[myIndex]);
GEvent.trigger(eval(myArray)[myIndex],'click');
}
// Show all markers
if (myVal == 'all')
{
cntMarker = 0;
reMaxMin(Albuquerque);map.removeOverlays(Albuquerque);
map.removeOverlays(Bosque_Farms);
map.removeOverlays(Brimhall);
map.removeOverlays(Cuba);
map.removeOverlays(Espanola);
map.removeOverlays(Eunice);
map.removeOverlays(Farmington);
map.removeOverlays(Gallup);
map.removeOverlays(Grants);
map.removeOverlays(Hobbs);
map.removeOverlays(Los_Lunas);
map.removeOverlays(Mountainair);
map.removeOverlays(Rio_Rancho);
map.removeOverlays(Roswell);
map.removeOverlays(Santa_Fe);
map.removeOverlays(Truth_Or_Consequences);
map.addOverlays(Albuquerque);
centerByArray(Albuquerque, false, false);
cntMarker += Albuquerque.length;
map.addOverlays(Bosque_Farms);
centerByArray(Bosque_Farms, false, false);
cntMarker += Bosque_Farms.length;
map.addOverlays(Brimhall);
centerByArray(Brimhall, false, false);
cntMarker += Brimhall.length;
map.addOverlays(Cuba);
centerByArray(Cuba, false, false);
cntMarker += Cuba.length;
map.addOverlays(Espanola);
centerByArray(Espanola, false, false);
cntMarker += Espanola.length;
map.addOverlays(Eunice);
centerByArray(Eunice, false, false);
cntMarker += Eunice.length;
map.addOverlays(Farmington);
centerByArray(Farmington, false, false);
cntMarker += Farmington.length;
map.addOverlays(Gallup);
centerByArray(Gallup, false, false);
cntMarker += Gallup.length;
map.addOverlays(Grants);
centerByArray(Grants, false, false);
cntMarker += Grants.length;
map.addOverlays(Hobbs);
centerByArray(Hobbs, false, false);
cntMarker += Hobbs.length;
map.addOverlays(Los_Lunas);
centerByArray(Los_Lunas, false, false);
cntMarker += Los_Lunas.length;
map.addOverlays(Mountainair);
centerByArray(Mountainair, false, false);
cntMarker += Mountainair.length;
map.addOverlays(Rio_Rancho);
centerByArray(Rio_Rancho, false, false);
cntMarker += Rio_Rancho.length;
map.addOverlays(Roswell);
centerByArray(Roswell, false, false);
cntMarker += Roswell.length;
map.addOverlays(Santa_Fe);
centerByArray(Santa_Fe, false, false);
cntMarker += Santa_Fe.length;
map.addOverlays(Truth_Or_Consequences);
centerByArray(Truth_Or_Consequences, false, false);
cntMarker += Truth_Or_Consequences.length;
centerByArray(Albuquerque,true, false);
if (cntMarker > 20)
// New window depends on whether or not we're on the search page
if (location.href.indexOf('schools-by-distance') == -1)
window.open(location.href + '/map/all');
else
window.open('/search///18392,18431,18514,18523,18584,18407,18415,18525,18581,18449,18501,18593,18460,33182,18491,18500,18425,18572,18392,18431,18514,18523,18584,18407,18415,18525,18581,18585,18449,18501,18593,33182,33183,18491,18500,35174,33181,18425,18572,18404,/all');
//window.open('/map.php?type=2&schools=18392,18431,18514,18523,18584,18407,18415,18525,18581,18449,18501,18593,18460,33182,18491,18500,18425,18572,18392,18431,18514,18523,18584,18407,18415,18525,18581,18585,18449,18501,18593,33182,33183,18491,18500,35174,33181,18425,18572,18404,&school_level=&radius=&zipcode=&school_type_search=&school_type_code=');
}
}
function createMarker(point, label, icon)
{
var marker = new GMarker(point, icon);
var html = label;
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}