﻿// JScript File

    //<![CDATA[
    
    // A OfficeSelectControl is a GControl that displays textual "Zoom In"
    // and "Zoom Out" buttons (as opposed to the iconic buttons used in
    // Google Maps).
    function OfficeSelectControl() {
    }
    OfficeSelectControl.prototype = new GControl();

    // Creates a one DIV for each of the buttons and places them in a container
    // DIV which is returned as our control element. We add the control to
    // to the map container and return the element for the map class to
    // position properly.
    OfficeSelectControl.prototype.initialize = function(map) {
      var container = document.createElement("div");

      var GuelphDiv = document.createElement("div");
      this.setButtonStyle_(GuelphDiv);
      container.appendChild(GuelphDiv);
      GuelphDiv.appendChild(document.createTextNode("Guelph Office"));
      GEvent.addDomListener(GuelphDiv, "click", function() {
      var point = new GLatLng(43.543616,-80.291083);
        map.panTo(new GLatLng(43.543616,-80.291083));
        map.openInfoWindowHtml(point, "<img src='../App_Themes/Main/SiteImages/RLB-FINAL-Logo-small.jpg' alt='RLB LLP' /><br /><b>RLB LLP</b><br />15 Lewis Road<br />Guelph, Ontario N1H 1E9");
      });

      var FergusDiv = document.createElement("div");
      this.setButtonStyle_(FergusDiv);
      container.appendChild(FergusDiv);
      FergusDiv.appendChild(document.createTextNode("Fergus Office"));
      GEvent.addDomListener(FergusDiv, "click", function() {
        var point2 = new GLatLng(43.709787,-80.385081);
        map.panTo(new GLatLng(43.709787,-80.385081));
        map.openInfoWindowHtml(point2, "<img src='../App_Themes/Main/SiteImages/RLB-FINAL-Logo-small.jpg' alt='RLB LLP' /><br /><b>RLB LLP</b><br />686 St. David Street N.<br />Fergus, Ontario N1M 2K8");
      });

      map.getContainer().appendChild(container);
      return container;
    }

    // By default, the control will appear in the top left corner of the
    // map with 7 pixels of padding.
    OfficeSelectControl.prototype.getDefaultPosition = function() {
      return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 120));
    }

    // Sets the proper CSS for the given button element.
    OfficeSelectControl.prototype.setButtonStyle_ = function(button) {
      button.style.textDecoration = "underline";
      button.style.color = "#0000cc";
      button.style.backgroundColor = "white";
      button.style.font = "small Arial";
      button.style.border = "1px solid #333";
      button.style.padding = "2px";
      button.style.marginBottom = "3px";
      button.style.textAlign = "center";
      button.style.width = "6em";
      button.style.cursor = "pointer";
    }
    
    function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.addControl(new OfficeSelectControl());
        map.setCenter(new GLatLng(43.543616,-80.291083), 15);
        
       
       /*   Guelph Office   */
        // Add marker in default location on the map
        var point = new GLatLng(43.543616,-80.291083);  
        
        // Creates a marker at the given point with the given number label
        var marker = new GMarker(point);  
        GEvent.addListener(marker, "click", function() {    
        marker.openInfoWindowHtml("<img src='../App_Themes/Main/SiteImages/RLB-FINAL-Logo-small.jpg' alt='RLB LLP' /><br /><b>RLB LLP</b><br />15 Lewis Road<br />Guelph, Ontario N1H 1E9");  });  
        
        map.addOverlay(marker);
        
        map.openInfoWindowHtml(point, "<img src='../App_Themes/Main/SiteImages/RLB-FINAL-Logo-small.jpg' alt='RLB LLP' /><br /><b>RLB LLP</b><br />15 Lewis Road<br />Guelph, Ontario N1H 1E9");
        //map.showMapBlowup(point)
        
        /*   Fergus Office   */
        // Add marker in default location on the map
        var point2 = new GLatLng(43.709787,-80.385081);  
        
        // Creates a marker at the given point with the given number label
        var marker2 = new GMarker(point2);  
        GEvent.addListener(marker2, "click", function() {    
        marker2.openInfoWindowHtml("<img src='../App_Themes/Main/SiteImages/RLB-FINAL-Logo-small.jpg' alt='RLB LLP' /><br /><b>RLB LLP</b><br />686 St. David Street N.<br />Fergus, Ontario N1M 2K8");  });  
        
        map.addOverlay(marker2);
        
      }
    }
    //]]>
