﻿if(typeof(window["BDP"]) == "undefined") {
   window["BDP"] = {
      };
   }
BasicDatePicker = function(suppressInit) {
   if(!suppressInit) this.init();
   var today = new Date();
   this.todayDate = today.getDate(), this.todayMonth = today.getMonth(), this.todayYear = today.getFullYear(), this.dateCounts = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31), this.selectedYear, this.selectedMonth, this.selectedDay, this.buttonElement, this.valueElement, this.labelElement, this.yearInc, this.params, this.timeout, this.interval, this.$l0i, this.popUp, this.popUpShim, this.monthSelectorShim, this.yearSelectorShim, this.monthSelector, this.yearSelector, this.stayOpen = false, this.cancelFocus = false, this.cancelTextBoxClick, this.isIE, this.isIEWin, this.isOpera, this.isSafari, this.isNS6, this.isIEMac;
   };
BasicDatePicker.prototype.init = function() {
   var ua = navigator.userAgent.toLowerCase();
   var isMac = (ua.indexOf("mac") !=- 1);
   this.isIE = (ua.indexOf("ie") !=- 1);
   this.isOpera = (ua.indexOf("opera") !=- 1);
   this.isSafari = (ua.indexOf("safari") !=- 1);
   this.isNS6 = (ua.indexOf("netscape6/") !=- 1);
   this.isIEWin = (this.isIE && !isMac && !this.isOpera);
   this.isIEMac = (this.isIE && isMac && !this.isOpera);
   };
BasicDatePicker.prototype.ehTextBoxClick = function(buttonElement, valueElement, labelElement, params) {
   this.stayOpen = true;
   if(this.cancelTextBoxClick) {
      this.cancelTextBoxClick = false;
      return false;
      }
   else {
      this.showPopUp(buttonElement, valueElement, labelElement, params);
      }
   };
BasicDatePicker.prototype.showPopUp = function(buttonElement, valueElement, labelElement, params) {
   if(this.cancelFocus) {
      this.cancelFocus = false;
      return false;
      }
   this.inputFocusValue = valueElement.value;
   if(!params.enabled) {
      return false;
      }
   if(this.params != null && (this.params != params)) {
      this.hidePopUp();
      }
   else if(this.params == params && this.buttonElement == buttonElement && this.valueElement == valueElement) {
      this.hidePopUp();
      return false;
      }
   this.buttonElement = buttonElement;
   this.valueElement = valueElement;
   this.labelElement = labelElement;
   this.params = this.loadParams(params);
   if(!this.popUp) {
      this.popUp = document.createElement("DIV");
      with(this.popUp) {
         id = "basicDatePickerPopUp";
         style.position = "absolute";
         style.visibility = "hidden";
         style.zIndex = "100002";
         }
      this.popUp.onclick = this.ehPopUpClick;
      document.body.appendChild(this.popUp);
      }
   if(!this._l0I("onClientBeforeCalendarOpen")) {
      this.hidePopUp();
      return;
      }
   this.parseDate(this.valueElement.value);
   this._l0i();
   var l0i = this.findPosition(this.buttonElement);
   if(this.isIEWin)
   {
   var l0I = this.params.xOffset + l0i.x;
   var lOi = this.params.yOffset + l0i.y;
   }
   else
   {
   var l0I = this.params.xOffset + l0i.x +2;
   var lOi = this.params.yOffset + l0i.y +2;
   }
   var lOI = l0i.y - this.popUp.offsetHeight, loI;
   if(this.isIEWin) lOI -= 1;
   var loi = lOi + this.buttonElement.offsetHeight + this.popUp.offsetHeight;
   if(window.innerHeight) {
      loI = Math.max(window.innerHeight, document.documentElement.clientHeight);
      }
   else {
      loI = (document.documentElement.clientHeight > 0) ? document.documentElement.clientHeight : document.body.clientHeight;
      }
   loI = loI + Math.max(document.documentElement.scrollTop, document.body.scrollTop);
   this.popUp.style.left = (l0I + this.buttonElement.offsetWidth - this.popUp.offsetWidth) + "px";
   this.popUp.style.top = ((loi > loI && lOI > 0) ? lOI : (lOi + this.buttonElement.offsetHeight)) + "px";
   if(parseInt(this.popUp.style.left) < 0) {
      this.popUp.style.left = 0;
      }
   if(parseInt(this.popUp.style.top) < 0) {
      this.popUp.style.top = 0;
      }
   this.popUpShim = this._lOi(this.popUpShim, this.popUp);
   this.popUp.style.visibility = "visible";
   if(!this._l0I("onClientAfterCalendarOpen")) {
      this.hidePopUp();
      return;
      }
   document.onclick = this.ehDocumentClick;
   document.onkeydown = this.ehKeyPress;
   };
BasicDatePicker.prototype._lOi = function(v, o) {
   if(this.isIEWin) {
      if(!v) {
         v = document.createElement("IFRAME");
         with(v) {
            src = "javascript:false;";
            style.position = "absolute";
            style.visibility = "hidden";
            style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
            }
         document.body.appendChild(v);
         }
      with(v) {
         style.width = o.offsetWidth;
         style.height = o.offsetHeight;
         style.top = o.style.top;
         style.left = o.style.left;
         style.zIndex = o.style.zIndex - 1;
         style.visibility = "visible";
         }
      }
   return v;
   };
BasicDatePicker.prototype._lOI = function(v) {
   if(this.isIEWin) {
      if(v) {
         v.style.visibility = "hidden";
         }
      }
   };
BasicDatePicker.prototype.hidePopUp = function() {
   if(!this._l0I("onClientBeforeCalendarClose")) {
      return;
      }
   if(this.popUp) {
      this.popUp.style.visibility = "hidden";
      }
   this.clearTimers();
   this._lOI(this.popUpShim);
   this._loi();
   this.reset();
   document.onclick = null;
   document.onkeydown = null;
   };
BasicDatePicker.prototype._loi = function() {
   if(this.monthSelector) this.monthSelector.style.visibility = "hidden";
   if(this.yearSelector) this.yearSelector.style.visibility = "hidden";
   this._lOI(this.monthSelectorShim);
   this._lOI(this.yearSelectorShim);
   };
BasicDatePicker.prototype.clearTimers = function() {
   if(this.timeout) {
      clearTimeout(this.timeout);
      }
   if(this.interval) {
      clearInterval(this.interval);
      }
   };
BasicDatePicker.prototype._ae = function(e, ev, f, c) {
   if(e.addEventListener) {
      e.addEventListener(ev, f, c);
      return true;
      }
   else if(e.attachEvent) {
      var r = e.attachEvent('on' + ev, f);
      return r;
      }
   else {
      e['on' + ev] = f;
      }
   };
BasicDatePicker.prototype.buildStyleAttributes = function(style, cssClass) {
   var atts = "";
   if(style.length > 0 || cssClass.length > 0) {
      if(style.length > 0) {
         atts += " style=\"" + style + "\"";
         }
      if(cssClass.length > 0) {
         atts += " class=\"" + cssClass + "\"";
         }
      }
   return atts;
   };
