function addMarkers(){
mySelect = document.getElementById('selection');
Memphis = [];Eads = [];Germantown = [];Cordova = [];Millington = [];Arlington = [];Collierville = [];mySelect.options[mySelect.options.length] = new Option("Arlington schools",'all=Arlington');
mySelect.options[mySelect.options.length] = new Option("Collierville schools",'all=Collierville');
mySelect.options[mySelect.options.length] = new Option("Cordova schools",'all=Cordova');
mySelect.options[mySelect.options.length] = new Option("Eads schools",'all=Eads');
mySelect.options[mySelect.options.length] = new Option("Germantown schools",'all=Germantown');
mySelect.options[mySelect.options.length] = new Option("Memphis schools",'all=Memphis');
mySelect.options[mySelect.options.length] = new Option("Millington schools",'all=Millington');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Memphis[Memphis.length] = createMarker(new GPoint(-90.01468600,35.02086300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bishop Byrne Middle High School",'Memphis=' + Memphis.length);
Eads[Eads.length] = createMarker(new GPoint(-89.72804900,35.12950000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Briarcrest Christian High School",'Eads=' + Eads.length);
Eads[Eads.length] = createMarker(new GPoint(-89.72305900,35.11709000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Briarcrest Christian School",'Eads=' + Eads.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.77544700,35.20484000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brunswick Day School At Lakesi",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.84306400,35.04458000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Baptist Academy",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.88110400,35.18488900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Baptist School",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.77022900,35.04803700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ The Rock Christian Academy",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.86429900,35.13099800),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Christian Brothers High School",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.89717200,35.13074000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Concord Academy Inc",'Memphis=' + Memphis.length);
Germantown[Germantown.length] = createMarker(new GPoint(-89.81058100,35.08733700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Daybreak Specialized School",'Germantown=' + Germantown.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.92257700,35.08464800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Elliston Baptist Academy",'Memphis=' + Memphis.length);
Cordova[Cordova.length] = createMarker(new GPoint(-89.77610000,35.15550000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Evangelical Christian School",'Cordova=' + Cordova.length);
Millington[Millington.length] = createMarker(new GPoint(-89.90180000,35.34100000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Heritage Christian Academy",'Millington=' + Millington.length);
Cordova[Cordova.length] = createMarker(new GPoint(-89.77426500,35.12764000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Assembly Christian School",'Cordova=' + Cordova.length);
Memphis[Memphis.length] = createMarker(new GPoint(-90.00338100,35.22986400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Frayser Academy Of Christian Education",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.91134900,35.15357000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Christian School",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.91880800,35.17238700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grey Road Christian Academy",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.91572000,35.10002400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harding Academy Of Memphis",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-90.03195500,35.16459300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Helicon School @ Porterheath",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.92938900,35.17819500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heritage Baptist Academy",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.85850400,35.09172900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hutchison School",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-90.00431100,35.12612400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Immaculate Comception Mid. - High School",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.85168700,35.11078400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lausanne Collegiate School",'Memphis=' + Memphis.length);
Millington[Millington.length] = createMarker(new GPoint(-89.94179700,35.35186500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lighthouse Christian Academy",'Millington=' + Millington.length);
Germantown[Germantown.length] = createMarker(new GPoint(-89.82983300,35.09698500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Madonna Learning Center",'Germantown=' + Germantown.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.88763100,35.12073900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Margolin Hebrew Academy",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-90.05358000,35.16191200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maria Montessori School",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.99963300,35.13928000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Memphis Cath High School - Middle School",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.89829900,35.13219600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Memphis Junior Academy",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-90.01936900,35.14432400),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Memphis Recovery Center",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.85625600,35.09959300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Memphis University School",'Memphis=' + Memphis.length);
Arlington[Arlington.length] = createMarker(new GPoint(-89.68823000,35.20465500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Morris Wilson Campus School",'Arlington=' + Arlington.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.81612000,35.23565800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nicholas Hobbs Academy",'Memphis=' + Memphis.length);
Germantown[Germantown.length] = createMarker(new GPoint(-89.81015700,35.08550800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Phoenix School For Creative Learning",'Germantown=' + Germantown.length);
Germantown[Germantown.length] = createMarker(new GPoint(-89.81016300,35.08551200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Phoenix School For Creative Lrng",'Germantown=' + Germantown.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.90123600,35.13107900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Agnes Academy-st Dominic School",'Memphis=' + Memphis.length);
Cordova[Cordova.length] = createMarker(new GPoint(-89.79058600,35.18760600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Benedict At Auburndale",'Cordova=' + Cordova.length);
Collierville[Collierville.length] = createMarker(new GPoint(-89.72993900,35.09533000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Georges Independent School",'Collierville=' + Collierville.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.89816700,35.14516300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shady Oaks School",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.93597200,35.05584900),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Shelby Training Center",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.90855700,35.12956500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("St Mary's Episcopal School",'Memphis=' + Memphis.length);
Millington[Millington.length] = createMarker(new GPoint(-89.77198100,35.36363900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tipton-rosemark Academy",'Millington=' + Millington.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.85777600,35.18230600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trafalgar Village Bapt Dc/kg",'Memphis=' + Memphis.length);
Millington[Millington.length] = createMarker(new GPoint(-89.96448100,35.29231400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woodlawn Baptist Academy",'Millington=' + Millington.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.94509800,35.08673800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Word Of Faith Christian Academy",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-90.04656100,35.13604600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Y.d.a.c.-mid-town Mental Health",'Memphis=' + Memphis.length);
Memphis[Memphis.length] = createMarker(new GPoint(-89.85127200,35.15557600),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Youth Habilitation Center",'Memphis=' + Memphis.length);
} // 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/////2/' + showArray);
map.removeOverlays(Arlington);
map.removeOverlays(Collierville);
map.removeOverlays(Cordova);
map.removeOverlays(Eads);
map.removeOverlays(Germantown);
map.removeOverlays(Memphis);
map.removeOverlays(Millington);
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(Memphis);map.removeOverlays(Arlington);
map.removeOverlays(Collierville);
map.removeOverlays(Cordova);
map.removeOverlays(Eads);
map.removeOverlays(Germantown);
map.removeOverlays(Memphis);
map.removeOverlays(Millington);
map.addOverlays(Arlington);
centerByArray(Arlington, false, false);
cntMarker += Arlington.length;
map.addOverlays(Collierville);
centerByArray(Collierville, false, false);
cntMarker += Collierville.length;
map.addOverlays(Cordova);
centerByArray(Cordova, false, false);
cntMarker += Cordova.length;
map.addOverlays(Eads);
centerByArray(Eads, false, false);
cntMarker += Eads.length;
map.addOverlays(Germantown);
centerByArray(Germantown, false, false);
cntMarker += Germantown.length;
map.addOverlays(Memphis);
centerByArray(Memphis, false, false);
cntMarker += Memphis.length;
map.addOverlays(Millington);
centerByArray(Millington, false, false);
cntMarker += Millington.length;
centerByArray(Memphis,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////all');
//window.open('/map.php?type=1&schools=&school_level=2&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;
}