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