 function EKFadeAnim(oElement, oRelated) {
    this.opacity = 0;
    this.interval = 10;
    this.increment = 25;
    this.elementStyle = oElement.style;
    if (oRelated) {
        this.relatedStyle = oRelated.style;
    }
    this.timer = null;
}
EKFadeAnim.prototype.setOpacity = function (oStyle, value) {
    if (value == 0) {
        oStyle.visibility = "hidden";
    } else {
        oStyle.visibility = "visible";
    }
    oStyle.opacity = (value / 100);
    oStyle.MozOpacity = (value / 100);
    oStyle.KhtmlOpacity = (value / 100);
    oStyle.filter = "alpha(opacity=" + value + ")";
};
EKFadeAnim.prototype.stop = function () {
    if (this.opacity > 0) {
        this.setOpacity(this.elementStyle, 100);
        if (this.relatedStyle) {
            this.setOpacity(this.relatedStyle, 100);
        }
    }
};
EKFadeAnim.prototype.fadeIn = function () {
    if (this.timer == null) {
        this.opacity = 0;
        var oThis = this;
        this.timer = window.setInterval(function () {
            oThis.fadeInTimer();
        }, this.interval);
    }
};
EKFadeAnim.prototype.fadeInTimer = function () {
    if (this.opacity < 100) {
        this.opacity = this.opacity + this.increment;
        this.setOpacity(this.elementStyle, this.opacity);
        if (this.relatedStyle) {
            this.setOpacity(this.relatedStyle, this.opacity);
        }
    } else {
        window.clearInterval(this.timer);
        this.timer = null;
    }
};
EKFadeAnim.prototype.fadeOut = function () {
    if (this.timer == null) {
        this.opacity = 100;
        var oThis = this;
        this.timer = window.setInterval(function () {
            oThis.fadeOutTimer();
        }, this.interval);
    }
};
EKFadeAnim.prototype.fadeOutTimer = function () {
    if (this.opacity > 0) {
        this.opacity = this.opacity - this.increment;
        this.setOpacity(this.elementStyle, this.opacity);
        if (this.relatedStyle) {
            this.setOpacity(this.relatedStyle, this.opacity);
        }
    } else {
        window.clearInterval(this.timer);
        this.timer = null;
    }
};