BasicDatePicker.prototype._loI = function(year, month, showPrevMonthArrow, showNextMonthArrow) {
   this._loi();
   var viewingPrevMonth = month - 1;
   var viewingPrevMonthYear = year;
   if(viewingPrevMonth ==- 1) {
      viewingPrevMonth = 11;
      viewingPrevMonthYear--;
      }
   var viewingNextMonth = month + 1;
   var viewingNextMonthYear = year;
   if(viewingNextMonth == 12) {
      viewingNextMonth = 0;
      viewingNextMonthYear++;
      }
   var o = "";
   o += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"" + this.buildStyleAttributes(this.params.popUpStyle, this.params.popUpStyleCssClass) + ">";
   o += "<tr><td>";
   if(this.params.showTitle) {
      o += "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"" + this.buildStyleAttributes(this.params.titleStyle, this.params.titleStyleCssClass) + ">";
      o += "<tr>";
      var monthAndYear = "<th>";
      var titleParts = this.tokenizeFormat(this.params.titleFormat);
      var d = new Date(year, month, 1);
      for(var i = 0; i < titleParts.length; i++) {
         if(titleParts[i].indexOf("M") !=- 1) {
            if(this.params.monthSelectorEnabled) {
               monthAndYear += "<span onclick=\"basicDatePicker.ehMonthSelectorClick(this)\" style=\"cursor:pointer;background-color:#ffffff;padding:1px 3px 2px 3px;border-left:1px solid #666;border-right:1px solid #666;border-top:1px solid #666;\">" + this.formatDate(d, titleParts[i]) + "<img src=\"/content/DatePicker/arrow_down.gif\" class=\"arrow_down\"/></span>";
               }
            else {
               monthAndYear += this.formatDate(d, titleParts[i]);
               }
            }
         else if(titleParts[i].indexOf("yy") !=- 1) {
            if(this.params.yearSelectorEnabled) {
               monthAndYear += "<span onclick=\"basicDatePicker.ehYearSelectorClick(this)\" style=\"cursor:pointer;background-color:#ffffff;margin-left:-1px;padding:1px 3px 2px 3px;border-left:1px solid #666;border-right:1px solid #666;border-top:1px solid #666;\">" + this.formatDate(d, titleParts[i]) + "<img src=\"/content/DatePicker/arrow_down.gif\" class=\"arrow_down\"/></span>";
               }
            else {
               monthAndYear += this.formatDate(d, titleParts[i]);
               }
            }
         else {
            monthAndYear += titleParts[i];
            }
         }
      monthAndYear += "</th>";
      if(this.params.showNextPrevMonth) {
         var prevMonth, nextMonth;
         switch(this.params.nextPrevFormat) {
            case "ShortMonth" : prevMonth = this.params.culture.monthNamesAbbr[viewingPrevMonth];
            nextMonth = this.params.culture.monthNamesAbbr[viewingNextMonth];
            break;
            case "FullMonth" : prevMonth = this.params.culture.monthNames[viewingPrevMonth];
            nextMonth = this.params.culture.monthNames[viewingNextMonth];
            break;
            case "Image" : prevMonth = "<img src=\"" + this.params.prevMonthImageUrl + "\"";
            var prevMonthWidthHeight = (this.params.nextPrevMonthImageWidth != "") ? "width:" + this.params.nextPrevMonthImageWidth + ";" : "";
            prevMonthWidthHeight += (this.params.nextPrevMonthImageHeight != "") ? "height:" + this.params.nextPrevMonthImageHeight + ";" : "";
            if(prevMonthWidthHeight != "") prevMonth += " style=\"" + prevMonthWidthHeight + "\"";
            prevMonth += " border=\"0\" alt=\"\"/>";
            nextMonth = "<img src=\"" + this.params.nextMonthImageUrl + "\"";
            var nextMonthWidthHeight = (this.params.nextPrevMonthImageWidth != "") ? "width:" + this.params.nextPrevMonthImageWidth + ";" : "";
            nextMonthWidthHeight += (this.params.nextPrevMonthImageHeight != "") ? "height:" + this.params.nextPrevMonthImageHeight + ";" : "";
            if(nextMonthWidthHeight != "") nextMonth += " style=\"" + nextMonthWidthHeight + "\"";
            nextMonth += " border=\"0\" alt=\"\"/>";
            break;
            case "CustomText" : default : prevMonth = this.params.prevMonthText;
            nextMonth = this.params.nextMonthText;
            break;
            }
         if(showPrevMonthArrow) {
            o += "<td onclick=\"basicDatePicker.viewPrevMonth()\" onmousedown=\"basicDatePicker.clearTimers();basicDatePicker.timeout=setTimeout('basicDatePicker.ehPrevMonthMouseDown()', 400);\" onmouseup=\"basicDatePicker.clearTimers();\" onmouseout=\"basicDatePicker.clearTimers();\"" + this.buildStyleAttributes(this.params.nextPrevStyle, this.params.nextPrevStyleCssClass) + ">";
            o += prevMonth;
            o += "</td>";
            }
         else {
            o += "<td></td>";
            }
         o += monthAndYear;
         if(showNextMonthArrow) {
            o += "<td onclick=\"basicDatePicker.viewNextMonth()\" onmousedown=\"basicDatePicker.clearTimers();basicDatePicker.timeout=setTimeout('basicDatePicker.ehNextMonthMouseDown()', 400);\" onmouseup=\"basicDatePicker.clearTimers();\" onmouseout=\"basicDatePicker.clearTimers();\"" + this.buildStyleAttributes(this.params.nextPrevStyle, this.params.nextPrevStyleCssClass) + ">";
            o += nextMonth;
            o += "</td>";
            }
         else {
            o += "<td></td>";
            }
         }
      else {
         o += monthAndYear;
         }
      o += "</tr>";
      o += "</table>";
      }
   this.dateCounts[1] = (this.isLeapYear(year)) ? 29 : 28;
   /* calendar table */
   o += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"" + this.buildStyleAttributes(this.params.calendarStyle, this.params.calendarStyleCssClass) + ">";
   /* week number header */
   if(this.params.showDayHeader) {
      o += "<thead><tr>";
      if(this.params.showWeekNumbers) {
         o += "<th" + this.buildStyleAttributes(this.params.dayHeaderStyle, this.params.dayHeaderStyleCssClass) + ">&nbsp;</th>";
         }
      /* day of week headers */
      var dayPointer = this.params.firstDayOfWeek;
      for(var i = 0; i < 7; i++, dayPointer++) {
         if(dayPointer == 7) {
            dayPointer = 0;
            }
         o += "<th" + this.buildStyleAttributes(this.params.dayHeaderStyle, this.params.dayHeaderStyleCssClass) + ">";
         switch(this.params.dayNameFormat) {
            case "Short" : o += this.params.culture.dayNamesAbbr[dayPointer];
            break;
            case "Full" : o += this.params.culture.dayNames[dayPointer];
            break;
            case "FirstTwoLetters" : o += this.params.culture.dayNames[dayPointer].substring(0, 2);
            break;
            case "FirstLetter" : default : o += this.params.culture.dayNames[dayPointer].substring(0, 1);
            break;
            }
         o += "</th>";
         }
      o += "</tr></thead>";
      }
   o += "<tbody><tr>";
   var column = 0;
   var startOfMonth = new Date(year, month, 1).getDay();
   startOfMonth = startOfMonth - this.params.firstDayOfWeek;
   if(startOfMonth < 0) {
      startOfMonth = 7 + startOfMonth;
      }
   /* prev month days */
   for(var i = 0; i < startOfMonth; i++, column++) {
      o += this._li0(viewingPrevMonthYear, viewingPrevMonth, this.dateCounts[viewingPrevMonth] - startOfMonth + i + 1, "prev");
      }
   var row = 0;
   /* month days */
   for(var i = 1; i <= this.dateCounts[month]; i++, column++) {
      o += this._li0(year, month, i, "current");
      if(column == 6) {
         if(i < this.dateCounts[month]) {
            o += "</tr><tr>";
            row++;
            column =- 1;
            }
         }
      }
   /* next month days */
   if(column > 0) {
      for (var i = 1; column < 7; i++, column++) {
         o += this._li0(viewingNextMonthYear, viewingNextMonth, i, "next");
         }
      }
   /* 6th row */
   if(this.params.forceSixRows) {
      for(var y = row; y < 5; y++) {
         o += "</tr><tr>";
         for(var x = 0; x < 7; x++, i++) {
            o += this._li0(viewingNextMonthYear, viewingNextMonth, i, "next");
            }
         }
      }
   o += "</tr></tbody>";
   o += "</table>";
   o += "</td></tr>";
   o += "</table>";
   /* Fill TextArea var textArea=document.getElementById("textArea");textArea.value=o; */
   return o;
   };
