﻿var grid=false;


function initializeMap(elemID) {

    var lat=50.876702; //start map in calgary
    var lng=-113.979861;      
    
    if (GBrowserIsCompatible()) {
    
        if (grid) {
            var mapcontainer = document.getElementById(elemID);
            mapcontainer.style.position="absolute";
            mapcontainer.style.top="0px";
            mapcontainer.style.left="0px";
            mapcontainer.style.width="100%";
            mapcontainer.style.height="100%";
        }
        //restrict zoom options...
        var mapTypes = G_DEFAULT_MAP_TYPES;
        for(var i = 0; i < mapTypes.length; i++) {
            mapTypes[i].getMaximumResolution = function(latlng){ return 15;};
            mapTypes[i].getMinimumResolution = function(latlng){ return 8;};
        }
        //init map
        var map = new GMap2(document.getElementById(elemID));
        map.setCenter(new GLatLng(lat, lng), 9);            
        map.setMapType(G_PHYSICAL_MAP );
        
        
        //UI Options
        var customUI = map.getDefaultUI();
        customUI.maptypes.physical=true;
        customUI.maptypes.normal=true;
        customUI.maptypes.satellite=true;
        customUI.maptypes.hybrid=true;
        
        map.setUI(customUI);
        
        //custom overlays
        
        
        var tilelayer = new GTileLayer(new GCopyrightCollection(), 0, 17);
        tilelayer.getTileUrl = function(tile, zoom) {
            if (grid) {
                return "http://maps.csg.ca/tiles/GridTile.ashx?x="+tile.x+"&y="+tile.y+"&s="+zoom;
                
            } else {                
                return "http://maps.csg.ca/tiles/overlay/"+tile.x+"-"+tile.y+"-"+zoom+".png";
            }
               
        };
        //tilelayer.getOpacity = function() {return 0.5;}
        map.addOverlay(new GTileLayerOverlay(tilelayer));

        map.enableContinuousZoom();       
        return map;
    } else {
        return null;
    }
}

function initializeMontrose(elemID) {

    var lat=50.573193; //start map in montrose
    var lng=-113.870824; 
    
    if (GBrowserIsCompatible()) {
    
        if (grid) {
            var mapcontainer = document.getElementById(elemID);
            mapcontainer.style.position="absolute";
            mapcontainer.style.top="0px";
            mapcontainer.style.left="0px";
            mapcontainer.style.width="100%";
            mapcontainer.style.height="100%";
        }
        //restrict zoom options...
        var mapTypes = G_DEFAULT_MAP_TYPES;
        for(var i = 0; i < mapTypes.length; i++) {
            mapTypes[i].getMaximumResolution = function(latlng){ return 15;};
            mapTypes[i].getMinimumResolution = function(latlng){ return 8;};
        }
        //init map
        var map = new GMap2(document.getElementById(elemID));
        map.setCenter(new GLatLng(lat, lng), 15);            
        map.setMapType(G_PHYSICAL_MAP );
        
        
        //UI Options
        var customUI = map.getDefaultUI();
        customUI.maptypes.physical=true;
        customUI.maptypes.normal=true;
        customUI.maptypes.satellite=true;
        customUI.maptypes.hybrid=true;
        
        map.setUI(customUI);
        
        //custom overlays
        
        
        var tilelayer = new GTileLayer(new GCopyrightCollection(), 0, 17);
        tilelayer.getTileUrl = function(tile, zoom) {
            if (grid) {
                return "http://maps.csg.ca/tiles/GridTile.ashx?x="+tile.x+"&y="+tile.y+"&s="+zoom;
                
            } else {                
                return "http://maps.csg.ca/tiles/overlay/"+tile.x+"-"+tile.y+"-"+zoom+".png";
            }
               
        };
        //tilelayer.getOpacity = function() {return 0.5;}
        map.addOverlay(new GTileLayerOverlay(tilelayer));

        map.enableContinuousZoom();       
        return map;
    } else {
        return null;
    }
}

