function addMarkers(){
mySelect = document.getElementById('selection');
Birmingham = [];Bessemer = [];Concord = [];Hueytown = [];Rock_Creek = [];Hoover = [];Fairfield = [];Gardendale = [];mySelect.options[mySelect.options.length] = new Option("Bessemer schools",'all=Bessemer');
mySelect.options[mySelect.options.length] = new Option("Birmingham schools",'all=Birmingham');
mySelect.options[mySelect.options.length] = new Option("Concord schools",'all=Concord');
mySelect.options[mySelect.options.length] = new Option("Fairfield schools",'all=Fairfield');
mySelect.options[mySelect.options.length] = new Option("Gardendale schools",'all=Gardendale');
mySelect.options[mySelect.options.length] = new Option("Hoover schools",'all=Hoover');
mySelect.options[mySelect.options.length] = new Option("Hueytown schools",'all=Hueytown');
mySelect.options[mySelect.options.length] = new Option("Rock Creek schools",'all=Rock_Creek');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.76044400,33.51348900),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Altamont School",'Birmingham=' + Birmingham.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.78837600,33.49964600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Arlington School",'Birmingham=' + Birmingham.length);
Bessemer[Bessemer.length] = createMarker(new GPoint(-86.99187300,33.35571200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bessemer Academy",'Bessemer=' + Bessemer.length);
Bessemer[Bessemer.length] = createMarker(new GPoint(-86.96704700,33.36573800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brentwood Christian Academy",'Bessemer=' + Bessemer.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.75993900,33.41589500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Briarwood Christian School",'Birmingham=' + Birmingham.length);
Concord[Concord.length] = createMarker(new GPoint(-87.05733600,33.46468300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary At Home Christian School",'Concord=' + Concord.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.88518700,33.49209400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Park Christian Schools",'Birmingham=' + Birmingham.length);
Hueytown[Hueytown.length] = createMarker(new GPoint(-86.98580400,33.42388500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Deeper Life Academy & Daycare",'Hueytown=' + Hueytown.length);
Bessemer[Bessemer.length] = createMarker(new GPoint(-87.01426300,33.34947900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Flint Hill Christian School",'Bessemer=' + Bessemer.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.88297700,33.57646800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gloryland Christian Academy",'Birmingham=' + Birmingham.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.68666300,33.62649600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Good Samaritan Baptist School",'Birmingham=' + Birmingham.length);
Rock_Creek[Rock_Creek.length] = createMarker(new GPoint(-87.08319000,33.48590500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harvest Christian School",'Rock_Creek=' + Rock_Creek.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.73053600,33.54910100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Higdon Hill School",'Birmingham=' + Birmingham.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.88166900,33.51017100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family Catholic High School",'Birmingham=' + Birmingham.length);
Hoover[Hoover.length] = createMarker(new GPoint(-86.79522800,33.38879900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hoover Christian School",'Hoover=' + Hoover.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.64569300,33.54885700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jefferson Christian Academy",'Birmingham=' + Birmingham.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.89370000,33.50720000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jesus Christ Christian School",'Birmingham=' + Birmingham.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.83209600,33.44239200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("John Carroll Catholic High School",'Birmingham=' + Birmingham.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.75640000,33.53750000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maranathan Academy",'Birmingham=' + Birmingham.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.87636300,33.48845200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Miracle Deliverance Temple Learning Academy",'Birmingham=' + Birmingham.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.63726700,33.65242200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mountain View Baptist School",'Birmingham=' + Birmingham.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.68939900,33.60311800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Parkway Christian Academy",'Birmingham=' + Birmingham.length);
Fairfield[Fairfield.length] = createMarker(new GPoint(-86.91402300,33.49164700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Restoration Academy",'Fairfield=' + Fairfield.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.75627300,33.54925500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rushton School",'Birmingham=' + Birmingham.length);
Hoover[Hoover.length] = createMarker(new GPoint(-86.83310700,33.41539900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shades Mtn. Christian School",'Hoover=' + Hoover.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.74603300,33.50665000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Spring Valley School",'Birmingham=' + Birmingham.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.80543500,33.50338700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Sunshine School At Children's Hospital",'Birmingham=' + Birmingham.length);
Gardendale[Gardendale.length] = createMarker(new GPoint(-86.81947200,33.69048100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tabernacle Christian School",'Gardendale=' + Gardendale.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.80450300,33.50504500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Uab Psychiatric Prog. Hosp. School",'Birmingham=' + Birmingham.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.80543500,33.50338700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Vaughn School The",'Birmingham=' + Birmingham.length);
Bessemer[Bessemer.length] = createMarker(new GPoint(-86.95180000,33.40730000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Victory Christian Academy",'Bessemer=' + Bessemer.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.71431000,33.63139600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Winewood Christian School Inc",'Birmingham=' + Birmingham.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/////2/' + showArray);
map.removeOverlays(Bessemer);
map.removeOverlays(Birmingham);
map.removeOverlays(Concord);
map.removeOverlays(Fairfield);
map.removeOverlays(Gardendale);
map.removeOverlays(Hoover);
map.removeOverlays(Hueytown);
map.removeOverlays(Rock_Creek);
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(Birmingham);map.removeOverlays(Bessemer);
map.removeOverlays(Birmingham);
map.removeOverlays(Concord);
map.removeOverlays(Fairfield);
map.removeOverlays(Gardendale);
map.removeOverlays(Hoover);
map.removeOverlays(Hueytown);
map.removeOverlays(Rock_Creek);
map.addOverlays(Bessemer);
centerByArray(Bessemer, false, false);
cntMarker += Bessemer.length;
map.addOverlays(Birmingham);
centerByArray(Birmingham, false, false);
cntMarker += Birmingham.length;
map.addOverlays(Concord);
centerByArray(Concord, false, false);
cntMarker += Concord.length;
map.addOverlays(Fairfield);
centerByArray(Fairfield, false, false);
cntMarker += Fairfield.length;
map.addOverlays(Gardendale);
centerByArray(Gardendale, false, false);
cntMarker += Gardendale.length;
map.addOverlays(Hoover);
centerByArray(Hoover, false, false);
cntMarker += Hoover.length;
map.addOverlays(Hueytown);
centerByArray(Hueytown, false, false);
cntMarker += Hueytown.length;
map.addOverlays(Rock_Creek);
centerByArray(Rock_Creek, false, false);
cntMarker += Rock_Creek.length;
centerByArray(Birmingham,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=2&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;
}