Calendar.setup=function(e){function t(t,n){if(typeof e[t]=="undefined"){e[t]=n}}function i(e){var t=e.params;var n=e.dateClicked||t.electric;if(n&&t.inputField){t.inputField.value=e.date.print(e.dateFormat,e.dateType,e.langNumbers);if(typeof t.inputField.onchange=="function")t.inputField.onchange()}if(n&&t.displayArea)t.displayArea.innerHTML=e.date.print(t.daFormat,e.dateType,e.langNumbers);if(n&&typeof t.onUpdate=="function")t.onUpdate(e);if(n&&t.flat){if(typeof t.flatCallback=="function")t.flatCallback(e)}if(n&&t.singleClick&&e.dateClicked)e.callCloseHandler()}t("inputField",null);t("displayArea",null);t("button",null);t("eventName","click");t("ifFormat","%Y/%m/%d");t("daFormat","%Y/%m/%d");t("singleClick",true);t("disableFunc",null);t("dateStatusFunc",e["disableFunc"]);t("dateText",null);t("firstDay",null);t("align","Br");t("range",[1e3,3e3]);t("weekNumbers",true);t("flat",null);t("flatCallback",null);t("onSelect",null);t("onClose",null);t("onUpdate",null);t("date",null);t("showsTime",false);t("timeFormat","24");t("electric",true);t("step",2);t("position",null);t("showOthers",false);t("multiple",null);t("dateType","gregorian");t("langNumbers",false);var n=["inputField","displayArea","button"];for(var r in n){if(typeof e[n[r]]=="string"){e[n[r]]=document.getElementById(e[n[r]])}}if(!(e.flat||e.multiple||e.inputField||e.displayArea||e.button)){alert("Calendar.setup:\n  Nothing to setup (no fields found).  Please check your code");return false}if(e.flat!=null){if(typeof e.flat=="string")e.flat=document.getElementById(e.flat);if(!e.flat){alert("Calendar.setup:\n  Flat specified but can't find parent.");return false}var s=new Calendar(e.firstDay,e.date,e.onSelect||i);s.showsOtherMonths=e.showOthers;s.showsTime=e.showsTime;s.time24=e.timeFormat=="24";s.params=e;s.weekNumbers=e.weekNumbers;s.setRange(e.range[0],e.range[1]);s.setDateStatusHandler(e.dateStatusFunc);s.getDateText=e.dateText;s.dateType=e.dateType;s.langNumbers=e.langNumbers;if(e.ifFormat){s.setDateFormat(e.ifFormat)}s.create(e.flat);if(e.inputField&&typeof e.inputField.value=="string"){s.parseDate(e.inputField.value,null,e.dateType)}s.show();return s}var s=new Calendar(e.firstDay,e.date,e.onSelect||i,e.onClose||function(e){e.hide()});s.showsTime=e.showsTime;s.time24=e.timeFormat=="24";s.weekNumbers=e.weekNumbers;s.dateType=e.dateType;s.langNumbers=e.langNumbers;s.showsOtherMonths=e.showOthers;s.yearStep=e.step;s.setRange(e.range[0],e.range[1]);s.params=e;s.setDateStatusHandler(e.dateStatusFunc);s.getDateText=e.dateText;s.setDateFormat(e.inputField?e.ifFormat:e.daFormat);if(e.multiple){s.multiple={};for(var r=e.multiple.length;--r>=0;){var o=e.multiple[r];var u=o.print("%Y%m%d",s.dateType,s.langNumbers);s.multiple[u]=o}}var a=e.button||e.displayArea||e.inputField;a["on"+e.eventName]=function(){if(!s.element)s.create();var t=e.inputField||e.displayArea;if(t)e.date=Date.parseDate(t.value||t.innerHTML,s.dateFormat,s.dateType);if(e.date)s.setDate(e.date);s.refresh();if(!e.position)s.showAtElement(e.button||e.displayArea||e.inputField,e.align);else s.showAt(e.position[0],e.position[1]);return false};return s}