﻿
/// <reference path="GMAPJSHelper_Release.js" />

var map = null;
var mapLat = 49.68221;
var mapLong = -115.9873;
var mapZoom = 15;
var coordinates = null;
var geoxml;

// Specialist Real Estate Office Coordinates
var lat97 = 49.68670;
var long97 = -115.9825;
var point97 = null;
var marker97 = null;
var tabs97 = null;

// Caldwell Office Coordinates
var latCald = 49.68476;
var longCald = -115.9826;

// EK Office Coordinates
var latEK = 49.68419;
var longEK = -115.9836;

// Highland Office Coordinates
var latHigh = 49.68612;
var longHigh = -115.9851;

// City of Kimberley Office Coordinates
var latCity = 49.68518;
var longCity = -115.9817;

// Kimberley Chamber Coordinates
var latChamber = 49.68573;
var longChamber = -115.9853;

var logo = null; // top left of map
var houseIcon = null;
var officeIcon = null;



function loadMap()
{
    //************************************** CREATE MAP ***********************************// 
    if (!GBrowserIsCompatible())
        mapDiv.innerHTML = 'Sorry, your browser isn\'t compatible with Google Maps. Please try Firefox 3! And enable Javascript.';
    else
    {
        map = new GMap2(document.getElementById("mapDiv"));
        coordinates = new GLatLng(mapLat, mapLong);
        map.setCenter(coordinates, mapZoom);
        map._lastCenter = map.getCenter();
        GEvent.addListener(map, 'moveend', function() { map._lastCenter = map.getCenter(); });
        GEvent.addListener(map, 'resize', function() { map.setCenter(map._lastCenter); });
        
        var customUI = map.getDefaultUI();
		customUI.controls.scalecontrol = false;
		customUI.controls.largemapcontrol3d = true;
		customUI.controls.maptypecontrol = false;
		customUI.controls.menumaptypecontrol = true;
		customUI.maptypes.satellite = false;
		map.setUI(customUI);
        map.setMapType(G_HYBRID_MAP);

        //************************************** ADD LOGO AND CENTER MARKER ***********************************// 

        //************************************** CREATE CUSTOM ICONS  ***********************************// 

        officeIcon = new GIcon();
        officeIcon.image = 'http://kimberleyrealestate.ca/_Images/Icons/office.png';
        officeIcon.shadow = 'http://kimberleryrealestate.ca/_Images/Icons/officeS.png';
        officeIcon.iconSize = new GSize(32, 32);
        officeIcon.shadowSize = new GSize(49, 32);
        officeIcon.iconAnchor = new GPoint(17, 17);
        officeIcon.infoWindowAnchor = new GPoint(20, 0);
        
        infoIcon = new GIcon();
        infoIcon.image = 'http://kimberleyrealestate.ca/_Images/Icons/info_circle.png';
        infoIcon.shadow = 'http://kimberleryrealestate.ca/_Images/Icons/info_circle.shadow.png';
        infoIcon.iconSize = new GSize(32, 32);
        infoIcon.shadowSize = new GSize(49, 32);
        infoIcon.iconAnchor = new GPoint(17, 17);
        infoIcon.infoWindowAnchor = new GPoint(20, 0);

        //************************************** CREATE INFO WINDOWS ***********************************//

        var tabs97 = [new GInfoWindowTab('Address', document.getElementById('tab_specialist')),
                new GInfoWindowTab('3D View', document.getElementById('tab_97_3Dview')),
                 new GInfoWindowTab('Photo', document.getElementById('tab_97_Photo'))
                        ];
                        
        var tabsCaldwell = [new GInfoWindowTab('Address', document.getElementById('tab_caldwell'))]; 
        var tabsEK = [new GInfoWindowTab('Address', document.getElementById('tab_ek'))];
        var tabsHigh = [new GInfoWindowTab('Address', document.getElementById('tab_highland'))];
        var tabsChamber = [new GInfoWindowTab('Address', document.getElementById('tab_chamber'))];
         
        var tabsCity = [new GInfoWindowTab('Address', document.getElementById('tab_city')),
        new GInfoWindowTab('Documents', document.getElementById('tab_city_documents')),
        new GInfoWindowTab('Maps', document.getElementById('tab_city_maps'))];                        
                        
        //************************************** ADD MARKERS TO MAP ***********************************// 
        
        var pointCity = new GLatLng(latCity, longCity);
        var markerCity = new GMarker(pointCity, { icon: infoIcon, title:"City of Kimberley" });
        markerCity.bindInfoWindowTabs(tabsCity, { maxWidth: 450 });
        map.addOverlay(markerCity);
        
        var pointChamber = new GLatLng(latChamber, longChamber);
        var markerChamber = new GMarker(pointChamber, { icon: infoIcon, title:"Kimberley Chamber of Commerce" });
        markerChamber.bindInfoWindowTabs(tabsChamber, { maxWidth: 450 });
        map.addOverlay(markerChamber);
              
        var pointCald = new GLatLng(latCald, longCald);
        var markerCald = new GMarker(pointCald, { icon: officeIcon, title: "Remax Caldwell Agencies Ltd." });
        markerCald.bindInfoWindowTabs(tabsCaldwell, { maxWidth: 450 });
        map.addOverlay(markerCald);
        
        var pointEK = new GLatLng(latEK, longEK);
        var markerEK = new GMarker(pointEK, { icon: officeIcon, title:"Royal LePage East Kootenay Realty Ltd." });
        markerEK.bindInfoWindowTabs(tabsEK, { maxWidth: 450 });
        map.addOverlay(markerEK);
        
        var pointHigh = new GLatLng(latHigh, longHigh);
        var markerHigh = new GMarker(pointHigh, { icon: officeIcon, title:"Highland Property Management and Real Estate Ltd." });
        markerHigh.bindInfoWindowTabs(tabsHigh, { maxWidth: 450 });
        map.addOverlay(markerHigh);
                
        var point97 = new GLatLng(lat97, long97);
        var marker97 = new GMarker(point97, { icon: officeIcon, title:"Specialist Real Estate Ltd." });
        marker97.bindInfoWindowTabs(tabs97, { maxWidth: 450 });
        map.addOverlay(marker97);
        GEvent.trigger(marker97, "click");
		
		geoXml = new GGeoXml("http://kimberleyrealestate.ca/KMZs/KRE-Listings.kmz");
		map.addOverlay(geoXml);

    }
}
