function addMarkers(){
mySelect = document.getElementById('selection');
Villanova = [];Rosemont = [];Drexel_Hill = [];Scraton = [];Scranton = [];Bryn_Mawr = [];Old_Forge = [];Newtown_Square = [];Pittsburgh = [];Tyrone = [];Gwynedd_Valley = [];Philadelphia = [];Lititz = [];Birdsboro = [];Merion_Station = [];Flourtown = [];Jenkintown = [];Holland = [];Malvern = [];Immaculata = [];mySelect.options[mySelect.options.length] = new Option("Birdsboro schools",'all=Birdsboro');
mySelect.options[mySelect.options.length] = new Option("Bryn Mawr schools",'all=Bryn_Mawr');
mySelect.options[mySelect.options.length] = new Option("Drexel Hill schools",'all=Drexel_Hill');
mySelect.options[mySelect.options.length] = new Option("Flourtown schools",'all=Flourtown');
mySelect.options[mySelect.options.length] = new Option("Gwynedd Valley schools",'all=Gwynedd_Valley');
mySelect.options[mySelect.options.length] = new Option("Holland schools",'all=Holland');
mySelect.options[mySelect.options.length] = new Option("Immaculata schools",'all=Immaculata');
mySelect.options[mySelect.options.length] = new Option("Jenkintown schools",'all=Jenkintown');
mySelect.options[mySelect.options.length] = new Option("Lititz schools",'all=Lititz');
mySelect.options[mySelect.options.length] = new Option("Malvern schools",'all=Malvern');
mySelect.options[mySelect.options.length] = new Option("Merion Station schools",'all=Merion_Station');
mySelect.options[mySelect.options.length] = new Option("Newtown Square schools",'all=Newtown_Square');
mySelect.options[mySelect.options.length] = new Option("Old Forge schools",'all=Old_Forge');
mySelect.options[mySelect.options.length] = new Option("Philadelphia schools",'all=Philadelphia');
mySelect.options[mySelect.options.length] = new Option("Pittsburgh schools",'all=Pittsburgh');
mySelect.options[mySelect.options.length] = new Option("Rosemont schools",'all=Rosemont');
mySelect.options[mySelect.options.length] = new Option("Scranton schools",'all=Scranton');
mySelect.options[mySelect.options.length] = new Option("Scraton schools",'all=Scraton');
mySelect.options[mySelect.options.length] = new Option("Tyrone schools",'all=Tyrone');
mySelect.options[mySelect.options.length] = new Option("Villanova schools",'all=Villanova');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Villanova[Villanova.length] = createMarker(new GPoint(-75.36918300,40.02155700),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Academy-notre Dame De Namur",'Villanova=' + Villanova.length);
Rosemont[Rosemont.length] = createMarker(new GPoint(-75.32421100,40.02777100),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Agnes Irwin School",'Rosemont=' + Rosemont.length);
Drexel_Hill[Drexel_Hill.length] = createMarker(new GPoint(-75.28196800,39.95169800),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Archbishop Prendergast High School",'Drexel_Hill=' + Drexel_Hill.length);
Scraton[Scraton.length] = createMarker(new GPoint(-75.65468200,41.40906500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bais Yaakov High School",'Scraton=' + Scraton.length);
Scranton[Scranton.length] = createMarker(new GPoint(-75.65325800,41.40752300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bais Yaakov Of Scranton",'Scranton=' + Scranton.length);
Bryn_Mawr[Bryn_Mawr.length] = createMarker(new GPoint(-75.31357900,40.02246700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("The Baldwin School",'Bryn_Mawr=' + Bryn_Mawr.length);
Old_Forge[Old_Forge.length] = createMarker(new GPoint(-75.73725700,41.37762700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bethel Christian Academy",'Old_Forge=' + Old_Forge.length);
Newtown_Square[Newtown_Square.length] = createMarker(new GPoint(-75.40269700,40.02126700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Devereux Gateway School",'Newtown_Square=' + Newtown_Square.length);
Pittsburgh[Pittsburgh.length] = createMarker(new GPoint(-79.91853200,40.45332500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("The Ellis School",'Pittsburgh=' + Pittsburgh.length);
Tyrone[Tyrone.length] = createMarker(new GPoint(-78.24090000,40.66350000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("The Grier School",'Tyrone=' + Tyrone.length);
Gwynedd_Valley[Gwynedd_Valley.length] = createMarker(new GPoint(-75.25008500,40.18551400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gwynedd Mercy Academy H.S.",'Gwynedd_Valley=' + Gwynedd_Valley.length);
Philadelphia[Philadelphia.length] = createMarker(new GPoint(-75.17009600,39.95986400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("John W Hallahan Catholic Girls' High School",'Philadelphia=' + Philadelphia.length);
Lititz[Lititz.length] = createMarker(new GPoint(-76.30198500,40.15618200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Linden Hall",'Lititz=' + Lititz.length);
Birdsboro[Birdsboro.length] = createMarker(new GPoint(-75.81732700,40.26769000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Live N Learn Smile Center",'Birdsboro=' + Birdsboro.length);
Merion_Station[Merion_Station.length] = createMarker(new GPoint(-75.24917700,40.00766300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Merion Mercy Academy",'Merion_Station=' + Merion_Station.length);
Flourtown[Flourtown.length] = createMarker(new GPoint(-75.21803100,40.09805100),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mount St Joseph Academy",'Flourtown=' + Flourtown.length);
Philadelphia[Philadelphia.length] = createMarker(new GPoint(-74.99024600,40.06039200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Nazareth Academy High School",'Philadelphia=' + Philadelphia.length);
Pittsburgh[Pittsburgh.length] = createMarker(new GPoint(-79.94995500,40.44860400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oakland Catholic High School",'Pittsburgh=' + Pittsburgh.length);
Jenkintown[Jenkintown.length] = createMarker(new GPoint(-75.10344500,40.08799700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("St. Basil Academy",'Jenkintown=' + Jenkintown.length);
Pittsburgh[Pittsburgh.length] = createMarker(new GPoint(-79.96758200,40.39921600),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sleepy Hollow",'Pittsburgh=' + Pittsburgh.length);
Philadelphia[Philadelphia.length] = createMarker(new GPoint(-75.21084900,40.06040300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Springside School",'Philadelphia=' + Philadelphia.length);
Philadelphia[Philadelphia.length] = createMarker(new GPoint(-75.03448900,40.03067000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("St Hubert Catholic High School For Girls",'Philadelphia=' + Philadelphia.length);
Holland[Holland.length] = createMarker(new GPoint(-74.98254100,40.20609400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Villa Joseph Marie High School",'Holland=' + Holland.length);
Malvern[Malvern.length] = createMarker(new GPoint(-75.50966500,40.03936300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Villa Maria Academy High School",'Malvern=' + Malvern.length);
Immaculata[Immaculata.length] = createMarker(new GPoint(-75.51503800,40.03558000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Villa Maria Academy Lower School",'Immaculata=' + Immaculata.length);
map.removeOverlays(Birdsboro);
map.removeOverlays(Bryn_Mawr);
map.removeOverlays(Drexel_Hill);
map.removeOverlays(Flourtown);
map.removeOverlays(Gwynedd_Valley);
map.removeOverlays(Holland);
map.removeOverlays(Immaculata);
map.removeOverlays(Jenkintown);
map.removeOverlays(Lititz);
map.removeOverlays(Malvern);
map.removeOverlays(Merion_Station);
map.removeOverlays(Newtown_Square);
map.removeOverlays(Old_Forge);
map.removeOverlays(Philadelphia);
map.removeOverlays(Pittsburgh);
map.removeOverlays(Rosemont);
map.removeOverlays(Scranton);
map.removeOverlays(Scraton);
map.removeOverlays(Tyrone);
map.removeOverlays(Villanova);
setTimeout(function(){map.addOverlays(Birdsboro)},1000);
setTimeout(function(){map.addOverlays(Bryn_Mawr)},1000);
setTimeout(function(){map.addOverlays(Drexel_Hill)},1000);
setTimeout(function(){map.addOverlays(Flourtown)},1000);
setTimeout(function(){map.addOverlays(Gwynedd_Valley)},1000);
setTimeout(function(){map.addOverlays(Holland)},1000);
setTimeout(function(){map.addOverlays(Immaculata)},1000);
setTimeout(function(){map.addOverlays(Jenkintown)},1000);
setTimeout(function(){map.addOverlays(Lititz)},1000);
setTimeout(function(){map.addOverlays(Malvern)},1000);
setTimeout(function(){map.addOverlays(Merion_Station)},1000);
setTimeout(function(){map.addOverlays(Newtown_Square)},1000);
setTimeout(function(){map.addOverlays(Old_Forge)},1000);
setTimeout(function(){map.addOverlays(Philadelphia)},1000);
setTimeout(function(){map.addOverlays(Pittsburgh)},1000);
setTimeout(function(){map.addOverlays(Rosemont)},1000);
setTimeout(function(){map.addOverlays(Scranton)},1000);
setTimeout(function(){map.addOverlays(Scraton)},1000);
setTimeout(function(){map.addOverlays(Tyrone)},1000);
setTimeout(function(){map.addOverlays(Villanova)},1000);
maxLng = -74.98254100;
maxLat = 41.40906500;
minLng = -79.96758200;
minLat = 39.95169800;
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(Birdsboro);
map.removeOverlays(Bryn_Mawr);
map.removeOverlays(Drexel_Hill);
map.removeOverlays(Flourtown);
map.removeOverlays(Gwynedd_Valley);
map.removeOverlays(Holland);
map.removeOverlays(Immaculata);
map.removeOverlays(Jenkintown);
map.removeOverlays(Lititz);
map.removeOverlays(Malvern);
map.removeOverlays(Merion_Station);
map.removeOverlays(Newtown_Square);
map.removeOverlays(Old_Forge);
map.removeOverlays(Philadelphia);
map.removeOverlays(Pittsburgh);
map.removeOverlays(Rosemont);
map.removeOverlays(Scranton);
map.removeOverlays(Scraton);
map.removeOverlays(Tyrone);
map.removeOverlays(Villanova);
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(Villanova);map.removeOverlays(Birdsboro);
map.removeOverlays(Bryn_Mawr);
map.removeOverlays(Drexel_Hill);
map.removeOverlays(Flourtown);
map.removeOverlays(Gwynedd_Valley);
map.removeOverlays(Holland);
map.removeOverlays(Immaculata);
map.removeOverlays(Jenkintown);
map.removeOverlays(Lititz);
map.removeOverlays(Malvern);
map.removeOverlays(Merion_Station);
map.removeOverlays(Newtown_Square);
map.removeOverlays(Old_Forge);
map.removeOverlays(Philadelphia);
map.removeOverlays(Pittsburgh);
map.removeOverlays(Rosemont);
map.removeOverlays(Scranton);
map.removeOverlays(Scraton);
map.removeOverlays(Tyrone);
map.removeOverlays(Villanova);
map.addOverlays(Birdsboro);
centerByArray(Birdsboro, false, false);
cntMarker += Birdsboro.length;
map.addOverlays(Bryn_Mawr);
centerByArray(Bryn_Mawr, false, false);
cntMarker += Bryn_Mawr.length;
map.addOverlays(Drexel_Hill);
centerByArray(Drexel_Hill, false, false);
cntMarker += Drexel_Hill.length;
map.addOverlays(Flourtown);
centerByArray(Flourtown, false, false);
cntMarker += Flourtown.length;
map.addOverlays(Gwynedd_Valley);
centerByArray(Gwynedd_Valley, false, false);
cntMarker += Gwynedd_Valley.length;
map.addOverlays(Holland);
centerByArray(Holland, false, false);
cntMarker += Holland.length;
map.addOverlays(Immaculata);
centerByArray(Immaculata, false, false);
cntMarker += Immaculata.length;
map.addOverlays(Jenkintown);
centerByArray(Jenkintown, false, false);
cntMarker += Jenkintown.length;
map.addOverlays(Lititz);
centerByArray(Lititz, false, false);
cntMarker += Lititz.length;
map.addOverlays(Malvern);
centerByArray(Malvern, false, false);
cntMarker += Malvern.length;
map.addOverlays(Merion_Station);
centerByArray(Merion_Station, false, false);
cntMarker += Merion_Station.length;
map.addOverlays(Newtown_Square);
centerByArray(Newtown_Square, false, false);
cntMarker += Newtown_Square.length;
map.addOverlays(Old_Forge);
centerByArray(Old_Forge, false, false);
cntMarker += Old_Forge.length;
map.addOverlays(Philadelphia);
centerByArray(Philadelphia, false, false);
cntMarker += Philadelphia.length;
map.addOverlays(Pittsburgh);
centerByArray(Pittsburgh, false, false);
cntMarker += Pittsburgh.length;
map.addOverlays(Rosemont);
centerByArray(Rosemont, false, false);
cntMarker += Rosemont.length;
map.addOverlays(Scranton);
centerByArray(Scranton, false, false);
cntMarker += Scranton.length;
map.addOverlays(Scraton);
centerByArray(Scraton, false, false);
cntMarker += Scraton.length;
map.addOverlays(Tyrone);
centerByArray(Tyrone, false, false);
cntMarker += Tyrone.length;
map.addOverlays(Villanova);
centerByArray(Villanova, false, false);
cntMarker += Villanova.length;
centerByArray(Villanova,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///23069,23045,24161,23649,25125,24680,23955,25126,24097,23435,34445,23825,24204,24622,24755,23472,24267,32888,23001,31728,23066,25031,22994,23983,23069,25129,23435,24622,23472,23001,22994,/all');
//window.open('/map.php?type=2&schools=23069,23045,24161,23649,25125,24680,23955,25126,24097,23435,34445,23825,24204,24622,24755,23472,24267,32888,23001,31728,23066,25031,22994,23983,23069,25129,23435,24622,23472,23001,22994,&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;
}