/*
 *
 */

/*
 *
 */
function SingleDate(date, time)
{
    this.date = date;
    this.time = time;
    
    this.remaining = SingleDate_remaining;
    this.getDate = SingleDate_getDate;
}

/*
 *
 */
function SingleDate_remaining()
{
    var now = new Date();
    var year = now.getFullYear();
    
    var later = this.getDate(year);
    if (now > later)
    {
        later = this.getDate(year + 1);
    }

	return later.getTime() - now.getTime();
}

/*
 *
 */
function SingleDate_getDate(year)
{
    var time = (this.time != null) ? this.time : "00:00:00";
    return new Date(this.date + ", " + year + " " + time);
}

/*
 *
 */
function MultipleDate(dates, times)
{
    this.dates = dates;
    this.times = times;

    this.crt = 0;
    
    this.remaining = MultipleDate_remaining;
    this.getDate = MultipleDate_getDate;
    this.getCurrent = MultipleDate_getCurrent;
}

/*
 *
 */
function MultipleDate_remaining()
{
    var now = new Date();
    var year = now.getFullYear();

    var later = this.getDate(year);
    while (now > later)
    {
        this.crt = ++this.crt % this.dates.length;
        later = (this.crt != 0) ? this.getDate(year) : this.getDate(year + 1);
    }
    
    return later.getTime() - now.getTime();
}

/*
 *
 */
function MultipleDate_getDate(year)
{
    var time = (this.times != null) ? this.times[this.crt] : "00:00:00";
    return new Date(this.dates[this.crt] + ", " + year + " " + time);
}

/*
 *
 */
function MultipleDate_getCurrent()
{
    return this.crt;
}
