/* Compressed with http://www.lotterypost.com/css-compress.aspx*/

function getQueryStringVal(key) {
    var url = window.location.search.substring(1);
    var qsPairs = url.split("&");
    for (var i = 0; i < qsPairs.length; i++) {
        var pair = qsPairs[i].split("=");
        if (pair[0] == key) {
            return pair[1];
        }
    }
    return "";
}

// ========== GOOGLE MAP CLASS =================================================================================================
var map;
var selectLocation;

var GoogleMap = new Class({
    defaultOptions: {
        showtype: true,
        controlsize: "large", // large or small
        maptype: 0, // [map:0,sat:1,hyb:2]
        zoom: 1,
        minzoom: 1,
        maxzoom: 16,
        showzoom: true,
        showoverview: false,
        smoothzoom: true,
        scrollzoom: false,
        doubleclickzoom: false,
        dragging: true,
        markerList: null,
        initialLoad: true
    },
    params: {
        zoom: 1,
        lat: 1,
        lng: 30,
        minlat: false,
        maxlat: false,
        minlng: false,
        maxlng: false,
        activeMarker: null,
        startMarker: true
    },
    initialize: function(mapID, options) {
        this.setOptions($merge(this.defaultOptions, options));
        // ===== Check For Requirements =====
        if (GBrowserIsCompatible()) {
            if (!$(mapID)) return;
            this.mapID = mapID;
            this.map = new GMap($(mapID));
            this.map.setMapType(G_DEFAULT_MAP_TYPES[this.options.maptype]);
            this.map.getPane(G_MAP_FLOAT_SHADOW_PANE).style.display = 'none'; //get rid of bubble shadow
            // ===== Set Options =====
            if (this.options.showtype) this.map.addControl(new GMapTypeControl(3));
            if (this.options.showzoom && this.options.controlsize == "small") this.map.addControl(new GSmallMapControl()); // Small Zoom Controls
            if (this.options.showzoom && this.options.controlsize == "large") this.map.addControl(new GLargeMapControl()); // Large Zoom Controls
            if (this.options.showscale) this.map.addControl(new GScaleControl()) // Map Scale
            if (this.options.showoverview) this.map.addControl(new GOverviewMapControl());
            if (this.options.doubleclickzoom) this.map.enableDoubleClickZoom();
            if (this.options.scrollzoom) this.map.enableScrollWheelZoom();
            if (this.options.smoothzoom) this.map.enableContinuousZoom();
            if (!this.options.dragging) this.map.disableDragging();
            // ===== If Everything is ready, load the map =====
            if (this.options.initialLoad) { this.initialSetup() } else { this.cachedSetup() };
            // ===== Restricting the range of Zoom Levels =====
            // Overwrite the getMinimumResolution() and getMaximumResolution() methods
            var mt = this.map.getMapTypes();
            for (var i = 0; i < mt.length; i++) {
                mt[i].getMinimumResolution = function() { return this.options.minzoom } .bind(this);
                mt[i].getMaximumResolution = function() { return this.options.maxzoom } .bind(this);
            }
            // ===== Add EventListeners To Map =====
            GEvent.addListener(this.map, "load", function() {
                this.zoomSlider.setMin(this.map.getZoom());
            } .bind(this));
            GEvent.addListener(this.map, "dragstart", function() {
            } .bind(this));
            GEvent.addListener(this.map, "movestart", function() {
                this.hideBubbleDialog();
            } .bind(this));
            GEvent.addListener(this.map, "moveend", function() {
                this.displayMarkers();
            } .bind(this));
            GEvent.addListener(this.map, "zoomstart", function() {
                this.hideBubbleDialog();
            } .bind(this));
            GEvent.addListener(this.map, "zoomend", function() {
                this.zoomSlider.setMin(this.map.getZoom());
            } .bind(this));
            GEvent.addListener(this.map, "maptypechanged", function() {
                var type = this.map.getCurrentMapType().getName();
                this.adjustMapButtons(type);
            } .bind(this));
            // ===== Add EventListeners To Graphic Buttons =====
            GEvent.addDomListener($('mapType_MAP'), "click", function() {
                this.map.setMapType(G_MAP_TYPE);
            } .bind(this));
            GEvent.addDomListener($('mapType_SAT'), "click", function() {
                this.map.setMapType(G_SATELLITE_TYPE);
            } .bind(this));
            GEvent.addDomListener($('mapType_HYB'), "click", function() {
                this.map.setMapType(G_HYBRID_TYPE);
            } .bind(this));
            // ===== Init Slider Zoom Controls =====
            $('btnZoomPlus').addEvent('click', function() {
                this.zoomSlider.setMin(parseInt(this.params.zoom) + 1);
            } .bind(this)).setStyle('cursor', 'pointer');
            $('btnZoomMinus').addEvent('click', function() {
                this.zoomSlider.setMin(parseInt(this.params.zoom) - 1);
            } .bind(this)).setStyle('cursor', 'pointer');
            this.zoomSlider = new Slider($('zoomTrack'), $('btnThumb'), {
                start: this.options.minzoom,
                end: this.options.maxzoom,
                offset: 0,
                knobheight: 13,
                mode: 'horizontal', // vertical or horizontal;
                onComplete: function(pos) {
                    this.params.zoom = pos;
                    this.map.setZoom(parseInt(pos));
                } .bind(this)
            }, null);
            // ===== Marker Array Containers =====
            this.startPoint = null;
            this.gmarkers = []; // full list of markers;
            this.inBounds = []; // track markers in bounds;
            this.htmls = [];
            this.count = 0;

            // ===== Directions API ======
            this.gRoute = new GDirections(this.map);
            GEvent.addListener(this.gRoute, "load", function() {
                (function() { this.showDirections() } .bind(this)).delay(1);
            } .bind(this));

            var reasons = []; // === Array for decoding the failure codes ===
            reasons[G_GEO_SUCCESS] = "Success";
            reasons[G_GEO_MISSING_ADDRESS] = "Missing Address: The address was either missing or had no value.";
            reasons[G_GEO_UNKNOWN_ADDRESS] = "Unknown Address:  No corresponding geographic location could be found for the specified address.";
            reasons[G_GEO_UNAVAILABLE_ADDRESS] = "Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
            reasons[G_GEO_BAD_KEY] = "Bad Key: The API key is either invalid or does not match the domain for which it was given";
            reasons[G_GEO_TOO_MANY_QUERIES] = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";
            reasons[G_GEO_SERVER_ERROR] = "Server error: The geocoding request could not be successfully processed.";
            reasons[G_GEO_BAD_REQUEST] = "A directions request could not be successfully parsed.";
            reasons[G_GEO_MISSING_QUERY] = "No query was specified in the input.";
            reasons[G_GEO_UNKNOWN_DIRECTIONS] = "The GDirections object could not compute directions between the points.";

            // === catch Directions errors ===
            GEvent.addListener(this.gRoute, "error", function() {
                var code = this.gRoute.getStatus().code;
                var reason = "Code " + code;
                if (reasons[code]) reason = reasons[code];
                alert("Failed to obtain directions, " + reason);
            } .bind(this));

        } else {
            alert("Sorry, the Google Maps API is not compatible with this browser");
            return;
        };
        // ===== Init Map (kludge to set zoom slider) =====
        GEvent.trigger(this.map, "load");
    },
    // =====[ Data Types ]=======================================================
    loadData: function(data, callback) {
        var self = this;
        new Ajax(data, {
            method: 'get',
            evalScripts: false,
            onComplete: function(text, xml) {
                callback(xml);
            }
        }).request();
    },
    initialSetup: function() {
        this.map.setCenter(new GLatLng(this.params.lng, this.params.lat), this.options.zoom);
    },
    cachedSetup: function() {
        this.map.setCenter(new GLatLng(this.params.lng, this.params.lat), this.params.zoom);
    },
    // =====[ Display Markers ]=====================================================
    resetMap: function() {
    },
    updateMap: function(address) {
        this.params.address = address;
        this.getLocation(address);
    },
    initLocation: function(address) {
        this.removeAllMarkers();
        var geocoder = new GClientGeocoder();
        geocoder.getLatLng(address, function(point) {
            if (point) {
                this.hideBubbleDialog();
                this.map.setCenter(point, this.params.zoom);
                this.setBounds();
            } else {
                this.removeAllMarkers();
                this.message('Unable to find the location. Please verify the address and submit again.');
                return false;
            }
        } .bind(this));
    },
    getLocation: function(address) {
        this.removeAllMarkers();
        var geocoder = new GClientGeocoder();
        geocoder.getLocations(address, function(result) {
            if (result.Status.code == G_GEO_SUCCESS) {
                var place = result.Placemark[0];
                var p = place.Point.coordinates;
                // ===== Store New Location =====
                this.params.lat = p[1];
                this.params.lng = p[0];
                // ====== Set Start Icon =====
                if ($defined(this.startPoint)) this.removeMarker(this.startPoint)
                var marker = new GMarker(new GLatLng(p[1], p[0]), icon.self());
                this.startPoint = marker;
                this.map.addOverlay(marker);
                this.setLocation();
            } else {
                this.removeAllMarkers();
                this.message('Unable to find the location. Please verify the address and submit again.');
                return false;
            }
        } .bind(this));
    },
    setLocation: function(point) {
        if (!point) {
            var point = new GLatLng(this.params.lat, this.params.lng);
        }
        this.hideBubbleDialog();
        this.map.setCenter(point, this.params.zoom);
        this.setBounds();
    },
    setBounds: function() {
        var bounds = this.map.getBounds();
        this.params.minlat = Math.min(bounds.getSouthWest().lat(), bounds.getNorthEast().lat());
        this.params.maxlat = Math.max(bounds.getSouthWest().lat(), bounds.getNorthEast().lat());
        this.params.minlng = Math.min(bounds.getSouthWest().lng(), bounds.getNorthEast().lng());
        this.params.maxlng = Math.max(bounds.getSouthWest().lng(), bounds.getNorthEast().lng());

        this.saveLocation();
    },
    saveLocation: function() {
        this.showMarkers();
    },
    // =====[ Display Markers ]=====================================================
    showMarkers: function() {
        this.createBubbleDialog();
        this.markerList.each(function(mark) {
            this.setMarker(mark);
        } .bind(this));
        this.displayMarkers();
        // ===== Activate Checkboxes to Hide/Show Markers =====
        $E('#mapLegend').setStyle('display', 'block');
        $$('.checkbox').each(function(checkbox) {
            checkbox.addEvent('click', function(e) {
                new Event(e).stop();
                var id = checkbox.getElement('img').getProperty('id').replace('chbx_', '').toLowerCase();
                var box = checkbox.getElement('img');
                if (box.src.indexOf('_OFF') > -1) {
                    box.src = box.src.replace('_OFF', '_ON');
                } else {
                    box.src = box.src.replace('_ON', '_OFF');
                }
                this.toggleMarkers(id);
            } .bind(this));
        } .bind(this));
    },
    setMarker: function(mark) {
        var marker = new GMarker(new GLatLng(mark.lat, mark.lng), mark.icon);
        this.gmarkers[this.count] = marker;
        this.gmarkers[this.count].type = mark.type.toLowerCase();
        // ===== AddEventListeners =====
        GEvent.addListener(marker, "click", function() {
            this.showBubbleDialog(marker, this.formatDialogText(mark, this.startPoint, marker));
            if ($('getRoute')) {
                $('getRoute').addEvent('click', function(e) {
                    new Event(e).stop();
                    this.activeMarker = mark;
                    this.getDirections(mark);
                    $('getRoute').addClass('loading');
                } .bind(this));
            }
        } .bind(this));
        this.count++;
    },
    addMarker: function(marker) {
        this.map.addOverlay(marker);
    },
    removeMarker: function(marker) {
        this.map.removeOverlay(marker)
    },
    removeAllMarkers: function() {
        if (this.gmarkers.length > 0) {
            while (this.gmarkers.length > 0) {
                this.map.removeOverlay(this.gmarkers.shift());
            }
        }
        this.inBounds = [];
        this.gmarkers = [];
        this.count = 0;
    },
    displayMarkers: function() {
        var total = 0;
        this.inBounds = [];
        // ===== Show markers ONLY if they're in bounds =====
        var bounds = this.map.getBounds();
        var mapBounds = new GLatLngBounds(bounds.getSouthWest(), bounds.getNorthEast());
        this.gmarkers.each(function(marker, i) {
            this.removeMarker(marker);
            //if (mapBounds.containsLatLng(marker.getPoint())) {
                this.inBounds.include(marker);
                this.addMarker(marker);
                // ===== Only show markers if checkbox is ON =====
                if (!this.isMarkerActive(marker.type)) {
                    marker.hide();
                } else {
                    total++;
                }
            //};
            $('totalMarkers').setHTML(total);
        } .bind(this));
    },
    toggleMarkers: function(type) {
        var total = $('totalMarkers').getText();
        this.inBounds.each(function(marker) {
            if (marker.type == type) {
                if (!marker.isHidden()) {
                    marker.hide(); total--;
                } else {
                    marker.show(); total++;
                }
            };
        });
        $('totalMarkers').setHTML(total);
    },
    isMarkerActive: function(type) {
        var img = 'chbx_' + type.capitalize();
        return ($(img).getProperty('src').indexOf('_ON') > -1) ? true : false;
    },
    // =====[ Custom Bubble Dialog ]================================================
    createBubbleDialog: function() {
        if (!$("bubble")) $('googleMap').adopt(new Element('div', { 'id': 'bubble', 'class': 'mapBubble png' }).adopt(new Element('div', { 'class': 'info' })));
    },
    hideBubbleDialog: function() {
        if ($("bubble")) $("bubble").setStyle('display', 'none');
    },
    showBubbleDialog: function(marker, info) {
        var pixels = this.positionBubbleTo(marker);
        var ico = { width: icon.display(marker.type).iconSize.width, height: icon.display(marker.type).iconSize.height };
        var size = { width: $('bubble').getStyle('width').toInt(), height: $('bubble').getStyle('height').toInt() };
        $('bubble').setStyles({
            'top': pixels.y - size.height + (ico.height / 2) + 'px',
            //note had to adjest the left position of the bubble by 87px
            //this position can be configured on instatiation
            'left': (pixels.x - (size.width / 2) + (ico.width / 2) - 97) + 'px',
            'display': 'block'
        });
        $E('#bubble .info').setHTML(info);
        if ($('getRoute')) { $('getRoute').removeClass('loading'); }
        new Element('div', { 'class': 'close' }).setHTML('<img src="/tdwresources/img/map/btn_CLOSE.gif" border="0">').addEvent('click', function() { this.hideBubbleDialog() } .bind(this)).injectTop($E('#bubble .info'));
    },
    positionBubbleTo: function(marker) {

// Check zoom level to know where to have the popup show up.
if (this.params.zoom != 1)
{
        var cornerTopLeft = this.map.fromContainerPixelToLatLng(new GPoint(0, 0), true);
        var mapPos = this.map.fromLatLngToDivPixel(cornerTopLeft);
        var markerPos = this.map.fromLatLngToDivPixel(marker.getPoint());
        var markerPagePos = new GPoint(markerPos.x - mapPos.x, markerPos.y - mapPos.y);
        var pixels = this.map.getContainer().getPosition();
        return { x: markerPagePos.x, y: markerPagePos.y }
}
else
{
	
         var cornerTopLeft = this.map.fromContainerPixelToLatLng(new GPoint(0, 0), true);
        var mapPos = this.map.fromLatLngToDivPixel(cornerTopLeft);
        var markerPos = this.map.fromLatLngToDivPixel(marker.getPoint());

        var markerPagePos = new GPoint(markerPos.x, markerPos.y);
        var pixels = this.map.getContainer().getPosition();
        return { x: markerPagePos.x, y: markerPagePos.y }
}

    },
    // =====[ Alert Message Dialog ]================================================
    createMessageDialog: function() {
    },
    hideMessageDialog: function() {
    },
    message: function(msg) {
        console.log(msg);
        
    },
    positionMessageTo: function(marker) {
    },
    // =====[ Format Strings ]======================================================
    formatDialogText: function(info, start, end) {
        var phone = info.phone;
        var url = info.url;
        var id = info.id;
        var str = info.location
            + '<div class="clearBoth"></div>'
            + '<div class="btn_more"><a href="' + VariantGlobalJSVar + url + '?id=' + id + '"><img src="/tdwresources/img/map/btn_more_info.gif" alt="More Info" align="left"  width="46" height="11"/></a></div>'
            + '<div class="phone">'
            + '    Phone:' + phone;
+'<div><div class="clearBoth"></div>';
        return str;
    },
    validUSState: function(str) {
    },
    validUSZipCode: function(str) {
        /* ==================================================*\
        DESCRIPTION: Validates that a string is a United
        States zip code in 5 digit format or zip+4 format. 
        EXAMPLE: 99999 or 99999-9999
        \*===================================================*/
        var oRegExp = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
        return oRegExp.test(str);
    },
    // =====[ External Map Controls ]===============================================
    adjustMapButtons: function(type) {
        $('mapType_MAP').setProperty('src', $('mapType_MAP').getProperty('src').replace('_active', '_inactive'));
        $('mapType_SAT').setProperty('src', $('mapType_SAT').getProperty('src').replace('_active', '_inactive'));
        $('mapType_HYB').setProperty('src', $('mapType_HYB').getProperty('src').replace('_active', '_inactive'));
        switch (type) {
            case 'Satellite': $('mapType_SAT').setProperty('src', $('mapType_SAT').getProperty('src').replace('_inactive', '_active')); break;
            case 'Hybrid': $('mapType_HYB').setProperty('src', $('mapType_HYB').getProperty('src').replace('_inactive', '_active')); break;
            default: $('mapType_MAP').setProperty('src', $('mapType_MAP').getProperty('src').replace('_inactive', '_active')); break;
        }
    },
    // =====[ Driving Directions ]================================================
    getDirections: function(end) {
        this.clearDirections();
        this.gRoute.load("from: " + this.params.address + " to: " + end.lat + "," + end.lng, { 'getSteps': true, 'preserveViewport': true, 'getPolyline': true });
    },
    showDirections: function() {
        if ($('dirSteps')) $('dirSteps').remove();
        new Element('table', { 'id': 'dirSteps' }).injectBefore($('directions').getElement('.summary'));
        var tbody = new Element('tbody').injectInside('dirSteps');
        tbody.adopt(new Element('tr').adopt(new Element('th', { 'colspan': 3 }).setHTML(this.activeMarker.location + "<br />" + this.activeMarker.address)));
        // === read through the GRoutes and GSteps ===
        for (var r = 0, rl = this.gRoute.getNumRoutes(); r < rl; r++) {
            var route = this.gRoute.getRoute(r);
            for (var s = 0, sl = route.getNumSteps(r); s < sl; s++) {
                var step = route.getStep(s);
                tbody.adopt(
					new Element('tr')
					.adopt(new Element('td').setHTML(s + 1 + '.'))
					.adopt(new Element('td').setHTML(step.getDescriptionHtml()))
					.adopt(new Element('td').setHTML('<em>' + step.getDistance().html + '</em>'))
				);
            }
        }
        // ===== Hide START / STOP / PAUSE icon(s) =====
        var numMarkers = this.gRoute.getNumGeocodes();
        for (var i = 0; i < numMarkers; i++) {
            var marker = this.gRoute.getMarker(i);
            if (marker != null) marker.hide();
        }
        // ===== Add Path Between Points =====
        this.map.addOverlay(this.gRoute.getPolyline());
        // ===== Mileage / Duration =====
        $E('#directions .summary').setHTML(this.gRoute.getSummaryHtml());
        // ===== Copyright =====
        $E('#printDirections .copyright').setHTML(this.gRoute.getCopyrightsHtml());
        // ===== Print Function =====
        $E('#printDirections a').addEvent('click', function(e) {
            new Event(e).stop();
            this.printDirections();
        } .bind(this));
        $('gmap').setStyle('width', '700px');
        $('directions').setStyle('display', 'block');
        this.hideBubbleDialog();
    },
    clearDirections: function() {
        this.gRoute.clear();
        $E('#directions .summary').setHTML('&nbsp;');
        $E('#printDirections .copyright').setHTML('&nbsp;');
        if ($('dirSteps')) $('dirSteps').remove();
        if ($('formatForPrint')) $('formatForPrint').remove();
        $('directions').setStyle('display', 'none');
        $('gmap').setStyle('width', '100%');
    },
    printDirections: function() {
        // ===== Format Content for Print =====
        $E('body').adopt(new Element('div', { 'id': 'formatForPrint' }))
        $('formatForPrint').setHTML($('directions').innerHTML);
        $E('#formatForPrint img').remove();
        $E('#formatForPrint a').remove();

        // ===== Add Content to iframe =====
        if (!$('printFrame')) $E('body').adopt(new Element('iframe', { 'id': 'printFrame', 'name': 'printFrame', 'frameborder': 0, 'src': 'javascript:document.write("")' }))
        var dirFrame = $('printFrame');
        var iframeDoc = (dirFrame.document) ? dirFrame.contentWindow.document : dirFrame.contentDocument;
        iframeDoc.open();
        iframeDoc.write('<html><head><title>Directions</title>');
        iframeDoc.write('<link type="text/css" rel="stylesheet" href="css/directions.css" />');
        iframeDoc.write('</head><body>');
        iframeDoc.write('<div id="formatForPrint">' + $('formatForPrint').innerHTML + '</div>');
        iframeDoc.write('</body></html>');
        iframeDoc.close();
        (function() {
            window['printFrame'].focus();
            window['printFrame'].print();
        }).delay(1000);
    }
});
// ========== END GOOGLE MAP CLASS =================================================================================================

