复制代码 代码如下: js calendar <BR>/* Copyright Mihai Bazon, 2002-2005 | www.bazon.net/mishoo <BR>* ----------------------------------------------------------- <BR>* <BR>* The DHTML Calendar, version 1.0 "It is happening again" <BR>* <BR>* Details and latest version at: <BR>* www.dynarch.com/projects/calendar <BR>* <BR>* This script is developed by Dynarch.com. Visit us at www.dynarch.com. <BR>* <BR>* This script is distributed under the GNU Lesser General Public License. <BR>* Read the entire license text here: http://www.gnu.org/licenses/lgpl.html <BR>*/ <BR>// $Id: calendar.js,v 1.51 2005/03/07 16:44:31 mishoo Exp $ <BR>/** The Calendar object constructor. */ <BR>Calendar = function (firstDayOfWeek, dateStr, onSelected, onClose) { <BR>// member variables <BR>this.activeDiv = null; <BR>this.currentDateEl = null; <BR>this.getDateStatus = null; <BR>this.getDateToolTip = null; <BR>this.getDateText = null; <BR>this.timeout = null; <BR>this.onSelected = onSelected || null; <BR>this.onClose = onClose || null; <BR>this.dragging = false; <BR>this.hidden = false; <BR>this.minYear = 1970; <BR>this.maxYear = 2050; <BR>this.dateFormat = Calendar._TT["DEF_DATE_FORMAT"]; <BR>this.ttDateFormat = Calendar._TT["TT_DATE_FORMAT"]; <BR>this.isPopup = true; <BR>this.weekNumbers = true; <BR>this.firstDayOfWeek = typeof firstDayOfWeek == "number" ? firstDayOfWeek : Calendar._FD; // 0 for Sunday, 1 for Monday, etc. <BR>this.showsOtherMonths = false; <BR>this.dateStr = dateStr; <BR>this.ar_days = null; <BR>this.showsTime = false; <BR>this.time24 = true; <BR>this.yearStep = 2; <BR>this.hiliteToday = true; <BR>this.multiple = null; <BR>// HTML elements <BR>this.table = null; <BR>this.element = null; <BR>this.tbody = null; <BR>this.firstdayname = null; <BR>// Combo boxes <BR>this.monthsCombo = null; <BR>this.yearsCombo = null; <BR>this.hilitedMonth = null; <BR>this.activeMonth = null; <BR>this.hilitedYear = null; <BR>this.activeYear = null; <BR>// Information <BR>this.dateClicked = false; <BR>// one-time initializations <BR>if (typeof Calendar._SDN == "undefined") { <BR>// table of short day names <BR>if (typeof Calendar._SDN_len == "undefined") <BR>Calendar._SDN_len = 3; <BR>var ar = new Array(); <BR>for (var i = 8; i > 0;) { <BR>ar[--i] = Calendar._DN[i].substr(0, Calendar._SDN_len); <BR>} <BR>Calendar._SDN = ar; <BR>// table of short month names <BR>if (typeof Calendar._SMN_len == "undefined") <BR>Calendar._SMN_len = 3; <BR>ar = new Array(); <BR>for (var i = 12; i > 0;) { <BR>ar[--i] = Calendar._MN[i].substr(0, Calendar._SMN_len); <BR>} <BR>Calendar._SMN = ar; <BR>} <BR>}; <BR>// ** constants <BR>/// "static", needed for event handlers. <BR>Calendar._C = null; <BR>/// detect a special case of "web browser" <BR>Calendar.is_ie = ( /msie/i.test(navigator.userAgent) && <BR>!/opera/i.test(navigator.userAgent) ); <BR>Calendar.is_ie5 = ( Calendar.is_ie && /msie 5\.0/i.test(navigator.userAgent) ); <BR>/// detect Opera browser <BR>Calendar.is_opera = /opera/i.test(navigator.userAgent); <BR>/// detect KHTML-based browsers <BR>Calendar.is_khtml = /Konqueror|Safari|KHTML/i.test(navigator.userAgent); <BR>// BEGIN: UTILITY FUNCTIONS; beware that these might be moved into a separate <BR>// library, at some point. <BR>Calendar.getAbsolutePos = function(el) { <BR>var SL = 0, ST = 0; <BR>var is_div = /^div$/i.test(el.tagName); <BR>if (is_div && el.scrollLeft) <BR>SL = el.scrollLeft; <BR>if (is_div && el.scrollTop) <BR>ST = el.scrollTop; <BR>var r = { x: el.offsetLeft - SL, y: el.offsetTop - ST }; <BR>if (el.offsetParent) { <BR>var tmp = this.getAbsolutePos(el.offsetParent); <BR>r.x += tmp.x; <BR>r.y += tmp.y; <BR>} <BR>return r; <BR>}; <BR>Calendar.isRelated = function (el, evt) { <BR>var related = evt.relatedTarget; <BR>if (!related) { <BR>var type = evt.type; <BR>if (type == "mouseover") { <BR>related = evt.fromElement; <BR>} else if (type == "mouseout") { <BR>related = evt.toElement; <BR>} <BR>} <BR>while (related) { <BR>if (related == el) { <BR>return true; <BR>} <BR>related = related.parentNode; <BR>} <BR>return false; <BR>}; <BR>Calendar.removeClass = function(el, className) { <BR>if (!(el && el.className)) { <BR>return; <BR>} <BR>var cls = el.className.split(" "); <BR>var ar = new Array(); <BR>for (var i = cls.length; i > 0;) { <BR>if (cls[--i] != className) { <BR>ar[ar.length] = cls[i]; <BR>} <BR>} <BR>el.className = ar.join(" "); <BR>}; <BR>Calendar.addClass = function(el, className) { <BR>Calendar.removeClass(el, className); <BR>el.className += " " + className; <BR>}; <BR>// FIXME: the following 2 functions totally suck, are useless and should be replaced immediately. <BR>Calendar.getElement = function(ev) { <BR>var f = Calendar.is_ie ? window.event.srcElement : ev.currentTarget; <BR>while (f.nodeType != 1 || /^div$/i.test(f.tagName)) <BR>f = f.parentNode; <BR>return f; <BR>}; <BR>Calendar.getTargetElement = function(ev) { <BR>var f = Calendar.is_ie ? window.event.srcElement : ev.target; <BR>while (f.nodeType != 1) <BR>f = f.parentNode; <BR>return f; <BR>}; <BR>Calendar.stopEvent = function(ev) { <BR>ev || (ev = window.event); <BR>if (Calendar.is_ie) { <BR>ev.cancelBubble = true; <BR>ev.returnValue = false; <BR>} else { <BR>ev.preventDefault(); <BR>ev.stopPropagation(); <BR>} <BR>return false; <BR>}; <BR>Calendar.addEvent = function(el, evname, func) { <BR>if (el.attachEvent) { // IE <BR>el.attachEvent("on" + evname, func); <BR>} else if (el.addEventListener) { // Gecko / W3C <BR>el.addEventListener(evname, func, true); <BR>} else { <BR>el["on" + evname] = func; <BR>} <BR>}; <BR>Calendar.removeEvent = function(el, evname, func) { <BR>if (el.detachEvent) { // IE <BR>el.detachEvent("on" + evname, func); <BR>} else if (el.removeEventListener) { // Gecko / W3C <BR>el.removeEventListener(evname, func, true); <BR>} else { <BR>el["on" + evname] = null; <BR>} <BR>}; <BR>Calendar.createElement = function(type, parent) { <BR>var el = null; <BR>if (document.createElementNS) { <BR>// use the XHTML namespace; IE won't normally get here unless <BR>// _they_ "fix" the DOM2 implementation. <BR>el = document.createElementNS("http://www.w3.org/1999/xhtml", type); <BR>} else { <BR>el = document.createElement(type); <BR>} <BR>if (typeof parent != "undefined") { <BR>parent.appendChild(el); <BR>} <BR>return el; <BR>}; <BR>// END: UTILITY FUNCTIONS <BR>// BEGIN: CALENDAR STATIC FUNCTIONS <BR>/** Internal -- adds a set of events to make some element behave like a button. */ <BR>Calendar._add_evs = function(el) { <BR>with (Calendar) { <BR>addEvent(el, "mouseover", dayMouseOver); <BR>addEvent(el, "mousedown", dayMouseDown); <BR>addEvent(el, "mouseout", dayMouseOut); <BR>if (is_ie) { <BR>addEvent(el, "dblclick", dayMouseDblClick); <BR>el.setAttribute("unselectable", true); <BR>} <BR>} <BR>}; <BR>Calendar.findMonth = function(el) { <BR>if (typeof el.month != "undefined") { <BR>return el; <BR>} else if (typeof el.parentNode.month != "undefined") { <BR>return el.parentNode; <BR>} <BR>return null; <BR>}; <BR>Calendar.findYear = function(el) { <BR>if (typeof el.year != "undefined") { <BR>return el; <BR>} else if (typeof el.parentNode.year != "undefined") { <BR>return el.parentNode; <BR>} <BR>return null; <BR>}; <BR>Calendar.showMonthsCombo = function () { <BR>var cal = Calendar._C; <BR>if (!cal) { <BR>return false; <BR>} <BR>var cal = cal; <BR>var cd = cal.activeDiv; <BR>var mc = cal.monthsCombo; <BR>if (cal.hilitedMonth) { <BR>Calendar.removeClass(cal.hilitedMonth, "hilite"); <BR>} <BR>if (cal.activeMonth) { <BR>Calendar.removeClass(cal.activeMonth, "active"); <BR>} <BR>var mon = cal.monthsCombo.getElementsByTagName("div")[cal.date.getMonth()]; <BR>Calendar.addClass(mon, "active"); <BR>cal.activeMonth = mon; <BR>var s = mc.style; <BR>s.display = "block"; <BR>if (cd.navtype < 0) <BR>s.left = cd.offsetLeft + "px"; <BR>else { <BR>var mcw = mc.offsetWidth; <BR>if (typeof mcw == "undefined") <BR>// Konqueror brain-dead techniques <BR>mcw = 50; <BR>s.left = (cd.offsetLeft + cd.offsetWidth - mcw) + "px"; <BR>} <BR>s.top = (cd.offsetTop + cd.offsetHeight) + "px"; <BR>}; <BR>Calendar.showYearsCombo = function (fwd) { <BR>var cal = Calendar._C; <BR>if (!cal) { <BR>return false; <BR>} <BR>var cal = cal; <BR>var cd = cal.activeDiv; <BR>var yc = cal.yearsCombo; <BR>if (cal.hilitedYear) { <BR>Calendar.removeClass(cal.hilitedYear, "hilite"); <BR>} <BR>if (cal.activeYear) { <BR>Calendar.removeClass(cal.activeYear, "active"); <BR>} <BR>cal.activeYear = null; <BR>var Y = cal.date.getFullYear() + (fwd ? 1 : -1); <BR>var yr = yc.firstChild; <BR>var show = false; <BR>for (var i = 12; i > 0; --i) { <BR>if (Y >= cal.minYear && Y <= cal.maxYear) { <BR>yr.innerHTML = Y; <BR>yr.year = Y; <BR>yr.style.display = "block"; <BR>show = true; <BR>} else { <BR>yr.style.display = "none"; <BR>} <BR>yr = yr.nextSibling; <BR>Y += fwd ? cal.yearStep : -cal.yearStep; <BR>} <BR>if (show) { <BR>var s = yc.style; <BR>s.display = "block"; <BR>if (cd.navtype < 0) <BR>s.left = cd.offsetLeft + "px"; <BR>else { <BR>var ycw = yc.offsetWidth; <BR>if (typeof ycw == "undefined") <BR>// Konqueror brain-dead techniques <BR>ycw = 50; <BR>s.left = (cd.offsetLeft + cd.offsetWidth - ycw) + "px"; <BR>} <BR>s.top = (cd.offsetTop + cd.offsetHeight) + "px"; <BR>} <BR>}; <BR>// event handlers <BR>Calendar.tableMouseUp = function(ev) { <BR>var cal = Calendar._C; <BR>if (!cal) { <BR>return false; <BR>} <BR>if (cal.timeout) { <BR>clearTimeout(cal.timeout); <BR>} <BR>var el = cal.activeDiv; <BR>if (!el) { <BR>return false; <BR>} <BR>var target = Calendar.getTargetElement(ev); <BR>ev || (ev = window.event); <BR>Calendar.removeClass(el, "active"); <BR>if (target == el || target.parentNode == el) { <BR>Calendar.cellClick(el, ev); <BR>} <BR>var mon = Calendar.findMonth(target); <BR>var date = null; <BR>if (mon) { <BR>date = new Date(cal.date); <BR>if (mon.month != date.getMonth()) { <BR>date.setMonth(mon.month); <BR>cal.setDate(date); <BR>cal.dateClicked = false; <BR>cal.callHandler(); <BR>} <BR>} else { <BR>var year = Calendar.findYear(target); <BR>if (year) { <BR>date = new Date(cal.date); <BR>if (year.year != date.getFullYear()) { <BR>date.setFullYear(year.year); <BR>cal.setDate(date); <BR>cal.dateClicked = false; <BR>cal.callHandler(); <BR>} <BR>} <BR>} <BR>with (Calendar) { <BR>removeEvent(document, "mouseup", tableMouseUp); <BR>removeEvent(document, "mouseover", tableMouseOver); <BR>removeEvent(document, "mousemove", tableMouseOver); <BR>cal._hideCombos(); <BR>_C = null; <BR>return stopEvent(ev); <BR>} <BR>}; <BR>Calendar.tableMouseOver = function (ev) { <BR>var cal = Calendar._C; <BR>if (!cal) { <BR>return; <BR>} <BR>var el = cal.activeDiv; <BR>var target = Calendar.getTargetElement(ev); <BR>if (target == el || target.parentNode == el) { <BR>Calendar.addClass(el, "hilite active"); <BR>Calendar.addClass(el.parentNode, "rowhilite"); <BR>} else { <BR>if (typeof el.navtype == "undefined" || (el.navtype != 50 && (el.navtype == 0 || Math.abs(el.navtype) > 2))) <BR>Calendar.removeClass(el, "active"); <BR>Calendar.removeClass(el, "hilite"); <BR>Calendar.removeClass(el.parentNode, "rowhilite"); <BR>} <BR>ev || (ev = window.event); <BR>if (el.navtype == 50 && target != el) { <BR>var pos = Calendar.getAbsolutePos(el); <BR>var w = el.offsetWidth; <BR>var x = ev.clientX; <BR>var dx; <BR>var decrease = true; <BR>if (x > pos.x + w) { <BR>dx = x - pos.x - w; <BR>decrease = false; <BR>} else <BR>dx = pos.x - x; <BR>if (dx < 0) dx = 0; <BR>var range = el._range; <BR>var current = el._current; <BR>var count = Math.floor(dx / 10) % range.length; <BR>for (var i = range.length; --i >= 0;) <BR>if (range[i] == current) <BR>break; <BR>while (count-- > 0) <BR>if (decrease) { <BR>if (--i < 0) <BR>i = range.length - 1; <BR>} else if ( ++i >= range.length ) <BR>i = 0; <BR>var newval = range[i]; <BR>el.innerHTML = newval; <BR>cal.onUpdateTime(); <BR>} <BR>var mon = Calendar.findMonth(target); <BR>if (mon) { <BR>if (mon.month != cal.date.getMonth()) { <BR>if (cal.hilitedMonth) { <BR>Calendar.removeClass(cal.hilitedMonth, "hilite"); <BR>} <BR>Calendar.addClass(mon, "hilite"); <BR>cal.hilitedMonth = mon; <BR>} else if (cal.hilitedMonth) { <BR>Calendar.removeClass(cal.hilitedMonth, "hilite"); <BR>} <BR>} else { <BR>if (cal.hilitedMonth) { <BR>Calendar.removeClass(cal.hilitedMonth, "hilite"); <BR>} <BR>var year = Calendar.findYear(target); <BR>if (year) { <BR>if (year.year != cal.date.getFullYear()) { <BR>if (cal.hilitedYear) { <BR>Calendar.removeClass(cal.hilitedYear, "hilite"); <BR>} <BR>Calendar.addClass(year, "hilite"); <BR>cal.hilitedYear = year; <BR>} else if (cal.hilitedYear) { <BR>Calendar.removeClass(cal.hilitedYear, "hilite"); <BR>} <BR>} else if (cal.hilitedYear) { <BR>Calendar.removeClass(cal.hilitedYear, "hilite"); <BR>} <BR>} <BR>return Calendar.stopEvent(ev); <BR>}; <BR>Calendar.tableMouseDown = function (ev) { <BR>if (Calendar.getTargetElement(ev) == Calendar.getElement(ev)) { <BR>return Calendar.stopEvent(ev); <BR>} <BR>}; <BR>Calendar.calDragIt = function (ev) { <BR>var cal = Calendar._C; <BR>if (!(cal && cal.dragging)) { <BR>return false; <BR>} <BR>var posX; <BR>var posY; <BR>if (Calendar.is_ie) { <BR>posY = window.event.clientY + document.body.scrollTop; <BR>posX = window.event.clientX + document.body.scrollLeft; <BR>} else { <BR>posX = ev.pageX; <BR>posY = ev.pageY; <BR>} <BR>cal.hideShowCovered(); <BR>var st = cal.element.style; <BR>st.left = (posX - cal.xOffs) + "px"; <BR>st.top = (posY - cal.yOffs) + "px"; <BR>return Calendar.stopEvent(ev); <BR>}; <BR>Calendar.calDragEnd = function (ev) { <BR>var cal = Calendar._C; <BR>if (!cal) { <BR>return false; <BR>} <BR>cal.dragging = false; <BR>with (Calendar) { <BR>removeEvent(document, "mousemove", calDragIt); <BR>removeEvent(document, "mouseup", calDragEnd); <BR>tableMouseUp(ev); <BR>} <BR>cal.hideShowCovered(); <BR>}; <BR>Calendar.dayMouseDown = function(ev) { <BR>var el = Calendar.getElement(ev); <BR>if (el.disabled) { <BR>return false; <BR>} <BR>var cal = el.calendar; <BR>cal.activeDiv = el; <BR>Calendar._C = cal; <BR>if (el.navtype != 300) with (Calendar) { <BR>if (el.navtype == 50) { <BR>el._current = el.innerHTML; <BR>addEvent(document, "mousemove", tableMouseOver); <BR>} else <BR>addEvent(document, Calendar.is_ie5 ? "mousemove" : "mouseover", tableMouseOver); <BR>addClass(el, "hilite active"); <BR>addEvent(document, "mouseup", tableMouseUp); <BR>} else if (cal.isPopup) { <BR>cal._dragStart(ev); <BR>} <BR>if (el.navtype == -1 || el.navtype == 1) { <BR>if (cal.timeout) clearTimeout(cal.timeout); <BR>cal.timeout = setTimeout("Calendar.showMonthsCombo()", 250); <BR>} else if (el.navtype == -2 || el.navtype == 2) { <BR>if (cal.timeout) clearTimeout(cal.timeout); <BR>cal.timeout = setTimeout((el.navtype > 0) ? "Calendar.showYearsCombo(true)" : "Calendar.showYearsCombo(false)", 250); <BR>} else { <BR>cal.timeout = null; <BR>} <BR>return Calendar.stopEvent(ev); <BR>}; <BR>Calendar.dayMouseDblClick = function(ev) { <BR>Calendar.cellClick(Calendar.getElement(ev), ev || window.event); <BR>if (Calendar.is_ie) { <BR>document.selection.empty(); <BR>} <BR>}; <BR>Calendar.dayMouseOver = function(ev) { <BR>var el = Calendar.getElement(ev); <BR>if (Calendar.isRelated(el, ev) || Calendar._C || el.disabled) { <BR>return false; <BR>} <BR>if (el.ttip) { <BR>if (el.ttip.substr(0, 1) == "_") { <BR>el.ttip = el.caldate.print(el.calendar.ttDateFormat) + el.ttip.substr(1); <BR>} <BR>el.calendar.tooltips.innerHTML = el.ttip; <BR>} <BR>if (el.navtype != 300) { <BR>Calendar.addClass(el, "hilite"); <BR>if (el.caldate) { <BR>Calendar.addClass(el.parentNode, "rowhilite"); <BR>} <BR>} <BR>return Calendar.stopEvent(ev); <BR>}; <BR>Calendar.dayMouseOut = function(ev) { <BR>with (Calendar) { <BR>var el = getElement(ev); <BR>if (isRelated(el, ev) || _C || el.disabled) <BR>return false; <BR>removeClass(el, "hilite"); <BR>if (el.caldate) <BR>removeClass(el.parentNode, "rowhilite"); <BR>if (el.calendar) <BR>el.calendar.tooltips.innerHTML = _TT["SEL_DATE"]; <BR>return stopEvent(ev); <BR>} <BR>}; <BR>/** <BR>* A generic "click" handler :) handles all types of buttons defined in this <BR>* calendar. <BR>*/ <BR>Calendar.cellClick = function(el, ev) { <BR>var cal = el.calendar; <BR>var closing = false; <BR>var newdate = false; <BR>var date = null; <BR>if (typeof el.navtype == "undefined") { <BR>if (cal.currentDateEl) { <BR>Calendar.removeClass(cal.currentDateEl, "selected"); <BR>Calendar.addClass(el, "selected"); <BR>closing = (cal.currentDateEl == el); <BR>if (!closing) { <BR>cal.currentDateEl = el; <BR>} <BR>} <BR>cal.date.setDateOnly(el.caldate); <BR>date = cal.date; <BR>var other_month = !(cal.dateClicked = !el.otherMonth); <BR>if (!other_month && !cal.currentDateEl) <BR>cal._toggleMultipleDate(new Date(date)); <BR>else <BR>newdate = !el.disabled; <BR>// a date was clicked <BR>if (other_month) <BR>cal._init(cal.firstDayOfWeek, date); <BR>} else { <BR>if (el.navtype == 200) { <BR>Calendar.removeClass(el, "hilite"); <BR>cal.callCloseHandler(); <BR>return; <BR>} <BR>date = new Date(cal.date); <BR>if (el.navtype == 0) <BR>date.setDateOnly(new Date()); // TODAY <BR>// unless "today" was clicked, we assume no date was clicked so <BR>// the selected handler will know not to close the calenar when <BR>// in single-click mode. <BR>// cal.dateClicked = (el.navtype == 0); <BR>cal.dateClicked = false; <BR>var year = date.getFullYear(); <BR>var mon = date.getMonth(); <BR>function setMonth(m) { <BR>var day = date.getDate(); <BR>var max = date.getMonthDays(m); <BR>if (day > max) { <BR>date.setDate(max); <BR>} <BR>date.setMonth(m); <BR>}; <BR>switch (el.navtype) { <BR>case 400: <BR>Calendar.removeClass(el, "hilite"); <BR>var text = Calendar._TT["ABOUT"]; <BR>if (typeof text != "undefined") { <BR>text += cal.showsTime ? Calendar._TT["ABOUT_TIME"] : ""; <BR>} else { <BR>// FIXME: this should be removed as soon as lang files get updated! <BR>text = "Help and about box text is not translated into this language.\n" + <BR>"If you know this language and you feel generous please update\n" + <BR>"the corresponding file in \"lang\" subdir to match calendar-en.js\n" + <BR>"and send it back to <mihai_bazon@yahoo.com> to get it into the distribution ;-)\n\n" + <BR>"Thank you!\n" + <BR>"http://dynarch.com/mishoo/calendar.epl\n"; <BR>} <BR>alert(text); <BR>return; <BR>case -2: <BR>if (year > cal.minYear) { <BR>date.setFullYear(year - 1); <BR>} <BR>break; <BR>case -1: <BR>if (mon > 0) { <BR>setMonth(mon - 1); <BR>} else if (year-- > cal.minYear) { <BR>date.setFullYear(year); <BR>setMonth(11); <BR>} <BR>break; <BR>case 1: <BR>if (mon < 11) { <BR>setMonth(mon + 1); <BR>} else if (year < cal.maxYear) { <BR>date.setFullYear(year + 1); <BR>setMonth(0); <BR>} <BR>break; <BR>case 2: <BR>if (year < cal.maxYear) { <BR>date.setFullYear(year + 1); <BR>} <BR>break; <BR>case 100: <BR>cal.setFirstDayOfWeek(el.fdow); <BR>return; <BR>case 50: <BR>var range = el._range; <BR>var current = el.innerHTML; <BR>for (var i = range.length; --i >= 0;) <BR>if (range[i] == current) <BR>break; <BR>if (ev && ev.shiftKey) { <BR>if (--i < 0) <BR>i = range.length - 1; <BR>} else if ( ++i >= range.length ) <BR>i = 0; <BR>var newval = range[i]; <BR>el.innerHTML = newval; <BR>cal.onUpdateTime(); <BR>return; <BR>case 0: <BR>// TODAY will bring us here <BR>if ((typeof cal.getDateStatus == "function") && <BR>cal.getDateStatus(date, date.getFullYear(), date.getMonth(), date.getDate())) { <BR>return false; <BR>} <BR>break; <BR>} <BR>if (!date.equalsTo(cal.date)) { <BR>cal.setDate(date); <BR>newdate = true; <BR>} else if (el.navtype == 0) <BR>newdate = closing = true; <BR>} <BR>if (newdate) { <BR>ev && cal.callHandler(); <BR>} <BR>if (closing) { <BR>Calendar.removeClass(el, "hilite"); <BR>ev && cal.callCloseHandler(); <BR>} <BR>}; <BR>// END: CALENDAR STATIC FUNCTIONS <BR>// BEGIN: CALENDAR OBJECT FUNCTIONS <BR>/** <BR>* This function creates the calendar inside the given parent. If _par is <BR>* null than it creates a popup calendar inside the BODY element. If _par is <BR>* an element, be it BODY, then it creates a non-popup calendar (still <BR>* hidden). Some properties need to be set before calling this function. <BR>*/ <BR>Calendar.prototype.create = function (_par) { <BR>var parent = null; <BR>if (! _par) { <BR>// default parent is the document body, in which case we create <BR>// a popup calendar. <BR>parent = document.getElementsByTagName("body")[0]; <BR>this.isPopup = true; <BR>} else { <BR>parent = _par; <BR>this.isPopup = false; <BR>} <BR>this.date = this.dateStr ? new Date(this.dateStr) : new Date(); <BR>var table = Calendar.createElement("table"); <BR>this.table = table; <BR>table.cellSpacing = 0; <BR>table.cellPadding = 0; <BR>table.calendar = this; <BR>Calendar.addEvent(table, "mousedown", Calendar.tableMouseDown); <BR>var div = Calendar.createElement("div"); <BR>this.element = div; <BR>div.className = "calendar"; <BR>if (this.isPopup) { <BR>div.style.position = "absolute"; <BR>div.style.display = "none"; <BR>} <BR>div.appendChild(table); <BR>var thead = Calendar.createElement("thead", table); <BR>var cell = null; <BR>var row = null; <BR>var cal = this; <BR>var hh = function (text, cs, navtype) { <BR>cell = Calendar.createElement("td", row); <BR>cell.colSpan = cs; <BR>cell.className = "button"; <BR>if (navtype != 0 && Math.abs(navtype) <= 2) <BR>cell.className += " nav"; <BR>Calendar._add_evs(cell); <BR>cell.calendar = cal; <BR>cell.navtype = navtype; <BR>cell.innerHTML = "<div unselectable='on'>" + text + ""; <BR>return cell; <BR>}; <BR>row = Calendar.createElement("tr", thead); <BR>var title_length = 6; <BR>(this.isPopup) && --title_length; <BR>(this.weekNumbers) && ++title_length; <BR>hh("?", 1, 400).ttip = Calendar._TT["INFO"]; <BR>this.title = hh("", title_length, 300); <BR>this.title.className = "title"; <BR>if (this.isPopup) { <BR>this.title.ttip = Calendar._TT["DRAG_TO_MOVE"]; <BR>this.title.style.cursor = "move"; <BR>hh("×", 1, 200).ttip = Calendar._TT["CLOSE"]; <BR>} <BR>row = Calendar.createElement("tr", thead); <BR>row.className = "headrow"; <BR>this._nav_py = hh("«", 1, -2); <BR>this._nav_py.ttip = Calendar._TT["PREV_YEAR"]; <BR>this._nav_pm = hh("‹", 1, -1); <BR>this._nav_pm.ttip = Calendar._TT["PREV_MONTH"]; <BR>this._nav_now = hh(Calendar._TT["TODAY"], this.weekNumbers ? 4 : 3, 0); <BR>this._nav_now.ttip = Calendar._TT["GO_TODAY"]; <BR>this._nav_nm = hh("›", 1, 1); <BR>this._nav_nm.ttip = Calendar._TT["NEXT_MONTH"]; <BR>this._nav_ny = hh("»", 1, 2); <BR>this._nav_ny.ttip = Calendar._TT["NEXT_YEAR"]; <BR>// day names <BR>row = Calendar.createElement("tr", thead); <BR>row.className = "daynames"; <BR>if (this.weekNumbers) { <BR>cell = Calendar.createElement("td", row); <BR>cell.className = "name wn"; <BR>cell.innerHTML = Calendar._TT["WK"]; <BR>} <BR>for (var i = 7; i > 0; --i) { <BR>cell = Calendar.createElement("td", row); <BR>if (!i) { <BR>cell.navtype = 100; <BR>cell.calendar = this; <BR>Calendar._add_evs(cell); <BR>} <BR>} <BR>this.firstdayname = (this.weekNumbers) ? row.firstChild.nextSibling : row.firstChild; <BR>this._displayWeekdays(); <BR>var tbody = Calendar.createElement("tbody", table); <BR>this.tbody = tbody; <BR>for (i = 6; i > 0; --i) { <BR>row = Calendar.createElement("tr", tbody); <BR>if (this.weekNumbers) { <BR>cell = Calendar.createElement("td", row); <BR>} <BR>for (var j = 7; j > 0; --j) { <BR>cell = Calendar.createElement("td", row); <BR>cell.calendar = this; <BR>Calendar._add_evs(cell); <BR>} <BR>} <BR>if (this.showsTime) { <BR>row = Calendar.createElement("tr", tbody); <BR>row.className = "time"; <BR>cell = Calendar.createElement("td", row); <BR>cell.className = "time"; <BR>cell.colSpan = 2; <BR>cell.innerHTML = Calendar._TT["TIME"] || " "; <BR>cell = Calendar.createElement("td", row); <BR>cell.className = "time"; <BR>cell.colSpan = this.weekNumbers ? 4 : 3; <BR>(function(){ <BR>function makeTimePart(className, init, range_start, range_end) { <BR>var part = Calendar.createElement("span", cell); <BR>part.className = className; <BR>part.innerHTML = init; <BR>part.calendar = cal; <BR>part.ttip = Calendar._TT["TIME_PART"]; <BR>part.navtype = 50; <BR>part._range = []; <BR>if (typeof range_start != "number") <BR>part._range = range_start; <BR>else { <BR>for (var i = range_start; i <= range_end; ++i) { <BR>var txt; <BR>if (i < 10 && range_end >= 10) txt = '0' + i; <BR>else txt = '' + i; <BR>part._range[part._range.length] = txt; <BR>} <BR>} <BR>Calendar._add_evs(part); <BR>return part; <BR>}; <BR>var hrs = cal.date.getHours(); <BR>var mins = cal.date.getMinutes(); <BR>var t12 = !cal.time24; <BR>var pm = (hrs > 12); <BR>if (t12 && pm) hrs -= 12; <BR>var H = makeTimePart("hour", hrs, t12 ? 1 : 0, t12 ? 12 : 23); <BR>var span = Calendar.createElement("span", cell); <BR>span.innerHTML = ":"; <BR>span.className = "colon"; <BR>var M = makeTimePart("minute", mins, 0, 59); <BR>var AP = null; <BR>cell = Calendar.createElement("td", row); <BR>cell.className = "time"; <BR>cell.colSpan = 2; <BR>if (t12) <BR>AP = makeTimePart("ampm", pm ? "pm" : "am", ["am", "pm"]); <BR>else <BR>cell.innerHTML = " "; <BR>cal.onSetTime = function() { <BR>var pm, hrs = this.date.getHours(), <BR>mins = this.date.getMinutes(); <BR>if (t12) { <BR>pm = (hrs >= 12); <BR>if (pm) hrs -= 12; <BR>if (hrs == 0) hrs = 12; <BR>AP.innerHTML = pm ? "pm" : "am"; <BR>} <BR>H.innerHTML = (hrs < 10) ? ("0" + hrs) : hrs; <BR>M.innerHTML = (mins < 10) ? ("0" + mins) : mins; <BR>}; <BR>cal.onUpdateTime = function() { <BR>var date = this.date; <BR>var h = parseInt(H.innerHTML, 10); <BR>if (t12) { <BR>if (/pm/i.test(AP.innerHTML) && h < 12) <BR>h += 12; <BR>else if (/am/i.test(AP.innerHTML) && h == 12) <BR>h = 0; <BR>} <BR>var d = date.getDate(); <BR>var m = date.getMonth(); <BR>var y = date.getFullYear(); <BR>date.setHours(h); <BR>date.setMinutes(parseInt(M.innerHTML, 10)); <BR>date.setFullYear(y); <BR>date.setMonth(m); <BR>date.setDate(d); <BR>this.dateClicked = false; <BR>this.callHandler(); <BR>}; <BR>})(); <BR>} else { <BR>this.onSetTime = this.onUpdateTime = function() {}; <BR>} <BR>var tfoot = Calendar.createElement("tfoot", table); <BR>row = Calendar.createElement("tr", tfoot); <BR>row.className = "footrow"; <BR>cell = hh(Calendar._TT["SEL_DATE"], this.weekNumbers ? 8 : 7, 300); <BR>cell.className = "ttip"; <BR>if (this.isPopup) { <BR>cell.ttip = Calendar._TT["DRAG_TO_MOVE"]; <BR>cell.style.cursor = "move"; <BR>} <BR>this.tooltips = cell; <BR>div = Calendar.createElement("div", this.element); <BR>this.monthsCombo = div; <BR>div.className = "combo"; <BR>for (i = 0; i < Calendar._MN.length; ++i) { <BR>var mn = Calendar.createElement("div"); <BR>mn.className = Calendar.is_ie ? "label-IEfix" : "label"; <BR>mn.month = i; <BR>mn.innerHTML = Calendar._SMN[i]; <BR>div.appendChild(mn); <BR>} <BR>div = Calendar.createElement("div", this.element); <BR>this.yearsCombo = div; <BR>div.className = "combo"; <BR>for (i = 12; i > 0; --i) { <BR>var yr = Calendar.createElement("div"); <BR>yr.className = Calendar.is_ie ? "label-IEfix" : "label"; <BR>div.appendChild(yr); <BR>} <BR>this._init(this.firstDayOfWeek, this.date); <BR>parent.appendChild(this.element); <BR>}; <BR>/** keyboard navigation, only for popup calendars */ <BR>Calendar._keyEvent = function(ev) { <BR>var cal = window._dynarch_popupCalendar; <BR>if (!cal || cal.multiple) <BR>return false; <BR>(Calendar.is_ie) && (ev = window.event); <BR>var act = (Calendar.is_ie || ev.type == "keypress"), <BR>K = ev.keyCode; <BR>if (ev.ctrlKey) { <BR>switch (K) { <BR>case 37: // KEY left <BR>act && Calendar.cellClick(cal._nav_pm); <BR>break; <BR>case 38: // KEY up <BR>act && Calendar.cellClick(cal._nav_py); <BR>break; <BR>case 39: // KEY right <BR>act && Calendar.cellClick(cal._nav_nm); <BR>break; <BR>case 40: // KEY down <BR>act && Calendar.cellClick(cal._nav_ny); <BR>break; <BR>default: <BR>return false; <BR>} <BR>} else switch (K) { <BR>case 32: // KEY space (now) <BR>Calendar.cellClick(cal._nav_now); <BR>break; <BR>case 27: // KEY esc <BR>act && cal.callCloseHandler(); <BR>break; <BR>case 37: // KEY left <BR>case 38: // KEY up <BR>case 39: // KEY right <BR>case 40: // KEY down <BR>if (act) { <BR>var prev, x, y, ne, el, step; <BR>prev = K == 37 || K == 38; <BR>step = (K == 37 || K == 39) ? 1 : 7; <BR>function setVars() { <BR>el = cal.currentDateEl; <BR>var p = el.pos; <BR>x = p & 15; <BR>y = p >> 4; <BR>ne = cal.ar_days[y][x]; <BR>};setVars(); <BR>function prevMonth() { <BR>var date = new Date(cal.date); <BR>date.setDate(date.getDate() - step); <BR>cal.setDate(date); <BR>}; <BR>function nextMonth() { <BR>var date = new Date(cal.date); <BR>date.setDate(date.getDate() + step); <BR>cal.setDate(date); <BR>}; <BR>while (1) { <BR>switch (K) { <BR>case 37: // KEY left <BR>if (--x >= 0) <BR>ne = cal.ar_days[y][x]; <BR>else { <BR>x = 6; <BR>K = 38; <BR>continue; <BR>} <BR>break; <BR>case 38: // KEY up <BR>if (--y >= 0) <BR>ne = cal.ar_days[y][x]; <BR>else { <BR>prevMonth(); <BR>setVars(); <BR>} <BR>break; <BR>case 39: // KEY right <BR>if (++x < 7) <BR>ne = cal.ar_days[y][x]; <BR>else { <BR>x = 0; <BR>K = 40; <BR>continue; <BR>} <BR>break; <BR>case 40: // KEY down <BR>if (++y < cal.ar_days.length) <BR>ne = cal.ar_days[y][x]; <BR>else { <BR>nextMonth(); <BR>setVars(); <BR>} <BR>break; <BR>} <BR>break; <BR>} <BR>if (ne) { <BR>if (!ne.disabled) <BR>Calendar.cellClick(ne); <BR>else if (prev) <BR>prevMonth(); <BR>else <BR>nextMonth(); <BR>} <BR>} <BR>break; <BR>case 13: // KEY enter <BR>if (act) <BR>Calendar.cellClick(cal.currentDateEl, ev); <BR>break; <BR>default: <BR>return false; <BR>} <BR>return Calendar.stopEvent(ev); <BR>}; <BR>/** <BR>* (RE)Initializes the calendar to the given date and firstDayOfWeek <BR>*/ <BR>Calendar.prototype._init = function (firstDayOfWeek, date) { <BR>var today = new Date(), <BR>TY = today.getFullYear(), <BR>TM = today.getMonth(), <BR>TD = today.getDate(); <BR>this.table.style.visibility = "hidden"; <BR>var year = date.getFullYear(); <BR>if (year < this.minYear) { <BR>year = this.minYear; <BR>date.setFullYear(year); <BR>} else if (year > this.maxYear) { <BR>year = this.maxYear; <BR>date.setFullYear(year); <BR>} <BR>this.firstDayOfWeek = firstDayOfWeek; <BR>this.date = new Date(date); <BR>var month = date.getMonth(); <BR>var mday = date.getDate(); <BR>var no_days = date.getMonthDays(); <BR>// calendar voodoo for computing the first day that would actually be <BR>// displayed in the calendar, even if it's from the previous month. <BR>// WARNING: this is magic. ;-) <BR>date.setDate(1); <BR>var day1 = (date.getDay() - this.firstDayOfWeek) % 7; <BR>if (day1 < 0) <BR>day1 += 7; <BR>date.setDate(-day1); <BR>date.setDate(date.getDate() + 1); <BR>var row = this.tbody.firstChild; <BR>var MN = Calendar._SMN[month]; <BR>var ar_days = this.ar_days = new Array(); <BR>var weekend = Calendar._TT["WEEKEND"]; <BR>var dates = this.multiple ? (this.datesCells = {}) : null; <BR>for (var i = 0; i < 6; ++i, row = row.nextSibling) { <BR>var cell = row.firstChild; <BR>if (this.weekNumbers) { <BR>cell.className = "day wn"; <BR>cell.innerHTML = date.getWeekNumber(); <BR>cell = cell.nextSibling; <BR>} <BR>row.className = "daysrow"; <BR>var hasdays = false, iday, dpos = ar_days[i] = []; <BR>for (var j = 0; j < 7; ++j, cell = cell.nextSibling, date.setDate(iday + 1)) { <BR>iday = date.getDate(); <BR>var wday = date.getDay(); <BR>cell.className = "day"; <BR>cell.pos = i << 4 | j; <BR>dpos[j] = cell; <BR>var current_month = (date.getMonth() == month); <BR>if (!current_month) { <BR>if (this.showsOtherMonths) { <BR>cell.className += " othermonth"; <BR>cell.otherMonth = true; <BR>} else { <BR>cell.className = "emptycell"; <BR>cell.innerHTML = " "; <BR>cell.disabled = true; <BR>continue; <BR>} <BR>} else { <BR>cell.otherMonth = false; <BR>hasdays = true; <BR>} <BR>cell.disabled = false; <BR>cell.innerHTML = this.getDateText ? this.getDateText(date, iday) : iday; <BR>if (dates) <BR>dates[date.print("%Y%m%d")] = cell; <BR>if (this.getDateStatus) { <BR>var status = this.getDateStatus(date, year, month, iday); <BR>if (this.getDateToolTip) { <BR>var toolTip = this.getDateToolTip(date, year, month, iday); <BR>if (toolTip) <BR>cell.title = toolTip; <BR>} <BR>if (status === true) { <BR>cell.className += " disabled"; <BR>cell.disabled = true; <BR>} else { <BR>if (/disabled/i.test(status)) <BR>cell.disabled = true; <BR>cell.className += " " + status; <BR>} <BR>} <BR>if (!cell.disabled) { <BR>cell.caldate = new Date(date); <BR>cell.ttip = "_"; <BR>if (!this.multiple && current_month <BR>&& iday == mday && this.hiliteToday) { <BR>cell.className += " selected"; <BR>this.currentDateEl = cell; <BR>} <BR>if (date.getFullYear() == TY && <BR>date.getMonth() == TM && <BR>iday == TD) { <BR>cell.className += " today"; <BR>cell.ttip += Calendar._TT["PART_TODAY"]; <BR>} <BR>if (weekend.indexOf(wday.toString()) != -1) <BR>cell.className += cell.otherMonth ? " oweekend" : " weekend"; <BR>} <BR>} <BR>if (!(hasdays || this.showsOtherMonths)) <BR>row.className = "emptyrow"; <BR>} <BR>this.title.innerHTML = Calendar._MN[month] + ", " + year; <BR>this.onSetTime(); <BR>this.table.style.visibility = "visible"; <BR>this._initMultipleDates(); <BR>// PROFILE <BR>// this.tooltips.innerHTML = "Generated in " + ((new Date()) - today) + " ms"; <BR>}; <BR>Calendar.prototype._initMultipleDates = function() { <BR>if (this.multiple) { <BR>for (var i in this.multiple) { <BR>var cell = this.datesCells[i]; <BR>var d = this.multiple[i]; <BR>if (!d) <BR>continue; <BR>if (cell) <BR>cell.className += " selected"; <BR>} <BR>} <BR>}; <BR>Calendar.prototype._toggleMultipleDate = function(date) { <BR>if (this.multiple) { <BR>var ds = date.print("%Y%m%d"); <BR>var cell = this.datesCells[ds]; <BR>if (cell) { <BR>var d = this.multiple[ds]; <BR>if (!d) { <BR>Calendar.addClass(cell, "selected"); <BR>this.multiple[ds] = date; <BR>} else { <BR>Calendar.removeClass(cell, "selected"); <BR>delete this.multiple[ds]; <BR>} <BR>} <BR>} <BR>}; <BR>Calendar.prototype.setDateToolTipHandler = function (unaryFunction) { <BR>this.getDateToolTip = unaryFunction; <BR>}; <BR>/** <BR>* Calls _init function above for going to a certain date (but only if the <BR>* date is different than the currently selected one). <BR>*/ <BR>Calendar.prototype.setDate = function (date) { <BR>if (!date.equalsTo(this.date)) { <BR>this._init(this.firstDayOfWeek, date); <BR>} <BR>}; <BR>/** <BR>* Refreshes the calendar. Useful if the "disabledHandler" function is <BR>* dynamic, meaning that the list of disabled date can change at runtime. <BR>* Just * call this function if you think that the list of disabled dates <BR>* should * change. <BR>*/ <BR>Calendar.prototype.refresh = function () { <BR>this._init(this.firstDayOfWeek, this.date); <BR>}; <BR>/** Modifies the "firstDayOfWeek" parameter (pass 0 for Synday, 1 for Monday, etc.). */ <BR>Calendar.prototype.setFirstDayOfWeek = function (firstDayOfWeek) { <BR>this._init(firstDayOfWeek, this.date); <BR>this._displayWeekdays(); <BR>}; <BR>/** <BR>* Allows customization of what dates are enabled. The "unaryFunction" <BR>* parameter must be a function object that receives the date (as a JS Date <BR>* object) and returns a boolean value. If the returned value is true then <BR>* the passed date will be marked as disabled. <BR>*/ <BR>Calendar.prototype.setDateStatusHandler = Calendar.prototype.setDisabledHandler = function (unaryFunction) { <BR>this.getDateStatus = unaryFunction; <BR>}; <BR>/** Customization of allowed year range for the calendar. */ <BR>Calendar.prototype.setRange = function (a, z) { <BR>this.minYear = a; <BR>this.maxYear = z; <BR>}; <BR>/** Calls the first user handler (selectedHandler). */ <BR>Calendar.prototype.callHandler = function () { <BR>if (this.onSelected) { <BR>this.onSelected(this, this.date.print(this.dateFormat)); <BR>} <BR>}; <BR>/** Calls the second user handler (closeHandler). */ <BR>Calendar.prototype.callCloseHandler = function () { <BR>if (this.onClose) { <BR>this.onClose(this); <BR>} <BR>this.hideShowCovered(); <BR>}; <BR>/** Removes the calendar object from the DOM tree and destroys it. */ <BR>Calendar.prototype.destroy = function () { <BR>var el = this.element.parentNode; <BR>el.removeChild(this.element); <BR>Calendar._C = null; <BR>window._dynarch_popupCalendar = null; <BR>}; <BR>/** <BR>* Moves the calendar element to a different section in the DOM tree (changes <BR>* its parent). <BR>*/ <BR>Calendar.prototype.reparent = function (new_parent) { <BR>var el = this.element; <BR>el.parentNode.removeChild(el); <BR>new_parent.appendChild(el); <BR>}; <BR>// This gets called when the user presses a mouse button anywhere in the <BR>// document, if the calendar is shown. If the click was outside the open <BR>// calendar this function closes it. <BR>Calendar._checkCalendar = function(ev) { <BR>var calendar = window._dynarch_popupCalendar; <BR>if (!calendar) { <BR>return false; <BR>} <BR>var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev); <BR>for (; el != null && el != calendar.element; el = el.parentNode); <BR>if (el == null) { <BR>// calls closeHandler which should hide the calendar. <BR>window._dynarch_popupCalendar.callCloseHandler(); <BR>return Calendar.stopEvent(ev); <BR>} <BR>}; <BR>/** Shows the calendar. */ <BR>Calendar.prototype.show = function () { <BR>var rows = this.table.getElementsByTagName("tr"); <BR>for (var i = rows.length; i > 0;) { <BR>var row = rows[--i]; <BR>Calendar.removeClass(row, "rowhilite"); <BR>var cells = row.getElementsByTagName("td"); <BR>for (var j = cells.length; j > 0;) { <BR>var cell = cells[--j]; <BR>Calendar.removeClass(cell, "hilite"); <BR>Calendar.removeClass(cell, "active"); <BR>} <BR>} <BR>this.element.style.display = "block"; <BR>this.hidden = false; <BR>if (this.isPopup) { <BR>window._dynarch_popupCalendar = this; <BR>Calendar.addEvent(document, "keydown", Calendar._keyEvent); <BR>Calendar.addEvent(document, "keypress", Calendar._keyEvent); <BR>Calendar.addEvent(document, "mousedown", Calendar._checkCalendar); <BR>} <BR>this.hideShowCovered(); <BR>}; <BR>/** <BR>* Hides the calendar. Also removes any "hilite" from the class of any TD <BR>* element. <BR>*/ <BR>Calendar.prototype.hide = function () { <BR>if (this.isPopup) { <BR>Calendar.removeEvent(document, "keydown", Calendar._keyEvent); <BR>Calendar.removeEvent(document, "keypress", Calendar._keyEvent); <BR>Calendar.removeEvent(document, "mousedown", Calendar._checkCalendar); <BR>} <BR>this.element.style.display = "none"; <BR>this.hidden = true; <BR>this.hideShowCovered(); <BR>}; <BR>/** <BR>* Shows the calendar at a given absolute position (beware that, depending on <BR>* the calendar element style -- position property -- this might be relative <BR>* to the parent's containing rectangle). <BR>*/ <BR>Calendar.prototype.showAt = function (x, y) { <BR>var s = this.element.style; <BR>s.left = x + "px"; <BR>s.top = y + "px"; <BR>this.show(); <BR>}; <BR>/** Shows the calendar near a given element. */ <BR>Calendar.prototype.showAtElement = function (el, opts) { <BR>var self = this; <BR>var p = Calendar.getAbsolutePos(el); <BR>if (!opts || typeof opts != "string") { <BR>this.showAt(p.x, p.y + el.offsetHeight); <BR>return true; <BR>} <BR>function fixPosition(box) { <BR>if (box.x < 0) <BR>box.x = 0; <BR>if (box.y < 0) <BR>box.y = 0; <BR>var cp = document.createElement("div"); <BR>var s = cp.style; <BR>s.position = "absolute"; <BR>s.right = s.bottom = s.width = s.height = "0px"; <BR>document.body.appendChild(cp); <BR>var br = Calendar.getAbsolutePos(cp); <BR>document.body.removeChild(cp); <BR>if (Calendar.is_ie) { <BR>br.y += document.body.scrollTop; <BR>br.x += document.body.scrollLeft; <BR>} else { <BR>br.y += window.scrollY; <BR>br.x += window.scrollX; <BR>} <BR>var tmp = box.x + box.width - br.x; <BR>if (tmp > 0) box.x -= tmp; <BR>tmp = box.y + box.height - br.y; <BR>if (tmp > 0) box.y -= tmp; <BR>}; <BR>this.element.style.display = "block"; <BR>Calendar.continuation_for_the_fucking_khtml_browser = function() { <BR>var w = self.element.offsetWidth; <BR>var h = self.element.offsetHeight; <BR>self.element.style.display = "none"; <BR>var valign = opts.substr(0, 1); <BR>var halign = "l"; <BR>if (opts.length > 1) { <BR>halign = opts.substr(1, 1); <BR>} <BR>// vertical alignment <BR>switch (valign) { <BR>case "T": p.y -= h; break; <BR>case "B": p.y += el.offsetHeight; break; <BR>case "C": p.y += (el.offsetHeight - h) / 2; break; <BR>case "t": p.y += el.offsetHeight - h; break; <BR>case "b": break; // already there <BR>} <BR>// horizontal alignment <BR>switch (halign) { <BR>case "L": p.x -= w; break; <BR>case "R": p.x += el.offsetWidth; break; <BR>case "C": p.x += (el.offsetWidth - w) / 2; break; <BR>case "l": p.x += el.offsetWidth - w; break; <BR>case "r": break; // already there <BR>} <BR>p.width = w; <BR>p.height = h + 40; <BR>self.monthsCombo.style.display = "none"; <BR>fixPosition(p); <BR>self.showAt(p.x, p.y); <BR>}; <BR>if (Calendar.is_khtml) <BR>setTimeout("Calendar.continuation_for_the_fucking_khtml_browser()", 10); <BR>else <BR>Calendar.continuation_for_the_fucking_khtml_browser(); <BR>}; <BR>/** Customizes the date format. */ <BR>Calendar.prototype.setDateFormat = function (str) { <BR>this.dateFormat = str; <BR>}; <BR>/** Customizes the tooltip date format. */ <BR>Calendar.prototype.setTtDateFormat = function (str) { <BR>this.ttDateFormat = str; <BR>}; <BR>/** <BR>* Tries to identify the date represented in a string. If successful it also <BR>* calls this.setDate which moves the calendar to the given date. <BR>*/ <BR>Calendar.prototype.parseDate = function(str, fmt) { <BR>if (!fmt) <BR>fmt = this.dateFormat; <BR>this.setDate(Date.parseDate(str, fmt)); <BR>}; <BR>Calendar.prototype.hideShowCovered = function () { <BR>if (!Calendar.is_ie && !Calendar.is_opera) <BR>return; <BR>function getVisib(obj){ <BR>var value = obj.style.visibility; <BR>if (!value) { <BR>if (document.defaultView && typeof (document.defaultView.getComputedStyle) == "function") { // Gecko, W3C <BR>if (!Calendar.is_khtml) <BR>value = document.defaultView. <BR>getComputedStyle(obj, "").getPropertyValue("visibility"); <BR>else <BR>value = ''; <BR>} else if (obj.currentStyle) { // IE <BR>value = obj.currentStyle.visibility; <BR>} else <BR>value = ''; <BR>} <BR>return value; <BR>}; <BR>var tags = new Array("applet", "iframe", "select"); <BR>var el = this.element; <BR>var p = Calendar.getAbsolutePos(el); <BR>var EX1 = p.x; <BR>var EX2 = el.offsetWidth + EX1; <BR>var EY1 = p.y; <BR>var EY2 = el.offsetHeight + EY1; <BR>for (var k = tags.length; k > 0; ) { <BR>var ar = document.getElementsByTagName(tags[--k]); <BR>var cc = null; <BR>for (var i = ar.length; i > 0;) { <BR>cc = ar[--i]; <BR>p = Calendar.getAbsolutePos(cc); <BR>var CX1 = p.x; <BR>var CX2 = cc.offsetWidth + CX1; <BR>var CY1 = p.y; <BR>var CY2 = cc.offsetHeight + CY1; <BR>if (this.hidden || (CX1 > EX2) || (CX2 < EX1) || (CY1 > EY2) || (CY2 < EY1)) { <BR>if (!cc.__msh_save_visibility) { <BR>cc.__msh_save_visibility = getVisib(cc); <BR>} <BR>cc.style.visibility = cc.__msh_save_visibility; <BR>} else { <BR>if (!cc.__msh_save_visibility) { <BR>cc.__msh_save_visibility = getVisib(cc); <BR>} <BR>cc.style.visibility = "hidden"; <BR>} <BR>} <BR>} <BR>}; <BR>/** Internal function; it displays the bar with the names of the weekday. */ <BR>Calendar.prototype._displayWeekdays = function () { <BR>var fdow = this.firstDayOfWeek; <BR>var cell = this.firstdayname; <BR>var weekend = Calendar._TT["WEEKEND"]; <BR>for (var i = 0; i < 7; ++i) { <BR>cell.className = "day name"; <BR>var realday = (i + fdow) % 7; <BR>if (i) { <BR>cell.ttip = Calendar._TT["DAY_FIRST"].replace("%s", Calendar._DN[realday]); <BR>cell.navtype = 100; <BR>cell.calendar = this; <BR>cell.fdow = realday; <BR>Calendar._add_evs(cell); <BR>} <BR>if (weekend.indexOf(realday.toString()) != -1) { <BR>Calendar.addClass(cell, "weekend"); <BR>} <BR>cell.innerHTML = Calendar._SDN[(i + fdow) % 7]; <BR>cell = cell.nextSibling; <BR>} <BR>}; <BR>/** Internal function. Hides all combo boxes that might be displayed. */ <BR>Calendar.prototype._hideCombos = function () { <BR>this.monthsCombo.style.display = "none"; <BR>this.yearsCombo.style.display = "none"; <BR>}; <BR>/** Internal function. Starts dragging the element. */ <BR>Calendar.prototype._dragStart = function (ev) { <BR>if (this.dragging) { <BR>return; <BR>} <BR>this.dragging = true; <BR>var posX; <BR>var posY; <BR>if (Calendar.is_ie) { <BR>posY = window.event.clientY + document.body.scrollTop; <BR>posX = window.event.clientX + document.body.scrollLeft; <BR>} else { <BR>posY = ev.clientY + window.scrollY; <BR>posX = ev.clientX + window.scrollX; <BR>} <BR>var st = this.element.style; <BR>this.xOffs = posX - parseInt(st.left); <BR>this.yOffs = posY - parseInt(st.top); <BR>with (Calendar) { <BR>addEvent(document, "mousemove", calDragIt); <BR>addEvent(document, "mouseup", calDragEnd); <BR>} <BR>}; <BR>// BEGIN: DATE OBJECT PATCHES <BR>/** Adds the number of days array to the Date object. */ <BR>Date._MD = new Array(31,28,31,30,31,30,31,31,30,31,30,31); <BR>/** Constants used for time computations */ <BR>Date.SECOND = 1000 /* milliseconds */; <BR>Date.MINUTE = 60 * Date.SECOND; <BR>Date.HOUR = 60 * Date.MINUTE; <BR>Date.DAY = 24 * Date.HOUR; <BR>Date.WEEK = 7 * Date.DAY; <BR>Date.parseDate = function(str, fmt) { <BR>var today = new Date(); <BR>var y = 0; <BR>var m = -1; <BR>var d = 0; <BR>var a = str.split(/\W+/); <BR>var b = fmt.match(/%./g); <BR>var i = 0, j = 0; <BR>var hr = 0; <BR>var min = 0; <BR>for (i = 0; i < a.length; ++i) { <BR>if (!a[i]) <BR>continue; <BR>switch (b[i]) { <BR>case "%d": <BR>case "%e": <BR>d = parseInt(a[i], 10); <BR>break; <BR>case "%m": <BR>m = parseInt(a[i], 10) - 1; <BR>break; <BR>case "%Y": <BR>case "%y": <BR>y = parseInt(a[i], 10); <BR>(y < 100) && (y += (y > 29) ? 1900 : 2000); <BR>break; <BR>case "%b": <BR>case "%B": <BR>for (j = 0; j < 12; ++j) { <BR>if (Calendar._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { m = j; break; } <BR>} <BR>break; <BR>case "%H": <BR>case "%I": <BR>case "%k": <BR>case "%l": <BR>hr = parseInt(a[i], 10); <BR>break; <BR>case "%P": <BR>case "%p": <BR>if (/pm/i.test(a[i]) && hr < 12) <BR>hr += 12; <BR>else if (/am/i.test(a[i]) && hr >= 12) <BR>hr -= 12; <BR>break; <BR>case "%M": <BR>min = parseInt(a[i], 10); <BR>break; <BR>} <BR>} <BR>if (isNaN(y)) y = today.getFullYear(); <BR>if (isNaN(m)) m = today.getMonth(); <BR>if (isNaN(d)) d = today.getDate(); <BR>if (isNaN(hr)) hr = today.getHours(); <BR>if (isNaN(min)) min = today.getMinutes(); <BR>if (y != 0 && m != -1 && d != 0) <BR>return new Date(y, m, d, hr, min, 0); <BR>y = 0; m = -1; d = 0; <BR>for (i = 0; i < a.length; ++i) { <BR>if (a[i].search(/[a-zA-Z]+/) != -1) { <BR>var t = -1; <BR>for (j = 0; j < 12; ++j) { <BR>if (Calendar._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { t = j; break; } <BR>} <BR>if (t != -1) { <BR>if (m != -1) { <BR>d = m+1; <BR>} <BR>m = t; <BR>} <BR>} else if (parseInt(a[i], 10) <= 12 && m == -1) { <BR>m = a[i]-1; <BR>} else if (parseInt(a[i], 10) > 31 && y == 0) { <BR>y = parseInt(a[i], 10); <BR>(y < 100) && (y += (y > 29) ? 1900 : 2000); <BR>} else if (d == 0) { <BR>d = a[i]; <BR>} <BR>} <BR>if (y == 0) <BR>y = today.getFullYear(); <BR>if (m != -1 && d != 0) <BR>return new Date(y, m, d, hr, min, 0); <BR>return today; <BR>}; <BR>/** Returns the number of days in the current month */ <BR>Date.prototype.getMonthDays = function(month) { <BR>var year = this.getFullYear(); <BR>if (typeof month == "undefined") { <BR>month = this.getMonth(); <BR>} <BR>if (((0 == (year%4)) && ( (0 != (year%100)) || (0 == (year%400)))) && month == 1) { <BR>return 29; <BR>} else { <BR>return Date._MD[month]; <BR>} <BR>}; <BR>/** Returns the number of day in the year. */ <BR>Date.prototype.getDayOfYear = function() { <BR>var now = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0); <BR>var then = new Date(this.getFullYear(), 0, 0, 0, 0, 0); <BR>var time = now - then; <BR>return Math.floor(time / Date.DAY); <BR>}; <BR>/** Returns the number of the week in year, as defined in ISO 8601. */ <BR>Date.prototype.getWeekNumber = function() { <BR>var d = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0); <BR>var DoW = d.getDay(); <BR>d.setDate(d.getDate() - (DoW + 6) % 7 + 3); // Nearest Thu <BR>var ms = d.valueOf(); // GMT <BR>d.setMonth(0); <BR>d.setDate(4); // Thu in Week 1 <BR>return Math.round((ms - d.valueOf()) / (7 * 864e5)) + 1; <BR>}; <BR>/** Checks date and time equality */ <BR>Date.prototype.equalsTo = function(date) { <BR>return ((this.getFullYear() == date.getFullYear()) && <BR>(this.getMonth() == date.getMonth()) && <BR>(this.getDate() == date.getDate()) && <BR>(this.getHours() == date.getHours()) && <BR>(this.getMinutes() == date.getMinutes())); <BR>}; <BR>/** Set only the year, month, date parts (keep existing time) */ <BR>Date.prototype.setDateOnly = function(date) { <BR>var tmp = new Date(date); <BR>this.setDate(1); <BR>this.setFullYear(tmp.getFullYear()); <BR>this.setMonth(tmp.getMonth()); <BR>this.setDate(tmp.getDate()); <BR>}; <BR>/** Prints the date in a string according to the given format. */ <BR>Date.prototype.print = function (str) { <BR>var m = this.getMonth(); <BR>var d = this.getDate(); <BR>var y = this.getFullYear(); <BR>var wn = this.getWeekNumber(); <BR>var w = this.getDay(); <BR>var s = {}; <BR>var hr = this.getHours(); <BR>var pm = (hr >= 12); <BR>var ir = (pm) ? (hr - 12) : hr; <BR>var dy = this.getDayOfYear(); <BR>if (ir == 0) <BR>ir = 12; <BR>var min = this.getMinutes(); <BR>var sec = this.getSeconds(); <BR>s["%a"] = Calendar._SDN[w]; // abbreviated weekday name [FIXME: I18N] <BR>s["%A"] = Calendar._DN[w]; // full weekday name <BR>s["%b"] = Calendar._SMN[m]; // abbreviated month name [FIXME: I18N] <BR>s["%B"] = Calendar._MN[m]; // full month name <BR>// FIXME: %c : preferred date and time representation for the current locale <BR>s["%C"] = 1 + Math.floor(y / 100); // the century number <BR>s["%d"] = (d < 10) ? ("0" + d) : d; // the day of the month (range 01 to 31) <BR>s["%e"] = d; // the day of the month (range 1 to 31) <BR>// FIXME: %D : american date style: %m/%d/%y <BR>// FIXME: %E, %F, %G, %g, %h (man strftime) <BR>s["%H"] = (hr < 10) ? ("0" + hr) : hr; // hour, range 00 to 23 (24h format) <BR>s["%I"] = (ir < 10) ? ("0" + ir) : ir; // hour, range 01 to 12 (12h format) <BR>s["%j"] = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy; // day of the year (range 001 to 366) <BR>s["%k"] = hr; // hour, range 0 to 23 (24h format) <BR>s["%l"] = ir; // hour, range 1 to 12 (12h format) <BR>s["%m"] = (m < 9) ? ("0" + (1+m)) : (1+m); // month, range 01 to 12 <BR>s["%M"] = (min < 10) ? ("0" + min) : min; // minute, range 00 to 59 <BR>s["%n"] = "\n"; // a newline character <BR>s["%p"] = pm ? "PM" : "AM"; <BR>s["%P"] = pm ? "pm" : "am"; <BR>// FIXME: %r : the time in am/pm notation %I:%M:%S %p <BR>// FIXME: %R : the time in 24-hour notation %H:%M <BR>s["%s"] = Math.floor(this.getTime() / 1000); <BR>s["%S"] = (sec < 10) ? ("0" + sec) : sec; // seconds, range 00 to 59 <BR>s["%t"] = "\t"; // a tab character <BR>// FIXME: %T : the time in 24-hour notation (%H:%M:%S) <BR>s["%U"] = s["%W"] = s["%V"] = (wn < 10) ? ("0" + wn) : wn; <BR>s["%u"] = w + 1; // the day of the week (range 1 to 7, 1 = MON) <BR>s["%w"] = w; // the day of the week (range 0 to 6, 0 = SUN) <BR>// FIXME: %x : preferred date representation for the current locale without the time <BR>// FIXME: %X : preferred time representation for the current locale without the date <BR>s["%y"] = ('' + y).substr(2, 2); // year without the century (range 00 to 99) <BR>s["%Y"] = y; // year with the century <BR>s["%%"] = "%"; // a literal '%' character <BR>var re = /%./g; <BR>if (!Calendar.is_ie5 && !Calendar.is_khtml) <BR>return str.replace(re, function (par) { return s[par] || par; }); <BR>var a = str.match(re); <BR>for (var i = 0; i < a.length; i++) { <BR>var tmp = s[a[i]]; <BR>if (tmp) { <BR>re = new RegExp(a[i], 'g'); <BR>str = str.replace(re, tmp); <BR>} <BR>} <BR>return str; <BR>}; <BR>Date.prototype.__msh_oldSetFullYear = Date.prototype.setFullYear; <BR>Date.prototype.setFullYear = function(y) { <BR>var d = new Date(this); <BR>d.__msh_oldSetFullYear(y); <BR>if (d.getMonth() != this.getMonth()) <BR>this.setDate(28); <BR>this.__msh_oldSetFullYear(y); <BR>}; <BR>// END: DATE OBJECT PATCHES <BR>// global object that remembers the calendar <BR>window._dynarch_popupCalendar = null; <BR>//********* calendar.js END ******************** <BR>/* Copyright Mihai Bazon, 2002, 2003 | http://dynarch.com/mishoo/ <BR>* --------------------------------------------------------------------------- <BR>* <BR>* The DHTML Calendar <BR>* <BR>* Details and latest version at: <BR>* http://dynarch.com/mishoo/calendar.epl <BR>* <BR>* This script is distributed under the GNU Lesser General Public License. <BR>* Read the entire license text here: http://www.gnu.org/licenses/lgpl.html <BR>* <BR>* This file defines helper functions for setting up the calendar. They are <BR>* intended to help non-programmers get a working calendar on their site <BR>* quickly. This script should not be seen as part of the calendar. It just <BR>* shows you what one can do with the calendar, while in the same time <BR>* providing a quick and simple method for setting it up. If you need <BR>* exhaustive customization of the calendar creation process feel free to <BR>* modify this code to suit your needs (this is recommended and much better <BR>* than modifying calendar.js itself). <BR>*/ <BR>// $Id: calendar-setup.js,v 1.25 2005/03/07 09:51:33 mishoo Exp $ <BR>/** <BR>* This function "patches" an input field (or other element) to use a calendar <BR>* widget for date selection. <BR>* <BR>* The "params" is a single object that can have the following properties: <BR>* <BR>* prop. name | description <BR>* ------------------------------------------------------------------------------------------------- <BR>* inputField | the ID of an input field to store the date <BR>* displayArea | the ID of a DIV or other element to show the date <BR>* button | ID of a button or other element that will trigger the calendar <BR>* eventName | event that will trigger the calendar, without the "on" prefix (default: "click") <BR>* ifFormat | date format that will be stored in the input field <BR>* daFormat | the date format that will be used to display the date in displayArea <BR>* singleClick | (true/false) wether the calendar is in single click mode or not (default: true) <BR>* firstDay | numeric: 0 to 6. "0" means display Sunday first, "1" means display Monday first, etc. <BR>* align | alignment (default: "Br"); if you don't know what's this see the calendar documentation <BR>* range | array with 2 elements. Default: [1900, 2999] -- the range of years available <BR>* weekNumbers | (true/false) if it's true (default) the calendar will display week numbers <BR>* flat | null or element ID; if not null the calendar will be a flat calendar having the parent with the given ID <BR>* flatCallback | function that receives a JS Date object and returns an URL to point the browser to (for flat calendar) <BR>* disableFunc | function that receives a JS Date object and should return true if that date has to be disabled in the calendar <BR>* onSelect | function that gets called when a date is selected. You don't _have_ to supply this (the default is generally okay) <BR>* onClose | function that gets called when the calendar is closed. [default] <BR>* onUpdate | function that gets called after the date is updated in the input field. Receives a reference to the calendar. <BR>* date | the date that the calendar will be initially displayed to <BR>* showsTime | default: false; if true the calendar will include a time selector <BR>* timeFormat | the time format; can be "12" or "24", default is "12" <BR>* electric | if true (default) then given fields/date areas are updated for each move; otherwise they're updated only on close <BR>* step | configures the step of the years in drop-down boxes; default: 2 <BR>* position | configures the calendar absolute position; default: null <BR>* cache | if "true" (but default: "false") it will reuse the same calendar object, where possible <BR>* showOthers | if "true" (but default: "false") it will show days from other months too <BR>* <BR>* None of them is required, they all have default values. However, if you <BR>* pass none of "inputField", "displayArea" or "button" you'll get a warning <BR>* saying "nothing to setup". <BR>*/ <BR>Calendar.setup = function (params) { <BR>function param_default(pname, def) { if (typeof params[pname] == "undefined") { params[pname] = def; } }; <BR>param_default("inputField", null); <BR>param_default("displayArea", null); <BR>param_default("button", null); <BR>param_default("eventName", "click"); <BR>param_default("ifFormat", "%Y/%m/%d"); <BR>param_default("daFormat", "%Y/%m/%d"); <BR>param_default("singleClick", true); <BR>param_default("disableFunc", null); <BR>param_default("dateStatusFunc", params["disableFunc"]); // takes precedence if both are defined <BR>param_default("dateText", null); <BR>param_default("firstDay", null); <BR>param_default("align", "Br"); <BR>param_default("range", [1900, 2999]); <BR>param_default("weekNumbers", true); <BR>param_default("flat", null); <BR>param_default("flatCallback", null); <BR>param_default("onSelect", null); <BR>param_default("onClose", null); <BR>param_default("onUpdate", null); <BR>param_default("date", null); <BR>param_default("showsTime", false); <BR>param_default("timeFormat", "24"); <BR>param_default("electric", true); <BR>param_default("step", 2); <BR>param_default("position", null); <BR>param_default("cache", false); <BR>param_default("showOthers", false); <BR>param_default("multiple", null); <BR>var tmp = ["inputField", "displayArea", "button"]; <BR>for (var i in tmp) { <BR>if (typeof params[tmp[i]] == "string") { <BR>params[tmp[i]] = document.getElementById(params[tmp[i]]); <BR>} <BR>} <BR>if (!(params.flat || params.multiple || params.inputField || params.displayArea || params.button)) { <BR>alert("Calendar.setup:\n Nothing to setup (no fields found). Please check your code"); <BR>return false; <BR>} <BR>function onSelect(cal) { <BR>var p = cal.params; <BR>var update = (cal.dateClicked || p.electric); <BR>if (update && p.inputField) { <BR>p.inputField.value = cal.date.print(p.ifFormat); <BR>if (typeof p.inputField.onchange == "function") <BR>p.inputField.onchange(); <BR>} <BR>if (update && p.displayArea) <BR>p.displayArea.innerHTML = cal.date.print(p.daFormat); <BR>if (update && typeof p.onUpdate == "function") <BR>p.onUpdate(cal); <BR>if (update && p.flat) { <BR>if (typeof p.flatCallback == "function") <BR>p.flatCallback(cal); <BR>} <BR>if (update && p.singleClick && cal.dateClicked) <BR>cal.callCloseHandler(); <BR>}; <BR>if (params.flat != null) { <BR>if (typeof params.flat == "string") <BR>params.flat = document.getElementById(params.flat); <BR>if (!params.flat) { <BR>alert("Calendar.setup:\n Flat specified but can't find parent."); <BR>return false; <BR>} <BR>var cal = new Calendar(params.firstDay, params.date, params.onSelect || onSelect); <BR>cal.showsOtherMonths = params.showOthers; <BR>cal.showsTime = params.showsTime; <BR>cal.time24 = (params.timeFormat == "24"); <BR>cal.params = params; <BR>cal.weekNumbers = params.weekNumbers; <BR>cal.setRange(params.range[0], params.range[1]); <BR>cal.setDateStatusHandler(params.dateStatusFunc); <BR>cal.getDateText = params.dateText; <BR>if (params.ifFormat) { <BR>cal.setDateFormat(params.ifFormat); <BR>} <BR>if (params.inputField && typeof params.inputField.value == "string") { <BR>cal.parseDate(params.inputField.value); <BR>} <BR>cal.create(params.flat); <BR>cal.show(); <BR>return false; <BR>} <BR>var triggerEl = params.button || params.displayArea || params.inputField; <BR>triggerEl["on" + params.eventName] = function() { <BR>var dateEl = params.inputField || params.displayArea; <BR>var dateFmt = params.inputField ? params.ifFormat : params.daFormat; <BR>var mustCreate = false; <BR>var cal = window.calendar; <BR>if (dateEl) <BR>params.date = Date.parseDate(dateEl.value || dateEl.innerHTML, dateFmt); <BR>if (!(cal && params.cache)) { <BR>window.calendar = cal = new Calendar(params.firstDay, <BR>params.date, <BR>params.onSelect || onSelect, <BR>params.onClose || function(cal) { cal.hide(); }); <BR>cal.showsTime = params.showsTime; <BR>cal.time24 = (params.timeFormat == "24"); <BR>cal.weekNumbers = params.weekNumbers; <BR>mustCreate = true; <BR>} else { <BR>if (params.date) <BR>cal.setDate(params.date); <BR>cal.hide(); <BR>} <BR>if (params.multiple) { <BR>cal.multiple = {}; <BR>for (var i = params.multiple.length; --i >= 0;) { <BR>var d = params.multiple[i]; <BR>var ds = d.print("%Y%m%d"); <BR>cal.multiple[ds] = d; <BR>} <BR>} <BR>cal.showsOtherMonths = params.showOthers; <BR>cal.yearStep = params.step; <BR>cal.setRange(params.range[0], params.range[1]); <BR>cal.params = params; <BR>cal.setDateStatusHandler(params.dateStatusFunc); <BR>cal.getDateText = params.dateText; <BR>cal.setDateFormat(dateFmt); <BR>if (mustCreate) <BR>cal.create(); <BR>cal.refresh(); <BR>if (!params.position) <BR>cal.showAtElement(params.button || params.displayArea || params.inputField, params.align); <BR>else <BR>cal.showAt(params.position[0], params.position[1]); <BR>return false; <BR>}; <BR>return cal; <BR>}; <BR>//************ calendar-setup.js END ********************* <br><br>// ** I18N <BR>// Calendar big5-utf8 language <BR>// Author: Gary Fu, <gary@garyfu.idv.tw> <BR>// Encoding: utf8 <BR>// Distributed under the same terms as the calendar itself. <BR>// For translators: please use UTF-8 if possible. We strongly believe that <BR>// Unicode is the answer to a real internationalized world. Also please <BR>// include your contact information in the header, as can be seen above. <BR>// full day names <BR>Calendar._DN = new Array <BR>("星期日", <BR>"星期一", <BR>"星期二", <BR>"星期三", <BR>"星期四", <BR>"星期五", <BR>"星期六", <BR>"星期日"); <BR>// Please note that the following array of short day names (and the same goes <BR>// for short month names, _SMN) isn't absolutely necessary. We give it here <BR>// for exemplification on how one can customize the short day names, but if <BR>// they are simply the first N letters of the full name you can simply say: <BR>// <BR>// Calendar._SDN_len = N; // short day name length <BR>// Calendar._SMN_len = N; // short month name length <BR>// <BR>// If N = 3 then this is not needed either since we assume a value of 3 if not <BR>// present, to be compatible with translation files that were written before <BR>// this feature. <BR>// short day names <BR>Calendar._SDN = new Array <BR>("日", <BR>"一", <BR>"二", <BR>"三", <BR>"四", <BR>"五", <BR>"六", <BR>"日"); <BR>// First day of the week. "0" means display Sunday first, "1" means display <BR>// Monday first, etc. <BR>Calendar._FD = 0; <BR>// full month names <BR>Calendar._MN = new Array <BR>("一月", <BR>"二月", <BR>"三月", <BR>"四月", <BR>"五月", <BR>"六月", <BR>"七月", <BR>"八月", <BR>"九月", <BR>"十月", <BR>"十一月", <BR>"十二月"); <BR>// short month names <BR>Calendar._SMN = new Array <BR>("一月", <BR>"二月", <BR>"三月", <BR>"四月", <BR>"五月", <BR>"六月", <BR>"七月", <BR>"八月", <BR>"九月", <BR>"十月", <BR>"十一月", <BR>"十二月"); <BR>// tooltips <BR>Calendar._TT = {}; <BR>Calendar._TT["INFO"] = "關於"; <BR>Calendar._TT["ABOUT"] = <BR>"DHTML Date/Time Selector\n" + <BR>"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-) <BR>"For latest version visit: http://www.dynarch.com/projects/calendar/\n" + <BR>"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." + <BR>"\n\n" + <BR>"日期選擇方法:\n" + <BR>"- 使用 \xab, \xbb 按鈕可選擇年份\n" + <BR>"- 使用 " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " 按鈕可選擇月份\n" + <BR>"- 按住上面的按鈕可以加快選取"; <BR>Calendar._TT["ABOUT_TIME"] = "\n\n" + <BR>"時間選擇方法:\n" + <BR>"- 點擊任何的時間部份可增加其值\n" + <BR>"- 同時按Shift鍵再點擊可減少其值\n" + <BR>"- 點擊並拖曳可加快改變的值"; <BR>Calendar._TT["PREV_YEAR"] = "上一年 (按住選單)"; <BR>Calendar._TT["PREV_MONTH"] = "上一月 (按住選單)"; <BR>Calendar._TT["GO_TODAY"] = "到今日"; <BR>Calendar._TT["NEXT_MONTH"] = " 下一月(按住選單)"; <BR>Calendar._TT["NEXT_YEAR"] = "下一年 (按住選單)"; <BR>Calendar._TT["SEL_DATE"] = "選擇日期"; <BR>Calendar._TT["DRAG_TO_MOVE"] = "拖曳"; <BR>Calendar._TT["PART_TODAY"] = " (今日)"; <BR>// the following is to inform that "%s" is to be the first day of week <BR>// %s will be replaced with the day name. <BR>Calendar._TT["DAY_FIRST"] = "將 %s 顯示在前"; <BR>// This may be locale-dependent. It specifies the week-end days, as an array <BR>// of comma-se