﻿var CheckMapControl = false;
if ((window.location.href.indexOf("MapControl.aspx") >= 0) ||
           (window.location.href.indexOf("StaticMapControl.aspx") >= 0)) {
    CheckMapControl = true;
}

function ChangeDataSet(mapImageFolder) {
    var strHref = window.location.href;
    if (strHref.indexOf(MapPage, 0) == -1) {
        window.location.href = MapPage + mapImageFolder;
        return;
    }
    MapImageFolder = mapImageFolder;

    if (CheckMapControl) {
        SetMaps();
    }

    ChangeLinksColor();

    //Logging
    var Logging = new Image();
    var LoggingURL = ApplicationURL + "/Logging.ashx?url=" + ApplicationURL + "/" + MapPage + mapImageFolder;
    LoggingURL = LoggingURL.replace(/&/g, "|");
    LoggingURL = LoggingURL + "&phone=" + Phone;
    Logging.src = LoggingURL;
}


function ChangeLinksColor() {
    document.getElementById("ctl00_lnkForecast").style.color = "#FFCC33";
    document.getElementById("ctl00_lnkRadar").style.color = "#FFCC33";
    document.getElementById("ctl00_lnkStation").style.color = "#FFCC33";
    document.getElementById("ctl00_lnkPSI").style.color = "#FFCC33";
    document.getElementById("ctl00_lnkText").style.color = "#FFCC33";
    document.getElementById("ctl00_divForecastSubMenu").style.display = "none";
    document.getElementById("ctl00_divForecastTextInfo").style.display = "none";


    if (MapImageFolder == "3HourlyMaps") {
        document.getElementById("ctl00_lnkForecast").style.color = "#FFF";
        document.getElementById("ctl00_lnk3Days").style.color = "#69BCD3";
        document.getElementById("ctl00_lnk3Hours").style.color = "#FFF";
        document.getElementById("ctl00_lnk12Hours").style.color = "#69BCD3";
        document.getElementById("ctl00_divForecastSubMenu").style.display = "block";
        document.getElementById("ctl00_div3HourlyValidTime").style.display = "block";
        document.getElementById("ctl00_div12HourlyValidTime").style.display = "none";
    }
    else if (MapImageFolder == "12HourlyMaps") {
        document.getElementById("ctl00_lnkForecast").style.color = "#FFF";
        document.getElementById("ctl00_lnk3Days").style.color = "#69BCD3";
        document.getElementById("ctl00_lnk3Hours").style.color = "#69BCD3";
        document.getElementById("ctl00_lnk12Hours").style.color = "#FFF";
        document.getElementById("ctl00_divForecastSubMenu").style.display = "block";
        document.getElementById("ctl00_div3HourlyValidTime").style.display = "none";
        document.getElementById("ctl00_div12HourlyValidTime").style.display = "block";
    }
    else if (MapImageFolder == "RadarMaps") {
        document.getElementById("ctl00_lnkRadar").style.color = "#FFF";
        document.getElementById("ctl00_divRadarInfo").style.display = "block";
        document.getElementById("ctl00_divStationInfo").style.display = "none";
        document.getElementById("ctl00_divPSIInfo").style.display = "none";
    }
    else if (MapImageFolder == "PSIMaps") {
        document.getElementById("ctl00_lnkPSI").style.color = "#FFF";
        document.getElementById("ctl00_divPSIInfo").style.display = "block";
        document.getElementById("ctl00_divRadarInfo").style.display = "none";
        document.getElementById("ctl00_divStationInfo").style.display = "none";
    }
    else if (MapImageFolder == "StationTemperatureMaps") {
        document.getElementById("ctl00_lnkStation").style.color = "#FFF";
        document.getElementById("ctl00_lnkStationTemperature").style.color = "#FFF";
        document.getElementById("ctl00_lnkStationWind").style.color = "#69BCD3";
        document.getElementById("ctl00_lnkStationRain").style.color = "#69BCD3";
        document.getElementById("ctl00_lnkStationHumidity").style.color = "#69BCD3";
        document.getElementById("ctl00_divStationInfo").style.display = "block";
        document.getElementById("ctl00_divPSIInfo").style.display = "none";
        document.getElementById("ctl00_divRadarInfo").style.display = "none";
    }
    else if (MapImageFolder == "StationWindMaps") {
        document.getElementById("ctl00_lnkStation").style.color = "#FFF";
        document.getElementById("ctl00_lnkStationTemperature").style.color = "#69BCD3";
        document.getElementById("ctl00_lnkStationWind").style.color = "#FFF";
        document.getElementById("ctl00_lnkStationRain").style.color = "#69BCD3";
        document.getElementById("ctl00_lnkStationHumidity").style.color = "#69BCD3";
    }
    else if (MapImageFolder == "StationRainMaps") {
        document.getElementById("ctl00_lnkStation").style.color = "#FFF";
        document.getElementById("ctl00_lnkStationTemperature").style.color = "#69BCD3";
        document.getElementById("ctl00_lnkStationWind").style.color = "#69BCD3";
        document.getElementById("ctl00_lnkStationRain").style.color = "#FFF";
        document.getElementById("ctl00_lnkStationHumidity").style.color = "#69BCD3";
    }
    else if (MapImageFolder == "StationHumidityMaps") {
        document.getElementById("ctl00_lnkStation").style.color = "#FFF";
        document.getElementById("ctl00_lnkStationTemperature").style.color = "#69BCD3";
        document.getElementById("ctl00_lnkStationWind").style.color = "#69BCD3";
        document.getElementById("ctl00_lnkStationRain").style.color = "#69BCD3";
        document.getElementById("ctl00_lnkStationHumidity").style.color = "#FFF";
    }
}