GoogleMap.implement(new Options);
window.addEvent('unload', GUnload);

// =====[ Icon Graphics ]===================================================================================================
var icon = {
    display: function(type) {
        switch (type) {
            case 'location': return icon.location(); break;
            case 'service': return icon.service(); break;
            case 'both': return icon.both(); break;
        };
    },
    self: function() {
        var icon = new GIcon();
        icon.image = "/tdwresources/img/map/icon_YOU.png";
        icon.iconSize = new GSize(37, 41);
        icon.iconAnchor = new GPoint(16, 38);
        return icon;
    },
    location: function() {
        var icon = new GIcon();
        icon.image = "/tdwresources/img/map/icon_location.png";
        icon.iconSize = new GSize(37, 41);
        icon.iconAnchor = new GPoint(16, 43);
        return icon;
    },
    service: function() {
        var icon = new GIcon();
        icon.image = "/tdwresources/img/map/icon_service.png";
        icon.iconSize = new GSize(37, 41);
        icon.iconAnchor = new GPoint(16, 43);
        return icon;
    },
    both: function() {
        var icon = new GIcon();
        icon.image = "/tdwresources/img/map/icon_BOTH.png";
        icon.iconSize = new GSize(37, 41);
        icon.iconAnchor = new GPoint(16, 43);
        return icon;
    }
}
// =====[ Google Map ]======================================================================================================

