﻿$(function () {

    // ========================================================================
    // Functions for the locations default page 
    // ========================================================================
    $("#country a").click(function (e) {
        e.preventDefault();

        if (typeof (closePopups) != "undefined" && $.isFunction(closePopups)) {
            closePopups();
        }

        // Make the non-selected country semi-transparent
        $(".countrymap,#map-icons a,#location-list").hide();
        $("#country a").css("color", "#787878").find("img").css("opacity", .5);
        $(this).css("color", "#000").find("img").css("opacity", 1);

        // Show the map which corresponds to the selected country
        var sel = $(this).attr("href");
        $(sel).show();

        window.location.replace(window.location.pathname + sel.split("-")[0]);
        return false;
    });

    // Show the initial country on page load (either from the url hash or a default)
    var countryHash = window.location.hash || "#us";
    $("#country a[href^='" + countryHash + "']").trigger("click");
});
