//2011.1.19カレンダー横型修正版（文字サイズの指定／cssに変更）
//2011.9.22 OPERAで2011年が111年と表示されるので、yearに直接2011を代入することに変更

function calender(){
	dat = new Date();
//	year = dat.getYear();
	year = 2012;			//2011年を入力
	month = dat.getMonth();		//月−1で示される
	date = dat.getDate();
//	if(navigator.userAgent.indexOf("Firefox")>-1){	Firefoxで年を補正する
//		year=year+1900;
//	}

	haikei="#6b8e23";		//背景色を指定する
	toujitubgcolor="#2b4e00";         //今日の背景色を指定する
	heijitu="#bbbbbb";		//平日色を指定する
	poinnto ="10px";			//表示文字サイズを指定する
	midasi_size ="11px";			//見出しの文字サイズを指定する
	midasisize6 ="10px";			//見出しの文字サイズを指定する

	b_niti="#aa0000";		//日曜日の文字色を指定する
	b_getu="#2b4e00";		//月〜金曜日の文字色を指定する
	b_doyo="#00bbbb";		//土曜日の文字色を指定する	
	b_siku="#ee0382";		//祝日の文字色を指定する

	//祝日の配列作成（1月から12月まで各月4個のデータで構成する　0は祝日なしを意味する）下記配列は2011年で毎年変更が必要
	siku_d = new Array(2,9,0,0,11,0,0,0,20,0,0,0,30,0,0,0,3,4,5,0,0,0,0,0,16,0,0,0,0,0,0,0,17,22,0,0,8,0,0,0,3,23,0,0,24,0,0,0);
	d=month*4;
	siku1=siku_d[d++]; siku2=siku_d[d++]; siku3=siku_d[d++]; siku4=siku_d[d];

	hajime = '<table style="border-width:0px;border-color:#88aa88;text-align:right;" cellspacing="0"><tbody>';
	tome = "</tr></tbody></table>";
					//月
	tuki = month + 1;
					//各月の日数
	nitisu = new Array(31,29,31,30,31,30,31,31,30,31,30,31);
	if (year % 4 == 0){
		nitisu[1] = 29;
	}
					//今月の日数（回数）
	kaisuu = nitisu[month];
					//今月の１日の曜日（０→日曜日　６→土曜日）
	dat.setDate(1);
	tuitati = dat.getDay();

	ha = new Array();
	for (i = 1; i <= kaisuu; i++){
		k=tuitati+i; k=k % 7;	
		if(i == siku1 || i == siku2 || i == siku3 || i == siku4){
		iro = '<td style="font-weight:bold;text-align:center;font:normal normal ' + poinnto + ' sans-serif;color:' + b_siku +  ';">' + i + '</td>';
		}
		else if(k == 1){
		iro = '<td style="font-weight:bold;text-align:center;font:normal normal ' + poinnto + ' sans-serif;color:' + b_niti +  ';">' + i + '</td>';
		}
		else if(k == 0){
		iro = '<td style="font-weight:bold;text-align:center;font:normal normal ' + poinnto + ' sans-serif;color:' + b_doyo +  ';">' + i + '</td>';
		}
		else{
		iro = '<td style="font-weight:bold;text-align:center;font:normal normal ' + poinnto + ' sans-serif;color:' + heijitu +  ';">' + i + '</td>';
		}
		ha[i] =iro;
	}
	k=tuitati+date; k=k % 7;
	if(date == siku1 || date == siku2 || date == siku3 || date == siku4){
	iro = '<td  style="font-weight:bold;text-align:center;background-color:' +toujitubgcolor+  ';font-weight:bold;font-size:' + poinnto + ';color:' + b_siku +  ';">' + date + '</td>';
	}
	else if(k == 1){
	iro = '<td  style="font-weight:bold;text-align:center;background-color:' +toujitubgcolor+  ';font-weight:bold;font-size:' + poinnto + ';color:' + b_niti +  ';">' + date + '</td>';
	}
	else if(k == 0){
	iro = '<td  style="font-weight:bold;text-align:center;background-color:' +toujitubgcolor+  ';font-weight:bold;font-size:' + poinnto + ';color:' + b_doyo +  ';">' + date + '</td>';
	}
	else {
	iro = '<td  style="font-weight:bold;text-align:center;background-color:' +toujitubgcolor+  ';font-weight:bold;font-size:' + poinnto + ';color:' + heijitu +  ';">' + date + '</td>';
	}
	ha[date] = iro;

	yobi = new Array(7);
	yobi[0]='<th style="font-weight:bold;font-size:'+poinnto+';color:'+b_niti+';">日</th>';
	yobi[1]='<th style="font-weight:bold;font-size:'+poinnto+';color:'+b_getu+';">月</th>';
	yobi[2]='<th style="font-weight:bold;font-size:'+poinnto+';color:'+b_getu+';">火</th>';
	yobi[3]='<th style="font-weight:bold;font-size:'+poinnto+';color:'+b_getu+';">水</th>';
	yobi[4]='<th style="font-weight:bold;font-size:'+poinnto+';color:'+b_getu+';">木</th>';
	yobi[5]='<th style="font-size:'+poinnto+';color:'+b_getu+';">金</th>';
	yobi[6]='<th style="font-weight:bold;font-size:'+poinnto+';color:'+b_doyo+';">土</th>';

	mae = '<td align="center">';


	yobihairetu=yobi[tuitati];

	for (i=2,k=tuitati;i<=kaisuu;i++){
	k=k+1;
	k = k % 7;
	yobihairetu = yobihairetu + yobi[k];
	}
	hyouji1=hajime+"<tr><th style='font-weight:bold;text-align:center;font-size:"+poinnto+"';color:"+heijitu+";>calender</th>";
	hyouji1=hyouji1+yobihairetu+"</tr>";

	if(navigator.userAgent.indexOf("MSIE")>-1){				//Internet Explorer	
		if(navigator.userAgent.indexOf("MSIE 6.0")>-1){			//Internet Explorer ver6
			hyouji2="<tr><td style='font-weight:bold;text-align:center;background-color:#2b4e00;font-size:'+midasisize6+';color:#bbbbbb;>"+year+"年　"+tuki+"月</td>";
		}else{
			hyouji2="<tr><td style='font-weight:bold;text-align:center;background-color:#2b4e00;font-size:'+midasi_size+';color:#bbbbbb;>"+year+"年　"+tuki+"月</td>";
		}
	} else {
		hyouji2="<tr><td style='font-weight:bold;text-align:center;background-color:#2b4e00;font-size:'+midasi_size+';color:#bbbbbb;>"+year+"年　"+tuki+"月</td>";
	}

	for (i = 1; i <= kaisuu; i++){
		hyouji2 = hyouji2 + ha[i];
	}
	hyouji2=hyouji2+tome;

	document.write(hyouji1);
	document.write(hyouji2);
}
