// *******************************************************************
// カレンダー表示

// 初期設定
function calInit() {
	sendRequest();
}
// 日付クリック
function dayClick(year, mon, day) {
	/*
	var tdId = "d" + year.toString() + mon.toString() + day.toString();
	var obj = document.getElementById(tdId).getElementsByTagName('a')[0];
	var check_style = obj.currentStyle;
	if(check_style.backgroundColor == "#ebf2cb") {
		obj.style.backgroundColor = "#47885e";
		obj.style.color = "#fff";
	} else {
		obj.style.backgroundColor = "#ebf2cb";
		obj.style.color = "#1e50a2";
	}
	*/
	var date = year + "-" + mon + "-" + day;
	sendRequest(date);
}
// 月送りクリック
function calchg(date, year, mon) {
	sendRequest(date, year, mon);
}

// -----------------------------------------------------------------------------------
// 非同期通信
function sendRequest(date, year, mon) {
	var xmlhttp;
	try{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				processRequest(xmlhttp);
			}
		}
	} catch(e) {
		xmlhttp = new XMLHttpRequest();
		xmlhttp.onload = function() {
			processRequest(xmlhttp);
		}
	}
	xmlhttp.open("POST", "index_calendar.php");
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	if(date) {
		xmlhttp.send("date=" + date);
	} else if(year && mon) {
		xmlhttp.send("year=" + year + "&mon=" + mon);
	} else {
		xmlhttp.send();
	}
}
function processRequest(xmlhttp) {
	document.getElementById("calendar").innerHTML = xmlhttp.responseText;
}



// *******************************************************************
// エリア選択
function selectArea(areaID) {
	var checkObj = document.forms[0].elements["area" + areaID];
	if(checkObj.checked) {
		checkObj.checked = false;
	} else {
		checkObj.checked = true;
	}
}





