function addMarkers(){
mySelect = document.getElementById('selection');
Walls = [];Biloxi = [];Ridgeland = [];Jackson = [];Rolling_Fork = [];Yazoo_City = [];French_Camp = [];Louisville = [];Southaven = [];Steens = [];Kosciusko = [];Clarksdale = [];Starkville = [];Tupelo = [];mySelect.options[mySelect.options.length] = new Option("Biloxi schools",'all=Biloxi');
mySelect.options[mySelect.options.length] = new Option("Clarksdale schools",'all=Clarksdale');
mySelect.options[mySelect.options.length] = new Option("French Camp schools",'all=French_Camp');
mySelect.options[mySelect.options.length] = new Option("Jackson schools",'all=Jackson');
mySelect.options[mySelect.options.length] = new Option("Kosciusko schools",'all=Kosciusko');
mySelect.options[mySelect.options.length] = new Option("Louisville schools",'all=Louisville');
mySelect.options[mySelect.options.length] = new Option("Ridgeland schools",'all=Ridgeland');
mySelect.options[mySelect.options.length] = new Option("Rolling Fork schools",'all=Rolling_Fork');
mySelect.options[mySelect.options.length] = new Option("Southaven schools",'all=Southaven');
mySelect.options[mySelect.options.length] = new Option("Starkville schools",'all=Starkville');
mySelect.options[mySelect.options.length] = new Option("Steens schools",'all=Steens');
mySelect.options[mySelect.options.length] = new Option("Tupelo schools",'all=Tupelo');
mySelect.options[mySelect.options.length] = new Option("Walls schools",'all=Walls');
mySelect.options[mySelect.options.length] = new Option("Yazoo City schools",'all=Yazoo_City');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Walls[Walls.length] = createMarker(new GPoint(-90.09667900,34.96236300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethel Baptist Schools",'Walls=' + Walls.length);
Biloxi[Biloxi.length] = createMarker(new GPoint(-88.93875800,30.45534100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cedar Lake Christian Academy",'Biloxi=' + Biloxi.length);
Ridgeland[Ridgeland.length] = createMarker(new GPoint(-90.12336800,32.40351700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ Covenant School",'Ridgeland=' + Ridgeland.length);
Jackson[Jackson.length] = createMarker(new GPoint(-90.22460000,32.36610000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ Missionary Industrial College",'Jackson=' + Jackson.length);
Rolling_Fork[Rolling_Fork.length] = createMarker(new GPoint(-90.87412600,32.90643800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cornerstone Christian School",'Rolling_Fork=' + Rolling_Fork.length);
Yazoo_City[Yazoo_City.length] = createMarker(new GPoint(-90.41730000,32.84960000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Covenant Christian School",'Yazoo_City=' + Yazoo_City.length);
French_Camp[French_Camp.length] = createMarker(new GPoint(-89.39810300,33.28963000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("French Camp Academy",'French_Camp=' + French_Camp.length);
Louisville[Louisville.length] = createMarker(new GPoint(-88.95931200,33.14074100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Christian School",'Louisville=' + Louisville.length);
Southaven[Southaven.length] = createMarker(new GPoint(-90.01638700,34.97061300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Highway Baptist Christian Academy",'Southaven=' + Southaven.length);
Jackson[Jackson.length] = createMarker(new GPoint(-90.30069600,32.24035200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hillcrest Christian School",'Jackson=' + Jackson.length);
Steens[Steens.length] = createMarker(new GPoint(-88.43277700,33.51600600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Immanuel Center For Christian Education",'Steens=' + Steens.length);
Jackson[Jackson.length] = createMarker(new GPoint(-90.19256200,32.39952700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mother Goose Christian Academy",'Jackson=' + Jackson.length);
Jackson[Jackson.length] = createMarker(new GPoint(-90.24216100,32.25071000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("New Horizon Christian School A",'Jackson=' + Jackson.length);
Jackson[Jackson.length] = createMarker(new GPoint(-90.24529900,32.28417500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Jerusalem Christian Academy",'Jackson=' + Jackson.length);
Kosciusko[Kosciusko.length] = createMarker(new GPoint(-89.57715300,33.05096000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Presbyterian Day School",'Kosciusko=' + Kosciusko.length);
Clarksdale[Clarksdale.length] = createMarker(new GPoint(-90.59668400,34.20166300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Presbyterian Day School",'Clarksdale=' + Clarksdale.length);
Southaven[Southaven.length] = createMarker(new GPoint(-89.93663200,34.96735000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Southern Baptist Educ Center",'Southaven=' + Southaven.length);
Starkville[Starkville.length] = createMarker(new GPoint(-88.82555100,33.44163100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Starkville Christian School",'Starkville=' + Starkville.length);
Jackson[Jackson.length] = createMarker(new GPoint(-90.26583200,32.33893700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Triumph Village Christian Academy",'Jackson=' + Jackson.length);
Tupelo[Tupelo.length] = createMarker(new GPoint(-88.79591200,34.30847800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tupelo Christian Prep School",'Tupelo=' + Tupelo.length);
Jackson[Jackson.length] = createMarker(new GPoint(-90.12285000,32.37699600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Veritas School",'Jackson=' + Jackson.length);
map.removeOverlays(Biloxi);
map.removeOverlays(Clarksdale);
map.removeOverlays(French_Camp);
map.removeOverlays(Jackson);
map.removeOverlays(Kosciusko);
map.removeOverlays(Louisville);
map.removeOverlays(Ridgeland);
map.removeOverlays(Rolling_Fork);
map.removeOverlays(Southaven);
map.removeOverlays(Starkville);
map.removeOverlays(Steens);
map.removeOverlays(Tupelo);
map.removeOverlays(Walls);
map.removeOverlays(Yazoo_City);
setTimeout(function(){map.addOverlays(Biloxi)},1000);
setTimeout(function(){map.addOverlays(Clarksdale)},1000);
setTimeout(function(){map.addOverlays(French_Camp)},1000);
setTimeout(function(){map.addOverlays(Jackson)},1000);
setTimeout(function(){map.addOverlays(Kosciusko)},1000);
setTimeout(function(){map.addOverlays(Louisville)},1000);
setTimeout(function(){map.addOverlays(Ridgeland)},1000);
setTimeout(function(){map.addOverlays(Rolling_Fork)},1000);
setTimeout(function(){map.addOverlays(Southaven)},1000);
setTimeout(function(){map.addOverlays(Starkville)},1000);
setTimeout(function(){map.addOverlays(Steens)},1000);
setTimeout(function(){map.addOverlays(Tupelo)},1000);
setTimeout(function(){map.addOverlays(Walls)},1000);
setTimeout(function(){map.addOverlays(Yazoo_City)},1000);
maxLng = -88.43277700;
maxLat = 34.97061300;
minLng = -90.87412600;
minLat = 30.45534100;
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(Biloxi);
map.removeOverlays(Clarksdale);
map.removeOverlays(French_Camp);
map.removeOverlays(Jackson);
map.removeOverlays(Kosciusko);
map.removeOverlays(Louisville);
map.removeOverlays(Ridgeland);
map.removeOverlays(Rolling_Fork);
map.removeOverlays(Southaven);
map.removeOverlays(Starkville);
map.removeOverlays(Steens);
map.removeOverlays(Tupelo);
map.removeOverlays(Walls);
map.removeOverlays(Yazoo_City);
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(Walls);map.removeOverlays(Biloxi);
map.removeOverlays(Clarksdale);
map.removeOverlays(French_Camp);
map.removeOverlays(Jackson);
map.removeOverlays(Kosciusko);
map.removeOverlays(Louisville);
map.removeOverlays(Ridgeland);
map.removeOverlays(Rolling_Fork);
map.removeOverlays(Southaven);
map.removeOverlays(Starkville);
map.removeOverlays(Steens);
map.removeOverlays(Tupelo);
map.removeOverlays(Walls);
map.removeOverlays(Yazoo_City);
map.addOverlays(Biloxi);
centerByArray(Biloxi, false, false);
cntMarker += Biloxi.length;
map.addOverlays(Clarksdale);
centerByArray(Clarksdale, false, false);
cntMarker += Clarksdale.length;
map.addOverlays(French_Camp);
centerByArray(French_Camp, false, false);
cntMarker += French_Camp.length;
map.addOverlays(Jackson);
centerByArray(Jackson, false, false);
cntMarker += Jackson.length;
map.addOverlays(Kosciusko);
centerByArray(Kosciusko, false, false);
cntMarker += Kosciusko.length;
map.addOverlays(Louisville);
centerByArray(Louisville, false, false);
cntMarker += Louisville.length;
map.addOverlays(Ridgeland);
centerByArray(Ridgeland, false, false);
cntMarker += Ridgeland.length;
map.addOverlays(Rolling_Fork);
centerByArray(Rolling_Fork, false, false);
cntMarker += Rolling_Fork.length;
map.addOverlays(Southaven);
centerByArray(Southaven, false, false);
cntMarker += Southaven.length;
map.addOverlays(Starkville);
centerByArray(Starkville, false, false);
cntMarker += Starkville.length;
map.addOverlays(Steens);
centerByArray(Steens, false, false);
cntMarker += Steens.length;
map.addOverlays(Tupelo);
centerByArray(Tupelo, false, false);
cntMarker += Tupelo.length;
map.addOverlays(Walls);
centerByArray(Walls, false, false);
cntMarker += Walls.length;
map.addOverlays(Yazoo_City);
centerByArray(Yazoo_City, false, false);
cntMarker += Yazoo_City.length;
centerByArray(Walls,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///15429,15403,15441,35674,15433,15440,15507,15538,15447,15553,15382,15393,15495,15403,15441,15468,15473,33588,15550,33883,15433,36007,33587,15440,15507,15538,15447,15553,15382,15412,/all');
//window.open('/map.php?type=2&schools=15429,15403,15441,35674,15433,15440,15507,15538,15447,15553,15382,15393,15495,15403,15441,15468,15473,33588,15550,33883,15433,36007,33587,15440,15507,15538,15447,15553,15382,15412,&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;
}