Index: core.js
===================================================================
--- core.js	(revision 5007)
+++ core.js	(working copy)
@@ -25,6 +25,12 @@
     }
 }
 
+function cancelEventPropagation(e) {
+    if (!e) e = window.event;
+    e.cancelBubble = true;
+    if (e.stopPropagation) e.stopPropagation();
+}
+
 // quickElement(tagType, parentReference, textInChildNode, [, attribute, attributeValue ...]);
 function quickElement() {
     var obj = document.createElement(arguments[0]);
@@ -40,6 +46,11 @@
     return obj;
 }
 
+// "a" is reference to an object
+function removeChildren(a) {
+    while (a.hasChildNodes()) a.removeChild(a.lastChild);
+}
+
 // ----------------------------------------------------------------------------
 // Cross-browser xmlhttp object
 // from http://jibbering.com/2002/4/httprequest.html
Index: calendar.js
===================================================================
--- calendar.js	(revision 5007)
+++ calendar.js	(working copy)
@@ -2,25 +2,6 @@
 calendar.js - Calendar functions by Adrian Holovaty
 */
 
-function removeChildren(a) { // "a" is reference to an object
-    while (a.hasChildNodes()) a.removeChild(a.lastChild);
-}
-
-// quickElement(tagType, parentReference, textInChildNode, [, attribute, attributeValue ...]);
-function quickElement() {
-    var obj = document.createElement(arguments[0]);
-    if (arguments[2] != '' && arguments[2] != null) {
-        var textNode = document.createTextNode(arguments[2]);
-        obj.appendChild(textNode);
-    }
-    var len = arguments.length;
-    for (var i = 3; i < len; i += 2) {
-        obj.setAttribute(arguments[i], arguments[i+1]);
-    }
-    arguments[1].appendChild(obj);
-    return obj;
-}
-
 // CalendarNamespace -- Provides a collection of HTML calendar-related helper functions
 var CalendarNamespace = {
     monthsOfYear: gettext('January February March April May June July August September October November December').split(' '),
Index: admin/ordering.js
===================================================================
--- admin/ordering.js	(revision 5007)
+++ admin/ordering.js	(working copy)
@@ -120,18 +120,3 @@
     draw();
 }
 
-function addEvent(elm, evType, fn, useCapture)
-// addEvent and removeEvent
-// cross-browser event handling for IE5+,  NS6 and Mozilla
-// By Scott Andrew
-{
-  if (elm.addEventListener){
-    elm.addEventListener(evType, fn, useCapture);
-    return true;
-  } else if (elm.attachEvent){
-    var r = elm.attachEvent("on"+evType, fn);
-    return r;
-  } else {
-    elm['on'+evType] = fn;
-  }
-}
Index: admin/DateTimeShortcuts.js
===================================================================
--- admin/DateTimeShortcuts.js	(revision 5007)
+++ admin/DateTimeShortcuts.js	(working copy)
@@ -6,6 +6,8 @@
     calendars: [],
     calendarInputs: [],
     clockInputs: [],
+    dismissCalendarFunc: [],
+    dismissClockFunc: [],
     calendarDivName1: 'calendarbox', // name of calendar <div> that gets toggled
     calendarDivName2: 'calendarin',  // name of <div> that contains calendar
     calendarLinkName: 'calendarlink',// name of the link that is used to toggle
@@ -39,6 +41,7 @@
     addClock: function(inp) {
         var num = DateTimeShortcuts.clockInputs.length;
         DateTimeShortcuts.clockInputs[num] = inp;
+	DateTimeShortcuts.dismissClockFunc[num] = function() { DateTimeShortcuts.dismissClock(num); return true; };
 
         // Shortcut links (clock icon and "Now" link)
         var shortcuts_span = document.createElement('span');
@@ -75,7 +78,7 @@
         clock_box.className = 'clockbox module';
         clock_box.setAttribute('id', DateTimeShortcuts.clockDivName + num);
         document.body.appendChild(clock_box);
-        addEvent(clock_box, 'click', DateTimeShortcuts.cancelEventPropagation);
+        addEvent(clock_box, 'click', cancelEventPropagation);
 
         quickElement('h2', clock_box, gettext('Choose a time'));
         time_list = quickElement('ul', clock_box, '');
@@ -109,11 +112,11 @@
     
         // Show the clock box
         clock_box.style.display = 'block';
-        addEvent(window, 'click', function() { DateTimeShortcuts.dismissClock(num); return true; });
+        addEvent(document, 'click', DateTimeShortcuts.dismissClockFunc[num]);
     },
     dismissClock: function(num) {
        document.getElementById(DateTimeShortcuts.clockDivName + num).style.display = 'none';
-       window.onclick = null;
+	removeEvent(document, 'click', DateTimeShortcuts.dismissClockFunc[num]);
     },
     handleClockQuicklink: function(num, val) {
        DateTimeShortcuts.clockInputs[num].value = val;
@@ -122,8 +125,8 @@
     // Add calendar widget to a given field.
     addCalendar: function(inp) {
         var num = DateTimeShortcuts.calendars.length;
-
         DateTimeShortcuts.calendarInputs[num] = inp;
+	DateTimeShortcuts.dismissCalendarFunc[num] = function() { DateTimeShortcuts.dismissCalendar(num); return true; };
 
         // Shortcut links (calendar icon and "Today" link)
         var shortcuts_span = document.createElement('span');
@@ -163,7 +166,7 @@
         cal_box.className = 'calendarbox module';
         cal_box.setAttribute('id', DateTimeShortcuts.calendarDivName1 + num);
         document.body.appendChild(cal_box);
-        addEvent(cal_box, 'click', DateTimeShortcuts.cancelEventPropagation);
+        addEvent(cal_box, 'click', cancelEventPropagation);
 
         // next-prev links
         var cal_nav = quickElement('div', cal_box, '');
@@ -211,10 +214,11 @@
         cal_box.style.top = findPosY(cal_link) - 75 + 'px';
     
         cal_box.style.display = 'block';
-        addEvent(window, 'click', function() { DateTimeShortcuts.dismissCalendar(num); return true; });
+        addEvent(document, 'click', DateTimeShortcuts.dismissCalendarFunc[num]);
     },
     dismissCalendar: function(num) {
         document.getElementById(DateTimeShortcuts.calendarDivName1+num).style.display = 'none';
+	removeEvent(document, 'click', DateTimeShortcuts.dismissCalendarFunc[num]);
     },
     drawPrev: function(num) {
         DateTimeShortcuts.calendars[num].drawPreviousMonth();
@@ -223,18 +227,13 @@
         DateTimeShortcuts.calendars[num].drawNextMonth();
     },
     handleCalendarCallback: function(num) {
-        return "function(y, m, d) { DateTimeShortcuts.calendarInputs["+num+"].value = y+'-'+m+'-'+d; document.getElementById(DateTimeShortcuts.calendarDivName1+"+num+").style.display='none';}";
+	return "function(y, m, d) { var d = new Date(y, m, d); DateTimeShortcuts.calendarInputs["+num+"].value = d.getISODate(); DateTimeShortcuts.dismissCalendar("+num+");}";
     },
     handleCalendarQuickLink: function(num, offset) {
        var d = new Date();
        d.setDate(d.getDate() + offset)
        DateTimeShortcuts.calendarInputs[num].value = d.getISODate();
        DateTimeShortcuts.dismissCalendar(num);
-    },
-    cancelEventPropagation: function(e) {
-        if (!e) e = window.event;
-        e.cancelBubble = true;
-        if (e.stopPropagation) e.stopPropagation();
     }
 }
 
