*/
protected void addCalendarOptions(List headElements) {
String fieldId = getId();
String imgId = fieldId + "-button";
JsScript script = new JsScript();
script.setId(fieldId + "_calendar_date_select");
// Note the Calendar options script is recreated and checked if it
// is contained in the headElement. This caters for when the field is
// used in a fly-weight pattern such as FormTable.
if (!headElements.contains(script)) {
// Script must be executed as soon as browser dom is ready
script.setExecuteOnDomReady(true);
HtmlStringBuffer buffer = new HtmlStringBuffer(150);
buffer.append("Event.observe('").append(imgId).append("', 'click', function(){");
buffer.append(" Date.first_day_of_week=").append(getFirstDayOfWeek() - 1).append(";");
buffer.append(" calendar = new CalendarDateSelect($('").append(fieldId).append("'), {");
buffer.append(" minute_interval: 1, popup_by: '").append(imgId).append("',");
buffer.append(" embedded: false,");
buffer.append(" footer: false,");
buffer.append(" buttons: ").append(isShowTime()).append(",");
buffer.append(" time: ").append(isShowTime() ? "'mixed'," : "false,");
buffer.append(" formatValue: '").append(getCalendarPattern()).append("',");
buffer.append(" year_range: [").append(getMinimumYear()).append(",").append(getMaximumYear()).append("]");
buffer.append(" });");
buffer.append("});");
script.setContent(buffer.toString());
headElements.add(script);
}
}