BasicDatePicker.prototype._l0i = function() {
   var o = "<table cellpadding=\"0\" cellspacing=\"0\" class=\"bdpWrapper\">";
   for(var y = 0; y < this.params.rows; y++) {
      o += "<tr>";
      for(var x = 0; x < this.params.columns; x++) {
         var showPrevMonth = (y == 0 && x == 0);
         var showNextMonth = (y == 0 && x == this.params.columns - 1);
         o += "<td>";
         o += this._loI(this.getVisibleDate().getFullYear(), this.getVisibleDate().getMonth(), showPrevMonth, showNextMonth);
         o += "</td>";
         this.setVisibleDate(this.getVisibleDate());
         }
      o += "</tr>";
      }
   o += "<tr><td colspan=\"" + this.params.columns + "\">";
   var showFooter = (this.params.showTodayButton || this.params.showNoneButton);
   if(showFooter) {
      o += "<div" + this.buildStyleAttributes(this.params.footerStyle, this.params.footerStyleCssClass) + ">";
      if(this.params.showTodayButton) {
         o += "<input type=\"button\" onClick=\"basicDatePicker.selectDate(basicDatePicker.todayYear,basicDatePicker.todayMonth,basicDatePicker.todayDate,true);\" value=\"" + this.params.todayButtonText + "\"" + this.buildStyleAttributes(this.params.todayButtonStyle, this.params.todayButtonStyleCssClass) + " title=\"\"/>";
         }
      if(this.params.showNoneButton) {
         o += "<input type=\"button\" onClick=\"basicDatePicker.clearSelectedDate();\" value=\"" + this.params.noneButtonText + "\"" + this.buildStyleAttributes(this.params.noneButtonStyle, this.params.noneButtonStyleCssClass) + " title=\"\"/>";
         }
      o += "</div>";
      }
   if(this.params.footNoteText != '') {
      o += "<div" + this.buildStyleAttributes(this.params.footNoteStyle, this.params.footNoteStyleCssClass) + ">" + this.params.footNoteText + "</div>";
      }
   o += "</td></tr>";
   o += "</table>";
   this.popUp.innerHTML = o;
   var els = this._gc("bdpDayItem", this.popUp, "a");
   for(i = 0; i < els.length; i++) {
      var dp = els[i].getAttribute("d").split('/');
      this._ae(els[i], 'click', this._oc(dp[0], dp[1], dp[2]), false);
      }
   };
BasicDatePicker.prototype._oc = function(y, m, d) {
   return function() {
      basicDatePicker.selectDate(y, m, d, true);
      return false;
      };
   };
BasicDatePicker.prototype._gc = function(c, n, t) {
   var el, ell, p, e;
   n = (n == null) ? document : n;
   t = (t == null) ? '*':t;
   el = n.getElementsByTagName(t);
   ell = el.length;
   p = new RegExp('(^|\\s)' + c + '(\\s|$)');
   e = new Array();
   for (i = 0, j = 0; i < ell; i++) {
      if(p.test(el[i].className) ) {
         e[j] = el[i];
         j++;
         }
      }
   return e;
   };
BasicDatePicker.prototype._li0 = function(y, m, d, type) {
   var lio = new Date(y, m, d);
   var lIO = null;
   var l0I = lio.getDay(), dayClassName = "";
   var l0i = (l0I != 0 && l0I != 6);
   var lOi = null;
   var lOI = null;
   var loi = true;
   var loI = "";
   var li0 = "";
   switch(type) {
      case "current" : var lI0 = (this.selectedYear == y && this.selectedMonth == m && this.selectedDay == d);
      var liO = (y == this.todayYear && m == this.todayMonth && this.todayDate == d);
      if(lI0 && liO) {
         if(l0i) {
            lOi = this.params.selectedDayTodayDayStyle;
            lOI = this.params.selectedDayTodayDayStyleCssClass;
            }
         else {
            lOi = this.params.selectedDayWeekendDayStyle;
            lOI = this.params.selectedDayWeekendDayStyleCssClass;
            }
         }
      else if(lI0) {
         if(l0i) {
            lOi = this.params.selectedDayStyle;
            lOI = this.params.selectedDayStyleCssClass;
            }
         else {
            lOi = this.params.selectedDayWeekendDayStyle;
            lOI = this.params.selectedDayWeekendDayStyleCssClass;
            }
         }
      else if(liO) {
         if(l0i) {
            lOi = this.params.todayDayStyle;
            lOI = this.params.todayDayStyleCssClass;
            }
         else {
            lOi = this.params.todayDayWeekendDayStyle;
            lOI = this.params.todayDayWeekendDayStyleCssClass;
            }
         }
      else {
         if(l0i) {
            lOi = this.params.dayStyle;
            lOI = this.params.dayStyleCssClass;
            }
         else {
            lOi = this.params.weekendDayStyle;
            lOI = this.params.weekendDayStyleCssClass;
            }
         }
      break;
      case "prev" : case "next" : if(l0i) {
         lOi = this.params.otherMonthDayStyle;
         lOI = this.params.otherMonthDayStyleCssClass;
         }
      else {
         lOi = this.params.otherMonthDayWeekendDayStyle;
         lOI = this.params.otherMonthDayWeekendDayStyleCssClass;
         }
      break;
      }
   if(this.getSpecialDates() != null) {
      lIO = this.getSpecialDates().getByDate(lio);
      for(var i = 0; i < lIO.length; i++) {
         lOi += lIO[i].style;
         lOI += " " + lIO[i].styleCssClass;
         loi = lIO[i].selectable;
         if(lIO[i].text.length > 0) {
            if(i != 0) {
               if(this.isIE || this.isOpera || this.isSafari) {
                  li0 += "\n";
                  }
               else {
                  li0 += ", ";
                  }
               }
            li0 += lIO[i].text;
            }
         if(lIO[i].clientSpecialDateClickFunction.length > 0) {
            loI += "eval(" + lIO[i].clientSpecialDateClickFunction + "(new Date(" + y + "," + m + "," + d + ")));";
            }
         }
      if(lIO.length > 0) {
         loi = false;
         }
      for(var i = 0; i < lIO.length; i++) {
         if(lIO[i].selectable == true) {
            loi = true;
            break;
            }
         }
      }
   var o = "";
   if(this.params.showWeekNumbers && l0I == this.params.firstDayOfWeek) {
      var l1I = this.calculateWeekNumber(y, m, d, this.params.firstDayOfWeek);
      o += "<td" + this.buildStyleAttributes(this.params.weekNumberStyle, this.params.weekNumberStyleCssClass) + ">" + l1I + "</td>";
      }
   o += "<td" + this.buildStyleAttributes(lOi, lOI);
   o += " title=\"" + li0 + "\"";
   if(this.params.dayStatusBarText.length > 0) {
      var lo1 = this.params.dayStatusBarText;
      if(lo1.indexOf("{0}") !=- 1) {
         var dateText = this.formatDate(lio, this.params.dateFormat);
         lo1 = lo1.replace("{0}", dateText);
         }
      o += " onmouseover=\"window.status='" + lo1 + "';return true;\"";
      o += " onmouseout=\"window.status='';return true;\"";
      }
   o += ">";
   var li1 = "basicDatePicker.selectDate(" + y + "," + m + "," + d + ", true);" + loI;
   if(type == "current" || type == "prev" && this.params.showDaysInPrevMonth || type == "next" && this.params.showDaysInNextMonth) {
      if(loi == true && ((l0i && this.params.selectableWeekDays ||!l0i && this.params.selectableWeekendDays) && (type == "current" || type == "prev" && this.params.selectablePrevMonthDays || type == "next" && this.params.selectableNextMonthDays) && (!this.params.maximumDate || this.params.maximumDate >= lio) && (!this.params.minimumDate || this.params.minimumDate <= lio))) {
         o += '<a onclick="return false;" d="' + y + '/' + m + '/' + d + '" class="bdpDayItem" href="#" title="' + li0 + '">' + d + '</a>';
         }
      else {
         o += d;
         }
      }
   else {
      o += "&nbsp;";
      }
   o += "</td>";
   if(!this.isNS6 && this.params.onClientDayRender.length > 0 && eval("window." + this.params.onClientDayRender)) {
      var lI1 = document.createElement("DIV");
      lI1.innerHTML = "<table><tr>" + o + "</tr></table>";
      var l1O = eval(this.params.onClientDayRender + "(this, lio , lI1.firstChild.firstChild.firstChild.firstChild )");
      if(l1O != null && l1O.tagName && l1O.tagName == "TD") {
         var l1o = document.createElement("TR");
         l1o.appendChild(l1O);
         return l1o.innerHTML;
         }
      }
   return o;
   };
