//  カレンダー表示
function setCalendar(action, year, month, day) {
    //  引数初期値
    switch (arguments.length) {
        case 0: action = "index";
        case 1: year = "";
        case 2: month = "";
        case 3: day = "";
    }

    //  カレンダーをセットする対象
    calendar = "#cal";

    $.ajax({
        type: "POST",
        url: "calendar/" + action,
        data: "YEAR=" + year + "&MONTH=" + month + "&DAY=" + day,
        success: function(res) {
            $(calendar).html(res);
        },
        error: function() {
            $(calendar).text("カレンダーを読み込めませんでした。");
            $(calendar).css({ color:"#ff0000", fontWeight:"bold" });
        }
    });
}

//  日付セット
function setDate(action) {
    setCalendar(action, $("#YEAR").val(), $("#MONTH").val());
}

