function ReservationsForm()
{
    this.form = new Form(this.getIds());
}

ReservationsForm.prototype.submitForm = function()
{
    if (this.isAValidForm())
    {
        document.getElementById('source').value = 'Reservations';
        return true;
    }
    else
    {
        return false;
    }
}

ReservationsForm.prototype.isAValidForm = function()
{
    var isValid = this.form.isAValidForm();
    
    if (!this.isAValidDate())
    {
        this.form.showRequiredFieldHint('arrival_day');
        isValid = false;
    }
    
    return isValid;
}

ReservationsForm.prototype.getIds = function()
{
    return new Array('first_name', 'last_name', 'email', 'confirm_email', 'arrival_day');
}

ReservationsForm.prototype.isAValidDate = function()
{
    var currentMonth = new Date().getMonth();
    
    if (currentMonth > 3 && currentMonth < 10)
    {
        var months = new Array('May', 'June', 'July', 'August', 'September', 'October');
        currentMonth = months[currentMonth - 4];
        
        if (currentMonth == document.getElementById('arrival_month').value)
        {
            return new Date().getDate() < document.getElementById('arrival_day').value;
        }
    }
    
    return true;
}

ReservationsForm.prototype.setDaysInArrivalMonth = function()
{
    switch (document.getElementById('arrival_month').value)
    {
        case 'May':
            this.addSelectListOptions(31);
            break;
        case 'June':
            this.addSelectListOptions(30);
            break;
        case 'July':
            this.addSelectListOptions(31);
            break;
        case 'August':
            this.addSelectListOptions(31);
            break;
        case 'September':
            this.addSelectListOptions(30);
            break;
        case 'October':
            this.addSelectListOptions(31);
            break;
    }
}

ReservationsForm.prototype.addSelectListOptions = function(i)
{
    var parent = document.getElementById('arrival_day').parentNode;
    parent.removeChild(document.getElementById('arrival_day'));
    var selectList = document.createElement('select');
    selectList.setAttribute('id', 'arrival_day');
    selectList.setAttribute('name', 'arrival_day');
    parent.appendChild(selectList);
    
    for (var j = 1; j <= i; j++)
    {
        var option = document.createElement('option');
        option.setAttribute('value', j);
        option.appendChild(document.createTextNode(j));
        selectList.appendChild(option);
    }
}