/*
 * WICHTIG :
 * ZEIT WIRD BISHER HARDCODED REINGESCHRIEBEN:
 * $j("#von").val(d + " 00:00:00");
 * $j("#bis").val(e + " 23:59:59");
 * own functions:
 * - _chosenDate : if a date is chosen its written into two hidden input fields with id "von", "bis"
 * - _toggleTip : onClick get the toggleTip and on the second click submit the form
 * - _highlightCalendarEvents : all the ajax stuff. if the calendar is updated get the events of a single day and set the class "highlight"
 * the class "highlight" is also used for the tooltip stuff in calendarboxtime.phtml only if this class is set we get the events of the day
 */



; (function($) {
    var j = $.fn.remove;
    $.fn.remove = function() {
        $("*", this).add(this).triggerHandler("remove");
        return j.apply(this, arguments)
    };
    function isVisible(c) {
        function checkStyles(a) {
            var b = a.style;
            return (b.display != 'none' && b.visibility != 'hidden')
        }
        var d = checkStyles(c); (d && $.each($.dir(c, 'parentNode'),
        function() {
            return (d = checkStyles(this))
        }));
        return d
    }
    $.extend($.expr[':'], {
        data: function(a, i, m) {
            return $.data(a, m[3])
        },
        tabbable: function(a, i, m) {
            var b = a.nodeName.toLowerCase();
            return (a.tabIndex >= 0 && (('a' == b && a.href) || (/input|select|textarea|button/.test(b) && 'hidden' != a.type && !a.disabled)) && isVisible(a))
        }
    });
    $.keyCode = {
        BACKSPACE: 8,
        CAPS_LOCK: 20,
        COMMA: 188,
        CONTROL: 17,
        DELETE: 46,
        DOWN: 40,
        END: 35,
        ENTER: 13,
        ESCAPE: 27,
        HOME: 36,
        INSERT: 45,
        LEFT: 37,
        NUMPAD_ADD: 107,
        NUMPAD_DECIMAL: 110,
        NUMPAD_DIVIDE: 111,
        NUMPAD_ENTER: 108,
        NUMPAD_MULTIPLY: 106,
        NUMPAD_SUBTRACT: 109,
        PAGE_DOWN: 34,
        PAGE_UP: 33,
        PERIOD: 190,
        RIGHT: 39,
        SHIFT: 16,
        SPACE: 32,
        TAB: 9,
        UP: 38
    };
    function getter(c, d, e, f) {
        function getMethods(a) {
            var b = $[c][d][a] || [];
            return (typeof b == 'string' ? b.split(/,?\s+/) : b)
        }
        var g = getMethods('getter');
        if (f.length == 1 && typeof f[0] == 'string') {
            g = g.concat(getMethods('getterSetter'))
        }
        return ($.inArray(e, g) != -1)
    }
    $.widget = function(g, h) {
        var i = g.split(".")[0];
        g = g.split(".")[1];
        $.fn[g] = function(b) {
            var c = (typeof b == 'string'),
            args = Array.prototype.slice.call(arguments, 1);
            if (c && b.substring(0, 1) == '_') {
                return this
            }
            if (c && getter(i, g, b, args)) {
                var d = $.data(this[0], g);
                return (d ? d[b].apply(d, args) : undefined)
            }
            return this.each(function() {
                var a = $.data(this, g); (!a && !c && $.data(this, g, new $[i][g](this, b))); (a && c && $.isFunction(a[b]) && a[b].apply(a, args))
            })
        };
        $[i][g] = function(c, d) {
            var f = this;
            this.widgetName = g;
            this.widgetEventPrefix = $[i][g].eventPrefix || g;
            this.widgetBaseClass = i + '-' + g;
            this.options = $.extend({},
            $.widget.defaults, $[i][g].defaults, $.metadata && $.metadata.get(c)[g], d);
            this.element = $(c).bind('setData.' + g,
            function(e, a, b) {
                return f._setData(a, b)
            }).bind('getData.' + g,
            function(e, a) {
                return f._getData(a)
            }).bind('remove',
            function() {
                return f.destroy()
            });
            this._init()
        };
        $[i][g].prototype = $.extend({},
        $.widget.prototype, h);
        $[i][g].getterSetter = 'option'
    };
    $.widget.prototype = {
        _init: function() {},
        destroy: function() {
            this.element.removeData(this.widgetName)
        },
        option: function(c, d) {
            var e = c,
            self = this;
            if (typeof c == "string") {
                if (d === undefined) {
                    return this._getData(c)
                }
                e = {};
                e[c] = d
            }
            $.each(e,
            function(a, b) {
                self._setData(a, b)
            })
        },
        _getData: function(a) {
            return this.options[a]
        },
        _setData: function(a, b) {
            this.options[a] = b;
            if (a == 'disabled') {
                this.element[b ? 'addClass': 'removeClass'](this.widgetBaseClass + '-disabled')
            }
        },
        enable: function() {
            this._setData('disabled', false)
        },
        disable: function() {
            this._setData('disabled', true)
        },
        _trigger: function(a, e, b) {
            var c = (a == this.widgetEventPrefix ? a: this.widgetEventPrefix + a);
            e = e || $.event.fix({
                type: c,
                target: this.element[0]
            });
            return this.element.triggerHandler(c, [e, b], this.options[a])
        }
    };
    $.widget.defaults = {
        disabled: false
    };
    $.ui = {
        plugin: {
            add: function(a, b, c) {
                var d = $.ui[a].prototype;
                for (var i in c) {
                    d.plugins[i] = d.plugins[i] || [];
                    d.plugins[i].push([b, c[i]])
                }
            },
            call: function(a, b, c) {
                var d = a.plugins[b];
                if (!d) {
                    return
                }
                for (var i = 0; i < d.length; i++) {
                    if (a.options[d[i][0]]) {
                        d[i][1].apply(a.element, c)
                    }
                }
            }
        },
        cssCache: {},
        css: function(a) {
            if ($.ui.cssCache[a]) {
                return $.ui.cssCache[a]
            }
            var b = $('<div class="ui-gen">').addClass(a).css({
                position: 'absolute',
                top: '-5000px',
                left: '-5000px',
                display: 'block'
            }).appendTo('body');
            $.ui.cssCache[a] = !!((!(/auto|default/).test(b.css('cursor')) || (/^[1-9]/).test(b.css('height')) || (/^[1-9]/).test(b.css('width')) || !(/none/).test(b.css('backgroundImage')) || !(/transparent|rgba\(0, 0, 0, 0\)/).test(b.css('backgroundColor'))));
            try {
                $('body').get(0).removeChild(b.get(0))
            } catch(e) {}
            return $.ui.cssCache[a]
        },
        disableSelection: function(a) {
            return $(a).attr('unselectable', 'on').css('MozUserSelect', 'none').bind('selectstart.ui',
            function() {
                return false
            })
        },
        enableSelection: function(a) {
            return $(a).attr('unselectable', 'off').css('MozUserSelect', '').unbind('selectstart.ui')
        },
        hasScroll: function(e, a) {
            if ($(e).css('overflow') == 'hidden') {
                return false
            }
            var b = (a && a == 'left') ? 'scrollLeft': 'scrollTop',
            has = false;
            if (e[b] > 0) {
                return true
            }
            e[b] = 1;
            has = (e[b] > 0);
            e[b] = 0;
            return has
        }
    };
    $.ui.mouse = {
        _mouseInit: function() {
            var a = this;
            this.element.bind('mousedown.' + this.widgetName,
            function(e) {
                return a._mouseDown(e)
            });
            if ($.browser.msie) {
                this._mouseUnselectable = this.element.attr('unselectable');
                this.element.attr('unselectable', 'on')
            }
            this.started = false
        },
        _mouseDestroy: function() {
            this.element.unbind('.' + this.widgetName); ($.browser.msie && this.element.attr('unselectable', this._mouseUnselectable))
        },
        _mouseDown: function(e) { (this._mouseStarted && this._mouseUp(e));
            this._mouseDownEvent = e;
            var a = this,
            btnIsLeft = (e.which == 1),
            elIsCancel = (typeof this.options.cancel == "string" ? $(e.target).parents().add(e.target).filter(this.options.cancel).length: false);
            if (!btnIsLeft || elIsCancel || !this._mouseCapture(e)) {
                return true
            }
            this.mouseDelayMet = !this.options.delay;
            if (!this.mouseDelayMet) {
                this._mouseDelayTimer = setTimeout(function() {
                    a.mouseDelayMet = true
                },
                this.options.delay)
            }
            if (this._mouseDistanceMet(e) && this._mouseDelayMet(e)) {
                this._mouseStarted = (this._mouseStart(e) !== false);
                if (!this._mouseStarted) {
                    e.preventDefault();
                    return true
                }
            }
            this._mouseMoveDelegate = function(e) {
                return a._mouseMove(e)
            };
            this._mouseUpDelegate = function(e) {
                return a._mouseUp(e)
            };
            $(document).bind('mousemove.' + this.widgetName, this._mouseMoveDelegate).bind('mouseup.' + this.widgetName, this._mouseUpDelegate);
            return false
        },
        _mouseMove: function(e) {
            if ($.browser.msie && !e.button) {
                return this._mouseUp(e)
            }
            if (this._mouseStarted) {
                this._mouseDrag(e);
                return false
            }
            if (this._mouseDistanceMet(e) && this._mouseDelayMet(e)) {
                this._mouseStarted = (this._mouseStart(this._mouseDownEvent, e) !== false); (this._mouseStarted ? this._mouseDrag(e) : this._mouseUp(e))
            }
            return ! this._mouseStarted
        },
        _mouseUp: function(e) {
            $(document).unbind('mousemove.' + this.widgetName, this._mouseMoveDelegate).unbind('mouseup.' + this.widgetName, this._mouseUpDelegate);
            if (this._mouseStarted) {
                this._mouseStarted = false;
                this._mouseStop(e)
            }
            return false
        },
        _mouseDistanceMet: function(e) {
            return (Math.max(Math.abs(this._mouseDownEvent.pageX - e.pageX), Math.abs(this._mouseDownEvent.pageY - e.pageY)) >= this.options.distance)
        },
        _mouseDelayMet: function(e) {
            return this.mouseDelayMet
        },
        _mouseStart: function(e) {},
        _mouseDrag: function(e) {},
        _mouseStop: function(e) {},
        _mouseCapture: function(e) {
            return true
        }
    };
    $.ui.mouse.defaults = {
        cancel: null,
        distance: 1,
        delay: 0
    }
})(jQuery); (function($) {
    var bl = 'datepicker';
    function Datepicker() {
        this.debug = true;
        this._curInst = null;
        this._disabledInputs = [];
        this._datepickerShowing = false;
        this._inDialog = false;
        this._tip = false;
        this._mySelectedMonth = '';
        this._mySelectedYear = '';
        this._mainDivId = 'ui-datepicker-div';
        this._inlineClass = 'ui-datepicker-inline';
        this._appendClass = 'ui-datepicker-append';
        this._triggerClass = 'ui-datepicker-trigger';
        this._dialogClass = 'ui-datepicker-dialog';
        this._promptClass = 'ui-datepicker-prompt';
        this._disableClass = 'ui-datepicker-disabled';
        this._unselectableClass = 'ui-datepicker-unselectable';
        this._currentClass = 'ui-datepicker-current-day';
        this.regional = [];
        this.regional[''] = {
            clearText: 'Clear',
            clearStatus: 'Erase the current date',
            closeText: 'Close',
            closeStatus: 'Close without change',
            prevText: '&#x3c;Prev',
            prevStatus: 'Show the previous month',
            prevBigText: '&#x3c;&#x3c;',
            prevBigStatus: 'Show the previous year',
            nextText: 'Next&#x3e;',
            nextStatus: 'Show the next month',
            nextBigText: '&#x3e;&#x3e;',
            nextBigStatus: 'Show the next year',
            currentText: 'Today',
            currentStatus: 'Show the current month',
            monthNames: ['Januar', 'Februar', 'M&auml;rz', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
            monthNamesShort: ['So', 'Mo', 'Die', 'Mi', 'Do', 'Fr', 'Sa'],
            monthStatus: 'Show a different month',
            yearStatus: 'Show a different year',
            weekHeader: 'Wk',
            weekStatus: 'Week of the year',
            dayNames: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'],
            dayNamesShort: ['Son', 'Mon', 'Die', 'Mit', 'Don', 'Fre', 'Sam'],
            dayNamesMin: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
            dayStatus: 'Set DD as first week day',
            dateStatus: 'Select DD, M d',
            dateFormat: 'mm/dd/yy',
            firstDay: 0,
            initStatus: 'Select a date',
            isRTL: false,
            actionurl: '',
            highlight: false
        };
        this._defaults = {
            showOn: 'focus',
            showAnim: 'show',
            showOptions: {},
            defaultDate: null,
            appendText: '',
            buttonText: '...',
            buttonImage: '',
            buttonImageOnly: false,
            closeAtTop: true,
            mandatory: false,
            hideIfNoPrevNext: false,
            navigationAsDateFormat: false,
            showBigPrevNext: false,
            gotoCurrent: false,
            changeMonth: true,
            changeYear: true,
            showMonthAfterYear: false,
            yearRange: '-10:+10',
            changeFirstDay: true,
            highlightWeek: false,
            showOtherMonths: false,
            showWeeks: false,
            calculateWeek: this.iso8601Week,
            shortYearCutoff: '+10',
            showStatus: false,
            statusForDate: this.dateStatus,
            minDate: null,
            maxDate: null,
            duration: 'normal',
            beforeShowDay: null,
            beforeShow: null,
            onSelect: null,
            onChangeMonthYear: null,
            onClose: null,
            numberOfMonths: 1,
            showCurrentAtPos: 0,
            stepMonths: 1,
            stepBigMonths: 12,
            rangeSelect: false,
            rangeSeparator: ' - ',
            altField: '',
            altFormat: ''
        };
        $.extend(this._defaults, this.regional['']);
        this.dpDiv = $('<div id="' + this._mainDivId + '" style="display: none;"></div>')
    }
    $.extend(Datepicker.prototype, {
        markerClassName: 'hasDatepicker',
        log: function() {
            if (this.debug) console.log.apply('', arguments)
        },
        setDefaults: function(a) {
            extendRemove(this._defaults, a || {});
            return this
        },
        _attachDatepicker: function(a, b) {
            var c = null;
            for (attrName in this._defaults) {
                var d = a.getAttribute('date:' + attrName);
                if (d) {
                    c = c || {};
                    try {
                        c[attrName] = eval(d)
                    } catch(err) {
                        c[attrName] = d
                    }
                }
            }
            var e = a.nodeName.toLowerCase();
            var f = (e == 'div' || e == 'span');
            if (!a.id) a.id = 'dp' + (++this.uuid);
            var g = this._newInst($(a), f);
            g.settings = $.extend({},
            b || {},
            c || {});
            if (e == 'input') {
                this._connectDatepicker(a, g)
            } else if (f) {
                this._inlineDatepicker(a, g)
            }
        },
        _newInst: function(a, b) {
            var c = a[0].id.replace(/([:\[\]\.])/g, '\\\\$1');
            return {
                id: c,
                input: a,
                selectedDay: 0,
                selectedMonth: 0,
                selectedYear: 0,
                drawMonth: 0,
                drawYear: 0,
                inline: b,
                dpDiv: (!b ? this.dpDiv: $('<div class="' + this._inlineClass + '"></div>'))
            }
        },
        _connectDatepicker: function(d, e) {
            var f = $(d);
            if (f.hasClass(this.markerClassName)) return;
            var g = this._get(e, 'appendText');
            var h = this._get(e, 'isRTL');
            if (g) f[h ? 'before': 'after']('<span class="' + this._appendClass + '">' + g + '</span>');
            var i = this._get(e, 'showOn');
            if (i == 'focus' || i == 'both') f.focus(this._showDatepicker);
            if (i == 'button' || i == 'both') {
                var j = this._get(e, 'buttonText');
                var k = this._get(e, 'buttonImage');
                var l = $(this._get(e, 'buttonImageOnly') ? $('<img/>').addClass(this._triggerClass).attr({
                    src: k,
                    alt: j,
                    title: j
                }) : $('<button type="button"></button>').addClass(this._triggerClass).html(k == '' ? j: $('<img/>').attr({
                    src: k,
                    alt: j,
                    title: j
                })));
                f[h ? 'before': 'after'](l);
                l.click(function() {
                    if ($.datepicker._datepickerShowing && $.datepicker._lastInput == d) $.datepicker._hideDatepicker();
                    else $.datepicker._showDatepicker(d);
                    return false
                })
            }
            f.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).bind("setData.datepicker",
            function(a, b, c) {
                e.settings[b] = c
            }).bind("getData.datepicker",
            function(a, b) {
                return this._get(e, b)
            });
            $.data(d, bl, e)
        },
        _inlineDatepicker: function(d, e) {
            var f = $(d);
            if (f.hasClass(this.markerClassName)) return;
            f.addClass(this.markerClassName).append(e.dpDiv).bind("setData.datepicker",
            function(a, b, c) {
                e.settings[b] = c
            }).bind("getData.datepicker",
            function(a, b) {
                return this._get(e, b)
            });
            $.data(d, bl, e);
            this._setDate(e, this._getDefaultDate(e));
           	
           
           	      	
           	this._updateDatepicker(e);
           	//
        	//SKEN
        	//if(this._get(e, 'highlight')){	        		
			//	this._highlightCalendarEvents(e);  		        		        		
        	//}
        	//
        	//
           	 
         },
        _inlineShow: function(a) {
            var b = this._getNumberOfMonths(a);
            a.dpDiv.width(b[1] * $('.ui-datepicker', a.dpDiv[0]).width())
        },
        _dialogDatepicker: function(a, b, c, d, e) {
            var f = this._dialogInst;
            if (!f) {
                var g = 'dp' + (++this.uuid);
                this._dialogInput = $('<input type="text" id="' + g + '" size="1" style="position: absolute; top: -100px;"/>');
                this._dialogInput.keydown(this._doKeyDown);
                $('body').append(this._dialogInput);
                f = this._dialogInst = this._newInst(this._dialogInput, false);
                f.settings = {};
                $.data(this._dialogInput[0], bl, f)
            }
            extendRemove(f.settings, d || {});
            this._dialogInput.val(b);
            this._pos = (e ? (e.length ? e: [e.pageX, e.pageY]) : null);
            if (!this._pos) {
                var h = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
                var i = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
                var j = document.documentElement.scrollLeft || document.body.scrollLeft;
                var k = document.documentElement.scrollTop || document.body.scrollTop;
                this._pos = [(h / 2) - 100 + j, (i / 2) - 150 + k]
            }
            this._dialogInput.css('left', this._pos[0] + 'px').css('top', this._pos[1] + 'px');
            f.settings.onSelect = c;
            this._inDialog = true;
            this.dpDiv.addClass(this._dialogClass);
            this._showDatepicker(this._dialogInput[0]);
            if ($.blockUI) $.blockUI(this.dpDiv);
            $.data(this._dialogInput[0], bl, f);
            return this
        },
        _destroyDatepicker: function(a) {
            var b = $(a);
            if (!b.hasClass(this.markerClassName)) {
                return
            }
            var c = a.nodeName.toLowerCase();
            $.removeData(a, bl);
            if (c == 'input') {
                b.siblings('.' + this._appendClass).remove().end().siblings('.' + this._triggerClass).remove().end().removeClass(this.markerClassName).unbind('focus', this._showDatepicker).unbind('keydown', this._doKeyDown).unbind('keypress', this._doKeyPress)
            } else if (c == 'div' || c == 'span') b.removeClass(this.markerClassName).empty()
        },
        _enableDatepicker: function(b) {
            var c = $(b);
            if (!c.hasClass(this.markerClassName)) {
                return
            }
            var d = b.nodeName.toLowerCase();
            if (d == 'input') {
                b.disabled = false;
                c.siblings('button.' + this._triggerClass).each(function() {
                    this.disabled = false
                }).end().siblings('img.' + this._triggerClass).css({
                    opacity: '1.0',
                    cursor: ''
                })
            } else if (d == 'div' || d == 'span') {
                c.children('.' + this._disableClass).remove()
            }
            this._disabledInputs = $.map(this._disabledInputs,
            function(a) {
                return (a == b ? null: a)
            })
        },
        _disableDatepicker: function(b) {
            var c = $(b);
            if (!c.hasClass(this.markerClassName)) {
                return
            }
            var d = b.nodeName.toLowerCase();
            if (d == 'input') {
                b.disabled = true;
                c.siblings('button.' + this._triggerClass).each(function() {
                    this.disabled = true
                }).end().siblings('img.' + this._triggerClass).css({
                    opacity: '0.5',
                    cursor: 'default'
                })
            } else if (d == 'div' || d == 'span') {
                var e = c.children('.' + this._inlineClass);
                var f = e.offset();
                var g = {
                    left: 0,
                    top: 0
                };
                e.parents().each(function() {
                    if ($(this).css('position') == 'relative') {
                        g = $(this).offset();
                        return false
                    }
                });
                c.prepend('<div class="' + this._disableClass + '" style="' + ($.browser.msie ? 'background-color: transparent; ': '') + 'width: ' + e.width() + 'px; height: ' + e.height() + 'px; left: ' + (f.left - g.left) + 'px; top: ' + (f.top - g.top) + 'px;"></div>')
            }
            this._disabledInputs = $.map(this._disabledInputs,
            function(a) {
                return (a == b ? null: a)
            });
            this._disabledInputs[this._disabledInputs.length] = b
        },
        _isDisabledDatepicker: function(a) {
            if (!a) return false;
            for (var i = 0; i < this._disabledInputs.length; i++) {
                if (this._disabledInputs[i] == a) return true
            }
            return false
        },
        _getInst: function(a) {
            try {
                return $.data(a, bl)
            } catch(err) {
                throw 'Missing instance data for this datepicker';
            }
        },
        _changeDatepicker: function(a, b, c) {
            var d = b || {};
            if (typeof b == 'string') {
                d = {};
                d[b] = c
            }
            var e = this._getInst(a);
            if (e) {
                if (this._curInst == e) {
                    this._hideDatepicker(null)
                }
                extendRemove(e.settings, d);
                var f = new Date();
                extendRemove(e, {
                    rangeStart: null,
                    endDay: null,
                    endMonth: null,
                    endYear: null,
                    selectedDay: f.getDate(),
                    selectedMonth: f.getMonth(),
                    selectedYear: f.getFullYear(),
                    currentDay: f.getDate(),
                    currentMonth: f.getMonth(),
                    currentYear: f.getFullYear(),
                    drawMonth: f.getMonth(),
                    drawYear: f.getFullYear()
                });
                this._updateDatepicker(e)
            }
        },
        _refreshDatepicker: function(a) {
            var b = this._getInst(a);
            if (b) {
                this._updateDatepicker(b)
            }
        },
        _setDateDatepicker: function(a, b, c) {
            var d = this._getInst(a);
            if (d) {
                this._setDate(d, b, c);
                this._updateDatepicker(d);                
                //
                //SKEN
        		if(this._get(d, 'highlight')){
        			this._highlightCalendarEvents(d);
        		}
        		//
        		//                 
                this._updateAlternate(d)
            }
        },
        _getDateDatepicker: function(a) {
            var b = this._getInst(a);
            if (b && !b.inline) this._setDateFromField(b);
            return (b ? this._getDate(b) : null)
        },
        _doKeyDown: function(e) {
            var a = $.datepicker._getInst(e.target);
            var b = true;
            if ($.datepicker._datepickerShowing) switch (e.keyCode) {
            case 9:
                $.datepicker._hideDatepicker(null, '');
                break;
            case 13:
                $.datepicker._selectDay(e.target, a.selectedMonth, a.selectedYear, $('td.ui-datepicker-days-cell-over', a.dpDiv)[0]);
                return false;
                break;
            case 27:
                $.datepicker._hideDatepicker(null, $.datepicker._get(a, 'duration'));
                break;
            case 33:
                $.datepicker._adjustDate(e.target, (e.ctrlKey ? -$.datepicker._get(a, 'stepBigMonths') : -$.datepicker._get(a, 'stepMonths')), 'M');
                break;
            case 34:
                $.datepicker._adjustDate(e.target, (e.ctrlKey ? +$.datepicker._get(a, 'stepBigMonths') : +$.datepicker._get(a, 'stepMonths')), 'M');
                break;
            case 35:
                if (e.ctrlKey) $.datepicker._clearDate(e.target);
                b = e.ctrlKey;
                break;
            case 36:
                if (e.ctrlKey) $.datepicker._gotoToday(e.target);
                b = e.ctrlKey;
                break;
            case 37:
                if (e.ctrlKey) $.datepicker._adjustDate(e.target, -1, 'D');
                b = e.ctrlKey;
                break;
            case 38:
                if (e.ctrlKey) $.datepicker._adjustDate(e.target, -7, 'D');
                b = e.ctrlKey;
                break;
            case 39:
                if (e.ctrlKey) $.datepicker._adjustDate(e.target, +1, 'D');
                b = e.ctrlKey;
                break;
            case 40:
                if (e.ctrlKey) $.datepicker._adjustDate(e.target, +7, 'D');
                b = e.ctrlKey;
                break;
            default:
                b = false
            } else if (e.keyCode == 36 && e.ctrlKey) $.datepicker._showDatepicker(this);
            else b = false;
            if (b) {
                e.preventDefault();
                e.stopPropagation()
            }
        },
        _doKeyPress: function(e) {
            var a = $.datepicker._getInst(e.target);
            var b = $.datepicker._possibleChars($.datepicker._get(a, 'dateFormat'));
            var c = String.fromCharCode(e.charCode == undefined ? e.keyCode: e.charCode);
            return e.ctrlKey || (c < ' ' || !b || b.indexOf(c) > -1)
        },
        _showDatepicker: function(a) {
            a = a.target || a;
            if (a.nodeName.toLowerCase() != 'input') a = $('input', a.parentNode)[0];
            if ($.datepicker._isDisabledDatepicker(a) || $.datepicker._lastInput == a) return;
            var b = $.datepicker._getInst(a);
            var c = $.datepicker._get(b, 'beforeShow');
            extendRemove(b.settings, (c ? c.apply(a, [a, b]) : {}));
            $.datepicker._hideDatepicker(null, '');
            $.datepicker._lastInput = a;
            $.datepicker._setDateFromField(b);
            if ($.datepicker._inDialog) a.value = '';
            if (!$.datepicker._pos) {
                $.datepicker._pos = $.datepicker._findPos(a);
                $.datepicker._pos[1] += a.offsetHeight
            }
            var d = false;
            $(a).parents().each(function() {
                d |= $(this).css('position') == 'fixed';
                return ! d
            });
            if (d && $.browser.opera) {
                $.datepicker._pos[0] -= document.documentElement.scrollLeft;
                $.datepicker._pos[1] -= document.documentElement.scrollTop
            }
            var e = {
                left: $.datepicker._pos[0],
                top: $.datepicker._pos[1]
            };
            $.datepicker._pos = null;
            b.rangeStart = null;
            b.dpDiv.css({
                position: 'absolute',
                display: 'block',
                top: '-1000px'
            });
            $.datepicker._updateDatepicker(b);
             
            b.dpDiv.width($.datepicker._getNumberOfMonths(b)[1] * $('.ui-datepicker', b.dpDiv[0])[0].offsetWidth);
            e = $.datepicker._checkOffset(b, e, d);
            b.dpDiv.css({
                position: ($.datepicker._inDialog && $.blockUI ? 'static': (d ? 'fixed': 'absolute')),
                display: 'none',
                left: e.left + 'px',
                top: e.top + 'px'
            });
            if (!b.inline) {
                var f = $.datepicker._get(b, 'showAnim') || 'show';
                var g = $.datepicker._get(b, 'duration');
                var h = function() {
                    $.datepicker._datepickerShowing = true;
                    if ($.browser.msie && parseInt($.browser.version, 10) < 7) $('iframe.ui-datepicker-cover').css({
                        width: b.dpDiv.width() + 4,
                        height: b.dpDiv.height() + 4
                    })
                };
                if ($.effects && $.effects[f]) b.dpDiv.show(f, $.datepicker._get(b, 'showOptions'), g, h);
                else b.dpDiv[f](g, h);
                if (g == '') h();
                if (b.input[0].type != 'hidden') b.input[0].focus();
                $.datepicker._curInst = b
            }
        },
        _updateDatepicker: function(a) {
        	//
        	//SKEN
        	if(typeof($j("select.ui-datepicker-new-month :selected").val()) != "undefined"){
        		this._mySelectedMonth = a.selectedMonth;
        		this._mySelectedYear = a.selectedYear;
        	}
        	//
        	//  	
        	var b = {
                width: a.dpDiv.width() + 4,
                height: a.dpDiv.height() + 4
            };
            a.dpDiv.empty().append(this._generateHTML(a)).find('iframe.ui-datepicker-cover').css({
                width: b.width,
                height: b.height
            });
            var c = this._getNumberOfMonths(a);
            a.dpDiv[(c[0] != 1 || c[1] != 1 ? 'add': 'remove') + 'Class']('ui-datepicker-multi');
            a.dpDiv[(this._get(a, 'isRTL') ? 'add': 'remove') + 'Class']('ui-datepicker-rtl');
            if (a.input && a.input[0].type != 'hidden') $(a.input[0]).focus()
            
            
           
            
            
        },
        _chosenDate: function(a) {
            var b = this._getDate(a);
            var c = $.datepicker._get(a, 'dateFormat');
            var d = this.formatDate(c, b[0], this._getFormatConfig(a));
            var e = this.formatDate(c, b[1], this._getFormatConfig(a));
			
			//
            $j("#von").val(d + " 00:00:00");
            $j("#bis").val(e + " 23:59:59")
			//
        },
        _toggleTip: function(f){
        	
          	var e = $(f);
            var f = this._getInst(e[0]);
            var g = this._get(f, 'rangeSelect');      
        	if(g==true){	        
	        	if(this._tip==false){
	        		this._tip=true;		
	        		Tip("Klicke f&uuml;r das End-Datum");
	        		$j("#tooltip").remove();
	        	}else{
	        		UnTip();
	        		this._tip=false;
	        		var h = this._inlineClass;
	        		var p = $j("." + h + " table");
					var a = p.offset();
	                var b = p.width();
	                var c = p.height();
	                $j("body").append("<div id='waiting'></div>");
	                $j("#waiting").css({                           
	                	top: a.top,
	                    left: a.left,
	                    width:b,
	                    height:c
					}).show();
	        		$j("form[name='time_control']").submit();
	        	}
        	}        
        },
        _highlightCalendarEvents: function(f) {
        	
        	
        	var g = this._get(f, 'actionurl');
            var h = this._inlineClass;
           
            var i = parseInt(this._mySelectedMonth)+1;
            var j = parseInt(this._mySelectedYear);
          
            if (i < 10) i = "0" + i;
            var k = $j("." + h)[0].offsetLeft + 80;
            var l = $j("." + h)[0].offsetTop + 90;
            if (g && i && j) {            
                $j.ajax({
                    type: "POST",
                    url: g,
                    data: "monat=" + i + "&jahr=" + j + "&type=highlight",
                    beforeSend: function() {
                        var p = $j("." + h + " table");
                        var a = p.offset();
                        var b = p.width();
                        var c = p.height();
                        $j("body").append("<div id='waiting'></div>");
                        $j("#waiting").css({                           
                            top: a.top,
                            left: a.left,
                            width:b,
                            height:c
                        }).show();
                    },
                     success: function(a) {
                    	var b = [];
                       	b = a.split("|");
                       	$j.each(b,
                        function(b) {
                    		$j("table.ui-datepicker td a#" + this + "").addClass("highlight")
                        });                       
                        $j("." + h + " table").css("visibility", "visible");
                        $j("#waiting").remove();
                        tooltip();
                    }
                });
            }
            
            
            
        },
        _checkOffset: function(a, b, c) {
            var d = a.input ? this._findPos(a.input[0]) : null;
            var e = window.innerWidth || document.documentElement.clientWidth;
            var f = window.innerHeight || document.documentElement.clientHeight;
            var g = document.documentElement.scrollLeft || document.body.scrollLeft;
            var h = document.documentElement.scrollTop || document.body.scrollTop;
            if (this._get(a, 'isRTL') || (b.left + a.dpDiv.width() - g) > e) b.left = Math.max((c ? 0 : g), d[0] + (a.input ? a.input.width() : 0) - (c ? g: 0) - a.dpDiv.width() - (c && $.browser.opera ? document.documentElement.scrollLeft: 0));
            else b.left -= (c ? g: 0);
            if ((b.top + a.dpDiv.height() - h) > f) b.top = Math.max((c ? 0 : h), d[1] - (c ? h: 0) - (this._inDialog ? 0 : a.dpDiv.height()) - (c && $.browser.opera ? document.documentElement.scrollTop: 0));
            else b.top -= (c ? h: 0);
            return b
        },
        _findPos: function(a) {
            while (a && (a.type == 'hidden' || a.nodeType != 1)) {
                a = a.nextSibling
            }
            var b = $(a).offset();
            return [b.left, b.top]
        },
        _hideDatepicker: function(a, b) {
            var c = this._curInst;
            if (!c || (a && c != $.data(a, bl))) return;
            var d = this._get(c, 'rangeSelect');
            if (d && c.stayOpen) this._selectDate('#' + c.id, this._formatDate(c, c.currentDay, c.currentMonth, c.currentYear));
            c.stayOpen = false;
            if (this._datepickerShowing) {
                b = (b != null ? b: this._get(c, 'duration'));
                var e = this._get(c, 'showAnim');
                var f = function() {
                    $.datepicker._tidyDialog(c)
                };
                if (b != '' && $.effects && $.effects[e]) c.dpDiv.hide(e, $.datepicker._get(c, 'showOptions'), b, f);
                else c.dpDiv[(b == '' ? 'hide': (e == 'slideDown' ? 'slideUp': (e == 'fadeIn' ? 'fadeOut': 'hide')))](b, f);
                if (b == '') this._tidyDialog(c);
                var g = this._get(c, 'onClose');
                if (g) g.apply((c.input ? c.input[0] : null), [(c.input ? c.input.val() : ''), c]);
                this._datepickerShowing = false;
                this._lastInput = null;
                c.settings.prompt = null;
                if (this._inDialog) {
                    this._dialogInput.css({
                        position: 'absolute',
                        left: '0',
                        top: '-100px'
                    });
                    if ($.blockUI) {
                        $.unblockUI();
                        $('body').append(this.dpDiv)
                    }
                }
                this._inDialog = false
            }
            this._curInst = null
        },
        _tidyDialog: function(a) {
            a.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker');
            $('.' + this._promptClass, a.dpDiv).remove()
        },
        _checkExternalClick: function(a) {
            if (!$.datepicker._curInst) return;
            var b = $(a.target);
            if ((b.parents('#' + $.datepicker._mainDivId).length == 0) && !b.hasClass($.datepicker.markerClassName) && !b.hasClass($.datepicker._triggerClass) && $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI)) $.datepicker._hideDatepicker(null, '')
        },
        _adjustDate: function(a, b, c) {
            var d = $(a);
            var e = this._getInst(d[0]);
            
                       
            this._adjustInstDate(e, b, c);
            //SKEN
           // 
            this._updateDatepicker(e);
           
           (this._get(e, 'highlight') ? this._highlightCalendarEvents(e) : '');
        },
        _gotoToday: function(a) {
            var b = $(a);
            var c = this._getInst(b[0]);
            if (this._get(c, 'gotoCurrent') && c.currentDay) {
                c.selectedDay = c.currentDay;
                c.drawMonth = c.selectedMonth = c.currentMonth;
                c.drawYear = c.selectedYear = c.currentYear
            } else {
                var d = new Date();
                c.selectedDay = d.getDate();
                c.drawMonth = c.selectedMonth = d.getMonth();
                c.drawYear = c.selectedYear = d.getFullYear()
            }
            this._notifyChange(c);
            this._adjustDate(b)
        },
        _selectMonthYear: function(a, b, c) {
            var d = $(a);
            var e = this._getInst(d[0]);
            e._selectingMonthYear = false;
            e['selected' + (c == 'M' ? 'Month': 'Year')] = e['draw' + (c == 'M' ? 'Month': 'Year')] = parseInt(b.options[b.selectedIndex].value, 10);
            this._notifyChange(e);
            this._adjustDate(d)
        },
        _clickMonthYear: function(a) {
            var b = $(a);
            var c = this._getInst(b[0]);
            if (c.input && c._selectingMonthYear && !$.browser.msie) c.input[0].focus();
            c._selectingMonthYear = !c._selectingMonthYear
        },
        _changeFirstDay: function(a, b) {
            var c = $(a);
            var d = this._getInst(c[0]);
            d.settings.firstDay = b;
            this._updateDatepicker(d)
           
        },
        _selectDay: function(a, b, c, d) {
            if ($(d).hasClass(this._unselectableClass)) return;
            var e = $(a);
            var f = this._getInst(e[0]);
            var g = this._get(f, 'rangeSelect');
            if (g) {
                f.stayOpen = !f.stayOpen;
                if (f.stayOpen) {
                    $('.ui-datepicker td', f.dpDiv).removeClass(this._currentClass);
                    $(d).addClass(this._currentClass)
                }
            }
            f.selectedDay = f.currentDay = $('a', d).html();
            f.selectedMonth = f.currentMonth = b;
            f.selectedYear = f.currentYear = c;
            if (f.stayOpen) {
                f.endDay = f.endMonth = f.endYear = null
            } else if (g) {
                f.endDay = f.currentDay;
                f.endMonth = f.currentMonth;
                f.endYear = f.currentYear
            }
            this._selectDate(a, this._formatDate(f, f.currentDay, f.currentMonth, f.currentYear));
            if (f.stayOpen) {
                f.rangeStart = new Date(f.currentYear, f.currentMonth, f.currentDay);
                this._updateDatepicker(f)
                 
            } else if (g) {
                f.selectedDay = f.currentDay = f.rangeStart.getDate();
                f.selectedMonth = f.currentMonth = f.rangeStart.getMonth();
                f.selectedYear = f.currentYear = f.rangeStart.getFullYear();
                f.rangeStart = null;
                if (f.inline) this._updateDatepicker(f)
           
            }
            this._chosenDate(f)
        },
        _clearDate: function(a) {
            var b = $(a);
            var c = this._getInst(b[0]);
            if (this._get(c, 'mandatory')) return;
            c.stayOpen = false;
            c.endDay = c.endMonth = c.endYear = c.rangeStart = null;
            this._selectDate(b, '')
        },
        _selectDate: function(a, b) {
            var c = $(a);
            var d = this._getInst(c[0]);
            b = (b != null ? b: this._formatDate(d));
            if (this._get(d, 'rangeSelect') && b) b = (d.rangeStart ? this._formatDate(d, d.rangeStart) : b) + this._get(d, 'rangeSeparator') + b;
            if (d.input) d.input.val(b);
            this._updateAlternate(d);
            var e = this._get(d, 'onSelect');
            if (e) e.apply((d.input ? d.input[0] : null), [b, d]);
            else if (d.input) d.input.trigger('change');
            if (d.inline) this._updateDatepicker(d);
            else if (!d.stayOpen) {
                this._hideDatepicker(null, this._get(d, 'duration'));
                this._lastInput = d.input[0];
                if (typeof(d.input[0]) != 'object') d.input[0].focus();
                this._lastInput = null
            }
        },
        _updateAlternate: function(a) {
            var b = this._get(a, 'altField');
            if (b) {
                var c = this._get(a, 'altFormat');
                var d = this._getDate(a);
                dateStr = (isArray(d) ? (!d[0] && !d[1] ? '': this.formatDate(c, d[0], this._getFormatConfig(a)) + this._get(a, 'rangeSeparator') + this.formatDate(c, d[1] || d[0], this._getFormatConfig(a))) : this.formatDate(c, d, this._getFormatConfig(a)));
                $(b).each(function() {
                    $(this).val(dateStr)
                })
            }
        },
        noWeekends: function(a) {
            var b = a.getDay();
            return [(b > 0 && b < 6), '']
        },
        iso8601Week: function(a) {
            var b = new Date(a.getFullYear(), a.getMonth(), a.getDate(), (a.getTimezoneOffset() / -60));
            var c = new Date(b.getFullYear(), 1 - 1, 4);
            var d = c.getDay() || 7;
            c.setDate(c.getDate() + 1 - d);
            if (d < 4 && b < c) {
                b.setDate(b.getDate() - 3);
                return $.datepicker.iso8601Week(b)
            } else if (b > new Date(b.getFullYear(), 12 - 1, 28)) {
                d = new Date(b.getFullYear() + 1, 1 - 1, 4).getDay() || 7;
                if (d > 4 && (b.getDay() || 7) < d - 3) {
                    return 1
                }
            }
            return Math.floor(((b - c) / 86400000) / 7) + 1
        },
        dateStatus: function(a, b) {
            return $.datepicker.formatDate($.datepicker._get(b, 'dateStatus'), a, $.datepicker._getFormatConfig(b))
        },
        parseDate: function(h, k, l) {
            if (h == null || k == null) throw 'Invalid arguments';
            k = (typeof k == 'object' ? k.toString() : k + '');
            if (k == '') return null;
            var m = (l ? l.shortYearCutoff: null) || this._defaults.shortYearCutoff;
            var n = (l ? l.dayNamesShort: null) || this._defaults.dayNamesShort;
            var o = (l ? l.dayNames: null) || this._defaults.dayNames;
            var p = (l ? l.monthNamesShort: null) || this._defaults.monthNamesShort;
            var q = (l ? l.monthNames: null) || this._defaults.monthNames;
            var r = -1;
            var s = -1;
            var t = -1;
            var u = -1;
            var v = false;
            var w = function(a) {
                var b = (B + 1 < h.length && h.charAt(B + 1) == a);
                if (b) B++;
                return b
            };
            var x = function(a) {
                w(a);
                var b = (a == '@' ? 14 : (a == 'y' ? 4 : (a == 'o' ? 3 : 2)));
                var c = b;
                var d = 0;
                while (c > 0 && A < k.length && k.charAt(A) >= '0' && k.charAt(A) <= '9') {
                    d = d * 10 + parseInt(k.charAt(A++), 10);
                    c--
                }
                if (c == b) throw 'Missing number at position ' + A;
                return d
            };
            var y = function(a, b, c) {
                var d = (w(a) ? c: b);
                var e = 0;
                for (var j = 0; j < d.length; j++) e = Math.max(e, d[j].length);
                var f = '';
                var g = A;
                while (e > 0 && A < k.length) {
                    f += k.charAt(A++);
                    for (var i = 0; i < d.length; i++) if (f == d[i]) return i + 1;
                    e--
                }
                throw 'Unknown name at position ' + g;
            };
            var z = function() {
                if (k.charAt(A) != h.charAt(B)) throw 'Unexpected literal at position ' + A;
                A++
            };
            var A = 0;
            for (var B = 0; B < h.length; B++) {
                if (v) if (h.charAt(B) == "'" && !w("'")) v = false;
                else z();
                else switch (h.charAt(B)) {
                case 'd':
                    t = x('d');
                    break;
                case 'D':
                    y('D', n, o);
                    break;
                case 'o':
                    u = x('o');
                    break;
                case 'm':
                    s = x('m');
                    break;
                case 'M':
                    s = y('M', p, q);
                    break;
                case 'y':
                    r = x('y');
                    break;
                case '@':
                    var C = new Date(x('@'));
                    r = C.getFullYear();
                    s = C.getMonth() + 1;
                    t = C.getDate();
                    break;
                case "'":
                    if (w("'")) z();
                    else v = true;
                    break;
                default:
                    z()
                }
            }
            if (r < 100) r += new Date().getFullYear() - new Date().getFullYear() % 100 + (r <= m ? 0 : -100);
            if (u > -1) {
                s = 1;
                t = u;
                do {
                    var D = this._getDaysInMonth(r, s - 1);
                    if (t <= D) break;
                    s++;
                    t -= D
                } while ( true )
            }
            var C = new Date(r, s - 1, t);
            if (C.getFullYear() != r || C.getMonth() + 1 != s || C.getDate() != t) throw 'Invalid date';
            return C
        },
        ATOM: 'yy-mm-dd',
        COOKIE: 'D, dd M yy',
        ISO_8601: 'yy-mm-dd',
        RFC_822: 'D, d M y',
        RFC_850: 'DD, dd-M-y',
        RFC_1036: 'D, d M y',
        RFC_1123: 'D, d M yy',
        RFC_2822: 'D, d M yy',
        RSS: 'D, d M y',
        TIMESTAMP: '@',
        W3C: 'yy-mm-dd',
        formatDate: function(e, f, g) {
            if (!f) return '';
            var h = (g ? g.dayNamesShort: null) || this._defaults.dayNamesShort;
            var i = (g ? g.dayNames: null) || this._defaults.dayNames;
            var j = (g ? g.monthNamesShort: null) || this._defaults.monthNamesShort;
            var k = (g ? g.monthNames: null) || this._defaults.monthNames;
            var l = function(a) {
                var b = (r + 1 < e.length && e.charAt(r + 1) == a);
                if (b) r++;
                return b
            };
            var n = function(a, b, c) {
                var d = '' + b;
                if (l(a)) while (d.length < c) d = '0' + d;
                return d
            };
            var o = function(a, b, c, d) {
                return (l(a) ? d[b] : c[b])
            };
            var p = '';
            var q = false;
            if (f) for (var r = 0; r < e.length; r++) {
                if (q) if (e.charAt(r) == "'" && !l("'")) q = false;
                else p += e.charAt(r);
                else switch (e.charAt(r)) {
                case 'd':
                    p += n('d', f.getDate(), 2);
                    break;
                case 'D':
                    p += o('D', f.getDay(), h, i);
                    break;
                case 'o':
                    var s = f.getDate();
                    for (var m = f.getMonth() - 1; m >= 0; m--) s += this._getDaysInMonth(f.getFullYear(), m);
                    p += n('o', s, 3);
                    break;
                case 'm':
                    p += n('m', f.getMonth() + 1, 2);
                    break;
                case 'M':
                    p += o('M', f.getMonth(), j, k);
                    break;
                case 'y':
                    p += (l('y') ? f.getFullYear() : (f.getYear() % 100 < 10 ? '0': '') + f.getYear() % 100);
                    break;
                case '@':
                    p += f.getTime();
                    break;
                case "'":
                    if (l("'")) p += "'";
                    else q = true;
                    break;
                default:
                    p += e.charAt(r)
                }
            }
            return p
        },
        _possibleChars: function(a) {
            var b = '';
            var c = false;
            for (var d = 0; d < a.length; d++) if (c) if (a.charAt(d) == "'" && !lookAhead("'")) c = false;
            else b += a.charAt(d);
            else switch (a.charAt(d)) {
            case 'd':
            case 'm':
            case 'y':
            case '@':
                b += '0123456789';
                break;
            case 'D':
            case 'M':
                return null;
            case "'":
                if (lookAhead("'")) b += "'";
                else c = true;
                break;
            default:
                b += a.charAt(d)
            }
            return b
        },
        _get: function(a, b) {
            return a.settings[b] !== undefined ? a.settings[b] : this._defaults[b]
        },
        _setDateFromField: function(a) {
            var b = this._get(a, 'dateFormat');
            var c = a.input ? a.input.val().split(this._get(a, 'rangeSeparator')) : null;
            a.endDay = a.endMonth = a.endYear = null;
            var d = defaultDate = this._getDefaultDate(a);
            if (c.length > 0) {
                var f = this._getFormatConfig(a);
                if (c.length > 1) {
                    d = this.parseDate(b, c[1], f) || defaultDate;
                    a.endDay = d.getDate();
                    a.endMonth = d.getMonth();
                    a.endYear = d.getFullYear()
                }
                try {
                    d = this.parseDate(b, c[0], f) || defaultDate
                } catch(e) {
                    this.log(e);
                    d = defaultDate
                }
            }
            a.selectedDay = d.getDate();
            a.drawMonth = a.selectedMonth = d.getMonth();
            a.drawYear = a.selectedYear = d.getFullYear();
            a.currentDay = (c[0] ? d.getDate() : 0);
            a.currentMonth = (c[0] ? d.getMonth() : 0);
            a.currentYear = (c[0] ? d.getFullYear() : 0);
            this._adjustInstDate(a)
        },
        _getDefaultDate: function(a) {
            var b = this._determineDate(this._get(a, 'defaultDate'), new Date());
            var c = this._getMinMaxDate(a, 'min', true);
            var d = this._getMinMaxDate(a, 'max');
            b = (c && b < c ? c: b);
            b = (d && b > d ? d: b);
            return b
        },
        _determineDate: function(i, j) {
            var k = function(a) {
                var b = new Date();
                b.setUTCDate(b.getUTCDate() + a);
                return b
            };
            var l = function(a, b) {
                var c = new Date();
                var d = c.getFullYear();
                var e = c.getMonth();
                var f = c.getDate();
                var g = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
                var h = g.exec(a);
                while (h) {
                    switch (h[2] || 'd') {
                    case 'd':
                    case 'D':
                        f += parseInt(h[1], 10);
                        break;
                    case 'w':
                    case 'W':
                        f += parseInt(h[1], 10) * 7;
                        break;
                    case 'm':
                    case 'M':
                        e += parseInt(h[1], 10);
                        f = Math.min(f, b(d, e));
                        break;
                    case 'y':
                    case 'Y':
                        d += parseInt(h[1], 10);
                        f = Math.min(f, b(d, e));
                        break
                    }
                    h = g.exec(a)
                }
                return new Date(d, e, f)
            };
            i = (i == null ? j: (typeof i == 'string' ? l(i, this._getDaysInMonth) : (typeof i == 'number' ? (isNaN(i) ? j: k(i)) : i)));
            return (i && i.toString() == 'Invalid Date' ? j: i)
        },
        _setDate: function(a, b, c) {
            var d = !(b);
            var e = a.selectedMonth;
            var f = a.selectedYear;
            b = this._determineDate(b, new Date());
            a.selectedDay = a.currentDay = b.getDate();
            a.drawMonth = a.selectedMonth = a.currentMonth = b.getMonth();
            a.drawYear = a.selectedYear = a.currentYear = b.getFullYear();
            if (this._get(a, 'rangeSelect')) {
                if (c) {
                    c = this._determineDate(c, null);
                    a.endDay = c.getDate();
                    a.endMonth = c.getMonth();
                    a.endYear = c.getFullYear()
                } else {
                    a.endDay = a.currentDay;
                    a.endMonth = a.currentMonth;
                    a.endYear = a.currentYear
                }
            }
            if (e != a.selectedMonth || f != a.selectedYear) this._notifyChange(a);
            this._adjustInstDate(a);
            if (a.input) a.input.val(d ? '': this._formatDate(a) + (!this._get(a, 'rangeSelect') ? '': this._get(a, 'rangeSeparator') + this._formatDate(a, a.endDay, a.endMonth, a.endYear)))
        },
        _getDate: function(a) {
            var b = (!a.currentYear || (a.input && a.input.val() == '') ? null: new Date(a.currentYear, a.currentMonth, a.currentDay));
            if (this._get(a, 'rangeSelect')) {
                return [a.rangeStart || b, (!a.endYear ? a.rangeStart || b: new Date(a.endYear, a.endMonth, a.endDay))]
            } else return b
        },
        _generateHTML: function(a) {
            var b = new Date();
            b = new Date(b.getFullYear(), b.getMonth(), b.getDate());
            var c = this._get(a, 'showStatus');
            var d = this._get(a, 'initStatus') || '&#xa0;';
            var e = this._get(a, 'isRTL');
            var f = (this._get(a, 'mandatory') ? '': '<div class="ui-datepicker-clear"><a onclick="jQuery.datepicker._clearDate(\'#' + a.id + '\');"' + this._addStatus(c, a.id, this._get(a, 'clearStatus'), d) + '>' + this._get(a, 'clearText') + '</a></div>');
            var g = '<div class="ui-datepicker-control">' + (e ? '': f) + '<div class="ui-datepicker-close"><a onclick="jQuery.datepicker._hideDatepicker();"' + this._addStatus(c, a.id, this._get(a, 'closeStatus'), d) + '>' + this._get(a, 'closeText') + '</a></div>' + (e ? f: '') + '</div>';
            var h = this._get(a, 'prompt');
            var i = this._get(a, 'closeAtTop');
            var j = this._get(a, 'hideIfNoPrevNext');
            var k = this._get(a, 'navigationAsDateFormat');
            var l = this._get(a, 'showBigPrevNext');
            var m = this._getNumberOfMonths(a);
            var n = this._get(a, 'showCurrentAtPos');
            var o = this._get(a, 'stepMonths');
            var p = this._get(a, 'stepBigMonths');
            var q = (m[0] != 1 || m[1] != 1);
            var r = (!a.currentDay ? new Date(9999, 9, 9) : new Date(a.currentYear, a.currentMonth, a.currentDay));
            var s = this._getMinMaxDate(a, 'min', true);
            var t = this._getMinMaxDate(a, 'max');
            var u = a.drawMonth - n;
            var v = a.drawYear;
            if (u < 0) {
                u += 12;
                v--
            }
            if (t) {
                var w = new Date(t.getFullYear(), t.getMonth() - m[1] + 1, t.getDate());
                w = (s && w < s ? s: w);
                while (new Date(v, u, 1) > w) {
                    u--;
                    if (u < 0) {
                        u = 11;
                        v--
                    }
                }
            }
            var x = this._get(a, 'prevText');
            x = (!k ? x: this.formatDate(x, new Date(v, u - o, 1), this._getFormatConfig(a)));
            var y = (l ? this._get(a, 'prevBigText') : '');
            y = (!k ? y: this.formatDate(y, new Date(v, u - p, 1), this._getFormatConfig(a)));
            var z = '<div class="ui-datepicker-prev">' + (this._canAdjustMonth(a, -1, v, u) ? (l ? '<a onclick="jQuery.datepicker._adjustDate(\'#' + a.id + '\', -' + p + ', \'M\');"' + this._addStatus(c, a.id, this._get(a, 'prevBigStatus'), d) + '>' + y + '</a>': '') + '<a onclick="jQuery.datepicker._adjustDate(\'#' + a.id + '\', -' + o + ', \'M\');"' + this._addStatus(c, a.id, this._get(a, 'prevStatus'), d) + '>' + x + '</a>': (j ? '': '')) + '</div>';
            var A = this._get(a, 'nextText');
            A = (!k ? A: this.formatDate(A, new Date(v, u + o, 1), this._getFormatConfig(a)));
            var B = (l ? this._get(a, 'nextBigText') : '');
            B = (!k ? B: this.formatDate(B, new Date(v, u + p, 1), this._getFormatConfig(a)));
            var C = '<div class="ui-datepicker-next">' + (this._canAdjustMonth(a, +1, v, u) ? '<a onclick="jQuery.datepicker._adjustDate(\'#' + a.id + '\', +' + o + ', \'M\');"' + this._addStatus(c, a.id, this._get(a, 'nextStatus'), d) + '>' + A + '</a>' + (l ? '<a onclick="jQuery.datepicker._adjustDate(\'#' + a.id + '\', +' + p + ', \'M\');"' + this._addStatus(c, a.id, this._get(a, 'nextBigStatus'), d) + '>' + B + '</a>': '') : (j ? '': '<label>' + A + '</label><label>' + B + '</label>')) + '</div>';
            var D = this._get(a, 'currentText');
            var E = (this._get(a, 'gotoCurrent') && a.currentDay ? r: b);
            D = (!k ? D: this.formatDate(D, E, this._getFormatConfig(a)));
            var F = (h ? '<div class="' + this._promptClass + '">' + h + '</div>': '') + (i && !a.inline ? g: '') + '<div class="ui-datepicker-links">' + (e ? C: z) + (this._isInRange(a, E) ? '<div class="ui-datepicker-current">' + '<a onclick="jQuery.datepicker._gotoToday(\'#' + a.id + '\');"' + this._addStatus(c, a.id, this._get(a, 'currentStatus'), d) + '>' + D + '</a></div>': '') + (e ? z: C) + '</div>';
            var G = this._get(a, 'firstDay');
            var H = this._get(a, 'changeFirstDay');
            var I = this._get(a, 'dayNames');
            var J = this._get(a, 'dayNamesShort');
            var K = this._get(a, 'dayNamesMin');
            var L = this._get(a, 'monthNames');
            var M = this._get(a, 'beforeShowDay');
            var N = this._get(a, 'highlightWeek');
            var O = this._get(a, 'showOtherMonths');
            var P = this._get(a, 'showWeeks');
            var Q = this._get(a, 'calculateWeek') || this.iso8601Week;
            var R = this._get(a, 'weekStatus');
            var S = (c ? this._get(a, 'dayStatus') || d: '');
            var T = this._get(a, 'statusForDate') || this.dateStatus;
            var U = a.endDay ? new Date(a.endYear, a.endMonth, a.endDay) : r;
            for (var V = 0; V < m[0]; V++) for (var W = 0; W < m[1]; W++) {
                var X = new Date(v, u, a.selectedDay);
                F += '<div class="ui-datepicker-one-month' + (W == 0 ? ' ui-datepicker-new-row': '') + '">' + this._generateMonthYearHeader(a, u, v, s, t, X, V > 0 || W > 0, c, d, L) + '<table class="ui-datepicker" cellpadding="0" cellspacing="0"><thead>' + '<tr class="ui-datepicker-title-row">' + (P ? '<td' + this._addStatus(c, a.id, R, d) + '>' + this._get(a, 'weekHeader') + '</td>': '');
                for (var Y = 0; Y < 7; Y++) {
                    var Z = (Y + G) % 7;
                    var bm = (S.indexOf('DD') > -1 ? S.replace(/DD/, I[Z]) : S.replace(/D/, J[Z]));
                    F += '<td' + ((Y + G + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end-cell"': '') + '>' + (!H ? '<span': '<a onclick="jQuery.datepicker._changeFirstDay(\'#' + a.id + '\', ' + Z + ');"') + this._addStatus(c, a.id, bm, d) + ' title="' + I[Z] + '">' + K[Z] + (H ? '</a>': '</span>') + '</td>'
                }
                F += '</tr></thead><tbody>';
                var bn = this._getDaysInMonth(v, u);
                if (v == a.selectedYear && u == a.selectedMonth) a.selectedDay = Math.min(a.selectedDay, bn);
                var bo = (this._getFirstDayOfMonth(v, u) - G + 7) % 7;
                var bp = new Date(v, u, 1 - bo);
                var bq = new Date(v, u, 1 - bo);
                var br = bq;
                var bs = (q ? 6 : Math.ceil((bo + bn) / 7));
                for (var bt = 0; bt < bs; bt++) {
                    F += '<tr class="ui-datepicker-days-row">' + (P ? '<td class="ui-datepicker-week-col"' + this._addStatus(c, a.id, R, d) + '>' + Q(br) + '</td>': '');
                    for (var Y = 0; Y < 7; Y++) {
                        var bu = (M ? M.apply((a.input ? a.input[0] : null), [br]) : [true, '']);
                        var bv = (br.getMonth() != u);
                        var bw = bv || !bu[0] || (s && br < s) || (t && br > t);
                        F += '<td class="ui-datepicker-days-cell' + ((Y + G + 6) % 7 >= 5 ? ' ui-datepicker-week-end-cell': '') + (bv ? ' ui-datepicker-other-month': '') + (br.getTime() == X.getTime() && u == a.selectedMonth ? ' ui-datepicker-days-cell-over': '') + (bw ? ' ' + this._unselectableClass: '') + (bv && !O ? '': ' ' + bu[1] + (br.getTime() >= r.getTime() && br.getTime() <= U.getTime() ? ' ' + this._currentClass: '') + (br.getTime() == b.getTime() ? ' ui-datepicker-today': '')) + '"' + ((!bv || O) && bu[2] ? ' title="' + bu[2] + '"': '') + (bw ? (N ? ' onmouseover="jQuery(this).parent().addClass(\'ui-datepicker-week-over\');"' + ' onmouseout="jQuery(this).parent().removeClass(\'ui-datepicker-week-over\');"': '') : ' onmouseover="jQuery(this).addClass(\'ui-datepicker-days-cell-over\')' + (N ? '.parent().addClass(\'ui-datepicker-week-over\')': '') + ';' + (!c || (bv && !O) ? '': 'jQuery(\'#ui-datepicker-status-' + a.id + '\').html(\'' + (T.apply((a.input ? a.input[0] : null), [br, a]) || d) + '\');') + '"' + ' onmouseout="jQuery(this).removeClass(\'ui-datepicker-days-cell-over\')' + (N ? '.parent().removeClass(\'ui-datepicker-week-over\')': '') + ';' + (!c || (bv && !O) ? '': 'jQuery(\'#ui-datepicker-status-' + a.id + '\').html(\'' + d + '\');') + '" onclick="jQuery.datepicker._selectDay(\'#' + a.id + '\',' + u + ',' + v + ', this);jQuery.datepicker._toggleTip(\'#' + a.id + '\');"') + '>' + (bv ? (O ? br.getDate() : '&#xa0;') : (bw ? br.getDate() : '<a class=\"tooltip\" id=' + br.getDate() + '>' + br.getDate() + '</a>')) + '</td>';
                        bp.setDate(bp.getDate() + 1);
                        bq.setUTCDate(bq.getUTCDate() + 1);
                        br = (bp > bq ? bp: bq)
                    }
                    F += '</tr>'
                }
                u++;
                if (u > 11) {
                    u = 0;
                    v++
                }
                F += '</tbody></table></div>'
            }
            F += (c ? '<div style="clear: both;"></div><div id="ui-datepicker-status-' + a.id + '" class="ui-datepicker-status">' + d + '</div>': '') + (!i && !a.inline ? g: '') + '<div style="clear: both;"></div>' + ($.browser.msie && parseInt($.browser.version, 10) < 7 && !a.inline ? '<iframe src="javascript:false;" class="ui-datepicker-cover"></iframe>': '');
            return F
        },
        _generateMonthYearHeader: function(a, b, c, d, e, f, g, h, i, j) {
            d = (a.rangeStart && d && f < d ? f: d);
            var k = this._get(a, 'showMonthAfterYear');
            var l = '<div class="ui-datepicker-header">';
            var m = '';
            if (g || !this._get(a, 'changeMonth')) m += j[b] + '&#xa0;';
            else {
                var n = (d && d.getFullYear() == c);
                var o = (e && e.getFullYear() == c);
                m += '<select class="ui-datepicker-new-month" ' + 'onchange="jQuery.datepicker._selectMonthYear(\'#' + a.id + '\', this, \'M\');" ' + 'onclick="jQuery.datepicker._clickMonthYear(\'#' + a.id + '\');"' + this._addStatus(h, a.id, this._get(a, 'monthStatus'), i) + '>';
                for (var p = 0; p < 12; p++) {
                    if ((!n || p >= d.getMonth()) && (!o || p <= e.getMonth())) m += '<option value="' + p + '"' + (p == b ? ' selected="selected"': '') + '>' + j[p] + '</option>'
                }
                m += '</select>'
            }
            if (!k) l += m;
            if (g || !this._get(a, 'changeYear')) l += c;
            else {
                var q = this._get(a, 'yearRange').split(':');
                var r = 0;
                var s = 0;
                if (q.length != 2) {
                    r = c - 10;
                    s = c + 10
                } else if (q[0].charAt(0) == '+' || q[0].charAt(0) == '-') {
                    r = s = new Date().getFullYear();
                    r += parseInt(q[0], 10);
                    s += parseInt(q[1], 10)
                } else {
                    r = parseInt(q[0], 10);
                    s = parseInt(q[1], 10)
                }
                r = (d ? Math.max(r, d.getFullYear()) : r);
                s = (e ? Math.min(s, e.getFullYear()) : s);
                l += '<select class="ui-datepicker-new-year" ' + 'onchange="jQuery.datepicker._selectMonthYear(\'#' + a.id + '\', this, \'Y\');" ' + 'onclick="jQuery.datepicker._clickMonthYear(\'#' + a.id + '\');"' + this._addStatus(h, a.id, this._get(a, 'yearStatus'), i) + '>';
                for (; r <= s; r++) {
                    l += '<option value="' + r + '"' + (r == c ? ' selected="selected"': '') + '>' + r + '</option>'
                }
                l += '</select>'
            }
            if (k) l += m;
            l += '</div>';
            return l
        },
        _addStatus: function(a, b, c, d) {
            return (a ? ' onmouseover="jQuery(\'#ui-datepicker-status-' + b + '\').html(\'' + (c || d) + '\');" ' + 'onmouseout="jQuery(\'#ui-datepicker-status-' + b + '\').html(\'' + d + '\');"': '')
        },
        _adjustInstDate: function(a, b, c) {
            var d = a.drawYear + (c == 'Y' ? b: 0);
            var e = a.drawMonth + (c == 'M' ? b: 0);
            var f = Math.min(a.selectedDay, this._getDaysInMonth(d, e)) + (c == 'D' ? b: 0);
            var g = new Date(d, e, f);
            var h = this._getMinMaxDate(a, 'min', true);
            var i = this._getMinMaxDate(a, 'max');
            g = (h && g < h ? h: g);
            g = (i && g > i ? i: g);
            a.selectedDay = g.getDate();
            a.drawMonth = a.selectedMonth = g.getMonth();
            a.drawYear = a.selectedYear = g.getFullYear();
            if (c == 'M' || c == 'Y') this._notifyChange(a)
        },
        _notifyChange: function(a) {
            var b = this._get(a, 'onChangeMonthYear');
            if (b) b.apply((a.input ? a.input[0] : null), [a.selectedYear, a.selectedMonth + 1, a])
        },
        _getNumberOfMonths: function(a) {
            var b = this._get(a, 'numberOfMonths');
            return (b == null ? [1, 1] : (typeof b == 'number' ? [1, b] : b))
        },
        _getMinMaxDate: function(a, b, c) {
            var d = this._determineDate(this._get(a, b + 'Date'), null);
            if (d) {
                d.setHours(0);
                d.setMinutes(0);
                d.setSeconds(0);
                d.setMilliseconds(0)
            }
            return (!c || !a.rangeStart ? d: (!d || a.rangeStart > d ? a.rangeStart: d))
        },
        _getDaysInMonth: function(a, b) {
            return 32 - new Date(a, b, 32).getDate()
        },
        _getFirstDayOfMonth: function(a, b) {
            return new Date(a, b, 1).getDay()
        },
        _canAdjustMonth: function(a, b, c, d) {
            var e = this._getNumberOfMonths(a);
            var f = new Date(c, d + (b < 0 ? b: e[1]), 1);
            if (b < 0) f.setDate(this._getDaysInMonth(f.getFullYear(), f.getMonth()));
            return this._isInRange(a, f)
        },
        _isInRange: function(a, b) {
            var c = (!a.rangeStart ? null: new Date(a.selectedYear, a.selectedMonth, a.selectedDay));
            c = (c && a.rangeStart < c ? a.rangeStart: c);
            var d = c || this._getMinMaxDate(a, 'min');
            var e = this._getMinMaxDate(a, 'max');
            return ((!d || b >= d) && (!e || b <= e))
        },
        _getFormatConfig: function(a) {
            var b = this._get(a, 'shortYearCutoff');
            b = (typeof b != 'string' ? b: new Date().getFullYear() % 100 + parseInt(b, 10));
            return {
                shortYearCutoff: b,
                dayNamesShort: this._get(a, 'dayNamesShort'),
                dayNames: this._get(a, 'dayNames'),
                monthNamesShort: this._get(a, 'monthNamesShort'),
                monthNames: this._get(a, 'monthNames')
            }
        },
        _formatDate: function(a, b, c, d) {
            if (!b) {
                a.currentDay = a.selectedDay;
                a.currentMonth = a.selectedMonth;
                a.currentYear = a.selectedYear
            }
            var e = (b ? (typeof b == 'object' ? b: new Date(d, c, b)) : new Date(a.currentYear, a.currentMonth, a.currentDay));
            return this.formatDate(this._get(a, 'dateFormat'), e, this._getFormatConfig(a))
        }
    });
    function extendRemove(a, b) {
        $.extend(a, b);
        for (var c in b) if (b[c] == null || b[c] == undefined) a[c] = b[c];
        return a
    };
    function isArray(a) {
        return (a && (($.browser.safari && typeof a == 'object' && a.length) || (a.constructor && a.constructor.toString().match(/\Array\(\)/))))
    };
    $.fn.datepicker = function(a) {
        if (!$.datepicker.initialized) {
            $(document.body).append($.datepicker.dpDiv).mousedown($.datepicker._checkExternalClick);
            $.datepicker.initialized = true
        }
        var b = Array.prototype.slice.call(arguments, 1);
        if (typeof a == 'string' && (a == 'isDisabled' || a == 'getDate')) return $.datepicker['_' + a + 'Datepicker'].apply($.datepicker, [this[0]].concat(b));
        return this.each(function() {
            typeof a == 'string' ? $.datepicker['_' + a + 'Datepicker'].apply($.datepicker, [this].concat(b)) : $.datepicker._attachDatepicker(this, a)
        })
    };
    $.datepicker = new Datepicker();
    $.datepicker.initialized = false;
    $.datepicker.uuid = new Date().getTime()
})(jQuery);