function initializeDrake(elemID) {

    var lat=50.731350; //start map in Drake
    var lng=-113.953461; 
    
    if (GBrowserIsCompatible()) {
    
        if (grid) {
            var mapcontainer = document.getElementById(elemID);
            mapcontainer.style.position="absolute";
            mapcontainer.style.top="0px";
            mapcontainer.style.left="0px";
            mapcontainer.style.width="100%";
            mapcontainer.style.height="100%";
        }
        //restrict zoom options...
        var mapTypes = G_DEFAULT_MAP_TYPES;
        for(var i = 0; i < mapTypes.length; i++) {
            mapTypes[i].getMaximumResolution = function(latlng){ return 15;};
            mapTypes[i].getMinimumResolution = function(latlng){ return 8;};
        }
        //init map
        var map = new GMap2(document.getElementById(elemID));
        map.setCenter(new GLatLng(lat, lng), 15);            
        map.setMapType(G_PHYSICAL_MAP );
        
        
        //UI Options
        var customUI = map.getDefaultUI();
        customUI.maptypes.physical=true;
        customUI.maptypes.normal=true;
        customUI.maptypes.satellite=true;
        customUI.maptypes.hybrid=true;
        
        map.setUI(customUI);
        
        //custom overlays
        
        
        var tilelayer = new GTileLayer(new GCopyrightCollection(), 0, 17);
        tilelayer.getTileUrl = function(tile, zoom) {
            if (grid) {
                return "http://maps.csg.ca/tiles/GridTile.ashx?x="+tile.x+"&y="+tile.y+"&s="+zoom;
                
            } else {                
                return "http://maps.csg.ca/tiles/overlay/"+tile.x+"-"+tile.y+"-"+zoom+".png";
            }
               
        };
        //tilelayer.getOpacity = function() {return 0.5;}
        map.addOverlay(new GTileLayerOverlay(tilelayer));

        map.enableContinuousZoom();       
        return map;
    } else {
        return null;
    }
}

function initializeSage(elemID) {

    var lat=51.185434; //start map in Sage Hill
    var lng=-114.150353; 
    
    if (GBrowserIsCompatible()) {
    
        if (grid) {
            var mapcontainer = document.getElementById(elemID);
            mapcontainer.style.position="absolute";
            mapcontainer.style.top="0px";
            mapcontainer.style.left="0px";
            mapcontainer.style.width="100%";
            mapcontainer.style.height="100%";
        }
        //restrict zoom options...
        var mapTypes = G_DEFAULT_MAP_TYPES;
        for(var i = 0; i < mapTypes.length; i++) {
            mapTypes[i].getMaximumResolution = function(latlng){ return 15;};
            mapTypes[i].getMinimumResolution = function(latlng){ return 8;};
        }
        //init map
        var map = new GMap2(document.getElementById(elemID));
        map.setCenter(new GLatLng(lat, lng), 15);            
        map.setMapType(G_PHYSICAL_MAP );
        
        
        //UI Options
        var customUI = map.getDefaultUI();
        customUI.maptypes.physical=true;
        customUI.maptypes.normal=true;
        customUI.maptypes.satellite=true;
        customUI.maptypes.hybrid=true;
        
        map.setUI(customUI);
        
        //custom overlays
        
        
        var tilelayer = new GTileLayer(new GCopyrightCollection(), 0, 17);
        tilelayer.getTileUrl = function(tile, zoom) {
            if (grid) {
                return "http://maps.csg.ca/tiles/GridTile.ashx?x="+tile.x+"&y="+tile.y+"&s="+zoom;
                
            } else {                
                return "http://maps.csg.ca/tiles/overlay/"+tile.x+"-"+tile.y+"-"+zoom+".png";
            }
               
        };
        //tilelayer.getOpacity = function() {return 0.5;}
        map.addOverlay(new GTileLayerOverlay(tilelayer));

        map.enableContinuousZoom();       
        return map;
    } else {
        return null;
    }
}

function initializePano(elemID) {

    var lat=51.164107; //start map in Panorama Hills
    var lng=-114.07585; 
    
    if (GBrowserIsCompatible()) {
    
        if (grid) {
            var mapcontainer = document.getElementById(elemID);
            mapcontainer.style.position="absolute";
            mapcontainer.style.top="0px";
            mapcontainer.style.left="0px";
            mapcontainer.style.width="100%";
            mapcontainer.style.height="100%";
        }
        //restrict zoom options...
        var mapTypes = G_DEFAULT_MAP_TYPES;
        for(var i = 0; i < mapTypes.length; i++) {
            mapTypes[i].getMaximumResolution = function(latlng){ return 15;};
            mapTypes[i].getMinimumResolution = function(latlng){ return 8;};
        }
        //init map
        var map = new GMap2(document.getElementById(elemID));
        map.setCenter(new GLatLng(lat, lng), 15);            
        map.setMapType(G_PHYSICAL_MAP );
        
        
        //UI Options
        var customUI = map.getDefaultUI();
        customUI.maptypes.physical=true;
        customUI.maptypes.normal=true;
        customUI.maptypes.satellite=true;
        customUI.maptypes.hybrid=true;
        
        map.setUI(customUI);
        
        //custom overlays
        
        
        var tilelayer = new GTileLayer(new GCopyrightCollection(), 0, 17);
        tilelayer.getTileUrl = function(tile, zoom) {
            if (grid) {
                return "http://maps.csg.ca/tiles/GridTile.ashx?x="+tile.x+"&y="+tile.y+"&s="+zoom;
                
            } else {                
                return "http://maps.csg.ca/tiles/overlay/"+tile.x+"-"+tile.y+"-"+zoom+".png";
            }
               
        };
        //tilelayer.getOpacity = function() {return 0.5;}
        map.addOverlay(new GTileLayerOverlay(tilelayer));

        map.enableContinuousZoom();       
        return map;
    } else {
        return null;
    }
}

