function addMarkers(){
mySelect = document.getElementById('selection');
Dupo = [];East_Peoria = [];Carbondale = [];Bourbonnais = [];Decatur = [];Homewood = [];Chicago = [];Roberts = [];Robbins = [];Peoria = [];Forrest = [];Pana = [];Pinckneyville = [];Riverdale = [];Zion = [];Bellwood = [];mySelect.options[mySelect.options.length] = new Option("Bellwood schools",'all=Bellwood');
mySelect.options[mySelect.options.length] = new Option("Bourbonnais schools",'all=Bourbonnais');
mySelect.options[mySelect.options.length] = new Option("Carbondale schools",'all=Carbondale');
mySelect.options[mySelect.options.length] = new Option("Chicago schools",'all=Chicago');
mySelect.options[mySelect.options.length] = new Option("Decatur schools",'all=Decatur');
mySelect.options[mySelect.options.length] = new Option("Dupo schools",'all=Dupo');
mySelect.options[mySelect.options.length] = new Option("East Peoria schools",'all=East_Peoria');
mySelect.options[mySelect.options.length] = new Option("Forrest schools",'all=Forrest');
mySelect.options[mySelect.options.length] = new Option("Homewood schools",'all=Homewood');
mySelect.options[mySelect.options.length] = new Option("Pana schools",'all=Pana');
mySelect.options[mySelect.options.length] = new Option("Peoria schools",'all=Peoria');
mySelect.options[mySelect.options.length] = new Option("Pinckneyville schools",'all=Pinckneyville');
mySelect.options[mySelect.options.length] = new Option("Riverdale schools",'all=Riverdale');
mySelect.options[mySelect.options.length] = new Option("Robbins schools",'all=Robbins');
mySelect.options[mySelect.options.length] = new Option("Roberts schools",'all=Roberts');
mySelect.options[mySelect.options.length] = new Option("Zion schools",'all=Zion');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Dupo[Dupo.length] = createMarker(new GPoint(-90.20917300,38.51574300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Apostolic Learning Academy",'Dupo=' + Dupo.length);
East_Peoria[East_Peoria.length] = createMarker(new GPoint(-89.53920000,40.69260000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Life Academy",'East_Peoria=' + East_Peoria.length);
Carbondale[Carbondale.length] = createMarker(new GPoint(-89.27271700,37.73096500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ed Resource Center",'Carbondale=' + Carbondale.length);
Bourbonnais[Bourbonnais.length] = createMarker(new GPoint(-87.87780000,41.16930000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gospel Assembly Christian School",'Bourbonnais=' + Bourbonnais.length);
Decatur[Decatur.length] = createMarker(new GPoint(-88.90105700,39.82841700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hillside Bethel Christian School",'Decatur=' + Decatur.length);
Homewood[Homewood.length] = createMarker(new GPoint(-87.69418200,41.55119200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Homewood Community Academy",'Homewood=' + Homewood.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.67950600,41.75006200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Liberty Temple Full Gospel Academy",'Chicago=' + Chicago.length);
Roberts[Roberts.length] = createMarker(new GPoint(-88.17970000,40.62360000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Living Word Christian School",'Roberts=' + Roberts.length);
Robbins[Robbins.length] = createMarker(new GPoint(-87.71000000,41.64320000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mary P Moody Christian Academy",'Robbins=' + Robbins.length);
Chicago[Chicago.length] = createMarker(new GPoint(-87.55988300,41.70986300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mighty God Christian Academy",'Chicago=' + Chicago.length);
Peoria[Peoria.length] = createMarker(new GPoint(-89.64906600,40.67506300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Life Christian Academy",'Peoria=' + Peoria.length);
Forrest[Forrest.length] = createMarker(new GPoint(-88.40611900,40.75387000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Open Door Of Hope Christian Academy",'Forrest=' + Forrest.length);
Pana[Pana.length] = createMarker(new GPoint(-89.09029400,39.39396800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pana Christian Academy",'Pana=' + Pana.length);
Pinckneyville[Pinckneyville.length] = createMarker(new GPoint(-89.37949300,38.07747000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pinckneyville Christian Academy",'Pinckneyville=' + Pinckneyville.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);
Chicago[Chicago.length] = createMarker(new GPoint(-87.61512800,41.75009500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rescue Missionary Christian Church Ctr & School",'Chicago=' + Chicago.length);
Zion[Zion.length] = createMarker(new GPoint(-87.87303300,42.47248200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Spirit Of Life Christian Ed Un",'Zion=' + Zion.length);
Bellwood[Bellwood.length] = createMarker(new GPoint(-87.86147600,41.88555700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("True Vine Christian Academy",'Bellwood=' + Bellwood.length);
map.removeOverlays(Bellwood);
map.removeOverlays(Bourbonnais);
map.removeOverlays(Carbondale);
map.removeOverlays(Chicago);
map.removeOverlays(Decatur);
map.removeOverlays(Dupo);
map.removeOverlays(East_Peoria);
map.removeOverlays(Forrest);
map.removeOverlays(Homewood);
map.removeOverlays(Pana);
map.removeOverlays(Peoria);
map.removeOverlays(Pinckneyville);
map.removeOverlays(Riverdale);
map.removeOverlays(Robbins);
map.removeOverlays(Roberts);
map.removeOverlays(Zion);
setTimeout(function(){map.addOverlays(Bellwood)},1000);
setTimeout(function(){map.addOverlays(Bourbonnais)},1000);
setTimeout(function(){map.addOverlays(Carbondale)},1000);
setTimeout(function(){map.addOverlays(Chicago)},1000);
setTimeout(function(){map.addOverlays(Decatur)},1000);
setTimeout(function(){map.addOverlays(Dupo)},1000);
setTimeout(function(){map.addOverlays(East_Peoria)},1000);
setTimeout(function(){map.addOverlays(Forrest)},1000);
setTimeout(function(){map.addOverlays(Homewood)},1000);
setTimeout(function(){map.addOverlays(Pana)},1000);
setTimeout(function(){map.addOverlays(Peoria)},1000);
setTimeout(function(){map.addOverlays(Pinckneyville)},1000);
setTimeout(function(){map.addOverlays(Riverdale)},1000);
setTimeout(function(){map.addOverlays(Robbins)},1000);
setTimeout(function(){map.addOverlays(Roberts)},1000);
setTimeout(function(){map.addOverlays(Zion)},1000);
maxLng = -87.55988300;
maxLat = 42.47248200;
minLng = -90.20917300;
minLat = 37.73096500;
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(Bellwood);
map.removeOverlays(Bourbonnais);
map.removeOverlays(Carbondale);
map.removeOverlays(Chicago);
map.removeOverlays(Decatur);
map.removeOverlays(Dupo);
map.removeOverlays(East_Peoria);
map.removeOverlays(Forrest);
map.removeOverlays(Homewood);
map.removeOverlays(Pana);
map.removeOverlays(Peoria);
map.removeOverlays(Pinckneyville);
map.removeOverlays(Riverdale);
map.removeOverlays(Robbins);
map.removeOverlays(Roberts);
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(Dupo);map.removeOverlays(Bellwood);
map.removeOverlays(Bourbonnais);
map.removeOverlays(Carbondale);
map.removeOverlays(Chicago);
map.removeOverlays(Decatur);
map.removeOverlays(Dupo);
map.removeOverlays(East_Peoria);
map.removeOverlays(Forrest);
map.removeOverlays(Homewood);
map.removeOverlays(Pana);
map.removeOverlays(Peoria);
map.removeOverlays(Pinckneyville);
map.removeOverlays(Riverdale);
map.removeOverlays(Robbins);
map.removeOverlays(Roberts);
map.removeOverlays(Zion);
map.addOverlays(Bellwood);
centerByArray(Bellwood, false, false);
cntMarker += Bellwood.length;
map.addOverlays(Bourbonnais);
centerByArray(Bourbonnais, false, false);
cntMarker += Bourbonnais.length;
map.addOverlays(Carbondale);
centerByArray(Carbondale, false, false);
cntMarker += Carbondale.length;
map.addOverlays(Chicago);
centerByArray(Chicago, false, false);
cntMarker += Chicago.length;
map.addOverlays(Decatur);
centerByArray(Decatur, false, false);
cntMarker += Decatur.length;
map.addOverlays(Dupo);
centerByArray(Dupo, false, false);
cntMarker += Dupo.length;
map.addOverlays(East_Peoria);
centerByArray(East_Peoria, false, false);
cntMarker += East_Peoria.length;
map.addOverlays(Forrest);
centerByArray(Forrest, false, false);
cntMarker += Forrest.length;
map.addOverlays(Homewood);
centerByArray(Homewood, false, false);
cntMarker += Homewood.length;
map.addOverlays(Pana);
centerByArray(Pana, false, false);
cntMarker += Pana.length;
map.addOverlays(Peoria);
centerByArray(Peoria, false, false);
cntMarker += Peoria.length;
map.addOverlays(Pinckneyville);
centerByArray(Pinckneyville, false, false);
cntMarker += Pinckneyville.length;
map.addOverlays(Riverdale);
centerByArray(Riverdale, false, false);
cntMarker += Riverdale.length;
map.addOverlays(Robbins);
centerByArray(Robbins, false, false);
cntMarker += Robbins.length;
map.addOverlays(Roberts);
centerByArray(Roberts, false, false);
cntMarker += Roberts.length;
map.addOverlays(Zion);
centerByArray(Zion, false, false);
cntMarker += Zion.length;
centerByArray(Dupo,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///9730,8692,8616,8953,8718,33869,8558,33522,33806,9019,9113,8876,9228,9730,8692,8616,8859,8953,9149,8718,33869,8558,8748,33806,9019,9113,9694,8918,8876,/all');
//window.open('/map.php?type=2&schools=9730,8692,8616,8953,8718,33869,8558,33522,33806,9019,9113,8876,9228,9730,8692,8616,8859,8953,9149,8718,33869,8558,8748,33806,9019,9113,9694,8918,8876,&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;
}