BasicDatePicker.prototype.calculateWeekNumber = function(y, m, d, f) {
   var func = this.params["onClientCalculateWeekNumber"];
   if(func != null && func.length > 0 && window[func]) {
      r = window[func](this, {
         startOfWeek : new Date(y, m, d)}
      );
      if(r != null && this.isNumeric(r)) {
         return r;
         }
      };
   var offset = 7 + 1 - new Date(y, 0, 1).getDay();
   if(offset == 8) offset = 1;
   var l1i = ((Date.UTC(y, m, d, 0, 0, 0) - Date.UTC(y, 0, 1, 0, 0, 0)) /1000/60/60/24)+1;
   var w = Math.floor((l1i - offset + 7) / 7);
   if(w == f) {
      y--;
      var lO1 = 7 + 1 - new Date(y, 0, 1).getDay();
      if(lO1 == 2 || lO1 == 8) w = 53;
      else w = 52;
      }
   return w;
   };
/* The following getStyle() and findPosition() functions were based off functions provided in the Yahoo! User Interface Library. See http://developer.yahoo.com/yui/ Copyright (c) 2007, Yahoo! Inc. All rights reserved. */
BasicDatePicker.prototype.getStyle = function(el, property) {
   var value = null;
   var dv = document.defaultView;
   if(el.style[property]) {
      value = el.style[property];
      }
   else if(el.currentStyle && el.currentStyle[property]) {
      value = el.currentStyle[property];
      }
   else if( dv && dv.getComputedStyle ) {
      var converted = "";
      for(var i = 0, len = property.length; i < len; ++i) {
         converted = (property.charAt(i) == property.charAt(i).toUpperCase()) ? converted + '-' + property.charAt(i).toLowerCase() : converted + property.charAt(i);
         }
      if(dv.getComputedStyle(el, "") && dv.getComputedStyle(el, "").getPropertyValue(converted)) {
         value = dv.getComputedStyle(el, "").getPropertyValue(converted);
         }
      }
   return value;
   };
BasicDatePicker.prototype.findPosition = function(el) {
   if(el.parentNode === null) {
      return null;
      }
   var parent = null, box, pos = {
      x : 0, y : 0 };
   if(el.getBoundingClientRect) {
      box = el.getBoundingClientRect();
      var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
      var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
      pos.x = box.left + scrollLeft;
      pos.y = box.top + scrollTop;
      return pos;
      }
   else if(document.getBoxObjectFor) {
      box = document.getBoxObjectFor(el);
      var borderLeft = parseInt(this.getStyle(el, "borderLeftWidth"));
      var borderTop = parseInt(this.getStyle(el, "borderTopWidth"));
      pos.x = box.x - borderLeft;
      pos.y = box.y - borderTop;
      }
   else {
      pos.x = el.offsetLeft;
      pos.y = el.offsetTop;
      parent = el.offsetParent;
      if(parent != el) {
         while (parent) {
            pos.x += parent.offsetLeft;
            pos.y += parent.offsetTop;
            parent = parent.offsetParent;
            }
         }
      if(this.isOpera || this.isSafari && this.getStyle(el, "position") == "absolute" ) {
         pos.x -= document.body.offsetLeft;
         pos.y -= document.body.offsetTop;
         }
      }
   parent = (el.parentNode) ? el.parentNode : null;
   while (parent && parent.tagName.toLowerCase() != "body" && parent.tagName.toLowerCase() != "html") {
      pos.x -= parent.scrollLeft;
      if(!this.isOpera) {
         pos.y -= parent.scrollTop;
         }
      parent = (parent.parentNode) ? parent.parentNode : null;
      }
   return pos;
   };
BasicDatePicker.prototype.viewNextMonth = function() {
   this.setVisibleDate(this.getVisibleDate().addMonths(1));
   if(!this._l0I("onClientBeforeVisibleMonthChanged", this.getVisibleDate())) {
      return;
      }
   this._l0i();
   if(!this._l0I("onClientAfterVisibleMonthChanged")) {
      return;
      }
   };
BasicDatePicker.prototype.viewPrevMonth = function() {
   this.setVisibleDate(this.getVisibleDate().addMonths( - 1));
   if(!this._l0I("onClientBeforeVisibleMonthChanged", this.getVisibleDate())) {
      return;
      }
   this._l0i();
   if(!this._l0I("onClientAfterVisibleMonthChanged")) {
      return;
      }
   };
BasicDatePicker.prototype._l0I = function(arg1, arg2) {
   var r, f = this.params[arg1];
   if(f != null && f.length > 0 && window[f]) {
      r = window[f](this, arg2);
      };
   return (r == false) ? false : true;
   };
BasicDatePicker.prototype.clearSelectedDate = function() {
   this.clear();
   if(this.valueElement.style.display != "none" && !this.valueElement.disabled) {
      this.valueElement.focus();
      }
   this.hidePopUp();
   };
BasicDatePicker.prototype.selectDate = function(y, m, d, hide) {
   if((d) == null || (d) == 0) return;
   this.selectedYear = y, this.selectedMonth = m, this.selectedDay = d;
   this.setVisibleDate(new Date(y, m, 1));
   var prevFormattedDate = this.valueElement.value;
   var newDate = new Date(this.selectedYear, this.selectedMonth, this.selectedDay, 0, 0, 0);
   if(this.params.nullDate != null && newDate.getTime() == this.params.nullDate.getTime()) {
      newDate = null;
      }
   var formattedDate = this.formatDate(newDate, this.params.dateFormat);
   if(prevFormattedDate != formattedDate) {
      if(!this._l0I("onClientBeforeSelectionChanged", new Date(this.selectedYear, this.selectedMonth, this.selectedDay))) {
         return;
         }
      if(this.params.displayType == "Button") {
         this.buttonElement.value = formattedDate;
         }
      else if(this.params.displayType == "HyperLink") {
         this.buttonElement.innerHTML = formattedDate;
         }
      else if(this.labelElement) {
         this.labelElement.innerHTML = formattedDate;
         }
      this.valueElement.value = formattedDate;
      if(this.isIEWin) {
         this.valueElement.fireEvent("onchange");
         }
      else if(document.createEvent) {
         var e = document.createEvent("HTMLEvents");
         e.initEvent("change", true, true );
         this.valueElement.dispatchEvent(e);
         }
      this.clearTimers();
      if(!this._l0I("onClientAfterSelectionChanged")) {
         return;
         }
      if(this.params.autoPostBack && hide) {
         eval(this.params.postBackFunction);
         }
      if(this.params.displayType == "TextBox" || this.params.displayType.indexOf("TextBox") !=- 1 && this.params.openCalendarOnTextBoxFocus) {
         this.cancelFocus = true;
         }
      if(this.valueElement.style.display != "none" && this.cancelFocus) {
         this.valueElement.focus();
         }
      }
   if(hide) {
      this.hidePopUp();
      }
   };
BasicDatePicker.prototype._lI0 = function(num) {
   return (num < 10) ? "0" + num : num;
   };
BasicDatePicker.prototype.formatDate = function(date, f) {
   if(date) {
      var y = date.getFullYear(), m = date.getMonth(), d = date.getDate(), dow = date.getDay();
      f = f.replace("yyyy", y);
      f = f.replace("yy", this._lI0(y % 100));
      f = f.replace("dddd", "{0}");
      f = f.replace("ddd", "{1}");
      f = f.replace("dd", "{2}");
      f = f.replace("d", "{3}");
      f = f.replace("MMMM", "{4}");
      f = f.replace("MMM", "{5}");
      f = f.replace("MM", "{6}");
      f = f.replace("M", "{7}");
      f = f.replace("{0}", this.params.culture.dayNames[dow]);
      f = f.replace("{1}", this.params.culture.dayNamesAbbr[dow]);
      f = f.replace("{2}", this._lI0(d));
      f = f.replace("{3}", d);
      f = f.replace("{4}", this.params.culture.monthNames[m]);
      f = f.replace("{5}", this.params.culture.monthNamesAbbr[m]);
      f = f.replace("{6}", this._lI0(m + 1));
      f = f.replace("{7}", m + 1);
      return f;
      }
   else {
      return null;
      }
   };