function initializeTusc(elemID) {

    var lat=51.116707; //start map in Tuscany
    var lng=-114.253696; 
    
    if (GBrowserIsCompatible()) {
    
        if (grid) {
            var mapcontainer = document.getElementById(elemID);
            mapcontainer.style.position="absolute";
            mapcontainer.style.top="0px";
            mapcontainer.style.left="0px";
            mapcontainer.style.width="100%";
            mapcontainer.style.height="100%";
        }
        //restrict zoom options...
        var mapTypes = G_DEFAULT_MAP_TYPES;
        for(var i = 0; i < mapTypes.length; i++) {
            mapTypes[i].getMaximumResolution = function(latlng){ return 15;};
            mapTypes[i].getMinimumResolution = function(latlng){ return 8;};
        }
        //init map
        var map = new GMap2(document.getElementById(elemID));
        map.setCenter(new GLatLng(lat, lng), 15);            
        map.setMapType(G_PHYSICAL_MAP );
        
        
        //UI Options
        var customUI = map.getDefaultUI();
        customUI.maptypes.physical=true;
        customUI.maptypes.normal=true;
        customUI.maptypes.satellite=true;
        customUI.maptypes.hybrid=true;
        
        map.setUI(customUI);
        
        //custom overlays
        
        
        var tilelayer = new GTileLayer(new GCopyrightCollection(), 0, 17);
        tilelayer.getTileUrl = function(tile, zoom) {
            if (grid) {
                return "http://maps.csg.ca/tiles/GridTile.ashx?x="+tile.x+"&y="+tile.y+"&s="+zoom;
                
            } else {                
                return "http://maps.csg.ca/tiles/overlay/"+tile.x+"-"+tile.y+"-"+zoom+".png";
            }
               
        };
        //tilelayer.getOpacity = function() {return 0.5;}
        map.addOverlay(new GTileLayerOverlay(tilelayer));

        map.enableContinuousZoom();       
        return map;
    } else {
        return null;
    }
}

function initializeSilverado(elemID) {

    var lat=50.889221; //start map in Silverado
    var lng=-114.089261; 
    
    if (GBrowserIsCompatible()) {
    
        if (grid) {
            var mapcontainer = document.getElementById(elemID);
            mapcontainer.style.position="absolute";
            mapcontainer.style.top="0px";
            mapcontainer.style.left="0px";
            mapcontainer.style.width="100%";
            mapcontainer.style.height="100%";
        }
        //restrict zoom options...
        var mapTypes = G_DEFAULT_MAP_TYPES;
        for(var i = 0; i < mapTypes.length; i++) {
            mapTypes[i].getMaximumResolution = function(latlng){ return 15;};
            mapTypes[i].getMinimumResolution = function(latlng){ return 8;};
        }
        //init map
        var map = new GMap2(document.getElementById(elemID));
        map.setCenter(new GLatLng(lat, lng), 15);            
        map.setMapType(G_PHYSICAL_MAP );
        
        
        //UI Options
        var customUI = map.getDefaultUI();
        customUI.maptypes.physical=true;
        customUI.maptypes.normal=true;
        customUI.maptypes.satellite=true;
        customUI.maptypes.hybrid=true;
        
        map.setUI(customUI);
        
        //custom overlays
        
        
        var tilelayer = new GTileLayer(new GCopyrightCollection(), 0, 17);
        tilelayer.getTileUrl = function(tile, zoom) {
            if (grid) {
                return "http://maps.csg.ca/tiles/GridTile.ashx?x="+tile.x+"&y="+tile.y+"&s="+zoom;
                
            } else {                
                return "http://maps.csg.ca/tiles/overlay/"+tile.x+"-"+tile.y+"-"+zoom+".png";
            }
               
        };
        //tilelayer.getOpacity = function() {return 0.5;}
        map.addOverlay(new GTileLayerOverlay(tilelayer));

        map.enableContinuousZoom();       
        return map;
    } else {
        return null;
    }
}

