﻿// JScript File

function BuildBaseIcon(){
    //Create a base icon that can be used for all of the markers.
    //The image file is set when the marker is assigned in the setupOfficeMarkers() function.
    baseIcon = new GIcon();
    baseIcon.iconSize = new GSize(22, 23);
    baseIcon.iconAnchor = new GPoint(12, 7);
    baseIcon.infoWindowAnchor = new GPoint(17, 8);
}

function BuildHeatIcon(){
    //Create a base icon that can be used for all of the markers.
    //The image file is set when the marker is assigned in the setupOfficeMarkers() function.
    heatIcon = new GIcon();
    heatIcon.iconSize = new GSize(80, 80);
    heatIcon.iconAnchor = new GPoint(40, 40);
    heatIcon.infoWindowAnchor = new GPoint(40, 40);
}


function SetupImageIconArray(){
    //This associative array maps a location type to a png file in the images folder.
    //Each location type has a specific color to distinguish between locations of different types.
    Array_IconImage["Medical Center"] = "mc";
    Array_IconImportance["Medical Center"] = 9;
    Array_IconImage["Affiliated Medical Center"] = "aff";
    Array_IconImportance["Affiliated Medical Center"] = 8;
    Array_IconImage["Corporate Office"] = "crp";
    Array_IconImportance["Corporate Office"] = 7;
    Array_IconImage["Advanced Medical Specialist"] = "ams";
    Array_IconImportance["Advanced Medical Specialist"] = 6;
    Array_IconImage["Urgent Care"] = "uc";
    Array_IconImportance["Urgent Care"] = 10;
}

function SetupTranslationsArray(){
    Array_LocationTypeTranslation["Urgent Care"] = "Medical Center with Urgent Care";
    Array_LocationTypeTranslation["Medical Center"] = "Medical Center";
    Array_LocationTypeTranslation["Corporate Office"] = "Corporate Office";
    Array_LocationTypeTranslation["Affiliated Medical Center"] = "Affiliated Medical Center";
    Array_LocationTypeTranslation["Advanced Medical Specialist"] = "Advanced Medical Specialists";
    Array_LocationTypeTranslation["Advanced Medical Specialists"] = "Advanced Medical Specialists";
}

function SetupAddressFailureCodes(){
    // ====== Array for decoding the failure codes ======
    Array_AddressFailureReasons[G_GEO_SUCCESS]            = "Success";
    Array_AddressFailureReasons[G_GEO_MISSING_ADDRESS]    = "Missing Address: The address was either missing or had no value.";
    Array_AddressFailureReasons[G_GEO_UNKNOWN_ADDRESS]    = "Unknown Address:  Please check the address you entered.";
    Array_AddressFailureReasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
    Array_AddressFailureReasons[G_GEO_BAD_KEY]            = "Bad Key: The API key is either invalid or does not match the domain for which it was given";
    Array_AddressFailureReasons[G_GEO_TOO_MANY_QUERIES]   = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";
    Array_AddressFailureReasons[G_GEO_SERVER_ERROR]       = "Server error: The geocoding request could not be successfully processed.";
}

function SetMapToFillWindow(mapDiv){
    //The mapDiv gives access to the CSS properties to enable the dynamic width and heigh of the Google map.
    //The GetAvailableWidth() funciton checks several factors to decide the size of the map.
    //The GetUtilityWidth() function helps the map decide the left-hand position of the map.
    mapDiv = document.getElementById(mapDiv);
    mapDiv.style.width = (GetAvailableWidth()).toString() + "px";
    mapDiv.style.left = (GetUtilityWidth()).toString() + "px";
}

function SetupDefaultsForMainMap(mapVar){
    geocoder = new GClientGeocoder();
    bounds = new GBounds();
    trafficInfo = new GTrafficOverlay();
    mapVar.setCenter(new GLatLng(36.52729481454624, -95.80078125), 4);
    mapVar.enableDoubleClickZoom();
    mapVar.enableScrollWheelZoom();
    mapVar.enableContinuousZoom();
    mapVar.addControl(new GLargeMapControl());
    mapVar.addControl(new GMapTypeControl());
    mapVar.addControl(new TrafficControl());
    mapVar.addControl(new GScaleControl());
    mapVar.addMapType(G_PHYSICAL_MAP); 
    mapVar.removeMapType(G_HYBRID_MAP); 
    mapVar.setMapType(G_PHYSICAL_MAP);
}

function SetupMyLocationElements(){
    MyLocationChangeDiv = document.getElementById("MyLocationChange");
    MyLocationChangeAddressDiv = document.getElementById("MyLocationChangeAddress");
    MyLocationDiv = document.getElementById("MyLocation");
    MyLocationAddressTextDiv = document.getElementById("MyLocationAddressText");
    MyLocationSearchVal = document.getElementById("searchVal");
    MyLocationSearchCloseBtn = document.getElementById("CancelMyLoc");
}