function addMarkers(){
mySelect = document.getElementById('selection');
Twin_Falls = [];Boise = [];Idaho_Falls = [];Post_Falls = [];Buhl = [];Meridian = [];Lewiston = [];Coeur_Dalene = [];Emmett = [];Sandpoint = [];Greenleaf = [];Mccall = [];Oldtown = [];Jerome = [];Nampa = [];Hayden_Lake = [];Payette = [];Ponderay = [];Mountain_Home = [];Kellogg = [];mySelect.options[mySelect.options.length] = new Option("Boise schools",'all=Boise');
mySelect.options[mySelect.options.length] = new Option("Buhl schools",'all=Buhl');
mySelect.options[mySelect.options.length] = new Option("Coeur Dalene schools",'all=Coeur_Dalene');
mySelect.options[mySelect.options.length] = new Option("Emmett schools",'all=Emmett');
mySelect.options[mySelect.options.length] = new Option("Greenleaf schools",'all=Greenleaf');
mySelect.options[mySelect.options.length] = new Option("Hayden Lake schools",'all=Hayden_Lake');
mySelect.options[mySelect.options.length] = new Option("Idaho Falls schools",'all=Idaho_Falls');
mySelect.options[mySelect.options.length] = new Option("Jerome schools",'all=Jerome');
mySelect.options[mySelect.options.length] = new Option("Kellogg schools",'all=Kellogg');
mySelect.options[mySelect.options.length] = new Option("Lewiston schools",'all=Lewiston');
mySelect.options[mySelect.options.length] = new Option("Mccall schools",'all=Mccall');
mySelect.options[mySelect.options.length] = new Option("Meridian schools",'all=Meridian');
mySelect.options[mySelect.options.length] = new Option("Mountain Home schools",'all=Mountain_Home');
mySelect.options[mySelect.options.length] = new Option("Nampa schools",'all=Nampa');
mySelect.options[mySelect.options.length] = new Option("Oldtown schools",'all=Oldtown');
mySelect.options[mySelect.options.length] = new Option("Payette schools",'all=Payette');
mySelect.options[mySelect.options.length] = new Option("Ponderay schools",'all=Ponderay');
mySelect.options[mySelect.options.length] = new Option("Post Falls schools",'all=Post_Falls');
mySelect.options[mySelect.options.length] = new Option("Sandpoint schools",'all=Sandpoint');
mySelect.options[mySelect.options.length] = new Option("Twin Falls schools",'all=Twin_Falls');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Twin_Falls[Twin_Falls.length] = createMarker(new GPoint(-114.49311300,42.56279600),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Agape Christian School",'Twin_Falls=' + Twin_Falls.length);
Boise[Boise.length] = createMarker(new GPoint(-116.23358900,43.60638300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Boise Christian School",'Boise=' + Boise.length);
Idaho_Falls[Idaho_Falls.length] = createMarker(new GPoint(-111.98425800,43.45854600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Chapel Christian School",'Idaho_Falls=' + Idaho_Falls.length);
Boise[Boise.length] = createMarker(new GPoint(-116.27575500,43.60313000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Christian School",'Boise=' + Boise.length);
Post_Falls[Post_Falls.length] = createMarker(new GPoint(-116.97867100,47.71625900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Classical Christian Academy",'Post_Falls=' + Post_Falls.length);
Buhl[Buhl.length] = createMarker(new GPoint(-114.68731300,42.51682800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clover Trinity Lutheran School",'Buhl=' + Buhl.length);
Meridian[Meridian.length] = createMarker(new GPoint(-116.39024000,43.61386500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cole Valley Christian Schools",'Meridian=' + Meridian.length);
Lewiston[Lewiston.length] = createMarker(new GPoint(-117.04068000,46.37146100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cornerstone Christian School",'Lewiston=' + Lewiston.length);
Coeur_Dalene[Coeur_Dalene.length] = createMarker(new GPoint(-116.78521500,47.67586300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Discovery Christian Dayschool",'Coeur_Dalene=' + Coeur_Dalene.length);
Emmett[Emmett.length] = createMarker(new GPoint(-116.52290200,43.86518500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Emmett Valley Christian School",'Emmett=' + Emmett.length);
Sandpoint[Sandpoint.length] = createMarker(new GPoint(-116.53100000,48.32340000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Christian Academy",'Sandpoint=' + Sandpoint.length);
Greenleaf[Greenleaf.length] = createMarker(new GPoint(-116.82230000,43.67080000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greenleaf Friends Academy",'Greenleaf=' + Greenleaf.length);
Mccall[Mccall.length] = createMarker(new GPoint(-116.04430000,44.88010000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Highland Christian Academy",'Mccall=' + Mccall.length);
Oldtown[Oldtown.length] = createMarker(new GPoint(-117.02786300,48.17240500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("House Of The Lord Christian Academy",'Oldtown=' + Oldtown.length);
Jerome[Jerome.length] = createMarker(new GPoint(-114.50785700,42.71676300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Liberty Christian Academy",'Jerome=' + Jerome.length);
Twin_Falls[Twin_Falls.length] = createMarker(new GPoint(-114.46111300,42.54950700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lighthouse Christian School",'Twin_Falls=' + Twin_Falls.length);
Twin_Falls[Twin_Falls.length] = createMarker(new GPoint(-114.65340000,42.25040000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Magic Valley Christian School",'Twin_Falls=' + Twin_Falls.length);
Boise[Boise.length] = createMarker(new GPoint(-116.33093800,43.61963700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maranatha Christian School",'Boise=' + Boise.length);
Nampa[Nampa.length] = createMarker(new GPoint(-116.58469700,43.59033900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nampa Christian Schools",'Nampa=' + Nampa.length);
Hayden_Lake[Hayden_Lake.length] = createMarker(new GPoint(-116.78857500,47.76643700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Idaho Christian School",'Hayden_Lake=' + Hayden_Lake.length);
Jerome[Jerome.length] = createMarker(new GPoint(-114.51835400,42.73158200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Valley Christian School",'Jerome=' + Jerome.length);
Payette[Payette.length] = createMarker(new GPoint(-116.93345000,44.09276300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("River Of Life Christian School",'Payette=' + Payette.length);
Ponderay[Ponderay.length] = createMarker(new GPoint(-116.54644300,48.32105200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sandpoint Christian School",'Ponderay=' + Ponderay.length);
Mountain_Home[Mountain_Home.length] = createMarker(new GPoint(-115.69725800,43.14670900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shiloh Christian School",'Mountain_Home=' + Mountain_Home.length);
Kellogg[Kellogg.length] = createMarker(new GPoint(-116.12804200,47.54332400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Silver Valley Christian Academy",'Kellogg=' + Kellogg.length);
map.removeOverlays(Boise);
map.removeOverlays(Buhl);
map.removeOverlays(Coeur_Dalene);
map.removeOverlays(Emmett);
map.removeOverlays(Greenleaf);
map.removeOverlays(Hayden_Lake);
map.removeOverlays(Idaho_Falls);
map.removeOverlays(Jerome);
map.removeOverlays(Kellogg);
map.removeOverlays(Lewiston);
map.removeOverlays(Mccall);
map.removeOverlays(Meridian);
map.removeOverlays(Mountain_Home);
map.removeOverlays(Nampa);
map.removeOverlays(Oldtown);
map.removeOverlays(Payette);
map.removeOverlays(Ponderay);
map.removeOverlays(Post_Falls);
map.removeOverlays(Sandpoint);
map.removeOverlays(Twin_Falls);
setTimeout(function(){map.addOverlays(Boise)},1000);
setTimeout(function(){map.addOverlays(Buhl)},1000);
setTimeout(function(){map.addOverlays(Coeur_Dalene)},1000);
setTimeout(function(){map.addOverlays(Emmett)},1000);
setTimeout(function(){map.addOverlays(Greenleaf)},1000);
setTimeout(function(){map.addOverlays(Hayden_Lake)},1000);
setTimeout(function(){map.addOverlays(Idaho_Falls)},1000);
setTimeout(function(){map.addOverlays(Jerome)},1000);
setTimeout(function(){map.addOverlays(Kellogg)},1000);
setTimeout(function(){map.addOverlays(Lewiston)},1000);
setTimeout(function(){map.addOverlays(Mccall)},1000);
setTimeout(function(){map.addOverlays(Meridian)},1000);
setTimeout(function(){map.addOverlays(Mountain_Home)},1000);
setTimeout(function(){map.addOverlays(Nampa)},1000);
setTimeout(function(){map.addOverlays(Oldtown)},1000);
setTimeout(function(){map.addOverlays(Payette)},1000);
setTimeout(function(){map.addOverlays(Ponderay)},1000);
setTimeout(function(){map.addOverlays(Post_Falls)},1000);
setTimeout(function(){map.addOverlays(Sandpoint)},1000);
setTimeout(function(){map.addOverlays(Twin_Falls)},1000);
maxLng = -111.98425800;
maxLat = 48.32340000;
minLng = -117.04068000;
minLat = 42.25040000;
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(Boise);
map.removeOverlays(Buhl);
map.removeOverlays(Coeur_Dalene);
map.removeOverlays(Emmett);
map.removeOverlays(Greenleaf);
map.removeOverlays(Hayden_Lake);
map.removeOverlays(Idaho_Falls);
map.removeOverlays(Jerome);
map.removeOverlays(Kellogg);
map.removeOverlays(Lewiston);
map.removeOverlays(Mccall);
map.removeOverlays(Meridian);
map.removeOverlays(Mountain_Home);
map.removeOverlays(Nampa);
map.removeOverlays(Oldtown);
map.removeOverlays(Payette);
map.removeOverlays(Ponderay);
map.removeOverlays(Post_Falls);
map.removeOverlays(Sandpoint);
map.removeOverlays(Twin_Falls);
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(Twin_Falls);map.removeOverlays(Boise);
map.removeOverlays(Buhl);
map.removeOverlays(Coeur_Dalene);
map.removeOverlays(Emmett);
map.removeOverlays(Greenleaf);
map.removeOverlays(Hayden_Lake);
map.removeOverlays(Idaho_Falls);
map.removeOverlays(Jerome);
map.removeOverlays(Kellogg);
map.removeOverlays(Lewiston);
map.removeOverlays(Mccall);
map.removeOverlays(Meridian);
map.removeOverlays(Mountain_Home);
map.removeOverlays(Nampa);
map.removeOverlays(Oldtown);
map.removeOverlays(Payette);
map.removeOverlays(Ponderay);
map.removeOverlays(Post_Falls);
map.removeOverlays(Sandpoint);
map.removeOverlays(Twin_Falls);
map.addOverlays(Boise);
centerByArray(Boise, false, false);
cntMarker += Boise.length;
map.addOverlays(Buhl);
centerByArray(Buhl, false, false);
cntMarker += Buhl.length;
map.addOverlays(Coeur_Dalene);
centerByArray(Coeur_Dalene, false, false);
cntMarker += Coeur_Dalene.length;
map.addOverlays(Emmett);
centerByArray(Emmett, false, false);
cntMarker += Emmett.length;
map.addOverlays(Greenleaf);
centerByArray(Greenleaf, false, false);
cntMarker += Greenleaf.length;
map.addOverlays(Hayden_Lake);
centerByArray(Hayden_Lake, false, false);
cntMarker += Hayden_Lake.length;
map.addOverlays(Idaho_Falls);
centerByArray(Idaho_Falls, false, false);
cntMarker += Idaho_Falls.length;
map.addOverlays(Jerome);
centerByArray(Jerome, false, false);
cntMarker += Jerome.length;
map.addOverlays(Kellogg);
centerByArray(Kellogg, false, false);
cntMarker += Kellogg.length;
map.addOverlays(Lewiston);
centerByArray(Lewiston, false, false);
cntMarker += Lewiston.length;
map.addOverlays(Mccall);
centerByArray(Mccall, false, false);
cntMarker += Mccall.length;
map.addOverlays(Meridian);
centerByArray(Meridian, false, false);
cntMarker += Meridian.length;
map.addOverlays(Mountain_Home);
centerByArray(Mountain_Home, false, false);
cntMarker += Mountain_Home.length;
map.addOverlays(Nampa);
centerByArray(Nampa, false, false);
cntMarker += Nampa.length;
map.addOverlays(Oldtown);
centerByArray(Oldtown, false, false);
cntMarker += Oldtown.length;
map.addOverlays(Payette);
centerByArray(Payette, false, false);
cntMarker += Payette.length;
map.addOverlays(Ponderay);
centerByArray(Ponderay, false, false);
cntMarker += Ponderay.length;
map.addOverlays(Post_Falls);
centerByArray(Post_Falls, false, false);
cntMarker += Post_Falls.length;
map.addOverlays(Sandpoint);
centerByArray(Sandpoint, false, false);
cntMarker += Sandpoint.length;
map.addOverlays(Twin_Falls);
centerByArray(Twin_Falls, false, false);
cntMarker += Twin_Falls.length;
centerByArray(Twin_Falls,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///8219,33509,8249,8271,8260,33511,8288,8233,8287,8267,8256,8274,8282,33830,8239,8261,8264,8219,33507,8265,8228,8236,33509,8249,8271,8223,8260,33511,8288,8234,8250,8233,8287,8267,8256,8274,8282,33830,8216,8261,/all');
//window.open('/map.php?type=2&schools=8219,33509,8249,8271,8260,33511,8288,8233,8287,8267,8256,8274,8282,33830,8239,8261,8264,8219,33507,8265,8228,8236,33509,8249,8271,8223,8260,33511,8288,8234,8250,8233,8287,8267,8256,8274,8282,33830,8216,8261,&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;
}