function setCalendarStyle() {
	cText1 = '日';			// ヘッダー行１列目のテキスト
	cText2 = '曜日';		// ヘッダー行２列目のテキスト
	cText3 = 'イベント';	// ヘッダー行３列目のテキスト
	cTextbox = 'kosodatecalbox';	// カレンダーブロックのスタイル名
	cHeight = 600;			// 改ページする単位(px)
	
	nIdx = -1;
	nFlag = 0;
	// ヘッダー行と一致する<TR>タグを検索する
	oEl = document.getElementsByTagName('div');
	nTRs = oEl.length;
	for (i=0; i<nTRs; i++) {
	  if ( oEl[i].className == cTextbox) {
	    oTRe = oEl[i].getElementsByTagName('tr');
	    nFlag = 1;
	    break;
	  }
	}
	// カレンダーブロックなし
	if (nFlag == 0) {
		return;
	}
	nTRs = oTRe.length;
	if (typeof oTRe[0].textContent != "undefined") {
		// textContent(非IE)
		for (i=0; i<nTRs; i++) {
			oTDe = oTRe[i].getElementsByTagName('td');
			if ((oTDe[0].textContent == cText1) && (oTDe[1].textContent == cText2) && (oTDe[2].textContent == cText3)) {
				nIdx = i;
				break;
			}
		}
	} else {
		// innerText(IE)
		for (i=0; i<nTRs; i++) {
			oTDe = oTRe[i].getElementsByTagName('td');

			if ((oTDe[0].innerText == cText1) && (oTDe[1].innerText == cText2) && (oTDe[2].innerText == cText3)) {
				nIdx = i;
				break;
			}
		}
	}
	// ヘッダー行が見つかった場合
	if (nIdx >= 0) {
		oTBody = oTRe[i].parentNode;
		oTable = oTBody.parentNode;
		// <THEAD>タグを準備
		oTHead = oTable.tHead;
		if (oTHead == null) {
			oTable.createTHead();
			oTHead = oTable.tHead;
		}
		// <THEAD>タグにDISPLAYスタイルを設定
		oTHead.style.display = 'table-header-group';
		
		// 検索したヘッダー行までを<TBODY>から<THEAD>へ移動する
		for (i=0; i<=nIdx; i++) {
			var oTR = oTRe[i].cloneNode(true);
			oTBody.deleteRow(0);
			oTHead.appendChild(oTR);
		}
		// ヘッダー行までの高さを計算する
		nTHeadHeigh = 0;
		for (i=0; i<=nIdx; i++) {
			nTHeadHeigh += parseFloat(oTRe[i].style.height);
		}
		// ヘッダー行以降を計算して超過したら改ページを挿入する
		nPHeight = nTHeadHeigh;
		for (; i<nTRs; i++) {
			nPHeight += parseFloat(oTRe[i].style.height);
			if (nPHeight > cHeight) {
				oTRe[i].style.pageBreakBefore = 'always';
				nPHeight = nTHeadHeigh;
			}
		}
	}
}
// ページonLoad時に呼び出されます。
// ※ <BODY onload=> が存在する場合、上書きされるので対処が必要
window.onload = function() {
	setCalendarStyle();
}
