﻿/* Begin Japanese 2up Calendar */

YAHOO.widget.Calendar2up_JP_Cal = function(id, containerId, monthyear, selected) {
	if (arguments.length > 0)
	{
		this.init(id, containerId, monthyear, selected);
	}
}

YAHOO.widget.Calendar2up_JP_Cal.prototype = new YAHOO.widget.Calendar2up_Cal();

YAHOO.widget.Calendar2up_JP_Cal.prototype.customConfig = function() {
	this.Config.Locale.MONTHS_SHORT = ["1\u6708", "2\u6708", "3\u6708", "4\u6708", "5\u6708", "6\u6708", "7\u6708", "8\u6708", "9\u6708", "10\u6708", "11\u6708", "12\u6708"];
	this.Config.Locale.MONTHS_LONG = ["1\u6708", "2\u6708", "3\u6708", "4\u6708", "5\u6708", "6\u6708", "7\u6708", "8\u6708", "9\u6708", "10\u6708", "11\u6708", "12\u6708"];
	this.Config.Locale.WEEKDAYS_1CHAR = ["\u65E5", "\u6708", "\u706B", "\u6C34", "\u6728", "\u91D1", "\u571F"];
	this.Config.Locale.WEEKDAYS_SHORT = ["\u65E5", "\u6708", "\u706B", "\u6C34", "\u6728", "\u91D1", "\u571F"];
	this.Config.Locale.WEEKDAYS_MEDIUM = ["\u65E5", "\u6708", "\u706B", "\u6C34", "\u6728", "\u91D1", "\u571F"];
	this.Config.Locale.WEEKDAYS_LONG = ["\u65E5", "\u6708", "\u706B", "\u6C34", "\u6728", "\u91D1", "\u571F"];

	this.Config.Options.START_WEEKDAY = 0;
}
/**********************************/

YAHOO.widget.Calendar2up_JP = function(id, containerId, monthyear, selected) {
	if (arguments.length > 0)
	{	
		this.buildWrapper(containerId);
		this.init(2, id, containerId, monthyear, selected);
	}
}

YAHOO.widget.Calendar2up_JP.prototype = new YAHOO.widget.Calendar2up();

YAHOO.widget.Calendar2up_JP.prototype.constructChild = function(id,containerId,monthyear,selected) {
	var cal = new YAHOO.widget.Calendar2up_JP_Cal(id,containerId,monthyear,selected);
	return cal;
};

/* End Japanese 2up Calendar */

YAHOO.namespace("jegog_calendar");

var today,link1,container1,year_box,month_box,day_box;

function initJapan() {
	today = new Date();

	var thisMonth = today.getMonth();
	var thisDay = today.getDate();
	var thisYear = today.getFullYear();

	container1 = document.getElementById('container1');
	year_box = document.getElementById('yearbox1');
	month_box = document.getElementById('monthbox1');
	day_box = document.getElementById('daybox1');
	link1 = document.getElementById('dateLink1');

	YAHOO.jegog_calendar.cal = new YAHOO.widget.Calendar2up_JP("jegog_calendar","container1",(thisMonth+1)+"/"+thisYear,(thisMonth+1)+"/"+thisDay+"/"+thisYear);
	YAHOO.jegog_calendar.cal.setChildFunction("onSelect",setDate1);
	YAHOO.jegog_calendar.cal.title = "\u65e5\u4ed8\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\u3002";
	

	var renderSunday = function(cal,cell) {
		YAHOO.util.Dom.addClass(cell, "sunday");
	}

	var renderSaturday = function(cal,cell) {
		YAHOO.util.Dom.addClass(cell, "saturday");
	}

	YAHOO.jegog_calendar.cal.addWeekdayRenderer(1, renderSunday);
	YAHOO.jegog_calendar.cal.addWeekdayRenderer(7, renderSaturday);

	YAHOO.jegog_calendar.cal.render();
}

function showCalendar1(date_box_id) {
	
	var _link = document.getElementById('dateLink' + date_box_id);

	var pos = YAHOO.util.Dom.getXY(_link);
	YAHOO.jegog_calendar.cal.outerContainer.style.display='block';

	year_box = document.getElementById("yearbox" + date_box_id);
	month_box = document.getElementById("monthbox" + date_box_id);
	day_box = document.getElementById("daybox" + date_box_id);
	YAHOO.util.Dom.setXY(YAHOO.jegog_calendar.cal.outerContainer, [pos[0],pos[1]+_link.offsetHeight+1]);
//	container1 = document.getElementById("container" + date_box_id);

}

function setDate1() {
	var date1 = YAHOO.jegog_calendar.cal.getSelectedDates()[0];
	year_box.value = date1.getFullYear();
	month_box.value = date1.getMonth() + 1;
	day_box.value = date1.getDate();
	YAHOO.jegog_calendar.cal.hide();
}

function padZero(par) {
	if (1 <= par && par <= 9) {
		return "0" + par;
	} else {
		return par;
	}
}

YAHOO.util.Event.addListener(window, "load", initJapan);

