]> git.mxchange.org Git - friendica.git/commitdiff
update of fullcalender to v1.6.4
authorhauke <hauke@grlg.org>
Sun, 7 Sep 2014 12:31:01 +0000 (14:31 +0200)
committerhauke <hauke@grlg.org>
Sun, 7 Sep 2014 12:31:01 +0000 (14:31 +0200)
library/fullcalendar/GPL-LICENSE.txt [deleted file]
library/fullcalendar/MIT-LICENSE.txt [deleted file]
library/fullcalendar/changelog.txt
library/fullcalendar/fullcalendar.css
library/fullcalendar/fullcalendar.js
library/fullcalendar/fullcalendar.min.js
library/fullcalendar/fullcalendar.print.css
library/fullcalendar/gcal.js
library/fullcalendar/license.txt [new file with mode: 0644]

diff --git a/library/fullcalendar/GPL-LICENSE.txt b/library/fullcalendar/GPL-LICENSE.txt
deleted file mode 100644 (file)
index 11dddd0..0000000
+++ /dev/null
@@ -1,278 +0,0 @@
-        GNU GENERAL PUBLIC LICENSE
-           Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-          Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users.  This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it.  (Some other Free Software Foundation software is covered by
-the GNU Lesser General Public License instead.)  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have.  You must make sure that they, too, receive or can get the
-source code.  And you must show them these terms so they know their
-rights.
-
-  We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
-  Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software.  If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
-  Finally, any free program is threatened constantly by software
-patents.  We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary.  To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-
-        GNU GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License.  The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language.  (Hereinafter, translation is included without limitation in
-the term "modification".)  Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
-  1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
-  2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) You must cause the modified files to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    b) You must cause any work that you distribute or publish, that in
-    whole or in part contains or is derived from the Program or any
-    part thereof, to be licensed as a whole at no charge to all third
-    parties under the terms of this License.
-
-    c) If the modified program normally reads commands interactively
-    when run, you must cause it, when started running for such
-    interactive use in the most ordinary way, to print or display an
-    announcement including an appropriate copyright notice and a
-    notice that there is no warranty (or else, saying that you provide
-    a warranty) and that users may redistribute the program under
-    these conditions, and telling the user how to view a copy of this
-    License.  (Exception: if the Program itself is interactive but
-    does not normally print such an announcement, your work based on
-    the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
-    a) Accompany it with the complete corresponding machine-readable
-    source code, which must be distributed under the terms of Sections
-    1 and 2 above on a medium customarily used for software interchange; or,
-
-    b) Accompany it with a written offer, valid for at least three
-    years, to give any third party, for a charge no more than your
-    cost of physically performing source distribution, a complete
-    machine-readable copy of the corresponding source code, to be
-    distributed under the terms of Sections 1 and 2 above on a medium
-    customarily used for software interchange; or,
-
-    c) Accompany it with the information you received as to the offer
-    to distribute corresponding source code.  (This alternative is
-    allowed only for noncommercial distribution and only if you
-    received the program in object code or executable form with such
-    an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it.  For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable.  However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License.  Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
-  5. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Program or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
-  6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
-  7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation.  If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
-  10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission.  For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this.  Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-          NO WARRANTY
-
-  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
-  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
diff --git a/library/fullcalendar/MIT-LICENSE.txt b/library/fullcalendar/MIT-LICENSE.txt
deleted file mode 100644 (file)
index 46d4754..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright (c) 2009 Adam Shaw
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
index 17b31f8622ae1798de7492cdb258bc1a20f86c44..829971463e8f814f5153dd54855277b31c5a902a 100644 (file)
@@ -1,4 +1,68 @@
 
+version 1.6.4 (9/1/13)
+       - better algorithm for positioning timed agenda events (issue 1115)
+       - `slotEventOverlap` option to tweak timed agenda event overlapping (issue 218)
+       - selection bug when slot height is customized (issue 1035)
+       - supply view argument in `loading` callback (issue 1018)
+       - fixed week number not displaying in agenda views (issue 1951)
+       - fixed fullCalendar not initializing with no options (issue 1356)
+       - NPM's package.json, no more warnings or errors (issue 1762)
+       - building the bower component should output bower.json instead of component.json (PR 125)
+       - use bower internally for fetching new versions of jQuery and jQuery UI
+
+version 1.6.3 (8/10/13)
+       - viewRender callback (PR 15)
+       - viewDestroy callback (PR 15)
+       - eventDestroy callback (PR 111)
+       - handleWindowResize option (PR 54)
+       - eventStartEditable/startEditable options (PR 49)
+       - eventDurationEditable/durationEditable options (PR 49)
+       - specify function for $.ajax `data` parameter for JSON event sources (PR 59)
+       - fixed bug with agenda event dropping in wrong column (PR 55)
+       - easier event element z-index customization (PR 58)
+       - classNames on past/future days (PR 88)
+       - allow null/undefined event titles (PR 84)
+       - small optimize for agenda event rendering (PR 56)
+       - deprecated:
+               - viewDisplay
+               - disableDragging
+               - disableResizing
+       - bundled with latest jQuery (1.10.2) and jQuery UI (1.10.3)
+
+version 1.6.2 (7/18/13)
+       - hiddenDays option (issue 686)
+       - bugfix: when eventRender returns false, incorrect stacking of events (issue 762)
+       - bugfix: couldn't change event.backgroundImage when calling updateEvent (thx stephenharris)
+
+version 1.6.1 (4/14/13)
+       - fixed event inner content overflow bug (issue 1783)
+       - fixed table header className bug (1772)
+       - removed text-shadow on events (better for general use, thx tkrotoff)
+
+version 1.6.0 (3/18/13)
+       - visual facelift, with bootstrap-inspired buttons and colors
+       - simplified HTML/CSS for events and buttons
+       - dayRender, for modifying a day cell (issue 191, thx althaus)
+       - week numbers on side of calendar (issue 295)
+               - weekNumber
+               - weekNumberCalculation
+               - weekNumberTitle
+               - "W" formatting variable
+       - finer snapping granularity for agenda view events (issue 495, thx ms-doodle-com)
+       - eventAfterAllRender (issue 753, thx pdrakeweb)
+       - eventDataTransform (thx joeyspo)
+       - data-date attributes on cells (thx Jae)
+       - expose $.fullCalendar.dateFormatters
+       - when clicking fast on buttons, prevent text selection
+       - bundled with latest jQuery (1.9.1) and jQuery UI (1.10.2)
+       - Grunt/Lumbar build system for internal development
+       - build for Bower package manager
+       - build for jQuery plugin site
+
+version 1.5.4 (9/5/12)
+       - made compatible with jQuery 1.8.* (thx archaeron)
+       - bundled with jQuery 1.8.1 and jQuery UI 1.8.23
+
 version 1.5.3 (2/6/12)
        - fixed dragging issue with jQuery UI 1.8.16 (issue 1168)
        - bundled with jQuery 1.7.1 and jQuery UI 1.8.17
index 04f118493a4e6f9ba3626934578fe605c5244c14..92fe47f2029408792e7fd9adb9c0f0ec833c9667 100644 (file)
@@ -1,12 +1,7 @@
-/*
- * FullCalendar v1.5.3 Stylesheet
- *
- * Copyright (c) 2011 Adam Shaw
- * Dual licensed under the MIT and GPL licenses, located in
- * MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
- *
- * Date: Mon Feb 6 22:40:40 2012 -0800
- *
+/*!
+ * FullCalendar v1.6.4 Stylesheet
+ * Docs & License: http://arshaw.com/fullcalendar/
+ * (c) 2013 Adam Shaw
  */
 
 
@@ -79,11 +74,8 @@ html .fc,
        margin-right: -1px;
        }
        
-.fc-header .fc-corner-right {
-       margin-right: 1px; /* back to normal */
-       }
-       
-.fc-header .ui-corner-right {
+.fc-header .fc-corner-right,  /* non-theme */
+.fc-header .ui-corner-right { /* theme */
        margin-right: 0; /* back to normal */
        }
        
@@ -110,10 +102,11 @@ html .fc,
        
 .fc-content {
        clear: both;
+       zoom: 1; /* for IE7, gives accurate coordinates for [un]freezeContentHeight */
        }
        
 .fc-view {
-       width: 100%; /* needed for view switching (when view is absolute) */
+       width: 100%;
        overflow: hidden;
        }
        
@@ -124,17 +117,17 @@ html .fc,
 
 .fc-widget-header,    /* <th>, usually */
 .fc-widget-content {  /* <td>, usually */
-       border: 1px solid #ccc;
+       border: 1px solid #ddd;
        }
        
 .fc-state-highlight { /* <td> today cell */ /* TODO: add .fc-today to <th> */
-       background: #ffc;
+       background: #fcf8e3;
        }
        
 .fc-cell-overlay { /* semi-transparent rectangle while dragging */
-       background: #9cf;
-       opacity: .2;
-       filter: alpha(opacity=20); /* for IE */
+       background: #bce8f1;
+       opacity: .3;
+       filter: alpha(opacity=30); /* for IE */
        }
        
 
@@ -145,43 +138,54 @@ html .fc,
 .fc-button {
        position: relative;
        display: inline-block;
+       padding: 0 .6em;
+       overflow: hidden;
+       height: 1.9em;
+       line-height: 1.9em;
+       white-space: nowrap;
        cursor: pointer;
        }
        
 .fc-state-default { /* non-theme */
-       border-style: solid;
-       border-width: 1px 0;
+       border: 1px solid;
        }
-       
-.fc-button-inner {
-       position: relative;
-       float: left;
-       overflow: hidden;
+
+.fc-state-default.fc-corner-left { /* non-theme */
+       border-top-left-radius: 4px;
+       border-bottom-left-radius: 4px;
        }
-       
-.fc-state-default .fc-button-inner { /* non-theme */
-       border-style: solid;
-       border-width: 0 1px;
+
+.fc-state-default.fc-corner-right { /* non-theme */
+       border-top-right-radius: 4px;
+       border-bottom-right-radius: 4px;
        }
-       
-.fc-button-content {
-       position: relative;
-       float: left;
-       height: 1.9em;
-       line-height: 1.9em;
-       padding: 0 .6em;
-       white-space: nowrap;
+
+/*
+       Our default prev/next buttons use HTML entities like &lsaquo; &rsaquo; &laquo; &raquo;
+       and we'll try to make them look good cross-browser.
+*/
+
+.fc-text-arrow {
+       margin: 0 .1em;
+       font-size: 2em;
+       font-family: "Courier New", Courier, monospace;
+       vertical-align: baseline; /* for IE7 */
+       }
+
+.fc-button-prev .fc-text-arrow,
+.fc-button-next .fc-text-arrow { /* for &lsaquo; &rsaquo; */
+       font-weight: bold;
        }
        
 /* icon (for jquery ui) */
        
-.fc-button-content .fc-icon-wrap {
+.fc-button .fc-icon-wrap {
        position: relative;
        float: left;
        top: 50%;
        }
        
-.fc-button-content .ui-icon {
+.fc-button .ui-icon {
        position: relative;
        float: left;
        margin-top: -50%;
@@ -189,107 +193,98 @@ html .fc,
        *top: -50%;
        }
        
-/* gloss effect */
-       
-.fc-state-default .fc-button-effect {
-       position: absolute;
-       top: 50%;
-       left: 0;
-       }
-       
-.fc-state-default .fc-button-effect span {
-       position: absolute;
-       top: -100px;
-       left: 0;
-       width: 500px;
-       height: 100px;
-       border-width: 100px 0 0 1px;
-       border-style: solid;
-       border-color: #fff;
-       background: #444;
-       opacity: .09;
-       filter: alpha(opacity=9);
-       }
-       
-/* button states (determines colors)  */
-       
-.fc-state-default,
-.fc-state-default .fc-button-inner {
-       border-style: solid;
-       border-color: #ccc #bbb #aaa;
-       background: #F3F3F3;
-       color: #000;
+/*
+  button states
+  borrowed from twitter bootstrap (http://twitter.github.com/bootstrap/)
+*/
+
+.fc-state-default {
+       background-color: #f5f5f5;
+       background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
+       background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
+       background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
+       background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
+       background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
+       background-repeat: repeat-x;
+       border-color: #e6e6e6 #e6e6e6 #bfbfbf;
+       border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+       color: #333;
+       text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
+       box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
        }
-       
+
 .fc-state-hover,
-.fc-state-hover .fc-button-inner {
-       border-color: #999;
-       }
-       
 .fc-state-down,
-.fc-state-down .fc-button-inner {
-       border-color: #555;
-       background: #777;
-       }
-       
 .fc-state-active,
-.fc-state-active .fc-button-inner {
-       border-color: #555;
-       background: #777;
-       color: #fff;
+.fc-state-disabled {
+       color: #333333;
+       background-color: #e6e6e6;
        }
-       
-.fc-state-disabled,
-.fc-state-disabled .fc-button-inner {
-       color: #999;
-       border-color: #ddd;
+
+.fc-state-hover {
+       color: #333333;
+       text-decoration: none;
+       background-position: 0 -15px;
+       -webkit-transition: background-position 0.1s linear;
+          -moz-transition: background-position 0.1s linear;
+            -o-transition: background-position 0.1s linear;
+               transition: background-position 0.1s linear;
        }
-       
+
+.fc-state-down,
+.fc-state-active {
+       background-color: #cccccc;
+       background-image: none;
+       outline: 0;
+       box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
+       }
+
 .fc-state-disabled {
        cursor: default;
+       background-image: none;
+       opacity: 0.65;
+       filter: alpha(opacity=65);
+       box-shadow: none;
        }
-       
-.fc-state-disabled .fc-button-effect {
-       display: none;
-       }
-       
+
        
 
 /* Global Event Styles
 ------------------------------------------------------------------------*/
+
+.fc-event-container > * {
+       z-index: 8;
+       }
+
+.fc-event-container > .ui-draggable-dragging,
+.fc-event-container > .ui-resizable-resizing {
+       z-index: 9;
+       }
         
 .fc-event {
-       border-style: solid;
-       border-width: 0;
+       border: 1px solid #3a87ad; /* default BORDER color */
+       background-color: #3a87ad; /* default BACKGROUND color */
+       color: #fff;               /* default TEXT color */
        font-size: .85em;
        cursor: default;
        }
+
+a.fc-event {
+       text-decoration: none;
+       }
        
 a.fc-event,
 .fc-event-draggable {
        cursor: pointer;
        }
        
-a.fc-event {
-       text-decoration: none;
-       }
-       
 .fc-rtl .fc-event {
        text-align: right;
        }
-       
-.fc-event-skin {
-       border-color: #36c;     /* default BORDER color */
-       background-color: #36c; /* default BACKGROUND color */
-       color: #fff;            /* default TEXT color */
-       }
-       
+
 .fc-event-inner {
-       position: relative;
        width: 100%;
        height: 100%;
-       border-style: solid;
-       border-width: 0;
        overflow: hidden;
        }
        
@@ -298,7 +293,7 @@ a.fc-event {
        padding: 0 1px;
        }
        
-.fc .ui-resizable-handle { /*** TODO: don't use ui-resizable anymore, change class ***/
+.fc .ui-resizable-handle {
        display: block;
        position: absolute;
        z-index: 99999;
@@ -316,6 +311,20 @@ a.fc-event {
        border-width: 1px 0;
        margin-bottom: 1px;
        }
+
+.fc-ltr .fc-event-hori.fc-event-start,
+.fc-rtl .fc-event-hori.fc-event-end {
+       border-left-width: 1px;
+       border-top-left-radius: 3px;
+       border-bottom-left-radius: 3px;
+       }
+
+.fc-ltr .fc-event-hori.fc-event-end,
+.fc-rtl .fc-event-hori.fc-event-start {
+       border-right-width: 1px;
+       border-top-right-radius: 3px;
+       border-bottom-right-radius: 3px;
+       }
        
 /* resizable */
        
@@ -341,66 +350,6 @@ a.fc-event {
        
        
        
-/* Fake Rounded Corners (for buttons and events)
-------------------------------------------------------------*/
-       
-.fc-corner-left {
-       margin-left: 1px;
-       }
-       
-.fc-corner-left .fc-button-inner,
-.fc-corner-left .fc-event-inner {
-       margin-left: -1px;
-       }
-       
-.fc-corner-right {
-       margin-right: 1px;
-       }
-       
-.fc-corner-right .fc-button-inner,
-.fc-corner-right .fc-event-inner {
-       margin-right: -1px;
-       }
-       
-.fc-corner-top {
-       margin-top: 1px;
-       }
-       
-.fc-corner-top .fc-event-inner {
-       margin-top: -1px;
-       }
-       
-.fc-corner-bottom {
-       margin-bottom: 1px;
-       }
-       
-.fc-corner-bottom .fc-event-inner {
-       margin-bottom: -1px;
-       }
-       
-       
-       
-/* Fake Rounded Corners SPECIFICALLY FOR EVENTS
------------------------------------------------------------------*/
-       
-.fc-corner-left .fc-event-inner {
-       border-left-width: 1px;
-       }
-       
-.fc-corner-right .fc-event-inner {
-       border-right-width: 1px;
-       }
-       
-.fc-corner-top .fc-event-inner {
-       border-top-width: 1px;
-       }
-       
-.fc-corner-bottom .fc-event-inner {
-       border-bottom-width: 1px;
-       }
-       
-       
-       
 /* Reusable Separate-border Table
 ------------------------------------------------------------*/
 
@@ -436,6 +385,15 @@ table.fc-border-separate {
 .fc-grid th {
        text-align: center;
        }
+
+.fc .fc-week-number {
+       width: 22px;
+       text-align: center;
+       }
+
+.fc .fc-week-number div {
+       padding: 0 2px;
+       }
        
 .fc-grid .fc-day-number {
        float: right;
@@ -492,6 +450,10 @@ table.fc-border-separate {
        white-space: nowrap;
        font-weight: normal;
        }
+
+.fc-agenda .fc-week-number {
+       font-weight: bold;
+       }
        
 .fc-agenda .fc-day-content {
        padding: 2px 2px 1px;
@@ -566,19 +528,28 @@ table.fc-border-separate {
 .fc-event-vert {
        border-width: 0 1px;
        }
-       
-.fc-event-vert .fc-event-head,
-.fc-event-vert .fc-event-content {
-       position: relative;
-       z-index: 2;
-       width: 100%;
-       overflow: hidden;
+
+.fc-event-vert.fc-event-start {
+       border-top-width: 1px;
+       border-top-left-radius: 3px;
+       border-top-right-radius: 3px;
+       }
+
+.fc-event-vert.fc-event-end {
+       border-bottom-width: 1px;
+       border-bottom-left-radius: 3px;
+       border-bottom-right-radius: 3px;
        }
        
 .fc-event-vert .fc-event-time {
        white-space: nowrap;
        font-size: 10px;
        }
+
+.fc-event-vert .fc-event-inner {
+       position: relative;
+       z-index: 2;
+       }
        
 .fc-event-vert .fc-event-bg { /* makes the event lighter w/ a semi-transparent overlay  */
        position: absolute;
@@ -588,8 +559,8 @@ table.fc-border-separate {
        width: 100%;
        height: 100%;
        background: #fff;
-       opacity: .3;
-       filter: alpha(opacity=30);
+       opacity: .25;
+       filter: alpha(opacity=25);
        }
        
 .fc .ui-draggable-dragging .fc-event-bg, /* TODO: something nicer like .fc-opacity */
index 779a313c7611cfaa867ece2f740a7c5577477f11..41c50856cf4f181f4cbcd34f923e9dec0eabe708 100644 (file)
@@ -1,23 +1,20 @@
-/**
- * @preserve
- * FullCalendar v1.5.3
- * http://arshaw.com/fullcalendar/
- *
+/*!
+ * FullCalendar v1.6.4
+ * Docs & License: http://arshaw.com/fullcalendar/
+ * (c) 2013 Adam Shaw
+ */
+
+/*
  * Use fullcalendar.css for basic styling.
  * For event drag & drop, requires jQuery UI draggable.
  * For event resizing, requires jQuery UI resizable.
- *
- * Copyright (c) 2011 Adam Shaw
- * Dual licensed under the MIT and GPL licenses, located in
- * MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
- *
- * Date: Mon Feb 6 22:40:40 2012 -0800
- *
  */
  
 (function($, undefined) {
 
 
+;;
+
 var defaults = {
 
        // display
@@ -29,6 +26,9 @@ var defaults = {
                right: 'today prev,next'
        },
        weekends: true,
+       weekNumbers: false,
+       weekNumberCalculation: 'iso',
+       weekNumberTitle: 'W',
        
        // editing
        //editable: false,
@@ -66,10 +66,10 @@ var defaults = {
        dayNames: ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
        dayNamesShort: ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],
        buttonText: {
-               prev: '&nbsp;&#9668;&nbsp;',
-               next: '&nbsp;&#9658;&nbsp;',
-               prevYear: '&nbsp;&lt;&lt;&nbsp;',
-               nextYear: '&nbsp;&gt;&gt;&nbsp;',
+               prev: "<span class='fc-text-arrow'>&lsaquo;</span>",
+               next: "<span class='fc-text-arrow'>&rsaquo;</span>",
+               prevYear: "<span class='fc-text-arrow'>&laquo;</span>",
+               nextYear: "<span class='fc-text-arrow'>&raquo;</span>",
                today: 'today',
                month: 'month',
                week: 'week',
@@ -86,7 +86,9 @@ var defaults = {
        //selectable: false,
        unselectAuto: true,
        
-       dropAccept: '*'
+       dropAccept: '*',
+       
+       handleWindowResize: true
        
 };
 
@@ -98,10 +100,10 @@ var rtlDefaults = {
                right: 'title'
        },
        buttonText: {
-               prev: '&nbsp;&#9658;&nbsp;',
-               next: '&nbsp;&#9668;&nbsp;',
-               prevYear: '&nbsp;&gt;&gt;&nbsp;',
-               nextYear: '&nbsp;&lt;&lt;&nbsp;'
+               prev: "<span class='fc-text-arrow'>&rsaquo;</span>",
+               next: "<span class='fc-text-arrow'>&lsaquo;</span>",
+               prevYear: "<span class='fc-text-arrow'>&raquo;</span>",
+               nextYear: "<span class='fc-text-arrow'>&laquo;</span>"
        },
        buttonIcons: {
                prev: 'circle-triangle-e',
@@ -111,7 +113,9 @@ var rtlDefaults = {
 
 
 
-var fc = $.fullCalendar = { version: "1.5.3" };
+;;
+
+var fc = $.fullCalendar = { version: "1.6.4" };
 var fcViews = fc.views = {};
 
 
@@ -139,7 +143,8 @@ $.fn.fullCalendar = function(options) {
                }
                return this;
        }
-       
+
+       options = options || {};
        
        // would like to have this logic in EventManager, but needs to happen before options are recursively extended
        var eventSources = options.eventSources || [];
@@ -177,6 +182,8 @@ function setDefaults(d) {
 
 
 
+;;
+
  
 function Calendar(element, options, eventSources) {
        var t = this;
@@ -221,10 +228,8 @@ function Calendar(element, options, eventSources) {
        var content;
        var tm; // for making theme classes
        var currentView;
-       var viewInstances = {};
        var elementOuterWidth;
        var suggestedViewHeight;
-       var absoluteViewElement;
        var resizeUID = 0;
        var ignoreWindowResize = 0;
        var date = new Date();
@@ -243,11 +248,11 @@ function Calendar(element, options, eventSources) {
        function render(inc) {
                if (!content) {
                        initialRender();
-               }else{
+               }
+               else if (elementVisible()) {
+                       // mainly for the public API
                        calcSize();
-                       markSizesDirty();
-                       markEventsDirty();
-                       renderView(inc);
+                       _renderView(inc);
                }
        }
        
@@ -258,18 +263,28 @@ function Calendar(element, options, eventSources) {
                if (options.isRTL) {
                        element.addClass('fc-rtl');
                }
+               else {
+                       element.addClass('fc-ltr');
+               }
                if (options.theme) {
                        element.addClass('ui-widget');
                }
+
                content = $("<div class='fc-content' style='position:relative'/>")
                        .prependTo(element);
+
                header = new Header(t, options);
                headerElement = header.render();
                if (headerElement) {
                        element.prepend(headerElement);
                }
+
                changeView(options.defaultView);
-               $(window).resize(windowResize);
+
+               if (options.handleWindowResize) {
+                       $(window).resize(windowResize);
+               }
+
                // needed for IE in a 0x0 iframe, b/c when it is resized, never triggers a windowResize
                if (!bodyVisible()) {
                        lateRender();
@@ -289,21 +304,27 @@ function Calendar(element, options, eventSources) {
        
        
        function destroy() {
+
+               if (currentView) {
+                       trigger('viewDestroy', currentView, currentView, currentView.element);
+                       currentView.triggerEventDestroy();
+               }
+
                $(window).unbind('resize', windowResize);
+
                header.destroy();
                content.remove();
                element.removeClass('fc fc-rtl ui-widget');
        }
        
        
-       
        function elementVisible() {
-               return _element.offsetWidth !== 0;
+               return element.is(':visible');
        }
        
        
        function bodyVisible() {
-               return $('body')[0].offsetWidth !== 0;
+               return $('body').is(':visible');
        }
        
        
@@ -311,133 +332,97 @@ function Calendar(element, options, eventSources) {
        /* View Rendering
        -----------------------------------------------------------------------------*/
        
-       // TODO: improve view switching (still weird transition in IE, and FF has whiteout problem)
-       
+
        function changeView(newViewName) {
                if (!currentView || newViewName != currentView.name) {
-                       ignoreWindowResize++; // because setMinHeight might change the height before render (and subsequently setSize) is reached
+                       _changeView(newViewName);
+               }
+       }
+
+
+       function _changeView(newViewName) {
+               ignoreWindowResize++;
 
+               if (currentView) {
+                       trigger('viewDestroy', currentView, currentView, currentView.element);
                        unselect();
-                       
-                       var oldView = currentView;
-                       var newViewElement;
-                               
-                       if (oldView) {
-                               (oldView.beforeHide || noop)(); // called before changing min-height. if called after, scroll state is reset (in Opera)
-                               setMinHeight(content, content.height());
-                               oldView.element.hide();
-                       }else{
-                               setMinHeight(content, 1); // needs to be 1 (not 0) for IE7, or else view dimensions miscalculated
-                       }
-                       content.css('overflow', 'hidden');
-                       
-                       currentView = viewInstances[newViewName];
-                       if (currentView) {
-                               currentView.element.show();
-                       }else{
-                               currentView = viewInstances[newViewName] = new fcViews[newViewName](
-                                       newViewElement = absoluteViewElement =
-                                               $("<div class='fc-view fc-view-" + newViewName + "' style='position:absolute'/>")
-                                                       .appendTo(content),
-                                       t // the calendar object
-                               );
-                       }
-                       
-                       if (oldView) {
-                               header.deactivateButton(oldView.name);
-                       }
-                       header.activateButton(newViewName);
-                       
-                       renderView(); // after height has been set, will make absoluteViewElement's position=relative, then set to null
-                       
-                       content.css('overflow', '');
-                       if (oldView) {
-                               setMinHeight(content, 1);
-                       }
-                       
-                       if (!newViewElement) {
-                               (currentView.afterShow || noop)(); // called after setting min-height/overflow, so in final scroll state (for Opera)
-                       }
-                       
-                       ignoreWindowResize--;
+                       currentView.triggerEventDestroy(); // trigger 'eventDestroy' for each event
+                       freezeContentHeight();
+                       currentView.element.remove();
+                       header.deactivateButton(currentView.name);
                }
+
+               header.activateButton(newViewName);
+
+               currentView = new fcViews[newViewName](
+                       $("<div class='fc-view fc-view-" + newViewName + "' style='position:relative'/>")
+                               .appendTo(content),
+                       t // the calendar object
+               );
+
+               renderView();
+               unfreezeContentHeight();
+
+               ignoreWindowResize--;
        }
-       
-       
-       
+
+
        function renderView(inc) {
-               if (elementVisible()) {
-                       ignoreWindowResize++; // because renderEvents might temporarily change the height before setSize is reached
+               if (
+                       !currentView.start || // never rendered before
+                       inc || date < currentView.start || date >= currentView.end // or new date range
+               ) {
+                       if (elementVisible()) {
+                               _renderView(inc);
+                       }
+               }
+       }
+
+
+       function _renderView(inc) { // assumes elementVisible
+               ignoreWindowResize++;
 
+               if (currentView.start) { // already been rendered?
+                       trigger('viewDestroy', currentView, currentView, currentView.element);
                        unselect();
-                       
-                       if (suggestedViewHeight === undefined) {
-                               calcSize();
-                       }
-                       
-                       var forceEventRender = false;
-                       if (!currentView.start || inc || date < currentView.start || date >= currentView.end) {
-                               // view must render an entire new date range (and refetch/render events)
-                               currentView.render(date, inc || 0); // responsible for clearing events
-                               setSize(true);
-                               forceEventRender = true;
-                       }
-                       else if (currentView.sizeDirty) {
-                               // view must resize (and rerender events)
-                               currentView.clearEvents();
-                               setSize();
-                               forceEventRender = true;
-                       }
-                       else if (currentView.eventsDirty) {
-                               currentView.clearEvents();
-                               forceEventRender = true;
-                       }
-                       currentView.sizeDirty = false;
-                       currentView.eventsDirty = false;
-                       updateEvents(forceEventRender);
-                       
-                       elementOuterWidth = element.outerWidth();
-                       
-                       header.updateTitle(currentView.title);
-                       var today = new Date();
-                       if (today >= currentView.start && today < currentView.end) {
-                               header.disableButton('today');
-                       }else{
-                               header.enableButton('today');
-                       }
-                       
-                       ignoreWindowResize--;
-                       currentView.trigger('viewDisplay', _element);
+                       clearEvents();
                }
+
+               freezeContentHeight();
+               currentView.render(date, inc || 0); // the view's render method ONLY renders the skeleton, nothing else
+               setSize();
+               unfreezeContentHeight();
+               (currentView.afterRender || noop)();
+
+               updateTitle();
+               updateTodayButton();
+
+               trigger('viewRender', currentView, currentView, currentView.element);
+               currentView.trigger('viewDisplay', _element); // deprecated
+
+               ignoreWindowResize--;
+
+               getAndRenderEvents();
        }
        
        
-       
+
        /* Resizing
        -----------------------------------------------------------------------------*/
        
        
        function updateSize() {
-               markSizesDirty();
                if (elementVisible()) {
+                       unselect();
+                       clearEvents();
                        calcSize();
                        setSize();
-                       unselect();
-                       currentView.clearEvents();
-                       currentView.renderEvents(events);
-                       currentView.sizeDirty = false;
+                       renderEvents();
                }
        }
        
        
-       function markSizesDirty() {
-               $.each(viewInstances, function(i, inst) {
-                       inst.sizeDirty = true;
-               });
-       }
-       
-       
-       function calcSize() {
+       function calcSize() { // assumes elementVisible
                if (options.contentHeight) {
                        suggestedViewHeight = options.contentHeight;
                }
@@ -450,15 +435,20 @@ function Calendar(element, options, eventSources) {
        }
        
        
-       function setSize(dateChanged) { // todo: dateChanged?
-               ignoreWindowResize++;
-               currentView.setHeight(suggestedViewHeight, dateChanged);
-               if (absoluteViewElement) {
-                       absoluteViewElement.css('position', 'relative');
-                       absoluteViewElement = null;
+       function setSize() { // assumes elementVisible
+
+               if (suggestedViewHeight === undefined) {
+                       calcSize(); // for first time
+                               // NOTE: we don't want to recalculate on every renderView because
+                               // it could result in oscillating heights due to scrollbars.
                }
-               currentView.setWidth(content.width(), dateChanged);
+
+               ignoreWindowResize++;
+               currentView.setHeight(suggestedViewHeight);
+               currentView.setWidth(content.width());
                ignoreWindowResize--;
+
+               elementOuterWidth = element.outerWidth();
        }
        
        
@@ -487,52 +477,85 @@ function Calendar(element, options, eventSources) {
        
        /* Event Fetching/Rendering
        -----------------------------------------------------------------------------*/
+       // TODO: going forward, most of this stuff should be directly handled by the view
+
+
+       function refetchEvents() { // can be called as an API method
+               clearEvents();
+               fetchAndRenderEvents();
+       }
+
+
+       function rerenderEvents(modifiedEventID) { // can be called as an API method
+               clearEvents();
+               renderEvents(modifiedEventID);
+       }
+
+
+       function renderEvents(modifiedEventID) { // TODO: remove modifiedEventID hack
+               if (elementVisible()) {
+                       currentView.setEventData(events); // for View.js, TODO: unify with renderEvents
+                       currentView.renderEvents(events, modifiedEventID); // actually render the DOM elements
+                       currentView.trigger('eventAfterAllRender');
+               }
+       }
+
+
+       function clearEvents() {
+               currentView.triggerEventDestroy(); // trigger 'eventDestroy' for each event
+               currentView.clearEvents(); // actually remove the DOM elements
+               currentView.clearEventData(); // for View.js, TODO: unify with clearEvents
+       }
        
-       
-       // fetches events if necessary, rerenders events if necessary (or if forced)
-       function updateEvents(forceRender) {
+
+       function getAndRenderEvents() {
                if (!options.lazyFetching || isFetchNeeded(currentView.visStart, currentView.visEnd)) {
-                       refetchEvents();
+                       fetchAndRenderEvents();
                }
-               else if (forceRender) {
-                       rerenderEvents();
+               else {
+                       renderEvents();
                }
        }
-       
-       
-       function refetchEvents() {
-               fetchEvents(currentView.visStart, currentView.visEnd); // will call reportEvents
+
+
+       function fetchAndRenderEvents() {
+               fetchEvents(currentView.visStart, currentView.visEnd);
+                       // ... will call reportEvents
+                       // ... which will call renderEvents
        }
-       
+
        
        // called when event data arrives
        function reportEvents(_events) {
                events = _events;
-               rerenderEvents();
+               renderEvents();
        }
-       
-       
+
+
        // called when a single event's data has been changed
        function reportEventChange(eventID) {
                rerenderEvents(eventID);
        }
-       
-       
-       // attempts to rerenderEvents
-       function rerenderEvents(modifiedEventID) {
-               markEventsDirty();
-               if (elementVisible()) {
-                       currentView.clearEvents();
-                       currentView.renderEvents(events, modifiedEventID);
-                       currentView.eventsDirty = false;
-               }
+
+
+
+       /* Header Updating
+       -----------------------------------------------------------------------------*/
+
+
+       function updateTitle() {
+               header.updateTitle(currentView.title);
        }
-       
-       
-       function markEventsDirty() {
-               $.each(viewInstances, function(i, inst) {
-                       inst.eventsDirty = true;
-               });
+
+
+       function updateTodayButton() {
+               var today = new Date();
+               if (today >= currentView.start && today < currentView.end) {
+                       header.disableButton('today');
+               }
+               else {
+                       header.enableButton('today');
+               }
        }
        
 
@@ -613,6 +636,29 @@ function Calendar(element, options, eventSources) {
        function getDate() {
                return cloneDate(date);
        }
+
+
+
+       /* Height "Freezing"
+       -----------------------------------------------------------------------------*/
+
+
+       function freezeContentHeight() {
+               content.css({
+                       width: '100%',
+                       height: content.height(),
+                       overflow: 'hidden'
+               });
+       }
+
+
+       function unfreezeContentHeight() {
+               content.css({
+                       width: '',
+                       height: '',
+                       overflow: ''
+               });
+       }
        
        
        
@@ -674,6 +720,8 @@ function Calendar(element, options, eventSources) {
 
 }
 
+;;
+
 function Header(calendar, options) {
        var t = this;
        
@@ -747,54 +795,47 @@ function Header(calendar, options) {
                                                        var text = smartProperty(options.buttonText, buttonName); // why are we using smartProperty here?
                                                        var button = $(
                                                                "<span class='fc-button fc-button-" + buttonName + " " + tm + "-state-default'>" +
-                                                                       "<span class='fc-button-inner'>" +
-                                                                               "<span class='fc-button-content'>" +
-                                                                                       (icon ?
-                                                                                               "<span class='fc-icon-wrap'>" +
-                                                                                                       "<span class='ui-icon ui-icon-" + icon + "'/>" +
-                                                                                               "</span>" :
-                                                                                               text
-                                                                                               ) +
-                                                                               "</span>" +
-                                                                               "<span class='fc-button-effect'><span></span></span>" +
-                                                                       "</span>" +
+                                                                       (icon ?
+                                                                               "<span class='fc-icon-wrap'>" +
+                                                                                       "<span class='ui-icon ui-icon-" + icon + "'/>" +
+                                                                               "</span>" :
+                                                                               text
+                                                                               ) +
                                                                "</span>"
-                                                       );
-                                                       if (button) {
-                                                               button
-                                                                       .click(function() {
-                                                                               if (!button.hasClass(tm + '-state-disabled')) {
-                                                                                       buttonClick();
-                                                                               }
-                                                                       })
-                                                                       .mousedown(function() {
+                                                               )
+                                                               .click(function() {
+                                                                       if (!button.hasClass(tm + '-state-disabled')) {
+                                                                               buttonClick();
+                                                                       }
+                                                               })
+                                                               .mousedown(function() {
+                                                                       button
+                                                                               .not('.' + tm + '-state-active')
+                                                                               .not('.' + tm + '-state-disabled')
+                                                                               .addClass(tm + '-state-down');
+                                                               })
+                                                               .mouseup(function() {
+                                                                       button.removeClass(tm + '-state-down');
+                                                               })
+                                                               .hover(
+                                                                       function() {
                                                                                button
                                                                                        .not('.' + tm + '-state-active')
                                                                                        .not('.' + tm + '-state-disabled')
-                                                                                       .addClass(tm + '-state-down');
-                                                                       })
-                                                                       .mouseup(function() {
-                                                                               button.removeClass(tm + '-state-down');
-                                                                       })
-                                                                       .hover(
-                                                                               function() {
-                                                                                       button
-                                                                                               .not('.' + tm + '-state-active')
-                                                                                               .not('.' + tm + '-state-disabled')
-                                                                                               .addClass(tm + '-state-hover');
-                                                                               },
-                                                                               function() {
-                                                                                       button
-                                                                                               .removeClass(tm + '-state-hover')
-                                                                                               .removeClass(tm + '-state-down');
-                                                                               }
-                                                                       )
-                                                                       .appendTo(e);
-                                                               if (!prevButton) {
-                                                                       button.addClass(tm + '-corner-left');
-                                                               }
-                                                               prevButton = button;
+                                                                                       .addClass(tm + '-state-hover');
+                                                                       },
+                                                                       function() {
+                                                                               button
+                                                                                       .removeClass(tm + '-state-hover')
+                                                                                       .removeClass(tm + '-state-down');
+                                                                       }
+                                                               )
+                                                               .appendTo(e);
+                                                       disableTextSelection(button);
+                                                       if (!prevButton) {
+                                                               button.addClass(tm + '-corner-left');
                                                        }
+                                                       prevButton = button;
                                                }
                                        }
                                });
@@ -839,6 +880,8 @@ function Header(calendar, options) {
 
 }
 
+;;
+
 fc.sourceNormalizers = [];
 fc.sourceFetchers = [];
 
@@ -914,6 +957,16 @@ function EventManager(options, _sources) {
                _fetchEventSource(source, function(events) {
                        if (fetchID == currentFetchID) {
                                if (events) {
+
+                                       if (options.eventDataTransform) {
+                                               events = $.map(events, options.eventDataTransform);
+                                       }
+                                       if (source.eventDataTransform) {
+                                               events = $.map(events, source.eventDataTransform);
+                                       }
+                                       // TODO: this technique is not ideal for static array event sources.
+                                       //  For arrays, we'll want to process all events right in the beginning, then never again.
+                               
                                        for (var i=0; i<events.length; i++) {
                                                events[i].source = source;
                                                normalizeEvent(events[i]);
@@ -966,7 +1019,22 @@ function EventManager(options, _sources) {
                                var success = source.success;
                                var error = source.error;
                                var complete = source.complete;
-                               var data = $.extend({}, source.data || {});
+
+                               // retrieve any outbound GET/POST $.ajax data from the options
+                               var customData;
+                               if ($.isFunction(source.data)) {
+                                       // supplied as a function that returns a key/value object
+                                       customData = source.data();
+                               }
+                               else {
+                                       // supplied as a straight key/value object
+                                       customData = source.data;
+                               }
+
+                               // use a copy of the custom data so we can modify the parameters
+                               // and not affect the passed-in object.
+                               var data = $.extend({}, customData || {});
+
                                var startParam = firstDefined(source.startParam, options.startParam);
                                var endParam = firstDefined(source.endParam, options.endParam);
                                if (startParam) {
@@ -975,6 +1043,7 @@ function EventManager(options, _sources) {
                                if (endParam) {
                                        data[endParam] = Math.round(+rangeEnd / 1000);
                                }
+
                                pushLoading();
                                $.ajax($.extend({}, ajaxDefaults, source, {
                                        data: data,
@@ -1074,7 +1143,7 @@ function EventManager(options, _sources) {
                                e.className = event.className;
                                e.editable = event.editable;
                                e.color = event.color;
-                               e.backgroudColor = event.backgroudColor;
+                               e.backgroundColor = event.backgroundColor;
                                e.borderColor = event.borderColor;
                                e.textColor = event.textColor;
                                normalizeEvent(e);
@@ -1147,14 +1216,14 @@ function EventManager(options, _sources) {
        
        function pushLoading() {
                if (!loadingLevel++) {
-                       trigger('loading', null, true);
+                       trigger('loading', null, true, getView());
                }
        }
        
        
        function popLoading() {
                if (!--loadingLevel) {
-                       trigger('loading', null, false);
+                       trigger('loading', null, false, getView());
                }
        }
        
@@ -1227,6 +1296,8 @@ function EventManager(options, _sources) {
 
 }
 
+;;
+
 
 fc.addDays = addDays;
 fc.cloneDate = cloneDate;
@@ -1331,15 +1402,6 @@ function zeroDate() { // returns a Date with time 00:00:00 and dateOfMonth=1
 }
 
 
-function skipWeekend(date, inc, excl) {
-       inc = inc || 1;
-       while (!date.getDay() || (excl && date.getDay()==1 || !excl && date.getDay()==6)) {
-               addDays(date, inc);
-       }
-       return date;
-}
-
-
 function dayDiff(d1, d2) { // d1 - d2
        return Math.round((cloneDate(d1, true) - cloneDate(d2, true)) / DAY_MS);
 }
@@ -1581,11 +1643,39 @@ var dateFormatters = {
                        return 'th';
                }
                return ['st', 'nd', 'rd'][date%10-1] || 'th';
+       },
+       w   : function(d, o) { // local
+               return o.weekNumberCalculation(d);
+       },
+       W   : function(d) { // ISO
+               return iso8601Week(d);
        }
 };
+fc.dateFormatters = dateFormatters;
+
+
+/* thanks jQuery UI (https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js)
+ * 
+ * Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
+ * `date` - the date to get the week for
+ * `number` - the number of the week within the year that contains this date
+ */
+function iso8601Week(date) {
+       var time;
+       var checkDate = new Date(date.getTime());
 
+       // Find Thursday of this week starting on Monday
+       checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
+
+       time = checkDate.getTime();
+       checkDate.setMonth(0); // Compare with Jan 1
+       checkDate.setDate(1);
+       return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
+}
 
 
+;;
+
 fc.applyAll = applyAll;
 
 
@@ -1605,95 +1695,7 @@ function exclEndDay(event) {
 function _exclEndDay(end, allDay) {
        end = cloneDate(end);
        return allDay || end.getHours() || end.getMinutes() ? addDays(end, 1) : clearTime(end);
-}
-
-
-function segCmp(a, b) {
-       return (b.msLength - a.msLength) * 100 + (a.event.start - b.event.start);
-}
-
-
-function segsCollide(seg1, seg2) {
-       return seg1.end > seg2.start && seg1.start < seg2.end;
-}
-
-
-
-/* Event Sorting
------------------------------------------------------------------------------*/
-
-
-// event rendering utilities
-function sliceSegs(events, visEventEnds, start, end) {
-       var segs = [],
-               i, len=events.length, event,
-               eventStart, eventEnd,
-               segStart, segEnd,
-               isStart, isEnd;
-       for (i=0; i<len; i++) {
-               event = events[i];
-               eventStart = event.start;
-               eventEnd = visEventEnds[i];
-               if (eventEnd > start && eventStart < end) {
-                       if (eventStart < start) {
-                               segStart = cloneDate(start);
-                               isStart = false;
-                       }else{
-                               segStart = eventStart;
-                               isStart = true;
-                       }
-                       if (eventEnd > end) {
-                               segEnd = cloneDate(end);
-                               isEnd = false;
-                       }else{
-                               segEnd = eventEnd;
-                               isEnd = true;
-                       }
-                       segs.push({
-                               event: event,
-                               start: segStart,
-                               end: segEnd,
-                               isStart: isStart,
-                               isEnd: isEnd,
-                               msLength: segEnd - segStart
-                       });
-               }
-       } 
-       return segs.sort(segCmp);
-}
-
-
-// event rendering calculation utilities
-function stackSegs(segs) {
-       var levels = [],
-               i, len = segs.length, seg,
-               j, collide, k;
-       for (i=0; i<len; i++) {
-               seg = segs[i];
-               j = 0; // the level index where seg should belong
-               while (true) {
-                       collide = false;
-                       if (levels[j]) {
-                               for (k=0; k<levels[j].length; k++) {
-                                       if (segsCollide(levels[j][k], seg)) {
-                                               collide = true;
-                                               break;
-                                       }
-                               }
-                       }
-                       if (collide) {
-                               j++;
-                       }else{
-                               break;
-                       }
-               }
-               if (levels[j]) {
-                       levels[j].push(seg);
-               }else{
-                       levels[j] = [seg];
-               }
-       }
-       return levels;
+       // why don't we check for seconds/ms too?
 }
 
 
@@ -1742,29 +1744,26 @@ function setOuterHeight(element, height, includeMargins) {
 }
 
 
-// TODO: curCSS has been deprecated (jQuery 1.4.3 - 10/16/2010)
-
-
 function hsides(element, includeMargins) {
        return hpadding(element) + hborders(element) + (includeMargins ? hmargins(element) : 0);
 }
 
 
 function hpadding(element) {
-       return (parseFloat($.curCSS(element[0], 'paddingLeft', true)) || 0) +
-              (parseFloat($.curCSS(element[0], 'paddingRight', true)) || 0);
+       return (parseFloat($.css(element[0], 'paddingLeft', true)) || 0) +
+              (parseFloat($.css(element[0], 'paddingRight', true)) || 0);
 }
 
 
 function hmargins(element) {
-       return (parseFloat($.curCSS(element[0], 'marginLeft', true)) || 0) +
-              (parseFloat($.curCSS(element[0], 'marginRight', true)) || 0);
+       return (parseFloat($.css(element[0], 'marginLeft', true)) || 0) +
+              (parseFloat($.css(element[0], 'marginRight', true)) || 0);
 }
 
 
 function hborders(element) {
-       return (parseFloat($.curCSS(element[0], 'borderLeftWidth', true)) || 0) +
-              (parseFloat($.curCSS(element[0], 'borderRightWidth', true)) || 0);
+       return (parseFloat($.css(element[0], 'borderLeftWidth', true)) || 0) +
+              (parseFloat($.css(element[0], 'borderRightWidth', true)) || 0);
 }
 
 
@@ -1774,29 +1773,20 @@ function vsides(element, includeMargins) {
 
 
 function vpadding(element) {
-       return (parseFloat($.curCSS(element[0], 'paddingTop', true)) || 0) +
-              (parseFloat($.curCSS(element[0], 'paddingBottom', true)) || 0);
+       return (parseFloat($.css(element[0], 'paddingTop', true)) || 0) +
+              (parseFloat($.css(element[0], 'paddingBottom', true)) || 0);
 }
 
 
 function vmargins(element) {
-       return (parseFloat($.curCSS(element[0], 'marginTop', true)) || 0) +
-              (parseFloat($.curCSS(element[0], 'marginBottom', true)) || 0);
+       return (parseFloat($.css(element[0], 'marginTop', true)) || 0) +
+              (parseFloat($.css(element[0], 'marginBottom', true)) || 0);
 }
 
 
 function vborders(element) {
-       return (parseFloat($.curCSS(element[0], 'borderTopWidth', true)) || 0) +
-              (parseFloat($.curCSS(element[0], 'borderBottomWidth', true)) || 0);
-}
-
-
-function setMinHeight(element, height) {
-       height = (typeof height == 'number' ? height + 'px' : height);
-       element.each(function(i, _element) {
-               _element.style.cssText += ';min-height:' + height + ';_height:' + height;
-               // why can't we just use .css() ? i forget
-       });
+       return (parseFloat($.css(element[0], 'borderTopWidth', true)) || 0) +
+              (parseFloat($.css(element[0], 'borderBottomWidth', true)) || 0);
 }
 
 
@@ -1812,7 +1802,7 @@ function setMinHeight(element, height) {
 function noop() { }
 
 
-function cmp(a, b) {
+function dateCompare(a, b) {
        return a - b;
 }
 
@@ -1853,11 +1843,6 @@ function htmlEscape(s) {
 }
 
 
-function cssKey(_element) {
-       return _element.id + '/' + _element.className + '/' + _element.style.cssText.replace(/(^|;)\s*(top|left|width|height)\s*:[^;]*/ig, '');
-}
-
-
 function disableTextSelection(element) {
        element
                .attr('unselectable', 'on')
@@ -1956,6 +1941,7 @@ function firstDefined() {
 }
 
 
+;;
 
 fcViews.month = MonthView;
 
@@ -1971,44 +1957,56 @@ function MonthView(element, calendar) {
        BasicView.call(t, element, calendar, 'month');
        var opt = t.opt;
        var renderBasic = t.renderBasic;
+       var skipHiddenDays = t.skipHiddenDays;
+       var getCellsPerWeek = t.getCellsPerWeek;
        var formatDate = calendar.formatDate;
        
        
-       
        function render(date, delta) {
+
                if (delta) {
                        addMonths(date, delta);
                        date.setDate(1);
                }
+
+               var firstDay = opt('firstDay');
+
                var start = cloneDate(date, true);
                start.setDate(1);
+
                var end = addMonths(cloneDate(start), 1);
+
                var visStart = cloneDate(start);
+               addDays(visStart, -((visStart.getDay() - firstDay + 7) % 7));
+               skipHiddenDays(visStart);
+
                var visEnd = cloneDate(end);
-               var firstDay = opt('firstDay');
-               var nwe = opt('weekends') ? 0 : 1;
-               if (nwe) {
-                       skipWeekend(visStart);
-                       skipWeekend(visEnd, -1, true);
-               }
-               addDays(visStart, -((visStart.getDay() - Math.max(firstDay, nwe) + 7) % 7));
-               addDays(visEnd, (7 - visEnd.getDay() + Math.max(firstDay, nwe)) % 7);
-               var rowCnt = Math.round((visEnd - visStart) / (DAY_MS * 7));
+               addDays(visEnd, (7 - visEnd.getDay() + firstDay) % 7);
+               skipHiddenDays(visEnd, -1, true);
+
+               var colCnt = getCellsPerWeek();
+               var rowCnt = Math.round(dayDiff(visEnd, visStart) / 7); // should be no need for Math.round
+
                if (opt('weekMode') == 'fixed') {
-                       addDays(visEnd, (6 - rowCnt) * 7);
+                       addDays(visEnd, (6 - rowCnt) * 7); // add weeks to make up for it
                        rowCnt = 6;
                }
+
                t.title = formatDate(start, opt('titleFormat'));
+
                t.start = start;
                t.end = end;
                t.visStart = visStart;
                t.visEnd = visEnd;
-               renderBasic(6, rowCnt, nwe ? 5 : 7, true);
+
+               renderBasic(rowCnt, colCnt, true);
        }
        
        
 }
 
+;;
+
 fcViews.basicWeek = BasicWeekView;
 
 function BasicWeekView(element, calendar) {
@@ -2023,41 +2021,48 @@ function BasicWeekView(element, calendar) {
        BasicView.call(t, element, calendar, 'basicWeek');
        var opt = t.opt;
        var renderBasic = t.renderBasic;
+       var skipHiddenDays = t.skipHiddenDays;
+       var getCellsPerWeek = t.getCellsPerWeek;
        var formatDates = calendar.formatDates;
        
        
-       
        function render(date, delta) {
+
                if (delta) {
                        addDays(date, delta * 7);
                }
+
                var start = addDays(cloneDate(date), -((date.getDay() - opt('firstDay') + 7) % 7));
                var end = addDays(cloneDate(start), 7);
+
                var visStart = cloneDate(start);
+               skipHiddenDays(visStart);
+
                var visEnd = cloneDate(end);
-               var weekends = opt('weekends');
-               if (!weekends) {
-                       skipWeekend(visStart);
-                       skipWeekend(visEnd, -1, true);
-               }
-               t.title = formatDates(
-                       visStart,
-                       addDays(cloneDate(visEnd), -1),
-                       opt('titleFormat')
-               );
+               skipHiddenDays(visEnd, -1, true);
+
+               var colCnt = getCellsPerWeek();
+
                t.start = start;
                t.end = end;
                t.visStart = visStart;
                t.visEnd = visEnd;
-               renderBasic(1, 1, weekends ? 7 : 5, false);
+
+               t.title = formatDates(
+                       visStart,
+                       addDays(cloneDate(visEnd), -1),
+                       opt('titleFormat')
+               );
+
+               renderBasic(1, colCnt, false);
        }
        
        
 }
 
-fcViews.basicDay = BasicDayView;
+;;
 
-//TODO: when calendar's date starts out on a weekend, shouldn't happen
+fcViews.basicDay = BasicDayView;
 
 
 function BasicDayView(element, calendar) {
@@ -2072,26 +2077,33 @@ function BasicDayView(element, calendar) {
        BasicView.call(t, element, calendar, 'basicDay');
        var opt = t.opt;
        var renderBasic = t.renderBasic;
+       var skipHiddenDays = t.skipHiddenDays;
        var formatDate = calendar.formatDate;
        
        
-       
        function render(date, delta) {
+
                if (delta) {
                        addDays(date, delta);
-                       if (!opt('weekends')) {
-                               skipWeekend(date, delta < 0 ? -1 : 1);
-                       }
                }
+               skipHiddenDays(date, delta < 0 ? -1 : 1);
+
+               var start = cloneDate(date, true);
+               var end = addDays(cloneDate(start), 1);
+
                t.title = formatDate(date, opt('titleFormat'));
-               t.start = t.visStart = cloneDate(date, true);
-               t.end = t.visEnd = addDays(cloneDate(t.start), 1);
-               renderBasic(1, 1, 1, false);
+
+               t.start = t.visStart = start;
+               t.end = t.visEnd = end;
+
+               renderBasic(1, 1, false);
        }
        
        
 }
 
+;;
+
 setDefaults({
        weekMode: 'fixed'
 });
@@ -2114,14 +2126,12 @@ function BasicView(element, calendar, viewName) {
        t.dragStop = dragStop;
        t.defaultEventEnd = defaultEventEnd;
        t.getHoverListener = function() { return hoverListener };
+       t.colLeft = colLeft;
+       t.colRight = colRight;
        t.colContentLeft = colContentLeft;
        t.colContentRight = colContentRight;
-       t.dayOfWeekCol = dayOfWeekCol;
-       t.dateCell = dateCell;
-       t.cellDate = cellDate;
-       t.cellIsAllDay = function() { return true };
+       t.getIsCellAllDay = function() { return true };
        t.allDayRow = allDayRow;
-       t.allDayBounds = allDayBounds;
        t.getRowCnt = function() { return rowCnt };
        t.getColCnt = function() { return colCnt };
        t.getColWidth = function() { return colWidth };
@@ -2135,38 +2145,45 @@ function BasicView(element, calendar, viewName) {
        BasicEventRenderer.call(t);
        var opt = t.opt;
        var trigger = t.trigger;
-       var clearEvents = t.clearEvents;
        var renderOverlay = t.renderOverlay;
        var clearOverlays = t.clearOverlays;
        var daySelectionMousedown = t.daySelectionMousedown;
+       var cellToDate = t.cellToDate;
+       var dateToCell = t.dateToCell;
+       var rangeToSegments = t.rangeToSegments;
        var formatDate = calendar.formatDate;
        
        
        // locals
        
+       var table;
        var head;
        var headCells;
        var body;
        var bodyRows;
        var bodyCells;
        var bodyFirstCells;
-       var bodyCellTopInners;
+       var firstRowCellInners;
+       var firstRowCellContentInners;
        var daySegmentContainer;
        
        var viewWidth;
        var viewHeight;
        var colWidth;
+       var weekNumberWidth;
        
        var rowCnt, colCnt;
+       var showNumbers;
        var coordinateGrid;
        var hoverListener;
+       var colPositions;
        var colContentPositions;
        
-       var rtl, dis, dit;
-       var firstDay;
-       var nwe;
        var tm;
        var colFormat;
+       var showWeekNumbers;
+       var weekNumberTitle;
+       var weekNumberFormat;
        
        
        
@@ -2177,154 +2194,212 @@ function BasicView(element, calendar, viewName) {
        disableTextSelection(element.addClass('fc-grid'));
        
        
-       function renderBasic(maxr, r, c, showNumbers) {
-               rowCnt = r;
-               colCnt = c;
+       function renderBasic(_rowCnt, _colCnt, _showNumbers) {
+               rowCnt = _rowCnt;
+               colCnt = _colCnt;
+               showNumbers = _showNumbers;
                updateOptions();
-               var firstTime = !body;
-               if (firstTime) {
-                       buildSkeleton(maxr, showNumbers);
-               }else{
-                       clearEvents();
+
+               if (!body) {
+                       buildEventContainer();
                }
-               updateCells(firstTime);
+
+               buildTable();
        }
        
        
-       
        function updateOptions() {
-               rtl = opt('isRTL');
-               if (rtl) {
-                       dis = -1;
-                       dit = colCnt - 1;
-               }else{
-                       dis = 1;
-                       dit = 0;
-               }
-               firstDay = opt('firstDay');
-               nwe = opt('weekends') ? 0 : 1;
                tm = opt('theme') ? 'ui' : 'fc';
                colFormat = opt('columnFormat');
+
+               // week # options. (TODO: bad, logic also in other views)
+               showWeekNumbers = opt('weekNumbers');
+               weekNumberTitle = opt('weekNumberTitle');
+               if (opt('weekNumberCalculation') != 'iso') {
+                       weekNumberFormat = "w";
+               }
+               else {
+                       weekNumberFormat = "W";
+               }
        }
        
        
+       function buildEventContainer() {
+               daySegmentContainer =
+                       $("<div class='fc-event-container' style='position:absolute;z-index:8;top:0;left:0'/>")
+                               .appendTo(element);
+       }
        
-       function buildSkeleton(maxRowCnt, showNumbers) {
-               var s;
-               var headerClass = tm + "-widget-header";
-               var contentClass = tm + "-widget-content";
-               var i, j;
-               var table;
-               
-               s =
-                       "<table class='fc-border-separate' style='width:100%' cellspacing='0'>" +
-                       "<thead>" +
-                       "<tr>";
-               for (i=0; i<colCnt; i++) {
-                       s +=
-                               "<th class='fc- " + headerClass + "'/>"; // need fc- for setDayID
-               }
-               s +=
-                       "</tr>" +
-                       "</thead>" +
-                       "<tbody>";
-               for (i=0; i<maxRowCnt; i++) {
-                       s +=
-                               "<tr class='fc-week" + i + "'>";
-                       for (j=0; j<colCnt; j++) {
-                               s +=
-                                       "<td class='fc- " + contentClass + " fc-day" + (i*colCnt+j) + "'>" + // need fc- for setDayID
-                                       "<div>" +
-                                       (showNumbers ?
-                                               "<div class='fc-day-number'/>" :
-                                               ''
-                                               ) +
-                                       "<div class='fc-day-content'>" +
-                                       "<div style='position:relative'>&nbsp;</div>" +
-                                       "</div>" +
-                                       "</div>" +
-                                       "</td>";
-                       }
-                       s +=
-                               "</tr>";
+       
+       function buildTable() {
+               var html = buildTableHTML();
+
+               if (table) {
+                       table.remove();
                }
-               s +=
-                       "</tbody>" +
-                       "</table>";
-               table = $(s).appendTo(element);
-               
+               table = $(html).appendTo(element);
+
                head = table.find('thead');
-               headCells = head.find('th');
+               headCells = head.find('.fc-day-header');
                body = table.find('tbody');
                bodyRows = body.find('tr');
-               bodyCells = body.find('td');
-               bodyFirstCells = bodyCells.filter(':first-child');
-               bodyCellTopInners = bodyRows.eq(0).find('div.fc-day-content div');
+               bodyCells = body.find('.fc-day');
+               bodyFirstCells = bodyRows.find('td:first-child');
+
+               firstRowCellInners = bodyRows.eq(0).find('.fc-day > div');
+               firstRowCellContentInners = bodyRows.eq(0).find('.fc-day-content > div');
                
                markFirstLast(head.add(head.find('tr'))); // marks first+last tr/th's
                markFirstLast(bodyRows); // marks first+last td's
-               bodyRows.eq(0).addClass('fc-first'); // fc-last is done in updateCells
-               
+               bodyRows.eq(0).addClass('fc-first');
+               bodyRows.filter(':last').addClass('fc-last');
+
+               bodyCells.each(function(i, _cell) {
+                       var date = cellToDate(
+                               Math.floor(i / colCnt),
+                               i % colCnt
+                       );
+                       trigger('dayRender', t, date, $(_cell));
+               });
+
                dayBind(bodyCells);
-               
-               daySegmentContainer =
-                       $("<div style='position:absolute;z-index:8;top:0;left:0'/>")
-                               .appendTo(element);
        }
-       
-       
-       
-       function updateCells(firstTime) {
-               var dowDirty = firstTime || rowCnt == 1; // could the cells' day-of-weeks need updating?
-               var month = t.start.getMonth();
-               var today = clearTime(new Date());
-               var cell;
+
+
+
+       /* HTML Building
+       -----------------------------------------------------------*/
+
+
+       function buildTableHTML() {
+               var html =
+                       "<table class='fc-border-separate' style='width:100%' cellspacing='0'>" +
+                       buildHeadHTML() +
+                       buildBodyHTML() +
+                       "</table>";
+
+               return html;
+       }
+
+
+       function buildHeadHTML() {
+               var headerClass = tm + "-widget-header";
+               var html = '';
+               var col;
                var date;
-               var row;
-       
-               if (dowDirty) {
-                       headCells.each(function(i, _cell) {
-                               cell = $(_cell);
-                               date = indexDate(i);
-                               cell.html(formatDate(date, colFormat));
-                               setDayID(cell, date);
-                       });
+
+               html += "<thead><tr>";
+
+               if (showWeekNumbers) {
+                       html +=
+                               "<th class='fc-week-number " + headerClass + "'>" +
+                               htmlEscape(weekNumberTitle) +
+                               "</th>";
                }
-               
-               bodyCells.each(function(i, _cell) {
-                       cell = $(_cell);
-                       date = indexDate(i);
-                       if (date.getMonth() == month) {
-                               cell.removeClass('fc-other-month');
-                       }else{
-                               cell.addClass('fc-other-month');
-                       }
-                       if (+date == +today) {
-                               cell.addClass(tm + '-state-highlight fc-today');
-                       }else{
-                               cell.removeClass(tm + '-state-highlight fc-today');
-                       }
-                       cell.find('div.fc-day-number').text(date.getDate());
-                       if (dowDirty) {
-                               setDayID(cell, date);
+
+               for (col=0; col<colCnt; col++) {
+                       date = cellToDate(0, col);
+                       html +=
+                               "<th class='fc-day-header fc-" + dayIDs[date.getDay()] + " " + headerClass + "'>" +
+                               htmlEscape(formatDate(date, colFormat)) +
+                               "</th>";
+               }
+
+               html += "</tr></thead>";
+
+               return html;
+       }
+
+
+       function buildBodyHTML() {
+               var contentClass = tm + "-widget-content";
+               var html = '';
+               var row;
+               var col;
+               var date;
+
+               html += "<tbody>";
+
+               for (row=0; row<rowCnt; row++) {
+
+                       html += "<tr class='fc-week'>";
+
+                       if (showWeekNumbers) {
+                               date = cellToDate(row, 0);
+                               html +=
+                                       "<td class='fc-week-number " + contentClass + "'>" +
+                                       "<div>" +
+                                       htmlEscape(formatDate(date, weekNumberFormat)) +
+                                       "</div>" +
+                                       "</td>";
                        }
-               });
-               
-               bodyRows.each(function(i, _row) {
-                       row = $(_row);
-                       if (i < rowCnt) {
-                               row.show();
-                               if (i == rowCnt-1) {
-                                       row.addClass('fc-last');
-                               }else{
-                                       row.removeClass('fc-last');
-                               }
-                       }else{
-                               row.hide();
+
+                       for (col=0; col<colCnt; col++) {
+                               date = cellToDate(row, col);
+                               html += buildCellHTML(date);
                        }
-               });
+
+                       html += "</tr>";
+               }
+
+               html += "</tbody>";
+
+               return html;
        }
-       
+
+
+       function buildCellHTML(date) {
+               var contentClass = tm + "-widget-content";
+               var month = t.start.getMonth();
+               var today = clearTime(new Date());
+               var html = '';
+               var classNames = [
+                       'fc-day',
+                       'fc-' + dayIDs[date.getDay()],
+                       contentClass
+               ];
+
+               if (date.getMonth() != month) {
+                       classNames.push('fc-other-month');
+               }
+               if (+date == +today) {
+                       classNames.push(
+                               'fc-today',
+                               tm + '-state-highlight'
+                       );
+               }
+               else if (date < today) {
+                       classNames.push('fc-past');
+               }
+               else {
+                       classNames.push('fc-future');
+               }
+
+               html +=
+                       "<td" +
+                       " class='" + classNames.join(' ') + "'" +
+                       " data-date='" + formatDate(date, 'yyyy-MM-dd') + "'" +
+                       ">" +
+                       "<div>";
+
+               if (showNumbers) {
+                       html += "<div class='fc-day-number'>" + date.getDate() + "</div>";
+               }
+
+               html +=
+                       "<div class='fc-day-content'>" +
+                       "<div style='position:relative'>&nbsp;</div>" +
+                       "</div>" +
+                       "</div>" +
+                       "</td>";
+
+               return html;
+       }
+
+
+
+       /* Dimensions
+       -----------------------------------------------------------*/
        
        
        function setHeight(height) {
@@ -2345,8 +2420,8 @@ function BasicView(element, calendar, viewName) {
                bodyFirstCells.each(function(i, _cell) {
                        if (i < rowCnt) {
                                cell = $(_cell);
-                               setMinHeight(
-                                       cell.find('> div'),
+                               cell.find('> div').css(
+                                       'min-height',
                                        (i==rowCnt-1 ? rowHeightLast : rowHeight) - vsides(cell)
                                );
                        }
@@ -2357,8 +2432,15 @@ function BasicView(element, calendar, viewName) {
        
        function setWidth(width) {
                viewWidth = width;
+               colPositions.clear();
                colContentPositions.clear();
-               colWidth = Math.floor(viewWidth / colCnt);
+
+               weekNumberWidth = 0;
+               if (showWeekNumbers) {
+                       weekNumberWidth = head.find('th.fc-week-number').outerWidth();
+               }
+
+               colWidth = Math.floor((viewWidth - weekNumberWidth) / colCnt);
                setOuterWidth(headCells.slice(0, -1), colWidth);
        }
        
@@ -2376,8 +2458,7 @@ function BasicView(element, calendar, viewName) {
        
        function dayClick(ev) {
                if (!opt('selectable')) { // if selectable, SelectionManager will worry about dayClick
-                       var index = parseInt(this.className.match(/fc\-day(\d+)/)[1]); // TODO: maybe use .data
-                       var date = indexDate(index);
+                       var date = parseISO8601($(this).data('date'));
                        trigger('dayClick', this, date, true, ev);
                }
        }
@@ -2386,35 +2467,30 @@ function BasicView(element, calendar, viewName) {
        
        /* Semi-transparent Overlay Helpers
        ------------------------------------------------------*/
-       
-       
+       // TODO: should be consolidated with AgendaView's methods
+
+
        function renderDayOverlay(overlayStart, overlayEnd, refreshCoordinateGrid) { // overlayEnd is exclusive
+
                if (refreshCoordinateGrid) {
                        coordinateGrid.build();
                }
-               var rowStart = cloneDate(t.visStart);
-               var rowEnd = addDays(cloneDate(rowStart), colCnt);
-               for (var i=0; i<rowCnt; i++) {
-                       var stretchStart = new Date(Math.max(rowStart, overlayStart));
-                       var stretchEnd = new Date(Math.min(rowEnd, overlayEnd));
-                       if (stretchStart < stretchEnd) {
-                               var colStart, colEnd;
-                               if (rtl) {
-                                       colStart = dayDiff(stretchEnd, rowStart)*dis+dit+1;
-                                       colEnd = dayDiff(stretchStart, rowStart)*dis+dit+1;
-                               }else{
-                                       colStart = dayDiff(stretchStart, rowStart);
-                                       colEnd = dayDiff(stretchEnd, rowStart);
-                               }
-                               dayBind(
-                                       renderCellOverlay(i, colStart, i, colEnd-1)
-                               );
-                       }
-                       addDays(rowStart, 7);
-                       addDays(rowEnd, 7);
+
+               var segments = rangeToSegments(overlayStart, overlayEnd);
+
+               for (var i=0; i<segments.length; i++) {
+                       var segment = segments[i];
+                       dayBind(
+                               renderCellOverlay(
+                                       segment.row,
+                                       segment.leftCol,
+                                       segment.row,
+                                       segment.rightCol
+                               )
+                       );
                }
        }
-       
+
        
        function renderCellOverlay(row0, col0, row1, col1) { // row1,col1 is inclusive
                var rect = coordinateGrid.rect(row0, col0, row1, col1, element);
@@ -2443,7 +2519,7 @@ function BasicView(element, calendar, viewName) {
        
        
        function reportDayClick(date, allDay, ev) {
-               var cell = dateCell(date);
+               var cell = dateToCell(date);
                var _element = bodyCells[cell.row*colCnt + cell.col];
                trigger('dayClick', _element, date, allDay, ev);
        }
@@ -2468,7 +2544,7 @@ function BasicView(element, calendar, viewName) {
                var cell = hoverListener.stop();
                clearOverlays();
                if (cell) {
-                       var d = cellDate(cell);
+                       var d = cellToDate(cell);
                        trigger('drop', _dragElement, d, true, ev, ui);
                }
        }
@@ -2513,10 +2589,23 @@ function BasicView(element, calendar, viewName) {
        
        hoverListener = new HoverListener(coordinateGrid);
        
-       
+       colPositions = new HorizontalPositionCache(function(col) {
+               return firstRowCellInners.eq(col);
+       });
+
        colContentPositions = new HorizontalPositionCache(function(col) {
-               return bodyCellTopInners.eq(col);
+               return firstRowCellContentInners.eq(col);
        });
+
+
+       function colLeft(col) {
+               return colPositions.left(col);
+       }
+
+
+       function colRight(col) {
+               return colPositions.right(col);
+       }
        
        
        function colContentLeft(col) {
@@ -2529,195 +2618,43 @@ function BasicView(element, calendar, viewName) {
        }
        
        
-       
-       
-       function dateCell(date) {
-               return {
-                       row: Math.floor(dayDiff(date, t.visStart) / 7),
-                       col: dayOfWeekCol(date.getDay())
-               };
-       }
-       
-       
-       function cellDate(cell) {
-               return _cellDate(cell.row, cell.col);
-       }
-       
-       
-       function _cellDate(row, col) {
-               return addDays(cloneDate(t.visStart), row*7 + col*dis+dit);
-               // what about weekends in middle of week?
-       }
-       
-       
-       function indexDate(index) {
-               return _cellDate(Math.floor(index/colCnt), index%colCnt);
-       }
-       
-       
-       function dayOfWeekCol(dayOfWeek) {
-               return ((dayOfWeek - Math.max(firstDay, nwe) + colCnt) % colCnt) * dis + dit;
-       }
-       
-       
-       
-       
        function allDayRow(i) {
                return bodyRows.eq(i);
        }
        
-       
-       function allDayBounds(i) {
-               return {
-                       left: 0,
-                       right: viewWidth
-               };
-       }
-       
-       
 }
 
+;;
+
 function BasicEventRenderer() {
        var t = this;
        
        
        // exports
        t.renderEvents = renderEvents;
-       t.compileDaySegs = compileSegs; // for DayEventRenderer
        t.clearEvents = clearEvents;
-       t.bindDaySeg = bindDaySeg;
-       
        
+
        // imports
        DayEventRenderer.call(t);
-       var opt = t.opt;
-       var trigger = t.trigger;
-       //var setOverflowHidden = t.setOverflowHidden;
-       var isEventDraggable = t.isEventDraggable;
-       var isEventResizable = t.isEventResizable;
-       var reportEvents = t.reportEvents;
-       var reportEventClear = t.reportEventClear;
-       var eventElementHandlers = t.eventElementHandlers;
-       var showEvents = t.showEvents;
-       var hideEvents = t.hideEvents;
-       var eventDrop = t.eventDrop;
-       var getDaySegmentContainer = t.getDaySegmentContainer;
-       var getHoverListener = t.getHoverListener;
-       var renderDayOverlay = t.renderDayOverlay;
-       var clearOverlays = t.clearOverlays;
-       var getRowCnt = t.getRowCnt;
-       var getColCnt = t.getColCnt;
-       var renderDaySegs = t.renderDaySegs;
-       var resizableDayEvent = t.resizableDayEvent;
-       
-       
-       
-       /* Rendering
-       --------------------------------------------------------------------*/
-       
+
        
        function renderEvents(events, modifiedEventId) {
-               reportEvents(events);
-               renderDaySegs(compileSegs(events), modifiedEventId);
+               t.renderDayEvents(events, modifiedEventId);
        }
        
        
        function clearEvents() {
-               reportEventClear();
-               getDaySegmentContainer().empty();
-       }
-       
-       
-       function compileSegs(events) {
-               var rowCnt = getRowCnt(),
-                       colCnt = getColCnt(),
-                       d1 = cloneDate(t.visStart),
-                       d2 = addDays(cloneDate(d1), colCnt),
-                       visEventsEnds = $.map(events, exclEndDay),
-                       i, row,
-                       j, level,
-                       k, seg,
-                       segs=[];
-               for (i=0; i<rowCnt; i++) {
-                       row = stackSegs(sliceSegs(events, visEventsEnds, d1, d2));
-                       for (j=0; j<row.length; j++) {
-                               level = row[j];
-                               for (k=0; k<level.length; k++) {
-                                       seg = level[k];
-                                       seg.row = i;
-                                       seg.level = j; // not needed anymore
-                                       segs.push(seg);
-                               }
-                       }
-                       addDays(d1, 7);
-                       addDays(d2, 7);
-               }
-               return segs;
-       }
-       
-       
-       function bindDaySeg(event, eventElement, seg) {
-               if (isEventDraggable(event)) {
-                       draggableDayEvent(event, eventElement);
-               }
-               if (seg.isEnd && isEventResizable(event)) {
-                       resizableDayEvent(event, eventElement, seg);
-               }
-               eventElementHandlers(event, eventElement);
-                       // needs to be after, because resizableDayEvent might stopImmediatePropagation on click
-       }
-       
-       
-       
-       /* Dragging
-       ----------------------------------------------------------------------------*/
-       
-       
-       function draggableDayEvent(event, eventElement) {
-               var hoverListener = getHoverListener();
-               var dayDelta;
-               eventElement.draggable({
-                       zIndex: 9,
-                       delay: 50,
-                       opacity: opt('dragOpacity'),
-                       revertDuration: opt('dragRevertDuration'),
-                       start: function(ev, ui) {
-                               trigger('eventDragStart', eventElement, event, ev, ui);
-                               hideEvents(event, eventElement);
-                               hoverListener.start(function(cell, origCell, rowDelta, colDelta) {
-                                       eventElement.draggable('option', 'revert', !cell || !rowDelta && !colDelta);
-                                       clearOverlays();
-                                       if (cell) {
-                                               //setOverflowHidden(true);
-                                               dayDelta = rowDelta*7 + colDelta * (opt('isRTL') ? -1 : 1);
-                                               renderDayOverlay(
-                                                       addDays(cloneDate(event.start), dayDelta),
-                                                       addDays(exclEndDay(event), dayDelta)
-                                               );
-                                       }else{
-                                               //setOverflowHidden(false);
-                                               dayDelta = 0;
-                                       }
-                               }, ev, 'drag');
-                       },
-                       stop: function(ev, ui) {
-                               hoverListener.stop();
-                               clearOverlays();
-                               trigger('eventDragStop', eventElement, event, ev, ui);
-                               if (dayDelta) {
-                                       eventDrop(this, event, dayDelta, 0, event.allDay, ev, ui);
-                               }else{
-                                       eventElement.css('filter', ''); // clear IE opacity side-effects
-                                       showEvents(event, eventElement);
-                               }
-                               //setOverflowHidden(false);
-                       }
-               });
+               t.getDaySegmentContainer().empty();
        }
 
 
+       // TODO: have this class (and AgendaEventRenderer) be responsible for creating the event container div
+
 }
 
+;;
+
 fcViews.agendaWeek = AgendaWeekView;
 
 function AgendaWeekView(element, calendar) {
@@ -2732,40 +2669,49 @@ function AgendaWeekView(element, calendar) {
        AgendaView.call(t, element, calendar, 'agendaWeek');
        var opt = t.opt;
        var renderAgenda = t.renderAgenda;
+       var skipHiddenDays = t.skipHiddenDays;
+       var getCellsPerWeek = t.getCellsPerWeek;
        var formatDates = calendar.formatDates;
-       
-       
+
        
        function render(date, delta) {
+
                if (delta) {
                        addDays(date, delta * 7);
                }
+
                var start = addDays(cloneDate(date), -((date.getDay() - opt('firstDay') + 7) % 7));
                var end = addDays(cloneDate(start), 7);
+
                var visStart = cloneDate(start);
+               skipHiddenDays(visStart);
+
                var visEnd = cloneDate(end);
-               var weekends = opt('weekends');
-               if (!weekends) {
-                       skipWeekend(visStart);
-                       skipWeekend(visEnd, -1, true);
-               }
+               skipHiddenDays(visEnd, -1, true);
+
+               var colCnt = getCellsPerWeek();
+
                t.title = formatDates(
                        visStart,
                        addDays(cloneDate(visEnd), -1),
                        opt('titleFormat')
                );
+
                t.start = start;
                t.end = end;
                t.visStart = visStart;
                t.visEnd = visEnd;
-               renderAgenda(weekends ? 7 : 5);
+
+               renderAgenda(colCnt);
        }
-       
 
 }
 
+;;
+
 fcViews.agendaDay = AgendaDayView;
 
+
 function AgendaDayView(element, calendar) {
        var t = this;
        
@@ -2778,28 +2724,33 @@ function AgendaDayView(element, calendar) {
        AgendaView.call(t, element, calendar, 'agendaDay');
        var opt = t.opt;
        var renderAgenda = t.renderAgenda;
+       var skipHiddenDays = t.skipHiddenDays;
        var formatDate = calendar.formatDate;
        
        
-       
        function render(date, delta) {
+
                if (delta) {
                        addDays(date, delta);
-                       if (!opt('weekends')) {
-                               skipWeekend(date, delta < 0 ? -1 : 1);
-                       }
                }
+               skipHiddenDays(date, delta < 0 ? -1 : 1);
+
                var start = cloneDate(date, true);
                var end = addDays(cloneDate(start), 1);
+
                t.title = formatDate(date, opt('titleFormat'));
+
                t.start = t.visStart = start;
                t.end = t.visEnd = end;
+
                renderAgenda(1);
        }
        
 
 }
 
+;;
+
 setDefaults({
        allDaySlot: true,
        allDayText: 'all-day',
@@ -2814,7 +2765,8 @@ setDefaults({
                agenda: .5
        },
        minTime: 0,
-       maxTime: 24
+       maxTime: 24,
+       slotEventOverlap: true
 });
 
 
@@ -2830,28 +2782,27 @@ function AgendaView(element, calendar, viewName) {
        t.renderAgenda = renderAgenda;
        t.setWidth = setWidth;
        t.setHeight = setHeight;
-       t.beforeHide = beforeHide;
-       t.afterShow = afterShow;
+       t.afterRender = afterRender;
        t.defaultEventEnd = defaultEventEnd;
        t.timePosition = timePosition;
-       t.dayOfWeekCol = dayOfWeekCol;
-       t.dateCell = dateCell;
-       t.cellDate = cellDate;
-       t.cellIsAllDay = cellIsAllDay;
+       t.getIsCellAllDay = getIsCellAllDay;
        t.allDayRow = getAllDayRow;
-       t.allDayBounds = allDayBounds;
+       t.getCoordinateGrid = function() { return coordinateGrid }; // specifically for AgendaEventRenderer
        t.getHoverListener = function() { return hoverListener };
+       t.colLeft = colLeft;
+       t.colRight = colRight;
        t.colContentLeft = colContentLeft;
        t.colContentRight = colContentRight;
        t.getDaySegmentContainer = function() { return daySegmentContainer };
        t.getSlotSegmentContainer = function() { return slotSegmentContainer };
        t.getMinMinute = function() { return minMinute };
        t.getMaxMinute = function() { return maxMinute };
-       t.getBodyContent = function() { return slotContent }; // !!??
+       t.getSlotContainer = function() { return slotContainer };
        t.getRowCnt = function() { return 1 };
        t.getColCnt = function() { return colCnt };
        t.getColWidth = function() { return colWidth };
-       t.getSlotHeight = function() { return slotHeight };
+       t.getSnapHeight = function() { return snapHeight };
+       t.getSnapMinutes = function() { return snapMinutes };
        t.defaultSelectionEnd = defaultSelectionEnd;
        t.renderDayOverlay = renderDayOverlay;
        t.renderSelection = renderSelection;
@@ -2868,13 +2819,15 @@ function AgendaView(element, calendar, viewName) {
        AgendaEventRenderer.call(t);
        var opt = t.opt;
        var trigger = t.trigger;
-       var clearEvents = t.clearEvents;
        var renderOverlay = t.renderOverlay;
        var clearOverlays = t.clearOverlays;
        var reportSelection = t.reportSelection;
        var unselect = t.unselect;
        var daySelectionMousedown = t.daySelectionMousedown;
        var slotSegHtml = t.slotSegHtml;
+       var cellToDate = t.cellToDate;
+       var dateToCell = t.dateToCell;
+       var rangeToSegments = t.rangeToSegments;
        var formatDate = calendar.formatDate;
        
        
@@ -2886,6 +2839,7 @@ function AgendaView(element, calendar, viewName) {
        var dayBody;
        var dayBodyCells;
        var dayBodyCellInners;
+       var dayBodyCellContentInners;
        var dayBodyFirstCell;
        var dayBodyFirstCellStretcher;
        var slotLayer;
@@ -2893,12 +2847,9 @@ function AgendaView(element, calendar, viewName) {
        var allDayTable;
        var allDayRow;
        var slotScroller;
-       var slotContent;
+       var slotContainer;
        var slotSegmentContainer;
        var slotTable;
-       var slotTableFirstInner;
-       var axisFirstCells;
-       var gutterCells;
        var selectionHelper;
        
        var viewWidth;
@@ -2907,21 +2858,26 @@ function AgendaView(element, calendar, viewName) {
        var colWidth;
        var gutterWidth;
        var slotHeight; // TODO: what if slotHeight changes? (see issue 650)
-       var savedScrollTop;
+
+       var snapMinutes;
+       var snapRatio; // ratio of number of "selection" slots to normal slots. (ex: 1, 2, 4)
+       var snapHeight; // holds the pixel hight of a "selection" slot
        
        var colCnt;
        var slotCnt;
        var coordinateGrid;
        var hoverListener;
+       var colPositions;
        var colContentPositions;
        var slotTopCache = {};
        
        var tm;
-       var firstDay;
-       var nwe;            // no weekends (int)
-       var rtl, dis, dit;  // day index sign / translate
+       var rtl;
        var minMinute, maxMinute;
        var colFormat;
+       var showWeekNumbers;
+       var weekNumberTitle;
+       var weekNumberFormat;
        
 
        
@@ -2935,89 +2891,54 @@ function AgendaView(element, calendar, viewName) {
        function renderAgenda(c) {
                colCnt = c;
                updateOptions();
-               if (!dayTable) {
-                       buildSkeleton();
-               }else{
-                       clearEvents();
+
+               if (!dayTable) { // first time rendering?
+                       buildSkeleton(); // builds day table, slot area, events containers
+               }
+               else {
+                       buildDayTable(); // rebuilds day table
                }
-               updateCells();
        }
        
        
-       
        function updateOptions() {
+
                tm = opt('theme') ? 'ui' : 'fc';
-               nwe = opt('weekends') ? 0 : 1;
-               firstDay = opt('firstDay');
-               if (rtl = opt('isRTL')) {
-                       dis = -1;
-                       dit = colCnt - 1;
-               }else{
-                       dis = 1;
-                       dit = 0;
-               }
+               rtl = opt('isRTL')
                minMinute = parseTime(opt('minTime'));
                maxMinute = parseTime(opt('maxTime'));
                colFormat = opt('columnFormat');
+
+               // week # options. (TODO: bad, logic also in other views)
+               showWeekNumbers = opt('weekNumbers');
+               weekNumberTitle = opt('weekNumberTitle');
+               if (opt('weekNumberCalculation') != 'iso') {
+                       weekNumberFormat = "w";
+               }
+               else {
+                       weekNumberFormat = "W";
+               }
+
+               snapMinutes = opt('snapMinutes') || opt('slotMinutes');
        }
-       
-       
-       
+
+
+
+       /* Build DOM
+       -----------------------------------------------------------------------*/
+
+
        function buildSkeleton() {
                var headerClass = tm + "-widget-header";
                var contentClass = tm + "-widget-content";
                var s;
-               var i;
                var d;
+               var i;
                var maxd;
                var minutes;
                var slotNormal = opt('slotMinutes') % 15 == 0;
                
-               s =
-                       "<table style='width:100%' class='fc-agenda-days fc-border-separate' cellspacing='0'>" +
-                       "<thead>" +
-                       "<tr>" +
-                       "<th class='fc-agenda-axis " + headerClass + "'>&nbsp;</th>";
-               for (i=0; i<colCnt; i++) {
-                       s +=
-                               "<th class='fc- fc-col" + i + ' ' + headerClass + "'/>"; // fc- needed for setDayID
-               }
-               s +=
-                       "<th class='fc-agenda-gutter " + headerClass + "'>&nbsp;</th>" +
-                       "</tr>" +
-                       "</thead>" +
-                       "<tbody>" +
-                       "<tr>" +
-                       "<th class='fc-agenda-axis " + headerClass + "'>&nbsp;</th>";
-               for (i=0; i<colCnt; i++) {
-                       s +=
-                               "<td class='fc- fc-col" + i + ' ' + contentClass + "'>" + // fc- needed for setDayID
-                               "<div>" +
-                               "<div class='fc-day-content'>" +
-                               "<div style='position:relative'>&nbsp;</div>" +
-                               "</div>" +
-                               "</div>" +
-                               "</td>";
-               }
-               s +=
-                       "<td class='fc-agenda-gutter " + contentClass + "'>&nbsp;</td>" +
-                       "</tr>" +
-                       "</tbody>" +
-                       "</table>";
-               dayTable = $(s).appendTo(element);
-               dayHead = dayTable.find('thead');
-               dayHeadCells = dayHead.find('th').slice(1, -1);
-               dayBody = dayTable.find('tbody');
-               dayBodyCells = dayBody.find('td').slice(0, -1);
-               dayBodyCellInners = dayBodyCells.find('div.fc-day-content div');
-               dayBodyFirstCell = dayBodyCells.eq(0);
-               dayBodyFirstCellStretcher = dayBodyFirstCell.find('> div');
-               
-               markFirstLast(dayHead.add(dayHead.find('tr')));
-               markFirstLast(dayBody.add(dayBody.find('tr')));
-               
-               axisFirstCells = dayHead.find('th:first');
-               gutterCells = dayTable.find('.fc-agenda-gutter');
+               buildDayTable();
                
                slotLayer =
                        $("<div style='position:absolute;z-index:2;left:0;width:100%'/>")
@@ -3026,7 +2947,7 @@ function AgendaView(element, calendar, viewName) {
                if (opt('allDaySlot')) {
                
                        daySegmentContainer =
-                               $("<div style='position:absolute;z-index:8;top:0;left:0'/>")
+                               $("<div class='fc-event-container' style='position:absolute;z-index:8;top:0;left:0'/>")
                                        .appendTo(slotLayer);
                
                        s =
@@ -3044,9 +2965,6 @@ function AgendaView(element, calendar, viewName) {
                        
                        dayBind(allDayRow.find('td'));
                        
-                       axisFirstCells = axisFirstCells.add(allDayTable.find('th:first'));
-                       gutterCells = gutterCells.add(allDayTable.find('th.fc-agenda-gutter'));
-                       
                        slotLayer.append(
                                "<div class='fc-agenda-divider " + headerClass + "'>" +
                                "<div class='fc-agenda-divider-inner'/>" +
@@ -3063,13 +2981,13 @@ function AgendaView(element, calendar, viewName) {
                        $("<div style='position:absolute;width:100%;overflow-x:hidden;overflow-y:auto'/>")
                                .appendTo(slotLayer);
                                
-               slotContent =
+               slotContainer =
                        $("<div style='position:relative;width:100%;overflow:hidden'/>")
                                .appendTo(slotScroller);
                                
                slotSegmentContainer =
-                       $("<div style='position:absolute;z-index:8;top:0;left:0'/>")
-                               .appendTo(slotContent);
+                       $("<div class='fc-event-container' style='position:absolute;z-index:8;top:0;left:0'/>")
+                               .appendTo(slotContainer);
                
                s =
                        "<table class='fc-agenda-slots' style='width:100%' cellspacing='0'>" +
@@ -3095,39 +3013,170 @@ function AgendaView(element, calendar, viewName) {
                s +=
                        "</tbody>" +
                        "</table>";
-               slotTable = $(s).appendTo(slotContent);
-               slotTableFirstInner = slotTable.find('div:first');
+               slotTable = $(s).appendTo(slotContainer);
                
                slotBind(slotTable.find('td'));
+       }
+
+
+
+       /* Build Day Table
+       -----------------------------------------------------------------------*/
+
+
+       function buildDayTable() {
+               var html = buildDayTableHTML();
+
+               if (dayTable) {
+                       dayTable.remove();
+               }
+               dayTable = $(html).appendTo(element);
+
+               dayHead = dayTable.find('thead');
+               dayHeadCells = dayHead.find('th').slice(1, -1); // exclude gutter
+               dayBody = dayTable.find('tbody');
+               dayBodyCells = dayBody.find('td').slice(0, -1); // exclude gutter
+               dayBodyCellInners = dayBodyCells.find('> div');
+               dayBodyCellContentInners = dayBodyCells.find('.fc-day-content > div');
+
+               dayBodyFirstCell = dayBodyCells.eq(0);
+               dayBodyFirstCellStretcher = dayBodyCellInners.eq(0);
                
-               axisFirstCells = axisFirstCells.add(slotTable.find('th:first'));
+               markFirstLast(dayHead.add(dayHead.find('tr')));
+               markFirstLast(dayBody.add(dayBody.find('tr')));
+
+               // TODO: now that we rebuild the cells every time, we should call dayRender
        }
-       
-       
-       
-       function updateCells() {
-               var i;
-               var headCell;
-               var bodyCell;
+
+
+       function buildDayTableHTML() {
+               var html =
+                       "<table style='width:100%' class='fc-agenda-days fc-border-separate' cellspacing='0'>" +
+                       buildDayTableHeadHTML() +
+                       buildDayTableBodyHTML() +
+                       "</table>";
+
+               return html;
+       }
+
+
+       function buildDayTableHeadHTML() {
+               var headerClass = tm + "-widget-header";
+               var date;
+               var html = '';
+               var weekText;
+               var col;
+
+               html +=
+                       "<thead>" +
+                       "<tr>";
+
+               if (showWeekNumbers) {
+                       date = cellToDate(0, 0);
+                       weekText = formatDate(date, weekNumberFormat);
+                       if (rtl) {
+                               weekText += weekNumberTitle;
+                       }
+                       else {
+                               weekText = weekNumberTitle + weekText;
+                       }
+                       html +=
+                               "<th class='fc-agenda-axis fc-week-number " + headerClass + "'>" +
+                               htmlEscape(weekText) +
+                               "</th>";
+               }
+               else {
+                       html += "<th class='fc-agenda-axis " + headerClass + "'>&nbsp;</th>";
+               }
+
+               for (col=0; col<colCnt; col++) {
+                       date = cellToDate(0, col);
+                       html +=
+                               "<th class='fc-" + dayIDs[date.getDay()] + " fc-col" + col + ' ' + headerClass + "'>" +
+                               htmlEscape(formatDate(date, colFormat)) +
+                               "</th>";
+               }
+
+               html +=
+                       "<th class='fc-agenda-gutter " + headerClass + "'>&nbsp;</th>" +
+                       "</tr>" +
+                       "</thead>";
+
+               return html;
+       }
+
+
+       function buildDayTableBodyHTML() {
+               var headerClass = tm + "-widget-header"; // TODO: make these when updateOptions() called
+               var contentClass = tm + "-widget-content";
                var date;
                var today = clearTime(new Date());
-               for (i=0; i<colCnt; i++) {
-                       date = colDate(i);
-                       headCell = dayHeadCells.eq(i);
-                       headCell.html(formatDate(date, colFormat));
-                       bodyCell = dayBodyCells.eq(i);
+               var col;
+               var cellsHTML;
+               var cellHTML;
+               var classNames;
+               var html = '';
+
+               html +=
+                       "<tbody>" +
+                       "<tr>" +
+                       "<th class='fc-agenda-axis " + headerClass + "'>&nbsp;</th>";
+
+               cellsHTML = '';
+
+               for (col=0; col<colCnt; col++) {
+
+                       date = cellToDate(0, col);
+
+                       classNames = [
+                               'fc-col' + col,
+                               'fc-' + dayIDs[date.getDay()],
+                               contentClass
+                       ];
                        if (+date == +today) {
-                               bodyCell.addClass(tm + '-state-highlight fc-today');
-                       }else{
-                               bodyCell.removeClass(tm + '-state-highlight fc-today');
+                               classNames.push(
+                                       tm + '-state-highlight',
+                                       'fc-today'
+                               );
+                       }
+                       else if (date < today) {
+                               classNames.push('fc-past');
+                       }
+                       else {
+                               classNames.push('fc-future');
                        }
-                       setDayID(headCell.add(bodyCell), date);
+
+                       cellHTML =
+                               "<td class='" + classNames.join(' ') + "'>" +
+                               "<div>" +
+                               "<div class='fc-day-content'>" +
+                               "<div style='position:relative'>&nbsp;</div>" +
+                               "</div>" +
+                               "</div>" +
+                               "</td>";
+
+                       cellsHTML += cellHTML;
                }
+
+               html += cellsHTML;
+               html +=
+                       "<td class='fc-agenda-gutter " + contentClass + "'>&nbsp;</td>" +
+                       "</tr>" +
+                       "</tbody>";
+
+               return html;
        }
+
+
+       // TODO: data-date on the cells
+
        
        
+       /* Dimensions
+       -----------------------------------------------------------------------*/
+
        
-       function setHeight(height, dateChanged) {
+       function setHeight(height) {
                if (height === undefined) {
                        height = viewHeight;
                }
@@ -3140,7 +3189,7 @@ function AgendaView(element, calendar, viewName) {
                        height - headHeight,   // when scrollbars
                        slotTable.height() + allDayHeight + 1 // when no scrollbars. +1 for bottom border
                );
-               
+
                dayBodyFirstCellStretcher
                        .height(bodyHeight - vsides(dayBodyFirstCell));
                
@@ -3148,18 +3197,25 @@ function AgendaView(element, calendar, viewName) {
                
                slotScroller.height(bodyHeight - allDayHeight - 1);
                
-               slotHeight = slotTableFirstInner.height() + 1; // +1 for border
-               
-               if (dateChanged) {
-                       resetScroll();
-               }
+               // the stylesheet guarantees that the first row has no border.
+               // this allows .height() to work well cross-browser.
+               slotHeight = slotTable.find('tr:first').height() + 1; // +1 for bottom border
+
+               snapRatio = opt('slotMinutes') / snapMinutes;
+               snapHeight = slotHeight / snapRatio;
        }
        
        
-       
        function setWidth(width) {
                viewWidth = width;
+               colPositions.clear();
                colContentPositions.clear();
+
+               var axisFirstCells = dayHead.find('th:first');
+               if (allDayTable) {
+                       axisFirstCells = axisFirstCells.add(allDayTable.find('th:first'));
+               }
+               axisFirstCells = axisFirstCells.add(slotTable.find('th:first'));
                
                axisWidth = 0;
                setOuterWidth(
@@ -3171,8 +3227,12 @@ function AgendaView(element, calendar, viewName) {
                        axisWidth
                );
                
-               var slotTableWidth = slotScroller[0].clientWidth; // needs to be done after axisWidth (for IE7)
-               //slotTable.width(slotTableWidth);
+               var gutterCells = dayTable.find('.fc-agenda-gutter');
+               if (allDayTable) {
+                       gutterCells = gutterCells.add(allDayTable.find('th.fc-agenda-gutter'));
+               }
+
+               var slotTableWidth = slotScroller[0].clientWidth; // needs to be done after axisWidth (for IE7)
                
                gutterWidth = slotScroller.width() - slotTableWidth;
                if (gutterWidth) {
@@ -3194,6 +3254,10 @@ function AgendaView(element, calendar, viewName) {
        
 
 
+       /* Scrolling
+       -----------------------------------------------------------------------*/
+
+
        function resetScroll() {
                var d0 = zeroDate();
                var scrollDate = cloneDate(d0);
@@ -3205,15 +3269,10 @@ function AgendaView(element, calendar, viewName) {
                scroll();
                setTimeout(scroll, 0); // overrides any previous scroll state made by the browser
        }
-       
-       
-       function beforeHide() {
-               savedScrollTop = slotScroller.scrollTop();
-       }
-       
-       
-       function afterShow() {
-               slotScroller.scrollTop(savedScrollTop);
+
+
+       function afterRender() { // after the view has been freshly rendered and sized
+               resetScroll();
        }
        
        
@@ -3237,7 +3296,7 @@ function AgendaView(element, calendar, viewName) {
        function slotClick(ev) {
                if (!opt('selectable')) { // if selectable, SelectionManager will worry about dayClick
                        var col = Math.min(colCnt-1, Math.floor((ev.pageX - dayTable.offset().left - axisWidth) / colWidth));
-                       var date = colDate(col);
+                       var date = cellToDate(0, col);
                        var rowMatch = this.parentNode.className.match(/fc-slot(\d+)/); // TODO: maybe use data
                        if (rowMatch) {
                                var mins = parseInt(rowMatch[1]) * opt('slotMinutes');
@@ -3255,26 +3314,26 @@ function AgendaView(element, calendar, viewName) {
        
        /* Semi-transparent Overlay Helpers
        -----------------------------------------------------*/
-       
+       // TODO: should be consolidated with BasicView's methods
+
+
+       function renderDayOverlay(overlayStart, overlayEnd, refreshCoordinateGrid) { // overlayEnd is exclusive
 
-       function renderDayOverlay(startDate, endDate, refreshCoordinateGrid) { // endDate is exclusive
                if (refreshCoordinateGrid) {
                        coordinateGrid.build();
                }
-               var visStart = cloneDate(t.visStart);
-               var startCol, endCol;
-               if (rtl) {
-                       startCol = dayDiff(endDate, visStart)*dis+dit+1;
-                       endCol = dayDiff(startDate, visStart)*dis+dit+1;
-               }else{
-                       startCol = dayDiff(startDate, visStart);
-                       endCol = dayDiff(endDate, visStart);
-               }
-               startCol = Math.max(0, startCol);
-               endCol = Math.min(colCnt, endCol);
-               if (startCol < endCol) {
+
+               var segments = rangeToSegments(overlayStart, overlayEnd);
+
+               for (var i=0; i<segments.length; i++) {
+                       var segment = segments[i];
                        dayBind(
-                               renderCellOverlay(0, startCol, 0, endCol-1)
+                               renderCellOverlay(
+                                       segment.row,
+                                       segment.leftCol,
+                                       segment.row,
+                                       segment.rightCol
+                               )
                        );
                }
        }
@@ -3287,24 +3346,21 @@ function AgendaView(element, calendar, viewName) {
        
 
        function renderSlotOverlay(overlayStart, overlayEnd) {
-               var dayStart = cloneDate(t.visStart);
-               var dayEnd = addDays(cloneDate(dayStart), 1);
                for (var i=0; i<colCnt; i++) {
+                       var dayStart = cellToDate(0, i);
+                       var dayEnd = addDays(cloneDate(dayStart), 1);
                        var stretchStart = new Date(Math.max(dayStart, overlayStart));
                        var stretchEnd = new Date(Math.min(dayEnd, overlayEnd));
                        if (stretchStart < stretchEnd) {
-                               var col = i*dis+dit;
-                               var rect = coordinateGrid.rect(0, col, 0, col, slotContent); // only use it for horizontal coords
+                               var rect = coordinateGrid.rect(0, i, 0, i, slotContainer); // only use it for horizontal coords
                                var top = timePosition(dayStart, stretchStart);
                                var bottom = timePosition(dayStart, stretchEnd);
                                rect.top = top;
                                rect.height = bottom - top;
                                slotBind(
-                                       renderOverlay(rect, slotContent)
+                                       renderOverlay(rect, slotContainer)
                                );
                        }
-                       addDays(dayStart, 1);
-                       addDays(dayEnd, 1);
                }
        }
        
@@ -3331,16 +3387,16 @@ function AgendaView(element, calendar, viewName) {
                        n = e.offset().top;
                        rows[0] = [n, n+e.outerHeight()];
                }
-               var slotTableTop = slotContent.offset().top;
+               var slotTableTop = slotContainer.offset().top;
                var slotScrollerTop = slotScroller.offset().top;
                var slotScrollerBottom = slotScrollerTop + slotScroller.outerHeight();
                function constrain(n) {
                        return Math.max(slotScrollerTop, Math.min(slotScrollerBottom, n));
                }
-               for (var i=0; i<slotCnt; i++) {
+               for (var i=0; i<slotCnt*snapRatio; i++) { // adapt slot count to increased/decreased selection slot count
                        rows.push([
-                               constrain(slotTableTop + slotHeight*i),
-                               constrain(slotTableTop + slotHeight*(i+1))
+                               constrain(slotTableTop + snapHeight*i),
+                               constrain(slotTableTop + snapHeight*(i+1))
                        ]);
                }
        });
@@ -3348,62 +3404,53 @@ function AgendaView(element, calendar, viewName) {
        
        hoverListener = new HoverListener(coordinateGrid);
        
+       colPositions = new HorizontalPositionCache(function(col) {
+               return dayBodyCellInners.eq(col);
+       });
        
        colContentPositions = new HorizontalPositionCache(function(col) {
-               return dayBodyCellInners.eq(col);
+               return dayBodyCellContentInners.eq(col);
        });
        
        
+       function colLeft(col) {
+               return colPositions.left(col);
+       }
+
+
        function colContentLeft(col) {
                return colContentPositions.left(col);
        }
+
+
+       function colRight(col) {
+               return colPositions.right(col);
+       }
        
        
        function colContentRight(col) {
                return colContentPositions.right(col);
        }
-       
-       
-       
-       
-       function dateCell(date) { // "cell" terminology is now confusing
-               return {
-                       row: Math.floor(dayDiff(date, t.visStart) / 7),
-                       col: dayOfWeekCol(date.getDay())
-               };
+
+
+       function getIsCellAllDay(cell) {
+               return opt('allDaySlot') && !cell.row;
        }
-       
-       
-       function cellDate(cell) {
-               var d = colDate(cell.col);
+
+
+       function realCellToDate(cell) { // ugh "real" ... but blame it on our abuse of the "cell" system
+               var d = cellToDate(0, cell.col);
                var slotIndex = cell.row;
                if (opt('allDaySlot')) {
                        slotIndex--;
                }
                if (slotIndex >= 0) {
-                       addMinutes(d, minMinute + slotIndex * opt('slotMinutes'));
+                       addMinutes(d, minMinute + slotIndex * snapMinutes);
                }
                return d;
        }
        
        
-       function colDate(col) { // returns dates with 00:00:00
-               return addDays(cloneDate(t.visStart), col*dis+dit);
-       }
-       
-       
-       function cellIsAllDay(cell) {
-               return opt('allDaySlot') && !cell.row;
-       }
-       
-       
-       function dayOfWeekCol(dayOfWeek) {
-               return ((dayOfWeek - Math.max(firstDay, nwe) + colCnt) % colCnt)*dis+dit;
-       }
-       
-       
-       
-       
        // get the Y coordinate of the given time on the given day (both Date objects)
        function timePosition(day, time) { // both date objects. day holds 00:00 of current day
                day = cloneDate(day, true);
@@ -3418,7 +3465,11 @@ function AgendaView(element, calendar, viewName) {
                        slotI = Math.floor(minutes / slotMinutes),
                        slotTop = slotTopCache[slotI];
                if (slotTop === undefined) {
-                       slotTop = slotTopCache[slotI] = slotTable.find('tr:eq(' + slotI + ') td div')[0].offsetTop; //.position().top; // need this optimization???
+                       slotTop = slotTopCache[slotI] =
+                               slotTable.find('tr').eq(slotI).find('td div')[0].offsetTop;
+                               // .eq() is faster than ":eq()" selector
+                               // [0].offsetTop is faster than .position().top (do we really need this optimization?)
+                               // a better optimization would be to cache all these divs
                }
                return Math.max(0, Math.round(
                        slotTop - 1 + slotHeight * ((minutes % slotMinutes) / slotMinutes)
@@ -3426,14 +3477,6 @@ function AgendaView(element, calendar, viewName) {
        }
        
        
-       function allDayBounds() {
-               return {
-                       left: axisWidth,
-                       right: viewWidth - gutterWidth
-               }
-       }
-       
-       
        function getAllDayRow(index) {
                return allDayRow;
        }
@@ -3476,9 +3519,9 @@ function AgendaView(element, calendar, viewName) {
                var helperOption = opt('selectHelper');
                coordinateGrid.build();
                if (helperOption) {
-                       var col = dayDiff(startDate, t.visStart) * dis + dit;
+                       var col = dateToCell(startDate).col;
                        if (col >= 0 && col < colCnt) { // only works when times are on same day
-                               var rect = coordinateGrid.rect(0, col, 0, col, slotContent); // only for horizontal coords
+                               var rect = coordinateGrid.rect(0, col, 0, col, slotContainer); // only for horizontal coords
                                var top = timePosition(startDate, startDate);
                                var bottom = timePosition(startDate, endDate);
                                if (bottom > top) { // protect against selections that are entirely before or after visible range
@@ -3490,10 +3533,9 @@ function AgendaView(element, calendar, viewName) {
                                                var helperRes = helperOption(startDate, endDate);
                                                if (helperRes) {
                                                        rect.position = 'absolute';
-                                                       rect.zIndex = 8;
                                                        selectionHelper = $(helperRes)
                                                                .css(rect)
-                                                               .appendTo(slotContent);
+                                                               .appendTo(slotContainer);
                                                }
                                        }else{
                                                rect.isStart = true; // conside rect a "seg" now
@@ -3512,7 +3554,7 @@ function AgendaView(element, calendar, viewName) {
                                        }
                                        if (selectionHelper) {
                                                slotBind(selectionHelper);
-                                               slotContent.append(selectionHelper);
+                                               slotContainer.append(selectionHelper);
                                                setOuterWidth(selectionHelper, rect.width, true); // needs to be after appended
                                                setOuterHeight(selectionHelper, rect.height, true);
                                        }
@@ -3539,15 +3581,15 @@ function AgendaView(element, calendar, viewName) {
                        var dates;
                        hoverListener.start(function(cell, origCell) {
                                clearSelection();
-                               if (cell && cell.col == origCell.col && !cellIsAllDay(cell)) {
-                                       var d1 = cellDate(origCell);
-                                       var d2 = cellDate(cell);
+                               if (cell && cell.col == origCell.col && !getIsCellAllDay(cell)) {
+                                       var d1 = realCellToDate(origCell);
+                                       var d2 = realCellToDate(cell);
                                        dates = [
                                                d1,
-                                               addMinutes(cloneDate(d1), opt('slotMinutes')),
+                                               addMinutes(cloneDate(d1), snapMinutes), // calculate minutes depending on selection slot minutes 
                                                d2,
-                                               addMinutes(cloneDate(d2), opt('slotMinutes'))
-                                       ].sort(cmp);
+                                               addMinutes(cloneDate(d2), snapMinutes)
+                                       ].sort(dateCompare);
                                        renderSlotSelection(dates[0], dates[3]);
                                }else{
                                        dates = null;
@@ -3564,10 +3606,10 @@ function AgendaView(element, calendar, viewName) {
                        });
                }
        }
-       
-       
+
+
        function reportDayClick(date, allDay, ev) {
-               trigger('dayClick', dayBodyCells[dayOfWeekCol(date.getDay())], date, allDay, ev);
+               trigger('dayClick', dayBodyCells[dateToCell(date).col], date, allDay, ev);
        }
        
        
@@ -3580,10 +3622,10 @@ function AgendaView(element, calendar, viewName) {
                hoverListener.start(function(cell) {
                        clearOverlays();
                        if (cell) {
-                               if (cellIsAllDay(cell)) {
+                               if (getIsCellAllDay(cell)) {
                                        renderCellOverlay(cell.row, cell.col, cell.row, cell.col);
                                }else{
-                                       var d1 = cellDate(cell);
+                                       var d1 = realCellToDate(cell);
                                        var d2 = addMinutes(cloneDate(d1), opt('defaultEventMinutes'));
                                        renderSlotOverlay(d1, d2);
                                }
@@ -3596,35 +3638,32 @@ function AgendaView(element, calendar, viewName) {
                var cell = hoverListener.stop();
                clearOverlays();
                if (cell) {
-                       trigger('drop', _dragElement, cellDate(cell), cellIsAllDay(cell), ev, ui);
+                       trigger('drop', _dragElement, realCellToDate(cell), getIsCellAllDay(cell), ev, ui);
                }
        }
-
+       
 
 }
 
+;;
+
 function AgendaEventRenderer() {
        var t = this;
        
        
        // exports
        t.renderEvents = renderEvents;
-       t.compileDaySegs = compileDaySegs; // for DayEventRenderer
        t.clearEvents = clearEvents;
        t.slotSegHtml = slotSegHtml;
-       t.bindDaySeg = bindDaySeg;
        
        
        // imports
        DayEventRenderer.call(t);
        var opt = t.opt;
        var trigger = t.trigger;
-       //var setOverflowHidden = t.setOverflowHidden;
        var isEventDraggable = t.isEventDraggable;
        var isEventResizable = t.isEventResizable;
        var eventEnd = t.eventEnd;
-       var reportEvents = t.reportEvents;
-       var reportEventClear = t.reportEventClear;
        var eventElementHandlers = t.eventElementHandlers;
        var setHeight = t.setHeight;
        var getDaySegmentContainer = t.getDaySegmentContainer;
@@ -3633,14 +3672,15 @@ function AgendaEventRenderer() {
        var getMaxMinute = t.getMaxMinute;
        var getMinMinute = t.getMinMinute;
        var timePosition = t.timePosition;
+       var getIsCellAllDay = t.getIsCellAllDay;
        var colContentLeft = t.colContentLeft;
        var colContentRight = t.colContentRight;
-       var renderDaySegs = t.renderDaySegs;
-       var resizableDayEvent = t.resizableDayEvent; // TODO: streamline binding architecture
+       var cellToDate = t.cellToDate;
        var getColCnt = t.getColCnt;
        var getColWidth = t.getColWidth;
-       var getSlotHeight = t.getSlotHeight;
-       var getBodyContent = t.getBodyContent;
+       var getSnapHeight = t.getSnapHeight;
+       var getSnapMinutes = t.getSnapMinutes;
+       var getSlotContainer = t.getSlotContainer;
        var reportEventElement = t.reportEventElement;
        var showEvents = t.showEvents;
        var hideEvents = t.hideEvents;
@@ -3648,10 +3688,15 @@ function AgendaEventRenderer() {
        var eventResize = t.eventResize;
        var renderDayOverlay = t.renderDayOverlay;
        var clearOverlays = t.clearOverlays;
+       var renderDayEvents = t.renderDayEvents;
        var calendar = t.calendar;
        var formatDate = calendar.formatDate;
        var formatDates = calendar.formatDates;
-       
+
+
+       // overrides
+       t.draggableDayEvent = draggableDayEvent;
+
        
        
        /* Rendering
@@ -3659,7 +3704,6 @@ function AgendaEventRenderer() {
        
 
        function renderEvents(events, modifiedEventId) {
-               reportEvents(events);
                var i, len=events.length,
                        dayEvents=[],
                        slotEvents=[];
@@ -3670,67 +3714,96 @@ function AgendaEventRenderer() {
                                slotEvents.push(events[i]);
                        }
                }
+
                if (opt('allDaySlot')) {
-                       renderDaySegs(compileDaySegs(dayEvents), modifiedEventId);
+                       renderDayEvents(dayEvents, modifiedEventId);
                        setHeight(); // no params means set to viewHeight
                }
+
                renderSlotSegs(compileSlotSegs(slotEvents), modifiedEventId);
        }
        
        
        function clearEvents() {
-               reportEventClear();
                getDaySegmentContainer().empty();
                getSlotSegmentContainer().empty();
        }
-       
-       
-       function compileDaySegs(events) {
-               var levels = stackSegs(sliceSegs(events, $.map(events, exclEndDay), t.visStart, t.visEnd)),
-                       i, levelCnt=levels.length, level,
-                       j, seg,
-                       segs=[];
-               for (i=0; i<levelCnt; i++) {
-                       level = levels[i];
-                       for (j=0; j<level.length; j++) {
-                               seg = level[j];
-                               seg.row = 0;
-                               seg.level = i; // not needed anymore
-                               segs.push(seg);
-                       }
-               }
-               return segs;
-       }
-       
+
        
        function compileSlotSegs(events) {
                var colCnt = getColCnt(),
                        minMinute = getMinMinute(),
                        maxMinute = getMaxMinute(),
-                       d = addMinutes(cloneDate(t.visStart), minMinute),
+                       d,
                        visEventEnds = $.map(events, slotEventEnd),
-                       i, col,
-                       j, level,
-                       k, seg,
-                       segs=[];
+                       i,
+                       j, seg,
+                       colSegs,
+                       segs = [];
+
                for (i=0; i<colCnt; i++) {
-                       col = stackSegs(sliceSegs(events, visEventEnds, d, addMinutes(cloneDate(d), maxMinute-minMinute)));
-                       countForwardSegs(col);
-                       for (j=0; j<col.length; j++) {
-                               level = col[j];
-                               for (k=0; k<level.length; k++) {
-                                       seg = level[k];
-                                       seg.col = i;
-                                       seg.level = j;
-                                       segs.push(seg);
-                               }
+
+                       d = cellToDate(0, i);
+                       addMinutes(d, minMinute);
+
+                       colSegs = sliceSegs(
+                               events,
+                               visEventEnds,
+                               d,
+                               addMinutes(cloneDate(d), maxMinute-minMinute)
+                       );
+
+                       colSegs = placeSlotSegs(colSegs); // returns a new order
+
+                       for (j=0; j<colSegs.length; j++) {
+                               seg = colSegs[j];
+                               seg.col = i;
+                               segs.push(seg);
                        }
-                       addDays(d, 1, true);
                }
+
                return segs;
        }
-       
-       
+
+
+       function sliceSegs(events, visEventEnds, start, end) {
+               var segs = [],
+                       i, len=events.length, event,
+                       eventStart, eventEnd,
+                       segStart, segEnd,
+                       isStart, isEnd;
+               for (i=0; i<len; i++) {
+                       event = events[i];
+                       eventStart = event.start;
+                       eventEnd = visEventEnds[i];
+                       if (eventEnd > start && eventStart < end) {
+                               if (eventStart < start) {
+                                       segStart = cloneDate(start);
+                                       isStart = false;
+                               }else{
+                                       segStart = eventStart;
+                                       isStart = true;
+                               }
+                               if (eventEnd > end) {
+                                       segEnd = cloneDate(end);
+                                       isEnd = false;
+                               }else{
+                                       segEnd = eventEnd;
+                                       isEnd = true;
+                               }
+                               segs.push({
+                                       event: event,
+                                       start: segStart,
+                                       end: segEnd,
+                                       isStart: isStart,
+                                       isEnd: isEnd
+                               });
+                       }
+               }
+               return segs.sort(compareSlotSegs);
+       }
+
+
        function slotEventEnd(event) {
                if (event.end) {
                        return cloneDate(event.end);
@@ -3741,38 +3814,29 @@ function AgendaEventRenderer() {
        
        
        // renders events in the 'time slots' at the bottom
+       // TODO: when we refactor this, when user returns `false` eventRender, don't have empty space
+       // TODO: refactor will include using pixels to detect collisions instead of dates (handy for seg cmp)
        
        function renderSlotSegs(segs, modifiedEventId) {
        
                var i, segCnt=segs.length, seg,
                        event,
-                       classes,
-                       top, bottom,
-                       colI, levelI, forward,
-                       leftmost,
-                       availWidth,
-                       outerWidth,
+                       top,
+                       bottom,
+                       columnLeft,
+                       columnRight,
+                       columnWidth,
+                       width,
                        left,
-                       html='',
+                       right,
+                       html = '',
                        eventElements,
                        eventElement,
                        triggerRes,
-                       vsideCache={},
-                       hsideCache={},
-                       key, val,
-                       contentElement,
+                       titleElement,
                        height,
                        slotSegmentContainer = getSlotSegmentContainer(),
-                       rtl, dis, dit,
-                       colCnt = getColCnt();
-                       
-               if (rtl = opt('isRTL')) {
-                       dis = -1;
-                       dit = colCnt - 1;
-               }else{
-                       dis = 1;
-                       dit = 0;
-               }
+                       isRTL = opt('isRTL');
                        
                // calculate position/dimensions, create html
                for (i=0; i<segCnt; i++) {
@@ -3780,33 +3844,48 @@ function AgendaEventRenderer() {
                        event = seg.event;
                        top = timePosition(seg.start, seg.start);
                        bottom = timePosition(seg.start, seg.end);
-                       colI = seg.col;
-                       levelI = seg.level;
-                       forward = seg.forward || 0;
-                       leftmost = colContentLeft(colI*dis + dit);
-                       availWidth = colContentRight(colI*dis + dit) - leftmost;
-                       availWidth = Math.min(availWidth-6, availWidth*.95); // TODO: move this to CSS
-                       if (levelI) {
-                               // indented and thin
-                               outerWidth = availWidth / (levelI + forward + 1);
-                       }else{
-                               if (forward) {
-                                       // moderately wide, aligned left still
-                                       outerWidth = ((availWidth / (forward + 1)) - (12/2)) * 2; // 12 is the predicted width of resizer =
-                               }else{
-                                       // can be entire width, aligned left
-                                       outerWidth = availWidth;
-                               }
+                       columnLeft = colContentLeft(seg.col);
+                       columnRight = colContentRight(seg.col);
+                       columnWidth = columnRight - columnLeft;
+
+                       // shave off space on right near scrollbars (2.5%)
+                       // TODO: move this to CSS somehow
+                       columnRight -= columnWidth * .025;
+                       columnWidth = columnRight - columnLeft;
+
+                       width = columnWidth * (seg.forwardCoord - seg.backwardCoord);
+
+                       if (opt('slotEventOverlap')) {
+                               // double the width while making sure resize handle is visible
+                               // (assumed to be 20px wide)
+                               width = Math.max(
+                                       (width - (20/2)) * 2,
+                                       width // narrow columns will want to make the segment smaller than
+                                               // the natural width. don't allow it
+                               );
+                       }
+
+                       if (isRTL) {
+                               right = columnRight - seg.backwardCoord * columnWidth;
+                               left = right - width;
                        }
-                       left = leftmost +                                  // leftmost possible
-                               (availWidth / (levelI + forward + 1) * levelI) // indentation
-                               * dis + (rtl ? availWidth - outerWidth : 0);   // rtl
+                       else {
+                               left = columnLeft + seg.backwardCoord * columnWidth;
+                               right = left + width;
+                       }
+
+                       // make sure horizontal coordinates are in bounds
+                       left = Math.max(left, columnLeft);
+                       right = Math.min(right, columnRight);
+                       width = right - left;
+
                        seg.top = top;
                        seg.left = left;
-                       seg.outerWidth = outerWidth;
+                       seg.outerWidth = width;
                        seg.outerHeight = bottom - top;
                        html += slotSegHtml(event, seg);
                }
+
                slotSegmentContainer[0].innerHTML = html; // faster than html()
                eventElements = slotSegmentContainer.children();
                
@@ -3845,13 +3924,11 @@ function AgendaEventRenderer() {
                for (i=0; i<segCnt; i++) {
                        seg = segs[i];
                        if (eventElement = seg.element) {
-                               val = vsideCache[key = seg.key = cssKey(eventElement[0])];
-                               seg.vsides = val === undefined ? (vsideCache[key] = vsides(eventElement, true)) : val;
-                               val = hsideCache[key];
-                               seg.hsides = val === undefined ? (hsideCache[key] = hsides(eventElement, true)) : val;
-                               contentElement = eventElement.find('div.fc-event-content');
-                               if (contentElement.length) {
-                                       seg.contentTop = contentElement[0].offsetTop;
+                               seg.vsides = vsides(eventElement, true);
+                               seg.hsides = hsides(eventElement, true);
+                               titleElement = eventElement.find('.fc-event-title');
+                               if (titleElement.length) {
+                                       seg.contentTop = titleElement[0].offsetTop;
                                }
                        }
                }
@@ -3865,7 +3942,7 @@ function AgendaEventRenderer() {
                                eventElement[0].style.height = height + 'px';
                                event = seg.event;
                                if (seg.contentTop !== undefined && height - seg.contentTop < 10) {
-                                       // not enough room for title, put it in the time header
+                                       // not enough room for title, put it in the time (TODO: maybe make both display:inline instead)
                                        eventElement.find('div.fc-event-time')
                                                .text(formatDate(event.start, opt('timeFormat')) + ' - ' + event.title);
                                        eventElement.find('div.fc-event-title')
@@ -3882,16 +3959,15 @@ function AgendaEventRenderer() {
                var html = "<";
                var url = event.url;
                var skinCss = getSkinCss(event, opt);
-               var skinCssAttr = (skinCss ? " style='" + skinCss + "'" : '');
-               var classes = ['fc-event', 'fc-event-skin', 'fc-event-vert'];
+               var classes = ['fc-event', 'fc-event-vert'];
                if (isEventDraggable(event)) {
                        classes.push('fc-event-draggable');
                }
                if (seg.isStart) {
-                       classes.push('fc-corner-top');
+                       classes.push('fc-event-start');
                }
                if (seg.isEnd) {
-                       classes.push('fc-corner-bottom');
+                       classes.push('fc-event-end');
                }
                classes = classes.concat(event.className);
                if (event.source) {
@@ -3904,21 +3980,23 @@ function AgendaEventRenderer() {
                }
                html +=
                        " class='" + classes.join(' ') + "'" +
-                       " style='position:absolute;z-index:8;top:" + seg.top + "px;left:" + seg.left + "px;" + skinCss + "'" +
+                       " style=" +
+                               "'" +
+                               "position:absolute;" +
+                               "top:" + seg.top + "px;" +
+                               "left:" + seg.left + "px;" +
+                               skinCss +
+                               "'" +
                        ">" +
-                       "<div class='fc-event-inner fc-event-skin'" + skinCssAttr + ">" +
-                       "<div class='fc-event-head fc-event-skin'" + skinCssAttr + ">" +
+                       "<div class='fc-event-inner'>" +
                        "<div class='fc-event-time'>" +
                        htmlEscape(formatDates(event.start, event.end, opt('timeFormat'))) +
                        "</div>" +
-                       "</div>" +
-                       "<div class='fc-event-content'>" +
                        "<div class='fc-event-title'>" +
-                       htmlEscape(event.title) +
+                       htmlEscape(event.title || '') +
                        "</div>" +
                        "</div>" +
-                       "<div class='fc-event-bg'></div>" +
-                       "</div>"; // close inner
+                       "<div class='fc-event-bg'></div>";
                if (seg.isEnd && isEventResizable(event)) {
                        html +=
                                "<div class='ui-resizable-handle ui-resizable-s'>=</div>";
@@ -3929,18 +4007,6 @@ function AgendaEventRenderer() {
        }
        
        
-       function bindDaySeg(event, eventElement, seg) {
-               if (isEventDraggable(event)) {
-                       draggableDayEvent(event, eventElement, seg.isStart);
-               }
-               if (seg.isEnd && isEventResizable(event)) {
-                       resizableDayEvent(event, eventElement, seg);
-               }
-               eventElementHandlers(event, eventElement);
-                       // needs to be after, because resizableDayEvent might stopImmediatePropagation on click
-       }
-       
-       
        function bindSlotSeg(event, eventElement, seg) {
                var timeElement = eventElement.find('div.fc-event-time');
                if (isEventDraggable(event)) {
@@ -3959,31 +4025,34 @@ function AgendaEventRenderer() {
        
        
        // when event starts out FULL-DAY
+       // overrides DayEventRenderer's version because it needs to account for dragging elements
+       // to and from the slot area.
        
-       function draggableDayEvent(event, eventElement, isStart) {
+       function draggableDayEvent(event, eventElement, seg) {
+               var isStart = seg.isStart;
                var origWidth;
                var revert;
-               var allDay=true;
+               var allDay = true;
                var dayDelta;
-               var dis = opt('isRTL') ? -1 : 1;
                var hoverListener = getHoverListener();
                var colWidth = getColWidth();
-               var slotHeight = getSlotHeight();
+               var snapHeight = getSnapHeight();
+               var snapMinutes = getSnapMinutes();
                var minMinute = getMinMinute();
                eventElement.draggable({
-                       zIndex: 9,
                        opacity: opt('dragOpacity', 'month'), // use whatever the month view was using
                        revertDuration: opt('dragRevertDuration'),
                        start: function(ev, ui) {
                                trigger('eventDragStart', eventElement, event, ev, ui);
                                hideEvents(event, eventElement);
                                origWidth = eventElement.width();
-                               hoverListener.start(function(cell, origCell, rowDelta, colDelta) {
+                               hoverListener.start(function(cell, origCell) {
                                        clearOverlays();
                                        if (cell) {
-                                               //setOverflowHidden(true);
                                                revert = false;
-                                               dayDelta = colDelta * dis;
+                                               var origDate = cellToDate(0, origCell.col);
+                                               var date = cellToDate(0, cell.col);
+                                               dayDelta = dayDiff(date, origDate);
                                                if (!cell.row) {
                                                        // on full-days
                                                        renderDayOverlay(
@@ -3999,9 +4068,9 @@ function AgendaEventRenderer() {
                                                                        eventElement.width(colWidth - 10); // don't use entire width
                                                                        setOuterHeight(
                                                                                eventElement,
-                                                                               slotHeight * Math.round(
-                                                                                       (event.end ? ((event.end - event.start) / MINUTE_MS) : opt('defaultEventMinutes'))
-                                                                                       / opt('slotMinutes')
+                                                                               snapHeight * Math.round(
+                                                                                       (event.end ? ((event.end - event.start) / MINUTE_MS) : opt('defaultEventMinutes')) /
+                                                                                               snapMinutes
                                                                                )
                                                                        );
                                                                        eventElement.draggable('option', 'grid', [colWidth, 1]);
@@ -4014,7 +4083,6 @@ function AgendaEventRenderer() {
                                                revert = revert || (allDay && !dayDelta);
                                        }else{
                                                resetElement();
-                                               //setOverflowHidden(false);
                                                revert = true;
                                        }
                                        eventElement.draggable('option', 'revert', revert);
@@ -4033,14 +4101,13 @@ function AgendaEventRenderer() {
                                        // changed!
                                        var minuteDelta = 0;
                                        if (!allDay) {
-                                               minuteDelta = Math.round((eventElement.offset().top - getBodyContent().offset().top) / slotHeight)
-                                                       * opt('slotMinutes')
+                                               minuteDelta = Math.round((eventElement.offset().top - getSlotContainer().offset().top) / snapHeight)
+                                                       * snapMinutes
                                                        + minMinute
                                                        - (event.start.getHours() * 60 + event.start.getMinutes());
                                        }
                                        eventDrop(this, event, dayDelta, minuteDelta, allDay, ev, ui);
                                }
-                               //setOverflowHidden(false);
                        }
                });
                function resetElement() {
@@ -4058,78 +4125,147 @@ function AgendaEventRenderer() {
        // when event starts out IN TIMESLOTS
        
        function draggableSlotEvent(event, eventElement, timeElement) {
-               var origPosition;
-               var allDay=false;
-               var dayDelta;
-               var minuteDelta;
-               var prevMinuteDelta;
-               var dis = opt('isRTL') ? -1 : 1;
-               var hoverListener = getHoverListener();
+               var coordinateGrid = t.getCoordinateGrid();
                var colCnt = getColCnt();
                var colWidth = getColWidth();
-               var slotHeight = getSlotHeight();
+               var snapHeight = getSnapHeight();
+               var snapMinutes = getSnapMinutes();
+
+               // states
+               var origPosition; // original position of the element, not the mouse
+               var origCell;
+               var isInBounds, prevIsInBounds;
+               var isAllDay, prevIsAllDay;
+               var colDelta, prevColDelta;
+               var dayDelta; // derived from colDelta
+               var minuteDelta, prevMinuteDelta;
+
                eventElement.draggable({
-                       zIndex: 9,
                        scroll: false,
-                       grid: [colWidth, slotHeight],
+                       grid: [ colWidth, snapHeight ],
                        axis: colCnt==1 ? 'y' : false,
                        opacity: opt('dragOpacity'),
                        revertDuration: opt('dragRevertDuration'),
                        start: function(ev, ui) {
+
                                trigger('eventDragStart', eventElement, event, ev, ui);
                                hideEvents(event, eventElement);
+
+                               coordinateGrid.build();
+
+                               // initialize states
                                origPosition = eventElement.position();
+                               origCell = coordinateGrid.cell(ev.pageX, ev.pageY);
+                               isInBounds = prevIsInBounds = true;
+                               isAllDay = prevIsAllDay = getIsCellAllDay(origCell);
+                               colDelta = prevColDelta = 0;
+                               dayDelta = 0;
                                minuteDelta = prevMinuteDelta = 0;
-                               hoverListener.start(function(cell, origCell, rowDelta, colDelta) {
-                                       eventElement.draggable('option', 'revert', !cell);
-                                       clearOverlays();
-                                       if (cell) {
-                                               dayDelta = colDelta * dis;
-                                               if (opt('allDaySlot') && !cell.row) {
-                                                       // over full days
-                                                       if (!allDay) {
-                                                               // convert to temporary all-day event
-                                                               allDay = true;
-                                                               timeElement.hide();
-                                                               eventElement.draggable('option', 'grid', null);
-                                                       }
-                                                       renderDayOverlay(
-                                                               addDays(cloneDate(event.start), dayDelta),
-                                                               addDays(exclEndDay(event), dayDelta)
-                                                       );
-                                               }else{
-                                                       // on slots
-                                                       resetElement();
-                                               }
-                                       }
-                               }, ev, 'drag');
+
                        },
                        drag: function(ev, ui) {
-                               minuteDelta = Math.round((ui.position.top - origPosition.top) / slotHeight) * opt('slotMinutes');
-                               if (minuteDelta != prevMinuteDelta) {
-                                       if (!allDay) {
-                                               updateTimeText(minuteDelta);
+
+                               // NOTE: this `cell` value is only useful for determining in-bounds and all-day.
+                               // Bad for anything else due to the discrepancy between the mouse position and the
+                               // element position while snapping. (problem revealed in PR #55)
+                               //
+                               // PS- the problem exists for draggableDayEvent() when dragging an all-day event to a slot event.
+                               // We should overhaul the dragging system and stop relying on jQuery UI.
+                               var cell = coordinateGrid.cell(ev.pageX, ev.pageY);
+
+                               // update states
+                               isInBounds = !!cell;
+                               if (isInBounds) {
+                                       isAllDay = getIsCellAllDay(cell);
+
+                                       // calculate column delta
+                                       colDelta = Math.round((ui.position.left - origPosition.left) / colWidth);
+                                       if (colDelta != prevColDelta) {
+                                               // calculate the day delta based off of the original clicked column and the column delta
+                                               var origDate = cellToDate(0, origCell.col);
+                                               var col = origCell.col + colDelta;
+                                               col = Math.max(0, col);
+                                               col = Math.min(colCnt-1, col);
+                                               var date = cellToDate(0, col);
+                                               dayDelta = dayDiff(date, origDate);
+                                       }
+
+                                       // calculate minute delta (only if over slots)
+                                       if (!isAllDay) {
+                                               minuteDelta = Math.round((ui.position.top - origPosition.top) / snapHeight) * snapMinutes;
                                        }
+                               }
+
+                               // any state changes?
+                               if (
+                                       isInBounds != prevIsInBounds ||
+                                       isAllDay != prevIsAllDay ||
+                                       colDelta != prevColDelta ||
+                                       minuteDelta != prevMinuteDelta
+                               ) {
+
+                                       updateUI();
+
+                                       // update previous states for next time
+                                       prevIsInBounds = isInBounds;
+                                       prevIsAllDay = isAllDay;
+                                       prevColDelta = colDelta;
                                        prevMinuteDelta = minuteDelta;
                                }
+
+                               // if out-of-bounds, revert when done, and vice versa.
+                               eventElement.draggable('option', 'revert', !isInBounds);
+
                        },
                        stop: function(ev, ui) {
-                               var cell = hoverListener.stop();
+
                                clearOverlays();
                                trigger('eventDragStop', eventElement, event, ev, ui);
-                               if (cell && (dayDelta || minuteDelta || allDay)) {
-                                       // changed!
-                                       eventDrop(this, event, dayDelta, allDay ? 0 : minuteDelta, allDay, ev, ui);
-                               }else{
-                                       // either no change or out-of-bounds (draggable has already reverted)
-                                       resetElement();
+
+                               if (isInBounds && (isAllDay || dayDelta || minuteDelta)) { // changed!
+                                       eventDrop(this, event, dayDelta, isAllDay ? 0 : minuteDelta, isAllDay, ev, ui);
+                               }
+                               else { // either no change or out-of-bounds (draggable has already reverted)
+
+                                       // reset states for next time, and for updateUI()
+                                       isInBounds = true;
+                                       isAllDay = false;
+                                       colDelta = 0;
+                                       dayDelta = 0;
+                                       minuteDelta = 0;
+
+                                       updateUI();
                                        eventElement.css('filter', ''); // clear IE opacity side-effects
-                                       eventElement.css(origPosition); // sometimes fast drags make event revert to wrong position
-                                       updateTimeText(0);
+
+                                       // sometimes fast drags make event revert to wrong position, so reset.
+                                       // also, if we dragged the element out of the area because of snapping,
+                                       // but the *mouse* is still in bounds, we need to reset the position.
+                                       eventElement.css(origPosition);
+
                                        showEvents(event, eventElement);
                                }
                        }
                });
+
+               function updateUI() {
+                       clearOverlays();
+                       if (isInBounds) {
+                               if (isAllDay) {
+                                       timeElement.hide();
+                                       eventElement.draggable('option', 'grid', null); // disable grid snapping
+                                       renderDayOverlay(
+                                               addDays(cloneDate(event.start), dayDelta),
+                                               addDays(exclEndDay(event), dayDelta)
+                                       );
+                               }
+                               else {
+                                       updateTimeText(minuteDelta);
+                                       timeElement.css('display', ''); // show() was causing display=inline
+                                       eventElement.draggable('option', 'grid', [colWidth, snapHeight]); // re-enable grid snapping
+                               }
+                       }
+               }
+
                function updateTimeText(minuteDelta) {
                        var newStart = addMinutes(cloneDate(event.start), minuteDelta);
                        var newEnd;
@@ -4138,14 +4274,7 @@ function AgendaEventRenderer() {
                        }
                        timeElement.text(formatDates(newStart, newEnd, opt('timeFormat')));
                }
-               function resetElement() {
-                       // convert back to original slot-event
-                       if (allDay) {
-                               timeElement.css('display', ''); // show() was causing display=inline
-                               eventElement.draggable('option', 'grid', [colWidth, slotHeight]);
-                               allDay = false;
-                       }
-               }
+
        }
        
        
@@ -4155,40 +4284,39 @@ function AgendaEventRenderer() {
        
        
        function resizableSlotEvent(event, eventElement, timeElement) {
-               var slotDelta, prevSlotDelta;
-               var slotHeight = getSlotHeight();
+               var snapDelta, prevSnapDelta;
+               var snapHeight = getSnapHeight();
+               var snapMinutes = getSnapMinutes();
                eventElement.resizable({
                        handles: {
-                               s: 'div.ui-resizable-s'
+                               s: '.ui-resizable-handle'
                        },
-                       grid: slotHeight,
+                       grid: snapHeight,
                        start: function(ev, ui) {
-                               slotDelta = prevSlotDelta = 0;
+                               snapDelta = prevSnapDelta = 0;
                                hideEvents(event, eventElement);
-                               eventElement.css('z-index', 9);
                                trigger('eventResizeStart', this, event, ev, ui);
                        },
                        resize: function(ev, ui) {
                                // don't rely on ui.size.height, doesn't take grid into account
-                               slotDelta = Math.round((Math.max(slotHeight, eventElement.height()) - ui.originalSize.height) / slotHeight);
-                               if (slotDelta != prevSlotDelta) {
+                               snapDelta = Math.round((Math.max(snapHeight, eventElement.height()) - ui.originalSize.height) / snapHeight);
+                               if (snapDelta != prevSnapDelta) {
                                        timeElement.text(
                                                formatDates(
                                                        event.start,
-                                                       (!slotDelta && !event.end) ? null : // no change, so don't display time range
-                                                               addMinutes(eventEnd(event), opt('slotMinutes')*slotDelta),
+                                                       (!snapDelta && !event.end) ? null : // no change, so don't display time range
+                                                               addMinutes(eventEnd(event), snapMinutes*snapDelta),
                                                        opt('timeFormat')
                                                )
                                        );
-                                       prevSlotDelta = slotDelta;
+                                       prevSnapDelta = snapDelta;
                                }
                        },
                        stop: function(ev, ui) {
                                trigger('eventResizeStop', this, event, ev, ui);
-                               if (slotDelta) {
-                                       eventResize(this, event, 0, opt('slotMinutes')*slotDelta, ev, ui);
+                               if (snapDelta) {
+                                       eventResize(this, event, 0, snapMinutes*snapDelta, ev, ui);
                                }else{
-                                       eventElement.css('z-index', 8);
                                        showEvents(event, eventElement);
                                        // BUG: if event was really short, need to put title back in span
                                }
@@ -4200,23 +4328,213 @@ function AgendaEventRenderer() {
 }
 
 
-function countForwardSegs(levels) {
-       var i, j, k, level, segForward, segBack;
-       for (i=levels.length-1; i>0; i--) {
+
+/* Agenda Event Segment Utilities
+-----------------------------------------------------------------------------*/
+
+
+// Sets the seg.backwardCoord and seg.forwardCoord on each segment and returns a new
+// list in the order they should be placed into the DOM (an implicit z-index).
+function placeSlotSegs(segs) {
+       var levels = buildSlotSegLevels(segs);
+       var level0 = levels[0];
+       var i;
+
+       computeForwardSlotSegs(levels);
+
+       if (level0) {
+
+               for (i=0; i<level0.length; i++) {
+                       computeSlotSegPressures(level0[i]);
+               }
+
+               for (i=0; i<level0.length; i++) {
+                       computeSlotSegCoords(level0[i], 0, 0);
+               }
+       }
+
+       return flattenSlotSegLevels(levels);
+}
+
+
+// Builds an array of segments "levels". The first level will be the leftmost tier of segments
+// if the calendar is left-to-right, or the rightmost if the calendar is right-to-left.
+function buildSlotSegLevels(segs) {
+       var levels = [];
+       var i, seg;
+       var j;
+
+       for (i=0; i<segs.length; i++) {
+               seg = segs[i];
+
+               // go through all the levels and stop on the first level where there are no collisions
+               for (j=0; j<levels.length; j++) {
+                       if (!computeSlotSegCollisions(seg, levels[j]).length) {
+                               break;
+                       }
+               }
+
+               (levels[j] || (levels[j] = [])).push(seg);
+       }
+
+       return levels;
+}
+
+
+// For every segment, figure out the other segments that are in subsequent
+// levels that also occupy the same vertical space. Accumulate in seg.forwardSegs
+function computeForwardSlotSegs(levels) {
+       var i, level;
+       var j, seg;
+       var k;
+
+       for (i=0; i<levels.length; i++) {
                level = levels[i];
+
                for (j=0; j<level.length; j++) {
-                       segForward = level[j];
-                       for (k=0; k<levels[i-1].length; k++) {
-                               segBack = levels[i-1][k];
-                               if (segsCollide(segForward, segBack)) {
-                                       segBack.forward = Math.max(segBack.forward||0, (segForward.forward||0)+1);
-                               }
+                       seg = level[j];
+
+                       seg.forwardSegs = [];
+                       for (k=i+1; k<levels.length; k++) {
+                               computeSlotSegCollisions(seg, levels[k], seg.forwardSegs);
                        }
                }
        }
 }
 
 
+// Figure out which path forward (via seg.forwardSegs) results in the longest path until
+// the furthest edge is reached. The number of segments in this path will be seg.forwardPressure
+function computeSlotSegPressures(seg) {
+       var forwardSegs = seg.forwardSegs;
+       var forwardPressure = 0;
+       var i, forwardSeg;
+
+       if (seg.forwardPressure === undefined) { // not already computed
+
+               for (i=0; i<forwardSegs.length; i++) {
+                       forwardSeg = forwardSegs[i];
+
+                       // figure out the child's maximum forward path
+                       computeSlotSegPressures(forwardSeg);
+
+                       // either use the existing maximum, or use the child's forward pressure
+                       // plus one (for the forwardSeg itself)
+                       forwardPressure = Math.max(
+                               forwardPressure,
+                               1 + forwardSeg.forwardPressure
+                       );
+               }
+
+               seg.forwardPressure = forwardPressure;
+       }
+}
+
+
+// Calculate seg.forwardCoord and seg.backwardCoord for the segment, where both values range
+// from 0 to 1. If the calendar is left-to-right, the seg.backwardCoord maps to "left" and
+// seg.forwardCoord maps to "right" (via percentage). Vice-versa if the calendar is right-to-left.
+//
+// The segment might be part of a "series", which means consecutive segments with the same pressure
+// who's width is unknown until an edge has been hit. `seriesBackwardPressure` is the number of
+// segments behind this one in the current series, and `seriesBackwardCoord` is the starting
+// coordinate of the first segment in the series.
+function computeSlotSegCoords(seg, seriesBackwardPressure, seriesBackwardCoord) {
+       var forwardSegs = seg.forwardSegs;
+       var i;
+
+       if (seg.forwardCoord === undefined) { // not already computed
+
+               if (!forwardSegs.length) {
+
+                       // if there are no forward segments, this segment should butt up against the edge
+                       seg.forwardCoord = 1;
+               }
+               else {
+
+                       // sort highest pressure first
+                       forwardSegs.sort(compareForwardSlotSegs);
+
+                       // this segment's forwardCoord will be calculated from the backwardCoord of the
+                       // highest-pressure forward segment.
+                       computeSlotSegCoords(forwardSegs[0], seriesBackwardPressure + 1, seriesBackwardCoord);
+                       seg.forwardCoord = forwardSegs[0].backwardCoord;
+               }
+
+               // calculate the backwardCoord from the forwardCoord. consider the series
+               seg.backwardCoord = seg.forwardCoord -
+                       (seg.forwardCoord - seriesBackwardCoord) / // available width for series
+                       (seriesBackwardPressure + 1); // # of segments in the series
+
+               // use this segment's coordinates to computed the coordinates of the less-pressurized
+               // forward segments
+               for (i=0; i<forwardSegs.length; i++) {
+                       computeSlotSegCoords(forwardSegs[i], 0, seg.forwardCoord);
+               }
+       }
+}
+
+
+// Outputs a flat array of segments, from lowest to highest level
+function flattenSlotSegLevels(levels) {
+       var segs = [];
+       var i, level;
+       var j;
+
+       for (i=0; i<levels.length; i++) {
+               level = levels[i];
+
+               for (j=0; j<level.length; j++) {
+                       segs.push(level[j]);
+               }
+       }
+
+       return segs;
+}
+
+
+// Find all the segments in `otherSegs` that vertically collide with `seg`.
+// Append into an optionally-supplied `results` array and return.
+function computeSlotSegCollisions(seg, otherSegs, results) {
+       results = results || [];
+
+       for (var i=0; i<otherSegs.length; i++) {
+               if (isSlotSegCollision(seg, otherSegs[i])) {
+                       results.push(otherSegs[i]);
+               }
+       }
+
+       return results;
+}
+
+
+// Do these segments occupy the same vertical space?
+function isSlotSegCollision(seg1, seg2) {
+       return seg1.end > seg2.start && seg1.start < seg2.end;
+}
+
+
+// A cmp function for determining which forward segment to rely on more when computing coordinates.
+function compareForwardSlotSegs(seg1, seg2) {
+       // put higher-pressure first
+       return seg2.forwardPressure - seg1.forwardPressure ||
+               // put segments that are closer to initial edge first (and favor ones with no coords yet)
+               (seg1.backwardCoord || 0) - (seg2.backwardCoord || 0) ||
+               // do normal sorting...
+               compareSlotSegs(seg1, seg2);
+}
+
+
+// A cmp function for determining which segment should be closer to the initial edge
+// (the left edge on a left-to-right calendar).
+function compareSlotSegs(seg1, seg2) {
+       return seg1.start - seg2.start || // earlier start time goes first
+               (seg2.end - seg2.start) - (seg1.end - seg1.start) || // tie? longer-duration goes first
+               (seg1.event.title || '').localeCompare(seg2.event.title); // tie? alphabetically by title
+}
+
+
+;;
 
 
 function View(element, calendar, viewName) {
@@ -4229,13 +4547,13 @@ function View(element, calendar, viewName) {
        t.name = viewName;
        t.opt = opt;
        t.trigger = trigger;
-       //t.setOverflowHidden = setOverflowHidden;
        t.isEventDraggable = isEventDraggable;
        t.isEventResizable = isEventResizable;
-       t.reportEvents = reportEvents;
+       t.setEventData = setEventData;
+       t.clearEventData = clearEventData;
        t.eventEnd = eventEnd;
        t.reportEventElement = reportEventElement;
-       t.reportEventClear = reportEventClear;
+       t.triggerEventDestroy = triggerEventDestroy;
        t.eventElementHandlers = eventElementHandlers;
        t.showEvents = showEvents;
        t.hideEvents = hideEvents;
@@ -4253,16 +4571,16 @@ function View(element, calendar, viewName) {
        
        
        // locals
-       var eventsByID = {};
-       var eventElements = [];
-       var eventElementsByID = {};
+       var eventsByID = {}; // eventID mapped to array of events (there can be multiple b/c of repeating events)
+       var eventElementsByID = {}; // eventID mapped to array of jQuery elements
+       var eventElementCouples = []; // array of objects, { event, element } // TODO: unify with segment system
        var options = calendar.options;
        
        
        
        function opt(name, viewNameOverride) {
                var v = options[name];
-               if (typeof v == 'object') {
+               if ($.isPlainObject(v)) {
                        return smartProperty(v, viewNameOverride || viewName);
                }
                return v;
@@ -4276,26 +4594,37 @@ function View(element, calendar, viewName) {
                );
        }
        
-       
-       /*
-       function setOverflowHidden(bool) {
-               element.css('overflow', bool ? 'hidden' : '');
-       }
-       */
-       
+
+
+       /* Event Editable Boolean Calculations
+       ------------------------------------------------------------------------------*/
+
        
        function isEventDraggable(event) {
-               return isEventEditable(event) && !opt('disableDragging');
+               var source = event.source || {};
+               return firstDefined(
+                               event.startEditable,
+                               source.startEditable,
+                               opt('eventStartEditable'),
+                               event.editable,
+                               source.editable,
+                               opt('editable')
+                       )
+                       && !opt('disableDragging'); // deprecated
        }
        
        
        function isEventResizable(event) { // but also need to make sure the seg.isEnd == true
-               return isEventEditable(event) && !opt('disableResizing');
-       }
-       
-       
-       function isEventEditable(event) {
-               return firstDefined(event.editable, (event.source || {}).editable, opt('editable'));
+               var source = event.source || {};
+               return firstDefined(
+                               event.durationEditable,
+                               source.durationEditable,
+                               opt('eventDurationEditable'),
+                               event.editable,
+                               source.editable,
+                               opt('editable')
+                       )
+                       && !opt('disableResizing'); // deprecated
        }
        
        
@@ -4304,8 +4633,7 @@ function View(element, calendar, viewName) {
        ------------------------------------------------------------------------------*/
        
        
-       // report when view receives new events
-       function reportEvents(events) { // events are already normalized at this point
+       function setEventData(events) { // events are already normalized at this point
                eventsByID = {};
                var i, len=events.length, event;
                for (i=0; i<len; i++) {
@@ -4317,6 +4645,13 @@ function View(element, calendar, viewName) {
                        }
                }
        }
+
+
+       function clearEventData() {
+               eventsByID = {};
+               eventElementsByID = {};
+               eventElementCouples = [];
+       }
        
        
        // returns a Date object for an event's end
@@ -4332,18 +4667,19 @@ function View(element, calendar, viewName) {
        
        // report when view creates an element for an event
        function reportEventElement(event, element) {
-               eventElements.push(element);
+               eventElementCouples.push({ event: event, element: element });
                if (eventElementsByID[event._id]) {
                        eventElementsByID[event._id].push(element);
                }else{
                        eventElementsByID[event._id] = [element];
                }
        }
-       
-       
-       function reportEventClear() {
-               eventElements = [];
-               eventElementsByID = {};
+
+
+       function triggerEventDestroy() {
+               $.each(eventElementCouples, function(i, couple) {
+                       t.trigger('eventDestroy', couple.event, couple.event, couple.element);
+               });
        }
        
        
@@ -4380,6 +4716,8 @@ function View(element, calendar, viewName) {
        
        
        function eachEventElement(event, exceptElement, funcName) {
+               // NOTE: there may be multiple events per ID (repeating events)
+               // and multiple segments per event
                var elements = eventElementsByID[event._id],
                        i, len = elements.length;
                for (i=0; i<len; i++) {
@@ -4468,17 +4806,286 @@ function View(element, calendar, viewName) {
                        normalizeEvent(e, options);
                }
        }
+
+
+
+       // ====================================================================================================
+       // Utilities for day "cells"
+       // ====================================================================================================
+       // The "basic" views are completely made up of day cells.
+       // The "agenda" views have day cells at the top "all day" slot.
+       // This was the obvious common place to put these utilities, but they should be abstracted out into
+       // a more meaningful class (like DayEventRenderer).
+       // ====================================================================================================
+
+
+       // For determining how a given "cell" translates into a "date":
+       //
+       // 1. Convert the "cell" (row and column) into a "cell offset" (the # of the cell, cronologically from the first).
+       //    Keep in mind that column indices are inverted with isRTL. This is taken into account.
+       //
+       // 2. Convert the "cell offset" to a "day offset" (the # of days since the first visible day in the view).
+       //
+       // 3. Convert the "day offset" into a "date" (a JavaScript Date object).
+       //
+       // The reverse transformation happens when transforming a date into a cell.
+
+
+       // exports
+       t.isHiddenDay = isHiddenDay;
+       t.skipHiddenDays = skipHiddenDays;
+       t.getCellsPerWeek = getCellsPerWeek;
+       t.dateToCell = dateToCell;
+       t.dateToDayOffset = dateToDayOffset;
+       t.dayOffsetToCellOffset = dayOffsetToCellOffset;
+       t.cellOffsetToCell = cellOffsetToCell;
+       t.cellToDate = cellToDate;
+       t.cellToCellOffset = cellToCellOffset;
+       t.cellOffsetToDayOffset = cellOffsetToDayOffset;
+       t.dayOffsetToDate = dayOffsetToDate;
+       t.rangeToSegments = rangeToSegments;
+
+
+       // internals
+       var hiddenDays = opt('hiddenDays') || []; // array of day-of-week indices that are hidden
+       var isHiddenDayHash = []; // is the day-of-week hidden? (hash with day-of-week-index -> bool)
+       var cellsPerWeek;
+       var dayToCellMap = []; // hash from dayIndex -> cellIndex, for one week
+       var cellToDayMap = []; // hash from cellIndex -> dayIndex, for one week
+       var isRTL = opt('isRTL');
+
+
+       // initialize important internal variables
+       (function() {
+
+               if (opt('weekends') === false) {
+                       hiddenDays.push(0, 6); // 0=sunday, 6=saturday
+               }
+
+               // Loop through a hypothetical week and determine which
+               // days-of-week are hidden. Record in both hashes (one is the reverse of the other).
+               for (var dayIndex=0, cellIndex=0; dayIndex<7; dayIndex++) {
+                       dayToCellMap[dayIndex] = cellIndex;
+                       isHiddenDayHash[dayIndex] = $.inArray(dayIndex, hiddenDays) != -1;
+                       if (!isHiddenDayHash[dayIndex]) {
+                               cellToDayMap[cellIndex] = dayIndex;
+                               cellIndex++;
+                       }
+               }
+
+               cellsPerWeek = cellIndex;
+               if (!cellsPerWeek) {
+                       throw 'invalid hiddenDays'; // all days were hidden? bad.
+               }
+
+       })();
+
+
+       // Is the current day hidden?
+       // `day` is a day-of-week index (0-6), or a Date object
+       function isHiddenDay(day) {
+               if (typeof day == 'object') {
+                       day = day.getDay();
+               }
+               return isHiddenDayHash[day];
+       }
+
+
+       function getCellsPerWeek() {
+               return cellsPerWeek;
+       }
+
+
+       // Keep incrementing the current day until it is no longer a hidden day.
+       // If the initial value of `date` is not a hidden day, don't do anything.
+       // Pass `isExclusive` as `true` if you are dealing with an end date.
+       // `inc` defaults to `1` (increment one day forward each time)
+       function skipHiddenDays(date, inc, isExclusive) {
+               inc = inc || 1;
+               while (
+                       isHiddenDayHash[ ( date.getDay() + (isExclusive ? inc : 0) + 7 ) % 7 ]
+               ) {
+                       addDays(date, inc);
+               }
+       }
+
+
+       //
+       // TRANSFORMATIONS: cell -> cell offset -> day offset -> date
+       //
+
+       // cell -> date (combines all transformations)
+       // Possible arguments:
+       // - row, col
+       // - { row:#, col: # }
+       function cellToDate() {
+               var cellOffset = cellToCellOffset.apply(null, arguments);
+               var dayOffset = cellOffsetToDayOffset(cellOffset);
+               var date = dayOffsetToDate(dayOffset);
+               return date;
+       }
+
+       // cell -> cell offset
+       // Possible arguments:
+       // - row, col
+       // - { row:#, col:# }
+       function cellToCellOffset(row, col) {
+               var colCnt = t.getColCnt();
+
+               // rtl variables. wish we could pre-populate these. but where?
+               var dis = isRTL ? -1 : 1;
+               var dit = isRTL ? colCnt - 1 : 0;
+
+               if (typeof row == 'object') {
+                       col = row.col;
+                       row = row.row;
+               }
+               var cellOffset = row * colCnt + (col * dis + dit); // column, adjusted for RTL (dis & dit)
+
+               return cellOffset;
+       }
+
+       // cell offset -> day offset
+       function cellOffsetToDayOffset(cellOffset) {
+               var day0 = t.visStart.getDay(); // first date's day of week
+               cellOffset += dayToCellMap[day0]; // normlize cellOffset to beginning-of-week
+               return Math.floor(cellOffset / cellsPerWeek) * 7 // # of days from full weeks
+                       + cellToDayMap[ // # of days from partial last week
+                               (cellOffset % cellsPerWeek + cellsPerWeek) % cellsPerWeek // crazy math to handle negative cellOffsets
+                       ]
+                       - day0; // adjustment for beginning-of-week normalization
+       }
+
+       // day offset -> date (JavaScript Date object)
+       function dayOffsetToDate(dayOffset) {
+               var date = cloneDate(t.visStart);
+               addDays(date, dayOffset);
+               return date;
+       }
+
+
+       //
+       // TRANSFORMATIONS: date -> day offset -> cell offset -> cell
+       //
+
+       // date -> cell (combines all transformations)
+       function dateToCell(date) {
+               var dayOffset = dateToDayOffset(date);
+               var cellOffset = dayOffsetToCellOffset(dayOffset);
+               var cell = cellOffsetToCell(cellOffset);
+               return cell;
+       }
+
+       // date -> day offset
+       function dateToDayOffset(date) {
+               return dayDiff(date, t.visStart);
+       }
+
+       // day offset -> cell offset
+       function dayOffsetToCellOffset(dayOffset) {
+               var day0 = t.visStart.getDay(); // first date's day of week
+               dayOffset += day0; // normalize dayOffset to beginning-of-week
+               return Math.floor(dayOffset / 7) * cellsPerWeek // # of cells from full weeks
+                       + dayToCellMap[ // # of cells from partial last week
+                               (dayOffset % 7 + 7) % 7 // crazy math to handle negative dayOffsets
+                       ]
+                       - dayToCellMap[day0]; // adjustment for beginning-of-week normalization
+       }
+
+       // cell offset -> cell (object with row & col keys)
+       function cellOffsetToCell(cellOffset) {
+               var colCnt = t.getColCnt();
+
+               // rtl variables. wish we could pre-populate these. but where?
+               var dis = isRTL ? -1 : 1;
+               var dit = isRTL ? colCnt - 1 : 0;
+
+               var row = Math.floor(cellOffset / colCnt);
+               var col = ((cellOffset % colCnt + colCnt) % colCnt) * dis + dit; // column, adjusted for RTL (dis & dit)
+               return {
+                       row: row,
+                       col: col
+               };
+       }
+
+
+       //
+       // Converts a date range into an array of segment objects.
+       // "Segments" are horizontal stretches of time, sliced up by row.
+       // A segment object has the following properties:
+       // - row
+       // - cols
+       // - isStart
+       // - isEnd
+       //
+       function rangeToSegments(startDate, endDate) {
+               var rowCnt = t.getRowCnt();
+               var colCnt = t.getColCnt();
+               var segments = []; // array of segments to return
+
+               // day offset for given date range
+               var rangeDayOffsetStart = dateToDayOffset(startDate);
+               var rangeDayOffsetEnd = dateToDayOffset(endDate); // exclusive
+
+               // first and last cell offset for the given date range
+               // "last" implies inclusivity
+               var rangeCellOffsetFirst = dayOffsetToCellOffset(rangeDayOffsetStart);
+               var rangeCellOffsetLast = dayOffsetToCellOffset(rangeDayOffsetEnd) - 1;
+
+               // loop through all the rows in the view
+               for (var row=0; row<rowCnt; row++) {
+
+                       // first and last cell offset for the row
+                       var rowCellOffsetFirst = row * colCnt;
+                       var rowCellOffsetLast = rowCellOffsetFirst + colCnt - 1;
+
+                       // get the segment's cell offsets by constraining the range's cell offsets to the bounds of the row
+                       var segmentCellOffsetFirst = Math.max(rangeCellOffsetFirst, rowCellOffsetFirst);
+                       var segmentCellOffsetLast = Math.min(rangeCellOffsetLast, rowCellOffsetLast);
+
+                       // make sure segment's offsets are valid and in view
+                       if (segmentCellOffsetFirst <= segmentCellOffsetLast) {
+
+                               // translate to cells
+                               var segmentCellFirst = cellOffsetToCell(segmentCellOffsetFirst);
+                               var segmentCellLast = cellOffsetToCell(segmentCellOffsetLast);
+
+                               // view might be RTL, so order by leftmost column
+                               var cols = [ segmentCellFirst.col, segmentCellLast.col ].sort();
+
+                               // Determine if segment's first/last cell is the beginning/end of the date range.
+                               // We need to compare "day offset" because "cell offsets" are often ambiguous and
+                               // can translate to multiple days, and an edge case reveals itself when we the
+                               // range's first cell is hidden (we don't want isStart to be true).
+                               var isStart = cellOffsetToDayOffset(segmentCellOffsetFirst) == rangeDayOffsetStart;
+                               var isEnd = cellOffsetToDayOffset(segmentCellOffsetLast) + 1 == rangeDayOffsetEnd; // +1 for comparing exclusively
+
+                               segments.push({
+                                       row: row,
+                                       leftCol: cols[0],
+                                       rightCol: cols[1],
+                                       isStart: isStart,
+                                       isEnd: isEnd
+                               });
+                       }
+               }
+
+               return segments;
+       }
        
 
 }
 
+;;
+
 function DayEventRenderer() {
        var t = this;
 
        
        // exports
-       t.renderDaySegs = renderDaySegs;
-       t.resizableDayEvent = resizableDayEvent;
+       t.renderDayEvents = renderDayEvents;
+       t.draggableDayEvent = draggableDayEvent; // made public so that subclasses can override
+       t.resizableDayEvent = resizableDayEvent; // "
        
        
        // imports
@@ -4488,378 +5095,601 @@ function DayEventRenderer() {
        var isEventResizable = t.isEventResizable;
        var eventEnd = t.eventEnd;
        var reportEventElement = t.reportEventElement;
+       var eventElementHandlers = t.eventElementHandlers;
        var showEvents = t.showEvents;
        var hideEvents = t.hideEvents;
+       var eventDrop = t.eventDrop;
        var eventResize = t.eventResize;
        var getRowCnt = t.getRowCnt;
        var getColCnt = t.getColCnt;
        var getColWidth = t.getColWidth;
-       var allDayRow = t.allDayRow;
-       var allDayBounds = t.allDayBounds;
+       var allDayRow = t.allDayRow; // TODO: rename
+       var colLeft = t.colLeft;
+       var colRight = t.colRight;
        var colContentLeft = t.colContentLeft;
        var colContentRight = t.colContentRight;
-       var dayOfWeekCol = t.dayOfWeekCol;
-       var dateCell = t.dateCell;
-       var compileDaySegs = t.compileDaySegs;
+       var dateToCell = t.dateToCell;
        var getDaySegmentContainer = t.getDaySegmentContainer;
-       var bindDaySeg = t.bindDaySeg; //TODO: streamline this
        var formatDates = t.calendar.formatDates;
        var renderDayOverlay = t.renderDayOverlay;
        var clearOverlays = t.clearOverlays;
        var clearSelection = t.clearSelection;
-       
-       
-       
-       /* Rendering
-       -----------------------------------------------------------------------------*/
-       
-       
-       function renderDaySegs(segs, modifiedEventId) {
-               var segmentContainer = getDaySegmentContainer();
-               var rowDivs;
-               var rowCnt = getRowCnt();
-               var colCnt = getColCnt();
-               var i = 0;
-               var rowI;
-               var levelI;
-               var colHeights;
-               var j;
-               var segCnt = segs.length;
-               var seg;
-               var top;
-               var k;
-               segmentContainer[0].innerHTML = daySegHTML(segs); // faster than .html()
-               daySegElementResolve(segs, segmentContainer.children());
-               daySegElementReport(segs);
-               daySegHandlers(segs, segmentContainer, modifiedEventId);
-               daySegCalcHSides(segs);
-               daySegSetWidths(segs);
-               daySegCalcHeights(segs);
-               rowDivs = getRowDivs();
-               // set row heights, calculate event tops (in relation to row top)
-               for (rowI=0; rowI<rowCnt; rowI++) {
-                       levelI = 0;
-                       colHeights = [];
-                       for (j=0; j<colCnt; j++) {
-                               colHeights[j] = 0;
-                       }
-                       while (i<segCnt && (seg = segs[i]).row == rowI) {
-                               // loop through segs in a row
-                               top = arrayMax(colHeights.slice(seg.startCol, seg.endCol));
-                               seg.top = top;
-                               top += seg.outerHeight;
-                               for (k=seg.startCol; k<seg.endCol; k++) {
-                                       colHeights[k] = top;
-                               }
-                               i++;
+       var getHoverListener = t.getHoverListener;
+       var rangeToSegments = t.rangeToSegments;
+       var cellToDate = t.cellToDate;
+       var cellToCellOffset = t.cellToCellOffset;
+       var cellOffsetToDayOffset = t.cellOffsetToDayOffset;
+       var dateToDayOffset = t.dateToDayOffset;
+       var dayOffsetToCellOffset = t.dayOffsetToCellOffset;
+
+
+       // Render `events` onto the calendar, attach mouse event handlers, and call the `eventAfterRender` callback for each.
+       // Mouse event will be lazily applied, except if the event has an ID of `modifiedEventId`.
+       // Can only be called when the event container is empty (because it wipes out all innerHTML).
+       function renderDayEvents(events, modifiedEventId) {
+
+               // do the actual rendering. Receive the intermediate "segment" data structures.
+               var segments = _renderDayEvents(
+                       events,
+                       false, // don't append event elements
+                       true // set the heights of the rows
+               );
+
+               // report the elements to the View, for general drag/resize utilities
+               segmentElementEach(segments, function(segment, element) {
+                       reportEventElement(segment.event, element);
+               });
+
+               // attach mouse handlers
+               attachHandlers(segments, modifiedEventId);
+
+               // call `eventAfterRender` callback for each event
+               segmentElementEach(segments, function(segment, element) {
+                       trigger('eventAfterRender', segment.event, segment.event, element);
+               });
+       }
+
+
+       // Render an event on the calendar, but don't report them anywhere, and don't attach mouse handlers.
+       // Append this event element to the event container, which might already be populated with events.
+       // If an event's segment will have row equal to `adjustRow`, then explicitly set its top coordinate to `adjustTop`.
+       // This hack is used to maintain continuity when user is manually resizing an event.
+       // Returns an array of DOM elements for the event.
+       function renderTempDayEvent(event, adjustRow, adjustTop) {
+
+               // actually render the event. `true` for appending element to container.
+               // Recieve the intermediate "segment" data structures.
+               var segments = _renderDayEvents(
+                       [ event ],
+                       true, // append event elements
+                       false // don't set the heights of the rows
+               );
+
+               var elements = [];
+
+               // Adjust certain elements' top coordinates
+               segmentElementEach(segments, function(segment, element) {
+                       if (segment.row === adjustRow) {
+                               element.css('top', adjustTop);
                        }
-                       rowDivs[rowI].height(arrayMax(colHeights));
-               }
-               daySegSetTops(segs, getRowTops(rowDivs));
+                       elements.push(element[0]); // accumulate DOM nodes
+               });
+
+               return elements;
        }
-       
-       
-       function renderTempDaySegs(segs, adjustRow, adjustTop) {
-               var tempContainer = $("<div/>");
+
+
+       // Render events onto the calendar. Only responsible for the VISUAL aspect.
+       // Not responsible for attaching handlers or calling callbacks.
+       // Set `doAppend` to `true` for rendering elements without clearing the existing container.
+       // Set `doRowHeights` to allow setting the height of each row, to compensate for vertical event overflow.
+       function _renderDayEvents(events, doAppend, doRowHeights) {
+
+               // where the DOM nodes will eventually end up
+               var finalContainer = getDaySegmentContainer();
+
+               // the container where the initial HTML will be rendered.
+               // If `doAppend`==true, uses a temporary container.
+               var renderContainer = doAppend ? $("<div/>") : finalContainer;
+
+               var segments = buildSegments(events);
+               var html;
                var elements;
-               var segmentContainer = getDaySegmentContainer();
-               var i;
-               var segCnt = segs.length;
-               var element;
-               tempContainer[0].innerHTML = daySegHTML(segs); // faster than .html()
-               elements = tempContainer.children();
-               segmentContainer.append(elements);
-               daySegElementResolve(segs, elements);
-               daySegCalcHSides(segs);
-               daySegSetWidths(segs);
-               daySegCalcHeights(segs);
-               daySegSetTops(segs, getRowTops(getRowDivs()));
-               elements = [];
-               for (i=0; i<segCnt; i++) {
-                       element = segs[i].element;
-                       if (element) {
-                               if (segs[i].row === adjustRow) {
-                                       element.css('top', adjustTop);
-                               }
-                               elements.push(element[0]);
-                       }
+
+               // calculate the desired `left` and `width` properties on each segment object
+               calculateHorizontals(segments);
+
+               // build the HTML string. relies on `left` property
+               html = buildHTML(segments);
+
+               // render the HTML. innerHTML is considerably faster than jQuery's .html()
+               renderContainer[0].innerHTML = html;
+
+               // retrieve the individual elements
+               elements = renderContainer.children();
+
+               // if we were appending, and thus using a temporary container,
+               // re-attach elements to the real container.
+               if (doAppend) {
+                       finalContainer.append(elements);
+               }
+
+               // assigns each element to `segment.event`, after filtering them through user callbacks
+               resolveElements(segments, elements);
+
+               // Calculate the left and right padding+margin for each element.
+               // We need this for setting each element's desired outer width, because of the W3C box model.
+               // It's important we do this in a separate pass from acually setting the width on the DOM elements
+               // because alternating reading/writing dimensions causes reflow for every iteration.
+               segmentElementEach(segments, function(segment, element) {
+                       segment.hsides = hsides(element, true); // include margins = `true`
+               });
+
+               // Set the width of each element
+               segmentElementEach(segments, function(segment, element) {
+                       element.width(
+                               Math.max(0, segment.outerWidth - segment.hsides)
+                       );
+               });
+
+               // Grab each element's outerHeight (setVerticals uses this).
+               // To get an accurate reading, it's important to have each element's width explicitly set already.
+               segmentElementEach(segments, function(segment, element) {
+                       segment.outerHeight = element.outerHeight(true); // include margins = `true`
+               });
+
+               // Set the top coordinate on each element (requires segment.outerHeight)
+               setVerticals(segments, doRowHeights);
+
+               return segments;
+       }
+
+
+       // Generate an array of "segments" for all events.
+       function buildSegments(events) {
+               var segments = [];
+               for (var i=0; i<events.length; i++) {
+                       var eventSegments = buildSegmentsForEvent(events[i]);
+                       segments.push.apply(segments, eventSegments); // append an array to an array
                }
-               return $(elements);
+               return segments;
        }
-       
-       
-       function daySegHTML(segs) { // also sets seg.left and seg.outerWidth
-               var rtl = opt('isRTL');
-               var i;
-               var segCnt=segs.length;
-               var seg;
-               var event;
-               var url;
-               var classes;
-               var bounds = allDayBounds();
-               var minLeft = bounds.left;
-               var maxLeft = bounds.right;
-               var leftCol;
-               var rightCol;
-               var left;
-               var right;
-               var skinCss;
+
+
+       // Generate an array of segments for a single event.
+       // A "segment" is the same data structure that View.rangeToSegments produces,
+       // with the addition of the `event` property being set to reference the original event.
+       function buildSegmentsForEvent(event) {
+               var startDate = event.start;
+               var endDate = exclEndDay(event);
+               var segments = rangeToSegments(startDate, endDate);
+               for (var i=0; i<segments.length; i++) {
+                       segments[i].event = event;
+               }
+               return segments;
+       }
+
+
+       // Sets the `left` and `outerWidth` property of each segment.
+       // These values are the desired dimensions for the eventual DOM elements.
+       function calculateHorizontals(segments) {
+               var isRTL = opt('isRTL');
+               for (var i=0; i<segments.length; i++) {
+                       var segment = segments[i];
+
+                       // Determine functions used for calulating the elements left/right coordinates,
+                       // depending on whether the view is RTL or not.
+                       // NOTE:
+                       // colLeft/colRight returns the coordinate butting up the edge of the cell.
+                       // colContentLeft/colContentRight is indented a little bit from the edge.
+                       var leftFunc = (isRTL ? segment.isEnd : segment.isStart) ? colContentLeft : colLeft;
+                       var rightFunc = (isRTL ? segment.isStart : segment.isEnd) ? colContentRight : colRight;
+
+                       var left = leftFunc(segment.leftCol);
+                       var right = rightFunc(segment.rightCol);
+                       segment.left = left;
+                       segment.outerWidth = right - left;
+               }
+       }
+
+
+       // Build a concatenated HTML string for an array of segments
+       function buildHTML(segments) {
+               var html = '';
+               for (var i=0; i<segments.length; i++) {
+                       html += buildHTMLForSegment(segments[i]);
+               }
+               return html;
+       }
+
+
+       // Build an HTML string for a single segment.
+       // Relies on the following properties:
+       // - `segment.event` (from `buildSegmentsForEvent`)
+       // - `segment.left` (from `calculateHorizontals`)
+       function buildHTMLForSegment(segment) {
                var html = '';
-               // calculate desired position/dimensions, create html
-               for (i=0; i<segCnt; i++) {
-                       seg = segs[i];
-                       event = seg.event;
-                       classes = ['fc-event', 'fc-event-skin', 'fc-event-hori'];
-                       if (isEventDraggable(event)) {
-                               classes.push('fc-event-draggable');
-                       }
-                       if (rtl) {
-                               if (seg.isStart) {
-                                       classes.push('fc-corner-right');
-                               }
-                               if (seg.isEnd) {
-                                       classes.push('fc-corner-left');
-                               }
-                               leftCol = dayOfWeekCol(seg.end.getDay()-1);
-                               rightCol = dayOfWeekCol(seg.start.getDay());
-                               left = seg.isEnd ? colContentLeft(leftCol) : minLeft;
-                               right = seg.isStart ? colContentRight(rightCol) : maxLeft;
-                       }else{
-                               if (seg.isStart) {
-                                       classes.push('fc-corner-left');
-                               }
-                               if (seg.isEnd) {
-                                       classes.push('fc-corner-right');
-                               }
-                               leftCol = dayOfWeekCol(seg.start.getDay());
-                               rightCol = dayOfWeekCol(seg.end.getDay()-1);
-                               left = seg.isStart ? colContentLeft(leftCol) : minLeft;
-                               right = seg.isEnd ? colContentRight(rightCol) : maxLeft;
-                       }
-                       classes = classes.concat(event.className);
-                       if (event.source) {
-                               classes = classes.concat(event.source.className || []);
-                       }
-                       url = event.url;
-                       skinCss = getSkinCss(event, opt);
-                       if (url) {
-                               html += "<a href='" + htmlEscape(url) + "'";
-                       }else{
-                               html += "<div";
-                       }
+               var isRTL = opt('isRTL');
+               var event = segment.event;
+               var url = event.url;
+
+               // generate the list of CSS classNames
+               var classNames = [ 'fc-event', 'fc-event-hori' ];
+               if (isEventDraggable(event)) {
+                       classNames.push('fc-event-draggable');
+               }
+               if (segment.isStart) {
+                       classNames.push('fc-event-start');
+               }
+               if (segment.isEnd) {
+                       classNames.push('fc-event-end');
+               }
+               // use the event's configured classNames
+               // guaranteed to be an array via `normalizeEvent`
+               classNames = classNames.concat(event.className);
+               if (event.source) {
+                       // use the event's source's classNames, if specified
+                       classNames = classNames.concat(event.source.className || []);
+               }
+
+               // generate a semicolon delimited CSS string for any of the "skin" properties
+               // of the event object (`backgroundColor`, `borderColor` and such)
+               var skinCss = getSkinCss(event, opt);
+
+               if (url) {
+                       html += "<a href='" + htmlEscape(url) + "'";
+               }else{
+                       html += "<div";
+               }
+               html +=
+                       " class='" + classNames.join(' ') + "'" +
+                       " style=" +
+                               "'" +
+                               "position:absolute;" +
+                               "left:" + segment.left + "px;" +
+                               skinCss +
+                               "'" +
+                       ">" +
+                       "<div class='fc-event-inner'>";
+               if (!event.allDay && segment.isStart) {
                        html +=
-                               " class='" + classes.join(' ') + "'" +
-                               " style='position:absolute;z-index:8;left:"+left+"px;" + skinCss + "'" +
-                               ">" +
-                               "<div" +
-                               " class='fc-event-inner fc-event-skin'" +
-                               (skinCss ? " style='" + skinCss + "'" : '') +
-                               ">";
-                       if (!event.allDay && seg.isStart) {
-                               html +=
-                                       "<span class='fc-event-time'>" +
-                                       htmlEscape(formatDates(event.start, event.end, opt('timeFormat'))) +
-                                       "</span>";
-                       }
+                               "<span class='fc-event-time'>" +
+                               htmlEscape(
+                                       formatDates(event.start, event.end, opt('timeFormat'))
+                               ) +
+                               "</span>";
+               }
+               html +=
+                       "<span class='fc-event-title'>" +
+                       htmlEscape(event.title || '') +
+                       "</span>" +
+                       "</div>";
+               if (segment.isEnd && isEventResizable(event)) {
                        html +=
-                               "<span class='fc-event-title'>" + htmlEscape(event.title) + "</span>" +
+                               "<div class='ui-resizable-handle ui-resizable-" + (isRTL ? 'w' : 'e') + "'>" +
+                               "&nbsp;&nbsp;&nbsp;" + // makes hit area a lot better for IE6/7
                                "</div>";
-                       if (seg.isEnd && isEventResizable(event)) {
-                               html +=
-                                       "<div class='ui-resizable-handle ui-resizable-" + (rtl ? 'w' : 'e') + "'>" +
-                                       "&nbsp;&nbsp;&nbsp;" + // makes hit area a lot better for IE6/7
-                                       "</div>";
-                       }
-                       html +=
-                               "</" + (url ? "a" : "div" ) + ">";
-                       seg.left = left;
-                       seg.outerWidth = right - left;
-                       seg.startCol = leftCol;
-                       seg.endCol = rightCol + 1; // needs to be exclusive
                }
+               html += "</" + (url ? "a" : "div") + ">";
+
+               // TODO:
+               // When these elements are initially rendered, they will be briefly visibile on the screen,
+               // even though their widths/heights are not set.
+               // SOLUTION: initially set them as visibility:hidden ?
+
                return html;
        }
-       
-       
-       function daySegElementResolve(segs, elements) { // sets seg.element
-               var i;
-               var segCnt = segs.length;
-               var seg;
-               var event;
-               var element;
-               var triggerRes;
-               for (i=0; i<segCnt; i++) {
-                       seg = segs[i];
-                       event = seg.event;
-                       element = $(elements[i]); // faster than .eq()
-                       triggerRes = trigger('eventRender', event, event, element);
+
+
+       // Associate each segment (an object) with an element (a jQuery object),
+       // by setting each `segment.element`.
+       // Run each element through the `eventRender` filter, which allows developers to
+       // modify an existing element, supply a new one, or cancel rendering.
+       function resolveElements(segments, elements) {
+               for (var i=0; i<segments.length; i++) {
+                       var segment = segments[i];
+                       var event = segment.event;
+                       var element = elements.eq(i);
+
+                       // call the trigger with the original element
+                       var triggerRes = trigger('eventRender', event, event, element);
+
                        if (triggerRes === false) {
+                               // if `false`, remove the event from the DOM and don't assign it to `segment.event`
                                element.remove();
-                       }else{
+                       }
+                       else {
                                if (triggerRes && triggerRes !== true) {
+                                       // the trigger returned a new element, but not `true` (which means keep the existing element)
+
+                                       // re-assign the important CSS dimension properties that were already assigned in `buildHTMLForSegment`
                                        triggerRes = $(triggerRes)
                                                .css({
                                                        position: 'absolute',
-                                                       left: seg.left
+                                                       left: segment.left
                                                });
+
                                        element.replaceWith(triggerRes);
                                        element = triggerRes;
                                }
-                               seg.element = element;
+
+                               segment.element = element;
                        }
                }
        }
-       
-       
-       function daySegElementReport(segs) {
-               var i;
-               var segCnt = segs.length;
-               var seg;
-               var element;
-               for (i=0; i<segCnt; i++) {
-                       seg = segs[i];
-                       element = seg.element;
-                       if (element) {
-                               reportEventElement(seg.event, element);
+
+
+
+       /* Top-coordinate Methods
+       -------------------------------------------------------------------------------------------------*/
+
+
+       // Sets the "top" CSS property for each element.
+       // If `doRowHeights` is `true`, also sets each row's first cell to an explicit height,
+       // so that if elements vertically overflow, the cell expands vertically to compensate.
+       function setVerticals(segments, doRowHeights) {
+               var rowContentHeights = calculateVerticals(segments); // also sets segment.top
+               var rowContentElements = getRowContentElements(); // returns 1 inner div per row
+               var rowContentTops = [];
+
+               // Set each row's height by setting height of first inner div
+               if (doRowHeights) {
+                       for (var i=0; i<rowContentElements.length; i++) {
+                               rowContentElements[i].height(rowContentHeights[i]);
                        }
                }
+
+               // Get each row's top, relative to the views's origin.
+               // Important to do this after setting each row's height.
+               for (var i=0; i<rowContentElements.length; i++) {
+                       rowContentTops.push(
+                               rowContentElements[i].position().top
+                       );
+               }
+
+               // Set each segment element's CSS "top" property.
+               // Each segment object has a "top" property, which is relative to the row's top, but...
+               segmentElementEach(segments, function(segment, element) {
+                       element.css(
+                               'top',
+                               rowContentTops[segment.row] + segment.top // ...now, relative to views's origin
+                       );
+               });
        }
-       
-       
-       function daySegHandlers(segs, segmentContainer, modifiedEventId) {
-               var i;
-               var segCnt = segs.length;
-               var seg;
-               var element;
-               var event;
-               // retrieve elements, run through eventRender callback, bind handlers
-               for (i=0; i<segCnt; i++) {
-                       seg = segs[i];
-                       element = seg.element;
-                       if (element) {
-                               event = seg.event;
-                               if (event._id === modifiedEventId) {
-                                       bindDaySeg(event, element, seg);
-                               }else{
-                                       element[0]._fci = i; // for lazySegBind
+
+
+       // Calculate the "top" coordinate for each segment, relative to the "top" of the row.
+       // Also, return an array that contains the "content" height for each row
+       // (the height displaced by the vertically stacked events in the row).
+       // Requires segments to have their `outerHeight` property already set.
+       function calculateVerticals(segments) {
+               var rowCnt = getRowCnt();
+               var colCnt = getColCnt();
+               var rowContentHeights = []; // content height for each row
+               var segmentRows = buildSegmentRows(segments); // an array of segment arrays, one for each row
+
+               for (var rowI=0; rowI<rowCnt; rowI++) {
+                       var segmentRow = segmentRows[rowI];
+
+                       // an array of running total heights for each column.
+                       // initialize with all zeros.
+                       var colHeights = [];
+                       for (var colI=0; colI<colCnt; colI++) {
+                               colHeights.push(0);
+                       }
+
+                       // loop through every segment
+                       for (var segmentI=0; segmentI<segmentRow.length; segmentI++) {
+                               var segment = segmentRow[segmentI];
+
+                               // find the segment's top coordinate by looking at the max height
+                               // of all the columns the segment will be in.
+                               segment.top = arrayMax(
+                                       colHeights.slice(
+                                               segment.leftCol,
+                                               segment.rightCol + 1 // make exclusive for slice
+                                       )
+                               );
+
+                               // adjust the columns to account for the segment's height
+                               for (var colI=segment.leftCol; colI<=segment.rightCol; colI++) {
+                                       colHeights[colI] = segment.top + segment.outerHeight;
                                }
                        }
+
+                       // the tallest column in the row should be the "content height"
+                       rowContentHeights.push(arrayMax(colHeights));
                }
-               lazySegBind(segmentContainer, segs, bindDaySeg);
+
+               return rowContentHeights;
        }
-       
-       
-       function daySegCalcHSides(segs) { // also sets seg.key
-               var i;
-               var segCnt = segs.length;
-               var seg;
-               var element;
-               var key, val;
-               var hsideCache = {};
-               // record event horizontal sides
-               for (i=0; i<segCnt; i++) {
-                       seg = segs[i];
-                       element = seg.element;
-                       if (element) {
-                               key = seg.key = cssKey(element[0]);
-                               val = hsideCache[key];
-                               if (val === undefined) {
-                                       val = hsideCache[key] = hsides(element, true);
+
+
+       // Build an array of segment arrays, each representing the segments that will
+       // be in a row of the grid, sorted by which event should be closest to the top.
+       function buildSegmentRows(segments) {
+               var rowCnt = getRowCnt();
+               var segmentRows = [];
+               var segmentI;
+               var segment;
+               var rowI;
+
+               // group segments by row
+               for (segmentI=0; segmentI<segments.length; segmentI++) {
+                       segment = segments[segmentI];
+                       rowI = segment.row;
+                       if (segment.element) { // was rendered?
+                               if (segmentRows[rowI]) {
+                                       // already other segments. append to array
+                                       segmentRows[rowI].push(segment);
+                               }
+                               else {
+                                       // first segment in row. create new array
+                                       segmentRows[rowI] = [ segment ];
                                }
-                               seg.hsides = val;
                        }
                }
+
+               // sort each row
+               for (rowI=0; rowI<rowCnt; rowI++) {
+                       segmentRows[rowI] = sortSegmentRow(
+                               segmentRows[rowI] || [] // guarantee an array, even if no segments
+                       );
+               }
+
+               return segmentRows;
        }
-       
-       
-       function daySegSetWidths(segs) {
-               var i;
-               var segCnt = segs.length;
-               var seg;
-               var element;
-               for (i=0; i<segCnt; i++) {
-                       seg = segs[i];
-                       element = seg.element;
-                       if (element) {
-                               element[0].style.width = Math.max(0, seg.outerWidth - seg.hsides) + 'px';
-                       }
+
+
+       // Sort an array of segments according to which segment should appear closest to the top
+       function sortSegmentRow(segments) {
+               var sortedSegments = [];
+
+               // build the subrow array
+               var subrows = buildSegmentSubrows(segments);
+
+               // flatten it
+               for (var i=0; i<subrows.length; i++) {
+                       sortedSegments.push.apply(sortedSegments, subrows[i]); // append an array to an array
                }
+
+               return sortedSegments;
        }
-       
-       
-       function daySegCalcHeights(segs) {
-               var i;
-               var segCnt = segs.length;
-               var seg;
-               var element;
-               var key, val;
-               var vmarginCache = {};
-               // record event heights
-               for (i=0; i<segCnt; i++) {
-                       seg = segs[i];
-                       element = seg.element;
-                       if (element) {
-                               key = seg.key; // created in daySegCalcHSides
-                               val = vmarginCache[key];
-                               if (val === undefined) {
-                                       val = vmarginCache[key] = vmargins(element);
+
+
+       // Take an array of segments, which are all assumed to be in the same row,
+       // and sort into subrows.
+       function buildSegmentSubrows(segments) {
+
+               // Give preference to elements with certain criteria, so they have
+               // a chance to be closer to the top.
+               segments.sort(compareDaySegments);
+
+               var subrows = [];
+               for (var i=0; i<segments.length; i++) {
+                       var segment = segments[i];
+
+                       // loop through subrows, starting with the topmost, until the segment
+                       // doesn't collide with other segments.
+                       for (var j=0; j<subrows.length; j++) {
+                               if (!isDaySegmentCollision(segment, subrows[j])) {
+                                       break;
                                }
-                               seg.outerHeight = element[0].offsetHeight + val;
+                       }
+                       // `j` now holds the desired subrow index
+                       if (subrows[j]) {
+                               subrows[j].push(segment);
+                       }
+                       else {
+                               subrows[j] = [ segment ];
                        }
                }
+
+               return subrows;
        }
-       
-       
-       function getRowDivs() {
+
+
+       // Return an array of jQuery objects for the placeholder content containers of each row.
+       // The content containers don't actually contain anything, but their dimensions should match
+       // the events that are overlaid on top.
+       function getRowContentElements() {
                var i;
                var rowCnt = getRowCnt();
                var rowDivs = [];
                for (i=0; i<rowCnt; i++) {
                        rowDivs[i] = allDayRow(i)
-                               .find('td:first div.fc-day-content > div'); // optimal selector?
+                               .find('div.fc-day-content > div');
                }
                return rowDivs;
        }
-       
-       
-       function getRowTops(rowDivs) {
-               var i;
-               var rowCnt = rowDivs.length;
-               var tops = [];
-               for (i=0; i<rowCnt; i++) {
-                       tops[i] = rowDivs[i][0].offsetTop; // !!?? but this means the element needs position:relative if in a table cell!!!!
+
+
+
+       /* Mouse Handlers
+       ---------------------------------------------------------------------------------------------------*/
+       // TODO: better documentation!
+
+
+       function attachHandlers(segments, modifiedEventId) {
+               var segmentContainer = getDaySegmentContainer();
+
+               segmentElementEach(segments, function(segment, element, i) {
+                       var event = segment.event;
+                       if (event._id === modifiedEventId) {
+                               bindDaySeg(event, element, segment);
+                       }else{
+                               element[0]._fci = i; // for lazySegBind
+                       }
+               });
+
+               lazySegBind(segmentContainer, segments, bindDaySeg);
+       }
+
+
+       function bindDaySeg(event, eventElement, segment) {
+
+               if (isEventDraggable(event)) {
+                       t.draggableDayEvent(event, eventElement, segment); // use `t` so subclasses can override
+               }
+
+               if (
+                       segment.isEnd && // only allow resizing on the final segment for an event
+                       isEventResizable(event)
+               ) {
+                       t.resizableDayEvent(event, eventElement, segment); // use `t` so subclasses can override
                }
-               return tops;
+
+               // attach all other handlers.
+               // needs to be after, because resizableDayEvent might stopImmediatePropagation on click
+               eventElementHandlers(event, eventElement);
        }
+
        
-       
-       function daySegSetTops(segs, rowTops) { // also triggers eventAfterRender
-               var i;
-               var segCnt = segs.length;
-               var seg;
-               var element;
-               var event;
-               for (i=0; i<segCnt; i++) {
-                       seg = segs[i];
-                       element = seg.element;
-                       if (element) {
-                               element[0].style.top = rowTops[seg.row] + (seg.top||0) + 'px';
-                               event = seg.event;
-                               trigger('eventAfterRender', event, event, element);
+       function draggableDayEvent(event, eventElement) {
+               var hoverListener = getHoverListener();
+               var dayDelta;
+               eventElement.draggable({
+                       delay: 50,
+                       opacity: opt('dragOpacity'),
+                       revertDuration: opt('dragRevertDuration'),
+                       start: function(ev, ui) {
+                               trigger('eventDragStart', eventElement, event, ev, ui);
+                               hideEvents(event, eventElement);
+                               hoverListener.start(function(cell, origCell, rowDelta, colDelta) {
+                                       eventElement.draggable('option', 'revert', !cell || !rowDelta && !colDelta);
+                                       clearOverlays();
+                                       if (cell) {
+                                               var origDate = cellToDate(origCell);
+                                               var date = cellToDate(cell);
+                                               dayDelta = dayDiff(date, origDate);
+                                               renderDayOverlay(
+                                                       addDays(cloneDate(event.start), dayDelta),
+                                                       addDays(exclEndDay(event), dayDelta)
+                                               );
+                                       }else{
+                                               dayDelta = 0;
+                                       }
+                               }, ev, 'drag');
+                       },
+                       stop: function(ev, ui) {
+                               hoverListener.stop();
+                               clearOverlays();
+                               trigger('eventDragStop', eventElement, event, ev, ui);
+                               if (dayDelta) {
+                                       eventDrop(this, event, dayDelta, 0, event.allDay, ev, ui);
+                               }else{
+                                       eventElement.css('filter', ''); // clear IE opacity side-effects
+                                       showEvents(event, eventElement);
+                               }
                        }
-               }
+               });
        }
+
        
-       
-       
-       /* Resizing
-       -----------------------------------------------------------------------------------*/
-       
-       
-       function resizableDayEvent(event, element, seg) {
-               var rtl = opt('isRTL');
-               var direction = rtl ? 'w' : 'e';
-               var handle = element.find('div.ui-resizable-' + direction);
+       function resizableDayEvent(event, element, segment) {
+               var isRTL = opt('isRTL');
+               var direction = isRTL ? 'w' : 'e';
+               var handle = element.find('.ui-resizable-' + direction); // TODO: stop using this class because we aren't using jqui for this
                var isResizing = false;
                
                // TODO: look into using jquery-ui mouse widget for this stuff
@@ -4881,16 +5711,14 @@ function DayEventRenderer() {
                                return; // needs to be left mouse button
                        }
                        isResizing = true;
-                       var hoverListener = t.getHoverListener();
+                       var hoverListener = getHoverListener();
                        var rowCnt = getRowCnt();
                        var colCnt = getColCnt();
-                       var dis = rtl ? -1 : 1;
-                       var dit = rtl ? colCnt-1 : 0;
                        var elementTop = element.css('top');
                        var dayDelta;
                        var helpers;
                        var eventCopy = $.extend({}, event);
-                       var minCell = dateCell(event.start);
+                       var minCellOffset = dayOffsetToCellOffset( dateToDayOffset(event.start) );
                        clearSelection();
                        $('body')
                                .css('cursor', direction + '-resize')
@@ -4898,30 +5726,32 @@ function DayEventRenderer() {
                        trigger('eventResizeStart', this, event, ev);
                        hoverListener.start(function(cell, origCell) {
                                if (cell) {
-                                       var r = Math.max(minCell.row, cell.row);
-                                       var c = cell.col;
-                                       if (rowCnt == 1) {
-                                               r = 0; // hack for all-day area in agenda views
-                                       }
-                                       if (r == minCell.row) {
-                                               if (rtl) {
-                                                       c = Math.min(minCell.col, c);
-                                               }else{
-                                                       c = Math.max(minCell.col, c);
-                                               }
-                                       }
-                                       dayDelta = (r*7 + c*dis+dit) - (origCell.row*7 + origCell.col*dis+dit);
-                                       var newEnd = addDays(eventEnd(event), dayDelta, true);
+
+                                       var origCellOffset = cellToCellOffset(origCell);
+                                       var cellOffset = cellToCellOffset(cell);
+
+                                       // don't let resizing move earlier than start date cell
+                                       cellOffset = Math.max(cellOffset, minCellOffset);
+
+                                       dayDelta =
+                                               cellOffsetToDayOffset(cellOffset) -
+                                               cellOffsetToDayOffset(origCellOffset);
+
                                        if (dayDelta) {
-                                               eventCopy.end = newEnd;
+                                               eventCopy.end = addDays(eventEnd(event), dayDelta, true);
                                                var oldHelpers = helpers;
-                                               helpers = renderTempDaySegs(compileDaySegs([eventCopy]), seg.row, elementTop);
+
+                                               helpers = renderTempDayEvent(eventCopy, segment.row, elementTop);
+                                               helpers = $(helpers); // turn array into a jQuery object
+
                                                helpers.find('*').css('cursor', direction + '-resize');
                                                if (oldHelpers) {
                                                        oldHelpers.remove();
                                                }
+
                                                hideEvents(event);
-                                       }else{
+                                       }
+                                       else {
                                                if (helpers) {
                                                        showEvents(event);
                                                        helpers.remove();
@@ -4929,7 +5759,12 @@ function DayEventRenderer() {
                                                }
                                        }
                                        clearOverlays();
-                                       renderDayOverlay(event.start, addDays(cloneDate(newEnd), 1)); // coordinate grid already rebuild at hoverListener.start
+                                       renderDayOverlay( // coordinate grid already rebuilt with hoverListener.start()
+                                               event.start,
+                                               addDays( exclEndDay(event), dayDelta )
+                                               // TODO: instead of calling renderDayOverlay() with dates,
+                                               // call _renderDayOverlay (or whatever) with cell offsets.
+                                       );
                                }
                        }, ev);
                        
@@ -4948,13 +5783,54 @@ function DayEventRenderer() {
                                        isResizing = false;
                                },0);
                        }
-                       
                });
        }
        
 
 }
 
+
+
+/* Generalized Segment Utilities
+-------------------------------------------------------------------------------------------------*/
+
+
+function isDaySegmentCollision(segment, otherSegments) {
+       for (var i=0; i<otherSegments.length; i++) {
+               var otherSegment = otherSegments[i];
+               if (
+                       otherSegment.leftCol <= segment.rightCol &&
+                       otherSegment.rightCol >= segment.leftCol
+               ) {
+                       return true;
+               }
+       }
+       return false;
+}
+
+
+function segmentElementEach(segments, callback) { // TODO: use in AgendaView?
+       for (var i=0; i<segments.length; i++) {
+               var segment = segments[i];
+               var element = segment.element;
+               if (element) {
+                       callback(segment, element, i);
+               }
+       }
+}
+
+
+// A cmp function for determining which segments should appear higher up
+function compareDaySegments(a, b) {
+       return (b.rightCol - b.leftCol) - (a.rightCol - a.leftCol) || // put wider events first
+               b.event.allDay - a.event.allDay || // if tie, put all-day events first (booleans cast to 0/1)
+               a.event.start - b.event.start || // if a tie, sort by event start date
+               (a.event.title || '').localeCompare(b.event.title) // if a tie, sort by event title
+}
+
+
+;;
+
 //BUG: unselect needs to be triggered when events are dragged+dropped
 
 function SelectionManager() {
@@ -5021,18 +5897,18 @@ function SelectionManager() {
        
        
        function daySelectionMousedown(ev) { // not really a generic manager method, oh well
-               var cellDate = t.cellDate;
-               var cellIsAllDay = t.cellIsAllDay;
+               var cellToDate = t.cellToDate;
+               var getIsCellAllDay = t.getIsCellAllDay;
                var hoverListener = t.getHoverListener();
                var reportDayClick = t.reportDayClick; // this is hacky and sort of weird
                if (ev.which == 1 && opt('selectable')) { // which==1 means left mouse button
                        unselect(ev);
                        var _mousedownElement = this;
                        var dates;
-                       hoverListener.start(function(cell, origCell) { // TODO: maybe put cellDate/cellIsAllDay info in cell
+                       hoverListener.start(function(cell, origCell) { // TODO: maybe put cellToDate/getIsCellAllDay info in cell
                                clearSelection();
-                               if (cell && cellIsAllDay(cell)) {
-                                       dates = [ cellDate(origCell), cellDate(cell) ].sort(cmp);
+                               if (cell && getIsCellAllDay(cell)) {
+                                       dates = [ cellToDate(origCell), cellToDate(cell) ].sort(dateCompare);
                                        renderSelection(dates[0], dates[1], true);
                                }else{
                                        dates = null;
@@ -5052,6 +5928,8 @@ function SelectionManager() {
 
 
 }
+
+;;
  
 function OverlayManager() {
        var t = this;
@@ -5090,6 +5968,8 @@ function OverlayManager() {
 
 }
 
+;;
+
 function CoordinateGrid(buildFunc) {
 
        var t = this;
@@ -5136,6 +6016,8 @@ function CoordinateGrid(buildFunc) {
 
 }
 
+;;
+
 function HoverListener(coordinateGrid) {
 
 
@@ -5194,6 +6076,8 @@ function _fixUIEvent(event) { // for issue 1168
                event.pageY = event.originalEvent.pageY;
        }
 }
+;;
+
 function HorizontalPositionCache(getElement) {
 
        var t = this,
@@ -5220,5 +6104,7 @@ function HorizontalPositionCache(getElement) {
        };
        
 }
-\r
-})(jQuery);
+
+;;
+
+})(jQuery);
\ No newline at end of file
index df37bdfd803894789c0709aa2312432838bf1cf1..da4b984b2447e1b7a1ef14abf8db883fe693d875 100644 (file)
@@ -1,114 +1,7 @@
-/*
-
- FullCalendar v1.5.3
- http://arshaw.com/fullcalendar/
-
- Use fullcalendar.css for basic styling.
- For event drag & drop, requires jQuery UI draggable.
- For event resizing, requires jQuery UI resizable.
-
- Copyright (c) 2011 Adam Shaw
- Dual licensed under the MIT and GPL licenses, located in
- MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
-
- Date: Mon Feb 6 22:40:40 2012 -0800
-
-*/
-(function(m,ma){function wb(a){m.extend(true,Ya,a)}function Yb(a,b,e){function d(k){if(E){u();q();na();S(k)}else f()}function f(){B=b.theme?"ui":"fc";a.addClass("fc");b.isRTL&&a.addClass("fc-rtl");b.theme&&a.addClass("ui-widget");E=m("<div class='fc-content' style='position:relative'/>").prependTo(a);C=new Zb(X,b);(P=C.render())&&a.prepend(P);y(b.defaultView);m(window).resize(oa);t()||g()}function g(){setTimeout(function(){!n.start&&t()&&S()},0)}function l(){m(window).unbind("resize",oa);C.destroy();
-E.remove();a.removeClass("fc fc-rtl ui-widget")}function j(){return i.offsetWidth!==0}function t(){return m("body")[0].offsetWidth!==0}function y(k){if(!n||k!=n.name){F++;pa();var D=n,Z;if(D){(D.beforeHide||xb)();Za(E,E.height());D.element.hide()}else Za(E,1);E.css("overflow","hidden");if(n=Y[k])n.element.show();else n=Y[k]=new Ja[k](Z=s=m("<div class='fc-view fc-view-"+k+"' style='position:absolute'/>").appendTo(E),X);D&&C.deactivateButton(D.name);C.activateButton(k);S();E.css("overflow","");D&&
-Za(E,1);Z||(n.afterShow||xb)();F--}}function S(k){if(j()){F++;pa();o===ma&&u();var D=false;if(!n.start||k||r<n.start||r>=n.end){n.render(r,k||0);fa(true);D=true}else if(n.sizeDirty){n.clearEvents();fa();D=true}else if(n.eventsDirty){n.clearEvents();D=true}n.sizeDirty=false;n.eventsDirty=false;ga(D);W=a.outerWidth();C.updateTitle(n.title);k=new Date;k>=n.start&&k<n.end?C.disableButton("today"):C.enableButton("today");F--;n.trigger("viewDisplay",i)}}function Q(){q();if(j()){u();fa();pa();n.clearEvents();
-n.renderEvents(J);n.sizeDirty=false}}function q(){m.each(Y,function(k,D){D.sizeDirty=true})}function u(){o=b.contentHeight?b.contentHeight:b.height?b.height-(P?P.height():0)-Sa(E):Math.round(E.width()/Math.max(b.aspectRatio,0.5))}function fa(k){F++;n.setHeight(o,k);if(s){s.css("position","relative");s=null}n.setWidth(E.width(),k);F--}function oa(){if(!F)if(n.start){var k=++v;setTimeout(function(){if(k==v&&!F&&j())if(W!=(W=a.outerWidth())){F++;Q();n.trigger("windowResize",i);F--}},200)}else g()}function ga(k){if(!b.lazyFetching||
-ya(n.visStart,n.visEnd))ra();else k&&da()}function ra(){K(n.visStart,n.visEnd)}function sa(k){J=k;da()}function ha(k){da(k)}function da(k){na();if(j()){n.clearEvents();n.renderEvents(J,k);n.eventsDirty=false}}function na(){m.each(Y,function(k,D){D.eventsDirty=true})}function ua(k,D,Z){n.select(k,D,Z===ma?true:Z)}function pa(){n&&n.unselect()}function U(){S(-1)}function ca(){S(1)}function ka(){gb(r,-1);S()}function qa(){gb(r,1);S()}function G(){r=new Date;S()}function p(k,D,Z){if(k instanceof Date)r=
-N(k);else yb(r,k,D,Z);S()}function L(k,D,Z){k!==ma&&gb(r,k);D!==ma&&hb(r,D);Z!==ma&&ba(r,Z);S()}function c(){return N(r)}function z(){return n}function H(k,D){if(D===ma)return b[k];if(k=="height"||k=="contentHeight"||k=="aspectRatio"){b[k]=D;Q()}}function T(k,D){if(b[k])return b[k].apply(D||i,Array.prototype.slice.call(arguments,2))}var X=this;X.options=b;X.render=d;X.destroy=l;X.refetchEvents=ra;X.reportEvents=sa;X.reportEventChange=ha;X.rerenderEvents=da;X.changeView=y;X.select=ua;X.unselect=pa;
-X.prev=U;X.next=ca;X.prevYear=ka;X.nextYear=qa;X.today=G;X.gotoDate=p;X.incrementDate=L;X.formatDate=function(k,D){return Oa(k,D,b)};X.formatDates=function(k,D,Z){return ib(k,D,Z,b)};X.getDate=c;X.getView=z;X.option=H;X.trigger=T;$b.call(X,b,e);var ya=X.isFetchNeeded,K=X.fetchEvents,i=a[0],C,P,E,B,n,Y={},W,o,s,v=0,F=0,r=new Date,J=[],M;yb(r,b.year,b.month,b.date);b.droppable&&m(document).bind("dragstart",function(k,D){var Z=k.target,ja=m(Z);if(!ja.parents(".fc").length){var ia=b.dropAccept;if(m.isFunction(ia)?
-ia.call(Z,ja):ja.is(ia)){M=Z;n.dragStart(M,k,D)}}}).bind("dragstop",function(k,D){if(M){n.dragStop(M,k,D);M=null}})}function Zb(a,b){function e(){q=b.theme?"ui":"fc";if(b.header)return Q=m("<table class='fc-header' style='width:100%'/>").append(m("<tr/>").append(f("left")).append(f("center")).append(f("right")))}function d(){Q.remove()}function f(u){var fa=m("<td class='fc-header-"+u+"'/>");(u=b.header[u])&&m.each(u.split(" "),function(oa){oa>0&&fa.append("<span class='fc-header-space'/>");var ga;
-m.each(this.split(","),function(ra,sa){if(sa=="title"){fa.append("<span class='fc-header-title'><h2>&nbsp;</h2></span>");ga&&ga.addClass(q+"-corner-right");ga=null}else{var ha;if(a[sa])ha=a[sa];else if(Ja[sa])ha=function(){na.removeClass(q+"-state-hover");a.changeView(sa)};if(ha){ra=b.theme?jb(b.buttonIcons,sa):null;var da=jb(b.buttonText,sa),na=m("<span class='fc-button fc-button-"+sa+" "+q+"-state-default'><span class='fc-button-inner'><span class='fc-button-content'>"+(ra?"<span class='fc-icon-wrap'><span class='ui-icon ui-icon-"+
-ra+"'/></span>":da)+"</span><span class='fc-button-effect'><span></span></span></span></span>");if(na){na.click(function(){na.hasClass(q+"-state-disabled")||ha()}).mousedown(function(){na.not("."+q+"-state-active").not("."+q+"-state-disabled").addClass(q+"-state-down")}).mouseup(function(){na.removeClass(q+"-state-down")}).hover(function(){na.not("."+q+"-state-active").not("."+q+"-state-disabled").addClass(q+"-state-hover")},function(){na.removeClass(q+"-state-hover").removeClass(q+"-state-down")}).appendTo(fa);
-ga||na.addClass(q+"-corner-left");ga=na}}}});ga&&ga.addClass(q+"-corner-right")});return fa}function g(u){Q.find("h2").html(u)}function l(u){Q.find("span.fc-button-"+u).addClass(q+"-state-active")}function j(u){Q.find("span.fc-button-"+u).removeClass(q+"-state-active")}function t(u){Q.find("span.fc-button-"+u).addClass(q+"-state-disabled")}function y(u){Q.find("span.fc-button-"+u).removeClass(q+"-state-disabled")}var S=this;S.render=e;S.destroy=d;S.updateTitle=g;S.activateButton=l;S.deactivateButton=
-j;S.disableButton=t;S.enableButton=y;var Q=m([]),q}function $b(a,b){function e(c,z){return!ca||c<ca||z>ka}function d(c,z){ca=c;ka=z;L=[];c=++qa;G=z=U.length;for(var H=0;H<z;H++)f(U[H],c)}function f(c,z){g(c,function(H){if(z==qa){if(H){for(var T=0;T<H.length;T++){H[T].source=c;oa(H[T])}L=L.concat(H)}G--;G||ua(L)}})}function g(c,z){var H,T=Aa.sourceFetchers,X;for(H=0;H<T.length;H++){X=T[H](c,ca,ka,z);if(X===true)return;else if(typeof X=="object"){g(X,z);return}}if(H=c.events)if(m.isFunction(H)){u();
-H(N(ca),N(ka),function(C){z(C);fa()})}else m.isArray(H)?z(H):z();else if(c.url){var ya=c.success,K=c.error,i=c.complete;H=m.extend({},c.data||{});T=Ta(c.startParam,a.startParam);X=Ta(c.endParam,a.endParam);if(T)H[T]=Math.round(+ca/1E3);if(X)H[X]=Math.round(+ka/1E3);u();m.ajax(m.extend({},ac,c,{data:H,success:function(C){C=C||[];var P=$a(ya,this,arguments);if(m.isArray(P))C=P;z(C)},error:function(){$a(K,this,arguments);z()},complete:function(){$a(i,this,arguments);fa()}}))}else z()}function l(c){if(c=
-j(c)){G++;f(c,qa)}}function j(c){if(m.isFunction(c)||m.isArray(c))c={events:c};else if(typeof c=="string")c={url:c};if(typeof c=="object"){ga(c);U.push(c);return c}}function t(c){U=m.grep(U,function(z){return!ra(z,c)});L=m.grep(L,function(z){return!ra(z.source,c)});ua(L)}function y(c){var z,H=L.length,T,X=na().defaultEventEnd,ya=c.start-c._start,K=c.end?c.end-(c._end||X(c)):0;for(z=0;z<H;z++){T=L[z];if(T._id==c._id&&T!=c){T.start=new Date(+T.start+ya);T.end=c.end?T.end?new Date(+T.end+K):new Date(+X(T)+
-K):null;T.title=c.title;T.url=c.url;T.allDay=c.allDay;T.className=c.className;T.editable=c.editable;T.color=c.color;T.backgroudColor=c.backgroudColor;T.borderColor=c.borderColor;T.textColor=c.textColor;oa(T)}}oa(c);ua(L)}function S(c,z){oa(c);if(!c.source){if(z){pa.events.push(c);c.source=pa}L.push(c)}ua(L)}function Q(c){if(c){if(!m.isFunction(c)){var z=c+"";c=function(T){return T._id==z}}L=m.grep(L,c,true);for(H=0;H<U.length;H++)if(m.isArray(U[H].events))U[H].events=m.grep(U[H].events,c,true)}else{L=
-[];for(var H=0;H<U.length;H++)if(m.isArray(U[H].events))U[H].events=[]}ua(L)}function q(c){if(m.isFunction(c))return m.grep(L,c);else if(c){c+="";return m.grep(L,function(z){return z._id==c})}return L}function u(){p++||da("loading",null,true)}function fa(){--p||da("loading",null,false)}function oa(c){var z=c.source||{},H=Ta(z.ignoreTimezone,a.ignoreTimezone);c._id=c._id||(c.id===ma?"_fc"+bc++:c.id+"");if(c.date){if(!c.start)c.start=c.date;delete c.date}c._start=N(c.start=kb(c.start,H));c.end=kb(c.end,
-H);if(c.end&&c.end<=c.start)c.end=null;c._end=c.end?N(c.end):null;if(c.allDay===ma)c.allDay=Ta(z.allDayDefault,a.allDayDefault);if(c.className){if(typeof c.className=="string")c.className=c.className.split(/\s+/)}else c.className=[]}function ga(c){if(c.className){if(typeof c.className=="string")c.className=c.className.split(/\s+/)}else c.className=[];for(var z=Aa.sourceNormalizers,H=0;H<z.length;H++)z[H](c)}function ra(c,z){return c&&z&&sa(c)==sa(z)}function sa(c){return(typeof c=="object"?c.events||
-c.url:"")||c}var ha=this;ha.isFetchNeeded=e;ha.fetchEvents=d;ha.addEventSource=l;ha.removeEventSource=t;ha.updateEvent=y;ha.renderEvent=S;ha.removeEvents=Q;ha.clientEvents=q;ha.normalizeEvent=oa;var da=ha.trigger,na=ha.getView,ua=ha.reportEvents,pa={events:[]},U=[pa],ca,ka,qa=0,G=0,p=0,L=[];for(ha=0;ha<b.length;ha++)j(b[ha])}function gb(a,b,e){a.setFullYear(a.getFullYear()+b);e||Ka(a);return a}function hb(a,b,e){if(+a){b=a.getMonth()+b;var d=N(a);d.setDate(1);d.setMonth(b);a.setMonth(b);for(e||Ka(a);a.getMonth()!=
-d.getMonth();)a.setDate(a.getDate()+(a<d?1:-1))}return a}function ba(a,b,e){if(+a){b=a.getDate()+b;var d=N(a);d.setHours(9);d.setDate(b);a.setDate(b);e||Ka(a);lb(a,d)}return a}function lb(a,b){if(+a)for(;a.getDate()!=b.getDate();)a.setTime(+a+(a<b?1:-1)*cc)}function xa(a,b){a.setMinutes(a.getMinutes()+b);return a}function Ka(a){a.setHours(0);a.setMinutes(0);a.setSeconds(0);a.setMilliseconds(0);return a}function N(a,b){if(b)return Ka(new Date(+a));return new Date(+a)}function zb(){var a=0,b;do b=new Date(1970,
-a++,1);while(b.getHours());return b}function Fa(a,b,e){for(b=b||1;!a.getDay()||e&&a.getDay()==1||!e&&a.getDay()==6;)ba(a,b);return a}function Ca(a,b){return Math.round((N(a,true)-N(b,true))/Ab)}function yb(a,b,e,d){if(b!==ma&&b!=a.getFullYear()){a.setDate(1);a.setMonth(0);a.setFullYear(b)}if(e!==ma&&e!=a.getMonth()){a.setDate(1);a.setMonth(e)}d!==ma&&a.setDate(d)}function kb(a,b){if(typeof a=="object")return a;if(typeof a=="number")return new Date(a*1E3);if(typeof a=="string"){if(a.match(/^\d+(\.\d+)?$/))return new Date(parseFloat(a)*
-1E3);if(b===ma)b=true;return Bb(a,b)||(a?new Date(a):null)}return null}function Bb(a,b){a=a.match(/^([0-9]{4})(-([0-9]{2})(-([0-9]{2})([T ]([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?(Z|(([-+])([0-9]{2})(:?([0-9]{2}))?))?)?)?)?$/);if(!a)return null;var e=new Date(a[1],0,1);if(b||!a[13]){b=new Date(a[1],0,1,9,0);if(a[3]){e.setMonth(a[3]-1);b.setMonth(a[3]-1)}if(a[5]){e.setDate(a[5]);b.setDate(a[5])}lb(e,b);a[7]&&e.setHours(a[7]);a[8]&&e.setMinutes(a[8]);a[10]&&e.setSeconds(a[10]);a[12]&&e.setMilliseconds(Number("0."+
-a[12])*1E3);lb(e,b)}else{e.setUTCFullYear(a[1],a[3]?a[3]-1:0,a[5]||1);e.setUTCHours(a[7]||0,a[8]||0,a[10]||0,a[12]?Number("0."+a[12])*1E3:0);if(a[14]){b=Number(a[16])*60+(a[18]?Number(a[18]):0);b*=a[15]=="-"?1:-1;e=new Date(+e+b*60*1E3)}}return e}function mb(a){if(typeof a=="number")return a*60;if(typeof a=="object")return a.getHours()*60+a.getMinutes();if(a=a.match(/(\d+)(?::(\d+))?\s*(\w+)?/)){var b=parseInt(a[1],10);if(a[3]){b%=12;if(a[3].toLowerCase().charAt(0)=="p")b+=12}return b*60+(a[2]?parseInt(a[2],
-10):0)}}function Oa(a,b,e){return ib(a,null,b,e)}function ib(a,b,e,d){d=d||Ya;var f=a,g=b,l,j=e.length,t,y,S,Q="";for(l=0;l<j;l++){t=e.charAt(l);if(t=="'")for(y=l+1;y<j;y++){if(e.charAt(y)=="'"){if(f){Q+=y==l+1?"'":e.substring(l+1,y);l=y}break}}else if(t=="(")for(y=l+1;y<j;y++){if(e.charAt(y)==")"){l=Oa(f,e.substring(l+1,y),d);if(parseInt(l.replace(/\D/,""),10))Q+=l;l=y;break}}else if(t=="[")for(y=l+1;y<j;y++){if(e.charAt(y)=="]"){t=e.substring(l+1,y);l=Oa(f,t,d);if(l!=Oa(g,t,d))Q+=l;l=y;break}}else if(t==
-"{"){f=b;g=a}else if(t=="}"){f=a;g=b}else{for(y=j;y>l;y--)if(S=dc[e.substring(l,y)]){if(f)Q+=S(f,d);l=y-1;break}if(y==l)if(f)Q+=t}}return Q}function Ua(a){return a.end?ec(a.end,a.allDay):ba(N(a.start),1)}function ec(a,b){a=N(a);return b||a.getHours()||a.getMinutes()?ba(a,1):Ka(a)}function fc(a,b){return(b.msLength-a.msLength)*100+(a.event.start-b.event.start)}function Cb(a,b){return a.end>b.start&&a.start<b.end}function nb(a,b,e,d){var f=[],g,l=a.length,j,t,y,S,Q;for(g=0;g<l;g++){j=a[g];t=j.start;
-y=b[g];if(y>e&&t<d){if(t<e){t=N(e);S=false}else{t=t;S=true}if(y>d){y=N(d);Q=false}else{y=y;Q=true}f.push({event:j,start:t,end:y,isStart:S,isEnd:Q,msLength:y-t})}}return f.sort(fc)}function ob(a){var b=[],e,d=a.length,f,g,l,j;for(e=0;e<d;e++){f=a[e];for(g=0;;){l=false;if(b[g])for(j=0;j<b[g].length;j++)if(Cb(b[g][j],f)){l=true;break}if(l)g++;else break}if(b[g])b[g].push(f);else b[g]=[f]}return b}function Db(a,b,e){a.unbind("mouseover").mouseover(function(d){for(var f=d.target,g;f!=this;){g=f;f=f.parentNode}if((f=
-g._fci)!==ma){g._fci=ma;g=b[f];e(g.event,g.element,g);m(d.target).trigger(d)}d.stopPropagation()})}function Va(a,b,e){for(var d=0,f;d<a.length;d++){f=m(a[d]);f.width(Math.max(0,b-pb(f,e)))}}function Eb(a,b,e){for(var d=0,f;d<a.length;d++){f=m(a[d]);f.height(Math.max(0,b-Sa(f,e)))}}function pb(a,b){return gc(a)+hc(a)+(b?ic(a):0)}function gc(a){return(parseFloat(m.curCSS(a[0],"paddingLeft",true))||0)+(parseFloat(m.curCSS(a[0],"paddingRight",true))||0)}function ic(a){return(parseFloat(m.curCSS(a[0],
-"marginLeft",true))||0)+(parseFloat(m.curCSS(a[0],"marginRight",true))||0)}function hc(a){return(parseFloat(m.curCSS(a[0],"borderLeftWidth",true))||0)+(parseFloat(m.curCSS(a[0],"borderRightWidth",true))||0)}function Sa(a,b){return jc(a)+kc(a)+(b?Fb(a):0)}function jc(a){return(parseFloat(m.curCSS(a[0],"paddingTop",true))||0)+(parseFloat(m.curCSS(a[0],"paddingBottom",true))||0)}function Fb(a){return(parseFloat(m.curCSS(a[0],"marginTop",true))||0)+(parseFloat(m.curCSS(a[0],"marginBottom",true))||0)}
-function kc(a){return(parseFloat(m.curCSS(a[0],"borderTopWidth",true))||0)+(parseFloat(m.curCSS(a[0],"borderBottomWidth",true))||0)}function Za(a,b){b=typeof b=="number"?b+"px":b;a.each(function(e,d){d.style.cssText+=";min-height:"+b+";_height:"+b})}function xb(){}function Gb(a,b){return a-b}function Hb(a){return Math.max.apply(Math,a)}function Pa(a){return(a<10?"0":"")+a}function jb(a,b){if(a[b]!==ma)return a[b];b=b.split(/(?=[A-Z])/);for(var e=b.length-1,d;e>=0;e--){d=a[b[e].toLowerCase()];if(d!==
-ma)return d}return a[""]}function Qa(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#039;").replace(/"/g,"&quot;").replace(/\n/g,"<br />")}function Ib(a){return a.id+"/"+a.className+"/"+a.style.cssText.replace(/(^|;)\s*(top|left|width|height)\s*:[^;]*/ig,"")}function qb(a){a.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})}function ab(a){a.children().removeClass("fc-first fc-last").filter(":first-child").addClass("fc-first").end().filter(":last-child").addClass("fc-last")}
-function rb(a,b){a.each(function(e,d){d.className=d.className.replace(/^fc-\w*/,"fc-"+lc[b.getDay()])})}function Jb(a,b){var e=a.source||{},d=a.color,f=e.color,g=b("eventColor"),l=a.backgroundColor||d||e.backgroundColor||f||b("eventBackgroundColor")||g;d=a.borderColor||d||e.borderColor||f||b("eventBorderColor")||g;a=a.textColor||e.textColor||b("eventTextColor");b=[];l&&b.push("background-color:"+l);d&&b.push("border-color:"+d);a&&b.push("color:"+a);return b.join(";")}function $a(a,b,e){if(m.isFunction(a))a=
-[a];if(a){var d,f;for(d=0;d<a.length;d++)f=a[d].apply(b,e)||f;return f}}function Ta(){for(var a=0;a<arguments.length;a++)if(arguments[a]!==ma)return arguments[a]}function mc(a,b){function e(j,t){if(t){hb(j,t);j.setDate(1)}j=N(j,true);j.setDate(1);t=hb(N(j),1);var y=N(j),S=N(t),Q=f("firstDay"),q=f("weekends")?0:1;if(q){Fa(y);Fa(S,-1,true)}ba(y,-((y.getDay()-Math.max(Q,q)+7)%7));ba(S,(7-S.getDay()+Math.max(Q,q))%7);Q=Math.round((S-y)/(Ab*7));if(f("weekMode")=="fixed"){ba(S,(6-Q)*7);Q=6}d.title=l(j,
-f("titleFormat"));d.start=j;d.end=t;d.visStart=y;d.visEnd=S;g(6,Q,q?5:7,true)}var d=this;d.render=e;sb.call(d,a,b,"month");var f=d.opt,g=d.renderBasic,l=b.formatDate}function nc(a,b){function e(j,t){t&&ba(j,t*7);j=ba(N(j),-((j.getDay()-f("firstDay")+7)%7));t=ba(N(j),7);var y=N(j),S=N(t),Q=f("weekends");if(!Q){Fa(y);Fa(S,-1,true)}d.title=l(y,ba(N(S),-1),f("titleFormat"));d.start=j;d.end=t;d.visStart=y;d.visEnd=S;g(1,1,Q?7:5,false)}var d=this;d.render=e;sb.call(d,a,b,"basicWeek");var f=d.opt,g=d.renderBasic,
-l=b.formatDates}function oc(a,b){function e(j,t){if(t){ba(j,t);f("weekends")||Fa(j,t<0?-1:1)}d.title=l(j,f("titleFormat"));d.start=d.visStart=N(j,true);d.end=d.visEnd=ba(N(d.start),1);g(1,1,1,false)}var d=this;d.render=e;sb.call(d,a,b,"basicDay");var f=d.opt,g=d.renderBasic,l=b.formatDate}function sb(a,b,e){function d(w,I,R,V){v=I;F=R;f();(I=!C)?g(w,V):z();l(I)}function f(){if(k=L("isRTL")){D=-1;Z=F-1}else{D=1;Z=0}ja=L("firstDay");ia=L("weekends")?0:1;la=L("theme")?"ui":"fc";$=L("columnFormat")}function g(w,
-I){var R,V=la+"-widget-header",ea=la+"-widget-content",aa;R="<table class='fc-border-separate' style='width:100%' cellspacing='0'><thead><tr>";for(aa=0;aa<F;aa++)R+="<th class='fc- "+V+"'/>";R+="</tr></thead><tbody>";for(aa=0;aa<w;aa++){R+="<tr class='fc-week"+aa+"'>";for(V=0;V<F;V++)R+="<td class='fc- "+ea+" fc-day"+(aa*F+V)+"'><div>"+(I?"<div class='fc-day-number'/>":"")+"<div class='fc-day-content'><div style='position:relative'>&nbsp;</div></div></div></td>";R+="</tr>"}R+="</tbody></table>";w=
-m(R).appendTo(a);K=w.find("thead");i=K.find("th");C=w.find("tbody");P=C.find("tr");E=C.find("td");B=E.filter(":first-child");n=P.eq(0).find("div.fc-day-content div");ab(K.add(K.find("tr")));ab(P);P.eq(0).addClass("fc-first");y(E);Y=m("<div style='position:absolute;z-index:8;top:0;left:0'/>").appendTo(a)}function l(w){var I=w||v==1,R=p.start.getMonth(),V=Ka(new Date),ea,aa,va;I&&i.each(function(wa,Ga){ea=m(Ga);aa=ca(wa);ea.html(ya(aa,$));rb(ea,aa)});E.each(function(wa,Ga){ea=m(Ga);aa=ca(wa);aa.getMonth()==
-R?ea.removeClass("fc-other-month"):ea.addClass("fc-other-month");+aa==+V?ea.addClass(la+"-state-highlight fc-today"):ea.removeClass(la+"-state-highlight fc-today");ea.find("div.fc-day-number").text(aa.getDate());I&&rb(ea,aa)});P.each(function(wa,Ga){va=m(Ga);if(wa<v){va.show();wa==v-1?va.addClass("fc-last"):va.removeClass("fc-last")}else va.hide()})}function j(w){o=w;w=o-K.height();var I,R,V;if(L("weekMode")=="variable")I=R=Math.floor(w/(v==1?2:6));else{I=Math.floor(w/v);R=w-I*(v-1)}B.each(function(ea,
-aa){if(ea<v){V=m(aa);Za(V.find("> div"),(ea==v-1?R:I)-Sa(V))}})}function t(w){W=w;M.clear();s=Math.floor(W/F);Va(i.slice(0,-1),s)}function y(w){w.click(S).mousedown(X)}function S(w){if(!L("selectable")){var I=parseInt(this.className.match(/fc\-day(\d+)/)[1]);I=ca(I);c("dayClick",this,I,true,w)}}function Q(w,I,R){R&&r.build();R=N(p.visStart);for(var V=ba(N(R),F),ea=0;ea<v;ea++){var aa=new Date(Math.max(R,w)),va=new Date(Math.min(V,I));if(aa<va){var wa;if(k){wa=Ca(va,R)*D+Z+1;aa=Ca(aa,R)*D+Z+1}else{wa=
-Ca(aa,R);aa=Ca(va,R)}y(q(ea,wa,ea,aa-1))}ba(R,7);ba(V,7)}}function q(w,I,R,V){w=r.rect(w,I,R,V,a);return H(w,a)}function u(w){return N(w)}function fa(w,I){Q(w,ba(N(I),1),true)}function oa(){T()}function ga(w,I,R){var V=ua(w);c("dayClick",E[V.row*F+V.col],w,I,R)}function ra(w,I){J.start(function(R){T();R&&q(R.row,R.col,R.row,R.col)},I)}function sa(w,I,R){var V=J.stop();T();if(V){V=pa(V);c("drop",w,V,true,I,R)}}function ha(w){return N(w.start)}function da(w){return M.left(w)}function na(w){return M.right(w)}
-function ua(w){return{row:Math.floor(Ca(w,p.visStart)/7),col:ka(w.getDay())}}function pa(w){return U(w.row,w.col)}function U(w,I){return ba(N(p.visStart),w*7+I*D+Z)}function ca(w){return U(Math.floor(w/F),w%F)}function ka(w){return(w-Math.max(ja,ia)+F)%F*D+Z}function qa(w){return P.eq(w)}function G(){return{left:0,right:W}}var p=this;p.renderBasic=d;p.setHeight=j;p.setWidth=t;p.renderDayOverlay=Q;p.defaultSelectionEnd=u;p.renderSelection=fa;p.clearSelection=oa;p.reportDayClick=ga;p.dragStart=ra;p.dragStop=
-sa;p.defaultEventEnd=ha;p.getHoverListener=function(){return J};p.colContentLeft=da;p.colContentRight=na;p.dayOfWeekCol=ka;p.dateCell=ua;p.cellDate=pa;p.cellIsAllDay=function(){return true};p.allDayRow=qa;p.allDayBounds=G;p.getRowCnt=function(){return v};p.getColCnt=function(){return F};p.getColWidth=function(){return s};p.getDaySegmentContainer=function(){return Y};Kb.call(p,a,b,e);Lb.call(p);Mb.call(p);pc.call(p);var L=p.opt,c=p.trigger,z=p.clearEvents,H=p.renderOverlay,T=p.clearOverlays,X=p.daySelectionMousedown,
-ya=b.formatDate,K,i,C,P,E,B,n,Y,W,o,s,v,F,r,J,M,k,D,Z,ja,ia,la,$;qb(a.addClass("fc-grid"));r=new Nb(function(w,I){var R,V,ea;i.each(function(aa,va){R=m(va);V=R.offset().left;if(aa)ea[1]=V;ea=[V];I[aa]=ea});ea[1]=V+R.outerWidth();P.each(function(aa,va){if(aa<v){R=m(va);V=R.offset().top;if(aa)ea[1]=V;ea=[V];w[aa]=ea}});ea[1]=V+R.outerHeight()});J=new Ob(r);M=new Pb(function(w){return n.eq(w)})}function pc(){function a(U,ca){S(U);ua(e(U),ca)}function b(){Q();ga().empty()}function e(U){var ca=da(),ka=
-na(),qa=N(g.visStart);ka=ba(N(qa),ka);var G=m.map(U,Ua),p,L,c,z,H,T,X=[];for(p=0;p<ca;p++){L=ob(nb(U,G,qa,ka));for(c=0;c<L.length;c++){z=L[c];for(H=0;H<z.length;H++){T=z[H];T.row=p;T.level=c;X.push(T)}}ba(qa,7);ba(ka,7)}return X}function d(U,ca,ka){t(U)&&f(U,ca);ka.isEnd&&y(U)&&pa(U,ca,ka);q(U,ca)}function f(U,ca){var ka=ra(),qa;ca.draggable({zIndex:9,delay:50,opacity:l("dragOpacity"),revertDuration:l("dragRevertDuration"),start:function(G,p){j("eventDragStart",ca,U,G,p);fa(U,ca);ka.start(function(L,
-c,z,H){ca.draggable("option","revert",!L||!z&&!H);ha();if(L){qa=z*7+H*(l("isRTL")?-1:1);sa(ba(N(U.start),qa),ba(Ua(U),qa))}else qa=0},G,"drag")},stop:function(G,p){ka.stop();ha();j("eventDragStop",ca,U,G,p);if(qa)oa(this,U,qa,0,U.allDay,G,p);else{ca.css("filter","");u(U,ca)}}})}var g=this;g.renderEvents=a;g.compileDaySegs=e;g.clearEvents=b;g.bindDaySeg=d;Qb.call(g);var l=g.opt,j=g.trigger,t=g.isEventDraggable,y=g.isEventResizable,S=g.reportEvents,Q=g.reportEventClear,q=g.eventElementHandlers,u=g.showEvents,
-fa=g.hideEvents,oa=g.eventDrop,ga=g.getDaySegmentContainer,ra=g.getHoverListener,sa=g.renderDayOverlay,ha=g.clearOverlays,da=g.getRowCnt,na=g.getColCnt,ua=g.renderDaySegs,pa=g.resizableDayEvent}function qc(a,b){function e(j,t){t&&ba(j,t*7);j=ba(N(j),-((j.getDay()-f("firstDay")+7)%7));t=ba(N(j),7);var y=N(j),S=N(t),Q=f("weekends");if(!Q){Fa(y);Fa(S,-1,true)}d.title=l(y,ba(N(S),-1),f("titleFormat"));d.start=j;d.end=t;d.visStart=y;d.visEnd=S;g(Q?7:5)}var d=this;d.render=e;Rb.call(d,a,b,"agendaWeek");
-var f=d.opt,g=d.renderAgenda,l=b.formatDates}function rc(a,b){function e(j,t){if(t){ba(j,t);f("weekends")||Fa(j,t<0?-1:1)}t=N(j,true);var y=ba(N(t),1);d.title=l(j,f("titleFormat"));d.start=d.visStart=t;d.end=d.visEnd=y;g(1)}var d=this;d.render=e;Rb.call(d,a,b,"agendaDay");var f=d.opt,g=d.renderAgenda,l=b.formatDate}function Rb(a,b,e){function d(h){Ba=h;f();v?P():g();l()}function f(){Wa=i("theme")?"ui":"fc";Sb=i("weekends")?0:1;Tb=i("firstDay");if(Ub=i("isRTL")){Ha=-1;Ia=Ba-1}else{Ha=1;Ia=0}La=mb(i("minTime"));
-bb=mb(i("maxTime"));Vb=i("columnFormat")}function g(){var h=Wa+"-widget-header",O=Wa+"-widget-content",x,A,ta,za,Da,Ea=i("slotMinutes")%15==0;x="<table style='width:100%' class='fc-agenda-days fc-border-separate' cellspacing='0'><thead><tr><th class='fc-agenda-axis "+h+"'>&nbsp;</th>";for(A=0;A<Ba;A++)x+="<th class='fc- fc-col"+A+" "+h+"'/>";x+="<th class='fc-agenda-gutter "+h+"'>&nbsp;</th></tr></thead><tbody><tr><th class='fc-agenda-axis "+h+"'>&nbsp;</th>";for(A=0;A<Ba;A++)x+="<td class='fc- fc-col"+
-A+" "+O+"'><div><div class='fc-day-content'><div style='position:relative'>&nbsp;</div></div></div></td>";x+="<td class='fc-agenda-gutter "+O+"'>&nbsp;</td></tr></tbody></table>";v=m(x).appendTo(a);F=v.find("thead");r=F.find("th").slice(1,-1);J=v.find("tbody");M=J.find("td").slice(0,-1);k=M.find("div.fc-day-content div");D=M.eq(0);Z=D.find("> div");ab(F.add(F.find("tr")));ab(J.add(J.find("tr")));aa=F.find("th:first");va=v.find(".fc-agenda-gutter");ja=m("<div style='position:absolute;z-index:2;left:0;width:100%'/>").appendTo(a);
-if(i("allDaySlot")){ia=m("<div style='position:absolute;z-index:8;top:0;left:0'/>").appendTo(ja);x="<table style='width:100%' class='fc-agenda-allday' cellspacing='0'><tr><th class='"+h+" fc-agenda-axis'>"+i("allDayText")+"</th><td><div class='fc-day-content'><div style='position:relative'/></div></td><th class='"+h+" fc-agenda-gutter'>&nbsp;</th></tr></table>";la=m(x).appendTo(ja);$=la.find("tr");q($.find("td"));aa=aa.add(la.find("th:first"));va=va.add(la.find("th.fc-agenda-gutter"));ja.append("<div class='fc-agenda-divider "+
-h+"'><div class='fc-agenda-divider-inner'/></div>")}else ia=m([]);w=m("<div style='position:absolute;width:100%;overflow-x:hidden;overflow-y:auto'/>").appendTo(ja);I=m("<div style='position:relative;width:100%;overflow:hidden'/>").appendTo(w);R=m("<div style='position:absolute;z-index:8;top:0;left:0'/>").appendTo(I);x="<table class='fc-agenda-slots' style='width:100%' cellspacing='0'><tbody>";ta=zb();za=xa(N(ta),bb);xa(ta,La);for(A=tb=0;ta<za;A++){Da=ta.getMinutes();x+="<tr class='fc-slot"+A+" "+
-(!Da?"":"fc-minor")+"'><th class='fc-agenda-axis "+h+"'>"+(!Ea||!Da?s(ta,i("axisFormat")):"&nbsp;")+"</th><td class='"+O+"'><div style='position:relative'>&nbsp;</div></td></tr>";xa(ta,i("slotMinutes"));tb++}x+="</tbody></table>";V=m(x).appendTo(I);ea=V.find("div:first");u(V.find("td"));aa=aa.add(V.find("th:first"))}function l(){var h,O,x,A,ta=Ka(new Date);for(h=0;h<Ba;h++){A=ua(h);O=r.eq(h);O.html(s(A,Vb));x=M.eq(h);+A==+ta?x.addClass(Wa+"-state-highlight fc-today"):x.removeClass(Wa+"-state-highlight fc-today");
-rb(O.add(x),A)}}function j(h,O){if(h===ma)h=Wb;Wb=h;ub={};var x=J.position().top,A=w.position().top;h=Math.min(h-x,V.height()+A+1);Z.height(h-Sa(D));ja.css("top",x);w.height(h-A-1);Xa=ea.height()+1;O&&y()}function t(h){Ga=h;cb.clear();Ma=0;Va(aa.width("").each(function(O,x){Ma=Math.max(Ma,m(x).outerWidth())}),Ma);h=w[0].clientWidth;if(vb=w.width()-h){Va(va,vb);va.show().prev().removeClass("fc-last")}else va.hide().prev().addClass("fc-last");db=Math.floor((h-Ma)/Ba);Va(r.slice(0,-1),db)}function y(){function h(){w.scrollTop(A)}
-var O=zb(),x=N(O);x.setHours(i("firstHour"));var A=ca(O,x)+1;h();setTimeout(h,0)}function S(){Xb=w.scrollTop()}function Q(){w.scrollTop(Xb)}function q(h){h.click(fa).mousedown(W)}function u(h){h.click(fa).mousedown(H)}function fa(h){if(!i("selectable")){var O=Math.min(Ba-1,Math.floor((h.pageX-v.offset().left-Ma)/db)),x=ua(O),A=this.parentNode.className.match(/fc-slot(\d+)/);if(A){A=parseInt(A[1])*i("slotMinutes");var ta=Math.floor(A/60);x.setHours(ta);x.setMinutes(A%60+La);C("dayClick",M[O],x,false,
-h)}else C("dayClick",M[O],x,true,h)}}function oa(h,O,x){x&&Na.build();var A=N(K.visStart);if(Ub){x=Ca(O,A)*Ha+Ia+1;h=Ca(h,A)*Ha+Ia+1}else{x=Ca(h,A);h=Ca(O,A)}x=Math.max(0,x);h=Math.min(Ba,h);x<h&&q(ga(0,x,0,h-1))}function ga(h,O,x,A){h=Na.rect(h,O,x,A,ja);return E(h,ja)}function ra(h,O){for(var x=N(K.visStart),A=ba(N(x),1),ta=0;ta<Ba;ta++){var za=new Date(Math.max(x,h)),Da=new Date(Math.min(A,O));if(za<Da){var Ea=ta*Ha+Ia;Ea=Na.rect(0,Ea,0,Ea,I);za=ca(x,za);Da=ca(x,Da);Ea.top=za;Ea.height=Da-za;u(E(Ea,
-I))}ba(x,1);ba(A,1)}}function sa(h){return cb.left(h)}function ha(h){return cb.right(h)}function da(h){return{row:Math.floor(Ca(h,K.visStart)/7),col:U(h.getDay())}}function na(h){var O=ua(h.col);h=h.row;i("allDaySlot")&&h--;h>=0&&xa(O,La+h*i("slotMinutes"));return O}function ua(h){return ba(N(K.visStart),h*Ha+Ia)}function pa(h){return i("allDaySlot")&&!h.row}function U(h){return(h-Math.max(Tb,Sb)+Ba)%Ba*Ha+Ia}function ca(h,O){h=N(h,true);if(O<xa(N(h),La))return 0;if(O>=xa(N(h),bb))return V.height();
-h=i("slotMinutes");O=O.getHours()*60+O.getMinutes()-La;var x=Math.floor(O/h),A=ub[x];if(A===ma)A=ub[x]=V.find("tr:eq("+x+") td div")[0].offsetTop;return Math.max(0,Math.round(A-1+Xa*(O%h/h)))}function ka(){return{left:Ma,right:Ga-vb}}function qa(){return $}function G(h){var O=N(h.start);if(h.allDay)return O;return xa(O,i("defaultEventMinutes"))}function p(h,O){if(O)return N(h);return xa(N(h),i("slotMinutes"))}function L(h,O,x){if(x)i("allDaySlot")&&oa(h,ba(N(O),1),true);else c(h,O)}function c(h,O){var x=
-i("selectHelper");Na.build();if(x){var A=Ca(h,K.visStart)*Ha+Ia;if(A>=0&&A<Ba){A=Na.rect(0,A,0,A,I);var ta=ca(h,h),za=ca(h,O);if(za>ta){A.top=ta;A.height=za-ta;A.left+=2;A.width-=5;if(m.isFunction(x)){if(h=x(h,O)){A.position="absolute";A.zIndex=8;wa=m(h).css(A).appendTo(I)}}else{A.isStart=true;A.isEnd=true;wa=m(o({title:"",start:h,end:O,className:["fc-select-helper"],editable:false},A));wa.css("opacity",i("dragOpacity"))}if(wa){u(wa);I.append(wa);Va(wa,A.width,true);Eb(wa,A.height,true)}}}}else ra(h,
-O)}function z(){B();if(wa){wa.remove();wa=null}}function H(h){if(h.which==1&&i("selectable")){Y(h);var O;Ra.start(function(x,A){z();if(x&&x.col==A.col&&!pa(x)){A=na(A);x=na(x);O=[A,xa(N(A),i("slotMinutes")),x,xa(N(x),i("slotMinutes"))].sort(Gb);c(O[0],O[3])}else O=null},h);m(document).one("mouseup",function(x){Ra.stop();if(O){+O[0]==+O[1]&&T(O[0],false,x);n(O[0],O[3],false,x)}})}}function T(h,O,x){C("dayClick",M[U(h.getDay())],h,O,x)}function X(h,O){Ra.start(function(x){B();if(x)if(pa(x))ga(x.row,
-x.col,x.row,x.col);else{x=na(x);var A=xa(N(x),i("defaultEventMinutes"));ra(x,A)}},O)}function ya(h,O,x){var A=Ra.stop();B();A&&C("drop",h,na(A),pa(A),O,x)}var K=this;K.renderAgenda=d;K.setWidth=t;K.setHeight=j;K.beforeHide=S;K.afterShow=Q;K.defaultEventEnd=G;K.timePosition=ca;K.dayOfWeekCol=U;K.dateCell=da;K.cellDate=na;K.cellIsAllDay=pa;K.allDayRow=qa;K.allDayBounds=ka;K.getHoverListener=function(){return Ra};K.colContentLeft=sa;K.colContentRight=ha;K.getDaySegmentContainer=function(){return ia};
-K.getSlotSegmentContainer=function(){return R};K.getMinMinute=function(){return La};K.getMaxMinute=function(){return bb};K.getBodyContent=function(){return I};K.getRowCnt=function(){return 1};K.getColCnt=function(){return Ba};K.getColWidth=function(){return db};K.getSlotHeight=function(){return Xa};K.defaultSelectionEnd=p;K.renderDayOverlay=oa;K.renderSelection=L;K.clearSelection=z;K.reportDayClick=T;K.dragStart=X;K.dragStop=ya;Kb.call(K,a,b,e);Lb.call(K);Mb.call(K);sc.call(K);var i=K.opt,C=K.trigger,
-P=K.clearEvents,E=K.renderOverlay,B=K.clearOverlays,n=K.reportSelection,Y=K.unselect,W=K.daySelectionMousedown,o=K.slotSegHtml,s=b.formatDate,v,F,r,J,M,k,D,Z,ja,ia,la,$,w,I,R,V,ea,aa,va,wa,Ga,Wb,Ma,db,vb,Xa,Xb,Ba,tb,Na,Ra,cb,ub={},Wa,Tb,Sb,Ub,Ha,Ia,La,bb,Vb;qb(a.addClass("fc-agenda"));Na=new Nb(function(h,O){function x(eb){return Math.max(Ea,Math.min(tc,eb))}var A,ta,za;r.each(function(eb,uc){A=m(uc);ta=A.offset().left;if(eb)za[1]=ta;za=[ta];O[eb]=za});za[1]=ta+A.outerWidth();if(i("allDaySlot")){A=
-$;ta=A.offset().top;h[0]=[ta,ta+A.outerHeight()]}for(var Da=I.offset().top,Ea=w.offset().top,tc=Ea+w.outerHeight(),fb=0;fb<tb;fb++)h.push([x(Da+Xa*fb),x(Da+Xa*(fb+1))])});Ra=new Ob(Na);cb=new Pb(function(h){return k.eq(h)})}function sc(){function a(o,s){sa(o);var v,F=o.length,r=[],J=[];for(v=0;v<F;v++)o[v].allDay?r.push(o[v]):J.push(o[v]);if(u("allDaySlot")){L(e(r),s);na()}g(d(J),s)}function b(){ha();ua().empty();pa().empty()}function e(o){o=ob(nb(o,m.map(o,Ua),q.visStart,q.visEnd));var s,v=o.length,
-F,r,J,M=[];for(s=0;s<v;s++){F=o[s];for(r=0;r<F.length;r++){J=F[r];J.row=0;J.level=s;M.push(J)}}return M}function d(o){var s=z(),v=ka(),F=ca(),r=xa(N(q.visStart),v),J=m.map(o,f),M,k,D,Z,ja,ia,la=[];for(M=0;M<s;M++){k=ob(nb(o,J,r,xa(N(r),F-v)));vc(k);for(D=0;D<k.length;D++){Z=k[D];for(ja=0;ja<Z.length;ja++){ia=Z[ja];ia.col=M;ia.level=D;la.push(ia)}}ba(r,1,true)}return la}function f(o){return o.end?N(o.end):xa(N(o.start),u("defaultEventMinutes"))}function g(o,s){var v,F=o.length,r,J,M,k,D,Z,ja,ia,la,
-$="",w,I,R={},V={},ea=pa(),aa;v=z();if(w=u("isRTL")){I=-1;aa=v-1}else{I=1;aa=0}for(v=0;v<F;v++){r=o[v];J=r.event;M=qa(r.start,r.start);k=qa(r.start,r.end);D=r.col;Z=r.level;ja=r.forward||0;ia=G(D*I+aa);la=p(D*I+aa)-ia;la=Math.min(la-6,la*0.95);D=Z?la/(Z+ja+1):ja?(la/(ja+1)-6)*2:la;Z=ia+la/(Z+ja+1)*Z*I+(w?la-D:0);r.top=M;r.left=Z;r.outerWidth=D;r.outerHeight=k-M;$+=l(J,r)}ea[0].innerHTML=$;w=ea.children();for(v=0;v<F;v++){r=o[v];J=r.event;$=m(w[v]);I=fa("eventRender",J,J,$);if(I===false)$.remove();
-else{if(I&&I!==true){$.remove();$=m(I).css({position:"absolute",top:r.top,left:r.left}).appendTo(ea)}r.element=$;if(J._id===s)t(J,$,r);else $[0]._fci=v;ya(J,$)}}Db(ea,o,t);for(v=0;v<F;v++){r=o[v];if($=r.element){J=R[s=r.key=Ib($[0])];r.vsides=J===ma?(R[s]=Sa($,true)):J;J=V[s];r.hsides=J===ma?(V[s]=pb($,true)):J;s=$.find("div.fc-event-content");if(s.length)r.contentTop=s[0].offsetTop}}for(v=0;v<F;v++){r=o[v];if($=r.element){$[0].style.width=Math.max(0,r.outerWidth-r.hsides)+"px";R=Math.max(0,r.outerHeight-
-r.vsides);$[0].style.height=R+"px";J=r.event;if(r.contentTop!==ma&&R-r.contentTop<10){$.find("div.fc-event-time").text(Y(J.start,u("timeFormat"))+" - "+J.title);$.find("div.fc-event-title").remove()}fa("eventAfterRender",J,J,$)}}}function l(o,s){var v="<",F=o.url,r=Jb(o,u),J=r?" style='"+r+"'":"",M=["fc-event","fc-event-skin","fc-event-vert"];oa(o)&&M.push("fc-event-draggable");s.isStart&&M.push("fc-corner-top");s.isEnd&&M.push("fc-corner-bottom");M=M.concat(o.className);if(o.source)M=M.concat(o.source.className||
-[]);v+=F?"a href='"+Qa(o.url)+"'":"div";v+=" class='"+M.join(" ")+"' style='position:absolute;z-index:8;top:"+s.top+"px;left:"+s.left+"px;"+r+"'><div class='fc-event-inner fc-event-skin'"+J+"><div class='fc-event-head fc-event-skin'"+J+"><div class='fc-event-time'>"+Qa(W(o.start,o.end,u("timeFormat")))+"</div></div><div class='fc-event-content'><div class='fc-event-title'>"+Qa(o.title)+"</div></div><div class='fc-event-bg'></div></div>";if(s.isEnd&&ga(o))v+="<div class='ui-resizable-handle ui-resizable-s'>=</div>";
-v+="</"+(F?"a":"div")+">";return v}function j(o,s,v){oa(o)&&y(o,s,v.isStart);v.isEnd&&ga(o)&&c(o,s,v);da(o,s)}function t(o,s,v){var F=s.find("div.fc-event-time");oa(o)&&S(o,s,F);v.isEnd&&ga(o)&&Q(o,s,F);da(o,s)}function y(o,s,v){function F(){if(!M){s.width(r).height("").draggable("option","grid",null);M=true}}var r,J,M=true,k,D=u("isRTL")?-1:1,Z=U(),ja=H(),ia=T(),la=ka();s.draggable({zIndex:9,opacity:u("dragOpacity","month"),revertDuration:u("dragRevertDuration"),start:function($,w){fa("eventDragStart",
-s,o,$,w);i(o,s);r=s.width();Z.start(function(I,R,V,ea){B();if(I){J=false;k=ea*D;if(I.row)if(v){if(M){s.width(ja-10);Eb(s,ia*Math.round((o.end?(o.end-o.start)/wc:u("defaultEventMinutes"))/u("slotMinutes")));s.draggable("option","grid",[ja,1]);M=false}}else J=true;else{E(ba(N(o.start),k),ba(Ua(o),k));F()}J=J||M&&!k}else{F();J=true}s.draggable("option","revert",J)},$,"drag")},stop:function($,w){Z.stop();B();fa("eventDragStop",s,o,$,w);if(J){F();s.css("filter","");K(o,s)}else{var I=0;M||(I=Math.round((s.offset().top-
-X().offset().top)/ia)*u("slotMinutes")+la-(o.start.getHours()*60+o.start.getMinutes()));C(this,o,k,I,M,$,w)}}})}function S(o,s,v){function F(I){var R=xa(N(o.start),I),V;if(o.end)V=xa(N(o.end),I);v.text(W(R,V,u("timeFormat")))}function r(){if(M){v.css("display","");s.draggable("option","grid",[$,w]);M=false}}var J,M=false,k,D,Z,ja=u("isRTL")?-1:1,ia=U(),la=z(),$=H(),w=T();s.draggable({zIndex:9,scroll:false,grid:[$,w],axis:la==1?"y":false,opacity:u("dragOpacity"),revertDuration:u("dragRevertDuration"),
-start:function(I,R){fa("eventDragStart",s,o,I,R);i(o,s);J=s.position();D=Z=0;ia.start(function(V,ea,aa,va){s.draggable("option","revert",!V);B();if(V){k=va*ja;if(u("allDaySlot")&&!V.row){if(!M){M=true;v.hide();s.draggable("option","grid",null)}E(ba(N(o.start),k),ba(Ua(o),k))}else r()}},I,"drag")},drag:function(I,R){D=Math.round((R.position.top-J.top)/w)*u("slotMinutes");if(D!=Z){M||F(D);Z=D}},stop:function(I,R){var V=ia.stop();B();fa("eventDragStop",s,o,I,R);if(V&&(k||D||M))C(this,o,k,M?0:D,M,I,R);
-else{r();s.css("filter","");s.css(J);F(0);K(o,s)}}})}function Q(o,s,v){var F,r,J=T();s.resizable({handles:{s:"div.ui-resizable-s"},grid:J,start:function(M,k){F=r=0;i(o,s);s.css("z-index",9);fa("eventResizeStart",this,o,M,k)},resize:function(M,k){F=Math.round((Math.max(J,s.height())-k.originalSize.height)/J);if(F!=r){v.text(W(o.start,!F&&!o.end?null:xa(ra(o),u("slotMinutes")*F),u("timeFormat")));r=F}},stop:function(M,k){fa("eventResizeStop",this,o,M,k);if(F)P(this,o,0,u("slotMinutes")*F,M,k);else{s.css("z-index",
-8);K(o,s)}}})}var q=this;q.renderEvents=a;q.compileDaySegs=e;q.clearEvents=b;q.slotSegHtml=l;q.bindDaySeg=j;Qb.call(q);var u=q.opt,fa=q.trigger,oa=q.isEventDraggable,ga=q.isEventResizable,ra=q.eventEnd,sa=q.reportEvents,ha=q.reportEventClear,da=q.eventElementHandlers,na=q.setHeight,ua=q.getDaySegmentContainer,pa=q.getSlotSegmentContainer,U=q.getHoverListener,ca=q.getMaxMinute,ka=q.getMinMinute,qa=q.timePosition,G=q.colContentLeft,p=q.colContentRight,L=q.renderDaySegs,c=q.resizableDayEvent,z=q.getColCnt,
-H=q.getColWidth,T=q.getSlotHeight,X=q.getBodyContent,ya=q.reportEventElement,K=q.showEvents,i=q.hideEvents,C=q.eventDrop,P=q.eventResize,E=q.renderDayOverlay,B=q.clearOverlays,n=q.calendar,Y=n.formatDate,W=n.formatDates}function vc(a){var b,e,d,f,g,l;for(b=a.length-1;b>0;b--){f=a[b];for(e=0;e<f.length;e++){g=f[e];for(d=0;d<a[b-1].length;d++){l=a[b-1][d];if(Cb(g,l))l.forward=Math.max(l.forward||0,(g.forward||0)+1)}}}}function Kb(a,b,e){function d(G,p){G=qa[G];if(typeof G=="object")return jb(G,p||e);
-return G}function f(G,p){return b.trigger.apply(b,[G,p||da].concat(Array.prototype.slice.call(arguments,2),[da]))}function g(G){return j(G)&&!d("disableDragging")}function l(G){return j(G)&&!d("disableResizing")}function j(G){return Ta(G.editable,(G.source||{}).editable,d("editable"))}function t(G){U={};var p,L=G.length,c;for(p=0;p<L;p++){c=G[p];if(U[c._id])U[c._id].push(c);else U[c._id]=[c]}}function y(G){return G.end?N(G.end):na(G)}function S(G,p){ca.push(p);if(ka[G._id])ka[G._id].push(p);else ka[G._id]=
-[p]}function Q(){ca=[];ka={}}function q(G,p){p.click(function(L){if(!p.hasClass("ui-draggable-dragging")&&!p.hasClass("ui-resizable-resizing"))return f("eventClick",this,G,L)}).hover(function(L){f("eventMouseover",this,G,L)},function(L){f("eventMouseout",this,G,L)})}function u(G,p){oa(G,p,"show")}function fa(G,p){oa(G,p,"hide")}function oa(G,p,L){G=ka[G._id];var c,z=G.length;for(c=0;c<z;c++)if(!p||G[c][0]!=p[0])G[c][L]()}function ga(G,p,L,c,z,H,T){var X=p.allDay,ya=p._id;sa(U[ya],L,c,z);f("eventDrop",
-G,p,L,c,z,function(){sa(U[ya],-L,-c,X);pa(ya)},H,T);pa(ya)}function ra(G,p,L,c,z,H){var T=p._id;ha(U[T],L,c);f("eventResize",G,p,L,c,function(){ha(U[T],-L,-c);pa(T)},z,H);pa(T)}function sa(G,p,L,c){L=L||0;for(var z,H=G.length,T=0;T<H;T++){z=G[T];if(c!==ma)z.allDay=c;xa(ba(z.start,p,true),L);if(z.end)z.end=xa(ba(z.end,p,true),L);ua(z,qa)}}function ha(G,p,L){L=L||0;for(var c,z=G.length,H=0;H<z;H++){c=G[H];c.end=xa(ba(y(c),p,true),L);ua(c,qa)}}var da=this;da.element=a;da.calendar=b;da.name=e;da.opt=
-d;da.trigger=f;da.isEventDraggable=g;da.isEventResizable=l;da.reportEvents=t;da.eventEnd=y;da.reportEventElement=S;da.reportEventClear=Q;da.eventElementHandlers=q;da.showEvents=u;da.hideEvents=fa;da.eventDrop=ga;da.eventResize=ra;var na=da.defaultEventEnd,ua=b.normalizeEvent,pa=b.reportEventChange,U={},ca=[],ka={},qa=b.options}function Qb(){function a(i,C){var P=z(),E=pa(),B=U(),n=0,Y,W,o=i.length,s,v;P[0].innerHTML=e(i);d(i,P.children());f(i);g(i,P,C);l(i);j(i);t(i);C=y();for(P=0;P<E;P++){Y=[];for(W=
-0;W<B;W++)Y[W]=0;for(;n<o&&(s=i[n]).row==P;){W=Hb(Y.slice(s.startCol,s.endCol));s.top=W;W+=s.outerHeight;for(v=s.startCol;v<s.endCol;v++)Y[v]=W;n++}C[P].height(Hb(Y))}Q(i,S(C))}function b(i,C,P){var E=m("<div/>"),B=z(),n=i.length,Y;E[0].innerHTML=e(i);E=E.children();B.append(E);d(i,E);l(i);j(i);t(i);Q(i,S(y()));E=[];for(B=0;B<n;B++)if(Y=i[B].element){i[B].row===C&&Y.css("top",P);E.push(Y[0])}return m(E)}function e(i){var C=fa("isRTL"),P,E=i.length,B,n,Y,W;P=ka();var o=P.left,s=P.right,v,F,r,J,M,k=
-"";for(P=0;P<E;P++){B=i[P];n=B.event;W=["fc-event","fc-event-skin","fc-event-hori"];ga(n)&&W.push("fc-event-draggable");if(C){B.isStart&&W.push("fc-corner-right");B.isEnd&&W.push("fc-corner-left");v=p(B.end.getDay()-1);F=p(B.start.getDay());r=B.isEnd?qa(v):o;J=B.isStart?G(F):s}else{B.isStart&&W.push("fc-corner-left");B.isEnd&&W.push("fc-corner-right");v=p(B.start.getDay());F=p(B.end.getDay()-1);r=B.isStart?qa(v):o;J=B.isEnd?G(F):s}W=W.concat(n.className);if(n.source)W=W.concat(n.source.className||
-[]);Y=n.url;M=Jb(n,fa);k+=Y?"<a href='"+Qa(Y)+"'":"<div";k+=" class='"+W.join(" ")+"' style='position:absolute;z-index:8;left:"+r+"px;"+M+"'><div class='fc-event-inner fc-event-skin'"+(M?" style='"+M+"'":"")+">";if(!n.allDay&&B.isStart)k+="<span class='fc-event-time'>"+Qa(T(n.start,n.end,fa("timeFormat")))+"</span>";k+="<span class='fc-event-title'>"+Qa(n.title)+"</span></div>";if(B.isEnd&&ra(n))k+="<div class='ui-resizable-handle ui-resizable-"+(C?"w":"e")+"'>&nbsp;&nbsp;&nbsp;</div>";k+="</"+(Y?
-"a":"div")+">";B.left=r;B.outerWidth=J-r;B.startCol=v;B.endCol=F+1}return k}function d(i,C){var P,E=i.length,B,n,Y;for(P=0;P<E;P++){B=i[P];n=B.event;Y=m(C[P]);n=oa("eventRender",n,n,Y);if(n===false)Y.remove();else{if(n&&n!==true){n=m(n).css({position:"absolute",left:B.left});Y.replaceWith(n);Y=n}B.element=Y}}}function f(i){var C,P=i.length,E,B;for(C=0;C<P;C++){E=i[C];(B=E.element)&&ha(E.event,B)}}function g(i,C,P){var E,B=i.length,n,Y,W;for(E=0;E<B;E++){n=i[E];if(Y=n.element){W=n.event;if(W._id===
-P)H(W,Y,n);else Y[0]._fci=E}}Db(C,i,H)}function l(i){var C,P=i.length,E,B,n,Y,W={};for(C=0;C<P;C++){E=i[C];if(B=E.element){n=E.key=Ib(B[0]);Y=W[n];if(Y===ma)Y=W[n]=pb(B,true);E.hsides=Y}}}function j(i){var C,P=i.length,E,B;for(C=0;C<P;C++){E=i[C];if(B=E.element)B[0].style.width=Math.max(0,E.outerWidth-E.hsides)+"px"}}function t(i){var C,P=i.length,E,B,n,Y,W={};for(C=0;C<P;C++){E=i[C];if(B=E.element){n=E.key;Y=W[n];if(Y===ma)Y=W[n]=Fb(B);E.outerHeight=B[0].offsetHeight+Y}}}function y(){var i,C=pa(),
-P=[];for(i=0;i<C;i++)P[i]=ca(i).find("td:first div.fc-day-content > div");return P}function S(i){var C,P=i.length,E=[];for(C=0;C<P;C++)E[C]=i[C][0].offsetTop;return E}function Q(i,C){var P,E=i.length,B,n;for(P=0;P<E;P++){B=i[P];if(n=B.element){n[0].style.top=C[B.row]+(B.top||0)+"px";B=B.event;oa("eventAfterRender",B,B,n)}}}function q(i,C,P){var E=fa("isRTL"),B=E?"w":"e",n=C.find("div.ui-resizable-"+B),Y=false;qb(C);C.mousedown(function(W){W.preventDefault()}).click(function(W){if(Y){W.preventDefault();
-W.stopImmediatePropagation()}});n.mousedown(function(W){function o(ia){oa("eventResizeStop",this,i,ia);m("body").css("cursor","");s.stop();ya();k&&ua(this,i,k,0,ia);setTimeout(function(){Y=false},0)}if(W.which==1){Y=true;var s=u.getHoverListener(),v=pa(),F=U(),r=E?-1:1,J=E?F-1:0,M=C.css("top"),k,D,Z=m.extend({},i),ja=L(i.start);K();m("body").css("cursor",B+"-resize").one("mouseup",o);oa("eventResizeStart",this,i,W);s.start(function(ia,la){if(ia){var $=Math.max(ja.row,ia.row);ia=ia.col;if(v==1)$=0;
-if($==ja.row)ia=E?Math.min(ja.col,ia):Math.max(ja.col,ia);k=$*7+ia*r+J-(la.row*7+la.col*r+J);la=ba(sa(i),k,true);if(k){Z.end=la;$=D;D=b(c([Z]),P.row,M);D.find("*").css("cursor",B+"-resize");$&&$.remove();na(i)}else if(D){da(i);D.remove();D=null}ya();X(i.start,ba(N(la),1))}},W)}})}var u=this;u.renderDaySegs=a;u.resizableDayEvent=q;var fa=u.opt,oa=u.trigger,ga=u.isEventDraggable,ra=u.isEventResizable,sa=u.eventEnd,ha=u.reportEventElement,da=u.showEvents,na=u.hideEvents,ua=u.eventResize,pa=u.getRowCnt,
-U=u.getColCnt,ca=u.allDayRow,ka=u.allDayBounds,qa=u.colContentLeft,G=u.colContentRight,p=u.dayOfWeekCol,L=u.dateCell,c=u.compileDaySegs,z=u.getDaySegmentContainer,H=u.bindDaySeg,T=u.calendar.formatDates,X=u.renderDayOverlay,ya=u.clearOverlays,K=u.clearSelection}function Mb(){function a(Q,q,u){b();q||(q=j(Q,u));t(Q,q,u);e(Q,q,u)}function b(Q){if(S){S=false;y();l("unselect",null,Q)}}function e(Q,q,u,fa){S=true;l("select",null,Q,q,u,fa)}function d(Q){var q=f.cellDate,u=f.cellIsAllDay,fa=f.getHoverListener(),
-oa=f.reportDayClick;if(Q.which==1&&g("selectable")){b(Q);var ga;fa.start(function(ra,sa){y();if(ra&&u(ra)){ga=[q(sa),q(ra)].sort(Gb);t(ga[0],ga[1],true)}else ga=null},Q);m(document).one("mouseup",function(ra){fa.stop();if(ga){+ga[0]==+ga[1]&&oa(ga[0],true,ra);e(ga[0],ga[1],true,ra)}})}}var f=this;f.select=a;f.unselect=b;f.reportSelection=e;f.daySelectionMousedown=d;var g=f.opt,l=f.trigger,j=f.defaultSelectionEnd,t=f.renderSelection,y=f.clearSelection,S=false;g("selectable")&&g("unselectAuto")&&m(document).mousedown(function(Q){var q=
-g("unselectCancel");if(q)if(m(Q.target).parents(q).length)return;b(Q)})}function Lb(){function a(g,l){var j=f.shift();j||(j=m("<div class='fc-cell-overlay' style='position:absolute;z-index:3'/>"));j[0].parentNode!=l[0]&&j.appendTo(l);d.push(j.css(g).show());return j}function b(){for(var g;g=d.shift();)f.push(g.hide().unbind())}var e=this;e.renderOverlay=a;e.clearOverlays=b;var d=[],f=[]}function Nb(a){var b=this,e,d;b.build=function(){e=[];d=[];a(e,d)};b.cell=function(f,g){var l=e.length,j=d.length,
-t,y=-1,S=-1;for(t=0;t<l;t++)if(g>=e[t][0]&&g<e[t][1]){y=t;break}for(t=0;t<j;t++)if(f>=d[t][0]&&f<d[t][1]){S=t;break}return y>=0&&S>=0?{row:y,col:S}:null};b.rect=function(f,g,l,j,t){t=t.offset();return{top:e[f][0]-t.top,left:d[g][0]-t.left,width:d[j][1]-d[g][0],height:e[l][1]-e[f][0]}}}function Ob(a){function b(j){xc(j);j=a.cell(j.pageX,j.pageY);if(!j!=!l||j&&(j.row!=l.row||j.col!=l.col)){if(j){g||(g=j);f(j,g,j.row-g.row,j.col-g.col)}else f(j,g);l=j}}var e=this,d,f,g,l;e.start=function(j,t,y){f=j;
-g=l=null;a.build();b(t);d=y||"mousemove";m(document).bind(d,b)};e.stop=function(){m(document).unbind(d,b);return l}}function xc(a){if(a.pageX===ma){a.pageX=a.originalEvent.pageX;a.pageY=a.originalEvent.pageY}}function Pb(a){function b(l){return d[l]=d[l]||a(l)}var e=this,d={},f={},g={};e.left=function(l){return f[l]=f[l]===ma?b(l).position().left:f[l]};e.right=function(l){return g[l]=g[l]===ma?e.left(l)+b(l).width():g[l]};e.clear=function(){d={};f={};g={}}}var Ya={defaultView:"month",aspectRatio:1.35,
-header:{left:"title",center:"",right:"today prev,next"},weekends:true,allDayDefault:true,ignoreTimezone:true,lazyFetching:true,startParam:"start",endParam:"end",titleFormat:{month:"MMMM yyyy",week:"MMM d[ yyyy]{ '&#8212;'[ MMM] d yyyy}",day:"dddd, MMM d, yyyy"},columnFormat:{month:"ddd",week:"ddd M/d",day:"dddd M/d"},timeFormat:{"":"h(:mm)t"},isRTL:false,firstDay:0,monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan",
-"Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],buttonText:{prev:"&nbsp;&#9668;&nbsp;",next:"&nbsp;&#9658;&nbsp;",prevYear:"&nbsp;&lt;&lt;&nbsp;",nextYear:"&nbsp;&gt;&gt;&nbsp;",today:"today",month:"month",week:"week",day:"day"},theme:false,buttonIcons:{prev:"circle-triangle-w",next:"circle-triangle-e"},unselectAuto:true,dropAccept:"*"},yc=
-{header:{left:"next,prev today",center:"",right:"title"},buttonText:{prev:"&nbsp;&#9658;&nbsp;",next:"&nbsp;&#9668;&nbsp;",prevYear:"&nbsp;&gt;&gt;&nbsp;",nextYear:"&nbsp;&lt;&lt;&nbsp;"},buttonIcons:{prev:"circle-triangle-e",next:"circle-triangle-w"}},Aa=m.fullCalendar={version:"1.5.3"},Ja=Aa.views={};m.fn.fullCalendar=function(a){if(typeof a=="string"){var b=Array.prototype.slice.call(arguments,1),e;this.each(function(){var f=m.data(this,"fullCalendar");if(f&&m.isFunction(f[a])){f=f[a].apply(f,
-b);if(e===ma)e=f;a=="destroy"&&m.removeData(this,"fullCalendar")}});if(e!==ma)return e;return this}var d=a.eventSources||[];delete a.eventSources;if(a.events){d.push(a.events);delete a.events}a=m.extend(true,{},Ya,a.isRTL||a.isRTL===ma&&Ya.isRTL?yc:{},a);this.each(function(f,g){f=m(g);g=new Yb(f,a,d);f.data("fullCalendar",g);g.render()});return this};Aa.sourceNormalizers=[];Aa.sourceFetchers=[];var ac={dataType:"json",cache:false},bc=1;Aa.addDays=ba;Aa.cloneDate=N;Aa.parseDate=kb;Aa.parseISO8601=
-Bb;Aa.parseTime=mb;Aa.formatDate=Oa;Aa.formatDates=ib;var lc=["sun","mon","tue","wed","thu","fri","sat"],Ab=864E5,cc=36E5,wc=6E4,dc={s:function(a){return a.getSeconds()},ss:function(a){return Pa(a.getSeconds())},m:function(a){return a.getMinutes()},mm:function(a){return Pa(a.getMinutes())},h:function(a){return a.getHours()%12||12},hh:function(a){return Pa(a.getHours()%12||12)},H:function(a){return a.getHours()},HH:function(a){return Pa(a.getHours())},d:function(a){return a.getDate()},dd:function(a){return Pa(a.getDate())},
-ddd:function(a,b){return b.dayNamesShort[a.getDay()]},dddd:function(a,b){return b.dayNames[a.getDay()]},M:function(a){return a.getMonth()+1},MM:function(a){return Pa(a.getMonth()+1)},MMM:function(a,b){return b.monthNamesShort[a.getMonth()]},MMMM:function(a,b){return b.monthNames[a.getMonth()]},yy:function(a){return(a.getFullYear()+"").substring(2)},yyyy:function(a){return a.getFullYear()},t:function(a){return a.getHours()<12?"a":"p"},tt:function(a){return a.getHours()<12?"am":"pm"},T:function(a){return a.getHours()<
-12?"A":"P"},TT:function(a){return a.getHours()<12?"AM":"PM"},u:function(a){return Oa(a,"yyyy-MM-dd'T'HH:mm:ss'Z'")},S:function(a){a=a.getDate();if(a>10&&a<20)return"th";return["st","nd","rd"][a%10-1]||"th"}};Aa.applyAll=$a;Ja.month=mc;Ja.basicWeek=nc;Ja.basicDay=oc;wb({weekMode:"fixed"});Ja.agendaWeek=qc;Ja.agendaDay=rc;wb({allDaySlot:true,allDayText:"all-day",firstHour:6,slotMinutes:30,defaultEventMinutes:120,axisFormat:"h(:mm)tt",timeFormat:{agenda:"h:mm{ - h:mm}"},dragOpacity:{agenda:0.5},minTime:0,
-maxTime:24})})(jQuery);
+/*!
+ * FullCalendar v1.6.4
+ * Docs & License: http://arshaw.com/fullcalendar/
+ * (c) 2013 Adam Shaw
+ */
+(function(t,e){function n(e){t.extend(!0,Ce,e)}function r(n,r,c){function u(t){ae?p()&&(S(),M(t)):f()}function f(){oe=r.theme?"ui":"fc",n.addClass("fc"),r.isRTL?n.addClass("fc-rtl"):n.addClass("fc-ltr"),r.theme&&n.addClass("ui-widget"),ae=t("<div class='fc-content' style='position:relative'/>").prependTo(n),ne=new a(ee,r),re=ne.render(),re&&n.prepend(re),y(r.defaultView),r.handleWindowResize&&t(window).resize(x),m()||v()}function v(){setTimeout(function(){!ie.start&&m()&&C()},0)}function h(){ie&&(te("viewDestroy",ie,ie,ie.element),ie.triggerEventDestroy()),t(window).unbind("resize",x),ne.destroy(),ae.remove(),n.removeClass("fc fc-rtl ui-widget")}function p(){return n.is(":visible")}function m(){return t("body").is(":visible")}function y(t){ie&&t==ie.name||D(t)}function D(e){he++,ie&&(te("viewDestroy",ie,ie,ie.element),Y(),ie.triggerEventDestroy(),G(),ie.element.remove(),ne.deactivateButton(ie.name)),ne.activateButton(e),ie=new Se[e](t("<div class='fc-view fc-view-"+e+"' style='position:relative'/>").appendTo(ae),ee),C(),$(),he--}function C(t){(!ie.start||t||ie.start>ge||ge>=ie.end)&&p()&&M(t)}function M(t){he++,ie.start&&(te("viewDestroy",ie,ie,ie.element),Y(),N()),G(),ie.render(ge,t||0),T(),$(),(ie.afterRender||A)(),_(),P(),te("viewRender",ie,ie,ie.element),ie.trigger("viewDisplay",de),he--,z()}function E(){p()&&(Y(),N(),S(),T(),F())}function S(){le=r.contentHeight?r.contentHeight:r.height?r.height-(re?re.height():0)-R(ae):Math.round(ae.width()/Math.max(r.aspectRatio,.5))}function T(){le===e&&S(),he++,ie.setHeight(le),ie.setWidth(ae.width()),he--,se=n.outerWidth()}function x(){if(!he)if(ie.start){var t=++ve;setTimeout(function(){t==ve&&!he&&p()&&se!=(se=n.outerWidth())&&(he++,E(),ie.trigger("windowResize",de),he--)},200)}else v()}function k(){N(),W()}function H(t){N(),F(t)}function F(t){p()&&(ie.setEventData(pe),ie.renderEvents(pe,t),ie.trigger("eventAfterAllRender"))}function N(){ie.triggerEventDestroy(),ie.clearEvents(),ie.clearEventData()}function z(){!r.lazyFetching||ue(ie.visStart,ie.visEnd)?W():F()}function W(){fe(ie.visStart,ie.visEnd)}function O(t){pe=t,F()}function L(t){H(t)}function _(){ne.updateTitle(ie.title)}function P(){var t=new Date;t>=ie.start&&ie.end>t?ne.disableButton("today"):ne.enableButton("today")}function q(t,n,r){ie.select(t,n,r===e?!0:r)}function Y(){ie&&ie.unselect()}function B(){C(-1)}function j(){C(1)}function I(){i(ge,-1),C()}function X(){i(ge,1),C()}function J(){ge=new Date,C()}function V(t,e,n){t instanceof Date?ge=d(t):g(ge,t,e,n),C()}function U(t,n,r){t!==e&&i(ge,t),n!==e&&s(ge,n),r!==e&&l(ge,r),C()}function Z(){return d(ge)}function G(){ae.css({width:"100%",height:ae.height(),overflow:"hidden"})}function $(){ae.css({width:"",height:"",overflow:""})}function Q(){return ie}function K(t,n){return n===e?r[t]:(("height"==t||"contentHeight"==t||"aspectRatio"==t)&&(r[t]=n,E()),e)}function te(t,n){return r[t]?r[t].apply(n||de,Array.prototype.slice.call(arguments,2)):e}var ee=this;ee.options=r,ee.render=u,ee.destroy=h,ee.refetchEvents=k,ee.reportEvents=O,ee.reportEventChange=L,ee.rerenderEvents=H,ee.changeView=y,ee.select=q,ee.unselect=Y,ee.prev=B,ee.next=j,ee.prevYear=I,ee.nextYear=X,ee.today=J,ee.gotoDate=V,ee.incrementDate=U,ee.formatDate=function(t,e){return w(t,e,r)},ee.formatDates=function(t,e,n){return b(t,e,n,r)},ee.getDate=Z,ee.getView=Q,ee.option=K,ee.trigger=te,o.call(ee,r,c);var ne,re,ae,oe,ie,se,le,ce,ue=ee.isFetchNeeded,fe=ee.fetchEvents,de=n[0],ve=0,he=0,ge=new Date,pe=[];g(ge,r.year,r.month,r.date),r.droppable&&t(document).bind("dragstart",function(e,n){var a=e.target,o=t(a);if(!o.parents(".fc").length){var i=r.dropAccept;(t.isFunction(i)?i.call(a,o):o.is(i))&&(ce=a,ie.dragStart(ce,e,n))}}).bind("dragstop",function(t,e){ce&&(ie.dragStop(ce,t,e),ce=null)})}function a(n,r){function a(){v=r.theme?"ui":"fc";var n=r.header;return n?h=t("<table class='fc-header' style='width:100%'/>").append(t("<tr/>").append(i("left")).append(i("center")).append(i("right"))):e}function o(){h.remove()}function i(e){var a=t("<td class='fc-header-"+e+"'/>"),o=r.header[e];return o&&t.each(o.split(" "),function(e){e>0&&a.append("<span class='fc-header-space'/>");var o;t.each(this.split(","),function(e,i){if("title"==i)a.append("<span class='fc-header-title'><h2>&nbsp;</h2></span>"),o&&o.addClass(v+"-corner-right"),o=null;else{var s;if(n[i]?s=n[i]:Se[i]&&(s=function(){u.removeClass(v+"-state-hover"),n.changeView(i)}),s){var l=r.theme?P(r.buttonIcons,i):null,c=P(r.buttonText,i),u=t("<span class='fc-button fc-button-"+i+" "+v+"-state-default'>"+(l?"<span class='fc-icon-wrap'><span class='ui-icon ui-icon-"+l+"'/>"+"</span>":c)+"</span>").click(function(){u.hasClass(v+"-state-disabled")||s()}).mousedown(function(){u.not("."+v+"-state-active").not("."+v+"-state-disabled").addClass(v+"-state-down")}).mouseup(function(){u.removeClass(v+"-state-down")}).hover(function(){u.not("."+v+"-state-active").not("."+v+"-state-disabled").addClass(v+"-state-hover")},function(){u.removeClass(v+"-state-hover").removeClass(v+"-state-down")}).appendTo(a);Y(u),o||u.addClass(v+"-corner-left"),o=u}}}),o&&o.addClass(v+"-corner-right")}),a}function s(t){h.find("h2").html(t)}function l(t){h.find("span.fc-button-"+t).addClass(v+"-state-active")}function c(t){h.find("span.fc-button-"+t).removeClass(v+"-state-active")}function u(t){h.find("span.fc-button-"+t).addClass(v+"-state-disabled")}function f(t){h.find("span.fc-button-"+t).removeClass(v+"-state-disabled")}var d=this;d.render=a,d.destroy=o,d.updateTitle=s,d.activateButton=l,d.deactivateButton=c,d.disableButton=u,d.enableButton=f;var v,h=t([])}function o(n,r){function a(t,e){return!E||E>t||e>S}function o(t,e){E=t,S=e,W=[];var n=++R,r=F.length;N=r;for(var a=0;r>a;a++)i(F[a],n)}function i(e,r){s(e,function(a){if(r==R){if(a){n.eventDataTransform&&(a=t.map(a,n.eventDataTransform)),e.eventDataTransform&&(a=t.map(a,e.eventDataTransform));for(var o=0;a.length>o;o++)a[o].source=e,w(a[o]);W=W.concat(a)}N--,N||k(W)}})}function s(r,a){var o,i,l=Ee.sourceFetchers;for(o=0;l.length>o;o++){if(i=l[o](r,E,S,a),i===!0)return;if("object"==typeof i)return s(i,a),e}var c=r.events;if(c)t.isFunction(c)?(m(),c(d(E),d(S),function(t){a(t),y()})):t.isArray(c)?a(c):a();else{var u=r.url;if(u){var f,v=r.success,h=r.error,g=r.complete;f=t.isFunction(r.data)?r.data():r.data;var p=t.extend({},f||{}),w=X(r.startParam,n.startParam),b=X(r.endParam,n.endParam);w&&(p[w]=Math.round(+E/1e3)),b&&(p[b]=Math.round(+S/1e3)),m(),t.ajax(t.extend({},Te,r,{data:p,success:function(e){e=e||[];var n=I(v,this,arguments);t.isArray(n)&&(e=n),a(e)},error:function(){I(h,this,arguments),a()},complete:function(){I(g,this,arguments),y()}}))}else a()}}function l(t){t=c(t),t&&(N++,i(t,R))}function c(n){return t.isFunction(n)||t.isArray(n)?n={events:n}:"string"==typeof n&&(n={url:n}),"object"==typeof n?(b(n),F.push(n),n):e}function u(e){F=t.grep(F,function(t){return!D(t,e)}),W=t.grep(W,function(t){return!D(t.source,e)}),k(W)}function f(t){var e,n,r=W.length,a=x().defaultEventEnd,o=t.start-t._start,i=t.end?t.end-(t._end||a(t)):0;for(e=0;r>e;e++)n=W[e],n._id==t._id&&n!=t&&(n.start=new Date(+n.start+o),n.end=t.end?n.end?new Date(+n.end+i):new Date(+a(n)+i):null,n.title=t.title,n.url=t.url,n.allDay=t.allDay,n.className=t.className,n.editable=t.editable,n.color=t.color,n.backgroundColor=t.backgroundColor,n.borderColor=t.borderColor,n.textColor=t.textColor,w(n));w(t),k(W)}function v(t,e){w(t),t.source||(e&&(H.events.push(t),t.source=H),W.push(t)),k(W)}function h(e){if(e){if(!t.isFunction(e)){var n=e+"";e=function(t){return t._id==n}}W=t.grep(W,e,!0);for(var r=0;F.length>r;r++)t.isArray(F[r].events)&&(F[r].events=t.grep(F[r].events,e,!0))}else{W=[];for(var r=0;F.length>r;r++)t.isArray(F[r].events)&&(F[r].events=[])}k(W)}function g(e){return t.isFunction(e)?t.grep(W,e):e?(e+="",t.grep(W,function(t){return t._id==e})):W}function m(){z++||T("loading",null,!0,x())}function y(){--z||T("loading",null,!1,x())}function w(t){var r=t.source||{},a=X(r.ignoreTimezone,n.ignoreTimezone);t._id=t._id||(t.id===e?"_fc"+xe++:t.id+""),t.date&&(t.start||(t.start=t.date),delete t.date),t._start=d(t.start=p(t.start,a)),t.end=p(t.end,a),t.end&&t.end<=t.start&&(t.end=null),t._end=t.end?d(t.end):null,t.allDay===e&&(t.allDay=X(r.allDayDefault,n.allDayDefault)),t.className?"string"==typeof t.className&&(t.className=t.className.split(/\s+/)):t.className=[]}function b(t){t.className?"string"==typeof t.className&&(t.className=t.className.split(/\s+/)):t.className=[];for(var e=Ee.sourceNormalizers,n=0;e.length>n;n++)e[n](t)}function D(t,e){return t&&e&&C(t)==C(e)}function C(t){return("object"==typeof t?t.events||t.url:"")||t}var M=this;M.isFetchNeeded=a,M.fetchEvents=o,M.addEventSource=l,M.removeEventSource=u,M.updateEvent=f,M.renderEvent=v,M.removeEvents=h,M.clientEvents=g,M.normalizeEvent=w;for(var E,S,T=M.trigger,x=M.getView,k=M.reportEvents,H={events:[]},F=[H],R=0,N=0,z=0,W=[],A=0;r.length>A;A++)c(r[A])}function i(t,e,n){return t.setFullYear(t.getFullYear()+e),n||f(t),t}function s(t,e,n){if(+t){var r=t.getMonth()+e,a=d(t);for(a.setDate(1),a.setMonth(r),t.setMonth(r),n||f(t);t.getMonth()!=a.getMonth();)t.setDate(t.getDate()+(a>t?1:-1))}return t}function l(t,e,n){if(+t){var r=t.getDate()+e,a=d(t);a.setHours(9),a.setDate(r),t.setDate(r),n||f(t),c(t,a)}return t}function c(t,e){if(+t)for(;t.getDate()!=e.getDate();)t.setTime(+t+(e>t?1:-1)*Fe)}function u(t,e){return t.setMinutes(t.getMinutes()+e),t}function f(t){return t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0),t}function d(t,e){return e?f(new Date(+t)):new Date(+t)}function v(){var t,e=0;do t=new Date(1970,e++,1);while(t.getHours());return t}function h(t,e){return Math.round((d(t,!0)-d(e,!0))/He)}function g(t,n,r,a){n!==e&&n!=t.getFullYear()&&(t.setDate(1),t.setMonth(0),t.setFullYear(n)),r!==e&&r!=t.getMonth()&&(t.setDate(1),t.setMonth(r)),a!==e&&t.setDate(a)}function p(t,n){return"object"==typeof t?t:"number"==typeof t?new Date(1e3*t):"string"==typeof t?t.match(/^\d+(\.\d+)?$/)?new Date(1e3*parseFloat(t)):(n===e&&(n=!0),m(t,n)||(t?new Date(t):null)):null}function m(t,e){var n=t.match(/^([0-9]{4})(-([0-9]{2})(-([0-9]{2})([T ]([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?(Z|(([-+])([0-9]{2})(:?([0-9]{2}))?))?)?)?)?$/);if(!n)return null;var r=new Date(n[1],0,1);if(e||!n[13]){var a=new Date(n[1],0,1,9,0);n[3]&&(r.setMonth(n[3]-1),a.setMonth(n[3]-1)),n[5]&&(r.setDate(n[5]),a.setDate(n[5])),c(r,a),n[7]&&r.setHours(n[7]),n[8]&&r.setMinutes(n[8]),n[10]&&r.setSeconds(n[10]),n[12]&&r.setMilliseconds(1e3*Number("0."+n[12])),c(r,a)}else if(r.setUTCFullYear(n[1],n[3]?n[3]-1:0,n[5]||1),r.setUTCHours(n[7]||0,n[8]||0,n[10]||0,n[12]?1e3*Number("0."+n[12]):0),n[14]){var o=60*Number(n[16])+(n[18]?Number(n[18]):0);o*="-"==n[15]?1:-1,r=new Date(+r+1e3*60*o)}return r}function y(t){if("number"==typeof t)return 60*t;if("object"==typeof t)return 60*t.getHours()+t.getMinutes();var e=t.match(/(\d+)(?::(\d+))?\s*(\w+)?/);if(e){var n=parseInt(e[1],10);return e[3]&&(n%=12,"p"==e[3].toLowerCase().charAt(0)&&(n+=12)),60*n+(e[2]?parseInt(e[2],10):0)}}function w(t,e,n){return b(t,null,e,n)}function b(t,e,n,r){r=r||Ce;var a,o,i,s,l=t,c=e,u=n.length,f="";for(a=0;u>a;a++)if(o=n.charAt(a),"'"==o){for(i=a+1;u>i;i++)if("'"==n.charAt(i)){l&&(f+=i==a+1?"'":n.substring(a+1,i),a=i);break}}else if("("==o){for(i=a+1;u>i;i++)if(")"==n.charAt(i)){var d=w(l,n.substring(a+1,i),r);parseInt(d.replace(/\D/,""),10)&&(f+=d),a=i;break}}else if("["==o){for(i=a+1;u>i;i++)if("]"==n.charAt(i)){var v=n.substring(a+1,i),d=w(l,v,r);d!=w(c,v,r)&&(f+=d),a=i;break}}else if("{"==o)l=e,c=t;else if("}"==o)l=t,c=e;else{for(i=u;i>a;i--)if(s=Ne[n.substring(a,i)]){l&&(f+=s(l,r)),a=i-1;break}i==a&&l&&(f+=o)}return f}function D(t){var e,n=new Date(t.getTime());return n.setDate(n.getDate()+4-(n.getDay()||7)),e=n.getTime(),n.setMonth(0),n.setDate(1),Math.floor(Math.round((e-n)/864e5)/7)+1}function C(t){return t.end?M(t.end,t.allDay):l(d(t.start),1)}function M(t,e){return t=d(t),e||t.getHours()||t.getMinutes()?l(t,1):f(t)}function E(n,r,a){n.unbind("mouseover").mouseover(function(n){for(var o,i,s,l=n.target;l!=this;)o=l,l=l.parentNode;(i=o._fci)!==e&&(o._fci=e,s=r[i],a(s.event,s.element,s),t(n.target).trigger(n)),n.stopPropagation()})}function S(e,n,r){for(var a,o=0;e.length>o;o++)a=t(e[o]),a.width(Math.max(0,n-x(a,r)))}function T(e,n,r){for(var a,o=0;e.length>o;o++)a=t(e[o]),a.height(Math.max(0,n-R(a,r)))}function x(t,e){return k(t)+F(t)+(e?H(t):0)}function k(e){return(parseFloat(t.css(e[0],"paddingLeft",!0))||0)+(parseFloat(t.css(e[0],"paddingRight",!0))||0)}function H(e){return(parseFloat(t.css(e[0],"marginLeft",!0))||0)+(parseFloat(t.css(e[0],"marginRight",!0))||0)}function F(e){return(parseFloat(t.css(e[0],"borderLeftWidth",!0))||0)+(parseFloat(t.css(e[0],"borderRightWidth",!0))||0)}function R(t,e){return N(t)+W(t)+(e?z(t):0)}function N(e){return(parseFloat(t.css(e[0],"paddingTop",!0))||0)+(parseFloat(t.css(e[0],"paddingBottom",!0))||0)}function z(e){return(parseFloat(t.css(e[0],"marginTop",!0))||0)+(parseFloat(t.css(e[0],"marginBottom",!0))||0)}function W(e){return(parseFloat(t.css(e[0],"borderTopWidth",!0))||0)+(parseFloat(t.css(e[0],"borderBottomWidth",!0))||0)}function A(){}function O(t,e){return t-e}function L(t){return Math.max.apply(Math,t)}function _(t){return(10>t?"0":"")+t}function P(t,n){if(t[n]!==e)return t[n];for(var r,a=n.split(/(?=[A-Z])/),o=a.length-1;o>=0;o--)if(r=t[a[o].toLowerCase()],r!==e)return r;return t[""]}function q(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#039;").replace(/"/g,"&quot;").replace(/\n/g,"<br />")}function Y(t){t.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return!1})}function B(t){t.children().removeClass("fc-first fc-last").filter(":first-child").addClass("fc-first").end().filter(":last-child").addClass("fc-last")}function j(t,e){var n=t.source||{},r=t.color,a=n.color,o=e("eventColor"),i=t.backgroundColor||r||n.backgroundColor||a||e("eventBackgroundColor")||o,s=t.borderColor||r||n.borderColor||a||e("eventBorderColor")||o,l=t.textColor||n.textColor||e("eventTextColor"),c=[];return i&&c.push("background-color:"+i),s&&c.push("border-color:"+s),l&&c.push("color:"+l),c.join(";")}function I(e,n,r){if(t.isFunction(e)&&(e=[e]),e){var a,o;for(a=0;e.length>a;a++)o=e[a].apply(n,r)||o;return o}}function X(){for(var t=0;arguments.length>t;t++)if(arguments[t]!==e)return arguments[t]}function J(t,e){function n(t,e){e&&(s(t,e),t.setDate(1));var n=a("firstDay"),f=d(t,!0);f.setDate(1);var v=s(d(f),1),g=d(f);l(g,-((g.getDay()-n+7)%7)),i(g);var p=d(v);l(p,(7-p.getDay()+n)%7),i(p,-1,!0);var m=c(),y=Math.round(h(p,g)/7);"fixed"==a("weekMode")&&(l(p,7*(6-y)),y=6),r.title=u(f,a("titleFormat")),r.start=f,r.end=v,r.visStart=g,r.visEnd=p,o(y,m,!0)}var r=this;r.render=n,Z.call(r,t,e,"month");var a=r.opt,o=r.renderBasic,i=r.skipHiddenDays,c=r.getCellsPerWeek,u=e.formatDate}function V(t,e){function n(t,e){e&&l(t,7*e);var n=l(d(t),-((t.getDay()-a("firstDay")+7)%7)),u=l(d(n),7),f=d(n);i(f);var v=d(u);i(v,-1,!0);var h=s();r.start=n,r.end=u,r.visStart=f,r.visEnd=v,r.title=c(f,l(d(v),-1),a("titleFormat")),o(1,h,!1)}var r=this;r.render=n,Z.call(r,t,e,"basicWeek");var a=r.opt,o=r.renderBasic,i=r.skipHiddenDays,s=r.getCellsPerWeek,c=e.formatDates}function U(t,e){function n(t,e){e&&l(t,e),i(t,0>e?-1:1);var n=d(t,!0),c=l(d(n),1);r.title=s(t,a("titleFormat")),r.start=r.visStart=n,r.end=r.visEnd=c,o(1,1,!1)}var r=this;r.render=n,Z.call(r,t,e,"basicDay");var a=r.opt,o=r.renderBasic,i=r.skipHiddenDays,s=e.formatDate}function Z(e,n,r){function a(t,e,n){ee=t,ne=e,re=n,o(),j||i(),s()}function o(){le=he("theme")?"ui":"fc",ce=he("columnFormat"),ue=he("weekNumbers"),de=he("weekNumberTitle"),ve="iso"!=he("weekNumberCalculation")?"w":"W"}function i(){Z=t("<div class='fc-event-container' style='position:absolute;z-index:8;top:0;left:0'/>").appendTo(e)}function s(){var n=c();L&&L.remove(),L=t(n).appendTo(e),_=L.find("thead"),P=_.find(".fc-day-header"),j=L.find("tbody"),I=j.find("tr"),X=j.find(".fc-day"),J=I.find("td:first-child"),V=I.eq(0).find(".fc-day > div"),U=I.eq(0).find(".fc-day-content > div"),B(_.add(_.find("tr"))),B(I),I.eq(0).addClass("fc-first"),I.filter(":last").addClass("fc-last"),X.each(function(e,n){var r=Ee(Math.floor(e/ne),e%ne);ge("dayRender",O,r,t(n))}),y(X)}function c(){var t="<table class='fc-border-separate' style='width:100%' cellspacing='0'>"+u()+v()+"</table>";return t}function u(){var t,e,n=le+"-widget-header",r="";for(r+="<thead><tr>",ue&&(r+="<th class='fc-week-number "+n+"'>"+q(de)+"</th>"),t=0;ne>t;t++)e=Ee(0,t),r+="<th class='fc-day-header fc-"+ke[e.getDay()]+" "+n+"'>"+q(xe(e,ce))+"</th>";return r+="</tr></thead>"}function v(){var t,e,n,r=le+"-widget-content",a="";for(a+="<tbody>",t=0;ee>t;t++){for(a+="<tr class='fc-week'>",ue&&(n=Ee(t,0),a+="<td class='fc-week-number "+r+"'>"+"<div>"+q(xe(n,ve))+"</div>"+"</td>"),e=0;ne>e;e++)n=Ee(t,e),a+=h(n);a+="</tr>"}return a+="</tbody>"}function h(t){var e=le+"-widget-content",n=O.start.getMonth(),r=f(new Date),a="",o=["fc-day","fc-"+ke[t.getDay()],e];return t.getMonth()!=n&&o.push("fc-other-month"),+t==+r?o.push("fc-today",le+"-state-highlight"):r>t?o.push("fc-past"):o.push("fc-future"),a+="<td class='"+o.join(" ")+"'"+" data-date='"+xe(t,"yyyy-MM-dd")+"'"+">"+"<div>",re&&(a+="<div class='fc-day-number'>"+t.getDate()+"</div>"),a+="<div class='fc-day-content'><div style='position:relative'>&nbsp;</div></div></div></td>"}function g(e){Q=e;var n,r,a,o=Q-_.height();"variable"==he("weekMode")?n=r=Math.floor(o/(1==ee?2:6)):(n=Math.floor(o/ee),r=o-n*(ee-1)),J.each(function(e,o){ee>e&&(a=t(o),a.find("> div").css("min-height",(e==ee-1?r:n)-R(a)))})}function p(t){$=t,ie.clear(),se.clear(),te=0,ue&&(te=_.find("th.fc-week-number").outerWidth()),K=Math.floor(($-te)/ne),S(P.slice(0,-1),K)}function y(t){t.click(w).mousedown(Me)}function w(e){if(!he("selectable")){var n=m(t(this).data("date"));ge("dayClick",this,n,!0,e)}}function b(t,e,n){n&&ae.build();for(var r=Te(t,e),a=0;r.length>a;a++){var o=r[a];y(D(o.row,o.leftCol,o.row,o.rightCol))}}function D(t,n,r,a){var o=ae.rect(t,n,r,a,e);return be(o,e)}function C(t){return d(t)}function M(t,e){b(t,l(d(e),1),!0)}function E(){Ce()}function T(t,e,n){var r=Se(t),a=X[r.row*ne+r.col];ge("dayClick",a,t,e,n)}function x(t,e){oe.start(function(t){Ce(),t&&D(t.row,t.col,t.row,t.col)},e)}function k(t,e,n){var r=oe.stop();if(Ce(),r){var a=Ee(r);ge("drop",t,a,!0,e,n)}}function H(t){return d(t.start)}function F(t){return ie.left(t)}function N(t){return ie.right(t)}function z(t){return se.left(t)}function W(t){return se.right(t)}function A(t){return I.eq(t)}var O=this;O.renderBasic=a,O.setHeight=g,O.setWidth=p,O.renderDayOverlay=b,O.defaultSelectionEnd=C,O.renderSelection=M,O.clearSelection=E,O.reportDayClick=T,O.dragStart=x,O.dragStop=k,O.defaultEventEnd=H,O.getHoverListener=function(){return oe},O.colLeft=F,O.colRight=N,O.colContentLeft=z,O.colContentRight=W,O.getIsCellAllDay=function(){return!0},O.allDayRow=A,O.getRowCnt=function(){return ee},O.getColCnt=function(){return ne},O.getColWidth=function(){return K},O.getDaySegmentContainer=function(){return Z},fe.call(O,e,n,r),me.call(O),pe.call(O),G.call(O);var L,_,P,j,I,X,J,V,U,Z,$,Q,K,te,ee,ne,re,ae,oe,ie,se,le,ce,ue,de,ve,he=O.opt,ge=O.trigger,be=O.renderOverlay,Ce=O.clearOverlays,Me=O.daySelectionMousedown,Ee=O.cellToDate,Se=O.dateToCell,Te=O.rangeToSegments,xe=n.formatDate;Y(e.addClass("fc-grid")),ae=new ye(function(e,n){var r,a,o;P.each(function(e,i){r=t(i),a=r.offset().left,e&&(o[1]=a),o=[a],n[e]=o}),o[1]=a+r.outerWidth(),I.each(function(n,i){ee>n&&(r=t(i),a=r.offset().top,n&&(o[1]=a),o=[a],e[n]=o)}),o[1]=a+r.outerHeight()}),oe=new we(ae),ie=new De(function(t){return V.eq(t)}),se=new De(function(t){return U.eq(t)})}function G(){function t(t,e){n.renderDayEvents(t,e)}function e(){n.getDaySegmentContainer().empty()}var n=this;n.renderEvents=t,n.clearEvents=e,de.call(n)}function $(t,e){function n(t,e){e&&l(t,7*e);var n=l(d(t),-((t.getDay()-a("firstDay")+7)%7)),u=l(d(n),7),f=d(n);i(f);var v=d(u);i(v,-1,!0);var h=s();r.title=c(f,l(d(v),-1),a("titleFormat")),r.start=n,r.end=u,r.visStart=f,r.visEnd=v,o(h)}var r=this;r.render=n,K.call(r,t,e,"agendaWeek");var a=r.opt,o=r.renderAgenda,i=r.skipHiddenDays,s=r.getCellsPerWeek,c=e.formatDates}function Q(t,e){function n(t,e){e&&l(t,e),i(t,0>e?-1:1);var n=d(t,!0),c=l(d(n),1);r.title=s(t,a("titleFormat")),r.start=r.visStart=n,r.end=r.visEnd=c,o(1)}var r=this;r.render=n,K.call(r,t,e,"agendaDay");var a=r.opt,o=r.renderAgenda,i=r.skipHiddenDays,s=e.formatDate}function K(n,r,a){function o(t){We=t,i(),K?c():s()}function i(){qe=Ue("theme")?"ui":"fc",Ye=Ue("isRTL"),Be=y(Ue("minTime")),je=y(Ue("maxTime")),Ie=Ue("columnFormat"),Xe=Ue("weekNumbers"),Je=Ue("weekNumberTitle"),Ve="iso"!=Ue("weekNumberCalculation")?"w":"W",Re=Ue("snapMinutes")||Ue("slotMinutes")}function s(){var e,r,a,o,i,s=qe+"-widget-header",l=qe+"-widget-content",f=0==Ue("slotMinutes")%15;for(c(),ce=t("<div style='position:absolute;z-index:2;left:0;width:100%'/>").appendTo(n),Ue("allDaySlot")?(ue=t("<div class='fc-event-container' style='position:absolute;z-index:8;top:0;left:0'/>").appendTo(ce),e="<table style='width:100%' class='fc-agenda-allday' cellspacing='0'><tr><th class='"+s+" fc-agenda-axis'>"+Ue("allDayText")+"</th>"+"<td>"+"<div class='fc-day-content'><div style='position:relative'/></div>"+"</td>"+"<th class='"+s+" fc-agenda-gutter'>&nbsp;</th>"+"</tr>"+"</table>",de=t(e).appendTo(ce),ve=de.find("tr"),C(ve.find("td")),ce.append("<div class='fc-agenda-divider "+s+"'>"+"<div class='fc-agenda-divider-inner'/>"+"</div>")):ue=t([]),he=t("<div style='position:absolute;width:100%;overflow-x:hidden;overflow-y:auto'/>").appendTo(ce),ge=t("<div style='position:relative;width:100%;overflow:hidden'/>").appendTo(he),be=t("<div class='fc-event-container' style='position:absolute;z-index:8;top:0;left:0'/>").appendTo(ge),e="<table class='fc-agenda-slots' style='width:100%' cellspacing='0'><tbody>",r=v(),o=u(d(r),je),u(r,Be),Ae=0,a=0;o>r;a++)i=r.getMinutes(),e+="<tr class='fc-slot"+a+" "+(i?"fc-minor":"")+"'>"+"<th class='fc-agenda-axis "+s+"'>"+(f&&i?"&nbsp;":on(r,Ue("axisFormat")))+"</th>"+"<td class='"+l+"'>"+"<div style='position:relative'>&nbsp;</div>"+"</td>"+"</tr>",u(r,Ue("slotMinutes")),Ae++;e+="</tbody></table>",Ce=t(e).appendTo(ge),M(Ce.find("td"))}function c(){var e=h();K&&K.remove(),K=t(e).appendTo(n),ee=K.find("thead"),ne=ee.find("th").slice(1,-1),re=K.find("tbody"),ae=re.find("td").slice(0,-1),oe=ae.find("> div"),ie=ae.find(".fc-day-content > div"),se=ae.eq(0),le=oe.eq(0),B(ee.add(ee.find("tr"))),B(re.add(re.find("tr")))}function h(){var t="<table style='width:100%' class='fc-agenda-days fc-border-separate' cellspacing='0'>"+g()+p()+"</table>";return t}function g(){var t,e,n,r=qe+"-widget-header",a="";for(a+="<thead><tr>",Xe?(t=nn(0,0),e=on(t,Ve),Ye?e+=Je:e=Je+e,a+="<th class='fc-agenda-axis fc-week-number "+r+"'>"+q(e)+"</th>"):a+="<th class='fc-agenda-axis "+r+"'>&nbsp;</th>",n=0;We>n;n++)t=nn(0,n),a+="<th class='fc-"+ke[t.getDay()]+" fc-col"+n+" "+r+"'>"+q(on(t,Ie))+"</th>";return a+="<th class='fc-agenda-gutter "+r+"'>&nbsp;</th>"+"</tr>"+"</thead>"}function p(){var t,e,n,r,a,o=qe+"-widget-header",i=qe+"-widget-content",s=f(new Date),l="";for(l+="<tbody><tr><th class='fc-agenda-axis "+o+"'>&nbsp;</th>",n="",e=0;We>e;e++)t=nn(0,e),a=["fc-col"+e,"fc-"+ke[t.getDay()],i],+t==+s?a.push(qe+"-state-highlight","fc-today"):s>t?a.push("fc-past"):a.push("fc-future"),r="<td class='"+a.join(" ")+"'>"+"<div>"+"<div class='fc-day-content'>"+"<div style='position:relative'>&nbsp;</div>"+"</div>"+"</div>"+"</td>",n+=r;return l+=n,l+="<td class='fc-agenda-gutter "+i+"'>&nbsp;</td>"+"</tr>"+"</tbody>"}function m(t){t===e&&(t=Se),Se=t,sn={};var n=re.position().top,r=he.position().top,a=Math.min(t-n,Ce.height()+r+1);le.height(a-R(se)),ce.css("top",n),he.height(a-r-1),Fe=Ce.find("tr:first").height()+1,Ne=Ue("slotMinutes")/Re,ze=Fe/Ne}function w(e){Ee=e,_e.clear(),Pe.clear();var n=ee.find("th:first");de&&(n=n.add(de.find("th:first"))),n=n.add(Ce.find("th:first")),Te=0,S(n.width("").each(function(e,n){Te=Math.max(Te,t(n).outerWidth())}),Te);var r=K.find(".fc-agenda-gutter");de&&(r=r.add(de.find("th.fc-agenda-gutter")));var a=he[0].clientWidth;He=he.width()-a,He?(S(r,He),r.show().prev().removeClass("fc-last")):r.hide().prev().addClass("fc-last"),xe=Math.floor((a-Te)/We),S(ne.slice(0,-1),xe)}function b(){function t(){he.scrollTop(r)}var e=v(),n=d(e);n.setHours(Ue("firstHour"));var r=_(e,n)+1;t(),setTimeout(t,0)}function D(){b()}function C(t){t.click(E).mousedown(tn)}function M(t){t.click(E).mousedown(U)}function E(t){if(!Ue("selectable")){var e=Math.min(We-1,Math.floor((t.pageX-K.offset().left-Te)/xe)),n=nn(0,e),r=this.parentNode.className.match(/fc-slot(\d+)/);if(r){var a=parseInt(r[1])*Ue("slotMinutes"),o=Math.floor(a/60);n.setHours(o),n.setMinutes(a%60+Be),Ze("dayClick",ae[e],n,!1,t)}else Ze("dayClick",ae[e],n,!0,t)}}function x(t,e,n){n&&Oe.build();for(var r=an(t,e),a=0;r.length>a;a++){var o=r[a];C(k(o.row,o.leftCol,o.row,o.rightCol))}}function k(t,e,n,r){var a=Oe.rect(t,e,n,r,ce);return Ge(a,ce)}function H(t,e){for(var n=0;We>n;n++){var r=nn(0,n),a=l(d(r),1),o=new Date(Math.max(r,t)),i=new Date(Math.min(a,e));if(i>o){var s=Oe.rect(0,n,0,n,ge),c=_(r,o),u=_(r,i);s.top=c,s.height=u-c,M(Ge(s,ge))}}}function F(t){return _e.left(t)}function N(t){return Pe.left(t)}function z(t){return _e.right(t)}function W(t){return Pe.right(t)}function A(t){return Ue("allDaySlot")&&!t.row}function L(t){var e=nn(0,t.col),n=t.row;return Ue("allDaySlot")&&n--,n>=0&&u(e,Be+n*Re),e}function _(t,n){if(t=d(t,!0),u(d(t),Be)>n)return 0;if(n>=u(d(t),je))return Ce.height();var r=Ue("slotMinutes"),a=60*n.getHours()+n.getMinutes()-Be,o=Math.floor(a/r),i=sn[o];return i===e&&(i=sn[o]=Ce.find("tr").eq(o).find("td div")[0].offsetTop),Math.max(0,Math.round(i-1+Fe*(a%r/r)))}function P(){return ve}function j(t){var e=d(t.start);return t.allDay?e:u(e,Ue("defaultEventMinutes"))}function I(t,e){return e?d(t):u(d(t),Ue("slotMinutes"))}function X(t,e,n){n?Ue("allDaySlot")&&x(t,l(d(e),1),!0):J(t,e)}function J(e,n){var r=Ue("selectHelper");if(Oe.build(),r){var a=rn(e).col;if(a>=0&&We>a){var o=Oe.rect(0,a,0,a,ge),i=_(e,e),s=_(e,n);if(s>i){if(o.top=i,o.height=s-i,o.left+=2,o.width-=5,t.isFunction(r)){var l=r(e,n);l&&(o.position="absolute",Me=t(l).css(o).appendTo(ge))}else o.isStart=!0,o.isEnd=!0,Me=t(en({title:"",start:e,end:n,className:["fc-select-helper"],editable:!1},o)),Me.css("opacity",Ue("dragOpacity"));Me&&(M(Me),ge.append(Me),S(Me,o.width,!0),T(Me,o.height,!0))}}}else H(e,n)}function V(){$e(),Me&&(Me.remove(),Me=null)}function U(e){if(1==e.which&&Ue("selectable")){Ke(e);var n;Le.start(function(t,e){if(V(),t&&t.col==e.col&&!A(t)){var r=L(e),a=L(t);n=[r,u(d(r),Re),a,u(d(a),Re)].sort(O),J(n[0],n[3])}else n=null},e),t(document).one("mouseup",function(t){Le.stop(),n&&(+n[0]==+n[1]&&Z(n[0],!1,t),Qe(n[0],n[3],!1,t))})}}function Z(t,e,n){Ze("dayClick",ae[rn(t).col],t,e,n)}function G(t,e){Le.start(function(t){if($e(),t)if(A(t))k(t.row,t.col,t.row,t.col);else{var e=L(t),n=u(d(e),Ue("defaultEventMinutes"));H(e,n)}},e)}function $(t,e,n){var r=Le.stop();$e(),r&&Ze("drop",t,L(r),A(r),e,n)}var Q=this;Q.renderAgenda=o,Q.setWidth=w,Q.setHeight=m,Q.afterRender=D,Q.defaultEventEnd=j,Q.timePosition=_,Q.getIsCellAllDay=A,Q.allDayRow=P,Q.getCoordinateGrid=function(){return Oe},Q.getHoverListener=function(){return Le},Q.colLeft=F,Q.colRight=z,Q.colContentLeft=N,Q.colContentRight=W,Q.getDaySegmentContainer=function(){return ue},Q.getSlotSegmentContainer=function(){return be},Q.getMinMinute=function(){return Be},Q.getMaxMinute=function(){return je},Q.getSlotContainer=function(){return ge},Q.getRowCnt=function(){return 1},Q.getColCnt=function(){return We},Q.getColWidth=function(){return xe},Q.getSnapHeight=function(){return ze},Q.getSnapMinutes=function(){return Re},Q.defaultSelectionEnd=I,Q.renderDayOverlay=x,Q.renderSelection=X,Q.clearSelection=V,Q.reportDayClick=Z,Q.dragStart=G,Q.dragStop=$,fe.call(Q,n,r,a),me.call(Q),pe.call(Q),te.call(Q);var K,ee,ne,re,ae,oe,ie,se,le,ce,ue,de,ve,he,ge,be,Ce,Me,Ee,Se,Te,xe,He,Fe,Re,Ne,ze,We,Ae,Oe,Le,_e,Pe,qe,Ye,Be,je,Ie,Xe,Je,Ve,Ue=Q.opt,Ze=Q.trigger,Ge=Q.renderOverlay,$e=Q.clearOverlays,Qe=Q.reportSelection,Ke=Q.unselect,tn=Q.daySelectionMousedown,en=Q.slotSegHtml,nn=Q.cellToDate,rn=Q.dateToCell,an=Q.rangeToSegments,on=r.formatDate,sn={};Y(n.addClass("fc-agenda")),Oe=new ye(function(e,n){function r(t){return Math.max(l,Math.min(c,t))}var a,o,i;ne.each(function(e,r){a=t(r),o=a.offset().left,e&&(i[1]=o),i=[o],n[e]=i}),i[1]=o+a.outerWidth(),Ue("allDaySlot")&&(a=ve,o=a.offset().top,e[0]=[o,o+a.outerHeight()]);for(var s=ge.offset().top,l=he.offset().top,c=l+he.outerHeight(),u=0;Ae*Ne>u;u++)e.push([r(s+ze*u),r(s+ze*(u+1))])}),Le=new we(Oe),_e=new De(function(t){return oe.eq(t)}),Pe=new De(function(t){return ie.eq(t)})}function te(){function n(t,e){var n,r=t.length,o=[],i=[];for(n=0;r>n;n++)t[n].allDay?o.push(t[n]):i.push(t[n]);y("allDaySlot")&&(te(o,e),k()),s(a(i),e)}function r(){H().empty(),F().empty()}function a(e){var n,r,a,s,l,c=Y(),f=W(),v=z(),h=t.map(e,i),g=[];for(r=0;c>r;r++)for(n=P(0,r),u(n,f),l=o(e,h,n,u(d(n),v-f)),l=ee(l),a=0;l.length>a;a++)s=l[a],s.col=r,g.push(s);return g}function o(t,e,n,r){var a,o,i,s,l,c,u,f,v=[],h=t.length;for(a=0;h>a;a++)o=t[a],i=o.start,s=e[a],s>n&&r>i&&(n>i?(l=d(n),u=!1):(l=i,u=!0),s>r?(c=d(r),f=!1):(c=s,f=!0),v.push({event:o,start:l,end:c,isStart:u,isEnd:f}));return v.sort(ue)}function i(t){return t.end?d(t.end):u(d(t.start),y("defaultEventMinutes"))}function s(n,r){var a,o,i,s,l,u,d,v,h,g,p,m,b,D,C,M,S=n.length,T="",k=F(),H=y("isRTL");for(a=0;S>a;a++)o=n[a],i=o.event,s=A(o.start,o.start),l=A(o.start,o.end),u=L(o.col),d=_(o.col),v=d-u,d-=.025*v,v=d-u,h=v*(o.forwardCoord-o.backwardCoord),y("slotEventOverlap")&&(h=Math.max(2*(h-10),h)),H?(p=d-o.backwardCoord*v,g=p-h):(g=u+o.backwardCoord*v,p=g+h),g=Math.max(g,u),p=Math.min(p,d),h=p-g,o.top=s,o.left=g,o.outerWidth=h,o.outerHeight=l-s,T+=c(i,o);for(k[0].innerHTML=T,m=k.children(),a=0;S>a;a++)o=n[a],i=o.event,b=t(m[a]),D=w("eventRender",i,i,b),D===!1?b.remove():(D&&D!==!0&&(b.remove(),b=t(D).css({position:"absolute",top:o.top,left:o.left}).appendTo(k)),o.element=b,i._id===r?f(i,b,o):b[0]._fci=a,V(i,b));for(E(k,n,f),a=0;S>a;a++)o=n[a],(b=o.element)&&(o.vsides=R(b,!0),o.hsides=x(b,!0),C=b.find(".fc-event-title"),C.length&&(o.contentTop=C[0].offsetTop));for(a=0;S>a;a++)o=n[a],(b=o.element)&&(b[0].style.width=Math.max(0,o.outerWidth-o.hsides)+"px",M=Math.max(0,o.outerHeight-o.vsides),b[0].style.height=M+"px",i=o.event,o.contentTop!==e&&10>M-o.contentTop&&(b.find("div.fc-event-time").text(re(i.start,y("timeFormat"))+" - "+i.title),b.find("div.fc-event-title").remove()),w("eventAfterRender",i,i,b))}function c(t,e){var n="<",r=t.url,a=j(t,y),o=["fc-event","fc-event-vert"];return b(t)&&o.push("fc-event-draggable"),e.isStart&&o.push("fc-event-start"),e.isEnd&&o.push("fc-event-end"),o=o.concat(t.className),t.source&&(o=o.concat(t.source.className||[])),n+=r?"a href='"+q(t.url)+"'":"div",n+=" class='"+o.join(" ")+"'"+" style="+"'"+"position:absolute;"+"top:"+e.top+"px;"+"left:"+e.left+"px;"+a+"'"+">"+"<div class='fc-event-inner'>"+"<div class='fc-event-time'>"+q(ae(t.start,t.end,y("timeFormat")))+"</div>"+"<div class='fc-event-title'>"+q(t.title||"")+"</div>"+"</div>"+"<div class='fc-event-bg'></div>",e.isEnd&&D(t)&&(n+="<div class='ui-resizable-handle ui-resizable-s'>=</div>"),n+="</"+(r?"a":"div")+">"}function f(t,e,n){var r=e.find("div.fc-event-time");b(t)&&g(t,e,r),n.isEnd&&D(t)&&p(t,e,r),S(t,e)}function v(t,e,n){function r(){c||(e.width(a).height("").draggable("option","grid",null),c=!0)}var a,o,i,s=n.isStart,c=!0,u=N(),f=B(),v=I(),g=X(),p=W();e.draggable({opacity:y("dragOpacity","month"),revertDuration:y("dragRevertDuration"),start:function(n,p){w("eventDragStart",e,t,n,p),Z(t,e),a=e.width(),u.start(function(n,a){if(K(),n){o=!1;var u=P(0,a.col),p=P(0,n.col);i=h(p,u),n.row?s?c&&(e.width(f-10),T(e,v*Math.round((t.end?(t.end-t.start)/Re:y("defaultEventMinutes"))/g)),e.draggable("option","grid",[f,1]),c=!1):o=!0:(Q(l(d(t.start),i),l(C(t),i)),r()),o=o||c&&!i
+}else r(),o=!0;e.draggable("option","revert",o)},n,"drag")},stop:function(n,a){if(u.stop(),K(),w("eventDragStop",e,t,n,a),o)r(),e.css("filter",""),U(t,e);else{var s=0;c||(s=Math.round((e.offset().top-J().offset().top)/v)*g+p-(60*t.start.getHours()+t.start.getMinutes())),G(this,t,i,s,c,n,a)}}})}function g(t,e,n){function r(){K(),s&&(f?(n.hide(),e.draggable("option","grid",null),Q(l(d(t.start),b),l(C(t),b))):(a(D),n.css("display",""),e.draggable("option","grid",[T,x])))}function a(e){var r,a=u(d(t.start),e);t.end&&(r=u(d(t.end),e)),n.text(ae(a,r,y("timeFormat")))}var o,i,s,c,f,v,g,p,b,D,M,E=m.getCoordinateGrid(),S=Y(),T=B(),x=I(),k=X();e.draggable({scroll:!1,grid:[T,x],axis:1==S?"y":!1,opacity:y("dragOpacity"),revertDuration:y("dragRevertDuration"),start:function(n,r){w("eventDragStart",e,t,n,r),Z(t,e),E.build(),o=e.position(),i=E.cell(n.pageX,n.pageY),s=c=!0,f=v=O(i),g=p=0,b=0,D=M=0},drag:function(t,n){var a=E.cell(t.pageX,t.pageY);if(s=!!a){if(f=O(a),g=Math.round((n.position.left-o.left)/T),g!=p){var l=P(0,i.col),u=i.col+g;u=Math.max(0,u),u=Math.min(S-1,u);var d=P(0,u);b=h(d,l)}f||(D=Math.round((n.position.top-o.top)/x)*k)}(s!=c||f!=v||g!=p||D!=M)&&(r(),c=s,v=f,p=g,M=D),e.draggable("option","revert",!s)},stop:function(n,a){K(),w("eventDragStop",e,t,n,a),s&&(f||b||D)?G(this,t,b,f?0:D,f,n,a):(s=!0,f=!1,g=0,b=0,D=0,r(),e.css("filter",""),e.css(o),U(t,e))}})}function p(t,e,n){var r,a,o=I(),i=X();e.resizable({handles:{s:".ui-resizable-handle"},grid:o,start:function(n,o){r=a=0,Z(t,e),w("eventResizeStart",this,t,n,o)},resize:function(s,l){r=Math.round((Math.max(o,e.height())-l.originalSize.height)/o),r!=a&&(n.text(ae(t.start,r||t.end?u(M(t),i*r):null,y("timeFormat"))),a=r)},stop:function(n,a){w("eventResizeStop",this,t,n,a),r?$(this,t,0,i*r,n,a):U(t,e)}})}var m=this;m.renderEvents=n,m.clearEvents=r,m.slotSegHtml=c,de.call(m);var y=m.opt,w=m.trigger,b=m.isEventDraggable,D=m.isEventResizable,M=m.eventEnd,S=m.eventElementHandlers,k=m.setHeight,H=m.getDaySegmentContainer,F=m.getSlotSegmentContainer,N=m.getHoverListener,z=m.getMaxMinute,W=m.getMinMinute,A=m.timePosition,O=m.getIsCellAllDay,L=m.colContentLeft,_=m.colContentRight,P=m.cellToDate,Y=m.getColCnt,B=m.getColWidth,I=m.getSnapHeight,X=m.getSnapMinutes,J=m.getSlotContainer,V=m.reportEventElement,U=m.showEvents,Z=m.hideEvents,G=m.eventDrop,$=m.eventResize,Q=m.renderDayOverlay,K=m.clearOverlays,te=m.renderDayEvents,ne=m.calendar,re=ne.formatDate,ae=ne.formatDates;m.draggableDayEvent=v}function ee(t){var e,n=ne(t),r=n[0];if(re(n),r){for(e=0;r.length>e;e++)ae(r[e]);for(e=0;r.length>e;e++)oe(r[e],0,0)}return ie(n)}function ne(t){var e,n,r,a=[];for(e=0;t.length>e;e++){for(n=t[e],r=0;a.length>r&&se(n,a[r]).length;r++);(a[r]||(a[r]=[])).push(n)}return a}function re(t){var e,n,r,a,o;for(e=0;t.length>e;e++)for(n=t[e],r=0;n.length>r;r++)for(a=n[r],a.forwardSegs=[],o=e+1;t.length>o;o++)se(a,t[o],a.forwardSegs)}function ae(t){var n,r,a=t.forwardSegs,o=0;if(t.forwardPressure===e){for(n=0;a.length>n;n++)r=a[n],ae(r),o=Math.max(o,1+r.forwardPressure);t.forwardPressure=o}}function oe(t,n,r){var a,o=t.forwardSegs;if(t.forwardCoord===e)for(o.length?(o.sort(ce),oe(o[0],n+1,r),t.forwardCoord=o[0].backwardCoord):t.forwardCoord=1,t.backwardCoord=t.forwardCoord-(t.forwardCoord-r)/(n+1),a=0;o.length>a;a++)oe(o[a],0,t.forwardCoord)}function ie(t){var e,n,r,a=[];for(e=0;t.length>e;e++)for(n=t[e],r=0;n.length>r;r++)a.push(n[r]);return a}function se(t,e,n){n=n||[];for(var r=0;e.length>r;r++)le(t,e[r])&&n.push(e[r]);return n}function le(t,e){return t.end>e.start&&t.start<e.end}function ce(t,e){return e.forwardPressure-t.forwardPressure||(t.backwardCoord||0)-(e.backwardCoord||0)||ue(t,e)}function ue(t,e){return t.start-e.start||e.end-e.start-(t.end-t.start)||(t.event.title||"").localeCompare(e.event.title)}function fe(n,r,a){function o(e,n){var r=V[e];return t.isPlainObject(r)?P(r,n||a):r}function i(t,e){return r.trigger.apply(r,[t,e||_].concat(Array.prototype.slice.call(arguments,2),[_]))}function s(t){var e=t.source||{};return X(t.startEditable,e.startEditable,o("eventStartEditable"),t.editable,e.editable,o("editable"))&&!o("disableDragging")}function c(t){var e=t.source||{};return X(t.durationEditable,e.durationEditable,o("eventDurationEditable"),t.editable,e.editable,o("editable"))&&!o("disableResizing")}function f(t){j={};var e,n,r=t.length;for(e=0;r>e;e++)n=t[e],j[n._id]?j[n._id].push(n):j[n._id]=[n]}function v(){j={},I={},J=[]}function g(t){return t.end?d(t.end):q(t)}function p(t,e){J.push({event:t,element:e}),I[t._id]?I[t._id].push(e):I[t._id]=[e]}function m(){t.each(J,function(t,e){_.trigger("eventDestroy",e.event,e.event,e.element)})}function y(t,n){n.click(function(r){return n.hasClass("ui-draggable-dragging")||n.hasClass("ui-resizable-resizing")?e:i("eventClick",this,t,r)}).hover(function(e){i("eventMouseover",this,t,e)},function(e){i("eventMouseout",this,t,e)})}function w(t,e){D(t,e,"show")}function b(t,e){D(t,e,"hide")}function D(t,e,n){var r,a=I[t._id],o=a.length;for(r=0;o>r;r++)e&&a[r][0]==e[0]||a[r][n]()}function C(t,e,n,r,a,o,s){var l=e.allDay,c=e._id;E(j[c],n,r,a),i("eventDrop",t,e,n,r,a,function(){E(j[c],-n,-r,l),B(c)},o,s),B(c)}function M(t,e,n,r,a,o){var s=e._id;S(j[s],n,r),i("eventResize",t,e,n,r,function(){S(j[s],-n,-r),B(s)},a,o),B(s)}function E(t,n,r,a){r=r||0;for(var o,i=t.length,s=0;i>s;s++)o=t[s],a!==e&&(o.allDay=a),u(l(o.start,n,!0),r),o.end&&(o.end=u(l(o.end,n,!0),r)),Y(o,V)}function S(t,e,n){n=n||0;for(var r,a=t.length,o=0;a>o;o++)r=t[o],r.end=u(l(g(r),e,!0),n),Y(r,V)}function T(t){return"object"==typeof t&&(t=t.getDay()),G[t]}function x(){return U}function k(t,e,n){for(e=e||1;G[(t.getDay()+(n?e:0)+7)%7];)l(t,e)}function H(){var t=F.apply(null,arguments),e=R(t),n=N(e);return n}function F(t,e){var n=_.getColCnt(),r=K?-1:1,a=K?n-1:0;"object"==typeof t&&(e=t.col,t=t.row);var o=t*n+(e*r+a);return o}function R(t){var e=_.visStart.getDay();return t+=$[e],7*Math.floor(t/U)+Q[(t%U+U)%U]-e}function N(t){var e=d(_.visStart);return l(e,t),e}function z(t){var e=W(t),n=A(e),r=O(n);return r}function W(t){return h(t,_.visStart)}function A(t){var e=_.visStart.getDay();return t+=e,Math.floor(t/7)*U+$[(t%7+7)%7]-$[e]}function O(t){var e=_.getColCnt(),n=K?-1:1,r=K?e-1:0,a=Math.floor(t/e),o=(t%e+e)%e*n+r;return{row:a,col:o}}function L(t,e){for(var n=_.getRowCnt(),r=_.getColCnt(),a=[],o=W(t),i=W(e),s=A(o),l=A(i)-1,c=0;n>c;c++){var u=c*r,f=u+r-1,d=Math.max(s,u),v=Math.min(l,f);if(v>=d){var h=O(d),g=O(v),p=[h.col,g.col].sort(),m=R(d)==o,y=R(v)+1==i;a.push({row:c,leftCol:p[0],rightCol:p[1],isStart:m,isEnd:y})}}return a}var _=this;_.element=n,_.calendar=r,_.name=a,_.opt=o,_.trigger=i,_.isEventDraggable=s,_.isEventResizable=c,_.setEventData=f,_.clearEventData=v,_.eventEnd=g,_.reportEventElement=p,_.triggerEventDestroy=m,_.eventElementHandlers=y,_.showEvents=w,_.hideEvents=b,_.eventDrop=C,_.eventResize=M;var q=_.defaultEventEnd,Y=r.normalizeEvent,B=r.reportEventChange,j={},I={},J=[],V=r.options;_.isHiddenDay=T,_.skipHiddenDays=k,_.getCellsPerWeek=x,_.dateToCell=z,_.dateToDayOffset=W,_.dayOffsetToCellOffset=A,_.cellOffsetToCell=O,_.cellToDate=H,_.cellToCellOffset=F,_.cellOffsetToDayOffset=R,_.dayOffsetToDate=N,_.rangeToSegments=L;var U,Z=o("hiddenDays")||[],G=[],$=[],Q=[],K=o("isRTL");(function(){o("weekends")===!1&&Z.push(0,6);for(var e=0,n=0;7>e;e++)$[e]=n,G[e]=-1!=t.inArray(e,Z),G[e]||(Q[n]=e,n++);if(U=n,!U)throw"invalid hiddenDays"})()}function de(){function e(t,e){var n=r(t,!1,!0);he(n,function(t,e){N(t.event,e)}),w(n,e),he(n,function(t,e){k("eventAfterRender",t.event,t.event,e)})}function n(t,e,n){var a=r([t],!0,!1),o=[];return he(a,function(t,r){t.row===e&&r.css("top",n),o.push(r[0])}),o}function r(e,n,r){var o,l,c=Z(),d=n?t("<div/>"):c,v=a(e);return i(v),o=s(v),d[0].innerHTML=o,l=d.children(),n&&c.append(l),u(v,l),he(v,function(t,e){t.hsides=x(e,!0)}),he(v,function(t,e){e.width(Math.max(0,t.outerWidth-t.hsides))}),he(v,function(t,e){t.outerHeight=e.outerHeight(!0)}),f(v,r),v}function a(t){for(var e=[],n=0;t.length>n;n++){var r=o(t[n]);e.push.apply(e,r)}return e}function o(t){for(var e=t.start,n=C(t),r=ee(e,n),a=0;r.length>a;a++)r[a].event=t;return r}function i(t){for(var e=T("isRTL"),n=0;t.length>n;n++){var r=t[n],a=(e?r.isEnd:r.isStart)?V:X,o=(e?r.isStart:r.isEnd)?U:J,i=a(r.leftCol),s=o(r.rightCol);r.left=i,r.outerWidth=s-i}}function s(t){for(var e="",n=0;t.length>n;n++)e+=c(t[n]);return e}function c(t){var e="",n=T("isRTL"),r=t.event,a=r.url,o=["fc-event","fc-event-hori"];H(r)&&o.push("fc-event-draggable"),t.isStart&&o.push("fc-event-start"),t.isEnd&&o.push("fc-event-end"),o=o.concat(r.className),r.source&&(o=o.concat(r.source.className||[]));var i=j(r,T);return e+=a?"<a href='"+q(a)+"'":"<div",e+=" class='"+o.join(" ")+"'"+" style="+"'"+"position:absolute;"+"left:"+t.left+"px;"+i+"'"+">"+"<div class='fc-event-inner'>",!r.allDay&&t.isStart&&(e+="<span class='fc-event-time'>"+q(G(r.start,r.end,T("timeFormat")))+"</span>"),e+="<span class='fc-event-title'>"+q(r.title||"")+"</span>"+"</div>",t.isEnd&&F(r)&&(e+="<div class='ui-resizable-handle ui-resizable-"+(n?"w":"e")+"'>"+"&nbsp;&nbsp;&nbsp;"+"</div>"),e+="</"+(a?"a":"div")+">"}function u(e,n){for(var r=0;e.length>r;r++){var a=e[r],o=a.event,i=n.eq(r),s=k("eventRender",o,o,i);s===!1?i.remove():(s&&s!==!0&&(s=t(s).css({position:"absolute",left:a.left}),i.replaceWith(s),i=s),a.element=i)}}function f(t,e){var n=v(t),r=y(),a=[];if(e)for(var o=0;r.length>o;o++)r[o].height(n[o]);for(var o=0;r.length>o;o++)a.push(r[o].position().top);he(t,function(t,e){e.css("top",a[t.row]+t.top)})}function v(t){for(var e=P(),n=B(),r=[],a=g(t),o=0;e>o;o++){for(var i=a[o],s=[],l=0;n>l;l++)s.push(0);for(var c=0;i.length>c;c++){var u=i[c];u.top=L(s.slice(u.leftCol,u.rightCol+1));for(var l=u.leftCol;u.rightCol>=l;l++)s[l]=u.top+u.outerHeight}r.push(L(s))}return r}function g(t){var e,n,r,a=P(),o=[];for(e=0;t.length>e;e++)n=t[e],r=n.row,n.element&&(o[r]?o[r].push(n):o[r]=[n]);for(r=0;a>r;r++)o[r]=p(o[r]||[]);return o}function p(t){for(var e=[],n=m(t),r=0;n.length>r;r++)e.push.apply(e,n[r]);return e}function m(t){t.sort(ge);for(var e=[],n=0;t.length>n;n++){for(var r=t[n],a=0;e.length>a&&ve(r,e[a]);a++);e[a]?e[a].push(r):e[a]=[r]}return e}function y(){var t,e=P(),n=[];for(t=0;e>t;t++)n[t]=I(t).find("div.fc-day-content > div");return n}function w(t,e){var n=Z();he(t,function(t,n,r){var a=t.event;a._id===e?b(a,n,t):n[0]._fci=r}),E(n,t,b)}function b(t,e,n){H(t)&&S.draggableDayEvent(t,e,n),n.isEnd&&F(t)&&S.resizableDayEvent(t,e,n),z(t,e)}function D(t,e){var n,r=te();e.draggable({delay:50,opacity:T("dragOpacity"),revertDuration:T("dragRevertDuration"),start:function(a,o){k("eventDragStart",e,t,a,o),A(t,e),r.start(function(r,a,o,i){if(e.draggable("option","revert",!r||!o&&!i),Q(),r){var s=ne(a),c=ne(r);n=h(c,s),$(l(d(t.start),n),l(C(t),n))}else n=0},a,"drag")},stop:function(a,o){r.stop(),Q(),k("eventDragStop",e,t,a,o),n?O(this,t,n,0,t.allDay,a,o):(e.css("filter",""),W(t,e))}})}function M(e,r,a){var o=T("isRTL"),i=o?"w":"e",s=r.find(".ui-resizable-"+i),c=!1;Y(r),r.mousedown(function(t){t.preventDefault()}).click(function(t){c&&(t.preventDefault(),t.stopImmediatePropagation())}),s.mousedown(function(o){function s(n){k("eventResizeStop",this,e,n),t("body").css("cursor",""),u.stop(),Q(),f&&_(this,e,f,0,n),setTimeout(function(){c=!1},0)}if(1==o.which){c=!0;var u=te();P(),B();var f,d,v=r.css("top"),h=t.extend({},e),g=ie(oe(e.start));K(),t("body").css("cursor",i+"-resize").one("mouseup",s),k("eventResizeStart",this,e,o),u.start(function(r,o){if(r){var s=re(o),c=re(r);if(c=Math.max(c,g),f=ae(c)-ae(s)){h.end=l(R(e),f,!0);var u=d;d=n(h,a.row,v),d=t(d),d.find("*").css("cursor",i+"-resize"),u&&u.remove(),A(e)}else d&&(W(e),d.remove(),d=null);Q(),$(e.start,l(C(e),f))}},o)}})}var S=this;S.renderDayEvents=e,S.draggableDayEvent=D,S.resizableDayEvent=M;var T=S.opt,k=S.trigger,H=S.isEventDraggable,F=S.isEventResizable,R=S.eventEnd,N=S.reportEventElement,z=S.eventElementHandlers,W=S.showEvents,A=S.hideEvents,O=S.eventDrop,_=S.eventResize,P=S.getRowCnt,B=S.getColCnt;S.getColWidth;var I=S.allDayRow,X=S.colLeft,J=S.colRight,V=S.colContentLeft,U=S.colContentRight;S.dateToCell;var Z=S.getDaySegmentContainer,G=S.calendar.formatDates,$=S.renderDayOverlay,Q=S.clearOverlays,K=S.clearSelection,te=S.getHoverListener,ee=S.rangeToSegments,ne=S.cellToDate,re=S.cellToCellOffset,ae=S.cellOffsetToDayOffset,oe=S.dateToDayOffset,ie=S.dayOffsetToCellOffset}function ve(t,e){for(var n=0;e.length>n;n++){var r=e[n];if(r.leftCol<=t.rightCol&&r.rightCol>=t.leftCol)return!0}return!1}function he(t,e){for(var n=0;t.length>n;n++){var r=t[n],a=r.element;a&&e(r,a,n)}}function ge(t,e){return e.rightCol-e.leftCol-(t.rightCol-t.leftCol)||e.event.allDay-t.event.allDay||t.event.start-e.event.start||(t.event.title||"").localeCompare(e.event.title)}function pe(){function e(t,e,a){n(),e||(e=l(t,a)),c(t,e,a),r(t,e,a)}function n(t){f&&(f=!1,u(),s("unselect",null,t))}function r(t,e,n,r){f=!0,s("select",null,t,e,n,r)}function a(e){var a=o.cellToDate,s=o.getIsCellAllDay,l=o.getHoverListener(),f=o.reportDayClick;if(1==e.which&&i("selectable")){n(e);var d;l.start(function(t,e){u(),t&&s(t)?(d=[a(e),a(t)].sort(O),c(d[0],d[1],!0)):d=null},e),t(document).one("mouseup",function(t){l.stop(),d&&(+d[0]==+d[1]&&f(d[0],!0,t),r(d[0],d[1],!0,t))})}}var o=this;o.select=e,o.unselect=n,o.reportSelection=r,o.daySelectionMousedown=a;var i=o.opt,s=o.trigger,l=o.defaultSelectionEnd,c=o.renderSelection,u=o.clearSelection,f=!1;i("selectable")&&i("unselectAuto")&&t(document).mousedown(function(e){var r=i("unselectCancel");r&&t(e.target).parents(r).length||n(e)})}function me(){function e(e,n){var r=o.shift();return r||(r=t("<div class='fc-cell-overlay' style='position:absolute;z-index:3'/>")),r[0].parentNode!=n[0]&&r.appendTo(n),a.push(r.css(e).show()),r}function n(){for(var t;t=a.shift();)o.push(t.hide().unbind())}var r=this;r.renderOverlay=e,r.clearOverlays=n;var a=[],o=[]}function ye(t){var e,n,r=this;r.build=function(){e=[],n=[],t(e,n)},r.cell=function(t,r){var a,o=e.length,i=n.length,s=-1,l=-1;for(a=0;o>a;a++)if(r>=e[a][0]&&e[a][1]>r){s=a;break}for(a=0;i>a;a++)if(t>=n[a][0]&&n[a][1]>t){l=a;break}return s>=0&&l>=0?{row:s,col:l}:null},r.rect=function(t,r,a,o,i){var s=i.offset();return{top:e[t][0]-s.top,left:n[r][0]-s.left,width:n[o][1]-n[r][0],height:e[a][1]-e[t][0]}}}function we(e){function n(t){be(t);var n=e.cell(t.pageX,t.pageY);(!n!=!i||n&&(n.row!=i.row||n.col!=i.col))&&(n?(o||(o=n),a(n,o,n.row-o.row,n.col-o.col)):a(n,o),i=n)}var r,a,o,i,s=this;s.start=function(s,l,c){a=s,o=i=null,e.build(),n(l),r=c||"mousemove",t(document).bind(r,n)},s.stop=function(){return t(document).unbind(r,n),i}}function be(t){t.pageX===e&&(t.pageX=t.originalEvent.pageX,t.pageY=t.originalEvent.pageY)}function De(t){function n(e){return a[e]=a[e]||t(e)}var r=this,a={},o={},i={};r.left=function(t){return o[t]=o[t]===e?n(t).position().left:o[t]},r.right=function(t){return i[t]=i[t]===e?r.left(t)+n(t).width():i[t]},r.clear=function(){a={},o={},i={}}}var Ce={defaultView:"month",aspectRatio:1.35,header:{left:"title",center:"",right:"today prev,next"},weekends:!0,weekNumbers:!1,weekNumberCalculation:"iso",weekNumberTitle:"W",allDayDefault:!0,ignoreTimezone:!0,lazyFetching:!0,startParam:"start",endParam:"end",titleFormat:{month:"MMMM yyyy",week:"MMM d[ yyyy]{ '&#8212;'[ MMM] d yyyy}",day:"dddd, MMM d, yyyy"},columnFormat:{month:"ddd",week:"ddd M/d",day:"dddd M/d"},timeFormat:{"":"h(:mm)t"},isRTL:!1,firstDay:0,monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],buttonText:{prev:"<span class='fc-text-arrow'>&lsaquo;</span>",next:"<span class='fc-text-arrow'>&rsaquo;</span>",prevYear:"<span class='fc-text-arrow'>&laquo;</span>",nextYear:"<span class='fc-text-arrow'>&raquo;</span>",today:"today",month:"month",week:"week",day:"day"},theme:!1,buttonIcons:{prev:"circle-triangle-w",next:"circle-triangle-e"},unselectAuto:!0,dropAccept:"*",handleWindowResize:!0},Me={header:{left:"next,prev today",center:"",right:"title"},buttonText:{prev:"<span class='fc-text-arrow'>&rsaquo;</span>",next:"<span class='fc-text-arrow'>&lsaquo;</span>",prevYear:"<span class='fc-text-arrow'>&raquo;</span>",nextYear:"<span class='fc-text-arrow'>&laquo;</span>"},buttonIcons:{prev:"circle-triangle-e",next:"circle-triangle-w"}},Ee=t.fullCalendar={version:"1.6.4"},Se=Ee.views={};t.fn.fullCalendar=function(n){if("string"==typeof n){var a,o=Array.prototype.slice.call(arguments,1);return this.each(function(){var r=t.data(this,"fullCalendar");if(r&&t.isFunction(r[n])){var i=r[n].apply(r,o);a===e&&(a=i),"destroy"==n&&t.removeData(this,"fullCalendar")}}),a!==e?a:this}n=n||{};var i=n.eventSources||[];return delete n.eventSources,n.events&&(i.push(n.events),delete n.events),n=t.extend(!0,{},Ce,n.isRTL||n.isRTL===e&&Ce.isRTL?Me:{},n),this.each(function(e,a){var o=t(a),s=new r(o,n,i);o.data("fullCalendar",s),s.render()}),this},Ee.sourceNormalizers=[],Ee.sourceFetchers=[];var Te={dataType:"json",cache:!1},xe=1;Ee.addDays=l,Ee.cloneDate=d,Ee.parseDate=p,Ee.parseISO8601=m,Ee.parseTime=y,Ee.formatDate=w,Ee.formatDates=b;var ke=["sun","mon","tue","wed","thu","fri","sat"],He=864e5,Fe=36e5,Re=6e4,Ne={s:function(t){return t.getSeconds()},ss:function(t){return _(t.getSeconds())},m:function(t){return t.getMinutes()},mm:function(t){return _(t.getMinutes())},h:function(t){return t.getHours()%12||12},hh:function(t){return _(t.getHours()%12||12)},H:function(t){return t.getHours()},HH:function(t){return _(t.getHours())},d:function(t){return t.getDate()},dd:function(t){return _(t.getDate())},ddd:function(t,e){return e.dayNamesShort[t.getDay()]},dddd:function(t,e){return e.dayNames[t.getDay()]},M:function(t){return t.getMonth()+1},MM:function(t){return _(t.getMonth()+1)},MMM:function(t,e){return e.monthNamesShort[t.getMonth()]},MMMM:function(t,e){return e.monthNames[t.getMonth()]},yy:function(t){return(t.getFullYear()+"").substring(2)},yyyy:function(t){return t.getFullYear()},t:function(t){return 12>t.getHours()?"a":"p"},tt:function(t){return 12>t.getHours()?"am":"pm"},T:function(t){return 12>t.getHours()?"A":"P"},TT:function(t){return 12>t.getHours()?"AM":"PM"},u:function(t){return w(t,"yyyy-MM-dd'T'HH:mm:ss'Z'")},S:function(t){var e=t.getDate();return e>10&&20>e?"th":["st","nd","rd"][e%10-1]||"th"},w:function(t,e){return e.weekNumberCalculation(t)},W:function(t){return D(t)}};Ee.dateFormatters=Ne,Ee.applyAll=I,Se.month=J,Se.basicWeek=V,Se.basicDay=U,n({weekMode:"fixed"}),Se.agendaWeek=$,Se.agendaDay=Q,n({allDaySlot:!0,allDayText:"all-day",firstHour:6,slotMinutes:30,defaultEventMinutes:120,axisFormat:"h(:mm)tt",timeFormat:{agenda:"h:mm{ - h:mm}"},dragOpacity:{agenda:.5},minTime:0,maxTime:24,slotEventOverlap:!0})})(jQuery);
\ No newline at end of file
index e11c1816373a8d1df99c7849c669fe8d28db3307..43607199da3b0e2441d69f4e02c778fe4bc4ef1a 100644 (file)
@@ -1,54 +1,25 @@
+/*!
+ * FullCalendar v1.6.4 Print Stylesheet
+ * Docs & License: http://arshaw.com/fullcalendar/
+ * (c) 2013 Adam Shaw
+ */
+
 /*
- * FullCalendar v1.5.3 Print Stylesheet
- *
  * Include this stylesheet on your page to get a more printer-friendly calendar.
  * When including this stylesheet, use the media='print' attribute of the <link> tag.
  * Make sure to include this stylesheet IN ADDITION to the regular fullcalendar.css.
- *
- * Copyright (c) 2011 Adam Shaw
- * Dual licensed under the MIT and GPL licenses, located in
- * MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
- *
- * Date: Mon Feb 6 22:40:40 2012 -0800
- *
  */
  
  
  /* Events
 -----------------------------------------------------*/
  
-.fc-event-skin {
-       background: none !important;
+.fc-event {
+       background: #fff !important;
        color: #000 !important;
        }
        
-/* horizontal events */
-       
-.fc-event-hori {
-       border-width: 0 0 1px 0 !important;
-       border-bottom-style: dotted !important;
-       border-bottom-color: #000 !important;
-       padding: 1px 0 0 0 !important;
-       }
-       
-.fc-event-hori .fc-event-inner {
-       border-width: 0 !important;
-       padding: 0 1px !important;
-       }
-       
-/* vertical events */
-       
-.fc-event-vert {
-       border-width: 0 0 0 1px !important;
-       border-left-style: dotted !important;
-       border-left-color: #000 !important;
-       padding: 0 1px 0 0 !important;
-       }
-       
-.fc-event-vert .fc-event-inner {
-       border-width: 0 !important;
-       padding: 1px 0 !important;
-       }
+/* for vertical events */
        
 .fc-event-bg {
        display: none !important;
index e9bbe26d824fe65ca88fc1a5e751f817871caa1e..1644227628181efc176b060b46c868098666e44c 100644 (file)
@@ -1,12 +1,7 @@
-/*
- * FullCalendar v1.5.3 Google Calendar Plugin
- *
- * Copyright (c) 2011 Adam Shaw
- * Dual licensed under the MIT and GPL licenses, located in
- * MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
- *
- * Date: Mon Feb 6 22:40:40 2012 -0800
- *
+/*!
+ * FullCalendar v1.6.4 Google Calendar Plugin
+ * Docs & License: http://arshaw.com/fullcalendar/
+ * (c) 2013 Adam Shaw
  */
  
 (function($) {
diff --git a/library/fullcalendar/license.txt b/library/fullcalendar/license.txt
new file mode 100644 (file)
index 0000000..dd7b48e
--- /dev/null
@@ -0,0 +1,20 @@
+Copyright (c) 2013 Adam Shaw
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.