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