function Calendar(calendarSelector, activeDate) {
    var namesOfMonths = ['ЯНВАРЬ', 'ФЕВРАЛЬ', 'МАРТ', 'АПРЕЛЬ', 'МАЙ', 'ИЮНЬ', 'ИЮЛЬ', 'АВГУСТ', 'СЕНТЯБРЬ', 'ОКТЯБРЬ', 'НОЯБРЬ', 'ДЕКАБРЬ'];

    if (undefined === activeDate) {
        var today = new Date();
    } else {
        var today = new Date(activeDate);
    }

    var nowDate  = today.getDate();
    var nowMonth = today.getMonth();
    var nowYear  = today.getFullYear();

    /*if ($.browser.mozilla) {
        nowYear += 1900;
    }*/

    var currentMonth = nowMonth;
    var currentYear  = nowYear;

    this.urlPrefix = '';

    /**
     * @access private
     */
    function zeroNumberFormat(number) {
        return (number < 10) ? '0' + number : number;
    }

    var parentClass = this;

    /**
     * @access public
     */
    this.redraw = function() {
        $(calendarSelector + ' tr').not('.header').not('.days').remove();
        $(calendarSelector + ' .month_year').html(namesOfMonths[currentMonth] + ' ' + currentYear);

        var startDate = new Date(currentYear, currentMonth, 1);
        var endDate   = new Date(currentYear, currentMonth + 1, 1);

        // Last day of the month
        endDate = new Date (endDate - (24*60*60*1000));

        // Days in this month
        var numDaysInMonth = endDate.getDate();

        // The month starts from this day of week
        var startAt = startDate.getDay();

        // 7 - Russian Sunday
        if (startAt === 0) {
            startAt = 7;
        }

        var outputDay;

        var sResult = '<tr>';

        var i = 0;

        do {
            // Day number for cell
            outputDay = i + 2 - startAt;

            // Don't show day in cells placed left and right from month
            if ((outputDay < 1) || (outputDay > numDaysInMonth)) {
                sResult = sResult + '<td>&nbsp;</td>';
            } else {
                if ((nowYear == currentYear) && (nowMonth == currentMonth) && (nowDate == outputDay)) {
                    sResult = sResult + '<td class="selected">' + outputDay + '</td>';
                } else {
                    sResult = sResult + '<td><a href="' + parentClass.urlPrefix + currentYear + zeroNumberFormat(currentMonth + 1) + zeroNumberFormat(outputDay) + '/">'+ outputDay +'</a></td>';
                }
            }

            i++;

            // Reason to break (is Sunday and all days have displayed)
            if ((i % 7 === 0) && (outputDay >= numDaysInMonth)) {
                break;
            }

            // Next week
            if (i % 7 === 0) {
                sResult += '</tr><tr>';
            }
        } while (true);

        sResult += '</tr>';

        $(calendarSelector + ' tbody').append(sResult);
    }

    /**
     * @access public
     */
    this.showNextMonth = function() {
        currentMonth++;

        if (currentMonth > 11) {
            currentMonth = 0;
            currentYear++;
        }

        this.redraw();
    };

    /**
     * @access public
     */
    this.showPrevMonth = function() {
        currentMonth--;

        if (currentMonth < 0) {
            currentMonth = 11;
            currentYear--;
        }

        this.redraw();
    };
}