BasicDatePicker.prototype.parseDate = function(valueString) {
   this.$l0i = false;
   if(valueString && valueString != null && valueString.length > 0 && valueString != this.params.nullDateText) {
      var format = this.params.dateFormat;
      var i_value = 0, i_format = 0;
      var c, token;
      var x, y;
      var year = null, month = null, date = null;
      while(i_format < format.length) {
         c = format.charAt(i_format);
         token = "";
         while((format.charAt(i_format) == c) && (i_format < format.length)) {
            token += format.charAt(i_format++);
            }
         switch(token) {
            case "d" : case "dd" : date = this.getInt(valueString, i_value, 1, 2);
            if(!date) {
               return null };
            i_value += date.length;
            date = parseInt(date, 10);
            break;
            case "ddd" : for(var i = 0; i < this.params.culture.dayNamesAbbr.length; i++) {
               var dayName = this.params.culture.dayNamesAbbr[i];
               if(valueString.substring(i_value, i_value + dayName.length).toLowerCase() == dayName.toLowerCase()) {
                  i_value += dayName.length;
                  break;
                  }
               }
            break;
            case "dddd" : for(var i = 0; i < this.params.culture.dayNames.length; i++) {
               var dayName = this.params.culture.dayNames[i];
               if(valueString.substring(i_value, i_value + dayName.length).toLowerCase() == dayName.toLowerCase()) {
                  i_value += dayName.length;
                  break;
                  }
               }
            break;
            case "M" : case "MM" : month = this.getInt(valueString, i_value, 1, 2);
            if(!month) {
               return null };
            i_value += month.length;
            month = parseInt(month, 10) - 1;
            break;
            case "MMM" : for(var i = 0; i < this.params.culture.monthNamesAbbr.length; i++) {
               var monthName = this.params.culture.monthNamesAbbr[i];
               if(valueString.substring(i_value, i_value + monthName.length).toLowerCase() == monthName.toLowerCase()) {
                  month = i;
                  i_value += monthName.length;
                  break;
                  }
               }
            break;
            case "MMMM" : for(var i = 0; i < this.params.culture.monthNames.length; i++) {
               var monthName = this.params.culture.monthNames[i];
               if(valueString.substring(i_value, i_value + monthName.length).toLowerCase() == monthName.toLowerCase()) {
                  month = i;
                  i_value += monthName.length;
                  break;
                  }
               }
            break;
            case "yy" : case "yyyy" : if(token == "yyyy") {
               x = 1;
               y = 4;
               }
            if(token == "yy") {
               x = 1;
               y = 2;
               }
            var valuePart = valueString.substring(i_value, i_value + y);
            if(valuePart != null && token == "yyyy" && valuePart.length <= 4 && !this.isNumeric(valuePart) && valuePart.indexOf("/") < 1 && valuePart.indexOf("-") < 1 && valuePart.indexOf(" ") < 1) {
               break;
               }
            year = this.getInt(valueString, i_value, x, y);
            if(year != null) {
               i_value += year.length;
               if(year.length <= 2) {
                  year = this.getFullYear(year);
                  }
               }
            break;
            default : i_value += token.length;
            }
         }
      if(year == null || isNaN(year)) {
         year = this.todayYear;
         }
      if(date == null || month == null || isNaN(date) || isNaN(month) || date == 0 || month < 0) {
         var tempDate = this.tryParseDate(valueString, this.params.dateOrder);
         if(tempDate == null) {
            return null;
            }
         else {
            this.$l0i = true;
            this.selectDate(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate());
            return new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate());
            }
         }
      else {
         this.dateCounts[1] = (this.isLeapYear(year)) ? 29 : 28;
         if(date > this.dateCounts[month] || month > 11 || new Date(year, month, date) == this.params.nullDate) {
            return null;
            }
         this.$l0i = true;
         this.selectDate(year, month, date);
         return new Date(year, month, date);
         }
      }
   else {
      if(valueString != null) {
         this.clear();
         this.$l0i = true;
         }
      return null;
      }
   };
BasicDatePicker.prototype.getFullYear = function(year) {
   if(year > this.params.twoDigitYearBreak) {
      year = 1900 + (year - 0);
      return year;
      }
   else {
      year = 2000 + (year - 0);
      return year;
      }
   };
BasicDatePicker.prototype.tryParseDate = function(val, dateOrder) {
   /* Logic based on Microsoft(c) Validator ValidatorConvert() function */
   /* in order to provide consistent results between Microsoft and BasicDatePicker Date validation routines. */
   var yearFirstExp = new RegExp("^\\s*((\\d{4})|(\\d{2}))([,.-/ ]|\\. ?)(\\d{1,2})\\4(\\d{1,2})\\s*$");
   m = val.match(yearFirstExp);
   var d1, m1, y1;
   if(m != null && m[2] && (m[2].length == 4 || dateOrder == "ymd")) {
      d1 = m[6];
      m1 = m[5];
      y1 = (m[2].length == 4) ? m[2] : this.getFullYear(parseInt(m[3], 10))}
   else {
      if(dateOrder == "ymd") {
         return null;
         }
      var yearLastExp = new RegExp("^\\s*(\\d{1,2})([,.-/ ]|\\. ?)(\\d{1,2})\\2((\\d{4})|(\\d{2}))\\s*$");
      m = val.match(yearLastExp);
      if(m == null) {
         return null;
         }
      if(dateOrder == "mdy") {
         if(this.isNumeric(m[1]) && m[1] < 12) {
            d1 = m[3];
            m1 = m[1];
            }
         else {
            return this.tryParseDate(val, "dmy");
            }
         }
      else {
         d1 = m[1];
         m1 = m[3];
         }
      y1 = (m[5] && m[5].length == 4) ? m[5] : this.getFullYear(parseInt(m[6], 10))}
   m1 -= 1;
   var date = new Date(y1, m1, d1);
   if(y1 < 100) {
      date.setFullYear(y1);
      }
   return (date != null) ? date : null;
   };
BasicDatePicker.prototype.getInt = function(str, i, minlength, maxlength) {
   for(var x = maxlength; x >= minlength; x--) {
      var valuePart = str.substring(i, i + x);
      if(valuePart.length < minlength) {
         return null;
         }
      if(this.isNumeric(valuePart)) {
         return valuePart;
         }
      }
   return null;
   };
/* Event Handlers */
BasicDatePicker.prototype.ehKeyPress = function(e) {
   if(!e) e = window.event;
   if(e.keyCode == 9) basicDatePicker.hidePopUp();
   };
BasicDatePicker.prototype.ehPopUpClick = function(e) {
   basicDatePicker.stayOpen = true;
   };
BasicDatePicker.prototype.ehDocumentClick = function() {
   (!basicDatePicker.stayOpen) ? basicDatePicker.hidePopUp() : basicDatePicker.stayOpen = false;
   };
BasicDatePicker.prototype.ehPrevMonthMouseDown = function() {
   basicDatePicker.interval = setInterval("basicDatePicker.viewPrevMonth()", 150);
   };
BasicDatePicker.prototype.ehNextMonthMouseDown = function() {
   basicDatePicker.interval = setInterval("basicDatePicker.viewNextMonth()", 150);
   };
BasicDatePicker.prototype.ehUpYearMouseDown = function(baseYear) {
   basicDatePicker.interval = setInterval("basicDatePicker.buildYearSelectorLinks(" + (baseYear - 1) + ", -1)", 90);
   };
BasicDatePicker.prototype.ehDownYearMouseDown = function(baseYear) {
   basicDatePicker.interval = setInterval("basicDatePicker.buildYearSelectorLinks(" + (baseYear - 1) + ", 1)", 90);
   };
BasicDatePicker.prototype.ehMonthSelectorClick = function(oSpan) {
   this._loi();
   if(!this.monthSelector) {
      this.monthSelector = document.createElement("DIV");
      with(this.monthSelector) {
         id = "basicDatePickerMonthSelector";
         className = "bdpMonthSelector";
         style.position = "absolute";
         style.zIndex = "100003";
         }
      document.body.appendChild(this.monthSelector);
      }
   this.monthSelector.innerHTML = "";
   var o = "";
   var monthNames = this.params.culture.monthNames;
   for(var i = 0; i < monthNames.length; i++) {
      var className = (i == this.getVisibleDate().getMonth()) ? "bdpMonthSelectorSelectedItem" : "bdpMonthSelectorItem";
      o += '<a href="#" m="' + i + '" onclick="return false;" class="bdpMonthItem ' + className + '">' + monthNames[i] + '</a>';
      }
   this.monthSelector.innerHTML = o;
   var els = this._gc("bdpMonthItem", this.monthSelector, "a");
   for(i = 0; i < els.length; i++) {
      this._ae(els[i], 'click', this._ocm(els[i].getAttribute("m")), false);
      }
   var pos = this.findPosition(oSpan);
   this.monthSelector.style.top = (parseInt(pos.y + oSpan.offsetHeight + this.params.monthSelectorYOffset)) + "px";
   this.monthSelector.style.left = (parseInt(pos.x + this.params.monthSelectorXOffset)) + "px";
   this.monthSelectorShim = this._lOi(this.monthSelectorShim, this.monthSelector);
   this.monthSelector.style.visibility = "visible";
   };
