function EventCalendar() {
}
EventCalendar.prototype.init = function(current, max) {
	if(current < 0) {
		this.current = 1;
	} else {
		this.current = current;
		$(".m" + this.current).addClass("current");
	}
	if(this.current == 1) {
		this.l_gray();
	}
	this.max = max;
	this.x = this.current;
	this.refresh();
	$("#calendar_shell").show(250);
}
EventCalendar.prototype.this_month = function() {
	this.x = this.current;
	this.refresh();
	if(this.x == 1) {
		this.l_gray();
	}
	else {
		this.l_gray_off();
	}
	this.r_gray_off();
}
EventCalendar.prototype.prev = function() {
	if(this.x > 1) {
		if(this.x == this.max - 2) {
			this.r_gray_off();
		}
		this.x -= 1;
		this.refresh();
		if(this.x == 1) {
			this.l_gray();
		}
	}
}
EventCalendar.prototype.next = function() {
	if(this.x <= this.max-3) {
		if(this.x == 1) {
			this.l_gray_off();
		}
		this.x += 1;
		this.refresh();
		if(this.x == this.max - 2) {
			this.r_gray();
		}
	}
}
EventCalendar.prototype.refresh = function() {
	for(i = 1; i <= this.max; i++) {
		$(".m" + i).hide();
	}
	for(i = this.x; i < this.x + 3; i++) {
		$(".m" + i).show();
	}
}
EventCalendar.prototype.mouse_on = function(obj) {
	obj.firstChild.src = obj.firstChild.src.replace('.gif', '_over.gif');
}
EventCalendar.prototype.mouse_out = function(obj) {
	obj.firstChild.src = obj.firstChild.src.replace('_over.gif', '.gif');
}
EventCalendar.prototype.l_gray = function() {
	$(".ctl_l").html('<button class="button_gray" disabled="true"><img src="/parts/btn_schedule_prev_gray.gif" width="22" height="20" alt="前の月" /></button>');
}
EventCalendar.prototype.l_gray_off = function() {
	$(".ctl_l").html('<button class="button" onClick="ec.prev();" onmouseover="ec.mouse_on(this);" onmouseout="ec.mouse_out(this);"><img src="/parts/btn_schedule_prev.gif" width="22" height="20" alt="前の月" /></button>');
}
EventCalendar.prototype.r_gray = function() {
	$(".ctl_r").html('<button class="button_gray" disabled="true"><img src="/parts/btn_schedule_next_gray.gif" width="22" height="20" alt="前の月" /></button>');
}
EventCalendar.prototype.r_gray_off = function() {
	$(".ctl_r").html('<button class="button" onClick="ec.next();" onmouseover="ec.mouse_on(this);" onmouseout="ec.mouse_out(this);"><img src="/parts/btn_schedule_next.gif" width="22" height="20" alt="前の月" /></button>');
}

var ec = new EventCalendar();
