
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

var kabe_sun = "pink";
var kabe_mon = "lightgrey";
var kabe_tue = "lightgrey";
var kabe_wed = "lightgrey";
var kabe_thu = "lightgrey";
var kabe_fri = "lightgrey";
var kabe_sat = "lightblue";
var firstAltMsg = "&nbsp";
var firstAltYMD = "&nbsp";

//行事テーブル(フラグ(1:祝日 2:記念日など),月,日,メッセージ)//
var gyouji_tbl = new Array(
1, 1, 1, "元旦",
1, 1, 0, "成人の日",
1, 2, 11, "建国記念の日",
1, 4, 29, "昭和の日",
1, 5, 3, "憲法記念日",
1, 5, 4, "国民の休日",
1, 5, 5, "こどもの日",
1, 7, 0, "海の日",
1, 9, 0, "敬老の日",
1, 10, 0, "体育の日",
1, 11, 3, "文化の日",
1, 11, 23, "勤労感謝の日",
1, 12, 23, "天皇誕生日",
2, 2, 11, "『ゴルフ体験会』開催日"//後ほど消す//
);
var kokuminLastCnt = gyouji_tbl.length / 4;
function carenda(num){
var now = new Date();
var year;
var month;
var date;
var dValue = document.getElementById("dValue");

switch(parseInt(num)){
case 0:
year = now.getFullYear();
month = now.getMonth()+1;
date = now.getDate();
break;
case 1:
var backMDate = new Date(parseInt(dValue.innerHTML) - 24*60*60*1000*1);
if(backMDate.getMonth() == now.getMonth() && backMDate.getFullYear() == now.getFullYear()){
year = now.getFullYear();
month = now.getMonth()+1;
date = now.getDate();
}else{
year = backMDate.getFullYear();
month = backMDate.getMonth() + 1;
date = -1;
}
break;
case 2:
var nextMDate = new Date(parseInt(dValue.innerHTML) + 24*60*60*1000*31);
if(nextMDate.getMonth() == now.getMonth() && nextMDate.getFullYear() == now.getFullYear()){
year = now.getFullYear();
month = now.getMonth()+1;
date = now.getDate();
}else{
year = nextMDate.getFullYear();
month = nextMDate.getMonth() + 1;
date = -1;
}
break;
}

dValue.innerHTML = (new Date(year, month-1, 1)).getTime();

var last_date = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var editMsg;
if(month==2){
if(year%4==0){
if((year%100==0) && (year%400!=0)){
}else{
last_date[1] = 29;
}
}
}

editMsg = "";
editMsg += "<TABLE border=0 cellspacing=3><TR><TD colspan='7' align='center'><B><U><FONT size='-1'>" + year + "年" + month + "月</FONT></B></U></TD></TR>\n";
editMsg += "<TR>" + defTD("日","red",kabe_sun) + defTD("月","black",kabe_mon) + defTD("火","black",kabe_tue) + defTD("水","black",kabe_wed) + defTD("木","black",kabe_thu) + defTD("金","black",kabe_fri) + defTD("土","blue",kabe_sat) + "</TR>\n";
editMsg += "<TR>";

for(dayIndex=0; dayIndex<(new Date(year,month-1,1)).getDay(); dayIndex++){
editMsg += defTD("&nbsp;","white","white");
}


//行事テーブル（祝日）の再設定
//成人の日
gyouji_tbl[1*4+2] = getSyukujituDate(year, 1, 2);
//海の日
gyouji_tbl[7*4+2] = getSyukujituDate(year, 7, 3);
//敬老の日
gyouji_tbl[8*4+2] = getSyukujituDate(year, 9, 3);
//体育の日
gyouji_tbl[9*4+2] = getSyukujituDate(year, 10, 2);
//みどりの日4/29→昭和の日 国民の休日5/4→みどりの日
if(year<=2006){
gyouji_tbl[3*4+3] = "みどりの日";
gyouji_tbl[5*4+3] = "国民の休日";
} else {
gyouji_tbl[3*4+3] = "昭和の日";
gyouji_tbl[5*4+3] = "みどりの日";
}

//当日と行事が重なる場合の初期設定
if(date != -1){
firstAltMsg = "&nbsp";
firstAltYMD = year + "/" + month + "/" + date;
for(var j=0; j<kokuminLastCnt; j++){
if(gyouji_tbl[j*4+1] == month && gyouji_tbl[j*4+2] == date){
firstAltMsg += gyouji_tbl[j*4+3] + "&nbsp";
}
}
}

for(i=1; i<=last_date[month-1]; i++){
if(i!=1 && dayIndex == 0){
editMsg += "<TR>";
}

var kabeColor;
var fontColor;
var altYMD = year + "/" + month + "/" + i;
var altMsg = "&nbsp";
//曜日別基本設定
switch(dayIndex){
case 0: fontColor = "red";
kabeColor = kabe_sun; break;
case 1: fontColor = "black";
kabeColor = kabe_mon; break;
case 2: fontColor = "black";
kabeColor = kabe_tue; break;
case 3: fontColor = "black";
kabeColor = kabe_wed; break;
case 4: fontColor = "black";
kabeColor = kabe_thu; break;
case 5: fontColor = "black";
kabeColor = kabe_fri; break;
case 6: fontColor = "blue";
kabeColor = kabe_sat; break;
}

//行事の時
for(var j=0; j<kokuminLastCnt; j++){
if(gyouji_tbl[j*4+1] == month && gyouji_tbl[j*4+2] == i){
fontColor = "#9900ff";//行事の文字色（カレンダー数字）
//祝日
if(gyouji_tbl[j*4] == 1){
fontColor = "red";
}else{
kabeColor = "lightgreen";
}
altMsg += gyouji_tbl[j*4+3] + "&nbsp";
}
}

//当日
if(i==date){
fontColor = "darkorange";
kabeColor =  "#ffff00";
}

editMsg += defTD2(i,fontColor,kabeColor,altYMD,altMsg);

if(dayIndex == 6){
editMsg += "</TR>\n";
}
dayIndex++; dayIndex%=7;
}
if(dayIndex!=7){
editMsg += "</TR>\n";
}
editMsg += "</TABLE>\n";

document.getElementById("carenda").innerHTML = editMsg;
}

