﻿var Step1 = {
    getToStops: function(fromStopId) {
        StopSelectorWSProxy.getToStops(fromStopId, "StopSelectorToStops.xslt", function(data) {
            $("#toStopsContainer").html(data);
        });
    }
}

$(document).ready(function() {
    $("#fromStopId").change(function() {
        Step1.getToStops($(this).val());
    });

    if ($("#toStopId").val() == 0) {
        $("#fromStopId").val(0);
    }

    // Enkelresa
    $("#tripMode1").click(function() {
        $("#returnTripDateLabel").hide();
        $("#returnTripDate").hide();
    });

    // Tur/retur
    $("#tripMode2").click(function() {
        $("#returnTripDate select").each(function() {
            $(this).removeAttr("disabled");
        });

        $("#returnTripDateLabel").show();
        $("#returnTripDate").show();
    });

    // Dagstur
    $("#tripMode3").click(function() {
        $("#returnTripDate select").each(function() {
            $("#returnTripDateLabel").show();
            $("#returnTripDate").show();
            $(this).attr("disabled", "disabled");
            $("#returnYear").val($("#departureYear").val());
            $("#returnMonth").val($("#departureMonth").val());
            $("#returnDay").val($("#departureDay").val());
        });
    });
});
