function DateList(limit)
{
	this.limit = limit;
	this.count = 0;
	this.years = new Object();
}

DateList.prototype.add = function(month, day, year)
{
	if(this.count < this.limit)
	{
		if(!this.years[year])
		{
			this.years[year] = new Object();
			this.years[year].months = new Object();
		}
		
		if(!this.years[year].months[month])
		{
			this.years[year].months[month] = new Object();
			this.years[year].months[month].days = new Object();
		}
		
		if(!this.years[year].months[month].days[day])
		{
			this.years[year].months[month].days[day] = new Object();
		}
		
		this.years[year].months[month].days[day].active = true;
		
		this.count++;
		return true;
	}
	else
	{
		alert("You may only select a maximum of "+ this.limit +" dates.");
		return false;
	}
}


DateList.prototype.remove = function(month, day, year)
{
	try{
		if(this.years[year].months[month].days[day].active)
		{
			// There was no exception and the day is active
			// so we can lower the count and deactivate the day.
			this.years[year].months[month].days[day].active = false;
			this.count--;
		}
	}
	catch(e)
	{
		
	}
}

DateList.prototype.isSet = function(month, day, year)
{
	try{
		return this.years[year].months[month].days[day].active;
	}
	catch(e)
	{
		return false;
	}
}

// Flush the list out into form fields.
DateList.prototype.forSelected = function(fn)
{
	for(var y in this.years)
	{
		for(var m in this.years[y].months)
		{
			for(var d in this.years[y].months[m].days)
			{
				if(this.years[y].months[m].days[d].active)
				{
					fn(m, d, y);
				}
			}
		}
	}
}