BasicDatePicker.prototype._ocm = function(m) {
   return function() {
      basicDatePicker.ehMonthSelectorMonthClick(m);
      return false;
      };
   };
BasicDatePicker.prototype.ehMonthSelectorMonthClick = function(newMonth) {
   var d = this.getVisibleDate();
   d.setMonth(newMonth);
   this.setVisibleDate(d);
   if(!this._l0I("onClientBeforeVisibleMonthChanged", this.getVisibleDate())) {
      return;
      }
   this._l0i();
   this.ehPopUpClick();
   if(!this._l0I("onClientAfterVisibleMonthChanged")) {
      return;
      }
   };
BasicDatePicker.prototype.ehYearSelectorClick = function(oSpan) {
   this._loi();
   if(!this.yearSelector) {
      this.yearSelector = document.createElement("DIV");
      with(this.yearSelector) {
         id = "basicDatePickerYearSelector";
         className = "bdpYearSelector";
         style.position = "absolute";
         style.zIndex = "100003";
         }
      document.body.appendChild(this.yearSelector);
      }
   this.buildYearSelectorLinks(this.getVisibleDate().getFullYear());
   var pos = this.findPosition(oSpan);
   this.yearSelector.style.top = (parseInt(pos.y + oSpan.offsetHeight + this.params.monthSelectorYOffset)) + "px";
   this.yearSelector.style.left = (parseInt(pos.x + this.params.monthSelectorXOffset)) + "px";
   this.yearSelectorShim = this._lOi(this.yearSelectorShim, this.yearSelector);
   this.yearSelector.style.visibility = "visible";
   };
BasicDatePicker.prototype.ehYearSelectorYearClick = function(newYear) {
   var d = this.getVisibleDate();
   d.setYear(newYear);
   this.setVisibleDate(d);
   if(!this._l0I("onClientBeforeVisibleMonthChanged", this.getVisibleDate())) {
      return;
      }
   this._l0i();
   this.ehPopUpClick();
   if(!this._l0I("onClientAfterVisibleMonthChanged")) {
      return;
      }
   };
BasicDatePicker.prototype.buildYearSelectorLinks = function(baseYear, optTimeoutChange) {
   var p, m, o = "";
   this.yearSelector.innerHTML = "";
   switch(this.params.upDownYearSelectorFormat) {
      case "Image" : p = "<img src=\"" + this.params.upYearSelectorImageUrl + "\"";
      var pWidthHeight = (this.params.upDownYearSelectorImageWidth != "") ? "width:" + this.params.upDownYearSelectorImageWidth + ";" : "";
      pWidthHeight += (this.params.upDownYearSelectorImageHeight != "") ? "height:" + this.params.upDownYearSelectorImageHeight + ";" : "";
      if(pWidthHeight != "") p += " style=\"" + pWidthHeight + "\"";
      p += " border=\"0\" />";
      m = "<img src=\"" + this.params.downYearSelectorImageUrl + "\"";
      var mWidthHeight = (this.params.upDownYearSelectorImageWidth != "") ? "width:" + this.params.upDownYearSelectorImageWidth + ";" : "";
      mWidthHeight += (this.params.upDownYearSelectorImageHeight != "") ? "height:" + this.params.upDownYearSelectorImageHeight + ";" : "";
      if(mWidthHeight != "") m += " style=\"" + mWidthHeight + "\"";
      m += " border=\"0\" />";
      break;
      case "CustomText" : default : p = this.params.downYearSelectorText;
      m = this.params.upYearSelectorText;
      break;
      }
   baseYear = (optTimeoutChange != null) ? (this.yearInc + optTimeoutChange) : parseInt(baseYear);
   o = '<a href="javascript:void(0);" onclick="basicDatePicker.buildYearSelectorLinks(' + (baseYear - 1) + ');" onmousedown="basicDatePicker.clearTimers();basicDatePicker.timeout=setTimeout(\'basicDatePicker.ehUpYearMouseDown(' + baseYear + ')\', 300);if(basicDatePicker.isOpera||basicDatePicker.isSafari)basicDatePicker.ehPopUpClick();" onmouseup="basicDatePicker.clearTimers();" onmouseout="basicDatePicker.clearTimers();" class="bdpYearSelectorImg">' + p + '</a>';
   for(var i = (baseYear - 4); i <= (baseYear + 4); i++) {
      var className = (i == this.getVisibleDate().getFullYear()) ? "bdpYearSelectorSelectedItem" : "bdpYearSelectorItem";
      o += '<a href="#" y="' + i + '" onclick="return false;" class="bdpYearItem ' + className + '">' + i + '</a>';
      }
   o += '<a href="javascript:void(0);" onclick="basicDatePicker.buildYearSelectorLinks(' + (baseYear + 1) + ');" onmousedown="basicDatePicker.clearTimers();basicDatePicker.timeout=setTimeout(\'basicDatePicker.ehDownYearMouseDown(' + baseYear + ')\', 300);if(basicDatePicker.isOpera||basicDatePicker.isSafari)basicDatePicker.ehPopUpClick();" onmouseup="basicDatePicker.clearTimers();" onmouseout="basicDatePicker.clearTimers();" class="bdpYearSelectorImg">' + m + '</a>';
   var children = this.yearSelector.childNodes;
   if(children) {
      for(var i = 0; i < children.length; i++) {
         this.yearSelector.removeChild(children[i]);
         }
      }
   this.yearSelector.innerHTML = o;
   var els = this._gc("bdpYearItem", this.yearSelector, "a");
   for(i = 0; i < els.length; i++) {
      this._ae(els[i], 'click', this._ocy(els[i].getAttribute("y")), false);
      }
   this.yearInc = baseYear;
   };
BasicDatePicker.prototype._ocy = function(y) {
   return function() {
      basicDatePicker.ehYearSelectorYearClick(y);
      return false;
      };
   };
BasicDatePicker.prototype.ehFocus = function(valueElement) {
   this.inputFocusValue = valueElement.value;
   };
BasicDatePicker.prototype.tokenizeFormat = function(format) {
   var self = this;
   var formatCondition = function(i_format, format, c) {
      return ((i_format < format.length) && (format.charAt(i_format) == c));
      };
   return basicDatePicker.tokenize(format, formatCondition);
   };
BasicDatePicker.prototype.tokenizeSpeedDate = function(text) {
   var self = this;
   var formatCondition = function(i_format, format, c) {
      return (((i_format < format.length) && (format.charAt(i_format) == c)) || ((i_format < format.length) && self.isNumeric(format.charAt(i_format))));
      };
   return basicDatePicker.tokenize(text, formatCondition);
   };
BasicDatePicker.prototype.tokenize = function(format, formatCondition) {
   if(format != null && format.length > 0) {
      var tokens = new Array();
      var i_format = 0, c, token;
      while(i_format < format.length) {
         c = format.charAt(i_format);
         token = "";
         while(formatCondition(i_format, format, c)) {
            token += format.charAt(i_format++);
            };
         tokens[tokens.length] = token;
         };
      };
   return tokens;
   };
BasicDatePicker.prototype.selectRange = function(e, start, length) {
   var s = (!start || start < 1) ? 0 : start;
   var l = (isNaN(length) || length < 0) ? 1 : length;
   if(e.createTextRange) {
      var r = e.createTextRange();
      r.moveStart("character", s);
      r.moveEnd("character", s + l - e.value.length);
      r.select();
      }
   else if(e.setSelectionRange) {
      e.setSelectionRange(s, s + l);
      }
   e.focus();
   };