window.addEvent('domready', function() {
    map = new GoogleMap('gmap', {
        showtype: false,
        showzoom: false,
        zoom: 1
    });
    // ===== Add Events to Inputs =====
    $$('#googleMap .inputFields input').each(function(input) {
        input.addEvent('keydown', function(event) {
            var e = new Event(event);
            if (e.key == 'enter') { map.buildAddress(); e.stop(); };
        }).addEvent('focus', function(event) {
            if (input.value == input.defaultValue) { input.value = ''; }
        }).addEvent('blur', function(event) {
            if (input.value == '') { input.value = input.defaultValue; }
        });
    });
    $('btnSearch').addEvent('click', function(event) {
        map.buildAddress(); new Event(event).stop();
    });

    // ===== Format Address ======
    map.buildAddress = function() {
        var str = '';
        // ===== gather input values =====
        var address = ($E('#mapAddress input').value != $E('#mapAddress input').defaultValue) ? $E('#mapAddress input').value.clean() : '';
        // ===== format =====
        //if((city && state)|| map.validUSZipCode(zip)){
        str += (address) ? address + ' ' : '';
        map.params.startMarker = true;
        map.updateMap(str);
    };

    // ===== Load Data File ======
    map.parseXML = function(data) {
        var markerList = [];
        var markers = data.getElementsByTagName('marker');

        for (var x = 0, xl = markers.length; x < xl; x++) {
            var marker = markers[x];
            var mtype = marker.getAttribute('type');

            var locale = {
                type: mtype,
                icon: icon.display(mtype),
                location: marker.getAttribute('location'),
                address: marker.getAttribute('address'),
                phone: marker.getAttribute('phone'),
                url: marker.getAttribute('url') || '',
                lat: marker.getAttribute('lat'),
                lng: marker.getAttribute('lng'),
                id: marker.getAttribute('id')
            };
            markerList.include(locale);
        };
        map.markerList = markerList;
        // ===== Hide "You" marker =====
        map.params.startMarker = false;
        map.initLocation(map.params.lng + "," + map.params.lat);
        selectLocation = getQueryStringVal("selectedCountry");
        if (selectLocation != "") {
            setTimeout('moveToLocation()', 500);
            map.updateMap(selectLocation);
        }
    };
    map.loadData(VariantGlobalJSVar + '/contactus/_layouts/tdw/getlocationxml.aspx', map.parseXML);
});

function moveToLocation() {
    map.updateMap(selectLocation);
}


