Calendar.setup=function(a){function b(e,d){if(typeof a[e]=="undefined")a[e]=d}function k(e){var d=e.params,g=e.dateClicked||d.electric;if(g&&d.inputField){d.inputField.value=e.date.print(d.ifFormat);typeof d.inputField.onchange=="function"&&d.inputField.onchange()}if(g&&d.displayArea)d.displayArea.innerHTML=e.date.print(d.daFormat);g&&typeof d.onUpdate=="function"&&d.onUpdate(e);g&&d.flat&&typeof d.flatCallback=="function"&&d.flatCallback(e);g&&d.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||k);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,d=a.inputField?a.ifFormat:a.daFormat,g=false,c=window.calendar;if(e)a.date=Date.parseDate(e.value||e.innerHTML,d);if(c&&a.cache){a.date&&c.setDate(a.date);c.hide()}else{window.calendar=c=new Calendar(a.firstDay,a.date,a.onSelect||k,a.onClose||function(j){j.hide()});c.showsTime=a.showsTime;c.time24=a.timeFormat=="24";c.weekNumbers=a.weekNumbers;g=true}if(a.multiple){c.multiple={};for(e=a.multiple.length;--e>=0;){var l=a.multiple[e],n=l.print("%Y%m%d");c.multiple[n]=
l}}c.showsOtherMonths=a.showOthers;c.yearStep=a.step;c.setRange(a.range[0],a.range[1]);c.params=a;c.setDateStatusHandler(a.dateStatusFunc);c.setDisabledHandler(function(j){var m=(new Date).getTime();m-=864E5;if(j<new Date(m))return true;return false});c.getDateText=a.dateText;c.setDateFormat(d);g&&c.create();c.refresh();a.position?c.showAt(a.position[0],a.position[1]):c.showAtElement(a.button||a.displayArea||a.inputField,a.align);return false};return f};
