function addMarkers(){
mySelect = document.getElementById('selection');
Amboy = [];Calumet_City = [];Rockford = [];South_Roxana = [];Romeoville = [];Des_Plaines = [];Chillicothe = [];Macomb = [];Peoria = [];Pekin = [];Pana = [];Danville = [];Freeport = [];Frankfort = [];Waukegan = [];Glasford = [];Niles = [];Joliet = [];Downers_Grove = [];Riverdale = [];Schaumburg = [];Oak_Lawn = [];Zion = [];mySelect.options[mySelect.options.length] = new Option("Amboy schools",'all=Amboy');
mySelect.options[mySelect.options.length] = new Option("Calumet City schools",'all=Calumet_City');
mySelect.options[mySelect.options.length] = new Option("Chillicothe schools",'all=Chillicothe');
mySelect.options[mySelect.options.length] = new Option("Danville schools",'all=Danville');
mySelect.options[mySelect.options.length] = new Option("Des Plaines schools",'all=Des_Plaines');
mySelect.options[mySelect.options.length] = new Option("Downers Grove schools",'all=Downers_Grove');
mySelect.options[mySelect.options.length] = new Option("Frankfort schools",'all=Frankfort');
mySelect.options[mySelect.options.length] = new Option("Freeport schools",'all=Freeport');
mySelect.options[mySelect.options.length] = new Option("Glasford schools",'all=Glasford');
mySelect.options[mySelect.options.length] = new Option("Joliet schools",'all=Joliet');
mySelect.options[mySelect.options.length] = new Option("Macomb schools",'all=Macomb');
mySelect.options[mySelect.options.length] = new Option("Niles schools",'all=Niles');
mySelect.options[mySelect.options.length] = new Option("Oak Lawn schools",'all=Oak_Lawn');
mySelect.options[mySelect.options.length] = new Option("Pana schools",'all=Pana');
mySelect.options[mySelect.options.length] = new Option("Pekin schools",'all=Pekin');
mySelect.options[mySelect.options.length] = new Option("Peoria schools",'all=Peoria');
mySelect.options[mySelect.options.length] = new Option("Riverdale schools",'all=Riverdale');
mySelect.options[mySelect.options.length] = new Option("Rockford schools",'all=Rockford');
mySelect.options[mySelect.options.length] = new Option("Romeoville schools",'all=Romeoville');
mySelect.options[mySelect.options.length] = new Option("Schaumburg schools",'all=Schaumburg');
mySelect.options[mySelect.options.length] = new Option("South Roxana schools",'all=South_Roxana');
mySelect.options[mySelect.options.length] = new Option("Waukegan schools",'all=Waukegan');
mySelect.options[mySelect.options.length] = new Option("Zion schools",'all=Zion');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Amboy[Amboy.length] = createMarker(new GPoint(-89.32954700,41.71536600),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Amboy Baptist Academy",'Amboy=' + Amboy.length);
Calumet_City[Calumet_City.length] = createMarker(new GPoint(-87.53734400,41.62005000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Beacon Hill Preparatory Academy",'Calumet_City=' + Calumet_City.length);
Rockford[Rockford.length] = createMarker(new GPoint(-89.14768900,42.30245900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Berean Baptist Christian School",'Rockford=' + Rockford.length);
South_Roxana[South_Roxana.length] = createMarker(new GPoint(-90.05870000,38.82810000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethel Christian Academy",'South_Roxana=' + South_Roxana.length);
Romeoville[Romeoville.length] = createMarker(new GPoint(-88.08694800,41.65430800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bible Baptist Christian Academy",'Romeoville=' + Romeoville.length);
Des_Plaines[Des_Plaines.length] = createMarker(new GPoint(-87.92793300,42.04165800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brentwood Baptist Christian Academy",'Des_Plaines=' + Des_Plaines.length);
Chillicothe[Chillicothe.length] = createMarker(new GPoint(-89.49685900,40.90748000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Baptist Academy",'Chillicothe=' + Chillicothe.length);
Macomb[Macomb.length] = createMarker(new GPoint(-90.67071900,40.44244400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Baptist Christian Academy",'Macomb=' + Macomb.length);
Peoria[Peoria.length] = createMarker(new GPoint(-89.65586300,40.76320100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("El Vista Baptist Academy",'Peoria=' + Peoria.length);
Pekin[Pekin.length] = createMarker(new GPoint(-89.64257000,40.55283900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Baptist Christian School",'Pekin=' + Pekin.length);
Pana[Pana.length] = createMarker(new GPoint(-89.07729000,39.38819600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Baptist Christian Academy",'Pana=' + Pana.length);
Danville[Danville.length] = createMarker(new GPoint(-87.63001900,40.14430700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Baptist Christian School",'Danville=' + Danville.length);
Freeport[Freeport.length] = createMarker(new GPoint(-89.66588400,42.28308800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Freeport Christian Academy",'Freeport=' + Freeport.length);
Frankfort[Frankfort.length] = createMarker(new GPoint(-87.86525300,41.49474300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heritage Christian School",'Frankfort=' + Frankfort.length);
Waukegan[Waukegan.length] = createMarker(new GPoint(-87.85029100,42.41022900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lake County Baptist School",'Waukegan=' + Waukegan.length);
Glasford[Glasford.length] = createMarker(new GPoint(-89.84216400,40.58053600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lamarsh Baptist School",'Glasford=' + Glasford.length);
Niles[Niles.length] = createMarker(new GPoint(-87.79047400,42.01397500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Logos Christian Academy, aka Norwood Park Christian",'Niles=' + Niles.length);
Joliet[Joliet.length] = createMarker(new GPoint(-88.03849200,41.54276300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maranatha Christian School",'Joliet=' + Joliet.length);
Downers_Grove[Downers_Grove.length] = createMarker(new GPoint(-87.99193900,41.75111900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marquette Manor Baptist Academy",'Downers_Grove=' + Downers_Grove.length);
Rockford[Rockford.length] = createMarker(new GPoint(-89.11848600,42.27637000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mt Sinai Learning Academy",'Rockford=' + Rockford.length);
Riverdale[Riverdale.length] = createMarker(new GPoint(-87.61738300,41.64846100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Promise Christian Academy",'Riverdale=' + Riverdale.length);
Joliet[Joliet.length] = createMarker(new GPoint(-88.03344700,41.52849500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ridgewood Baptist Academy",'Joliet=' + Joliet.length);
Schaumburg[Schaumburg.length] = createMarker(new GPoint(-88.08005700,42.03138500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Schaumburg Christian School",'Schaumburg=' + Schaumburg.length);
Oak_Lawn[Oak_Lawn.length] = createMarker(new GPoint(-87.75050100,41.70186100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Side Baptist School",'Oak_Lawn=' + Oak_Lawn.length);
Zion[Zion.length] = createMarker(new GPoint(-80.70762200,41.06356800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Zion Christian School",'Zion=' + Zion.length);
map.removeOverlays(Amboy);
map.removeOverlays(Calumet_City);
map.removeOverlays(Chillicothe);
map.removeOverlays(Danville);
map.removeOverlays(Des_Plaines);
map.removeOverlays(Downers_Grove);
map.removeOverlays(Frankfort);
map.removeOverlays(Freeport);
map.removeOverlays(Glasford);
map.removeOverlays(Joliet);
map.removeOverlays(Macomb);
map.removeOverlays(Niles);
map.removeOverlays(Oak_Lawn);
map.removeOverlays(Pana);
map.removeOverlays(Pekin);
map.removeOverlays(Peoria);
map.removeOverlays(Riverdale);
map.removeOverlays(Rockford);
map.removeOverlays(Romeoville);
map.removeOverlays(Schaumburg);
map.removeOverlays(South_Roxana);
map.removeOverlays(Waukegan);
map.removeOverlays(Zion);
setTimeout(function(){map.addOverlays(Amboy)},1000);
setTimeout(function(){map.addOverlays(Calumet_City)},1000);
setTimeout(function(){map.addOverlays(Chillicothe)},1000);
setTimeout(function(){map.addOverlays(Danville)},1000);
setTimeout(function(){map.addOverlays(Des_Plaines)},1000);
setTimeout(function(){map.addOverlays(Downers_Grove)},1000);
setTimeout(function(){map.addOverlays(Frankfort)},1000);
setTimeout(function(){map.addOverlays(Freeport)},1000);
setTimeout(function(){map.addOverlays(Glasford)},1000);
setTimeout(function(){map.addOverlays(Joliet)},1000);
setTimeout(function(){map.addOverlays(Macomb)},1000);
setTimeout(function(){map.addOverlays(Niles)},1000);
setTimeout(function(){map.addOverlays(Oak_Lawn)},1000);
setTimeout(function(){map.addOverlays(Pana)},1000);
setTimeout(function(){map.addOverlays(Pekin)},1000);
setTimeout(function(){map.addOverlays(Peoria)},1000);
setTimeout(function(){map.addOverlays(Riverdale)},1000);
setTimeout(function(){map.addOverlays(Rockford)},1000);
setTimeout(function(){map.addOverlays(Romeoville)},1000);
setTimeout(function(){map.addOverlays(Schaumburg)},1000);
setTimeout(function(){map.addOverlays(South_Roxana)},1000);
setTimeout(function(){map.addOverlays(Waukegan)},1000);
setTimeout(function(){map.addOverlays(Zion)},1000);
maxLng = -80.70762200;
maxLat = 42.41022900;
minLng = -90.67071900;
minLat = 38.82810000;
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(Amboy);
map.removeOverlays(Calumet_City);
map.removeOverlays(Chillicothe);
map.removeOverlays(Danville);
map.removeOverlays(Des_Plaines);
map.removeOverlays(Downers_Grove);
map.removeOverlays(Frankfort);
map.removeOverlays(Freeport);
map.removeOverlays(Glasford);
map.removeOverlays(Joliet);
map.removeOverlays(Macomb);
map.removeOverlays(Niles);
map.removeOverlays(Oak_Lawn);
map.removeOverlays(Pana);
map.removeOverlays(Pekin);
map.removeOverlays(Peoria);
map.removeOverlays(Riverdale);
map.removeOverlays(Rockford);
map.removeOverlays(Romeoville);
map.removeOverlays(Schaumburg);
map.removeOverlays(South_Roxana);
map.removeOverlays(Waukegan);
map.removeOverlays(Zion);
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(Amboy);map.removeOverlays(Amboy);
map.removeOverlays(Calumet_City);
map.removeOverlays(Chillicothe);
map.removeOverlays(Danville);
map.removeOverlays(Des_Plaines);
map.removeOverlays(Downers_Grove);
map.removeOverlays(Frankfort);
map.removeOverlays(Freeport);
map.removeOverlays(Glasford);
map.removeOverlays(Joliet);
map.removeOverlays(Macomb);
map.removeOverlays(Niles);
map.removeOverlays(Oak_Lawn);
map.removeOverlays(Pana);
map.removeOverlays(Pekin);
map.removeOverlays(Peoria);
map.removeOverlays(Riverdale);
map.removeOverlays(Rockford);
map.removeOverlays(Romeoville);
map.removeOverlays(Schaumburg);
map.removeOverlays(South_Roxana);
map.removeOverlays(Waukegan);
map.removeOverlays(Zion);
map.addOverlays(Amboy);
centerByArray(Amboy, false, false);
cntMarker += Amboy.length;
map.addOverlays(Calumet_City);
centerByArray(Calumet_City, false, false);
cntMarker += Calumet_City.length;
map.addOverlays(Chillicothe);
centerByArray(Chillicothe, false, false);
cntMarker += Chillicothe.length;
map.addOverlays(Danville);
centerByArray(Danville, false, false);
cntMarker += Danville.length;
map.addOverlays(Des_Plaines);
centerByArray(Des_Plaines, false, false);
cntMarker += Des_Plaines.length;
map.addOverlays(Downers_Grove);
centerByArray(Downers_Grove, false, false);
cntMarker += Downers_Grove.length;
map.addOverlays(Frankfort);
centerByArray(Frankfort, false, false);
cntMarker += Frankfort.length;
map.addOverlays(Freeport);
centerByArray(Freeport, false, false);
cntMarker += Freeport.length;
map.addOverlays(Glasford);
centerByArray(Glasford, false, false);
cntMarker += Glasford.length;
map.addOverlays(Joliet);
centerByArray(Joliet, false, false);
cntMarker += Joliet.length;
map.addOverlays(Macomb);
centerByArray(Macomb, false, false);
cntMarker += Macomb.length;
map.addOverlays(Niles);
centerByArray(Niles, false, false);
cntMarker += Niles.length;
map.addOverlays(Oak_Lawn);
centerByArray(Oak_Lawn, false, false);
cntMarker += Oak_Lawn.length;
map.addOverlays(Pana);
centerByArray(Pana, false, false);
cntMarker += Pana.length;
map.addOverlays(Pekin);
centerByArray(Pekin, false, false);
cntMarker += Pekin.length;
map.addOverlays(Peoria);
centerByArray(Peoria, false, false);
cntMarker += Peoria.length;
map.addOverlays(Riverdale);
centerByArray(Riverdale, false, false);
cntMarker += Riverdale.length;
map.addOverlays(Rockford);
centerByArray(Rockford, false, false);
cntMarker += Rockford.length;
map.addOverlays(Romeoville);
centerByArray(Romeoville, false, false);
cntMarker += Romeoville.length;
map.addOverlays(Schaumburg);
centerByArray(Schaumburg, false, false);
cntMarker += Schaumburg.length;
map.addOverlays(South_Roxana);
centerByArray(South_Roxana, false, false);
cntMarker += South_Roxana.length;
map.addOverlays(Waukegan);
centerByArray(Waukegan, false, false);
cntMarker += Waukegan.length;
map.addOverlays(Zion);
centerByArray(Zion, false, false);
cntMarker += Zion.length;
centerByArray(Amboy,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///8396,8475,8650,8463,8916,8714,33274,8905,9153,9045,9218,8649,8636,8617,33273,9196,8440,8840,21399,8396,33272,8475,8650,8463,8916,8714,8670,33274,8905,9153,8479,9045,9218,8649,8636,8617,9694,33273,33275,8450,9196,8440,8840,21399,/all');
//window.open('/map.php?type=2&schools=8396,8475,8650,8463,8916,8714,33274,8905,9153,9045,9218,8649,8636,8617,33273,9196,8440,8840,21399,8396,33272,8475,8650,8463,8916,8714,8670,33274,8905,9153,8479,9045,9218,8649,8636,8617,9694,33273,33275,8450,9196,8440,8840,21399,&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;
}