/*******************************************************************/
/* 【一般向け】イベント・行事予定表表示                                   */
/* @author  Tsukamoto Yasuyoshi <tsukamoto@bmc.net-bibai.co.jp>    */
/* @create  2009/07/07                                             */
/* @version 1.0                                                    */
/*******************************************************************/
function prevnextsub(year){
		document.getElementById('inpcurrentyear').value = year;
		document.getElementById('prevnext').submit();
}

function selectMonth(month){
        var t;
        var p;
        for(var i=1; i<13; i++){
            t = 'm' + i + 't';
            document.getElementById(t).style.backgroundColor = 'blue';
            document.getElementById(t).style.border = "1px solid #bbbbbb";
            p = 'm' + i + 'p';
            document.getElementById(p).style.cursor = 'pointer';
            document.getElementById(p).style.color = '#ffffff';
            
        }
        t = 'm' + month + 't';
        p = 'm' + month + 'p';
        document.getElementById(t).style.backgroundColor = '#eeffee';
        document.getElementById(t).style.borderBottom = 'none';
        document.getElementById(p).style.cursor = 'default';
        document.getElementById(p).style.color = '#000000';
        
        /* スケジュールの読み込み */
        var loadyear;
        var loadmonth;
        loadyear = document.getElementById('loadyear').value;   /* 年 */
        loadmonth = month;  /* 月 */
        if( loadmonth >= 4) {
        } else {
            loadyear = ( loadyear - 0) + 1;
        }
        
        var url = './scheduleAjax.php';
        var postparam = "loadyear=" + loadyear + "&loadmonth=" + loadmonth;
        var myAjax = new Ajax.Request(
                        url,
                        {
                            method: 'post',
                            postBody: postparam,
                            onSuccess: scheduleAjaxSuccess,
                            onFailure: scheduleAjaxFailure
                        }
        );
}

function scheduleAjaxSuccess(httpObj){
	document.getElementById('monthschedule').innerHTML = httpObj.responseText;
}

function scheduleAjaxFailure(httpObj){
	document.getElementById('monthschedule').innerHTML = "<h3>■スケジュールを取得できません。</h3>";
}

window.onload = function(){
    selectMonth(document.getElementById('onloadmonth').value);
}