function initializeCranston(elemID) {

    var lat=50.881702; //start map in Cranston
    var lng=-113.984861; 
    
    if (GBrowserIsCompatible()) {
    
        if (grid) {
            var mapcontainer = document.getElementById(elemID);
            mapcontainer.style.position="absolute";
            mapcontainer.style.top="0px";
            mapcontainer.style.left="0px";
            mapcontainer.style.width="100%";
            mapcontainer.style.height="100%";
        }
        //restrict zoom options...
        var mapTypes = G_DEFAULT_MAP_TYPES;
        for(var i = 0; i < mapTypes.length; i++) {
            mapTypes[i].getMaximumResolution = function(latlng){ return 15;};
            mapTypes[i].getMinimumResolution = function(latlng){ return 8;};
        }
        //init map
        var map = new GMap2(document.getElementById(elemID));
        map.setCenter(new GLatLng(lat, lng), 15);            
        map.setMapType(G_PHYSICAL_MAP );
        
        
        //UI Options
        var customUI = map.getDefaultUI();
        customUI.maptypes.physical=true;
        customUI.maptypes.normal=true;
        customUI.maptypes.satellite=true;
        customUI.maptypes.hybrid=true;
        
        map.setUI(customUI);
        
        //custom overlays
        
        
        var tilelayer = new GTileLayer(new GCopyrightCollection(), 0, 17);
        tilelayer.getTileUrl = function(tile, zoom) {
            if (grid) {
                return "http://maps.csg.ca/tiles/GridTile.ashx?x="+tile.x+"&y="+tile.y+"&s="+zoom;
                
            } else {                
                return "http://maps.csg.ca/tiles/overlay/"+tile.x+"-"+tile.y+"-"+zoom+".png";
            }
               
        };
        //tilelayer.getOpacity = function() {return 0.5;}
        map.addOverlay(new GTileLayerOverlay(tilelayer));

        map.enableContinuousZoom();       
        return map;
    } else {
        return null;
    }
}

function initializeWestmere(elemID) {

    var lat=51.060058; //start map in Westmere
    var lng=-113.831601; 
    
    if (GBrowserIsCompatible()) {
    
        if (grid) {
            var mapcontainer = document.getElementById(elemID);
            mapcontainer.style.position="absolute";
            mapcontainer.style.top="0px";
            mapcontainer.style.left="0px";
            mapcontainer.style.width="100%";
            mapcontainer.style.height="100%";
        }
        //restrict zoom options...
        var mapTypes = G_DEFAULT_MAP_TYPES;
        for(var i = 0; i < mapTypes.length; i++) {
            mapTypes[i].getMaximumResolution = function(latlng){ return 15;};
            mapTypes[i].getMinimumResolution = function(latlng){ return 8;};
        }
        //init map
        var map = new GMap2(document.getElementById(elemID));
        map.setCenter(new GLatLng(lat, lng), 15);            
        map.setMapType(G_PHYSICAL_MAP );
        
        
        //UI Options
        var customUI = map.getDefaultUI();
        customUI.maptypes.physical=true;
        customUI.maptypes.normal=true;
        customUI.maptypes.satellite=true;
        customUI.maptypes.hybrid=true;
        
        map.setUI(customUI);
        
        //custom overlays
        
        
        var tilelayer = new GTileLayer(new GCopyrightCollection(), 0, 17);
        tilelayer.getTileUrl = function(tile, zoom) {
            if (grid) {
                return "http://maps.csg.ca/tiles/GridTile.ashx?x="+tile.x+"&y="+tile.y+"&s="+zoom;
                
            } else {                
                return "http://maps.csg.ca/tiles/overlay/"+tile.x+"-"+tile.y+"-"+zoom+".png";
            }
               
        };
        //tilelayer.getOpacity = function() {return 0.5;}
        map.addOverlay(new GTileLayerOverlay(tilelayer));

        map.enableContinuousZoom();       
        return map;
    } else {
        return null;
    }
}

/*
function addCommas(nStr)
{
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
	    x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    return x1 + x2;
}
*/