function defTD(str, iro, kabe){
return "<TD style='cursor:default' align='center' bgcolor='" + kabe + "'><B><FONT size='-2' color='" + iro + "'>" + str + "</FONT></B></TD>";
}
function defTD2(str, iro, kabe, altYMD,altMsg){
return "<TD style='cursor:default' align='center' bgcolor='" + kabe + "' onMouseOver=setAltMsg('" + altYMD + "','" + altMsg + "') onMouseOut=setAltMsg('" + firstAltYMD + "','" + firstAltMsg + "')><B><FONT size='-2' color='" + iro + "'>" + str + "</FONT></B></TD>";
}
function setAltMsg(altYMD, altMsg){
var editAltMsg = "";
editAltMsg += "<FONT size = '3' ><strong>" + altYMD + "</strong></FONT>";//日付の文字設定（オンマウス表示文字）
editAltMsg += "<HR width='95%' size='1' color='#9900ff'>";//水平線（オンマウス表示文字部分の改行）
editAltMsg += "<FONT size = '3' color='#ff0066'><strong>" + altMsg + "</strong></FONT>";//メッセージの文字設定（オンマウス表示文字）
document.getElementById("altMsg").innerHTML = editAltMsg;
}
//祝日の日にち取得(年、月、第？週の月曜日)
function getSyukujituDate(year, month, syuu){
var syuuCnt = 0;
for(var i=1; i<=31; i++){
var date = (new Date(year, month-1, i)).getDay();
if((new Date(year, month-1, i)).getDay() == 1){
syuuCnt++;
}
if(syuuCnt == syuu){
return i;
}
}
}


