AdfRichUIPeer.createPeerClass(AdfDhtmlInputBasePeer, "AdfDhtmlInputDatePeer");
AdfDhtmlInputDatePeer.prototype.getConvertedValue = function(component, submittedValue) {
  var newValue = submittedValue;
  if (component == null) {
    component = this.getComponent();
  }
  var losslessConverter = component.getProperty("_losslessConverter");
  if (!losslessConverter) {
    return AdfDhtmlInputDatePeer.superclass.getConvertedValue.call(this, component, submittedValue);
  } else {
    var converter = component.getConverter();
    if (converter != null) {
      var label = component.getProperty("label");
      try {
        newValue = converter.getAsObject(submittedValue, label);
      } catch (e) {
        try {
          newValue = losslessConverter.getAsObject(submittedValue, label);
        } catch (losslessException) {
          throw e;
        }
      }
    }
  }
  return newValue;
};
AdfDhtmlInputDatePeer.prototype.handleReturnFromChooseComponent = function(inputComponent, hidePopup) {
  if (hidePopup) {
    this._hidePopup(inputComponent);
  }
  var domElementToFocus = AdfAgent.AGENT.isTouchFirstDevice() ? this._getGlyph(inputComponent) : AdfDhtmlEditableValuePeer.getContentNode(inputComponent);
  if (domElementToFocus) {
    AdfFocusUtils.focusElement(domElementToFocus);
  }
  var rootDomElem = this.getDomElement();
  var agent = AdfAgent.AGENT;
  agent.setExpandoProperty(rootDomElem, AdfDhtmlInputDatePeer._UPDATE_FROM_CHOOSEDATE_ATTR, "t");
  this.Validate(inputComponent);
  agent.setExpandoProperty(rootDomElem, AdfDhtmlInputDatePeer._UPDATE_FROM_CHOOSEDATE_ATTR, null);
  this._returnedFromChooseComponent = 1;
};
AdfDhtmlInputDatePeer.prototype.handleUpdateFromChooseComponent = function(inputComponent, propertyName, newValue) {
  if (propertyName == AdfUIValue.VALUE) {
    this._updateLosslessNode(inputComponent, newValue);
    var dateAsString = this.getConvertedObject(inputComponent, newValue);
    this.SetDisplayValue(inputComponent, null, dateAsString);
  } else {
    if (propertyName == AdfDhtmlChooseDatePeer.TIMEZONE_SEL_DISPLAY) {
      var tzDisp = AdfRichUIPeer.CreateSubId(inputComponent.getClientId(), AdfDhtmlInputDatePeer._TIMEZONE_DISPNAME_ID);
      var tzDispNode = AdfAgent.AGENT.getElementById(tzDisp);
      AdfAgent.AGENT.setTextContent(tzDispNode, newValue);
    } else {
      if (propertyName == AdfDhtmlChooseDatePeer.TIMEZONE_SEL_ID) {
        var tzId = AdfRichUIPeer.CreateSubId(inputComponent.getClientId(), AdfDhtmlInputDatePeer._TIMEZONE_DISPID_ID);
        var tzIdNode = AdfAgent.AGENT.getElementById(tzId);
        tzIdNode.value = newValue;
      }
    }
  }
};
AdfDhtmlInputDatePeer.InitSubclass = function() {
  AdfObject.ensureClassInitialization(AdfUIValue);
  AdfObject.ensureClassInitialization(AdfRichChooseDate);
  AdfObject.ensureClassInitialization(AdfRichInputDate);
  AdfObject.ensureClassInitialization(AdfRichPopup);
  AdfObject.ensureClassInitialization(AdfDhtmlChooseDatePeer);
  AdfRichUIPeer.addComponentEventHandlers(this, AdfUIInputEvent.KEY_DOWN_EVENT_TYPE, AdfUIInputEvent.CLICK_EVENT_TYPE, AdfDialogEvent.EVENT_TYPE, AdfUIInputEvent.FOCUS_EVENT_TYPE, AdfValueChangeEvent.VALUE_CHANGE_TYPE);
  AdfRichUIPeer.addComponentPropertyChanges(this, AdfUIValue.VALUE);
  AdfRichUIPeer.addComponentPropertyGetters(this, AdfRichInputDate.MIN_VALUE);
  AdfRichUIPeer.addComponentPropertyGetters(this, AdfRichInputDate.MAX_VALUE);
  AdfRichUIPeer.addComponentPropertyGetters(this, AdfRichInputDate.LABEL);
  AdfRichUIPeer.addComponentPropertyChanges(this, AdfRichInputDate.LABEL);
  this._CHILD_EXPANDO = "child";
  this._LOSSLESS_SUBID = "lcId";
  this._GLYPH_ID = "glyph";
  this._CHOOSEDATE_ID = "cd";
  this._POPUP_ID = "pop";
  this._TIMEZONE_ID = "tz";
  this._TIMEZONE_DISPID_ID = "tzDispId";
  this._TIMEZONE_DISPNAME_ID = "tzDispName";
  this._UPDATE_FROM_CHOOSEDATE_ATTR = "ufc";
  this._MIN_ATTR = "data-afr-adfmin";
  this._MAX_ATTR = "data-afr-adfmax";
  this._MIN_ISO_ATTR = "data-afr-adfmnis";
  this._MAX_ISO_ATTR = "data-afr-adfmxis";
  this._MAX_WIDTH_CENTER_DLG = 768;
};
AdfDhtmlInputDatePeer.prototype.InitDomElement = function(component, domElement) {
  AdfDhtmlInputDatePeer.superclass.InitDomElement.call(this, component, domElement);
  return AdfPage.PAGE.scheduleTimer(this, this._hookUpChooseDate, component.getClientId(), 0);
};
AdfDhtmlInputDatePeer.prototype.ComponentValueChanged = function(component, domElement, newValue, oldValue) {
  AdfDhtmlInputDatePeer.superclass.ComponentValueChanged.call(this, component, domElement, newValue, oldValue);
  if (this._isChooserSuppressed()) {
    var chooseDateId = component.getProperty(AdfRichInputDate.CHOOSE_ID);
    var rootDomElem = this.getDomElement();
    var agent = AdfAgent.AGENT;
    var isHandlingChooserUpdate = agent.getExpandoProperty(rootDomElem, AdfDhtmlInputDatePeer._UPDATE_FROM_CHOOSEDATE_ATTR);
    if (chooseDateId != null && !isHandlingChooserUpdate) {
      AdfDhtmlInputChooseBindingUtils.updateChooseComponentProperty(component, chooseDateId, AdfUIValue.VALUE, AdfDhtmlChooseDatePeer.SELECTED_DATE);
    }
  }
  this._updateLosslessNode(component, newValue);
  var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component, domElement);
  AdfDhtmlInputBasePeer.setLastValue(contentNode);
};
AdfDhtmlInputDatePeer.prototype.Validate = function(component, submittedValue) {
  if (submittedValue != null) {
    this._updateLosslessNode(component, null);
  }
  AdfDhtmlInputDatePeer.superclass.Validate.call(this, component, submittedValue);
};
AdfDhtmlInputDatePeer.prototype.GetSubmittedValue = function(component, domElement) {
  var lcn = this._getLosslessConvertedNode(component);
  if (lcn && lcn.value) {
    return lcn.value;
  } else {
    return AdfDhtmlInputDatePeer.superclass.GetSubmittedValue.call(this, component, domElement);
  }
};
AdfDhtmlInputDatePeer.prototype.GetComponentLabel = function(component, domElement) {
  var agent = AdfAgent.AGENT;
  var labelElements = domElement.getElementsByTagName("LABEL");
  var contentId = AdfRichUIPeer.CreateSubId(component.getClientId(), "content");
  var compLabel = null;
  for (var i = 0;i < labelElements.length;i++) {
    if (agent.getAttribute(labelElements[i], "for") == contentId) {
      compLabel = labelElements[i];
      break;
    }
  }
  return compLabel ? agent.getTextContent(compLabel) : null;
};
AdfDhtmlInputDatePeer.prototype.GetComponentLabel = function(component, domElement) {
  var agent = AdfAgent.AGENT;
  var labelElements = domElement.getElementsByTagName("LABEL");
  var contentId = AdfRichUIPeer.CreateSubId(component.getClientId(), "content");
  var compLabel = null;
  for (var i = 0;i < labelElements.length;i++) {
    if (agent.getAttribute(labelElements[i], "for") == contentId) {
      compLabel = labelElements[i];
      break;
    }
  }
  return compLabel ? agent.getTextContent(compLabel) : null;
};
AdfDhtmlInputDatePeer.prototype.HandleComponentClick = function(componentEvent) {
  AdfDhtmlInputDatePeer.superclass.HandleComponentClick.call(this, componentEvent);
  var sourceComponent = componentEvent.getSource();
  var nativeEvent = componentEvent.getNativeEvent();
  var eventTarget = AdfAgent.AGENT.getEventTarget(nativeEvent);
  var glyphId = AdfRichUIPeer.CreateSubId(sourceComponent.getClientId(), AdfDhtmlInputDatePeer._GLYPH_ID);
  var component = componentEvent.getCurrentTarget();
  if (component != sourceComponent) {
    return;
  }
  if (this._isGlyphElement(eventTarget, glyphId)) {
    this._handleChooseDatePopupLaunch(component);
    componentEvent.cancel();
  }
};
AdfDhtmlInputDatePeer.prototype.HandleComponentDialog = function(componentEvent) {
  var inputDateComp = this.getComponent();
  var outcome = componentEvent.getOutcome();
  if (outcome == AdfDialogEvent.OUTCOME_OK) {
    var chooseDateId = this._getRuntimeChooseDateId(inputDateComp);
    var chooseDateComp = AdfPage.PAGE.findComponent(chooseDateId);
    var chooseDatePeer = chooseDateComp.getPeer();
    chooseDatePeer.bind(chooseDateComp);
    chooseDatePeer.submitValueToInput(null, chooseDateComp);
    componentEvent.cancel();
  } else {
    if (outcome == AdfDialogEvent.OUTCOME_CANCEL) {
      this._hidePopup(inputDateComp);
      var glyph = this._getGlyph(inputDateComp);
      if (glyph != null) {
        AdfFocusUtils.focusElement(glyph);
      }
      componentEvent.cancel();
    }
  }
};
AdfDhtmlInputDatePeer.prototype.HandleComponentFocus = function(componentEvent) {
  AdfDhtmlInputDatePeer.superclass.HandleComponentFocus.call(this, componentEvent);
  var component = this.getComponent();
  var chooseId = AdfDhtmlInputChooseBindingUtils.getChooseId(component);
  if (chooseId != null) {
    AdfDhtmlInputChooseBindingUtils.registerBinding(true, chooseId, component.getClientId());
  }
};
AdfDhtmlInputDatePeer.prototype.RunValidation = function(component, targetNode, isChangeRequired) {
  if (this.WasSubmitted(component)) {
    AdfDhtmlInputDatePeer.superclass.RunValidation.call(this, component, targetNode, isChangeRequired);
    var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component);
    AdfDhtmlInputBasePeer.setLastValue(contentNode, contentNode.value);
  }
};
AdfDhtmlInputDatePeer.prototype.HandleComponentKeyDown = function(componentEvent) {
  var evt = componentEvent.getNativeEvent();
  var keyCode = AdfAgent.AGENT.getKeyCode(evt);
  var cancelEvt = false;
  var component = this.getComponent();
  var sourceComponent = componentEvent.getSource();
  var targetComponent = componentEvent.getCurrentTarget();
  if (targetComponent != sourceComponent) {
    return;
  }
  switch(keyCode) {
    case AdfKeyStroke.ENTER_KEY:
      this.RunValidation(component, componentEvent.getNativeEventTarget());
      break;
    case AdfKeyStroke.ARROWDOWN_KEY:
      if (!this._isChooserSuppressed() && component == sourceComponent) {
        this.RunValidation(component, componentEvent.getNativeEventTarget());
        this._handleChooseDatePopupLaunch(component);
        cancelEvt = true;
      }
      break;
  }
  if (cancelEvt) {
    componentEvent.cancel();
  }
};
AdfDhtmlInputDatePeer.prototype.LazyInitialize = function(component, domElement) {
  AdfDhtmlInputDatePeer.superclass.LazyInitialize.call(this, component, domElement);
  this._createClientSideValidators(component, domElement);
};
AdfDhtmlInputDatePeer.prototype.HandleComponentValueChange = function(componentEvent) {
  var sourceId = componentEvent.getSource().getClientId();
  var component = this.getComponent();
  if (!this._isChooserSuppressed()) {
    return;
  }
  var tzSubId = AdfRichUIPeer.CreateSubId(component.getClientId(), AdfDhtmlInputDatePeer._TIMEZONE_ID);
  if (sourceId == tzSubId) {
    var tzComp = AdfPage.PAGE.findComponent(tzSubId);
    var tzNode = tzComp.getPeer().getDomElement();
    var tzContent = AdfDhtmlEditableValuePeer.getContentNode(tzComp, tzNode);
    var tzId = AdfRichUIPeer.CreateSubId(component.getClientId(), AdfDhtmlInputDatePeer._TIMEZONE_DISPID_ID);
    var tzIdNode = AdfAgent.AGENT.getElementById(tzId);
    tzIdNode.value = tzContent.value;
  }
};
AdfDhtmlInputDatePeer.prototype.IsSecret = function(component) {
  return false;
};
AdfDhtmlInputDatePeer.prototype.SetDisplayValue = function(component, domElement, newValue) {
  AdfAssert.assertString(newValue);
  var domNode = AdfDhtmlEditableValuePeer.getContentNode(component, domElement);
  var domNodeTagName = AdfAgent.AGENT.getNodeName(domNode);
  var isInput = domNodeTagName == "INPUT";
  if (component.getReadOnly()) {
    AdfAgent.AGENT.setTextContent(domNode, newValue);
  } else {
    domNode.title = newValue;
    if (isInput) {
      domNode.value = newValue;
    } else {
      AdfAgent.AGENT.setTextContent(domNode, newValue);
    }
  }
};
AdfDhtmlInputDatePeer.prototype.VetoShowNoteWindow = function(component) {
  if (this._isPopupVisible(component)) {
    return true;
  }
  if (!this._isChooserSuppressed()) {
    var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component);
    if (AdfPage.PAGE.getActiveDomElement() != contentNode) {
      return true;
    }
  }
  return AdfDhtmlInputDatePeer.superclass.VetoShowNoteWindow.call(this);
};
AdfDhtmlInputDatePeer.prototype.GetComponentMinValue = function(component, domElement) {
  var inputDom = AdfDhtmlEditableValuePeer.getContentNode(component);
  var minISOString = AdfAgent.AGENT.getAttribute(inputDom, AdfDhtmlInputDatePeer._MIN_ISO_ATTR, -1);
  if (minISOString) {
    return AdfDhtmlInputDatePeer._getISOStandardConverter().getAsObject(minISOString);
  }
  return null;
};
AdfDhtmlInputDatePeer.prototype.GetComponentMaxValue = function(component, domElement) {
  var inputDom = AdfDhtmlEditableValuePeer.getContentNode(component);
  var maxISOString = AdfAgent.AGENT.getAttribute(inputDom, AdfDhtmlInputDatePeer._MAX_ISO_ATTR, -1);
  if (maxISOString) {
    return AdfDhtmlInputDatePeer._getISOStandardConverter().getAsObject(maxISOString);
  }
  return null;
};
AdfDhtmlInputDatePeer.prototype.GetInlineEditor = function(event) {
  return AdfDhtmlSimpleLabelEditor.getInlineEditor();
};
AdfDhtmlInputDatePeer.prototype.setSelectedDate = function(selectedDate) {
  var chooseDateId = this._getRuntimeChooseDateId(this.getComponent());
  var chooseDateComp = AdfPage.PAGE.findComponent(chooseDateId);
  if (chooseDateComp) {
    chooseDateComp.setSelectedDate(selectedDate);
  }
};
AdfDhtmlInputDatePeer.prototype.__trace = function(txt) {
  AdfLogger.LOGGER.severe("InputDatePeer: " + txt);
};
AdfDhtmlInputDatePeer.prototype._handleChooseDatePopupLaunch = function(component) {
  var popupComponent = this._getPopup(component);
  if (popupComponent != null) {
    if (!popupComponent.isPopupVisible()) {
      this.HideNoteWindow();
      var chooseDateId = this._getRuntimeChooseDateId(component);
      var chooseDateRoot = AdfAgent.AGENT.getElementById(chooseDateId);
      var chooseDateComp = AdfPage.PAGE.findComponent(chooseDateId);
      this._updateChooseDateExpandos(component, chooseDateRoot, chooseDateComp);
      var chooseDatePeer = chooseDateComp.getPeer();
      chooseDatePeer.bind(chooseDateComp);
      chooseDatePeer.refresh();
      popupComponent.show(this._getChooserPopupHints(component));
    } else {
      popupComponent.hide();
    }
  } else {
    this._showPopup(component);
  }
};
AdfDhtmlInputDatePeer.prototype._createClientSideValidators = function(component, domElement) {
  AdfAssert.assertDomElement(domElement);
  var inputDom = AdfDhtmlEditableValuePeer.getContentNode(component);
  var min = AdfAgent.AGENT.getAttribute(inputDom, AdfDhtmlInputDatePeer._MIN_ATTR, -1);
  var max = AdfAgent.AGENT.getAttribute(inputDom, AdfDhtmlInputDatePeer._MAX_ATTR, -1);
  var month = component.getDisabledMonths();
  var days = component.getDisabledDaysOfWeek();
  if (min || max) {
    var minISO = AdfAgent.AGENT.getAttribute(inputDom, AdfDhtmlInputDatePeer._MIN_ISO_ATTR, -1);
    var maxISO = AdfAgent.AGENT.getAttribute(inputDom, AdfDhtmlInputDatePeer._MAX_ISO_ATTR, -1);
    var rangeValidator = new TrDateTimeRangeValidator(max, min, null, maxISO, minISO);
    component.addValidator(rangeValidator);
  }
  if (days || month) {
    var restrictionValidator = new TrDateRestrictionValidator(days, month, null);
    component.addValidator(restrictionValidator);
  }
};
AdfDhtmlInputDatePeer.prototype._getGlyph = function(component) {
  var glyphId = AdfRichUIPeer.CreateSubId(component.getClientId(), AdfDhtmlInputDatePeer._GLYPH_ID);
  var glyph = AdfAgent.AGENT.getElementById(glyphId);
  return glyph;
};
AdfDhtmlInputDatePeer.prototype._getPopup = function(component) {
  var popupId = this._getPopupId(component);
  var popup = AdfPage.PAGE.findComponent(popupId);
  return popup;
};
AdfDhtmlInputDatePeer.prototype._showPopup = function(component) {
  var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component);
  var ownerDoc = contentNode.ownerDocument;
  var agent = AdfAgent.AGENT;
  var popupId = this._getPopupId(component);
  var page = AdfPage.PAGE;
  var popupComponent = page.findComponent(popupId);
  var chooseDateClientId = this._getRuntimeChooseDateId(component);
  var chooseDateRoot = agent.getElementById(chooseDateClientId);
  var chooseDateComp = page.findComponent(chooseDateClientId);
  if (agent.getElementById(popupId) == null) {
    var popupContainerDiv = ownerDoc.createElement("div");
    contentNode.parentNode.appendChild(popupContainerDiv);
    agent.setAttribute(popupContainerDiv, "id", popupId);
    agent.setAttribute(popupContainerDiv, "style", "display:none");
    var popupContentSubid = AdfRichUIPeer.CreateSubId(popupId, "content");
    var popupContentContainerDiv = ownerDoc.createElement("div");
    popupContainerDiv.appendChild(popupContentContainerDiv);
    agent.setAttribute(popupContentContainerDiv, "id", popupContentSubid);
    var popupContainerStyling = "top:auto; right:auto; left:auto; bottom:auto; width:auto; height:auto; position:relative;";
    agent.setAttribute(popupContentContainerDiv, "style", popupContainerStyling);
    chooseDateRoot = ownerDoc.createElement("span");
    popupContentContainerDiv.appendChild(chooseDateRoot);
    agent.setAttribute(chooseDateRoot, "id", chooseDateClientId);
    agent.setAttribute(chooseDateRoot, "class", page.getLookAndFeel().getStyleClass("af|chooseDate"));
    popupComponent = new AdfRichPopup(popupId, {"contentDelivery":"immediate"});
    chooseDateComp = new AdfRichChooseDate(chooseDateClientId);
    this._updateChooseDateExpandos(component, chooseDateRoot, chooseDateComp);
    agent.elementsAdded(popupContainerDiv);
    page.addComponents(chooseDateComp, popupComponent);
  } else {
    this._updateChooseDateExpandos(component, chooseDateRoot, chooseDateComp);
  }
  var chooseDatePeer = chooseDateComp.getPeer();
  chooseDatePeer.BindToComponent(chooseDateComp, chooseDateRoot);
  chooseDatePeer.refresh();
  AdfObject.ensureClassInitialization(AdfRichPopup);
  popupComponent.show(this._getChooserPopupHints(component));
};
AdfDhtmlInputDatePeer.prototype._updateChooseDateExpandos = function(inputDateComponent, chooseDateRoot, chooseDateComponent) {
  AdfAssert.assert(inputDateComponent != null);
  var agent = AdfAgent.AGENT;
  if (chooseDateRoot == null) {
    var chooseDateClientId = this._getRuntimeChooseDateId(inputDateComponent);
    chooseDateRoot = agent.getElementById(chooseDateClientId);
  }
  var lnf = AdfPage.PAGE.getLookAndFeel();
  var _loc = lnf.getSkinProperty(AdfDhtmlChooseDatePeer._LOCALE);
  agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._LOCALE, _loc);
  agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._PARENT_ID, inputDateComponent.getClientId());
  agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._DISPLAY_MODE, AdfDhtmlChooseDatePeer._DATE_AND_TIME_MODE);
  var layouts = inputDateComponent.getLayout();
  var layoutStr = "";
  if (!layouts || layouts.length == 0) {
    layoutStr = AdfDhtmlInputDatePeer._getSkinDeterminedLayouts();
  } else {
    for (var i = 0;i < layouts.length;i++) {
      layoutStr += layouts[i] + " ";
    }
  }
  agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._LAYOUT, layoutStr);
  var contentNode = AdfDhtmlEditableValuePeer.getContentNode(inputDateComponent);
  var todayStr = agent.getAttribute(contentNode, AdfDhtmlChooseDatePeer._TODAY_DATE);
  if (todayStr != null) {
    agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._TODAY_DATE, todayStr);
  }
  var dateTimeConverter = AdfDhtmlInputDatePeer._getISOStandardConverter();
  var value = inputDateComponent.getValue();
  var valStr = null;
  if (value == null) {
    var defaultValue = inputDateComponent.getDefaultValue();
    if (defaultValue != null) {
      valStr = dateTimeConverter.getAsString(defaultValue);
    }
  } else {
    valStr = dateTimeConverter.getAsString(value);
  }
  if (chooseDateComponent) {
    if (inputDateComponent.getDisabledDays() != null) {
      chooseDateComponent.setDisabledDays(inputDateComponent.getDisabledDays());
    }
    chooseDateComponent.setDisabledMonths(inputDateComponent.getDisabledMonths());
    chooseDateComponent.setDisabledDaysOfWeek(inputDateComponent.getDisabledDaysOfWeek());
    chooseDateComponent.setDefaultValue(inputDateComponent.getDefaultValue());
    var months = inputDateComponent.getMonths ? inputDateComponent.getMonths() : null;
    if (!months || months < 1) {
      months = AdfDhtmlInputDatePeer._getSkinDeterminedMonths();
    }
    chooseDateComponent.setMonths(Math.max(1, months));
    var minValStr = agent.getAttribute(contentNode, AdfDhtmlInputDatePeer._MIN_ISO_ATTR);
    chooseDateComponent.setMinValue(minValStr);
    var maxValStr = agent.getAttribute(contentNode, AdfDhtmlInputDatePeer._MAX_ISO_ATTR);
    chooseDateComponent.setMaxValue(maxValStr);
  }
  if (valStr) {
    agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._SELECTED_DATE_TIME, valStr);
    var date = dateTimeConverter.getAsObject(valStr);
    date.setDate(1);
    agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._SHOW_DATE, dateTimeConverter.getAsString(date));
  } else {
    if (todayStr != null) {
      var todayDate = dateTimeConverter.getAsObject(todayStr);
      var maxValDate = inputDateComponent.getMaxValue();
      var minValDate = inputDateComponent.getMinValue();
      if (AdfDhtmlChooseDateDOMQueries.isDateAfterMaximumDate(chooseDateComponent, todayDate)) {
        todayDate = maxValDate;
      }
      if (AdfDhtmlChooseDateDOMQueries.isDateBeforeMinimumDate(chooseDateComponent, todayDate)) {
        todayDate = minValDate;
      }
      todayDate.setDate(1);
      agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._SHOW_DATE, dateTimeConverter.getAsString(todayDate));
    }
  }
  var showDateStr = agent.getAttribute(contentNode, AdfDhtmlChooseDatePeer._SHOW_DATE);
  if (showDateStr != null) {
    var showDate = dateTimeConverter.getAsObject(showDateStr);
    showDate.setDate(1);
    showDate.setFullYear(showDate.getFullYear() - AdfDhtmlChooseDatePeer._MAX_CLIENT_RANGE_YEARS / 2);
    agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._RANGE_START, dateTimeConverter.getAsString(showDate));
    showDate.setFullYear(showDate.getFullYear() + AdfDhtmlChooseDatePeer._MAX_CLIENT_RANGE_YEARS);
    agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._RANGE_END, dateTimeConverter.getAsString(showDate));
  }
  var firstDOWStr = agent.getAttribute(contentNode, AdfDhtmlChooseDatePeer._FIRST_DAY_OF_WEEK);
  if (firstDOWStr != null) {
    agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._FIRST_DAY_OF_WEEK, firstDOWStr);
  }
  var allowTmSelStr = agent.getAttribute(contentNode, AdfDhtmlChooseDatePeer._ALLOW_TIME_SELECTION);
  if (allowTmSelStr != null) {
    agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._ALLOW_TIME_SELECTION, allowTmSelStr);
  }
  var numHourDigStr = agent.getAttribute(contentNode, AdfDhtmlChooseDatePeer._NUMBER_HOUR_DIGITS);
  if (numHourDigStr != null) {
    agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._NUMBER_HOUR_DIGITS, numHourDigStr);
  }
  var show24HrStr = agent.getAttribute(contentNode, AdfDhtmlChooseDatePeer._SHOW_24_HOUR_FORMAT);
  if (show24HrStr != null) {
    agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._SHOW_24_HOUR_FORMAT, show24HrStr);
  }
  var showAMPMStr = agent.getAttribute(contentNode, AdfDhtmlChooseDatePeer._SHOW_AM_PM);
  if (showAMPMStr != null) {
    agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._SHOW_AM_PM, showAMPMStr);
  }
  var showAMPM2RowsStr = agent.getAttribute(contentNode, AdfDhtmlChooseDatePeer._SHOW_AM_PM_IN_2_ROWS);
  if (showAMPM2RowsStr != null) {
    agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._SHOW_AM_PM_IN_2_ROWS, showAMPM2RowsStr);
  }
  var numMinDigitsStr = agent.getAttribute(contentNode, AdfDhtmlChooseDatePeer._NUMBER_MINUTE_DIGITS);
  if (numMinDigitsStr != null) {
    agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._NUMBER_MINUTE_DIGITS, numMinDigitsStr);
  }
  var numSecDigitsStr = agent.getAttribute(contentNode, AdfDhtmlChooseDatePeer._NUMBER_SECOND_DIGITS);
  if (numSecDigitsStr != null) {
    agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._NUMBER_SECOND_DIGITS, numSecDigitsStr);
  }
  var showTZStr = agent.getAttribute(contentNode, AdfDhtmlChooseDatePeer._SHOW_TIMEZONE);
  if (showTZStr != null) {
    agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._SHOW_TIMEZONE, showTZStr);
  }
  var cntZeroStr = agent.getAttribute(contentNode, AdfDhtmlChooseDatePeer._COUNT_ZERO_BASED);
  if (cntZeroStr != null) {
    agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._COUNT_ZERO_BASED, cntZeroStr);
  }
  var selTZStr = agent.getAttribute(contentNode, AdfDhtmlChooseDatePeer._CLIENT_TIME_ZONE);
  if (selTZStr != null) {
    agent.setAttribute(chooseDateRoot, AdfDhtmlChooseDatePeer._CLIENT_TIME_ZONE, selTZStr);
  }
};
AdfDhtmlInputDatePeer.prototype._getChooserPopupHints = function(component) {
  var hints = {};
  var agent = AdfAgent.AGENT;
  var windowWidth = agent.getWindowWidth();
  if (windowWidth <= AdfDhtmlInputDatePeer._MAX_WIDTH_CENTER_DLG) {
    hints[AdfDhtmlPopupHints.POSITION_CENTER] = true;
  } else {
    hints[AdfRichPopup.HINT_ALIGN] = AdfRichPopup.ALIGN_AFTER_START;
    hints[AdfRichPopup.HINT_ALIGN_ID] = AdfRichUIPeer.CreateSubId(component.getClientId(), AdfDhtmlInputDatePeer._GLYPH_ID);
  }
  hints[AdfDhtmlPopupWindow.FOCUS] = true;
  hints[AdfDhtmlPopupWindow.HINT_CLOSE_HANDLER] = this.createCallback(this._chooserPopupClosedHandler);
  hints[AdfDhtmlPopupWindow.HINT_CLOSE_HANDLER_PARAM] = {};
  var label = component.getLabel();
  if (!label) {
    var glyphElement = this._getGlyph(component);
    label = AdfAgent.AGENT.getAttribute(glyphElement, "title");
  }
  hints[AdfDhtmlPopupWindow.ARIA_LABEL] = label;
  return hints;
};
AdfDhtmlInputDatePeer.prototype._chooserPopupClosedHandler = function(config) {
  var component = this.getComponent();
  var inputElement = AdfDhtmlEditableValuePeer.getContentNode(component);
  AdfFocusUtils.focusElement(inputElement);
};
AdfDhtmlInputDatePeer.prototype._getPopupId = function(component) {
  return AdfRichUIPeer.CreateSubId(component.getClientId(), AdfDhtmlInputDatePeer._POPUP_ID);
};
AdfDhtmlInputDatePeer.prototype._getRuntimeChooseDateId = function(thisComponent) {
  var domElement = AdfDhtmlEditableValuePeer.getContentNode(thisComponent);
  var chooseDateId = AdfDhtmlInputChooseBindingUtils.getChooseId(thisComponent, AdfRichInputDate.CHOOSE_ID);
  if (chooseDateId == null) {
    var baseId = AdfRichUIPeer.CreateSubId(thisComponent.getClientId(), AdfDhtmlInputDatePeer._POPUP_ID);
    var child = domElement.getAttribute(AdfDhtmlInputDatePeer._CHILD_EXPANDO);
    if (child) {
      baseId = AdfRichUIPeer.CreateSubId(baseId, child);
    }
    return AdfRichUIPeer.CreateSubId(baseId, AdfDhtmlInputDatePeer._CHOOSEDATE_ID);
  }
  return chooseDateId;
};
AdfDhtmlInputDatePeer.prototype._hidePopup = function(inputComponent) {
  var popup = this._getPopup(inputComponent);
  if (popup != null && popup.isPopupVisible()) {
    popup.hide();
  }
};
AdfDhtmlInputDatePeer.prototype._hookUpChooseDate = function(clientId) {
  var thisComponent = AdfPage.PAGE.findComponent(clientId);
  if (thisComponent) {
    var chooseDateId = this._getRuntimeChooseDateId(thisComponent);
    if (chooseDateId != null) {
      AdfDhtmlInputChooseBindingUtils.registerBinding(true, chooseDateId, thisComponent.getClientId());
    }
  }
};
AdfDhtmlInputDatePeer.prototype._isChooserSuppressed = function() {
  var domElement = AdfDhtmlEditableValuePeer.getContentNode(this.getComponent());
  var child = domElement.getAttribute(AdfDhtmlInputDatePeer._CHILD_EXPANDO);
  return child == "0";
};
AdfDhtmlInputDatePeer.prototype._isGlyphElement = function(eventTarget, glyphId) {
  var container = AdfAgent.AGENT.getElementById(glyphId);
  if (container == null) {
    return false;
  }
  if (eventTarget == container) {
    return true;
  } else {
    if (eventTarget == container.getElementsByTagName("img")[0]) {
      return true;
    }
  }
  return false;
};
AdfDhtmlInputDatePeer.prototype._isPopupVisible = function(component) {
  var popup = this._getPopup(component);
  if (popup != null && popup.isPopupVisible()) {
    return true;
  }
  return false;
};
AdfDhtmlInputDatePeer._getISOStandardConverter = function() {
  if (!AdfDhtmlInputDatePeer.ISO_STANDARD_CONVERTER) {
    AdfDhtmlInputDatePeer.ISO_STANDARD_CONVERTER = new TrDateTimeConverter("yyyy-MM-dd HH:mm:ss", null, null, null, null);
  }
  return AdfDhtmlInputDatePeer.ISO_STANDARD_CONVERTER;
};
AdfDhtmlInputDatePeer.prototype._getLosslessConvertedObject = function(component, value) {
  if (value != null) {
    var valueString = value;
    var losslessConverter = component.getProperty("_losslessConverter");
    if (losslessConverter) {
      valueString = losslessConverter.getAsString(value, component.getProperty("label"));
      if (valueString === undefined) {
        return null;
      }
    }
    return valueString;
  }
  return null;
};
AdfDhtmlInputDatePeer.prototype._getLosslessConvertedNode = function(component) {
  var lcId = AdfRichUIPeer.CreateSubId(component.getClientId(), AdfDhtmlInputDatePeer._LOSSLESS_SUBID);
  return AdfAgent.AGENT.getElementById(lcId);
};
AdfDhtmlInputDatePeer.prototype._updateLosslessNode = function(component, newValue) {
  var losslessNode = this._getLosslessConvertedNode(component);
  if (losslessNode) {
    if (!newValue) {
      losslessNode.value = "";
    } else {
      var convertedValue = this._getLosslessConvertedObject(component, newValue);
      losslessNode.value = convertedValue;
    }
  }
};
AdfDhtmlInputDatePeer._getSkinDeterminedLayouts = function() {
  if (!AdfDhtmlInputDatePeer._SKIN_DETERMINED_LAYOUTS) {
    var lnf = AdfPage.PAGE.getLookAndFeel();
    AdfDhtmlInputDatePeer._SKIN_DETERMINED_LAYOUTS = lnf.getSkinProperty("af|inputDate-tr-layout");
  }
  return AdfDhtmlInputDatePeer._SKIN_DETERMINED_LAYOUTS;
};
AdfDhtmlInputDatePeer._getSkinDeterminedMonths = function() {
  if (!AdfDhtmlInputDatePeer._SKIN_DETERMINED_MONTHS) {
    var lnf = AdfPage.PAGE.getLookAndFeel();
    AdfDhtmlInputDatePeer._SKIN_DETERMINED_MONTHS = parseInt(lnf.getSkinProperty("af|inputDate-tr-months"));
  }
  return AdfDhtmlInputDatePeer._SKIN_DETERMINED_MONTHS;
};