function EKCalendar() {
    this.Config = function () {};
    this.Config.imagePath = "/System/Images/calendar/";
    this.Config.calendarImages = ["left.gif", "right.gif", "close.gif", "left_off.gif", "right_off.gif"];
    this.Config.maxScreen = 960;
    this.Config.txtClose = "Close";
    this.Config.txtPrevMonth = "Previous month";
    this.Config.txtNextMonth = "Next month";
    this.Config.txtLegend = "Selected Departure Date";
    this.Config.monthLong = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
    this.Config.monthShort = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
    this.Config.dayShort = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
    this.Config.firstDay = 0;
    this.Config.monthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    this.Config.dateFormat = "dd-MMM-yy";
    this.Config.dateFormatTitle = "MMMM, yyyy";
    this.Config.templateHTML = "";
}
EKCalendar.prototype.stringFill = function (c, n) {
    var s = "";
    for (;;) {
        if (n & 1) {
            s += c;
        }
        n >>= 1;
        if (n) {
            c += c;
        } else {
            break;
        }
    }
    return s;
};
EKCalendar.prototype.padLeft = function (val, ch, num) {
    var data = val + "";
    while (data.length < num) {
        data = ch + data;
    }
    return data;
};
EKCalendar.prototype.isNumeric = function (sText) {
    var validChars, isNumber, ch, i, length;
    validChars = "0123456789";
    isNumber = true;
    for (i = 0, length = sText.length; i < length && isNumber == true; i++) {
        ch = sText.charAt(i);
        if (validChars.indexOf(ch) == -1) {
            isNumber = false;
        }
    }
    return isNumber;
};
EKCalendar.prototype.findPos = function (element) {
    var coordinates = function () {};
    coordinates.x = 0;
    coordinates.y = 0;
    while (element.offsetParent) {
        coordinates.x += element.offsetLeft;
        coordinates.y += element.offsetTop;
        element = element.offsetParent;
    }
    return coordinates;
};
EKCalendar.prototype.getWindowSize = function () {
    var size = function () {};
    size.width = 0;
    size.height = 0;
    if (typeof(window.innerWidth) == "number") {
        size.width = window.innerWidth;
        size.height = window.innerHeight;
    } else {
        if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
            size.width = document.documentElement.clientWidth;
            size.height = document.documentElement.clientHeight;
        } else {
            if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
                size.width = document.body.clientWidth;
                size.height = document.body.clientHeight;
            }
        }
    }
    return size;
};
EKCalendar.prototype.getScrollPosition = function () {
    var coordinates = function () {};
    coordinates.x = 0;
    coordinates.y = 0;
    if (typeof(window.pageYOffset) == "number") {
        coordinates.x = window.pageXOffset;
        coordinates.y = window.pageYOffset;
    } else {
        if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
            coordinates.x = document.body.scrollLeft;
            coordinates.y = document.body.scrollTop;
        } else {
            if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
                coordinates.x = document.documentElement.scrollLeft;
                coordinates.y = document.documentElement.scrollTop;
            }
        }
    }
    return coordinates;
};
EKCalendar.prototype.leapYear = function (year) {
    return ((year % 400) === 0 || ((year % 4) === 0 && (year % 100) !== 0));
};
EKCalendar.prototype.resolveMonth = function (aMonths, aValue) {
    for (var i = 0; i < aMonths.length; i++) {
        if (aValue.indexOf(aMonths[i]) != -1) {
            return i;
        }
    }
    return -1;
};
EKCalendar.prototype.cleanMonth = function (aMonths, aValue) {
    for (var i = 0; i < aMonths.length; i++) {
        if (aValue.indexOf(aMonths[i]) != -1) {
            return aValue.replace(aMonths[i], this.stringFill("M", aMonths[i].length));
        }
    }
    return aValue;
};
EKCalendar.prototype.addMonth = function (dateValue, bAdd) {
    var result = new Date(dateValue.getTime());
    result.setDate(1);
    if (!bAdd) {
        if (result.getMonth() === 0) {
            result.setYear(result.getFullYear() - 1);
            result.setMonth(11);
        } else {
            result.setMonth(result.getMonth() - 1);
        }
    } else {
        if (result.getMonth() == 11) {
            result.setYear(result.getFullYear() + 1);
            result.setMonth(0);
        } else {
            result.setMonth(result.getMonth() + 1);
        }
    }
    return result;
};
EKCalendar.prototype.formatDate = function (dateValue, dateFormat) {
    var bEscaped = false;
    var iCount = -1;
    var sResult = "";
    var sFormat = dateFormat + " ";
    var aFormat = sFormat.split("");
    for (var i = 0; i < aFormat.length; i++) {
        if (i > 0 && (aFormat[i - 1] != aFormat[i]) && !bEscaped) {
            iCount++;
            switch (aFormat[i - 1]) {
            case "d":
                switch (iCount) {
                case 1:
                    sResult = sResult + dateValue.getDate();
                    break;
                case 2:
                    sResult = sResult + this.padLeft(dateValue.getDate(), "0", 2);
                    break;
                }
                break;
            case "M":
                switch (iCount) {
                case 1:
                    sResult = sResult + (dateValue.getMonth() + 1);
                    break;
                case 2:
                    sResult = sResult + this.padLeft(dateValue.getMonth() + 1, "0", 2);
                    break;
                case 3:
                    sResult = sResult + this.Config.monthShort[dateValue.getMonth()];
                    break;
                case 4:
                    sResult = sResult + this.Config.monthLong[dateValue.getMonth()];
                    break;
                }
                break;
            case "y":
                var sYear = dateValue.getFullYear() + "";
                switch (iCount) {
                case 1:
                    if (sYear.substr(3, 1) != "0") {
                        sResult = sResult + sYear.substr(3, 1);
                    } else {
                        sResult = sResult + sYear.substr(2, 2);
                    }
                    break;
                case 2:
                    sResult = sResult + sYear.substr(2, 2);
                    break;
                default:
                    sResult = sResult + sYear;
                    break;
                }
                break;
            case "\\":
                sResult = sResult + aFormat[i];
                bEscaped = true;
                break;
            default:
                for (j = 0; j < iCount; j++) {
                    sResult = sResult + aFormat[i - 1];
                }
                break;
            }
            iCount = 0;
        } else {
            iCount++;
            bEscaped = false;
        }
    }
    return sResult;
};
EKCalendar.prototype.parseDate = function (dateValue, dateFormat) {
    var bEscaped = false;
    var iCount = -1;
    var iOffset = 0;
    var sResult = "";
    var sFormat = dateFormat + " ";
    var aFormat = sFormat.split("");
    var iDay = this.startDate.getDate();
    var iMonth = this.startDate.getMonth();
    var iYear = this.startDate.getFullYear();
    var sCleanDate = dateValue;
    if (dateFormat.indexOf("MMMM") != -1) {
        sCleanDate = this.cleanMonth(this.Config.monthLong, dateValue);
    }
    if (dateFormat.indexOf("MMM") != -1) {
        sCleanDate = this.cleanMonth(this.Config.monthShort, dateValue);
    }
    for (var i = 0, length = aFormat.length; i < length; i++) {
        if (i > 0 && (aFormat[i - 1] != aFormat[i]) && !bEscaped) {
            iCount++;
            switch (aFormat[i - 1]) {
            case "d":
                switch (iCount) {
                case 1:
                    if (this.isNumeric(sCleanDate.substr(i + iOffset - 1, 2))) {
                        iDay = parseFloat(sCleanDate.substr(i + iOffset - 1, 2));
                        iOffset++;
                    } else {
                        iDay = parseFloat(sCleanDate.substr(i + iOffset - 1, 1));
                    }
                    break;
                default:
                    iDay = parseFloat(sCleanDate.substr(i + iOffset - iCount, iCount));
                }
                break;
            case "M":
                switch (iCount) {
                case 1:
                    if (this.isNumeric(sCleanDate.substr(i + iOffset - 1, 2))) {
                        iMonth = parseFloat(sCleanDate.substr(i + iOffset - 1, 2));
                        iOffset++;
                    } else {
                        iMonth = parseFloat(sCleanDate.substr(i + iOffset - 1, 1));
                    }
                    iMonth--;
                    break;
                case 2:
                    iMonth = parseFloat(sCleanDate.substr(i - 2, 2));
                    iMonth--;
                    break;
                case 3:
                    iMonth = this.resolveMonth(this.Config.monthShort, dateValue);
                    if (iMonth != -1) {
                        iOffset = iOffset + this.Config.monthShort[iMonth].length - 3;
                    }
                    break;
                case 4:
                    iMonth = this.resolveMonth(this.Config.monthLong, dateValue);
                    if (iMonth != -1) {
                        iOffset = iOffset + this.Config.monthShort[iMonth].length - 3;
                    }
                    break;
                }
                break;
            case "y":
                iYear = parseFloat(sCleanDate.substr(i + iOffset - iCount, iCount));
                if (iYear < 100) {
                    iYear = iYear + 2000;
                }
                break;
            case "\\":
                bEscaped = true;
                break;
            }
            iCount = 0;
        } else {
            iCount++;
            bEscaped = false;
        }
    }
    try {
        var result = new Date(iYear, iMonth, iDay);
        if (result.getFullYear() == iYear && result.getMonth() == iMonth && result.getDate() == iDay) {
            if (result < this.startDate) {
                result.setTime(this.startDate.getTime());
            }
            if (result > this.endDate) {
                result.setTime(this.endDate.getTime());
                result.setDate(1);
            }
            return result;
        }
    } catch (e) {
        return this.startDate;
    }
    return this.startDate;
};
EKCalendar.prototype.preloadImages = function () {
    if (document.images) {
        for (var i = 0; i < this.Config.calendarImages.length; i++) {
            var oImage = new Image(1, 1);
            oImage.src = this.Config.imagePath + this.Config.calendarImages[i];
        }
    }
};
EKCalendar.prototype.initialize = function () {
    var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/
    ;
    this.iframe = null;
    if (IE6) {
        this.iframe = document.createElement("IFRAME");
        this.iframe.className = "calendar";
        this.iframe.border = "0";
        document.body.appendChild(this.iframe);
    }
    this.calendarDiv = document.createElement("DIV");
    this.calendarDiv.id = "calendarDiv";
    this.calendarDiv.onselectstart = function () {
        return false;
    };
    this.calendarDiv.onmousedown = function () {
        return false;
    };
    var oThis = this;
    this.oldKeyDown = document.onkeydown;
    document.onkeydown = function (oEvent) {
        oEvent = oEvent || window.event;
        return oThis.handleKeyDown(oEvent);
    };
    this.oldMouseDown = document.onmousedown;
    document.onmousedown = function (oEvent) {
        oEvent = oEvent || window.event;
        return oThis.handleMouseDown(oEvent);
    };
    this.calendarDiv.style.zIndex = -1000;
    document.body.appendChild(this.calendarDiv);
    this.calendarDiv.innerHTML = this.Config.templateHTML;
    if (this.iframe) {
        this.fade = new EKFadeAnim(this.calendarDiv, this.iframe);
    } else {
        this.fade = new EKFadeAnim(this.calendarDiv, null);
    }
    this.parseTemplate();
    this.refreshData();
};
EKCalendar.prototype.handleKeyDown = function (oEvent) {
    if (oEvent.keyCode == 27) {
        this.closeCalendar();
    }
    if (this.oldKeyDown) {
        return this.oldKeyDown(oEvent);
    }
};
EKCalendar.prototype.handleMouseDown = function (oEvent) {
    var oTarget = oEvent.target || oEvent.srcElement;
    bInCalendar = false;
    while (oTarget) {
        if (oTarget == this.calendarDiv || oTarget == this.returnDateTo) {
            bInCalendar = true;
        }
        oTarget = oTarget.parentNode;
    }
    if (!bInCalendar) {
        this.closeCalendar();
    }
    if (this.oldMouseDown) {
        return this.oldMouseDown(oEvent);
    }
    return true;
};
EKCalendar.prototype.parseTemplate = function () {
    this.calendarLeft = document.getElementById("calendarLeft");
    this.calendarRight = document.getElementById("calendarRight");
    this.monthLeft = document.getElementById("monthLeft");
    this.monthRight = document.getElementById("monthRight");
    this.prevMonth = document.getElementById("prevMonth");
    this.nextMonth = document.getElementById("nextMonth");
    this.dataLeft = document.getElementById("dataLeft");
    this.dataRight = document.getElementById("dataRight");
    var daysLeft = document.getElementById("daysLeft");
    for (var i = 0; i < this.Config.dayShort.length; i++) {
        daysLeft.cells[i].innerHTML = this.Config.dayShort[i];
    }
    var daysRight = document.getElementById("daysRight");
    for (var i = 0; i < this.Config.dayShort.length; i++) {
        daysRight.cells[i].innerHTML = this.Config.dayShort[i];
    }
    var btnClose = document.getElementById("closeBtn");
    btnClose.innerHTML = this.Config.txtClose;
    btnClose.title = this.Config.txtClose;
    var tdLegendText = document.getElementById("legendText");
    tdLegendText.innerHTML = this.Config.txtLegend;
    this.prevMonth.title = this.Config.txtPrevMonth;
    this.nextMonth.title = this.Config.txtNextMonth;
};
EKCalendar.prototype.switchMonth = function (oEvent) {
    var oTarget = oEvent.target || oEvent.srcElement;
    var year = this.outputDate.getFullYear();
    this.outputDate = this.addMonth(this.outputDate, oTarget.id.indexOf("next") >= 0);
    this.refreshData();
    return false;
};
EKCalendar.prototype.updateButtons = function () {
    var oThis = this;
    var leftArrow = this.prevMonth;
    var rightArrow = this.nextMonth;
    if ((this.outputDate.getFullYear() <= this.startDate.getFullYear()) && this.outputDate.getMonth() <= this.startDate.getMonth()) {
        leftArrow.className = "arrowLeftDisabled";
        leftArrow.onclick = null;
        leftArrow.title = "";
    } else {
        leftArrow.className = "arrowLeft";
        leftArrow.onclick = function (oEvent) {
            oEvent = oEvent || window.event;
            return oThis.switchMonth(oEvent);
        };
        leftArrow.title = this.Config.txtPrevMonth;
    }
    if (this.outputDate.getFullYear() >= this.endDate.getFullYear() && this.outputDate.getMonth() >= (this.endDate.getMonth() - 1)) {
        rightArrow.className = "arrowRightDisabled";
        rightArrow.onclick = null;
        rightArrow.title = "";
    } else {
        rightArrow.className = "arrowRight";
        rightArrow.onclick = function (oEvent) {
            oEvent = oEvent || window.event;
            return oThis.switchMonth(oEvent);
        };
        rightArrow.title = this.Config.txtNextMonth;
    }
    if (this.highlightPrimaryDate && this.dependentDateTo && this.dependentDateTo.value) {
        this.highlightDate = this.parseDate(this.dependentDateTo.value, this.Config.dateFormat);
        if (this.highlightDate) {
            var tableLegend = document.getElementById("legend");
            tableLegend.style.display = "";
        }
    } else {
        var tableLegend = document.getElementById("legend");
        tableLegend.style.display = "none";
    }
};
EKCalendar.prototype.highlightDay = function () {
    switch (this.className) {
    case "activeDay":
        this.className = "activeDayOver";
        break;
    case "activeDayOver":
        this.className = "activeDay";
        break;
    case "Day":
        this.className = "DayOver";
        break;
    case "DayOver":
        this.className = "Day";
        break;
    case "highlightDay":
        this.className = "highlightDayOver";
        break;
    case "highlightDayOver":
        this.className = "highlightDay";
        break;
    }
};
EKCalendar.prototype.refreshData = function () {
    if (this.outputDate.getFullYear() == this.endDate.getFullYear() && this.outputDate.getMonth() == this.endDate.getMonth()) {
        this.writeCalendarContent(this.addMonth(this.outputDate, false), this.monthLeft, this.dataLeft);
        this.writeCalendarContent(this.outputDate, this.monthRight, this.dataRight);
    } else {
        this.writeCalendarContent(this.outputDate, this.monthLeft, this.dataLeft);
        this.writeCalendarContent(this.addMonth(this.outputDate, true), this.monthRight, this.dataRight);
    }
    this.resizeContent();
    this.updateButtons();
};
EKCalendar.prototype.writeCalendarContent = function (monthDate, monthText, monthData) {
    var oThis = this;
    if (this.calendarLeft.style.removeProperty) {
        this.calendarLeft.style.removeProperty("height");
        this.calendarRight.style.removeProperty("height");
    } else {
        this.calendarLeft.style.removeAttribute("height");
        this.calendarRight.style.removeAttribute("height");
    }
    monthText.innerHTML = this.formatDate(monthDate, this.Config.dateFormatTitle);
    var htmlData = new Array();
    var d = new Date();
    d.setTime(monthDate.getTime());
    d.setDate(1);
    var dayStartOfMonth = d.getDay();
    dayStartOfMonth = (7 - (this.Config.firstDay - dayStartOfMonth)) % 7;
    var daysInMonth = this.Config.monthDays[monthDate.getMonth()];
    if (daysInMonth == 28) {
        if (this.leapYear(monthDate.getFullYear())) {
            daysInMonth = 29;
        }
    }
    var currentDay = 0;
    var highlightDay = 0;
    var startDay = 1;
    var endDay = daysInMonth;
    if (monthDate.getFullYear() <= this.startDate.getFullYear() && monthDate.getMonth() <= this.startDate.getMonth()) {
        startDay = this.startDate.getDate();
    }
    if (monthDate.getFullYear() >= this.endDate.getFullYear() && monthDate.getMonth() >= this.endDate.getMonth()) {
        endDay = this.endDate.getDate();
    }
    if (monthDate.getFullYear() == this.inputDate.getFullYear() && monthDate.getMonth() == this.inputDate.getMonth()) {
        currentDay = this.inputDate.getDate();
    }
    if (this.highlightPrimaryDate && this.dependentDateTo && this.dependentDateTo.value) {
        this.highlightDate = this.parseDate(this.dependentDateTo.value, this.Config.dateFormat);
        if (monthDate.getFullYear() == this.highlightDate.getFullYear() && monthDate.getMonth() == this.highlightDate.getMonth()) {
            highlightDay = this.highlightDate.getDate();
        }
    }
    if ((monthDate.getMonth() < this.startDate.getMonth() && monthDate.getFullYear() == this.startDate.getFullYear()) || monthDate.getFullYear() < this.startDate.getFullYear()) {
        startDay = 99;
    }
    for (i = 0; i < monthData.rows.length * 7; i++) {
        var oCell = monthData.rows[parseInt(i / 7)].cells[i % 7];
        var iDay = i - dayStartOfMonth + 1;
        oCell.id = "";
        oCell.onclick = null;
        oCell.onmouseover = null;
        oCell.onmouseout = null;
        if (i < dayStartOfMonth || iDay > daysInMonth) {
            oCell.className = "inActiveDay";
            oCell.innerHTML = "";
        } else {
            oCell.id = "day-" + iDay + "-" + monthDate.getMonth() + "-" + monthDate.getFullYear();
            oCell.innerHTML = iDay;
            oCell.className = "inActiveDay";
            if (iDay >= startDay && iDay <= endDay) {
                oCell.onmouseover = this.highlightDay;
                oCell.onmouseout = this.highlightDay;
                oCell.onclick = function (oEvent) {
                    oEvent = oEvent || window.event;
                    return oThis.pickDate(oEvent);
                };
                if (iDay == highlightDay) {
                    oCell.className = "highlightDay";
                } else {
                    if (iDay == currentDay) {
                        oCell.className = "activeDay";
                    } else {
                        oCell.className = "Day";
                    }
                }
            }
        }
    }
    if (daysInMonth + dayStartOfMonth > 5 * 7) {
        monthData.rows[monthData.rows.length - 1].style.display = "";
    } else {
        monthData.rows[monthData.rows.length - 1].style.display = "none";
    }
};
EKCalendar.prototype.resizeContent = function () {
    if (this.calendarRight.offsetHeight > this.calendarLeft.offsetHeight) {
        this.calendarLeft.style.height = (this.calendarRight.offsetHeight + 4) + "px";
    } else {
        this.calendarLeft.style.height = (this.calendarLeft.offsetHeight + 4) + "px";
    }
    if (this.iframe) {
        var iBorder = parseFloat(this.calendarDiv.currentStyle.borderWidth);
        if (!isNaN(iBorder)) {
            this.iframe.style.width = (this.calendarDiv.clientWidth - (2 * iBorder)) + "px";
            this.iframe.style.height = (this.calendarDiv.clientHeight + (2 * iBorder)) + "px";
        } else {
            this.iframe.style.width = this.calendarDiv.clientWidth + "px";
            this.iframe.style.height = this.calendarDiv.clientHeight + "px";
        }
    }
    if (this.returnDateTo) {
        var coord = this.findPos(this.returnDateTo);
        var scroll = this.getScrollPosition();
        var size = this.getWindowSize();
        var ourLeft = coord.x;
        var ourTop = coord.y + this.returnDateTo.offsetHeight + 2;
        var obj = this.calendarDiv;
        if ((obj.offsetHeight + ourTop) > (scroll.y + size.height)) {
            window.scrollTo(scroll.x, scroll.y + (obj.offsetHeight + ourTop) - (scroll.y + size.height) + 25);
        }
    }
};
EKCalendar.prototype.positionCalendar = function (xOffset) {
    var coord = this.findPos(this.returnDateTo);
    var scroll = this.getScrollPosition();
    var size = this.getWindowSize();
    var ourLeft = coord.x;
    var ourTop = coord.y + this.returnDateTo.offsetHeight + 2;
    var obj = this.calendarDiv;
    if ((obj.offsetHeight + ourTop) > (scroll.y + size.height + 4)) {
        window.scrollTo(scroll.x, scroll.y + (obj.offsetHeight + ourTop) - (scroll.y + size.height) + 25);
    }
    if (this.Config.maxScreen !== 0 && size.width > this.Config.maxScreen) {
        size.width = this.Config.maxScreen + (document.body.clientWidth - this.Config.maxScreen) / 2;
    }
    if ((obj.offsetWidth + ourLeft + 20) > (scroll.x + size.width)) {
        ourLeft = coord.x + this.returnDateTo.offsetWidth - obj.offsetWidth;
    }
    this.calendarDiv.style.left = ourLeft + xOffset + "px";
    this.calendarDiv.style.top = ourTop + "px";
    if (this.iframe) {
        this.iframe.style.left = this.calendarDiv.style.left;
        this.iframe.style.top = this.calendarDiv.style.top;
    }
};
EKCalendar.prototype.pickDate = function (oEvent) {
    var oTarget = oEvent.target || oEvent.srcElement;
    var aDateParts = oTarget.id.split("-");
    this.outputDate.setDate(1);
    this.outputDate.setYear(aDateParts[3]);
    this.outputDate.setMonth(aDateParts[2]);
    this.outputDate.setDate(aDateParts[1]);
    this.returnDateTo.value = this.formatDate(this.outputDate, this.Config.dateFormat);
    if (this.dependentDateTo && this.dependentDaysDiff) {
        this.outputDate = new Date(this.outputDate.getTime() + (this.dependentDaysDiff * 1000 * 3600 * 24));
        if (this.outputDate > this.endDate) {
            this.outputDate = new Date(this.endDate.getTime());
        }
        if (this.outputDate < this.startDate) {
            this.outputDate = new Date(this.startDate.getTime());
        }
        this.dependentDateTo.value = this.formatDate(this.outputDate, this.Config.dateFormat);
    }
    this.closeCalendar();
};
EKCalendar.prototype.display = function (inputField, startDate, endDate, dependentField, useDependantDates, highlightPrimaryDate, dependentDaysDiff, offset) {
    if (!this.Config) {
        return;
    }
    if (typeof dependentField == "undefined") {
        dependentField = null;
    }
    if (typeof useDependantDates == "undefined") {
        useDependantDates = true;
    }
    if (typeof highlightPrimaryDate == "undefined") {
        highlightPrimaryDate = false;
    }
    if (typeof dependentDaysDiff == "undefined") {
        dependentDaysDiff = null;
    }
    if (typeof offset == "undefined") {
        offset = 0;
    }
    this.startDate = new Date(startDate.getTime());
    this.endDate = new Date(endDate.getTime());
    if (dependentField && !dependentDaysDiff && dependentField.value && useDependantDates) {
        this.startDate = this.parseDate(dependentField.value, this.Config.dateFormat);
    }
    if (inputField && inputField.tagName == "INPUT" && !inputField.disabled) {
        this.inputDate = this.parseDate(inputField.value, this.Config.dateFormat);
        this.outputDate = new Date(this.inputDate.getTime());
    } else {
        return;
    }
    if (inputField.style.display == "none" || inputField.disabled == "true") {
        return;
    }
    if (!this.calendarDiv) {
        this.initialize();
    }
    this.returnDateTo = inputField;
    this.dependentDateTo = dependentField;
    this.dependentDaysDiff = dependentDaysDiff;
    this.highlightPrimaryDate = highlightPrimaryDate;
    var bDisplaying = this.calendarDiv.style.visibility == "visible";
    this.calendarDiv.style.zIndex = -1000;
    this.calendarDiv.style.visibility = "visible";
    this.refreshData();
    this.positionCalendar(offset);
    if (!bDisplaying) {
        this.calendarDiv.style.visibility = "hidden";
    }
    this.calendarDiv.style.zIndex = 1000;
    if (!bDisplaying) {
        this.fade.fadeIn();
    }
};
EKCalendar.prototype.closeCalendar = function () {
    if (this.calendarDiv) {
        if (this.calendarDiv.style.visibility == "visible") {
            this.fade.fadeOut();
        }
    }
    return false;
};
var EKCalendar = new EKCalendar();