﻿var SailingClubs = new clubs();

/*
javascript:void(prompt('',gApplication.getMap().getCenter()));
*/


function club(objectName, clubName, latitude, longitude, bubbleName) {
    this.objectName = objectName;
    this.clubName = clubName;
    this.latitude = latitude;
    this.longitude = longitude;
    this.bubbleName = "Images/Markers/" + bubbleName;

}

function clubs() {
    this.SudburyYachtClub = new club("sailingClubs.SudburyYachtClub", "Sudbury Yacht Club (SYC)", 46.4720, -80.9920, "blue_MarkerA.png");
    this.BritanniaYachtClub = new club("sailingClubs.BritanniaYachtClub", "Britannia Yacht Club (BYC)", 45.3720, -75.800, "red_MarkerB.png");
    this.NorwayBay = new club("sailingClubs.NorwayBay", "Norway Bay", 45.5172, -76.4291, "purple_MarkerC.png");
    this.GatineauYachtClub = new club("sailingClubs.GatineauYachtClub", "Gatineau River Yacht Club (GRYC)", 45.5389, -75.8079, "yellow_MarkerD.png");
    this.FanshaweYachtClub = new club("sailingClubs.FanshaweYachtClub", "Fanshawe Yacht Club (FYC)", 43.0517, -81.1728, "green_MarkerE.png");
    this.Bellwood = new club("sailingClubs.Bellwood", "Bellwood Yacht Club ;)", 43.7518, -80.3382, "pink_MarkerF.png");
    this.Falcon = new club("sailingClubs.Falcon", "Falcon Lake", 49.69028750932464, -95.33098697662354, "orange_MarkerG.png");
    this.VoileSaguenay = new club("sailingClubs.VoileSaguenay", "Club Voile Saguenay", 48.46549482105437, -71.2654459476471, "red_MarkerH.png");
    this.CalgaryYachtClub = new club("sailingClubs.CalgaryYachtClub", "Calgary Yacht Club", 51.03561, -113.809182, "blue_MarkerI.png");
    this.GlenmoreSailingClub = new club("sailingClubs.GlenmoreSailingClub", "Glenmore Sailing Club", 51.052352, -114.0733, "purple_MarkerJ.png");
    this.LacStJoseph = new club("sailingClubs.LacStJoseph", "Lac St. Joseph", 46.93778, -71.639137, "yellow_MarkerK.png");
    this.EdmontonYachtClub = new club("sailingClubs.EdmontonYachtClub", "Edmonton Yacht Club", 53.479063, -113.587847, "pink_MarkerL.png");
    this.CookingLake = new club("sailingClubs.CookingLake", "Cooking Lake Sailing Club", 53.414852464740726, -112.97309875488281, "orange_MarkerM.png");
    this.ItaskaYachtClub = new club("sailingClubs.ItaskaYachtClub", "Itaska Yacht Club", 53.10804109736252, -114.20562744140625, "yellow_MarkerN.png");
    this.wabamun = new club("sailingClubs.wabamun", "Wabamun Sailing Club", 53.551903, -114.516925, "red_MarkerO.png");
    this.whlyc = new club("sailingClubs.whlyc", "West Hawk Lake Yacht Club", 49.767295824128766, -95.1789379119873, "blue_MarkerP.png");
}

function mapClub(map, sailingClub) {
    var point = new GLatLng(sailingClub.latitude, sailingClub.longitude);
    var newIcon = new GIcon(G_DEFAULT_ICON);
    newIcon.image = sailingClub.bubbleName;
    var markerOptions = { title: sailingClub.clubName, icon: newIcon };
    marker = new GMarker(point, markerOptions);
    map.addOverlay(marker)
}

function initialize() {
    var map = new GMap2(document.getElementById("map_canvas"));
    var geocoder = new GClientGeocoder();
/*    map.setCenter(new GLatLng(45.0413, -79.3106), 6); */
    map.setCenter(new GLatLng(49.69028750932464, -95.33098697662354), 6);
    map.setZoom(4);
    map.addControl(new GSmallMapControl());
    map.addControl(new GOverviewMapControl());

    mapClub(map, SailingClubs.SudburyYachtClub);
    mapClub(map, SailingClubs.BritanniaYachtClub);
    mapClub(map, SailingClubs.FanshaweYachtClub);
    mapClub(map, SailingClubs.GatineauYachtClub);
    mapClub(map, SailingClubs.NorwayBay);
    mapClub(map, SailingClubs.Bellwood);
    mapClub(map, SailingClubs.Falcon);
    mapClub(map, SailingClubs.VoileSaguenay);
    mapClub(map, SailingClubs.CalgaryYachtClub);
    mapClub(map, SailingClubs.GlenmoreSailingClub);
    mapClub(map, SailingClubs.LacStJoseph);
    mapClub(map, SailingClubs.EdmontonYachtClub);
    mapClub(map, SailingClubs.CookingLake);
    mapClub(map, SailingClubs.ItaskaYachtClub);
    mapClub(map, SailingClubs.wabamun);
    mapClub(map, SailingClubs.whlyc);
}

function ToggleDisplay(id) {
    var elem = document.getElementById('d' + id);
    if (elem) {
        if (elem.style.display != 'block') {
            elem.style.display = 'block';
            elem.style.visibility = 'visible';
        }
        else {
            elem.style.display = 'none';
            elem.style.visibility = 'hidden';
        }
    }
}