Calendar.setup=function(C){function F(J,K){if(typeof C[J]=="undefined"){C[J]=K}}F("inputField","date_calendar");F("displayArea",null);F("button","date_btn");F("eventName","click");F("ifFormat","%Y-%m-%d %H:%M:%S");F("daFormat","%Y/%m/%d");F("singleClick",true);F("disableFunc",null);F("dateStatusFunc",C.disableFunc);F("dateText",null);F("firstDay",null);F("align","Br");F("range",[1000,3000]);F("weekNumbers",true);F("flat",null);F("flatCallback",null);F("onSelect",null);F("onClose",null);F("onUpdate",null);F("date",null);F("showsTime",true);F("timeFormat","24");F("electric",true);F("step",2);F("position",null);F("showOthers",true);F("multiple",null);F("dateType","jalali");F("ifDateType",null);F("langNumbers",false);F("autoShowOnFocus",false);var D=["inputField","displayArea","button"];for(var E in D){if(typeof C[D[E]]=="string"){C[D[E]]=document.getElementById(C[D[E]])}}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}function H(K){var J=K.params;var L=(K.dateClicked||J.electric);if(L&&J.inputField){J.inputField.value=K.date.print(K.dateFormat,J.ifDateType||K.dateType,K.langNumbers);if(typeof J.inputField.onchange=="function"){J.inputField.onchange()}}if(L&&J.displayArea){J.displayArea.innerHTML=K.date.print(J.daFormat,K.dateType,K.langNumbers)}if(L&&typeof J.onUpdate=="function"){J.onUpdate(K)}if(L&&J.flat){if(typeof J.flatCallback=="function"){J.flatCallback(K)}}if(L&&J.singleClick&&K.dateClicked){K.callCloseHandler()}}if(C.flat!=null){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||H);A.showsOtherMonths=C.showOthers;A.showsTime=C.showsTime;A.time24=(C.timeFormat=="24");A.params=C;A.weekNumbers=C.weekNumbers;A.setRange(C.range[0],C.range[1]);A.setDateStatusHandler(C.dateStatusFunc);A.getDateText=C.dateText;A.dateType=C.dateType;A.langNumbers=C.langNumbers;if(C.ifFormat){A.setDateFormat(C.ifFormat)}A.create(C.flat);if(C.inputField&&typeof C.inputField.value=="string"){A.parseDate(C.inputField.value,null,C.ifDateType||A.dateType)}A.show();return A}var A=new Calendar(C.firstDay,C.date,C.onSelect||H,C.onClose||function(J){J.hide()});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 E=C.multiple.length;--E>=0;){var G=C.multiple[E];var B=G.print("%Y%m%d",A.dateType,A.langNumbers);A.multiple[B]=G}}var I=C.button||C.displayArea||C.inputField;I["on"+C.eventName]=function(){if(!A.element){A.create()}var J=C.inputField||C.displayArea;var K=C.inputField?C.ifDateType||A.dateType:A.dateType;if(J){C.date=Date.parseDate(J.value||J.innerHTML,A.dateFormat,K)}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=I["on"+C.eventName]}return A};