BasicDatePicker.prototype.getPositionStart = function(e) {
   if(e.createTextRange) {
      var c = document.selection.createRange().duplicate();
      c.moveEnd("character", e.value.length);
      var s = e.value.lastIndexOf(c.text);
      if(c.text.trim().lenth < 1) {
         s = e.value.length;
         }
      return s;
      }
   else {
      return e.selectionStart;
      }
   };
BasicDatePicker.prototype.keyPress = function(event, e, bdpId) {
   var bdp = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
   var c = this.getKeyCode(event);
   var s = this.getPositionStart(e);
   if(c == (8 || 9)) {
      return;
      }
   if((c == 33 || c == 34 || c == 38 || c == 40)) {
      if(bdp.getIsNull()) {
         bdp.setSelectedDate(new Date());
         }
      switch(c) {
         case 38 : if(event.ctrlKey) bdp.setSelectedDate(bdp.getSelectedDate().addYears(1));
         else if(event.altKey) bdp.setSelectedDate(bdp.getSelectedDate().addMonths(1));
         else bdp.setSelectedDate(bdp.getSelectedDate().addDays(1));
         this.selectRange(e, s, 1);
         break;
         case 40 : if(event.ctrlKey) bdp.setSelectedDate(bdp.getSelectedDate().addYears( - 1));
         else if(event.altKey) bdp.setSelectedDate(bdp.getSelectedDate().addMonths( - 1));
         else bdp.setSelectedDate(bdp.getSelectedDate().addDays( - 1));
         this.selectRange(e, s, 1);
         break;
         };
      }
   };
BasicDatePicker.prototype.getKeyCode = function(e) {
   return e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
   };
BasicDatePicker.prototype.speedDate = function() {
   var text = this.phraseChecks(this.valueElement.value.toLowerCase().trim()), date = null;
   var tryDate = this.parseDate(text);
   if(text.length < 1 || this.$l0i) {
      return;
      }
   var firstChar = text.charAt(0);
   var firstTwoChar = text.substring(0, 2);
   var t = (text == "t" || firstTwoChar == "t+" || firstTwoChar == "t-");
   var hasOperator = (firstChar == "+" || firstChar == "-" || firstTwoChar.indexOf("+") !=- 1 || firstTwoChar.indexOf("-") !=- 1);
   var isNumber = (this.isNumeric(text) && text <= this.dateCounts[new Date().getMonth()]);
   if(!t && !isNumber && !hasOperator && (this.params.dateFormat.indexOf("-") !=- 1)) {
      return;
      }
   if((t || hasOperator || isNumber)) {
      if(this.inputFocusValue && this.inputFocusValue.trim().length > 0) {
         date = this.parseDate(this.inputFocusValue);
         }
      var tokens = this.tokenizeSpeedDate(text);
      if(date == null || isNumber) {
         date = new Date(this.todayYear, this.todayMonth, this.todayDate, 0, 0, 0) };
      if(isNumber) {
         date.setDate(text);
         }
      if(t) {
         date = new Date();
         }
      if(this.hasTimePicker()) {
         var time = window[this.params.timePickerID].getSelectedTime();
         if(time != null) {
            date.setHours(time.getHours()), date.setMinutes(time.getMinutes()), date.setSeconds(time.getSeconds());
            }
         else {
            date.setHours(0), date.setMinutes(0), date.setSeconds(0);
            }
         }
      if(hasOperator) {
         var increment = (t) ? parseInt(tokens[1], 10) : parseInt(tokens[0], 10);
         var datePart = (t) ? tokens[2] : tokens[1];
         date = (text == "+" || text == "t+") ? date.addDays(1) : date;
         date = (text == "-" || text == "t-") ? date.addDays( - 1) : date;
         if(datePart && increment) {
            switch(datePart) {
               case "d" : date = date.addDays(increment);
               break;
               case "w" : date = date.addDays(increment * 7);
               break;
               case "m" : date = date.addMonths(increment);
               break;
               case "y" : date = date.addYears(increment);
               break;
               };
            }
         else if(increment) {
            date = date.addDays(increment);
            };
         };
      };
   if(date != null) {
      this.setSelectedDate(date);
      this.inputFocusValue = this.getSelectedDateFormatted();
      }
   else {
      this.inputFocusValue = this.valueElement.value;
      }
   };
BasicDatePicker.prototype.ehBlur = function(buttonElement, valueElement, params) {
   this.buttonElement = buttonElement;
   this.valueElement = valueElement;
   this.params = this.loadParams(params);
   if(this.valueElement.value != this.inputFocusValue) {
      if(!this._l0I("onClientBeforeSelectionChanged", this.getSelectedDate())) {
         return;
         };
      this.speedDate();
      if(!this._l0I("onClientAfterSelectionChanged")) {
         return;
         };
      if(this.params.autoPostBack) {
         eval(basicDatePicker.params.postBackFunction);
         };
      };
   if(this.params.displayType != "TextBox" && !this.params.openCalendarOnTextBoxFocus) {
      this.reset();
      };
   };
BasicDatePicker.prototype.reset = function() {
   this.selectedMonth = null;
   this.selectedDay = null;
   this.selectedYear = null;
   this.setVisibleDate(null);
   this.params = null;
   };
BasicDatePicker.prototype.loadParams = function(params) {
   params.culture = eval(params.culture);
   if(params.firstDayOfWeek == 7) {
      params.firstDayOfWeek = params.culture.firstDayOfWeek;
      }
   return params;
   };
   
/* (Public) Helper Methods */
function BasicDatePickerLoadControl(bdpId) {
   var bdp = new BasicDatePicker(true);
   bdp.params = bdp.loadParams(eval(bdpId + "Params"));
   bdp.valueElement = document.getElementById(bdpId + "_textBox");
   bdp.labelElement = null;
   switch(bdp.params.displayType) {
      case "TextBoxAndButton" : bdp.buttonElement = document.getElementById(bdpId + "_button");
      break;
      case "TextBoxAndHyperLink" : bdp.buttonElement = document.getElementById(bdpId + "_hyperLink");
      break;
      case "TextBoxAndImage" : bdp.buttonElement = document.getElementById(bdpId + "_image");
      break;
      case "TextBox" : bdp.buttonElement = document.getElementById(bdpId + "_textBox");
      break;
      case "LabelAndButton" : bdp.buttonElement = document.getElementById(bdpId + "_button");
      bdp.labelElement = document.getElementById(bdpId + "_label");
      break;
      case "LabelAndHyperLink" : bdp.buttonElement = document.getElementById(bdpId + "_hyperLink");
      bdp.labelElement = document.getElementById(bdpId + "_label");
      break;
      case "LabelAndImage" : bdp.buttonElement = document.getElementById(bdpId + "_image");
      bdp.labelElement = document.getElementById(bdpId + "_label");
      break;
      case "Label" : bdp.buttonElement = document.getElementById(bdpId + "_label");
      bdp.labelElement = document.getElementById(bdpId + "_label");
      break;
      case "Button" : bdp.buttonElement = document.getElementById(bdpId + "_button");
      break;
      case "HyperLink" : bdp.buttonElement = document.getElementById(bdpId + "_hyperLink");
      break;
      case "Image" : bdp.buttonElement = document.getElementById(bdpId + "_image");
      break;
      }
   return bdp;
   };


/* Public Methods */
BasicDatePicker.prototype.getControlId = function() {
   return this.params.clientID;
   };
BasicDatePicker.prototype.getMaximumDate = function(bdpId) {
   var self = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
   return (self.params.maximumDate != null) ? self.params.maximumDate : new Date(9999, 11, 1);
   };
BasicDatePicker.prototype.setMaximumDate = function(date, bdpId) {
   var self = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
   self.params.maximumDate = date;
   };
BasicDatePicker.prototype.getMinimumDate = function(bdpId) {
   var self = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
   return (self.params.minimumDate != null) ? self.params.minimumDate : new Date(1, 0, 1);
   };
BasicDatePicker.prototype.setMinimumDate = function(date, bdpId) {
   var self = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
   self.params.minimumDate = date;
   };
BasicDatePicker.prototype.hasTimePicker = function() {
   return (this.params.timePickerID != null && this.params.timePickerID.length > 0);
   };
