function addMarkers(){
mySelect = document.getElementById('selection');
Knoxville = [];Kingsport = [];Murfreesboro = [];Gallatin = [];Summertown = [];La_Grange = [];Morristown = [];Athens = [];Nashville = [];Grand_Junction = [];Rutledge = [];Arthur = [];Cleveland = [];mySelect.options[mySelect.options.length] = new Option("Arthur schools",'all=Arthur');
mySelect.options[mySelect.options.length] = new Option("Athens schools",'all=Athens');
mySelect.options[mySelect.options.length] = new Option("Cleveland schools",'all=Cleveland');
mySelect.options[mySelect.options.length] = new Option("Gallatin schools",'all=Gallatin');
mySelect.options[mySelect.options.length] = new Option("Grand Junction schools",'all=Grand_Junction');
mySelect.options[mySelect.options.length] = new Option("Kingsport schools",'all=Kingsport');
mySelect.options[mySelect.options.length] = new Option("Knoxville schools",'all=Knoxville');
mySelect.options[mySelect.options.length] = new Option("La Grange schools",'all=La_Grange');
mySelect.options[mySelect.options.length] = new Option("Morristown schools",'all=Morristown');
mySelect.options[mySelect.options.length] = new Option("Murfreesboro schools",'all=Murfreesboro');
mySelect.options[mySelect.options.length] = new Option("Nashville schools",'all=Nashville');
mySelect.options[mySelect.options.length] = new Option("Rutledge schools",'all=Rutledge');
mySelect.options[mySelect.options.length] = new Option("Summertown schools",'all=Summertown');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Knoxville[Knoxville.length] = createMarker(new GPoint(-83.98817800,35.98650700),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Apostolic Christian School",'Knoxville=' + Knoxville.length);
Kingsport[Kingsport.length] = createMarker(new GPoint(-82.59066300,36.57006900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Apostolic Gospel Academy",'Kingsport=' + Kingsport.length);
Knoxville[Knoxville.length] = createMarker(new GPoint(-83.89107600,36.00779600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Berean Christian School",'Knoxville=' + Knoxville.length);
Murfreesboro[Murfreesboro.length] = createMarker(new GPoint(-86.29996700,35.78539100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bible Church Academy",'Murfreesboro=' + Murfreesboro.length);
Knoxville[Knoxville.length] = createMarker(new GPoint(-83.92082800,35.96052300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Family Cooperative",'Knoxville=' + Knoxville.length);
Knoxville[Knoxville.length] = createMarker(new GPoint(-83.95887800,35.95526400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Columbus Home School",'Knoxville=' + Knoxville.length);
Gallatin[Gallatin.length] = createMarker(new GPoint(-86.46066900,36.38111000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Declaration Christian Academy",'Gallatin=' + Gallatin.length);
Summertown[Summertown.length] = createMarker(new GPoint(-87.32880100,35.47871900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Farm School",'Summertown=' + Summertown.length);
La_Grange[La_Grange.length] = createMarker(new GPoint(-89.24359200,35.04896000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Grange Montessori School",'La_Grange=' + La_Grange.length);
Morristown[Morristown.length] = createMarker(new GPoint(-83.34261000,36.20249100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lakeway Christian School",'Morristown=' + Morristown.length);
Athens[Athens.length] = createMarker(new GPoint(-84.62230000,35.44230000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Liberty Christian",'Athens=' + Athens.length);
Morristown[Morristown.length] = createMarker(new GPoint(-83.29500000,36.21380000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Morristown Covenant Academy",'Morristown=' + Morristown.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.75761100,36.25424500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nashville Christian Advancement Academy",'Nashville=' + Nashville.length);
Grand_Junction[Grand_Junction.length] = createMarker(new GPoint(-89.02470000,35.10540000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Life Christian Academy",'Grand_Junction=' + Grand_Junction.length);
Rutledge[Rutledge.length] = createMarker(new GPoint(-83.54316100,36.19141400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New System School, Inc.",'Rutledge=' + Rutledge.length);
Nashville[Nashville.length] = createMarker(new GPoint(-86.72265400,36.05924100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Clement Coptic Orthodox Christian Academy",'Nashville=' + Nashville.length);
Arthur[Arthur.length] = createMarker(new GPoint(-83.67080000,36.54800000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tri-state Christian Academy",'Arthur=' + Arthur.length);
Cleveland[Cleveland.length] = createMarker(new GPoint(-84.86500000,35.10560000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("United Christian Academy",'Cleveland=' + Cleveland.length);
map.removeOverlays(Arthur);
map.removeOverlays(Athens);
map.removeOverlays(Cleveland);
map.removeOverlays(Gallatin);
map.removeOverlays(Grand_Junction);
map.removeOverlays(Kingsport);
map.removeOverlays(Knoxville);
map.removeOverlays(La_Grange);
map.removeOverlays(Morristown);
map.removeOverlays(Murfreesboro);
map.removeOverlays(Nashville);
map.removeOverlays(Rutledge);
map.removeOverlays(Summertown);
setTimeout(function(){map.addOverlays(Arthur)},1000);
setTimeout(function(){map.addOverlays(Athens)},1000);
setTimeout(function(){map.addOverlays(Cleveland)},1000);
setTimeout(function(){map.addOverlays(Gallatin)},1000);
setTimeout(function(){map.addOverlays(Grand_Junction)},1000);
setTimeout(function(){map.addOverlays(Kingsport)},1000);
setTimeout(function(){map.addOverlays(Knoxville)},1000);
setTimeout(function(){map.addOverlays(La_Grange)},1000);
setTimeout(function(){map.addOverlays(Morristown)},1000);
setTimeout(function(){map.addOverlays(Murfreesboro)},1000);
setTimeout(function(){map.addOverlays(Nashville)},1000);
setTimeout(function(){map.addOverlays(Rutledge)},1000);
setTimeout(function(){map.addOverlays(Summertown)},1000);
maxLng = -82.59066300;
maxLat = 36.57006900;
minLng = -89.24359200;
minLat = 35.04896000;
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(Arthur);
map.removeOverlays(Athens);
map.removeOverlays(Cleveland);
map.removeOverlays(Gallatin);
map.removeOverlays(Grand_Junction);
map.removeOverlays(Kingsport);
map.removeOverlays(Knoxville);
map.removeOverlays(La_Grange);
map.removeOverlays(Morristown);
map.removeOverlays(Murfreesboro);
map.removeOverlays(Nashville);
map.removeOverlays(Rutledge);
map.removeOverlays(Summertown);
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(Knoxville);map.removeOverlays(Arthur);
map.removeOverlays(Athens);
map.removeOverlays(Cleveland);
map.removeOverlays(Gallatin);
map.removeOverlays(Grand_Junction);
map.removeOverlays(Kingsport);
map.removeOverlays(Knoxville);
map.removeOverlays(La_Grange);
map.removeOverlays(Morristown);
map.removeOverlays(Murfreesboro);
map.removeOverlays(Nashville);
map.removeOverlays(Rutledge);
map.removeOverlays(Summertown);
map.addOverlays(Arthur);
centerByArray(Arthur, false, false);
cntMarker += Arthur.length;
map.addOverlays(Athens);
centerByArray(Athens, false, false);
cntMarker += Athens.length;
map.addOverlays(Cleveland);
centerByArray(Cleveland, false, false);
cntMarker += Cleveland.length;
map.addOverlays(Gallatin);
centerByArray(Gallatin, false, false);
cntMarker += Gallatin.length;
map.addOverlays(Grand_Junction);
centerByArray(Grand_Junction, false, false);
cntMarker += Grand_Junction.length;
map.addOverlays(Kingsport);
centerByArray(Kingsport, false, false);
cntMarker += Kingsport.length;
map.addOverlays(Knoxville);
centerByArray(Knoxville, false, false);
cntMarker += Knoxville.length;
map.addOverlays(La_Grange);
centerByArray(La_Grange, false, false);
cntMarker += La_Grange.length;
map.addOverlays(Morristown);
centerByArray(Morristown, false, false);
cntMarker += Morristown.length;
map.addOverlays(Murfreesboro);
centerByArray(Murfreesboro, false, false);
cntMarker += Murfreesboro.length;
map.addOverlays(Nashville);
centerByArray(Nashville, false, false);
cntMarker += Nashville.length;
map.addOverlays(Rutledge);
centerByArray(Rutledge, false, false);
cntMarker += Rutledge.length;
map.addOverlays(Summertown);
centerByArray(Summertown, false, false);
cntMarker += Summertown.length;
centerByArray(Knoxville,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///26161,33219,33212,26391,25933,26151,26205,25935,34478,26335,26353,26161,26358,26222,33212,26391,25933,25989,26100,31825,26151,26205,25935,33224,36094,34478,26335,/all');
//window.open('/map.php?type=2&schools=26161,33219,33212,26391,25933,26151,26205,25935,34478,26335,26353,26161,26358,26222,33212,26391,25933,25989,26100,31825,26151,26205,25935,33224,36094,34478,26335,&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;
}