﻿    var cookie = readCookie("style");
	var loc = cookie ? cookie : getPreferredStyleSheet();	
	if(loc == "Style_Edmonton")
    {
        window.location="#contact_edmonton";
    }
	else
	{
		window.location="#contact_kelowna";
	}
	
	if (loc == "Style_Calgary")
	{
		window.location="#contact_calgary";
    }
	
    // These are the keys for the servers
    var key_ccpy = "ABQIAAAA_grXNTS_A1CpaKkWc6tUPRRlMTiQX1uTjnTsydW16QIg2Dn64BSrEcbKVm1YRSZqpulKqUHaP9y3Aw";
    var key_ccpydgt = "ABQIAAAA_grXNTS_A1CpaKkWc6tUPRQ97yD9LjjDixU511Q3MOeqiaQ2BxQCagC_JvgkcT7TwqOGZ_X9AIAUhQ";
    var key_nccs = "ABQIAAAA_grXNTS_A1CpaKkWc6tUPRTt-4YLLM-lLYKCIMXveOTtk0_rBBSUi9gRWB0hSiUm1NBylgCKBuQ_mg";     

     // Three nearly identical code blocks.
     // First define a regular expression that will match my server
     var reg_ccpy = new RegExp("http://www.carbcopy.com/contact/index.htm");
	 //same as above for next server
     var reg_ccpydgt = new RegExp("http://www.carboncopydigital.com/contact/index.htm");
     
     var reg_ccdDev = new RegExp("http://ccd.medialogic.ca/contact/index.htm");
	 
     if( reg_ccpy.test(window.location.href)) 
     {
         loadScript(key_ccpy);
     }
     else if( reg_ccpydgt.test(window.location.href) ) 
     {
         loadScript(key_ccpydgt);
     }
     else if(reg_ccdDev.test(window.location.href))
     {
	 	loadScript("ABQIAAAAnJXuhctFQQhvpA4bxSGqKRSa8GFPW9YF8KZaTgd9pe_Ovcmn1hTfMoHI6ggLTOVr6o5cXZWjHCTjEg");
	 }
	 else
	 {
	    loadScript(key_nccs);
	    loadScript("ABQIAAAAnJXuhctFQQhvpA4bxSGqKRT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSRLYu2To7-mt8MYQHmTRV0NqZygw");
	 }
	 
     // build the script tag in the variable src and then
     // write it into the document
     function loadScript(key) {
	 
	 	var src = '<' + 'script src=' + '"' + 'http://maps.google.com/maps?file=api&amp;v=2&amp;key=' + key + '"'+ ' type="text/javascript"><' + '/script>';
		document.write(src);
     }

	function load() 
	{
      if (GBrowserIsCompatible()) 
      {
        var map_cal = new GMap2(document.getElementById("map_cal"));
        map_cal.addControl(new GLargeMapControl());
        map_cal.setCenter(new GLatLng(51.042716065813416, -114.06347036361694), 16);

        var point_cal = new GLatLng(51.04241925594382, -114.0644359588623);        
		map_cal.addOverlay(createCalgaryDowntownMarker(point_cal));

        var map_edm = new GMap2(document.getElementById("map_edm"));
        map_edm.addControl(new GLargeMapControl());
        map_edm.setCenter(new GLatLng(53.541634,-113.506193), 16);
        
        var point_edm = new GLatLng(53.542144,-113.506451);
		map_edm.addOverlay(createEdmontonMarker(point_edm));
				
		var map_calSouth = new GMap2(document.getElementById("map_calSouth"));
        map_calSouth.addControl(new GLargeMapControl());
        map_calSouth.setCenter(new GLatLng(50.96387329038093, -114.07231092453003), 16);
        
        var map_kel = new GMap2(document.getElementById("map_kel"));
        map_kel.addControl(new GLargeMapControl());
        map_kel.setCenter(new GLatLng(49.88195019022974, -119.45789694786072), 16);
       
        var point_kel = new GLatLng(49.88195019022974, -119.45789694786072);
		map_kel.addOverlay(createKelownaMarker (point_kel));       
        
        var point_calSouth = new GLatLng(50.96387329038093, -114.07231092453003);
        map_calSouth.addOverlay(createCalSouthMarker(point_calSouth));
      }
    }
    
      function createCalSouthMarker(point_calSouth) 
      {
		  var marker_calSouth = new GMarker(point_calSouth);
		  GEvent.addListener(marker_calSouth, "click", function() {
			marker_calSouth.openInfoWindowHtml("<b>Calgary South Location</b><br>105 - 10333 South Port RD S.W.,<br>Calgary, Alberta<br>");
		  });
		  return marker_calSouth;
		}
        
        function createEdmontonMarker(point_edm) {
		    var marker_edm = new GMarker(point_edm);
		    GEvent.addListener(marker_edm, "click", function() {
		    marker_edm.openInfoWindowHtml("<b>Edmonton Location</b><br>10159 - 108 St.,<br>Edmonton, Alberta<br>T5J 1L1");
		  });
		  return marker_edm;
		}
        
        function createCalgaryDowntownMarker(point_cal) {
		  var marker_cal = new GMarker(point_cal);
		  GEvent.addListener(marker_cal, "click", function() {
			marker_cal.openInfoWindowHtml("<b>Calgary Downtown Location</b><br>110 11th Avenue S.W.,<br>Calgary, Alberta<br>T2G 0B8");
		  });
		  return marker_cal;
		}
		
		function createKelownaMarker(point_kel)
		{
		    var marker_kel = new GMarker(point_kel);
		    GEvent.addListener(marker_kel, "click", function() {
			marker_kel.openInfoWindowHtml("<b>Kelowna Location</b><br>1763A Harvey Ave,<br>Kelowna, British Columbia<br>V1Y 6G4");
		  });
		  return marker_kel;
		}