$(document).ready(function () {
    setExposureTransitionDistanceVisibility();
    $("#exposure_category").change(setExposureTransitionDistanceVisibility);

    $(".icon-info-circled").click(showTooltip);
});

function setExposureTransitionDistanceVisibility() {
    exposureCategory = $("#exposure_category").val();
    if ($.inArray(exposureCategory, ["B to C", "C to B"]) != -1) {
        $("#exposure_category_transition_distance_row").show();
    } else {
        $("#exposure_category_transition_distance_row").hide();
    }
}

function showTooltip(event) {
    $(this).parent().find('.tooltip').removeClass('hidden');
    $('body').click(hideTooltip);
    event.stopPropagation();
}

function hideTooltip() {
    $('.tooltip').addClass('hidden');
    $(this).unbind();
}
