function addMarkers(){
mySelect = document.getElementById('selection');
Bartlett = [];Chicago = [];Du_Quoin = [];Charleston = [];Godfrey = [];Wyoming = [];Aurora = [];Glenview = [];Belvidere = [];Freeport = [];Harvey = [];Rockford = [];Saint_Francisville = [];Peoria = [];Monee = [];Skokie = [];Moline = [];Elmhurst = [];mySelect.options[mySelect.options.length] = new Option("Aurora schools",'all=Aurora');
mySelect.options[mySelect.options.length] = new Option("Bartlett schools",'all=Bartlett');
mySelect.options[mySelect.options.length] = new Option("Belvidere schools",'all=Belvidere');
mySelect.options[mySelect.options.length] = new Option("Charleston schools",'all=Charleston');
mySelect.options[mySelect.options.length] = new Option("Chicago schools",'all=Chicago');
mySelect.options[mySelect.options.length] = new Option("Du Quoin schools",'all=Du_Quoin');
mySelect.options[mySelect.options.length] = new Option("Elmhurst schools",'all=Elmhurst');
mySelect.options[mySelect.options.length] = new Option("Freeport schools",'all=Freeport');
mySelect.options[mySelect.options.length] = new Option("Glenview schools",'all=Glenview');
mySelect.options[mySelect.options.length] = new Option("Godfrey schools",'all=Godfrey');
mySelect.options[mySelect.options.length] = new Option("Harvey schools",'all=Harvey');
mySelect.options[mySelect.options.length] = new Option("Moline schools",'all=Moline');
mySelect.options[mySelect.options.length] = new Option("Monee schools",'all=Monee');
mySelect.options[mySelect.options.length] = new Option("Peoria schools",'all=Peoria');
mySelect.options[mySelect.options.length] = new Option("Rockford schools",'all=Rockford');
mySelect.options[mySelect.options.length] = new Option("Saint Francisville schools",'all=Saint_Francisville');
mySelect.options[mySelect.options.length] = new Option("Skokie schools",'all=Skokie');
mySelect.options[mySelect.options.length] = new Option("Wyoming schools",'all=Wyoming');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Bartlett[Bartlett.length] = createMarker(new GPoint(-88.19945600,41.99455000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bartlett Learning Center",'Bartlett=' + Bartlett.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.72036700,41.99721900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bnos Rabbeinu High School",'Chicago=' + Chicago.length);
Du_Quoin[Du_Quoin.length] = createMarker(new GPoint(-89.23680000,38.00980000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Fellowship School",'Du_Quoin=' + Du_Quoin.length);
Charleston[Charleston.length] = createMarker(new GPoint(-88.14100600,39.49178400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Coles County Christian School",'Charleston=' + Charleston.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.64837700,41.72813600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Evangelical Christian School",'Chicago=' + Chicago.length);
Godfrey[Godfrey.length] = createMarker(new GPoint(-90.21476100,38.94824800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Evangelical School",'Godfrey=' + Godfrey.length);
Wyoming[Wyoming.length] = createMarker(new GPoint(-89.78081400,41.06010000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hartland Private School",'Wyoming=' + Wyoming.length);
Aurora[Aurora.length] = createMarker(new GPoint(-88.29283900,41.81188600),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Marmion Academy",'Aurora=' + Aurora.length);
Glenview[Glenview.length] = createMarker(new GPoint(-87.82178500,42.07536000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Midwestern Academy-new Church",'Glenview=' + Glenview.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.74681400,41.94385500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Midwestern Christian Academy",'Chicago=' + Chicago.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.65045500,41.72248900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oakdale Christian Academy & Child Care",'Chicago=' + Chicago.length);
Belvidere[Belvidere.length] = createMarker(new GPoint(-88.88032100,42.27864900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Open Bible Academy",'Belvidere=' + Belvidere.length);
Freeport[Freeport.length] = createMarker(new GPoint(-89.69132900,42.29353700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Open Bible Learning Center",'Freeport=' + Freeport.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.56115200,41.75896300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Original Glorious Little Angel",'Chicago=' + Chicago.length);
Harvey[Harvey.length] = createMarker(new GPoint(-87.64762600,41.61121700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pathways To Learning Academy",'Harvey=' + Harvey.length);
Rockford[Rockford.length] = createMarker(new GPoint(-89.03552100,42.31524000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rainbow Academy",'Rockford=' + Rockford.length);
Saint_Francisville[Saint_Francisville.length] = createMarker(new GPoint(-87.67050000,38.61240000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Francisville Christian Academy",'Saint_Francisville=' + Saint_Francisville.length);
Peoria[Peoria.length] = createMarker(new GPoint(-89.58599000,40.69436900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Salvation Army Child Care",'Peoria=' + Peoria.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.68218300,41.89683700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Nicholas Ukrainian Catholic School",'Chicago=' + Chicago.length);
Monee[Monee.length] = createMarker(new GPoint(-87.75880000,41.41980000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Pauls Christian School",'Monee=' + Monee.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.69871400,41.97496500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Swedish Cov Hospital Child Care Center",'Chicago=' + Chicago.length);
Skokie[Skokie.length] = createMarker(new GPoint(-87.75114800,42.03133900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Swift Child Care & Kindergarten",'Skokie=' + Skokie.length);
Moline[Moline.length] = createMarker(new GPoint(-90.50474200,41.50828300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Temple Christian Academy",'Moline=' + Moline.length);
Elmhurst[Elmhurst.length] = createMarker(new GPoint(-87.94363500,41.86564400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Timothy Christian High School",'Elmhurst=' + Elmhurst.length);
Harvey[Harvey.length] = createMarker(new GPoint(-87.63766000,41.62270300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wee Care Christian Learning Center, Inc",'Harvey=' + Harvey.length);
map.removeOverlays(Aurora);
map.removeOverlays(Bartlett);
map.removeOverlays(Belvidere);
map.removeOverlays(Charleston);
map.removeOverlays(Chicago);
map.removeOverlays(Du_Quoin);
map.removeOverlays(Elmhurst);
map.removeOverlays(Freeport);
map.removeOverlays(Glenview);
map.removeOverlays(Godfrey);
map.removeOverlays(Harvey);
map.removeOverlays(Moline);
map.removeOverlays(Monee);
map.removeOverlays(Peoria);
map.removeOverlays(Rockford);
map.removeOverlays(Saint_Francisville);
map.removeOverlays(Skokie);
map.removeOverlays(Wyoming);
setTimeout(function(){map.addOverlays(Aurora)},1000);
setTimeout(function(){map.addOverlays(Bartlett)},1000);
setTimeout(function(){map.addOverlays(Belvidere)},1000);
setTimeout(function(){map.addOverlays(Charleston)},1000);
setTimeout(function(){map.addOverlays(Chicago)},1000);
setTimeout(function(){map.addOverlays(Du_Quoin)},1000);
setTimeout(function(){map.addOverlays(Elmhurst)},1000);
setTimeout(function(){map.addOverlays(Freeport)},1000);
setTimeout(function(){map.addOverlays(Glenview)},1000);
setTimeout(function(){map.addOverlays(Godfrey)},1000);
setTimeout(function(){map.addOverlays(Harvey)},1000);
setTimeout(function(){map.addOverlays(Moline)},1000);
setTimeout(function(){map.addOverlays(Monee)},1000);
setTimeout(function(){map.addOverlays(Peoria)},1000);
setTimeout(function(){map.addOverlays(Rockford)},1000);
setTimeout(function(){map.addOverlays(Saint_Francisville)},1000);
setTimeout(function(){map.addOverlays(Skokie)},1000);
setTimeout(function(){map.addOverlays(Wyoming)},1000);
maxLng = -87.56115200;
maxLat = 42.31524000;
minLng = -90.50474200;
minLat = 38.00980000;
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(Aurora);
map.removeOverlays(Bartlett);
map.removeOverlays(Belvidere);
map.removeOverlays(Charleston);
map.removeOverlays(Chicago);
map.removeOverlays(Du_Quoin);
map.removeOverlays(Elmhurst);
map.removeOverlays(Freeport);
map.removeOverlays(Glenview);
map.removeOverlays(Godfrey);
map.removeOverlays(Harvey);
map.removeOverlays(Moline);
map.removeOverlays(Monee);
map.removeOverlays(Peoria);
map.removeOverlays(Rockford);
map.removeOverlays(Saint_Francisville);
map.removeOverlays(Skokie);
map.removeOverlays(Wyoming);
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(Bartlett);map.removeOverlays(Aurora);
map.removeOverlays(Bartlett);
map.removeOverlays(Belvidere);
map.removeOverlays(Charleston);
map.removeOverlays(Chicago);
map.removeOverlays(Du_Quoin);
map.removeOverlays(Elmhurst);
map.removeOverlays(Freeport);
map.removeOverlays(Glenview);
map.removeOverlays(Godfrey);
map.removeOverlays(Harvey);
map.removeOverlays(Moline);
map.removeOverlays(Monee);
map.removeOverlays(Peoria);
map.removeOverlays(Rockford);
map.removeOverlays(Saint_Francisville);
map.removeOverlays(Skokie);
map.removeOverlays(Wyoming);
map.addOverlays(Aurora);
centerByArray(Aurora, false, false);
cntMarker += Aurora.length;
map.addOverlays(Bartlett);
centerByArray(Bartlett, false, false);
cntMarker += Bartlett.length;
map.addOverlays(Belvidere);
centerByArray(Belvidere, false, false);
cntMarker += Belvidere.length;
map.addOverlays(Charleston);
centerByArray(Charleston, false, false);
cntMarker += Charleston.length;
map.addOverlays(Chicago);
centerByArray(Chicago, false, false);
cntMarker += Chicago.length;
map.addOverlays(Du_Quoin);
centerByArray(Du_Quoin, false, false);
cntMarker += Du_Quoin.length;
map.addOverlays(Elmhurst);
centerByArray(Elmhurst, false, false);
cntMarker += Elmhurst.length;
map.addOverlays(Freeport);
centerByArray(Freeport, false, false);
cntMarker += Freeport.length;
map.addOverlays(Glenview);
centerByArray(Glenview, false, false);
cntMarker += Glenview.length;
map.addOverlays(Godfrey);
centerByArray(Godfrey, false, false);
cntMarker += Godfrey.length;
map.addOverlays(Harvey);
centerByArray(Harvey, false, false);
cntMarker += Harvey.length;
map.addOverlays(Moline);
centerByArray(Moline, false, false);
cntMarker += Moline.length;
map.addOverlays(Monee);
centerByArray(Monee, false, false);
cntMarker += Monee.length;
map.addOverlays(Peoria);
centerByArray(Peoria, false, false);
cntMarker += Peoria.length;
map.addOverlays(Rockford);
centerByArray(Rockford, false, false);
cntMarker += Rockford.length;
map.addOverlays(Saint_Francisville);
centerByArray(Saint_Francisville, false, false);
cntMarker += Saint_Francisville.length;
map.addOverlays(Skokie);
centerByArray(Skokie, false, false);
cntMarker += Skokie.length;
map.addOverlays(Wyoming);
centerByArray(Wyoming, false, false);
cntMarker += Wyoming.length;
centerByArray(Bartlett,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///8913,8424,31238,34329,8553,9700,8951,31199,8424,33523,31238,8628,8952,9053,9851,9520,9665,8553,9700,9816,8629,32365,31274,9670,9555,9857,9144,9342,9666,31199,/all');
//window.open('/map.php?type=2&schools=8913,8424,31238,34329,8553,9700,8951,31199,8424,33523,31238,8628,8952,9053,9851,9520,9665,8553,9700,9816,8629,32365,31274,9670,9555,9857,9144,9342,9666,31199,&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;
}