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