function PriceCalendar()
{
}
PriceCalendar.current = null;

PriceCalendar.setup = function ()
{
	PriceCalendar.current = new PriceCalendar();
	PriceCalendar.current.initialize();
}

PriceCalendar.cleanup = function ()
{
	if (PriceCalendar.current != null)
		PriceCalendar.current.cleanup();
}

PriceCalendar.prototype.initialize = function ()
{
	var calendar = document.getElementById("price_calendar");
	if (calendar != null)
	{
		var periods = dom.getElementsByClassName(calendar, "period", "div");
		for (var i = 0; i < periods.length; i++)
		{
			evt.addHandler(periods[i], "onmouseover", PriceCalendar.period_onmouseover);
			evt.addHandler(periods[i], "onmouseout", PriceCalendar.period_onmouseout);
			evt.addHandler(periods[i], "onmouseup", PriceCalendar.period_onmouseup);
		}
	}
}

PriceCalendar.prototype.cleanup = function ()
{
}

PriceCalendar.period_onmouseover = function ()
{
	var periodID = this.getAttribute("periodID");
	var calendar = document.getElementById("price_calendar");
	var periods = dom.getElementsByClassName(calendar, "period", "div");
	var related = [];
	for (var i = 0; i < periods.length; i++)
	{
		if (periods[i].getAttribute("periodID") == periodID)
			related.push(periods[i]);
	}
	for (var i = 0; i < related.length; i++)
		css.addClassName(related[i], "mouseover");
}

PriceCalendar.period_onmouseout = function ()
{
	var periodID = this.getAttribute("periodID");
	var calendar = document.getElementById("price_calendar");
	var periods = dom.getElementsByClassName(calendar, "period", "div");
	var related = [];
	for (var i = 0; i < periods.length; i++)
	{
		if (periods[i].getAttribute("periodID") == periodID)
			related.push(periods[i]);
	}
	for (var i = 0; i < related.length; i++)
		css.removeClassName(related[i], "mouseover");
}

PriceCalendar.period_onmouseup = function ()
{
	var href = this.getAttribute("href");
	var current = css.containsClassName(this, "current");
	if (href && !current)
		document.location = ui.expandHref(href);
}

evt.addHandler(window, "onready", PriceCalendar.setup);
evt.addHandler(window, "onunload", PriceCalendar.cleanup);

