pub/TWiki/JSCalendarContrib/doc/html/reference.html
changeset 0 414e01d06fd5
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/pub/TWiki/JSCalendarContrib/doc/html/reference.html	Sat Jan 26 15:50:53 2008 +0100
     1.3 @@ -0,0 +1,1738 @@
     1.4 +<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
     1.5 +<html>
     1.6 +<!--
     1.7 +
     1.8 +Generated from ../reference.tex by tex2page, v 2004-09-11
     1.9 +(running on MzScheme 209, unix), 
    1.10 +(c) Dorai Sitaram, 
    1.11 +http://www.ccs.neu.edu/~dorai/tex2page/tex2page-doc.html
    1.12 +
    1.13 +-->
    1.14 +<head>
    1.15 +<title>
    1.16 +DHTML Calendar Widget
    1.17 +</title>
    1.18 +<link rel="stylesheet" type="text/css" href="reference.css" title=default>
    1.19 +<link rel="stylesheet" type="text/css" href="reference-Z-S.css" title=default>
    1.20 +<meta name=robots content="index,follow">
    1.21 +</head>
    1.22 +<body>
    1.23 +<p>
    1.24 +</p>
    1.25 +<p>
    1.26 +</p>
    1.27 +<p>
    1.28 +</p>
    1.29 +<p>
    1.30 +</p>
    1.31 +<p>
    1.32 +</p>
    1.33 +<p>
    1.34 +</p>
    1.35 +<p>
    1.36 +
    1.37 +
    1.38 +
    1.39 +
    1.40 +</p>
    1.41 +<p>
    1.42 +
    1.43 +
    1.44 +</p>
    1.45 +<p>
    1.46 +</p>
    1.47 +<p>
    1.48 +</p>
    1.49 +<h1 class=title align=center><br><br>DHTML Calendar Widget</h1>
    1.50 +<p></p>
    1.51 +<div align=center>
    1.52 +Mihai Bazon, <tt>&lt;mihai_bazon@yahoo.com&gt;</tt><br>
    1.53 +&copy; Dynarch.com 2002-2005, <a href="http://www.dynarch.com/"><tt>www.dynarch.com</tt></a><p>March 7, 2005<br></p>
    1.54 +<p></p>
    1.55 +<p>
    1.56 +<span class=small>calendar version: 1.0 ``It is happening again''</span>
    1.57 +</p>
    1.58 +</div>
    1.59 +<p></p>
    1.60 +<p>
    1.61 +<span class=small><code class=verbatim>$Id: reference.html 7997 2005-12-27 20:23:39Z AndreUlrich $</code></span>
    1.62 +</p>
    1.63 +<span class=small><blockquote>
    1.64 +<div align=right><table><tr><td>
    1.65 +
    1.66 +</td></tr></table></div>
    1.67 +
    1.68 +</blockquote></span>
    1.69 +<a name="node_sec_Temp_1"></a>
    1.70 +<h1><a href="#node_toc_node_sec_Temp_1">Contents</a></h1>
    1.71 +<p><a name="node_toc_start"></a></p>
    1.72 +<p><b>
    1.73 +&nbsp; &nbsp; <a name="node_toc_node_sec_1"></a><a href="#node_sec_1">1&nbsp;&nbsp;Overview</a></b><br>
    1.74 +&nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_1.1"></a><a href="#node_sec_1.1">1.1&nbsp;&nbsp;How does this thing work?</a><br>
    1.75 +&nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_1.2"></a><a href="#node_sec_1.2">1.2&nbsp;&nbsp;Project files</a><br>
    1.76 +&nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_1.3"></a><a href="#node_sec_1.3">1.3&nbsp;&nbsp;License</a><br>
    1.77 +</p>
    1.78 +<p><b>
    1.79 +&nbsp; &nbsp; <a name="node_toc_node_sec_2"></a><a href="#node_sec_2">2&nbsp;&nbsp;Quick startup</a></b><br>
    1.80 +&nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_2.1"></a><a href="#node_sec_2.1">2.1&nbsp;&nbsp;Installing a popup calendar</a><br>
    1.81 +&nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_2.2"></a><a href="#node_sec_2.2">2.2&nbsp;&nbsp;Installing a flat calendar</a><br>
    1.82 +&nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_2.3"></a><a href="#node_sec_2.3">2.3&nbsp;&nbsp;<tt>Calendar.setup</tt> in detail</a><br>
    1.83 +</p>
    1.84 +<p><b>
    1.85 +&nbsp; &nbsp; <a name="node_toc_node_sec_3"></a><a href="#node_sec_3">3&nbsp;&nbsp;Recipes</a></b><br>
    1.86 +&nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_3.1"></a><a href="#node_sec_3.1">3.1&nbsp;&nbsp;Popup calendars</a><br>
    1.87 +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_3.1.1"></a><a href="#node_sec_3.1.1">3.1.1&nbsp;&nbsp;Simple text field with calendar attached to a button</a><br>
    1.88 +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_3.1.2"></a><a href="#node_sec_3.1.2">3.1.2&nbsp;&nbsp;Simple field with calendar attached to an image</a><br>
    1.89 +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_3.1.3"></a><a href="#node_sec_3.1.3">3.1.3&nbsp;&nbsp;Hidden field, plain text triggers</a><br>
    1.90 +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_3.1.4"></a><a href="#node_sec_3.1.4">3.1.4&nbsp;&nbsp;2 Linked fields, no trigger buttons</a><br>
    1.91 +&nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_3.2"></a><a href="#node_sec_3.2">3.2&nbsp;&nbsp;Flat calendars</a><br>
    1.92 +&nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_3.3"></a><a href="#node_sec_3.3">3.3&nbsp;&nbsp;Highlight special dates</a><br>
    1.93 +&nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_3.4"></a><a href="#node_sec_3.4">3.4&nbsp;&nbsp;Select multiple dates</a><br>
    1.94 +</p>
    1.95 +<p><b>
    1.96 +&nbsp; &nbsp; <a name="node_toc_node_sec_4"></a><a href="#node_sec_4">4&nbsp;&nbsp;The Calendar object overview</a></b><br>
    1.97 +&nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_4.1"></a><a href="#node_sec_4.1">4.1&nbsp;&nbsp;Creating a calendar</a><br>
    1.98 +&nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_4.2"></a><a href="#node_sec_4.2">4.2&nbsp;&nbsp;Order does matter ;-)</a><br>
    1.99 +&nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_4.3"></a><a href="#node_sec_4.3">4.3&nbsp;&nbsp;Caching the object</a><br>
   1.100 +&nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_4.4"></a><a href="#node_sec_4.4">4.4&nbsp;&nbsp;Callback functions</a><br>
   1.101 +</p>
   1.102 +<p><b>
   1.103 +&nbsp; &nbsp; <a name="node_toc_node_sec_5"></a><a href="#node_sec_5">5&nbsp;&nbsp;The Calendar object API reference</a></b><br>
   1.104 +&nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_5.1"></a><a href="#node_sec_5.1">5.1&nbsp;&nbsp;<tt>Calendar</tt> constructor</a><br>
   1.105 +&nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_5.2"></a><a href="#node_sec_5.2">5.2&nbsp;&nbsp;Useful member variables (properties)</a><br>
   1.106 +&nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_5.3"></a><a href="#node_sec_5.3">5.3&nbsp;&nbsp;Public methods</a><br>
   1.107 +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_5.3.1"></a><a href="#node_sec_5.3.1">5.3.1&nbsp;&nbsp;<tt>Calendar.create</tt></a><br>
   1.108 +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_5.3.2"></a><a href="#node_sec_5.3.2">5.3.2&nbsp;&nbsp;<tt>Calendar.callHandler</tt></a><br>
   1.109 +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_5.3.3"></a><a href="#node_sec_5.3.3">5.3.3&nbsp;&nbsp;<tt>Calendar.callCloseHandler</tt></a><br>
   1.110 +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_5.3.4"></a><a href="#node_sec_5.3.4">5.3.4&nbsp;&nbsp;<tt>Calendar.hide</tt></a><br>
   1.111 +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_5.3.5"></a><a href="#node_sec_5.3.5">5.3.5&nbsp;&nbsp;<tt>Calendar.setDateFormat</tt></a><br>
   1.112 +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_5.3.6"></a><a href="#node_sec_5.3.6">5.3.6&nbsp;&nbsp;<tt>Calendar.setTtDateFormat</tt></a><br>
   1.113 +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_5.3.7"></a><a href="#node_sec_5.3.7">5.3.7&nbsp;&nbsp;<tt>Calendar.setDisabledHandler</tt></a><br>
   1.114 +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_5.3.8"></a><a href="#node_sec_5.3.8">5.3.8&nbsp;&nbsp;<tt>Calendar.setDateStatusHandler</tt></a><br>
   1.115 +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_5.3.9"></a><a href="#node_sec_5.3.9">5.3.9&nbsp;&nbsp;<tt>Calendar.show</tt></a><br>
   1.116 +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_5.3.10"></a><a href="#node_sec_5.3.10">5.3.10&nbsp;&nbsp;<tt>Calendar.showAt</tt></a><br>
   1.117 +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_5.3.11"></a><a href="#node_sec_5.3.11">5.3.11&nbsp;&nbsp;<tt>Calendar.showAtElement</tt></a><br>
   1.118 +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_5.3.12"></a><a href="#node_sec_5.3.12">5.3.12&nbsp;&nbsp;<tt>Calendar.setDate</tt></a><br>
   1.119 +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_5.3.13"></a><a href="#node_sec_5.3.13">5.3.13&nbsp;&nbsp;<tt>Calendar.setFirstDayOfWeek</tt></a><br>
   1.120 +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_5.3.14"></a><a href="#node_sec_5.3.14">5.3.14&nbsp;&nbsp;<tt>Calendar.parseDate</tt></a><br>
   1.121 +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a name="node_toc_node_sec_5.3.15"></a><a href="#node_sec_5.3.15">5.3.15&nbsp;&nbsp;<tt>Calendar.setRange</tt></a><br>
   1.122 +</p>
   1.123 +<p><b>
   1.124 +&nbsp; &nbsp; <a name="node_toc_node_sec_6"></a><a href="#node_sec_6">6&nbsp;&nbsp;Side effects</a></b><br>
   1.125 +</p>
   1.126 +<p><b>
   1.127 +&nbsp; &nbsp; <a name="node_toc_node_sec_7"></a><a href="#node_sec_7">7&nbsp;&nbsp;Credits</a></b><br>
   1.128 +</p>
   1.129 +<p>
   1.130 +</p>
   1.131 +<p>
   1.132 +</p>
   1.133 +<a name="node_sec_1"></a>
   1.134 +<h1><a href="#node_toc_node_sec_1">1&nbsp;&nbsp;Overview</a></h1>
   1.135 +<p>The DHTML Calendar widget<a name="call_footnote_Temp_2"></a><a href="#footnote_Temp_2"><sup><small>1</small></sup></a>
   1.136 +is an (HTML) user interface element that gives end-users a friendly way to
   1.137 +select date and time.  It works in a web browser.  The first versions only provided
   1.138 +support for popup calendars, while starting with version 0.9 it also supports
   1.139 +``flat'' display.  A ``flat'' calendar is a calendar that stays visible in the
   1.140 +page all the time.  In this mode it could be very useful for ``blog'' pages and
   1.141 +other pages that require the calendar to be always present.</p>
   1.142 +<p>
   1.143 +The calendar is compatible with most popular browsers nowadays.  While it's
   1.144 +created using web standards and it should generally work with any compliant
   1.145 +browser, the following browsers were found to work: Mozilla/Firefox (the
   1.146 +development platform), Netscape&nbsp;6.0 or better, all other Gecko-based browsers,
   1.147 +Internet Explorer&nbsp;5.0 or better <em>for Windows</em><a name="call_footnote_Temp_3"></a><a href="#footnote_Temp_3"><sup><small>2</small></sup></a>, Opera&nbsp;7<a name="call_footnote_Temp_4"></a><a href="#footnote_Temp_4"><sup><small>3</small></sup></a>, Konqueror 3.1.2 and Apple Safari for
   1.148 +MacOSX.</p>
   1.149 +<p>
   1.150 +You can find the latest info and version at the calendar homepage:</p>
   1.151 +<p>
   1.152 +</p>
   1.153 +<div align=center><table><tr><td>
   1.154 +
   1.155 +<a href="http://www.dynarch.com/projects/calendar/"><tt>www.dynarch.com/projects/calendar</tt></a>
   1.156 +</td></tr></table></div>
   1.157 +<p>
   1.158 +</p>
   1.159 +<a name="node_sec_1.1"></a>
   1.160 +<h2><a href="#node_toc_node_sec_1.1">1.1&nbsp;&nbsp;How does this thing work?</a></h2>
   1.161 +<p>DHTML is not ``another kind of HTML''.  It's merely a naming convention.  DHTML
   1.162 +refers to the combination of HTML, CSS, JavaScript and DOM.  DOM (Document
   1.163 +Object Model) is a set of interfaces that glues the other three together.  In
   1.164 +other words, DOM allows dynamic modification of an HTML page through a program.
   1.165 +JavaScript is our programming language, since that's what browsers like.  CSS
   1.166 +is a way to make it look good ;-).  So all this soup is generically known as
   1.167 +DHTML.</p>
   1.168 +<p>
   1.169 +Using DOM calls, the program dynamically creates a <tt>&lt;table&gt;</tt> element
   1.170 +that contains a calendar for the given date and then inserts it in the document
   1.171 +body.  Then it shows this table at a specified position.  Usually the position
   1.172 +is related to some element in which the date needs to be displayed/entered,
   1.173 +such as an input field.</p>
   1.174 +<p>
   1.175 +By assigning a certain CSS class to the table we can control the look of the
   1.176 +calendar through an external CSS file; therefore, in order to change the
   1.177 +colors, backgrounds, rollover effects and other stuff, you can only change a
   1.178 +CSS file -- modification of the program itself is not necessary.</p>
   1.179 +<p>
   1.180 +</p>
   1.181 +<a name="node_sec_1.2"></a>
   1.182 +<h2><a href="#node_toc_node_sec_1.2">1.2&nbsp;&nbsp;Project files</a></h2>
   1.183 +<p>Here's a description of the project files, excluding documentation and example
   1.184 +files.</p>
   1.185 +<p>
   1.186 +</p>
   1.187 +<ul><p>
   1.188 +</p>
   1.189 +<li><p>the main program file (<tt>calendar.js</tt>).  This defines all the logic
   1.190 +behind the calendar widget.</p>
   1.191 +<p>
   1.192 +</p>
   1.193 +<li><p>the CSS files (<tt>calendar-*.css</tt>).  Loading one of them is
   1.194 +necessary in order to see the calendar as intended.</p>
   1.195 +<p>
   1.196 +</p>
   1.197 +<li><p>the language definition files (<tt>lang/calendar-*.js</tt>).  They are
   1.198 +plain JavaScript files that contain all texts that are displayed by the
   1.199 +calendar.  Loading one of them is necessary.</p>
   1.200 +<p>
   1.201 +</p>
   1.202 +<li><p>helper functions for quick setup of the calendar
   1.203 +(<tt>calendar-setup.js</tt>).  You can do fine without it, but starting with
   1.204 +version 0.9.3 this is the recommended way to setup a calendar.</p>
   1.205 +<p>
   1.206 +</p>
   1.207 +</ul><p></p>
   1.208 +<p>
   1.209 +</p>
   1.210 +<a name="node_sec_1.3"></a>
   1.211 +<h2><a href="#node_toc_node_sec_1.3">1.3&nbsp;&nbsp;License</a></h2>
   1.212 +<p></p>
   1.213 +<div align=center><table><tr><td>
   1.214 +
   1.215 +&copy; Dynarch.com 2002-2005,
   1.216 +<a href="http://www.dynarch.com/"><tt>www.dynarch.com</tt></a>
   1.217 +Author: Mihai Bazon
   1.218 +</td></tr></table></div>
   1.219 +<p>
   1.220 +The calendar is released under the
   1.221 +<a href="http://www.gnu.org/licenses/lgpl.html">GNU Lesser General Public License</a>.</p>
   1.222 +<p>
   1.223 +</p>
   1.224 +<a name="node_sec_2"></a>
   1.225 +<h1><a href="#node_toc_node_sec_2">2&nbsp;&nbsp;Quick startup</a></h1>
   1.226 +<p></p>
   1.227 +<p>
   1.228 +Installing the calendar used to be quite a task until version 0.9.3.  Starting
   1.229 +with 0.9.3 I have included the file <tt>calendar-setup.js</tt> whose goal is to
   1.230 +assist you to setup a popup or flat calendar in minutes.  You are
   1.231 +encouraged to modify this file and <em>not</em> calendar.js if you need
   1.232 +extra customization, but you're on your own.</p>
   1.233 +<p>
   1.234 +First you have to include the needed scripts and style-sheet.  Make sure you do
   1.235 +this in your document's <tt>&lt;head&gt;</tt> section, also make sure you put the
   1.236 +correct paths to the scripts.</p>
   1.237 +<p>
   1.238 +</p>
   1.239 +<pre class=verbatim>&lt;style type=&quot;text/css&quot;&gt;@import url(calendar-win2k-1.css);&lt;/style&gt;
   1.240 +&lt;script type=&quot;text/javascript&quot; src=&quot;calendar.js&quot;&gt;&lt;/script&gt;
   1.241 +&lt;script type=&quot;text/javascript&quot; src=&quot;lang/calendar-en.js&quot;&gt;&lt;/script&gt;
   1.242 +&lt;script type=&quot;text/javascript&quot; src=&quot;calendar-setup.js&quot;&gt;&lt;/script&gt;
   1.243 +</pre><p></p>
   1.244 +<p>
   1.245 +</p>
   1.246 +<a name="node_sec_2.1"></a>
   1.247 +<h2><a href="#node_toc_node_sec_2.1">2.1&nbsp;&nbsp;Installing a popup calendar</a></h2>
   1.248 +<p></p>
   1.249 +<p>
   1.250 +Now suppose you have the following HTML:</p>
   1.251 +<p>
   1.252 +</p>
   1.253 +<pre class=verbatim>&lt;form ...&gt;
   1.254 +  &lt;input type=&quot;text&quot; id=&quot;data&quot; name=&quot;data&quot; /&gt;
   1.255 +  &lt;button id=&quot;trigger&quot;&gt;...&lt;/button&gt;
   1.256 +&lt;/form&gt;
   1.257 +</pre><p></p>
   1.258 +<p>
   1.259 +You want the button to popup a calendar widget when clicked?  Just
   1.260 +insert the following code immediately <em>after</em> the HTML form:</p>
   1.261 +<p>
   1.262 +</p>
   1.263 +<pre class=verbatim>&lt;script type=&quot;text/javascript&quot;&gt;
   1.264 +  Calendar.setup(
   1.265 +    {
   1.266 +      inputField  : &quot;data&quot;,         // ID of the input field
   1.267 +      ifFormat    : &quot;%m %d, %Y&quot;,    // the date format
   1.268 +      button      : &quot;trigger&quot;       // ID of the button
   1.269 +    }
   1.270 +  );
   1.271 +&lt;/script&gt;
   1.272 +</pre><p></p>
   1.273 +<p>
   1.274 +The <tt>Calendar.setup</tt> function, defined in <tt>calendar-setup.js</tt>
   1.275 +takes care of ``patching'' the button to display a calendar when clicked.  The
   1.276 +calendar is by default in single-click mode and linked with the given input
   1.277 +field, so that when the end-user selects a date it will update the input field
   1.278 +with the date in the given format and close the calendar.  If you are a
   1.279 +long-term user of the calendar you probably remember that for doing this you
   1.280 +needed to write a couple functions and add an ``onclick'' handler for the
   1.281 +button by hand.</p>
   1.282 +<p>
   1.283 +By looking at the example above we can see that the function
   1.284 +<tt>Calendar.setup</tt> receives only one parameter: a JavaScript object.
   1.285 +Further, that object can have lots of properties that tell to the setup
   1.286 +function how would we like to have the calendar.  For instance, if we would
   1.287 +like a calendar that closes at double-click instead of single-click we would
   1.288 +also include the following: <tt>singleClick:false</tt>.</p>
   1.289 +<p>
   1.290 +For a list of all supported parameters please see the section
   1.291 +<a href="#node_sec_2.3">2.3</a>.</p>
   1.292 +<p>
   1.293 +</p>
   1.294 +<a name="node_sec_2.2"></a>
   1.295 +<h2><a href="#node_toc_node_sec_2.2">2.2&nbsp;&nbsp;Installing a flat calendar</a></h2>
   1.296 +<p></p>
   1.297 +<p>
   1.298 +Here's how to configure a flat calendar, using the same <tt>Calendar.setup</tt>
   1.299 +function.  First, you should have an empty element with an ID.  This element
   1.300 +will act as a container for the calendar.  It can be any block-level element,
   1.301 +such as DIV, TABLE, etc.  We will use a DIV in this example.</p>
   1.302 +<p>
   1.303 +</p>
   1.304 +<pre class=verbatim>&lt;div id=&quot;calendar-container&quot;&gt;&lt;/div&gt;
   1.305 +</pre><p></p>
   1.306 +<p>
   1.307 +Then there is the JavaScript code that sets up the calendar into the
   1.308 +``calendar-container'' DIV.  The code can occur anywhere in HTML
   1.309 +<em>after</em> the DIV element.</p>
   1.310 +<p>
   1.311 +</p>
   1.312 +<pre class=verbatim>&lt;script type=&quot;text/javascript&quot;&gt;
   1.313 +  function dateChanged(calendar) {
   1.314 +    // Beware that this function is called even if the end-user only
   1.315 +    // changed the month/year.  In order to determine if a date was
   1.316 +    // clicked you can use the dateClicked property of the calendar:
   1.317 +    if (calendar.dateClicked) {
   1.318 +      // OK, a date was clicked, redirect to /yyyy/mm/dd/index.php
   1.319 +      var y = calendar.date.getFullYear();
   1.320 +      var m = calendar.date.getMonth();     // integer, 0..11
   1.321 +      var d = calendar.date.getDate();      // integer, 1..31
   1.322 +      // redirect...
   1.323 +      window.location = &quot;/&quot; + y + &quot;/&quot; + m + &quot;/&quot; + d + &quot;/index.php&quot;;
   1.324 +    }
   1.325 +  };
   1.326 +
   1.327 +  Calendar.setup(
   1.328 +    {
   1.329 +      flat         : &quot;calendar-container&quot;, // ID of the parent element
   1.330 +      flatCallback : dateChanged           // our callback function
   1.331 +    }
   1.332 +  );
   1.333 +&lt;/script&gt;
   1.334 +</pre><p></p>
   1.335 +<p>
   1.336 +</p>
   1.337 +<a name="node_sec_2.3"></a>
   1.338 +<h2><a href="#node_toc_node_sec_2.3">2.3&nbsp;&nbsp;<tt>Calendar.setup</tt> in detail</a></h2>
   1.339 +<p></p>
   1.340 +<p>
   1.341 +Following there is the complete list of properties interpreted by
   1.342 +Calendar.setup.  All of them have default values, so you can pass only those
   1.343 +which you would like to customize.  Anyway, you <em>must</em> pass at least one
   1.344 +of <tt>inputField</tt>, <tt>displayArea</tt> or <tt>button</tt>, for a popup
   1.345 +calendar, or <tt>flat</tt> for a flat calendar.  Otherwise you will get a
   1.346 +warning message saying that there's nothing to setup.</p>
   1.347 +<p>
   1.348 +</p>
   1.349 +<span class=small><table border=0><tr><td valign=top ><b>property</b> </td><td valign=top ><b>type</b> </td><td valign=top ><b>description</b> </td><td valign=top ><b>default</b>
   1.350 +</td></tr>
   1.351 +<tr><td valign=top ><tt>inputField</tt>
   1.352 +</td><td valign=top >string </td><td valign=top >The ID of your input field.
   1.353 +</td><td valign=top >null
   1.354 +</td></tr>
   1.355 +<tr><td valign=top ><tt>displayArea</tt>
   1.356 +</td><td valign=top >string </td><td valign=top >This is the ID of a &lt;span&gt;, &lt;div&gt;, or any other element that you would like to use to display the current date. This is generally useful only if the input field is hidden, as an area to display the date.
   1.357 +</td><td valign=top >null
   1.358 +</td></tr>
   1.359 +<tr><td valign=top ><tt>button</tt>
   1.360 +</td><td valign=top >string </td><td valign=top >The ID of the calendar ``trigger''. This is an element (ordinarily a button or an image) that will dispatch a certain event (usually ``click'') to the function that creates and displays the calendar.
   1.361 +</td><td valign=top >null
   1.362 +</td></tr>
   1.363 +<tr><td valign=top ><tt>eventName</tt>
   1.364 +</td><td valign=top >string </td><td valign=top >The name of the event that will trigger the calendar. The name should be without the ``on'' prefix, such as ``click'' instead of ``onclick''. Virtually all users will want to let this have the default value (``click''). Anyway, it could be useful if, say, you want the calendar to appear when the input field is focused and have no trigger button (in this case use ``focus'' as the event name).
   1.365 +</td><td valign=top >``click''
   1.366 +</td></tr>
   1.367 +<tr><td valign=top ><tt>ifFormat</tt>
   1.368 +</td><td valign=top >string </td><td valign=top >The format string that will be used to enter the date in the input field. This format will be honored even if the input field is hidden.
   1.369 +</td><td valign=top >``%Y/%m/%d''
   1.370 +</td></tr>
   1.371 +<tr><td valign=top ><tt>daFormat</tt>
   1.372 +</td><td valign=top >string </td><td valign=top >Format of the date displayed in the displayArea (if specified).
   1.373 +</td><td valign=top >``%Y/%m/%d''
   1.374 +</td></tr>
   1.375 +<tr><td valign=top ><tt>singleClick</tt>
   1.376 +</td><td valign=top >boolean </td><td valign=top >Wether the calendar is in ``single-click mode'' or ``double-click mode''. If true (the default) the calendar will be created in single-click mode.
   1.377 +</td><td valign=top >true
   1.378 +</td></tr>
   1.379 +<tr><td valign=top ><tt>disableFunc</tt>
   1.380 +</td><td valign=top >function </td><td valign=top >A function that receives a JS Date object.  It should return
   1.381 +<tt>true</tt> if that date has to be disabled, <tt>false</tt> otherwise.
   1.382 +<font color="red">DEPRECATED (see below).</font>
   1.383 +</td><td valign=top >null
   1.384 +</td></tr>
   1.385 +<tr><td valign=top ><tt>dateStatusFunc</tt>
   1.386 +</td><td valign=top >function </td><td valign=top >A function that receives a JS Date object and returns a boolean
   1.387 +or a string.  This function allows one to set a certain CSS class to some
   1.388 +date, therefore making it look different.  If it returns <tt>true</tt> then
   1.389 +the date will be disabled.  If it returns <tt>false</tt> nothing special
   1.390 +happens with the given date.  If it returns a string then that will be taken
   1.391 +as a CSS class and appended to the date element.  If this string is
   1.392 +``disabled'' then the date is also disabled (therefore is like returning
   1.393 +<tt>true</tt>).  For more information please also refer to section
   1.394 +<a href="#node_sec_5.3.8">5.3.8</a>.
   1.395 +</td><td valign=top >null
   1.396 +</td></tr>
   1.397 +<tr><td valign=top ><tt>firstDay</tt>
   1.398 +</td><td valign=top >integer </td><td valign=top >Specifies which day is to be displayed as the first day of
   1.399 +week.  Possible values are 0 to 6; 0 means Sunday, 1 means Monday, ..., 6
   1.400 +means Saturday.  The end user can easily change this too, by clicking on the
   1.401 +day name in the calendar header.
   1.402 +</td><td valign=top >0
   1.403 +</td></tr>
   1.404 +<tr><td valign=top ><tt>weekNumbers</tt>
   1.405 +</td><td valign=top >boolean </td><td valign=top >If ``true'' then the calendar will display week numbers.
   1.406 +</td><td valign=top >true
   1.407 +</td></tr>
   1.408 +<tr><td valign=top ><tt>align</tt>
   1.409 +</td><td valign=top >string </td><td valign=top >Alignment of the calendar, relative to the reference element. The
   1.410 +reference element is dynamically chosen like this: if a displayArea is
   1.411 +specified then it will be the reference element. Otherwise, the input field
   1.412 +is the reference element.  For the meaning of the alignment characters
   1.413 +please section <a href="#node_sec_5.3.11">5.3.11</a>.
   1.414 +</td><td valign=top >``Bl''
   1.415 +</td></tr>
   1.416 +<tr><td valign=top ><tt>range</tt>
   1.417 +</td><td valign=top >array </td><td valign=top >An array having exactly 2 elements, integers. (!) The first [0] element is the minimum year that is available, and the second [1] element is the maximum year that the calendar will allow.
   1.418 +</td><td valign=top >[1900, 2999]
   1.419 +</td></tr>
   1.420 +<tr><td valign=top ><tt>flat</tt>
   1.421 +</td><td valign=top >string </td><td valign=top >If you want a flat calendar, pass the ID of the parent object in
   1.422 +this property.  If not, pass <tt>null</tt> here (or nothing at all as
   1.423 +<tt>null</tt> is the default value).
   1.424 +</td><td valign=top >null
   1.425 +</td></tr>
   1.426 +<tr><td valign=top ><tt>flatCallback</tt>
   1.427 +</td><td valign=top >function </td><td valign=top >You should provide this function if the calendar is flat.  It
   1.428 +will be called when the date in the calendar is changed with a reference to
   1.429 +the calendar object.  See section <a href="#node_sec_2.2">2.2</a> for an example
   1.430 +of how to setup a flat calendar.
   1.431 +</td><td valign=top >null
   1.432 +</td></tr>
   1.433 +<tr><td valign=top ><tt>onSelect</tt>
   1.434 +</td><td valign=top >function </td><td valign=top >If you provide a function handler here then you have to manage
   1.435 +the ``click-on-date'' event by yourself.  Look in the calendar-setup.js and
   1.436 +take as an example the onSelect handler that you can see there.
   1.437 +</td><td valign=top >null
   1.438 +</td></tr>
   1.439 +<tr><td valign=top ><tt>onClose</tt>
   1.440 +</td><td valign=top >function </td><td valign=top >This handler will be called when the calendar needs to close.
   1.441 +You don't need to provide one, but if you do it's your responsibility to
   1.442 +hide/destroy the calendar.  You're on your own.  Check the calendar-setup.js
   1.443 +file for an example.
   1.444 +</td><td valign=top >null
   1.445 +</td></tr>
   1.446 +<tr><td valign=top ><tt>onUpdate</tt>
   1.447 +</td><td valign=top >function </td><td valign=top >If you supply a function handler here, it will be called right
   1.448 +after the target field is updated with a new date.  You can use this to
   1.449 +chain 2 calendars, for instance to setup a default date in the second just
   1.450 +after a date was selected in the first.
   1.451 +</td><td valign=top >null
   1.452 +</td></tr>
   1.453 +<tr><td valign=top ><tt>date</tt>
   1.454 +</td><td valign=top >date </td><td valign=top >This allows you to setup an initial date where the calendar will be
   1.455 +positioned to.  If absent then the calendar will open to the today date.
   1.456 +</td><td valign=top >null
   1.457 +</td></tr>
   1.458 +<tr><td valign=top ><tt>showsTime</tt>
   1.459 +</td><td valign=top >boolean </td><td valign=top >If this is set to <tt>true</tt> then the calendar will also
   1.460 +allow time selection.
   1.461 +</td><td valign=top >false
   1.462 +</td></tr>
   1.463 +<tr><td valign=top ><tt>timeFormat</tt>
   1.464 +</td><td valign=top >string </td><td valign=top >Set this to ``12'' or ``24'' to configure the way that the
   1.465 +calendar will display time.
   1.466 +</td><td valign=top >``24''
   1.467 +</td></tr>
   1.468 +<tr><td valign=top ><tt>electric</tt>
   1.469 +</td><td valign=top >boolean </td><td valign=top >Set this to ``false'' if you want the calendar to update the
   1.470 +field only when closed (by default it updates the field at each date change,
   1.471 +even if the calendar is not closed) </td><td valign=top >true
   1.472 +</td></tr>
   1.473 +<tr><td valign=top ><tt>position</tt>
   1.474 +</td><td valign=top >array </td><td valign=top >Specifies the [x, y] position, relative to page's top-left corner,
   1.475 +where the calendar will be displayed.  If not passed then the position will
   1.476 +be computed based on the ``align'' parameter.  Defaults to ``null'' (not
   1.477 +used). </td><td valign=top >null
   1.478 +</td></tr>
   1.479 +<tr><td valign=top ><tt>cache</tt>
   1.480 +</td><td valign=top >boolean </td><td valign=top >Set this to ``true'' if you want to cache the calendar object.
   1.481 +This means that a single calendar object will be used for all fields that
   1.482 +require a popup calendar </td><td valign=top >false
   1.483 +</td></tr>
   1.484 +<tr><td valign=top ><tt>showOthers</tt>
   1.485 +</td><td valign=top >boolean </td><td valign=top >If set to ``true'' then days belonging to months overlapping
   1.486 +with the currently displayed month will also be displayed in the calendar
   1.487 +(but in a ``faded-out'' color) </td><td valign=top >false
   1.488 +
   1.489 +</td></tr></table>
   1.490 +
   1.491 +</span><p>
   1.492 +</p>
   1.493 +<a name="node_sec_3"></a>
   1.494 +<h1><a href="#node_toc_node_sec_3">3&nbsp;&nbsp;Recipes</a></h1>
   1.495 +<p>This section presents some common ways to setup a calendar using the
   1.496 +<tt>Calendar.setup</tt> function detailed in the previous section.</p>
   1.497 +<p>
   1.498 +We don't discuss here about loading the JS or CSS code -- so make sure you
   1.499 +add the proper &lt;script&gt; and &lt;style&gt; or &lt;link&gt; elements in your
   1.500 +HTML code.  Also, when we present input fields, please note that they should
   1.501 +be embedded in some form in order for data to be actually sent to server; we
   1.502 +don't discuss these things here because they are not related to our
   1.503 +calendar.</p>
   1.504 +<p>
   1.505 +</p>
   1.506 +<a name="node_sec_3.1"></a>
   1.507 +<h2><a href="#node_toc_node_sec_3.1">3.1&nbsp;&nbsp;Popup calendars</a></h2>
   1.508 +<p>These samples can be found in the file “<tt>simple-1.html</tt>” from the
   1.509 +calendar package.</p>
   1.510 +<p>
   1.511 +</p>
   1.512 +<a name="node_sec_3.1.1"></a>
   1.513 +<h3><a href="#node_toc_node_sec_3.1.1">3.1.1&nbsp;&nbsp;Simple text field with calendar attached to a button</a></h3>
   1.514 +<p></p>
   1.515 +<p>
   1.516 +This piece of code will create a calendar for a simple input field with a
   1.517 +button that will open the calendar when clicked.</p>
   1.518 +<p>
   1.519 +</p>
   1.520 +<pre class=verbatim>&lt;input type=&quot;text&quot; name=&quot;date&quot; id=&quot;f_date_b&quot;
   1.521 +       /&gt;&lt;button type=&quot;reset&quot; id=&quot;f_trigger_b&quot;
   1.522 +       &gt;...&lt;/button&gt;
   1.523 +&lt;script type=&quot;text/javascript&quot;&gt;
   1.524 +    Calendar.setup({
   1.525 +        inputField     :    &quot;f_date_b&quot;,           //*
   1.526 +        ifFormat       :    &quot;%m/%d/%Y %I:%M %p&quot;,
   1.527 +        showsTime      :    true,
   1.528 +        button         :    &quot;f_trigger_b&quot;,        //*
   1.529 +        step           :    1
   1.530 +    });
   1.531 +&lt;/script&gt;
   1.532 +</pre><p></p>
   1.533 +<p>
   1.534 +Note that this code does more actually; the only <em>required</em> fields are
   1.535 +those marked with “//*” -- that is, the ID of the input field and the ID of
   1.536 +the button need to be passed to <tt>Calendar.setup</tt> in order for the
   1.537 +calendar to be properly assigned to this input field.  As one can easily
   1.538 +guess from the argument names, the other arguments configure a certain date
   1.539 +format, instruct the calendar to also include a time selector and display
   1.540 +every year in the drop-down boxes (the “step” parameter) -- instead of showing
   1.541 +every other year as the default calendar does.</p>
   1.542 +<p>
   1.543 +</p>
   1.544 +<a name="node_sec_3.1.2"></a>
   1.545 +<h3><a href="#node_toc_node_sec_3.1.2">3.1.2&nbsp;&nbsp;Simple field with calendar attached to an image</a></h3>
   1.546 +<p>Same as the above, but the element that triggers the calendar is this time
   1.547 +an image, not a button.</p>
   1.548 +<p>
   1.549 +</p>
   1.550 +<pre class=verbatim>&lt;input type=&quot;text&quot; name=&quot;date&quot; id=&quot;f_date_c&quot; readonly=&quot;1&quot; /&gt;
   1.551 +&lt;img src=&quot;img.gif&quot; id=&quot;f_trigger_c&quot;
   1.552 +     style=&quot;cursor: pointer; border: 1px solid red;&quot;
   1.553 +     title=&quot;Date selector&quot;
   1.554 +     onmouseover=&quot;this.style.background='red';&quot;
   1.555 +     onmouseout=&quot;this.style.background=''&quot; /&gt;
   1.556 +&lt;script type=&quot;text/javascript&quot;&gt;
   1.557 +    Calendar.setup({
   1.558 +        inputField     :    &quot;f_date_c&quot;,
   1.559 +        ifFormat       :    &quot;%B %e, %Y&quot;,
   1.560 +        button         :    &quot;f_trigger_c&quot;,
   1.561 +        align          :    &quot;Tl&quot;,
   1.562 +        singleClick    :    false
   1.563 +    });
   1.564 +&lt;/script&gt;
   1.565 +</pre><p></p>
   1.566 +<p>
   1.567 +Note that the same 2 parameters are required as in the previous case; the
   1.568 +difference is that the 'button' parameter now gets the ID of the image
   1.569 +instead of the ID of the button.  But the event is the same: at 'onclick' on
   1.570 +the element that is passed as 'button', the calendar will be shown.</p>
   1.571 +<p>
   1.572 +The above code additionally sets an alignment mode -- the parameters are
   1.573 +described in <a href="#node_sec_5.3.11">5.3.11</a>.</p>
   1.574 +<p>
   1.575 +</p>
   1.576 +<a name="node_sec_3.1.3"></a>
   1.577 +<h3><a href="#node_toc_node_sec_3.1.3">3.1.3&nbsp;&nbsp;Hidden field, plain text triggers</a></h3>
   1.578 +<p>Sometimes, to assure that the date is well formatted, you might want not to
   1.579 +allow the end user to write a date manually.  This can easily be achieved
   1.580 +with an input field by setting its <tt>readonly</tt> attribute, which is
   1.581 +defined by the HTML4 standard; however, here's an even nicer approach: our
   1.582 +calendar widget allows you to use a hidden field as the way to pass data to
   1.583 +server, and a “display area” to show the end user the selected date.  The
   1.584 +“display area” can be any HTML element, such as a DIV or a SPAN or
   1.585 +whatever -- we will use a SPAN in our sample.</p>
   1.586 +<p>
   1.587 +</p>
   1.588 +<pre class=verbatim>&lt;input type=&quot;hidden&quot; name=&quot;date&quot; id=&quot;f_date_d&quot; /&gt;
   1.589 +
   1.590 +&lt;p&gt;Your birthday:
   1.591 +   &lt;span style=&quot;background-color: #ff8; cursor: default;&quot;
   1.592 +         onmouseover=&quot;this.style.backgroundColor='#ff0';&quot;
   1.593 +         onmouseout=&quot;this.style.backgroundColor='#ff8';&quot;
   1.594 +         id=&quot;show_d&quot;
   1.595 +   &gt;Click to open date selector&lt;/span&gt;.&lt;/p&gt;
   1.596 +
   1.597 +&lt;script type=&quot;text/javascript&quot;&gt;
   1.598 +    Calendar.setup({
   1.599 +        inputField     :    &quot;f_date_d&quot;,
   1.600 +        ifFormat       :    &quot;%Y/%d/%m&quot;,
   1.601 +        displayArea    :    &quot;show_d&quot;,
   1.602 +        daFormat       :    &quot;%A, %B %d, %Y&quot;,
   1.603 +    });
   1.604 +&lt;/script&gt;
   1.605 +</pre><p></p>
   1.606 +<p>
   1.607 +The above code will configure a calendar attached to the hidden field and to
   1.608 +the SPAN having the id=“show_d”.  When the SPAN element is clicked, the
   1.609 +calendar opens and allows the end user to chose a date.  When the date is
   1.610 +chosen, the input field will be updated with the value in the format
   1.611 +“<tt>%Y/%d/%m</tt>”, and the SPAN element will display the date in a
   1.612 +friendlier format (defined by “<tt>daFormat</tt>”).</p>
   1.613 +<p>
   1.614 +Beware that using this approach will make your page unfunctional in browsers
   1.615 +that do not support JavaScript or our calendar.</p>
   1.616 +<p>
   1.617 +</p>
   1.618 +<a name="node_sec_3.1.4"></a>
   1.619 +<h3><a href="#node_toc_node_sec_3.1.4">3.1.4&nbsp;&nbsp;2 Linked fields, no trigger buttons</a></h3>
   1.620 +<p>Supposing you want to create 2 fields that hold an interval of exactly one
   1.621 +week.  The first is the starting date, and the second is the ending date.
   1.622 +You want the fields to be automatically updated when some date is clicked in
   1.623 +one or the other, in order to keep exactly one week difference between them.</p>
   1.624 +<p>
   1.625 +</p>
   1.626 +<pre class=verbatim>&lt;input type=&quot;text&quot; name=&quot;date&quot; id=&quot;f_date_a&quot; /&gt;
   1.627 +&lt;input type=&quot;text&quot; name=&quot;date&quot; id=&quot;f_calcdate&quot; /&gt;
   1.628 +
   1.629 +&lt;script type=&quot;text/javascript&quot;&gt;
   1.630 +    function catcalc(cal) {
   1.631 +        var date = cal.date;
   1.632 +        var time = date.getTime()
   1.633 +        // use the _other_ field
   1.634 +        var field = document.getElementById(&quot;f_calcdate&quot;);
   1.635 +        if (field == cal.params.inputField) {
   1.636 +            field = document.getElementById(&quot;f_date_a&quot;);
   1.637 +            time -= Date.WEEK; // substract one week
   1.638 +        } else {
   1.639 +            time += Date.WEEK; // add one week
   1.640 +        }
   1.641 +        var date2 = new Date(time);
   1.642 +        field.value = date2.print(&quot;%Y-%m-%d %H:%M&quot;);
   1.643 +    }
   1.644 +    Calendar.setup({
   1.645 +        inputField     :    &quot;f_date_a&quot;,
   1.646 +        ifFormat       :    &quot;%Y-%m-%d %H:%M&quot;,
   1.647 +        showsTime      :    true,
   1.648 +        timeFormat     :    &quot;24&quot;,
   1.649 +        onUpdate       :    catcalc
   1.650 +    });
   1.651 +    Calendar.setup({
   1.652 +        inputField     :    &quot;f_calcdate&quot;,
   1.653 +        ifFormat       :    &quot;%Y-%m-%d %H:%M&quot;,
   1.654 +        showsTime      :    true,
   1.655 +        timeFormat     :    &quot;24&quot;,
   1.656 +        onUpdate       :    catcalc
   1.657 +    });
   1.658 +&lt;/script&gt;
   1.659 +</pre><p></p>
   1.660 +<p>
   1.661 +The above code will configure 2 input fields with calendars attached, as
   1.662 +usual.  The first thing to note is that there's no trigger button -- in such
   1.663 +case, the calendar will popup when one clicks into the input field.  Using
   1.664 +the <tt>onUpdate</tt> parameter, we pass a reference to a function of ours
   1.665 +that will get called after a date was selected.  In that function we
   1.666 +determine what field was updated and we compute the date in the other input
   1.667 +field such that it keeps a one week difference between the two.  Enjoy! :-)</p>
   1.668 +<p>
   1.669 +</p>
   1.670 +<a name="node_sec_3.2"></a>
   1.671 +<h2><a href="#node_toc_node_sec_3.2">3.2&nbsp;&nbsp;Flat calendars</a></h2>
   1.672 +<p>This sample can be found in “<tt>simple-2.html</tt>”.  It will configure a
   1.673 +flat calendar that is always displayed in the page, in the DIV having the
   1.674 +id=“calendar-container”.  When a date is clicked our function hander gets
   1.675 +called (<tt>dateChanged</tt>) and it will compute an URL to jump to based on
   1.676 +the selected date, then use <tt>window.location</tt> to visit the new link.</p>
   1.677 +<p>
   1.678 +</p>
   1.679 +<pre class=verbatim>&lt;div style=&quot;float: right; margin-left: 1em; margin-bottom: 1em;&quot;
   1.680 +id=&quot;calendar-container&quot;&gt;&lt;/div&gt;
   1.681 +
   1.682 +&lt;script type=&quot;text/javascript&quot;&gt;
   1.683 +  function dateChanged(calendar) {
   1.684 +    // Beware that this function is called even if the end-user only
   1.685 +    // changed the month/year.  In order to determine if a date was
   1.686 +    // clicked you can use the dateClicked property of the calendar:
   1.687 +    if (calendar.dateClicked) {
   1.688 +      // OK, a date was clicked, redirect to /yyyy/mm/dd/index.php
   1.689 +      var y = calendar.date.getFullYear();
   1.690 +      var m = calendar.date.getMonth();     // integer, 0..11
   1.691 +      var d = calendar.date.getDate();      // integer, 1..31
   1.692 +      // redirect...
   1.693 +      window.location = &quot;/&quot; + y + &quot;/&quot; + m + &quot;/&quot; + d + &quot;/index.php&quot;;
   1.694 +    }
   1.695 +  };
   1.696 +
   1.697 +  Calendar.setup(
   1.698 +    {
   1.699 +      flat         : &quot;calendar-container&quot;, // ID of the parent element
   1.700 +      flatCallback : dateChanged           // our callback function
   1.701 +    }
   1.702 +  );
   1.703 +&lt;/script&gt;
   1.704 +</pre><p></p>
   1.705 +<p>
   1.706 +</p>
   1.707 +<a name="node_sec_3.3"></a>
   1.708 +<h2><a href="#node_toc_node_sec_3.3">3.3&nbsp;&nbsp;Highlight special dates</a></h2>
   1.709 +<p>So you want to display certain dates in a different color, or with bold
   1.710 +font, or whatever, right?  Well, no problem -- our calendar can do this as
   1.711 +well.  It doesn't matter if it's a flat or popup calendar -- we'll use a flat
   1.712 +one for this sample.  The idea, however, is that you need to have the dates
   1.713 +in an array or a JavaScript object -- whatever is suitable for your way of
   1.714 +thinking -- and use it from a function that returns a value, telling the
   1.715 +calendar what kind of date is the passed one.</p>
   1.716 +<p>
   1.717 +Too much talking, here's the code ;-)</p>
   1.718 +<p>
   1.719 +</p>
   1.720 +<pre class=verbatim>&lt;!-- this goes into the &lt;head&gt; tag --&gt;
   1.721 +&lt;style type=&quot;text/css&quot;&gt;
   1.722 +  .special { background-color: #000; color: #fff; }
   1.723 +&lt;/style&gt;
   1.724 +
   1.725 +&lt;!-- and the rest inside the &lt;body&gt; --&gt;
   1.726 +&lt;div style=&quot;float: right; margin-left: 1em; margin-bottom: 1em;&quot;
   1.727 +id=&quot;calendar-container&quot;&gt;&lt;/div&gt;
   1.728 +
   1.729 +&lt;script type=&quot;text/javascript&quot;&gt;
   1.730 +  var SPECIAL_DAYS = {
   1.731 +    0 : [ 13, 24 ],		// special days in January
   1.732 +    2 : [ 1, 6, 8, 12, 18 ],	// special days in March
   1.733 +    8 : [ 21, 11 ]		// special days in September
   1.734 +  };
   1.735 +
   1.736 +  function dateIsSpecial(year, month, day) {
   1.737 +    var m = SPECIAL_DAYS[month];
   1.738 +    if (!m) return false;
   1.739 +    for (var i in m) if (m[i] == day) return true;
   1.740 +    return false;
   1.741 +  };
   1.742 +
   1.743 +  function dateChanged(calendar) {
   1.744 +    // Beware that this function is called even if the end-user only
   1.745 +    // changed the month/year.  In order to determine if a date was
   1.746 +    // clicked you can use the dateClicked property of the calendar:
   1.747 +    if (calendar.dateClicked) {
   1.748 +      // OK, a date was clicked, redirect to /yyyy/mm/dd/index.php
   1.749 +      var y = calendar.date.getFullYear();
   1.750 +      var m = calendar.date.getMonth();     // integer, 0..11
   1.751 +      var d = calendar.date.getDate();      // integer, 1..31
   1.752 +      // redirect...
   1.753 +      window.location = &quot;/&quot; + y + &quot;/&quot; + m + &quot;/&quot; + d + &quot;/index.php&quot;;
   1.754 +    }
   1.755 +  };
   1.756 +
   1.757 +  function ourDateStatusFunc(date, y, m, d) {
   1.758 +    if (dateIsSpecial(y, m, d))
   1.759 +      return &quot;special&quot;;
   1.760 +    else
   1.761 +      return false; // other dates are enabled
   1.762 +      // return true if you want to disable other dates
   1.763 +  };
   1.764 +
   1.765 +  Calendar.setup(
   1.766 +    {
   1.767 +      flat         : &quot;calendar-container&quot;, // ID of the parent element
   1.768 +      flatCallback : dateChanged,          // our callback function
   1.769 +      dateStatusFunc : ourDateStatusFunc
   1.770 +    }
   1.771 +  );
   1.772 +&lt;/script&gt;
   1.773 +</pre><p></p>
   1.774 +<p>
   1.775 +So the above code creates a normal flat calendar, like in the previous
   1.776 +sample.  We hook into it with the function “<tt>ourDateStatusFunc</tt>”,
   1.777 +which receives a date object as the first argument, and also the year,
   1.778 +month, date as the next 3 arguments (normally, you can extract year, month,
   1.779 +date from the first parameter too, but we pass them separately for
   1.780 +convenience, as it's very likely that they are going to be used in this
   1.781 +function).</p>
   1.782 +<p>
   1.783 +So, this function receives a date.  It can return <tt>false</tt> if you want
   1.784 +no special action to be taken on that date, <tt>true</tt> if that date
   1.785 +should be disabled (unselectable), or a string if you want to assign a
   1.786 +special CSS class to that date.  We return “special” for the dates that we
   1.787 +want to highlight -- and note that we defined a “special” look for them in
   1.788 +the CSS section.</p>
   1.789 +<p>
   1.790 +I used a simple approach here to define what dates are special.  There's a
   1.791 +JavaScript object (the SPECIAL_DAYS global variable) which holds an array
   1.792 +of dates for each month.  Month numbers start at zero (January).  Months
   1.793 +that don't contain special dates can be absent from this object.  Note that
   1.794 +the way to implement this is completely separated from the calendar
   1.795 +code -- therefore, feel free to use your imagination if you have better
   1.796 +ideas. :-)</p>
   1.797 +<p>
   1.798 +</p>
   1.799 +<a name="node_sec_3.4"></a>
   1.800 +<h2><a href="#node_toc_node_sec_3.4">3.4&nbsp;&nbsp;Select multiple dates</a></h2>
   1.801 +<p>Starting version 1.0, the calendar is able to handle multiple dates
   1.802 +selection.  You just need to pass the “<tt>multiple</tt>” parameter to
   1.803 +<tt>Calendar.setup</tt> and add some special code that interprets the
   1.804 +selection once the calendar is closed.</p>
   1.805 +<p>
   1.806 +</p>
   1.807 +<pre class=verbatim>&lt;a id=&quot;trigger&quot; href=&quot;#&quot;&gt;[open calendar...]&lt;/a&gt;
   1.808 +&lt;div id=&quot;output&quot;&gt;&lt;/div&gt;
   1.809 +&lt;script type=&quot;text/javascript&quot;&gt;//&lt;![CDATA[
   1.810 +    // the default multiple dates selected,
   1.811 +    // first time the calendar is displayed
   1.812 +    var MA = [];
   1.813 +
   1.814 +    function closed(cal) {
   1.815 +
   1.816 +      // here we'll write the output; this is only for example.  You
   1.817 +      // will normally fill an input field or something with the dates.
   1.818 +      var el = document.getElementById(&quot;output&quot;);
   1.819 +
   1.820 +      // reset initial content.
   1.821 +      el.innerHTML = &quot;&quot;;
   1.822 +
   1.823 +      // Reset the &quot;MA&quot;, in case one triggers the calendar again.
   1.824 +      // CAREFUL!  You don't want to do &quot;MA = [];&quot;.  We need to modify
   1.825 +      // the value of the current array, instead of creating a new one.
   1.826 +      // Calendar.setup is called only once! :-)  So be careful.
   1.827 +      MA.length = 0;
   1.828 +
   1.829 +      // walk the calendar's multiple dates selection hash
   1.830 +      for (var i in cal.multiple) {
   1.831 +        var d = cal.multiple[i];
   1.832 +        // sometimes the date is not actually selected,
   1.833 +        // so let's check
   1.834 +        if (d) {
   1.835 +          // OK, selected.  Fill an input field or something.
   1.836 +          el.innerHTML += d.print(&quot;%A, %Y %B %d&quot;) + &quot;&lt;br /&gt;&quot;;
   1.837 +          // and push it in the &quot;MA&quot;, in case one triggers the calendar again.
   1.838 +          MA[MA.length] = d;
   1.839 +        }
   1.840 +      }
   1.841 +      cal.hide();
   1.842 +      return true;
   1.843 +    };
   1.844 +
   1.845 +    Calendar.setup({
   1.846 +      align      : &quot;BR&quot;,
   1.847 +      showOthers : true,
   1.848 +      multiple   : MA, // pass the initial or computed array of multiple dates
   1.849 +      onClose    : closed,
   1.850 +      button     : &quot;trigger&quot;
   1.851 +    });
   1.852 +//]]&gt;&lt;/script&gt;
   1.853 +</pre><p></p>
   1.854 +<p>
   1.855 +The above code creates a popup calendar and passes to it an array of dates,
   1.856 +which is initially empty, in the “multiple” argument.  When the calendar is
   1.857 +closed it will call our “<tt>closed</tt>” function handler; in this handler
   1.858 +we determine what dates were actually selected, inspecting the
   1.859 +“<tt>cal.multiple</tt>” property, we display them in a DIV element right
   1.860 +next to the &lt;a&gt; element that opens the calendar, and we reinitialize the
   1.861 +global array of selected dates (which will be used if the end user opens the
   1.862 +calendar again).  I guess the code speaks for itself, right? :-)</p>
   1.863 +<p>
   1.864 +</p>
   1.865 +<a name="node_sec_4"></a>
   1.866 +<h1><a href="#node_toc_node_sec_4">4&nbsp;&nbsp;The Calendar object overview</a></h1>
   1.867 +<p></p>
   1.868 +<p>
   1.869 +Basically you should be able to setup the calendar with the function presented
   1.870 +in the previous section.  However, if for some reason <tt>Calendar.setup</tt>
   1.871 +doesn't provide all the functionality that you need and you want to tweak into
   1.872 +the process of creating and configuring the calendar ``by hand'', then this
   1.873 +section is the way to go.</p>
   1.874 +<p>
   1.875 +The file <tt>calendar.js</tt> implements the functionality of the calendar.
   1.876 +All (well, almost all) functions and variables are embedded in the JavaScript
   1.877 +object ``Calendar''.</p>
   1.878 +<p>
   1.879 +You can instantiate a <tt>Calendar</tt> object by calling the constructor, like
   1.880 +this: <tt>var cal = new Calendar(<tt>...</tt>)</tt>.  We will discuss the parameters
   1.881 +later.  After creating the object, the variable <tt>cal</tt> will contain a
   1.882 +reference to it.  You can use this reference to access further options of the
   1.883 +calendar, for instance:</p>
   1.884 +<p>
   1.885 +</p>
   1.886 +<pre class=verbatim>cal.weekNumbers = false; // do not display week numbers
   1.887 +cal.showsTime = true;    // include a time selector
   1.888 +cal.setDateFormat(&quot;%Y.%m.%d %H:%M&quot;); // set this format: 2003.12.31 23:59
   1.889 +cal.setDisabledHandler(function(date, year, month, day) {
   1.890 +  // verify date and return true if it has to be disabled
   1.891 +  // ``date'' is a JS Date object, but if you only need the
   1.892 +  // year, month and/or day you can get them separately as
   1.893 +  // next 3 parameters, as you can see in the declaration
   1.894 +  if (year == 2004) {
   1.895 +    // disable all dates from 2004
   1.896 +    return true;
   1.897 +  }
   1.898 +  return false;
   1.899 +});
   1.900 +</pre><p></p>
   1.901 +<p>
   1.902 +etc.  Prior to version
   1.903 +0.9.3 this was the only way to configure it.  The <tt>Calendar.setup</tt>
   1.904 +function, documented in section <a href="#node_sec_2">2</a>, basically does the same
   1.905 +things (actually more) in order to setup the calendar, based on the parameters
   1.906 +that you provided.</p>
   1.907 +<p>
   1.908 +</p>
   1.909 +<a name="node_sec_4.1"></a>
   1.910 +<h2><a href="#node_toc_node_sec_4.1">4.1&nbsp;&nbsp;Creating a calendar</a></h2>
   1.911 +<p>The calendar is created by following some steps (even the function
   1.912 +<tt>Calendar.setup</tt>, described in section <a href="#node_sec_2">2</a>, does the
   1.913 +same).  While you can skip optional (marked ``opt'') steps if you're happy with
   1.914 +the defaults, please respect the order below.</p>
   1.915 +<p>
   1.916 +</p>
   1.917 +<ol><p>
   1.918 +</p>
   1.919 +<li><p><em>Instantiate</em> a <tt>Calendar</tt> object.  Details about this in
   1.920 +section <a href="#node_sec_5.1">5.1</a>.</p>
   1.921 +<p>
   1.922 +</p>
   1.923 +<li><p><b>opt</b>&nbsp;&nbsp; Set the <tt>weekNumbers</tt> property to <tt>false</tt> if you don't want
   1.924 +the calendar to display week numbers.</p>
   1.925 +<p>
   1.926 +</p>
   1.927 +<li><p><b>opt</b>&nbsp;&nbsp; Set the <tt>showsTime</tt> property to <tt>true</tt> if you
   1.928 +want the calendar to also provide a time selector.</p>
   1.929 +<p>
   1.930 +</p>
   1.931 +<li><p><b>opt</b>&nbsp;&nbsp; Set the <tt>time24</tt> property to <tt>false</tt> if you want
   1.932 +the time selector to be in 12-hour format.  Default is 24-hour format.  This
   1.933 +property only has effect if you also set <tt>showsTime</tt> to
   1.934 +<tt>true</tt>.</p>
   1.935 +<p>
   1.936 +</p>
   1.937 +<li><p><b>opt</b>&nbsp;&nbsp; Set the range of years available for selection (see section
   1.938 +<a href="#node_sec_5.3.15">5.3.15</a>).  The default range is [1970..2050].</p>
   1.939 +<p>
   1.940 +</p>
   1.941 +<li><p><b>opt</b>&nbsp;&nbsp; Set the <tt>getDateStatus</tt> property.  You should pass
   1.942 +here a function that receives a JavaScript <tt>Date</tt> object and returns
   1.943 +<tt>true</tt> if the given date should be disabled, false otherwise (details in
   1.944 +section <a href="#node_sec_5.3.7">5.3.7</a>).</p>
   1.945 +<p>
   1.946 +</p>
   1.947 +<li><p><b>opt</b>&nbsp;&nbsp; Set a date format.  Your handler function, passed to the
   1.948 +calendar constructor, will be called when a date is selected with a reference
   1.949 +to the calendar and a date string in this format.</p>
   1.950 +<p>
   1.951 +</p>
   1.952 +<li><p><em>Create</em> the HTML elements related to the calendar.  This step
   1.953 +practically puts the calendar in your HTML page.  You simply call
   1.954 +<tt>Calendar.create()</tt>.  You can give an optional parameter if you wanna
   1.955 +create a flat calendar (details in section <a href="#node_sec_5.3.1">5.3.1</a>).</p>
   1.956 +<p>
   1.957 +</p>
   1.958 +<li><p><b>opt</b>&nbsp;&nbsp; Initialize the calendar to a certain date, for instance from
   1.959 +the input field.</p>
   1.960 +<p>
   1.961 +</p>
   1.962 +<li><p>Show the calendar (details in section <a href="#node_sec_5.3.9">5.3.9</a>).</p>
   1.963 +<p>
   1.964 +</p>
   1.965 +</ol><p></p>
   1.966 +<p>
   1.967 +</p>
   1.968 +<a name="node_sec_4.2"></a>
   1.969 +<h2><a href="#node_toc_node_sec_4.2">4.2&nbsp;&nbsp;Order does matter ;-)</a></h2>
   1.970 +<p>As you could see in the previous section, there are more steps to be followed
   1.971 +in order to setup the calendar.  This happens because there are two different
   1.972 +things that need to be accomplished: first there is the JavaScript object, that
   1.973 +is created with <tt>new Calendar(<tt>...</tt>)</tt>.  Secondly there are the HTML
   1.974 +elements that actually lets you see and manipulate the calendar.</p>
   1.975 +<p>
   1.976 +</p>
   1.977 +<span class=small>[ Those that did UI<a name="call_footnote_Temp_5"></a><a href="#footnote_Temp_5"><sup><small>4</small></sup></a> programming, no matter in what
   1.978 +language and on what platform, may be familiar with this concept.  First there
   1.979 +is the object in memory that lets you manipulate the UI element, and secondly
   1.980 +there is the UI element (known as ``control'', ``window'', ``widget'', etc.),
   1.981 +also in memory but you don't usually access it directly. ]
   1.982 +</span><p>
   1.983 +By instantiating the calendar we create the JavaScript object.  It lets us
   1.984 +configure some properties and it also knows how to create the UI element (the
   1.985 +HTML elements actually) that will eventually be what the end-user sees on
   1.986 +screen.  Creation of the HTML element is accomplished by the function
   1.987 +<tt>Calendar.create</tt>.  It knows how to create popup or flat calendars.
   1.988 +This function is described in section <a href="#node_sec_5.3.1">5.3.1</a>.</p>
   1.989 +<p>
   1.990 +Some properties need to be set prior to creating the HTML elements, because
   1.991 +otherwise they wouldn't have any effect.  Such a property is
   1.992 +<tt>weekNumbers</tt> -- it has the default value ``true'', and if you don't
   1.993 +want the calendar to display the week numbers you have to set it to false.  If,
   1.994 +however, you do that <em>after</em> calling <tt>Calendar.create</tt> the calendar
   1.995 +would still display the week numbers, because the HTML elements are already
   1.996 +created (including the <tt>&lt;td&gt;</tt>-s in the <tt>&lt;table&gt;</tt> element that
   1.997 +should contain the week numbers).  For this reason the order of the steps above
   1.998 +is important.</p>
   1.999 +<p>
  1.1000 +Another example is when you want to show the calendar.  The ``create'' function
  1.1001 +does create the HTML elements, but they are initially hidden (have the style
  1.1002 +``display: none'') unless the calendar is a flat calendar that should be always
  1.1003 +visible in the page.  Obviously, the <tt>Calendar.show</tt> function should be
  1.1004 +called <em>after</em> calling <tt>Calendar.create</tt>.</p>
  1.1005 +<p>
  1.1006 +</p>
  1.1007 +<a name="node_sec_4.3"></a>
  1.1008 +<h2><a href="#node_toc_node_sec_4.3">4.3&nbsp;&nbsp;Caching the object</a></h2>
  1.1009 +<p>Suppose the end-user has popped up a calendar and selects a date.  The calendar
  1.1010 +then closes.  What really happens now?</p>
  1.1011 +<p>
  1.1012 +There are two approaches.  The first (used in very old versions of the
  1.1013 +calendar) was to drop completely the Calendar object and when the end-user pops
  1.1014 +up the calendar again to create another one.  This approach is bad for more
  1.1015 +reasons:</p>
  1.1016 +<p>
  1.1017 +</p>
  1.1018 +<ul><p>
  1.1019 +</p>
  1.1020 +<li><p>creating the JavaScript object and HTML elements is time-consuming</p>
  1.1021 +<p>
  1.1022 +</p>
  1.1023 +<li><p>we may loose some end-user preferences (i.e. he might prefer to have
  1.1024 +Monday for the first day of week and probably already clicked it the first time
  1.1025 +when the calendar was opened, but now he has to do it again)</p>
  1.1026 +<p>
  1.1027 +</p>
  1.1028 +</ul><p></p>
  1.1029 +<p>
  1.1030 +The second approach, implemented by the <tt>Calendar.setup</tt> function, is to
  1.1031 +cache the JavaScript object.  It does this by checking the global variable
  1.1032 +<tt>window.calendar</tt> and if it is not null it assumes it is the created
  1.1033 +Calendar object.  When the end-user closes the calendar, our code will only
  1.1034 +call ``<tt>hide</tt>'' on it, therefore keeping the JavaScript object and the
  1.1035 +HTML elements in place.</p>
  1.1036 +<p>
  1.1037 +<font color="red">CAVEAT:</font> &nbsp;&nbsp;&nbsp;&nbsp;Since time selection support was introduced, this
  1.1038 +``object caching'' mechanism has the following drawback: if you once created
  1.1039 +the calendar with the time selection support, then other items that may not
  1.1040 +require this functionality will still get a calendar with the time selection
  1.1041 +support enabled.  And reciprocal. ;-)  Hopefully this will be corrected in a
  1.1042 +later version, but for now it doesn't seem such a big problem.</p>
  1.1043 +<p>
  1.1044 +</p>
  1.1045 +<a name="node_sec_4.4"></a>
  1.1046 +<h2><a href="#node_toc_node_sec_4.4">4.4&nbsp;&nbsp;Callback functions</a></h2>
  1.1047 +<p>You might rightfully wonder how is the calendar related to the input field?
  1.1048 +Who tells it that it has to update <em>that</em> input field when a date is
  1.1049 +selected, or that it has to jump to <em>that</em> URL when a date is clicked in
  1.1050 +flat mode?</p>
  1.1051 +<p>
  1.1052 +All this magic is done through callback functions.  The calendar doesn't know
  1.1053 +anything about the existence of an input field, nor does it know where to
  1.1054 +redirect the browser when a date is clicked in flat mode.  It just calls your
  1.1055 +callback when a particular event is happening, and you're responsible to handle
  1.1056 +it from there.  For a general purpose library I think this is the best model of
  1.1057 +making a truly reusable thing.</p>
  1.1058 +<p>
  1.1059 +The calendar supports the following user callbacks:</p>
  1.1060 +<p>
  1.1061 +</p>
  1.1062 +<ul><p>
  1.1063 +</p>
  1.1064 +<li><p><b>onSelect</b>&nbsp;&nbsp;  --  this gets called when the end-user changes the date in the
  1.1065 +calendar.  Documented in section <a href="#node_sec_5.1">5.1</a>.</p>
  1.1066 +<p>
  1.1067 +</p>
  1.1068 +<li><p><b>onClose</b>&nbsp;&nbsp;  --  this gets called when the calendar should close.  It's
  1.1069 +user's responsibility to close the calendar.  Details in section
  1.1070 +<a href="#node_sec_5.1">5.1</a>.</p>
  1.1071 +<p>
  1.1072 +</p>
  1.1073 +<li><p><b>getDateStatus</b>&nbsp;&nbsp;  --  this function gets called for any day in a month,
  1.1074 +just before displaying the month.  It is called with a JavaScript <tt>Date</tt>
  1.1075 +object and should return <tt>true</tt> if that date should be disabled, false
  1.1076 +if it's an ordinary date and no action should be taken, or it can return a
  1.1077 +string in which case the returned value will be appended to the element's CSS
  1.1078 +class (this way it provides a powerful way to make some dates ``special'',
  1.1079 +i.e. highlight them differently).  Details in section
  1.1080 +<a href="#node_sec_5.3.8">5.3.8</a>.</p>
  1.1081 +<p>
  1.1082 +</p>
  1.1083 +</ul><p></p>
  1.1084 +<p>
  1.1085 +</p>
  1.1086 +<a name="node_sec_5"></a>
  1.1087 +<h1><a href="#node_toc_node_sec_5">5&nbsp;&nbsp;The Calendar object API reference</a></h1>
  1.1088 +<p></p>
  1.1089 +<p>
  1.1090 +</p>
  1.1091 +<a name="node_sec_5.1"></a>
  1.1092 +<h2><a href="#node_toc_node_sec_5.1">5.1&nbsp;&nbsp;<tt>Calendar</tt> constructor</a></h2>
  1.1093 +<p></p>
  1.1094 +<p>
  1.1095 +Synopsis:</p>
  1.1096 +<p>
  1.1097 +</p>
  1.1098 +<pre class=verbatim>var calendar = Calendar(firstDayOfWeek, date, onSelect, onClose);
  1.1099 +</pre><p></p>
  1.1100 +<p>
  1.1101 +Parameters are as follows:</p>
  1.1102 +<p>
  1.1103 +</p>
  1.1104 +<ul><p>
  1.1105 +</p>
  1.1106 +<li><p><b>firstDayOfWeek</b>&nbsp;&nbsp;  --  specifies which day is to be displayed as the first
  1.1107 +day of week.  Possible values are 0 to 6; 0 means Sunday, 1 means Monday,
  1.1108 +..., 6 means Saturday.</p>
  1.1109 +<p>
  1.1110 +</p>
  1.1111 +<li><p><b>date</b>&nbsp;&nbsp;  --  a JavaScript Date object or <tt>null</tt>.  If <tt>null</tt>
  1.1112 +is passed then the calendar will default to today date.  Otherwise it will
  1.1113 +initialize on the given date.</p>
  1.1114 +<p>
  1.1115 +</p>
  1.1116 +<li><p><b>onSelect</b>&nbsp;&nbsp;  --  your callback for the ``onChange'' event.  See above.</p>
  1.1117 +<p>
  1.1118 +</p>
  1.1119 +<li><p><b>onClose</b>&nbsp;&nbsp;  --  your callback for the ``onClose'' event.  See above.</p>
  1.1120 +<p>
  1.1121 +</p>
  1.1122 +</ul><p></p>
  1.1123 +<p>
  1.1124 +</p>
  1.1125 +<a name="node_sec_Temp_6"></a>
  1.1126 +<h3><a href="#node_toc_node_sec_Temp_6">The <tt>onSelect</tt> event</a></h3>
  1.1127 +<p></p>
  1.1128 +<p>
  1.1129 +Here is a typical implementation of this function:</p>
  1.1130 +<p>
  1.1131 +</p>
  1.1132 +<pre class=verbatim>function onSelect(calendar, date) {
  1.1133 +  var input_field = document.getElementById(&quot;date&quot;);
  1.1134 +  input_field.value = date;
  1.1135 +};
  1.1136 +</pre><p></p>
  1.1137 +<p>
  1.1138 +<tt>date</tt> is in the format selected with <tt>calendar.setDateFormat</tt>
  1.1139 +(see section <a href="#node_sec_5.3.5">5.3.5</a>).  This code simply updates the
  1.1140 +input field.  If you want the calendar to be in single-click mode then you
  1.1141 +should also close the calendar after you updated the input field, so we come to
  1.1142 +the following version:</p>
  1.1143 +<p>
  1.1144 +</p>
  1.1145 +<pre class=verbatim>function onSelect(calendar, date) {
  1.1146 +  var input_field = document.getElementById(&quot;date&quot;);
  1.1147 +  input_field.value = date;
  1.1148 +  if (calendar.dateClicked) {
  1.1149 +    calendar.callCloseHandler(); // this calls &quot;onClose&quot; (see above)
  1.1150 +  }
  1.1151 +};
  1.1152 +</pre><p></p>
  1.1153 +<p>
  1.1154 +Note that we checked the member variable <tt>dateClicked</tt> and
  1.1155 +only hide the calendar if it's <tt>true</tt>.  If this variable is <tt>false</tt> it
  1.1156 +means that no date was actually selected, but the user only changed the
  1.1157 +month/year using the navigation buttons or the menus.  We don't want to hide
  1.1158 +the calendar in that case.</p>
  1.1159 +<p>
  1.1160 +</p>
  1.1161 +<a name="node_sec_Temp_7"></a>
  1.1162 +<h3><a href="#node_toc_node_sec_Temp_7">The <tt>onClose</tt> event</a></h3>
  1.1163 +<p></p>
  1.1164 +<p>
  1.1165 +This event is triggered when the calendar should close.  It should hide or
  1.1166 +destroy the calendar object -- the calendar itself just triggers the event, but
  1.1167 +it won't close itself.</p>
  1.1168 +<p>
  1.1169 +A typical implementation of this function is the following:</p>
  1.1170 +<p>
  1.1171 +</p>
  1.1172 +<pre class=verbatim>function onClose(calendar) {
  1.1173 +  calendar.hide();
  1.1174 +  // or calendar.destroy();
  1.1175 +};
  1.1176 +</pre><p></p>
  1.1177 +<p>
  1.1178 +</p>
  1.1179 +<a name="node_sec_5.2"></a>
  1.1180 +<h2><a href="#node_toc_node_sec_5.2">5.2&nbsp;&nbsp;Useful member variables (properties)</a></h2>
  1.1181 +<p></p>
  1.1182 +<p>
  1.1183 +After creating the Calendar object you can access the following properties:</p>
  1.1184 +<p>
  1.1185 +</p>
  1.1186 +<ul><p>
  1.1187 +</p>
  1.1188 +<li><p><tt>date</tt>  --  is a JavaScript <tt>Date</tt> object.  It will always
  1.1189 +reflect the date shown in the calendar (yes, even if the calendar is hidden).</p>
  1.1190 +<p>
  1.1191 +</p>
  1.1192 +<li><p><tt>isPopup</tt>  --  if this is true then the current Calendar object is
  1.1193 +a popup calendar.  Otherwise (false) we have a flat calendar.  This variable is
  1.1194 +set from <tt>Calendar.create</tt> and has no meaning before this function was
  1.1195 +called.</p>
  1.1196 +<p>
  1.1197 +</p>
  1.1198 +<li><p><tt>dateClicked</tt>  --  particularly useful in the <tt>onSelect</tt>
  1.1199 +handler, this variable tells us if a date was really clicked.  That's because
  1.1200 +the <tt>onSelect</tt> handler is called even if the end-user only changed the
  1.1201 +month/year but did not select a date.  We don't want to close the calendar in
  1.1202 +that case.</p>
  1.1203 +<p>
  1.1204 +</p>
  1.1205 +<li><p><tt>weekNumbers</tt>  --  if <tt>true</tt> (default) then the calendar
  1.1206 +displays week numbers.  If you don't want week numbers you have to set this
  1.1207 +variable to <tt>false</tt> <em>before</em> calling <tt>Calendar.create</tt>.</p>
  1.1208 +<p>
  1.1209 +</p>
  1.1210 +<li><p><tt>showsTime</tt> - if you set this to <tt>true</tt> (it is
  1.1211 +<tt>false</tt> by default) then the calendar will also include a time selector.</p>
  1.1212 +<p>
  1.1213 +</p>
  1.1214 +<li><p><tt>time24</tt> - if you set this to <tt>false</tt> then the time
  1.1215 +selector will be in 12-hour format.  It is in 24-hour format by default.</p>
  1.1216 +<p>
  1.1217 +</p>
  1.1218 +<li><p><tt>firstDayOfWeek</tt>  --  specifies the first day of week (0 to 6, pass
  1.1219 +0 for Sunday, 1 for Monday, ..., 6 for Saturday).  This variable is set from
  1.1220 +constructor, but you still have a chance to modify it <em>before</em> calling
  1.1221 +<tt>Calendar.create</tt>.</p>
  1.1222 +<p>
  1.1223 +</p>
  1.1224 +</ul><p></p>
  1.1225 +<p>
  1.1226 +There are lots of other member variables, but one should access them only
  1.1227 +through member functions so I won't document them here.</p>
  1.1228 +<p>
  1.1229 +</p>
  1.1230 +<a name="node_sec_5.3"></a>
  1.1231 +<h2><a href="#node_toc_node_sec_5.3">5.3&nbsp;&nbsp;Public methods</a></h2>
  1.1232 +<p></p>
  1.1233 +<a name="node_sec_5.3.1"></a>
  1.1234 +<h3><a href="#node_toc_node_sec_5.3.1">5.3.1&nbsp;&nbsp;<tt>Calendar.create</tt></a></h3>
  1.1235 +<p></p>
  1.1236 +<p>
  1.1237 +This function creates the afferent HTML elements that are needed to display the
  1.1238 +calendar.  You should call it after setting the calendar properties.  Synopsis:
  1.1239 +</p>
  1.1240 +<pre class=verbatim>calendar.create(); // creates a popup calendar
  1.1241 +  // -- or --
  1.1242 +calendar.create(document.getElementById(parent_id)); // makes a flat calendar
  1.1243 +</pre><p></p>
  1.1244 +<p>
  1.1245 +It can create a popup calendar or a flat calendar.  If the ``parent'' argument
  1.1246 +is present (it should be a <em>reference</em> -- not ID -- to an HTML element) then
  1.1247 +a flat calendar is created and it is inserted in the given element.</p>
  1.1248 +<p>
  1.1249 +At any moment, given a reference to a calendar object, we can inspect if it's a
  1.1250 +popup or a flat calendar by checking the boolean member variable
  1.1251 +<tt>isPopup</tt>:</p>
  1.1252 +<p>
  1.1253 +</p>
  1.1254 +<pre class=verbatim>if (calendar.isPopup) {
  1.1255 +   // this is a popup calendar
  1.1256 +} else {
  1.1257 +   // this is a flat calendar
  1.1258 +}
  1.1259 +</pre><p></p>
  1.1260 +<p>
  1.1261 +</p>
  1.1262 +<a name="node_sec_5.3.2"></a>
  1.1263 +<h3><a href="#node_toc_node_sec_5.3.2">5.3.2&nbsp;&nbsp;<tt>Calendar.callHandler</tt></a></h3>
  1.1264 +<p></p>
  1.1265 +<p>
  1.1266 +This function calls the first user callback (the
  1.1267 +<tt>onSelect</tt> handler) with the required parameters.</p>
  1.1268 +<p>
  1.1269 +</p>
  1.1270 +<a name="node_sec_5.3.3"></a>
  1.1271 +<h3><a href="#node_toc_node_sec_5.3.3">5.3.3&nbsp;&nbsp;<tt>Calendar.callCloseHandler</tt></a></h3>
  1.1272 +<p></p>
  1.1273 +<p>
  1.1274 +This function calls the second user callback (the
  1.1275 +<tt>onClose</tt> handler).  It's useful when you want to have a
  1.1276 +``single-click'' calendar -- just call this in your <tt>onSelect</tt> handler,
  1.1277 +if a date was clicked.</p>
  1.1278 +<p>
  1.1279 +</p>
  1.1280 +<a name="node_sec_5.3.4"></a>
  1.1281 +<h3><a href="#node_toc_node_sec_5.3.4">5.3.4&nbsp;&nbsp;<tt>Calendar.hide</tt></a></h3>
  1.1282 +<p></p>
  1.1283 +<p>
  1.1284 +Call this function to hide the calendar.  The calendar object and HTML elements
  1.1285 +will not be destroyed, thus you can later call one of the <tt>show</tt>
  1.1286 +functions on the same element.</p>
  1.1287 +<p>
  1.1288 +</p>
  1.1289 +<a name="node_sec_5.3.5"></a>
  1.1290 +<h3><a href="#node_toc_node_sec_5.3.5">5.3.5&nbsp;&nbsp;<tt>Calendar.setDateFormat</tt></a></h3>
  1.1291 +<p></p>
  1.1292 +<p>
  1.1293 +This function configures the format in which the calendar reports the date to
  1.1294 +your ``onSelect'' handler.  Call it like this:</p>
  1.1295 +<p>
  1.1296 +</p>
  1.1297 +<pre class=verbatim>calendar.setDateFormat(&quot;%y/%m/%d&quot;);
  1.1298 +</pre><p></p>
  1.1299 +<p>
  1.1300 +As you can see, it receives only one parameter, the required format.  The magic
  1.1301 +characters are the following:</p>
  1.1302 +<p>
  1.1303 +</p>
  1.1304 +<table border=0><tr><td valign=top ></td></tr>
  1.1305 +<tr><td valign=top ><tt>%a</tt> </td><td valign=top >abbreviated weekday name </td></tr>
  1.1306 +<tr><td valign=top ><tt>%A</tt> </td><td valign=top >full weekday name </td></tr>
  1.1307 +<tr><td valign=top ><tt>%b</tt> </td><td valign=top >abbreviated month name </td></tr>
  1.1308 +<tr><td valign=top ><tt>%B</tt> </td><td valign=top >full month name </td></tr>
  1.1309 +<tr><td valign=top ><tt>%C</tt> </td><td valign=top >century number </td></tr>
  1.1310 +<tr><td valign=top ><tt>%d</tt> </td><td valign=top >the day of the month ( 00 .. 31 ) </td></tr>
  1.1311 +<tr><td valign=top ><tt>%e</tt> </td><td valign=top >the day of the month ( 0 .. 31 ) </td></tr>
  1.1312 +<tr><td valign=top ><tt>%H</tt> </td><td valign=top >hour ( 00 .. 23 ) </td></tr>
  1.1313 +<tr><td valign=top ><tt>%I</tt> </td><td valign=top >hour ( 01 .. 12 ) </td></tr>
  1.1314 +<tr><td valign=top ><tt>%j</tt> </td><td valign=top >day of the year ( 000 .. 366 ) </td></tr>
  1.1315 +<tr><td valign=top ><tt>%k</tt> </td><td valign=top >hour ( 0 .. 23 ) </td></tr>
  1.1316 +<tr><td valign=top ><tt>%l</tt> </td><td valign=top >hour ( 1 .. 12 ) </td></tr>
  1.1317 +<tr><td valign=top ><tt>%m</tt> </td><td valign=top >month ( 01 .. 12 ) </td></tr>
  1.1318 +<tr><td valign=top ><tt>%M</tt> </td><td valign=top >minute ( 00 .. 59 ) </td></tr>
  1.1319 +<tr><td valign=top ><tt>%n</tt> </td><td valign=top >a newline character </td></tr>
  1.1320 +<tr><td valign=top ><tt>%p</tt> </td><td valign=top >``PM'' or ``AM'' </td></tr>
  1.1321 +<tr><td valign=top ><tt>%P</tt> </td><td valign=top >``pm'' or ``am'' </td></tr>
  1.1322 +<tr><td valign=top ><tt>%S</tt> </td><td valign=top >second ( 00 .. 59 ) </td></tr>
  1.1323 +<tr><td valign=top ><tt>%s</tt> </td><td valign=top >number of seconds since Epoch (since Jan 01 1970 00:00:00 UTC) </td></tr>
  1.1324 +<tr><td valign=top ><tt>%t</tt> </td><td valign=top >a tab character </td></tr>
  1.1325 +<tr><td valign=top ><tt>%U, %W, %V</tt> </td><td valign=top >the week number</td></tr>
  1.1326 +<tr><td valign=top ><tt>%u</tt> </td><td valign=top >the day of the week ( 1 .. 7, 1 = MON )</td></tr>
  1.1327 +<tr><td valign=top ><tt>%w</tt> </td><td valign=top >the day of the week ( 0 .. 6, 0 = SUN )</td></tr>
  1.1328 +<tr><td valign=top ><tt>%y</tt> </td><td valign=top >year without the century ( 00 .. 99 )</td></tr>
  1.1329 +<tr><td valign=top ><tt>%Y</tt> </td><td valign=top >year including the century ( ex. 1979 )</td></tr>
  1.1330 +<tr><td valign=top ><tt>%%</tt> </td><td valign=top >a literal <tt>%</tt> character
  1.1331 +</td></tr></table><p>
  1.1332 +There are more algorithms for computing the week number.  All
  1.1333 +three specifiers currently implement the same one, as defined by ISO 8601:
  1.1334 +``the week 01 is the week that has the Thursday in the current year, which is
  1.1335 +equivalent to the week that contains the fourth day of January.  Weeks start on
  1.1336 +Monday.''</p>
  1.1337 +<p>
  1.1338 +</p>
  1.1339 +<a name="node_sec_5.3.6"></a>
  1.1340 +<h3><a href="#node_toc_node_sec_5.3.6">5.3.6&nbsp;&nbsp;<tt>Calendar.setTtDateFormat</tt></a></h3>
  1.1341 +<p></p>
  1.1342 +<p>
  1.1343 +Has the same prototype as <tt>Calendar.setDateFormat</tt>, but refers to the
  1.1344 +format of the date displayed in the ``status bar'' when the mouse is over some
  1.1345 +date.</p>
  1.1346 +<p>
  1.1347 +</p>
  1.1348 +<a name="node_sec_5.3.7"></a>
  1.1349 +<h3><a href="#node_toc_node_sec_5.3.7">5.3.7&nbsp;&nbsp;<tt>Calendar.setDisabledHandler</tt></a></h3>
  1.1350 +<p></p>
  1.1351 +<p>
  1.1352 +This function allows you to specify a callback function that checks if a
  1.1353 +certain date must be disabled by the calendar.  You are responsible to write
  1.1354 +the callback function.  Synopsis:</p>
  1.1355 +<p>
  1.1356 +</p>
  1.1357 +<pre class=verbatim>function disallowDate(date) {
  1.1358 +  // date is a JS Date object
  1.1359 +  if (  date.getFullYear() == 2003 &amp;&amp;
  1.1360 +        date.getMonth()    == 6 /* July, it's zero-based */ &amp;&amp;
  1.1361 +        date.getDate()     == 5  ) {
  1.1362 +    return true; // disable July 5 2003
  1.1363 +  }
  1.1364 +  return false; // enable other dates
  1.1365 +};
  1.1366 +
  1.1367 +calendar.setDisabledHandler(disallowDate);
  1.1368 +</pre><p></p>
  1.1369 +<p>
  1.1370 +If you change this function in ``real-time'', meaning, without creating a new
  1.1371 +calendar, then you have to call <tt>calendar.refresh()</tt> to make it
  1.1372 +redisplay the month and take into account the new disabledHandler.
  1.1373 +<tt>Calendar.setup</tt> does this, so you have no such trouble with it.</p>
  1.1374 +<p>
  1.1375 +Note that <tt>disallowDate</tt> should be very fast, as it is called for each
  1.1376 +date in the month.  Thus, it gets called, say, 30 times before displaying the
  1.1377 +calendar, and 30 times when the month is changed.  Tests I've done so far show
  1.1378 +that it's still good, but in the future I might switch it to a different design
  1.1379 +(for instance, to call it once per month and to return an array of dates that
  1.1380 +must be disabled).</p>
  1.1381 +<p>
  1.1382 +This function should be considered deprecated in the favor of
  1.1383 +<tt>Calendar.setDateStatusHandler</tt>, described below.</p>
  1.1384 +<p>
  1.1385 +</p>
  1.1386 +<a name="node_sec_5.3.8"></a>
  1.1387 +<h3><a href="#node_toc_node_sec_5.3.8">5.3.8&nbsp;&nbsp;<tt>Calendar.setDateStatusHandler</tt></a></h3>
  1.1388 +<p></p>
  1.1389 +<p>
  1.1390 +This function obsoletes <tt>Calendar.setDisabledHandler</tt>.  You call it with
  1.1391 +a function parameter, but this function can return a boolean
  1.1392 +<em>or a string</em>.  If the return value is a boolean (<tt>true</tt> or
  1.1393 +<tt>false</tt>) then it behaves just like <tt>setDisabledHandler</tt>,
  1.1394 +therefore disabling the date if the return value is <tt>true</tt>.</p>
  1.1395 +<p>
  1.1396 +If the returned value is a string then the given date will gain an additional
  1.1397 +CSS class, namely the returned value.  You can use this to highlight some dates
  1.1398 +in some way.  Note that you are responsible for defining the CSS class that you
  1.1399 +return.  If you return the string ``disabled'' then that date will be disabled,
  1.1400 +just as if you returned <tt>true</tt>.</p>
  1.1401 +<p>
  1.1402 +Here is a simple scenario that shows what you can do with this function.  The
  1.1403 +following should be present in some of your styles, or in the document head in
  1.1404 +a STYLE tag (but put it <em>after</em> the place where the calendar styles were
  1.1405 +loaded):</p>
  1.1406 +<p>
  1.1407 +</p>
  1.1408 +<pre class=verbatim>.special { background-color: #000; color: #fff; }
  1.1409 +</pre><p></p>
  1.1410 +<p>
  1.1411 +And you would use the following code before calling <tt>Calendar.create()</tt>:</p>
  1.1412 +<p>
  1.1413 +</p>
  1.1414 +<pre class=verbatim>// this table holds your special days, so that we can automatize
  1.1415 +// things a bit:
  1.1416 +var SPECIAL_DAYS = {
  1.1417 +    0 : [ 13, 24 ],             // special days in January
  1.1418 +    2 : [ 1, 6, 8, 12, 18 ],    // special days in March
  1.1419 +    8 : [ 21, 11 ],             // special days in September
  1.1420 +   11 : [ 25, 28 ]              // special days in December
  1.1421 +};
  1.1422 +
  1.1423 +// this function returns true if the passed date is special
  1.1424 +function dateIsSpecial(year, month, day) {
  1.1425 +    var m = SPECIAL_DAYS[month];
  1.1426 +    if (!m) return false;
  1.1427 +    for (var i in m) if (m[i] == day) return true;
  1.1428 +    return false;
  1.1429 +}
  1.1430 +
  1.1431 +// this is the actual date status handler.  Note that it receives the
  1.1432 +// date object as well as separate values of year, month and date, for
  1.1433 +// your confort.
  1.1434 +function dateStatusHandler(date, y, m, d) {
  1.1435 +    if (dateIsSpecial(y, m, d)) return ``special'';
  1.1436 +    else return false;
  1.1437 +    // return true above if you want to disable other dates
  1.1438 +}
  1.1439 +
  1.1440 +// configure it to the calendar
  1.1441 +calendar.setDateStatusHandler(dateStatusHandler);
  1.1442 +</pre><p></p>
  1.1443 +<p>
  1.1444 +The above code adds the ``special'' class name to some dates that are defined
  1.1445 +in the SPECIAL_DAYS table.  Other dates will simply be displayed as default,
  1.1446 +enabled.</p>
  1.1447 +<p>
  1.1448 +</p>
  1.1449 +<a name="node_sec_5.3.9"></a>
  1.1450 +<h3><a href="#node_toc_node_sec_5.3.9">5.3.9&nbsp;&nbsp;<tt>Calendar.show</tt></a></h3>
  1.1451 +<p></p>
  1.1452 +<p>
  1.1453 +Call this function do show the calendar.  It basically sets the CSS ``display''
  1.1454 +property to ``block''.  It doesn't modify the calendar position.</p>
  1.1455 +<p>
  1.1456 +This function only makes sense when the calendar is in popup mode.</p>
  1.1457 +<p>
  1.1458 +</p>
  1.1459 +<a name="node_sec_5.3.10"></a>
  1.1460 +<h3><a href="#node_toc_node_sec_5.3.10">5.3.10&nbsp;&nbsp;<tt>Calendar.showAt</tt></a></h3>
  1.1461 +<p></p>
  1.1462 +<p>
  1.1463 +Call this to show the calendar at a certain (x, y) position.  Prototype:</p>
  1.1464 +<p>
  1.1465 +</p>
  1.1466 +<pre class=verbatim>calendar.showAt(x, y);
  1.1467 +</pre><p></p>
  1.1468 +<p>
  1.1469 +The parameters are absolute coordinates relative to the top left
  1.1470 +corner <em>of the page</em>, thus they are <em>page</em> coordinates not screen
  1.1471 +coordinates.</p>
  1.1472 +<p>
  1.1473 +After setting the given coordinates it calls Calendar.show.  This function only
  1.1474 +makes sense when the calendar is in popup mode.</p>
  1.1475 +<p>
  1.1476 +</p>
  1.1477 +<a name="node_sec_5.3.11"></a>
  1.1478 +<h3><a href="#node_toc_node_sec_5.3.11">5.3.11&nbsp;&nbsp;<tt>Calendar.showAtElement</tt></a></h3>
  1.1479 +<p></p>
  1.1480 +<p>
  1.1481 +This function is useful if you want to display the calendar near some element.
  1.1482 +You call it like this:</p>
  1.1483 +<p>
  1.1484 +</p>
  1.1485 +<pre class=verbatim>calendar.showAtElement(element, align);
  1.1486 +</pre><p></p>
  1.1487 +<p>
  1.1488 +where element is a reference to your element (for instance it can be the input
  1.1489 +field that displays the date) and align is an optional parameter, of type string,
  1.1490 +containing one or two characters.  For instance, if you pass <tt>&quot;Br&quot;</tt> as
  1.1491 +align, the calendar will appear <em>below</em> the element and with its right
  1.1492 +margin continuing the element's right margin.</p>
  1.1493 +<p>
  1.1494 +As stated above, align may contain one or two characters.  The first character
  1.1495 +dictates the vertical alignment, relative to the element, and the second
  1.1496 +character dictates the horizontal alignment.  If the second character is
  1.1497 +missing it will be assumed <tt>&quot;l&quot;</tt> (the left margin of the calendar will
  1.1498 +be at the same horizontal position as the left margin of the element).</p>
  1.1499 +<p>
  1.1500 +The characters given for the align parameters are case sensitive.  This
  1.1501 +function only makes sense when the calendar is in popup mode.  After computing
  1.1502 +the position it uses <tt>Calendar.showAt</tt> to display the calendar there.</p>
  1.1503 +<p>
  1.1504 +</p>
  1.1505 +<a name="node_sec_Temp_8"></a>
  1.1506 +<h4><a href="#node_toc_node_sec_Temp_8">Vertical alignment</a></h4>
  1.1507 +<p>The first character in ``<tt>align</tt>'' can take one of the following values:</p>
  1.1508 +<p>
  1.1509 +</p>
  1.1510 +<ul><p>
  1.1511 +</p>
  1.1512 +<li><p><tt>T</tt>  --  completely above the reference element (bottom margin of
  1.1513 +the calendar aligned to the top margin of the element).</p>
  1.1514 +<p>
  1.1515 +</p>
  1.1516 +<li><p><tt>t</tt>  --  above the element but may overlap it (bottom margin of the calendar aligned to
  1.1517 +the bottom margin of the element).</p>
  1.1518 +<p>
  1.1519 +</p>
  1.1520 +<li><p><tt>c</tt>  --  the calendar displays vertically centered to the reference
  1.1521 +element.  It might overlap it (that depends on the horizontal alignment).</p>
  1.1522 +<p>
  1.1523 +</p>
  1.1524 +<li><p><tt>b</tt>  --  below the element but may overlap it (top margin of the calendar aligned to
  1.1525 +the top margin of the element).</p>
  1.1526 +<p>
  1.1527 +</p>
  1.1528 +<li><p><tt>B</tt>  --  completely below the element (top margin of the calendar
  1.1529 +aligned to the bottom margin of the element).</p>
  1.1530 +<p>
  1.1531 +</p>
  1.1532 +</ul><p></p>
  1.1533 +<p>
  1.1534 +</p>
  1.1535 +<a name="node_sec_Temp_9"></a>
  1.1536 +<h4><a href="#node_toc_node_sec_Temp_9">Horizontal alignment</a></h4>
  1.1537 +<p>The second character in ``<tt>align</tt>'' can take one of the following values:</p>
  1.1538 +<p>
  1.1539 +</p>
  1.1540 +<ul><p>
  1.1541 +</p>
  1.1542 +<li><p><tt>L</tt>  --  completely to the left of the reference element (right
  1.1543 +margin of the calendar aligned to the left margin of the element).</p>
  1.1544 +<p>
  1.1545 +</p>
  1.1546 +<li><p><tt>l</tt>  --  to the left of the element but may overlap it (left margin
  1.1547 +of the calendar aligned to the left margin of the element).</p>
  1.1548 +<p>
  1.1549 +</p>
  1.1550 +<li><p><tt>c</tt>  --  horizontally centered to the element.  Might overlap it,
  1.1551 +depending on the vertical alignment.</p>
  1.1552 +<p>
  1.1553 +</p>
  1.1554 +<li><p><tt>r</tt>  --  to the right of the element but may overlap it (right
  1.1555 +margin of the calendar aligned to the right margin of the element).</p>
  1.1556 +<p>
  1.1557 +</p>
  1.1558 +<li><p><tt>R</tt>  --  completely to the right of the element (left margin of the
  1.1559 +calendar aligned to the right margin of the element).</p>
  1.1560 +<p>
  1.1561 +</p>
  1.1562 +</ul><p></p>
  1.1563 +<p>
  1.1564 +</p>
  1.1565 +<a name="node_sec_Temp_10"></a>
  1.1566 +<h4><a href="#node_toc_node_sec_Temp_10">Default values</a></h4>
  1.1567 +<p>If the ``<tt>align</tt>'' parameter is missing the calendar will choose
  1.1568 +``<tt>Br</tt>''.</p>
  1.1569 +<p>
  1.1570 +</p>
  1.1571 +<a name="node_sec_5.3.12"></a>
  1.1572 +<h3><a href="#node_toc_node_sec_5.3.12">5.3.12&nbsp;&nbsp;<tt>Calendar.setDate</tt></a></h3>
  1.1573 +<p></p>
  1.1574 +<p>
  1.1575 +Receives a JavaScript <tt>Date</tt> object.  Sets the given date in the
  1.1576 +calendar.  If the calendar is visible the new date is displayed immediately.</p>
  1.1577 +<p>
  1.1578 +</p>
  1.1579 +<pre class=verbatim>calendar.setDate(new Date()); // go today
  1.1580 +</pre><p></p>
  1.1581 +<p>
  1.1582 +</p>
  1.1583 +<a name="node_sec_5.3.13"></a>
  1.1584 +<h3><a href="#node_toc_node_sec_5.3.13">5.3.13&nbsp;&nbsp;<tt>Calendar.setFirstDayOfWeek</tt></a></h3>
  1.1585 +<p></p>
  1.1586 +<p>
  1.1587 +Changes the first day of week.  The parameter has to be a numeric value ranging
  1.1588 +from 0 to 6.  Pass 0 for Sunday, 1 for Monday, ..., 6 for Saturday.</p>
  1.1589 +<p>
  1.1590 +</p>
  1.1591 +<pre class=verbatim>calendar.setFirstDayOfWeek(5); // start weeks on Friday
  1.1592 +</pre><p></p>
  1.1593 +<p>
  1.1594 +</p>
  1.1595 +<a name="node_sec_5.3.14"></a>
  1.1596 +<h3><a href="#node_toc_node_sec_5.3.14">5.3.14&nbsp;&nbsp;<tt>Calendar.parseDate</tt></a></h3>
  1.1597 +<p></p>
  1.1598 +<p>
  1.1599 +Use this function to parse a date given as string and to move the calendar to
  1.1600 +that date.</p>
  1.1601 +<p>
  1.1602 +The algorithm tries to parse the date according to the format that was
  1.1603 +previously set with <tt>Calendar.setDateFormat</tt>; if that fails, it still
  1.1604 +tries to get some valid date out of it (it doesn't read your thoughts, though).</p>
  1.1605 +<p>
  1.1606 +</p>
  1.1607 +<pre class=verbatim>calendar.parseDate(&quot;2003/07/06&quot;);
  1.1608 +</pre><p></p>
  1.1609 +<p>
  1.1610 +</p>
  1.1611 +<a name="node_sec_5.3.15"></a>
  1.1612 +<h3><a href="#node_toc_node_sec_5.3.15">5.3.15&nbsp;&nbsp;<tt>Calendar.setRange</tt></a></h3>
  1.1613 +<p></p>
  1.1614 +<p>
  1.1615 +Sets the range of years that are allowed in the calendar.  Synopsis:</p>
  1.1616 +<p>
  1.1617 +</p>
  1.1618 +<pre class=verbatim>calendar.setRange(1970, 2050);
  1.1619 +</pre><p></p>
  1.1620 +<p>
  1.1621 +</p>
  1.1622 +<a name="node_sec_6"></a>
  1.1623 +<h1><a href="#node_toc_node_sec_6">6&nbsp;&nbsp;Side effects</a></h1>
  1.1624 +<p>The calendar code was intentionally embedded in an object to make it have as
  1.1625 +less as possible side effects.  However, there are some -- not harmful, after
  1.1626 +all.  Here is a list of side effects; you can count they already happened after
  1.1627 +<tt>calendar.js</tt> was loaded.</p>
  1.1628 +<p>
  1.1629 +</p>
  1.1630 +<ol><p>
  1.1631 +</p>
  1.1632 +<li><p>The global variable <tt>window.calendar</tt> will be set to null.  This
  1.1633 +variable is used by the calendar code, especially when doing drag &amp; drop for
  1.1634 +moving the calendar.  In the future I might get rid of it, but for now it
  1.1635 +didn't harm anyone.</p>
  1.1636 +<p>
  1.1637 +</p>
  1.1638 +<li><p>The JavaScript <tt>Date</tt> object is modified.  We add some properties
  1.1639 +and functions that are very useful to our calendar.  It made more sense to add
  1.1640 +them directly to the <tt>Date</tt> object than to the calendar itself.
  1.1641 +Complete list:</p>
  1.1642 +<p>
  1.1643 +</p>
  1.1644 +<ol><p>
  1.1645 +</p>
  1.1646 +<li><p><tt>Date._MD    = new Array(31,28,31,30,31,30,31,31,30,31,30,31);</tt>
  1.1647 +</p>
  1.1648 +<li><p><tt>Date.SECOND = 1000 /* milliseconds */;</tt>
  1.1649 +</p>
  1.1650 +<li><p><tt>Date.MINUTE = 60 * Date.SECOND;</tt>
  1.1651 +</p>
  1.1652 +<li><p><tt>Date.HOUR   = 60 * Date.MINUTE;</tt>
  1.1653 +</p>
  1.1654 +<li><p><tt>Date.DAY    = 24 * Date.HOUR;</tt>
  1.1655 +</p>
  1.1656 +<li><p><tt>Date.WEEK   =  7 * Date.DAY;</tt></p>
  1.1657 +<p>
  1.1658 +</p>
  1.1659 +<li><p><tt>Date.prototype.getMonthDays</tt>(month)  --  returns the number of days
  1.1660 +of the given month, or of the current date object if no month was given.</p>
  1.1661 +<p>
  1.1662 +</p>
  1.1663 +<li><p><tt>Date.prototype.getWeekNumber</tt>()  --  returns the week number of the
  1.1664 +date in the current object.</p>
  1.1665 +<p>
  1.1666 +</p>
  1.1667 +<li><p><tt>Date.prototype.equalsTo</tt>(other_date)  --  compare the current date
  1.1668 +object with <tt>other_date</tt> and returns <tt>true</tt> if the dates are
  1.1669 +equal.  <em>It ignores time</em>.</p>
  1.1670 +<p>
  1.1671 +</p>
  1.1672 +<li><p><tt>Date.prototype.print</tt>(format)  --  returns a string with the
  1.1673 +current date object represented in the given format.  It implements the format
  1.1674 +specified in section <a href="#node_sec_5.3.5">5.3.5</a>.</p>
  1.1675 +<p>
  1.1676 +</p>
  1.1677 +</ol><p></p>
  1.1678 +<p>
  1.1679 +</p>
  1.1680 +</ol><p></p>
  1.1681 +<p>
  1.1682 +</p>
  1.1683 +<a name="node_sec_7"></a>
  1.1684 +<h1><a href="#node_toc_node_sec_7">7&nbsp;&nbsp;Credits</a></h1>
  1.1685 +<p>The following people either sponsored, donated money to the project or bought
  1.1686 +commercial licenses (listed in reverse chronological order).  Your name could
  1.1687 +be here too!  If you wish to sponsor the project (for instance request a
  1.1688 +feature and pay me for implementing it) or donate some money please
  1.1689 +<em>please</em> contact me at <tt><a href="mailto:mihai\_bazon@yahoo.com">mihai_bazon@yahoo.com</a></tt>.</p>
  1.1690 +<p>
  1.1691 +</p>
  1.1692 +<ul><p>
  1.1693 +</p>
  1.1694 +<li><p>Sunny Chowdhury (<a href="http://www.ex3.com">www.ex3.com</a>)</p>
  1.1695 +<p>
  1.1696 +</p>
  1.1697 +<li><p>Ian Barrack (<a href="http://www.simban.com">www.simban.com</a>)</p>
  1.1698 +<p>
  1.1699 +</p>
  1.1700 +<li><p>Himanshukumar Shah</p>
  1.1701 +<p>
  1.1702 +</p>
  1.1703 +<li><p>Seyhan Ersoy (<a href="http://www.oocgi.com">www.oocgi.com</a>)</p>
  1.1704 +<p>
  1.1705 +</p>
  1.1706 +<li><p>Jon Stokkeland (<a href="http://www.sauen.com">www.sauen.com</a>)</p>
  1.1707 +<p>
  1.1708 +</p>
  1.1709 +</ul><p></p>
  1.1710 +<p>
  1.1711 +</p>
  1.1712 +<div align=right><table><tr><td>
  1.1713 +
  1.1714 +<b>Thank you!</b><br>
  1.1715 + --  <tt>mihai_bazon@yahoo.com</tt>
  1.1716 +</td></tr></table></div>
  1.1717 +<p>
  1.1718 +</p>
  1.1719 +<div class=footnoterule><hr></div><p></p>
  1.1720 +<div class=footnote><p><a name="footnote_Temp_2"></a><a href="#call_footnote_Temp_2"><sup><small>1</small></sup></a> 
  1.1721 +by the term ``widget'' I understand a single element of user interface.
  1.1722 +But that's in Linux world.  For those that did lots of Windows
  1.1723 +programming the term ``control'' might be more familiar
  1.1724 +</p>
  1.1725 +<p><a name="footnote_Temp_3"></a><a href="#call_footnote_Temp_3"><sup><small>2</small></sup></a> people report that the calendar does
  1.1726 +not work with IE5/Mac.  However, this browser was discontinued and we
  1.1727 +believe that supporting it doesn't worth the efforts, given the fact that
  1.1728 +it has the worst, buggiest implementation for DOM I've ever seen.</p>
  1.1729 +<p><a name="footnote_Temp_4"></a><a href="#call_footnote_Temp_4"><sup><small>3</small></sup></a>  under Opera 7 the calendar still lacks some functionality, such as
  1.1730 +keyboard navigation; also Opera doesn't seem to allow disabling text
  1.1731 +selection when one drags the mouse on the page; despite all that, the
  1.1732 +calendar is still highly functional under Opera 7 and looks as good as
  1.1733 +in other supported browsers. </p>
  1.1734 +<p><a name="footnote_Temp_5"></a><a href="#call_footnote_Temp_5"><sup><small>4</small></sup></a> user interface</p>
  1.1735 +</div>
  1.1736 +<div align=right class=colophon>
  1.1737 +<i>Last modified: Saturday, March 5th, 2005<br>
  1.1738 +HTML conversion by <a href="http://www.ccs.neu.edu/~dorai/tex2page/tex2page-doc.html">TeX2page 2004-09-11</a></i>
  1.1739 +</div>
  1.1740 +</body>
  1.1741 +</html>