function addMarkers(){
mySelect = document.getElementById('selection');
Pensacola = [];Walnut_Hill = [];Molino = [];mySelect.options[mySelect.options.length] = new Option("Molino schools",'all=Molino');
mySelect.options[mySelect.options.length] = new Option("Pensacola schools",'all=Pensacola');
mySelect.options[mySelect.options.length] = new Option("Walnut Hill schools",'all=Walnut_Hill');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.16780300,30.49860900),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Aletheia Christian Academy",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.37822000,30.53520000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Beulah Christian Academy",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.20917800,30.52843000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Blessed Star Christian School",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.29595900,30.43183700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Institute of Arts & Sciences",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.17897200,30.43958100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Creative Learning Academy",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.20163300,30.42683600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Hill Christian",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.21635000,30.41570900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Episcopal Day School Of Christ",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.21723800,30.42084000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Escambia Christian School",'Pensacola=' + Pensacola.length);
Walnut_Hill[Walnut_Hill.length] = createMarker(new GPoint(-87.44070000,30.89400000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heritage Christian Academy",'Walnut_Hill=' + Walnut_Hill.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.22900400,30.44088000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("House Of God Academy",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.25487100,30.47208400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jubilee Christian Academy",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.29994700,30.42266400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Flower School",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.25614900,30.47504700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marcus Pointe Christian School And Preschool",'Pensacola=' + Pensacola.length);
Molino[Molino.length] = createMarker(new GPoint(-87.37700000,30.72650000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Molino Christian School",'Molino=' + Molino.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.20298400,30.42593600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Pensacola",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.20264300,30.43118000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pensacola Liberal Arts",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.32242300,30.51344700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pensacola Mennonite Christian School",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.22129300,30.52282600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pensacola Sda Jr. Academy",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.27400300,30.38653300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Redeemer Lutheran School",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.20449400,30.43149800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart Cathedral School",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.27812200,30.38357500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John The Evangelist School",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.17943300,30.43962100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Paul Catholic School",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.20908600,30.40903000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Seville Montessori School",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.19023100,30.46162600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sl Jones Christian Academy",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.20606200,30.43816100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Smart Schools Inc",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.19788900,30.51703000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinitas Christian School",'Pensacola=' + Pensacola.length);
Pensacola[Pensacola.length] = createMarker(new GPoint(-87.40254600,30.35923800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Triple D's Christian Academy",'Pensacola=' + Pensacola.length);
Walnut_Hill[Walnut_Hill.length] = createMarker(new GPoint(-87.43493900,30.84414100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Walnut Hill Christian School",'Walnut_Hill=' + Walnut_Hill.length);
} // 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/////1/' + showArray);
map.removeOverlays(Molino);
map.removeOverlays(Pensacola);
map.removeOverlays(Walnut_Hill);
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(Pensacola);map.removeOverlays(Molino);
map.removeOverlays(Pensacola);
map.removeOverlays(Walnut_Hill);
map.addOverlays(Molino);
centerByArray(Molino, false, false);
cntMarker += Molino.length;
map.addOverlays(Pensacola);
centerByArray(Pensacola, false, false);
cntMarker += Pensacola.length;
map.addOverlays(Walnut_Hill);
centerByArray(Walnut_Hill, false, false);
cntMarker += Walnut_Hill.length;
centerByArray(Pensacola,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////all');
//window.open('/map.php?type=1&schools=&school_level=1&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;
}