function addMarkers(){
mySelect = document.getElementById('selection');
Birmingham = [];Athens = [];Prattville = [];Daphne = [];Pell_City = [];Concord = [];Gadsden = [];Harpersville = [];Scottsboro = [];Phenix_City = [];Huntsville = [];Dothan = [];Indian_Springs = [];Selma = [];Lowndesboro = [];Cecil = [];Monroeville = [];Montgomery = [];Mobile = [];Toxey = [];Lanett = [];Sumiton = [];Eutaw = [];Camden = [];mySelect.options[mySelect.options.length] = new Option("Athens schools",'all=Athens');
mySelect.options[mySelect.options.length] = new Option("Birmingham schools",'all=Birmingham');
mySelect.options[mySelect.options.length] = new Option("Camden schools",'all=Camden');
mySelect.options[mySelect.options.length] = new Option("Cecil schools",'all=Cecil');
mySelect.options[mySelect.options.length] = new Option("Concord schools",'all=Concord');
mySelect.options[mySelect.options.length] = new Option("Daphne schools",'all=Daphne');
mySelect.options[mySelect.options.length] = new Option("Dothan schools",'all=Dothan');
mySelect.options[mySelect.options.length] = new Option("Eutaw schools",'all=Eutaw');
mySelect.options[mySelect.options.length] = new Option("Gadsden schools",'all=Gadsden');
mySelect.options[mySelect.options.length] = new Option("Harpersville schools",'all=Harpersville');
mySelect.options[mySelect.options.length] = new Option("Huntsville schools",'all=Huntsville');
mySelect.options[mySelect.options.length] = new Option("Indian Springs schools",'all=Indian_Springs');
mySelect.options[mySelect.options.length] = new Option("Lanett schools",'all=Lanett');
mySelect.options[mySelect.options.length] = new Option("Lowndesboro schools",'all=Lowndesboro');
mySelect.options[mySelect.options.length] = new Option("Mobile schools",'all=Mobile');
mySelect.options[mySelect.options.length] = new Option("Monroeville schools",'all=Monroeville');
mySelect.options[mySelect.options.length] = new Option("Montgomery schools",'all=Montgomery');
mySelect.options[mySelect.options.length] = new Option("Pell City schools",'all=Pell_City');
mySelect.options[mySelect.options.length] = new Option("Phenix City schools",'all=Phenix_City');
mySelect.options[mySelect.options.length] = new Option("Prattville schools",'all=Prattville');
mySelect.options[mySelect.options.length] = new Option("Scottsboro schools",'all=Scottsboro');
mySelect.options[mySelect.options.length] = new Option("Selma schools",'all=Selma');
mySelect.options[mySelect.options.length] = new Option("Sumiton schools",'all=Sumiton');
mySelect.options[mySelect.options.length] = new Option("Toxey schools",'all=Toxey');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.80846500,33.51933200),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Advent Episcopal Day School",'Birmingham=' + Birmingham.length);
Birmingham[Birmingham.length] = createMarker(new GPoint(-86.76044400,33.51348900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Altamont School",'Birmingham=' + Birmingham.length);
Athens[Athens.length] = createMarker(new GPoint(-86.95673200,34.79806900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Athens Bible School",'Athens=' + Athens.length);
Prattville[Prattville.length] = createMarker(new GPoint(-86.50330000,32.48250000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Autauga Academy",'Prattville=' + Prattville.length);
Daphne[Daphne.length] = createMarker(new GPoint(-87.90546600,30.60126500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bayside Academy",'Daphne=' + Daphne.length);
Pell_City[Pell_City.length] = createMarker(new GPoint(-86.35873900,33.59422700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bible Methodist Christian School",'Pell_City=' + Pell_City.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);
Gadsden[Gadsden.length] = createMarker(new GPoint(-85.92299300,34.05993800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Coosa Christian School",'Gadsden=' + Gadsden.length);
Harpersville[Harpersville.length] = createMarker(new GPoint(-86.44537400,33.33705000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Coosa Valley Academy",'Harpersville=' + Harpersville.length);
Scottsboro[Scottsboro.length] = createMarker(new GPoint(-86.02723200,34.67074500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cumberland Presbyterian Pre-school",'Scottsboro=' + Scottsboro.length);
Phenix_City[Phenix_City.length] = createMarker(new GPoint(-85.10080000,32.38770000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Glenwood School Inc",'Phenix_City=' + Phenix_City.length);
Huntsville[Huntsville.length] = createMarker(new GPoint(-86.60190600,34.73449100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family Parochial School",'Huntsville=' + Huntsville.length);
Dothan[Dothan.length] = createMarker(new GPoint(-85.44846000,31.24355700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Houston Academy",'Dothan=' + Dothan.length);
Indian_Springs[Indian_Springs.length] = createMarker(new GPoint(-86.77080300,33.34338900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Indian Springs School",'Indian_Springs=' + Indian_Springs.length);
Selma[Selma.length] = createMarker(new GPoint(-87.02350000,32.40580000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("John T Morgan Academy",'Selma=' + Selma.length);
Lowndesboro[Lowndesboro.length] = createMarker(new GPoint(-86.62600000,32.30150000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lowndes Academy",'Lowndesboro=' + Lowndesboro.length);
Cecil[Cecil.length] = createMarker(new GPoint(-86.01285900,32.30298900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Macon - East Montgomery Academy",'Cecil=' + Cecil.length);
Selma[Selma.length] = createMarker(new GPoint(-87.06024000,32.40525600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Meadowview Christian School",'Selma=' + Selma.length);
Monroeville[Monroeville.length] = createMarker(new GPoint(-87.32470000,31.52770000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Monroe Academy",'Monroeville=' + Monroeville.length);
Huntsville[Huntsville.length] = createMarker(new GPoint(-86.55849500,34.70528600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Randolph School",'Huntsville=' + Huntsville.length);
Montgomery[Montgomery.length] = createMarker(new GPoint(-86.20732900,32.34088800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. James School",'Montgomery=' + Montgomery.length);
Mobile[Mobile.length] = createMarker(new GPoint(-88.13395900,30.69659400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Paul's Episcopal School",'Mobile=' + Mobile.length);
Toxey[Toxey.length] = createMarker(new GPoint(-88.29220000,31.95300000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Choctaw Academy",'Toxey=' + Toxey.length);
Lanett[Lanett.length] = createMarker(new GPoint(-85.21620000,32.86510000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Springwood School",'Lanett=' + Lanett.length);
Sumiton[Sumiton.length] = createMarker(new GPoint(-87.04780000,33.75340000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sumiton Christian School",'Sumiton=' + Sumiton.length);
Mobile[Mobile.length] = createMarker(new GPoint(-88.10455900,30.69006400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ums-wright Preparatory School",'Mobile=' + Mobile.length);
Eutaw[Eutaw.length] = createMarker(new GPoint(-87.94800000,32.90460000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Warrior Academy",'Eutaw=' + Eutaw.length);
Camden[Camden.length] = createMarker(new GPoint(-87.30010000,32.01420000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wilcox Academy",'Camden=' + Camden.length);
map.removeOverlays(Athens);
map.removeOverlays(Birmingham);
map.removeOverlays(Camden);
map.removeOverlays(Cecil);
map.removeOverlays(Concord);
map.removeOverlays(Daphne);
map.removeOverlays(Dothan);
map.removeOverlays(Eutaw);
map.removeOverlays(Gadsden);
map.removeOverlays(Harpersville);
map.removeOverlays(Huntsville);
map.removeOverlays(Indian_Springs);
map.removeOverlays(Lanett);
map.removeOverlays(Lowndesboro);
map.removeOverlays(Mobile);
map.removeOverlays(Monroeville);
map.removeOverlays(Montgomery);
map.removeOverlays(Pell_City);
map.removeOverlays(Phenix_City);
map.removeOverlays(Prattville);
map.removeOverlays(Scottsboro);
map.removeOverlays(Selma);
map.removeOverlays(Sumiton);
map.removeOverlays(Toxey);
setTimeout(function(){map.addOverlays(Athens)},1000);
setTimeout(function(){map.addOverlays(Birmingham)},1000);
setTimeout(function(){map.addOverlays(Camden)},1000);
setTimeout(function(){map.addOverlays(Cecil)},1000);
setTimeout(function(){map.addOverlays(Concord)},1000);
setTimeout(function(){map.addOverlays(Daphne)},1000);
setTimeout(function(){map.addOverlays(Dothan)},1000);
setTimeout(function(){map.addOverlays(Eutaw)},1000);
setTimeout(function(){map.addOverlays(Gadsden)},1000);
setTimeout(function(){map.addOverlays(Harpersville)},1000);
setTimeout(function(){map.addOverlays(Huntsville)},1000);
setTimeout(function(){map.addOverlays(Indian_Springs)},1000);
setTimeout(function(){map.addOverlays(Lanett)},1000);
setTimeout(function(){map.addOverlays(Lowndesboro)},1000);
setTimeout(function(){map.addOverlays(Mobile)},1000);
setTimeout(function(){map.addOverlays(Monroeville)},1000);
setTimeout(function(){map.addOverlays(Montgomery)},1000);
setTimeout(function(){map.addOverlays(Pell_City)},1000);
setTimeout(function(){map.addOverlays(Phenix_City)},1000);
setTimeout(function(){map.addOverlays(Prattville)},1000);
setTimeout(function(){map.addOverlays(Scottsboro)},1000);
setTimeout(function(){map.addOverlays(Selma)},1000);
setTimeout(function(){map.addOverlays(Sumiton)},1000);
setTimeout(function(){map.addOverlays(Toxey)},1000);
maxLng = -85.10080000;
maxLat = 34.79806900;
minLng = -88.29220000;
minLat = 30.60126500;
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(Athens);
map.removeOverlays(Birmingham);
map.removeOverlays(Camden);
map.removeOverlays(Cecil);
map.removeOverlays(Concord);
map.removeOverlays(Daphne);
map.removeOverlays(Dothan);
map.removeOverlays(Eutaw);
map.removeOverlays(Gadsden);
map.removeOverlays(Harpersville);
map.removeOverlays(Huntsville);
map.removeOverlays(Indian_Springs);
map.removeOverlays(Lanett);
map.removeOverlays(Lowndesboro);
map.removeOverlays(Mobile);
map.removeOverlays(Monroeville);
map.removeOverlays(Montgomery);
map.removeOverlays(Pell_City);
map.removeOverlays(Phenix_City);
map.removeOverlays(Prattville);
map.removeOverlays(Scottsboro);
map.removeOverlays(Selma);
map.removeOverlays(Sumiton);
map.removeOverlays(Toxey);
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(Athens);
map.removeOverlays(Birmingham);
map.removeOverlays(Camden);
map.removeOverlays(Cecil);
map.removeOverlays(Concord);
map.removeOverlays(Daphne);
map.removeOverlays(Dothan);
map.removeOverlays(Eutaw);
map.removeOverlays(Gadsden);
map.removeOverlays(Harpersville);
map.removeOverlays(Huntsville);
map.removeOverlays(Indian_Springs);
map.removeOverlays(Lanett);
map.removeOverlays(Lowndesboro);
map.removeOverlays(Mobile);
map.removeOverlays(Monroeville);
map.removeOverlays(Montgomery);
map.removeOverlays(Pell_City);
map.removeOverlays(Phenix_City);
map.removeOverlays(Prattville);
map.removeOverlays(Scottsboro);
map.removeOverlays(Selma);
map.removeOverlays(Sumiton);
map.removeOverlays(Toxey);
map.addOverlays(Athens);
centerByArray(Athens, false, false);
cntMarker += Athens.length;
map.addOverlays(Birmingham);
centerByArray(Birmingham, false, false);
cntMarker += Birmingham.length;
map.addOverlays(Camden);
centerByArray(Camden, false, false);
cntMarker += Camden.length;
map.addOverlays(Cecil);
centerByArray(Cecil, false, false);
cntMarker += Cecil.length;
map.addOverlays(Concord);
centerByArray(Concord, false, false);
cntMarker += Concord.length;
map.addOverlays(Daphne);
centerByArray(Daphne, false, false);
cntMarker += Daphne.length;
map.addOverlays(Dothan);
centerByArray(Dothan, false, false);
cntMarker += Dothan.length;
map.addOverlays(Eutaw);
centerByArray(Eutaw, false, false);
cntMarker += Eutaw.length;
map.addOverlays(Gadsden);
centerByArray(Gadsden, false, false);
cntMarker += Gadsden.length;
map.addOverlays(Harpersville);
centerByArray(Harpersville, false, false);
cntMarker += Harpersville.length;
map.addOverlays(Huntsville);
centerByArray(Huntsville, false, false);
cntMarker += Huntsville.length;
map.addOverlays(Indian_Springs);
centerByArray(Indian_Springs, false, false);
cntMarker += Indian_Springs.length;
map.addOverlays(Lanett);
centerByArray(Lanett, false, false);
cntMarker += Lanett.length;
map.addOverlays(Lowndesboro);
centerByArray(Lowndesboro, false, false);
cntMarker += Lowndesboro.length;
map.addOverlays(Mobile);
centerByArray(Mobile, false, false);
cntMarker += Mobile.length;
map.addOverlays(Monroeville);
centerByArray(Monroeville, false, false);
cntMarker += Monroeville.length;
map.addOverlays(Montgomery);
centerByArray(Montgomery, false, false);
cntMarker += Montgomery.length;
map.addOverlays(Pell_City);
centerByArray(Pell_City, false, false);
cntMarker += Pell_City.length;
map.addOverlays(Phenix_City);
centerByArray(Phenix_City, false, false);
cntMarker += Phenix_City.length;
map.addOverlays(Prattville);
centerByArray(Prattville, false, false);
cntMarker += Prattville.length;
map.addOverlays(Scottsboro);
centerByArray(Scottsboro, false, false);
cntMarker += Scottsboro.length;
map.addOverlays(Selma);
centerByArray(Selma, false, false);
cntMarker += Selma.length;
map.addOverlays(Sumiton);
centerByArray(Sumiton, false, false);
cntMarker += Sumiton.length;
map.addOverlays(Toxey);
centerByArray(Toxey, false, false);
cntMarker += Toxey.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///12,285,333,161,35596,35595,133,324,51,52,222,136,248,159,269,312,180,259,19,108,14,175,277,243,12,2,285,333,161,35596,35595,133,324,51,52,128,222,248,159,269,312,180,259,19,108,14,356,141,175,277,243,/all');
//window.open('/map.php?type=2&schools=12,285,333,161,35596,35595,133,324,51,52,222,136,248,159,269,312,180,259,19,108,14,175,277,243,12,2,285,333,161,35596,35595,133,324,51,52,128,222,248,159,269,312,180,259,19,108,14,356,141,175,277,243,&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;
}