// JavaScript Document

// カレンダー自動表示スクリプト
// 日付を取得
dd = new Date();

// 年・月・日を取得
year = dd.getYear();
month = dd.getMonth() + 1;
date = dd.getDate();

// 年を表示用の変数に格納
if (year < 2000) {
	year = year + 1900;
}

// 年をまたぐ場合の表示用
// 2009.8.7　4ヶ月対応
if (month == 10) {
	year_next = year;
	year_next2 = year;
	year_next3 = year + 1;
}else{
	if (month == 11) {
		year_next = year;
		year_next2 = year + 1;
		year_next3 = year + 1;
	}else{
		if (month == 12) {
			year_next = year + 1;
			year_next2 = year + 1;
			year_next3 = year + 1;
		}else{
			year_next = year;
			year_next2 = year;
			year_next3 = year;
		}
	}
}

// 月を表示用の変数に格納
if (month == 12) {
	month_next = 1;
}else{
	month_next = month + 1;
}

if (month_next == 12) {
	month_next2 = 1;
}else{
	month_next2 = month_next + 1;
}

if (month_next2 == 12) {
	month_next3 = 1;
}else{
	month_next3 = month_next2 + 1;
}


// 年月を表示用の２桁に変換、格納
year_month_disp = String(year) + "年" + String(month) + "月";
year_month_disp_next = String(year_next) + "年" + String(month_next) + "月";
year_month_disp_next2 = String(year_next2) + "年" + String(month_next2) + "月";
year_month_disp_next3 = String(year_next3) + "年" + String(month_next3) + "月";

if (month < 10) {
	month_disp = "0" + month;
} else {
	month_disp = month;
}

if (month_next < 10) {
	month_next_disp = "0" + month_next;
} else {
	month_next_disp = month_next;
}

if (month_next2 < 10) {
	month_next2_disp = "0" + month_next2;
} else {
	month_next2_disp = month_next2;
}

if (month_next3 < 10) {
	month_next3_disp = "0" + month_next3;
} else {
	month_next3_disp = month_next3;
}

// 年月を処理用の２桁に変換、格納
year_month_value = String(year) + String(month_disp);
year_month_value_next = String(year_next) + String(month_next_disp);
year_month_value_next2 = String(year_next2) + String(month_next2_disp);
year_month_value_next3 = String(year_next3) + String(month_next3_disp);

select_k_ym = '<select class="simpleBox m_year" name="' + 'k_ym' + '">';
select_k_ym += '<option value="' + year_month_value + '" selected>' + year_month_disp;
select_k_ym += '\n<\/option>\n';
select_k_ym += '<option value="' + year_month_value_next + '" >' + year_month_disp_next;
select_k_ym += '\n<\/option>\n';
select_k_ym += '<option value="' + year_month_value_next2 + '" >' + year_month_disp_next2;
select_k_ym += '\n<\/option>\n';
select_k_ym += '<option value="' + year_month_value_next3 + '" >' + year_month_disp_next3;
select_k_ym += '\n<\/option>\n';
select_k_ym += '\n<\/select>\n';

if (month < 10) {
	month_disp = "0" + month;
}

// 日を処理用の２桁に変換、格納
select_k_d = '<select class="simpleBox s_day" name="' + 'k_d' + '">';
for(i = 1; i < 32; i++ )
{
	if(i == date){
		select_k_d += '<option value="' + i + '" selected>' + i +'日';
	}else{
		select_k_d += '<option value="' + i + '">' + i +'日';
	}
}
select_k_d += '\n<\/select>\n';
	this.document.write(select_k_ym);
	this.document.write(select_k_d);