BasicDatePicker.prototype.setVisibleDate = function(date, bdpId) {
   var self = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
   this.params.visibleDate = date;
   };
BasicDatePicker.prototype.getVisibleDate = function(bdpId) {
   var self = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
   return (this.params.visibleDate == null) ? new Date() : this.params.visibleDate;
   };
BasicDatePicker.prototype.setSelectedDate = function(date, bdpId) {
   var self = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
   if(!self.getEnabled()) {
      return;
      }
   if(date == null || (self.params.nullDate != null && date.getTime() == self.params.nullDate.getTime())) {
      self.clear();
      }
   else {
      self.selectedYear = date.getFullYear();
      self.selectedMonth = date.getMonth();
      self.selectedDay = date.getDate();
      var formattedDate = self.formatDate(date, self.params.dateFormat);
      if(formattedDate == null) {
         formattedDate = "";
         }
      if(self.params.displayType == "Button") {
         self.buttonElement.value = formattedDate;
         }
      else if(self.params.displayType == "HyperLink") {
         self.buttonElement.innerHTML = formattedDate;
         }
      else if(self.labelElement) {
         self.labelElement.innerHTML = formattedDate;
         }
      self.valueElement.value = formattedDate;
      }
   if(self.hasTimePicker()) {
      var time = (date != null) ? new BDP.TimeSpan(null, date.getHours(), date.getMinutes(), date.getSeconds()) : (window[self.params.timePickerID].getIsNull()) ? null : window[self.params.timePickerID].getSelectedTime();
      window[self.params.timePickerID].setSelectedTime(time);
      }
   };
BasicDatePicker.prototype.getSelectedDate = function(bdpId) {
   var self = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
   self.speedDate();
   var date = self.parseDate(self.valueElement.value);
   if(self.hasTimePicker()) {
      var time = window[self.params.timePickerID].getSelectedTime();
      if(time != null) {
         if(date == null) date = new Date();
         return date.addHours(time.getHours()).addMinutes(time.getMinutes()).addSeconds(time.getSeconds());
         }
      }
   return date;
   };
BasicDatePicker.prototype.getSelectedDateFormatted = function(bdpId) {
   var self = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
   var text = self.valueElement.value.trim();
   return (text == "" || text == self.params.nullDateText) ? "" : text;
   };
BasicDatePicker.prototype.getSelectedDateTimeFormatted = function(bdpId) {
   var self = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
   var text = self.valueElement.value.trim();
   var formattedDate = (text == "" || text == self.params.nullDateText) ? "" : text;
   if(self.hasTimePicker()) {
      formattedDate += " " + window[self.params.timePickerID].getSelectedTimeFormatted();
      }
   return formattedDate.trim();
   };
BasicDatePicker.prototype.getSpecialDates = function(bdpId) {
   var self = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
   return (self.params.specialDates.trim().length > 0 && window[self.params.specialDates] && window[self.params.specialDates].dates.length > 0) ? window[self.params.specialDates] : null;
   };
BasicDatePicker.prototype.getEnabled = function(bdpId) {
   var self = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
   return self.params.enabled;
   };
BasicDatePicker.prototype.setEnabled = function(eVal, bdpId) {
   var self = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
   self.valueElement.disabled =!eVal;
   if(self.valueElement.parentElement) {
      self.valueElement.parentElement.disabled =!eVal;
      }
   if(self.buttonElement) self.buttonElement.disabled =!eVal;
   self.params.enabled = eVal;
   };
BasicDatePicker.prototype.isLeapYear = function(year) {
   return (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0));
   };
BasicDatePicker.prototype.getIsDate = function(bdpId) {
   var self = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
   self.getSelectedDate();
   return self.$l0i;
   };
BasicDatePicker.prototype.getIsNull = function(bdpId) {
   var self = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
   return (self.getSelectedDate() == null);
   };
BasicDatePicker.prototype.clear = function(bdpId) {
   var self = (bdpId) ? BasicDatePickerLoadControl(bdpId) : this;
   var prevFormattedDate = self.valueElement.value;
   if(prevFormattedDate != self.params.nullDateText) {
      if(!self._l0I("onClientBeforeSelectionChanged", null)) {
         return;
         }
      self.valueElement.value = self.params.nullDateText;
      self.clearDate = false;
      if(self.params.displayType == "Button") {
         self.buttonElement.value = self.params.buttonText;
         }
      else if(self.params.displayType == "HyperLink") {
         self.buttonElement.innerHTML = self.params.buttonText;
         }
      else if(self.labelElement) {
         self.labelElement.innerHTML = self.params.buttonText;
         }
      if(!self._l0I("onClientAfterSelectionChanged")) {
         return;
         }
      if(self.params.autoPostBack) {
         eval(self.params.postBackFunction);
         }
      }
   if(self.params.displayType == "TextBox" || self.params.displayType.indexOf("TextBox") !=- 1 && self.params.openCalendarOnTextBoxFocus) {
      self.cancelFocus = true;
      }
   if(self.hasTimePicker()) {
      window[self.params.timePickerID].clear();
      }
   };
/* Date, String and Object Helpers */
Date.prototype.addYears = function(number) {
   return new Date(this.getFullYear() + parseInt(number), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds());
   };
Date.prototype.addMonths = function(number) {
   return new Date(this.getFullYear(), this.getMonth() + parseInt(number), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds());
   };
Date.prototype.addDays = function(number) {
   return (new Date(this.getTime() + (parseInt(number) * 24 * 60 * 60 * 1000)));
   };
String.prototype.trim = function() {
   var text = this.toString();
   while ((text.substring(0, 1) == ' ') || (text.substring(0, 1) == '\n') || (text.substring(0, 1) == '\r')) {
      text = text.substring(1, text.length);
      }
   while ((text.substring(text.length - 1, text.length) == ' ') || (text.substring(text.length - 1, text.length) == '\n') || (text.substring(text.length - 1, text.length) == '\r')) {
      text = text.substring(0, text.length - 1);
      }
   return text;
   };
BasicDatePicker.prototype.stripAndClean = function(value) {
   var temp = "";
   for (i = 0; i < value.length; i++) {
      if(value.charAt(i) != " ") {
         temp += value.charAt(i);
         }
      }
   return temp.toLowerCase();
   };
BasicDatePicker.prototype.isNumeric = function(value) {
   var digits = "1234567890";
   for (var i = 0; i < value.length; i++) {
      if(digits.indexOf(value.charAt(i)) ==- 1) {
         return false;
         }
      }
   return true;
   };
BasicDatePicker.prototype.isDate = function(value) {
   return (value.constructor.toString().match(/Date/i)=="Date");
   };
/* Phrase Checking for Date Parsing */
BasicDatePicker.prototype.phraseChecks = function(t) {
   var r, t = this.stripAndClean(t), f = this.params["onClientPreParse"];
   d = new Date();
   if(f != null && f.length > 0 && window[f]) {
      r = window[f](this, t);
      if(r != null) {
         t = (this.isDate(r)) ? this.formatDate(r, this.params.dateFormat) : r;
         }
      };
   switch(t) {
      case "tomorrow" : t = "t+1";
      break;
      case "yesterday" : t = "t-1";
      break;
      case "nextmonth" : t = this.formatDate(d.addMonths(1), this.params.dateFormat);
      break;
      case "lastmonth" : t = this.formatDate(d.addMonths(1), this.params.dateFormat);
      break;
      case "nextweek" : t = this.formatDate(d.addDays(7), this.params.dateFormat);
      break;
      case "lastweek" : t = this.formatDate(d.addDays( - 7), this.params.dateFormat);
      break;
      }
   if(t.indexOf("today") !=- 1) {
      t = t.replace("today", "t");
      };
   if(t.indexOf("day") !=- 1) {
      t = t.replace("days", "d").replace("day", "d");
      };
   if(t.indexOf("week") !=- 1) {
      t = t.replace("weeks", "w").replace("week", "w");
      };
   if(t.indexOf("month") !=- 1) {
      t = t.replace("months", "m").replace("month", "m");
      };
   if(t.indexOf("year") !=- 1) {
      t = t.replace("years", "y").replace("year", "y");
      };
   return this.stripAndClean(t);
   };
if(typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();