function ChangeForecastTextLinksColor(area) {
    var strHref = window.location.href.toLowerCase();
    if (strHref.indexOf("forecasttext.aspx", 0) == -1) {
        window.location.href = "ForecastText.aspx?zone=" + area;
        return;
    }

    if (area.toString().toLowerCase() == "east") {
        document.getElementById("ctl00_ctl00_lnkCentral").style.color = "#69BCD3";
        document.getElementById("ctl00_ctl00_lnkEast").style.color = "#FFF";
        document.getElementById("ctl00_ctl00_lnkWest").style.color = "#69BCD3";
        document.getElementById("ctl00_ctl00_lnkNorth").style.color = "#69BCD3";
        document.getElementById("ctl00_ctl00_lnkSouth").style.color = "#69BCD3";
        ChangeForecastTextAreaData(area);
    }
    else if (area.toString().toLowerCase() == "west") {
        document.getElementById("ctl00_ctl00_lnkCentral").style.color = "#69BCD3";
        document.getElementById("ctl00_ctl00_lnkEast").style.color = "#69BCD3";
        document.getElementById("ctl00_ctl00_lnkWest").style.color = "#FFF";
        document.getElementById("ctl00_ctl00_lnkNorth").style.color = "#69BCD3";
        document.getElementById("ctl00_ctl00_lnkSouth").style.color = "#69BCD3";
        ChangeForecastTextAreaData(area);
    }
    else if (area.toString().toLowerCase() == "central") {
        document.getElementById("ctl00_ctl00_lnkCentral").style.color = "#FFF";
        document.getElementById("ctl00_ctl00_lnkEast").style.color = "#69BCD3";
        document.getElementById("ctl00_ctl00_lnkWest").style.color = "#69BCD3";
        document.getElementById("ctl00_ctl00_lnkNorth").style.color = "#69BCD3";
        document.getElementById("ctl00_ctl00_lnkSouth").style.color = "#69BCD3";
        ChangeForecastTextAreaData(area);
    }
    else if (area.toString().toLowerCase() == "north") {
        document.getElementById("ctl00_ctl00_lnkCentral").style.color = "#69BCD3";
        document.getElementById("ctl00_ctl00_lnkEast").style.color = "#69BCD3";
        document.getElementById("ctl00_ctl00_lnkWest").style.color = "#69BCD3";
        document.getElementById("ctl00_ctl00_lnkNorth").style.color = "#FFF";
        document.getElementById("ctl00_ctl00_lnkSouth").style.color = "#69BCD3";
        ChangeForecastTextAreaData(area);
    }
    else if (area.toString().toLowerCase() == "south") {
        document.getElementById("ctl00_ctl00_lnkCentral").style.color = "#69BCD3";
        document.getElementById("ctl00_ctl00_lnkEast").style.color = "#69BCD3";
        document.getElementById("ctl00_ctl00_lnkWest").style.color = "#69BCD3";
        document.getElementById("ctl00_ctl00_lnkNorth").style.color = "#69BCD3";
        document.getElementById("ctl00_ctl00_lnkSouth").style.color = "#FFF";
        ChangeForecastTextAreaData(area);
    }
}

function RedirectFAQ() {
    var sHref = window.location.href.toLowerCase();
    if (sHref.indexOf("today") != -1) {
        window.location = "faq_today.aspx";
    }
    else if (sHref.indexOf("3day") != -1) {
        window.location = "faq_3days.aspx";
    }
    else if (sHref.indexOf("text") != -1) {
        window.location = "faq_text.aspx";
    }
    else if (sHref.indexOf("mapcontrol") != -1) {
        if (MapImageFolder == "3HourlyMaps") {
            window.location = "faq_3hrs.aspx";
        }
        else if (MapImageFolder == "12HourlyMaps") {
            window.location = "faq_12hrs.aspx";
        }
        else if (MapImageFolder == "RadarMaps") {
            window.location = "faq_rain.aspx";
        }
        else if (MapImageFolder == "PSIMaps") {
            window.location = "faq_psi.aspx";
        }
        else if (MapImageFolder.indexOf("Station") > -1) {
            window.location = "faq_readings.aspx";
        }
    }
}