Merge new summary view branches changes into trunk
[citadel.git] / webcit / static / wclib.js
1 //
2 // $Id$
3 //
4 // JavaScript function library for WebCit.
5 //
6 //
7
8
9 var browserType;
10 var room_is_trash = 0;
11
12 var currentlyExpandedFloor = null;
13 var roomlist = null;
14
15 var _switchToRoomList = "switch to room list";
16 var _switchToMenu = "switch to menu";
17
18 var currentDropTarget = null;
19
20 var supportsAddEventListener = (!!document.addEventListener);
21 var today = new Date();
22
23 if (document.all) {browserType = "ie"}
24 if (window.navigator.userAgent.toLowerCase().match("gecko")) {
25         browserType= "gecko";
26 }
27 var ns6=document.getElementById&&!document.all;
28 Event.observe(window, 'load', ToggleTaskDateOrNoDateActivate);
29 Event.observe(window, 'load', taskViewActivate);
30 //document.observe("dom:loaded", setupPrefEngine);
31 document.observe("dom:loaded", setupIconBar);
32 function CtdlRandomString()  {
33         return((Math.random()+'').substr(3));
34 }
35
36 function emptyElement(element) {
37   childNodes = element.childNodes;
38   for(var i=0; i<childNodes.length; i++) {
39     element.removeChild(childNodes[i]);
40   }
41 }
42 /** Implements superior internet explorer 'extract all child text from element' feature'. Falls back on buggy, patent violating standardized method */
43 function getTextContent(element) {
44   if (element.textContent == undefined) {
45     return element.innerText;
46   }
47   return element.textContent;
48 }
49 /** Same reasons as above */
50 function setTextContent(element, textContent) {
51   if(element.textContent == undefined) {
52     element.innerText = textContent;
53   } else {
54   element.textContent = textContent;
55   }
56 }
57
58 // We love string tokenizers.
59 function extract_token(source_string, token_num, delimiter) {
60         var i = 0;
61         var extracted_string = source_string;
62
63         if (token_num > 0) {
64                 for (i=0; i<token_num; ++i) {
65                         var j = extracted_string.indexOf(delimiter);
66                         if (j >= 0) {
67                                 extracted_string = extracted_string.substr(j+1);
68                         }
69                 }
70         }
71
72         j = extracted_string.indexOf(delimiter);
73         if (j >= 0) {
74                 extracted_string = extracted_string.substr(0, j);
75         }
76
77         return extracted_string;
78 }
79
80 function CtdlSpawnContextMenu(event, source) {
81   // remove any existing menus
82   disintergrateContextMenus(null);
83   var x = event.clientX-10; // cut a few pixels out so our mouseout works right
84   var y = event.clientY-10;
85   var contextDIV = document.createElement("div");
86   contextDIV.setAttribute("id", "ctdlContextMenu");
87   document.body.appendChild(contextDIV);
88   var sourceChildren = source.childNodes;
89   for(var j=0; j<sourceChildren.length; j++) {
90     contextDIV.appendChild(sourceChildren[j].cloneNode(true));
91   }
92   var leftRule = "left: "+x+"px;";
93   contextDIV.setAttribute("style", leftRule);
94   contextDIV.setAttribute("actual", leftRule);
95   contextDIV.style.top = y+"px";
96   contextDIV.style.display = "block";
97   $(contextDIV).observe('mouseout',disintergrateContextMenus);
98 }
99 function disintergrateContextMenus(event) {
100   var contextMenu = document.getElementById("ctdlContextMenu");
101   if (contextMenu) {
102     contextMenu.parentNode.removeChild(contextMenu);
103   }
104   Event.stopObserving(document,'click',disintergrateContextMenus);
105 }
106 // This code handles the popups for important-messages.
107 function hide_imsg_popup() {
108         if (browserType == "gecko") {
109                 document.poppedLayer = eval('document.getElementById(\'important_message\')');
110         }
111         else if (browserType == "ie") {
112                 document.poppedLayer = eval('document.all[\'important_message\']');
113         }
114         else {
115                 document.poppedLayer = eval('document.layers[\'`important_message\']');
116         }
117
118         document.poppedLayer.style.visibility = "hidden";
119 }
120
121
122 // This function activates the ajax-powered recipient autocompleters on the message entry screen.
123 function activate_entmsg_autocompleters() {
124         new Ajax.Autocompleter('cc_id', 'cc_name_choices', 'cc_autocomplete', {} );
125         new Ajax.Autocompleter('bcc_id', 'bcc_name_choices', 'bcc_autocomplete', {} );
126         new Ajax.Autocompleter('recp_id', 'recp_name_choices', 'recp_autocomplete', {} );
127 }
128
129 function setupIconBar() {
130   if (!document.getElementById("switch")) {
131       return;
132     }
133   var switchSpan = document.getElementById("switch").firstChild;
134   if (switchSpan != null) {
135     setTextContent(switchSpan, _switchToRoomList);
136     $(switchSpan).observe('click', changeIconBarEvent);
137     var currentView = ctdlLocalPrefs.readPref("iconbar_view");
138     if (currentView != null) {
139       switchSpan.ctdlSwitchIconBarTo = currentView;
140       changeIconBar(switchSpan);
141     } else {
142       switchSpan.ctdlSwitchIconBarTo = "rooms";
143     }
144   }
145   var online_users = document.getElementById("online_users");
146   var ou_displayAs = online_users.style.display;
147   if (ou_displayAs != "none") {
148     new Ajax.PeriodicalUpdater('online_users', 'do_template?template=wholist_section', {method: 'get', frequency: 30});
149   }
150 }
151 function changeIconBarEvent(event) {
152   changeIconBar(event.target);
153 }
154 function changeIconBar(target) {
155   var switchTo = target.ctdlSwitchIconBarTo;
156   if (!!window.console) {
157     console.log("Changing to: " + switchTo);
158   }
159   ctdlLocalPrefs.setPref("iconbar_view", target.ctdlSwitchIconBarTo);  
160   if (switchTo == "rooms") {
161     switch_to_room_list();
162     setTextContent(target, _switchToMenu);
163     target.ctdlSwitchIconBarTo = "menu";
164   } else {
165     switch_to_menu_buttons();
166     setTextContent(target, _switchToRoomList);
167     target.ctdlSwitchIconBarTo = "rooms";
168   }
169 }
170 function switch_to_room_list() {
171   var roomlist = document.getElementById("roomlist");
172   var summary = document.getElementById("iconbar_menu");
173   if (!rooms || !floors || !roomlist) {
174     FillRooms(IconBarRoomList);
175   }
176   roomlist.className = roomlist.className.replace("hidden","");
177   summary.className += " hidden";
178 }
179
180 function switch_to_menu_buttons() {
181   if (roomlist != null) {
182     roomlist.className += "hidden";
183   }
184   var iconbar = document.getElementById("iconbar_menu");
185   iconbar.className = iconbar.className.replace("hidden","");
186   var roomlist = document.getElementById("roomlist");
187   roomlist.className += " hidden";
188 }
189 function IconBarRoomList() {
190   var currentExpanded = ctdlLocalPrefs.readPref("rooms_expanded");
191   currentDropTargets = new Array();
192   var iconbar = document.getElementById("iconbar");
193   roomlist = document.getElementById("roomlist");
194   var ul = document.createElement("ul");
195   roomlist.appendChild(ul);
196   // Add mailbox, because they are special
197   var mailboxLI = document.createElement("li");
198   ul.appendChild(mailboxLI);
199   var mailboxSPAN = document.createElement("span");
200   mailboxSPAN.appendChild(document.createTextNode("Mailbox"));
201   $(mailboxSPAN).observe('click', expandFloorEvent);
202   mailboxLI.appendChild(mailboxSPAN);
203   mailboxLI.setAttribute("class", "floor");
204   var mailboxUL = document.createElement("ul");
205   mailboxLI.appendChild(mailboxUL);
206   var mailboxRooms = GetMailboxRooms();
207   for(var i=0; i<mailboxRooms.length; i++) {
208     var room = mailboxRooms[i];
209     currentDropTargets.push(addRoomToList(mailboxUL, room));
210   }
211   if (currentExpanded != null && currentExpanded == "Mailbox") {
212     expandFloor(mailboxSPAN);
213   }
214   for(var a=0; a<floors.length; a++) {
215     var floor = floors[a];
216     var floornum = floor[0];
217     var name = floor[1];
218     var floorLI = document.createElement("li");
219     ul.appendChild(floorLI);
220     var floorSPAN = document.createElement("span");
221     floorSPAN.appendChild(document.createTextNode(name));
222     $(floorSPAN).observe('click', expandFloorEvent);
223     floorLI.appendChild(floorSPAN);
224     floorLI.setAttribute("class", "floor");
225     var floorUL = document.createElement("ul");
226     floorLI.appendChild(floorUL);
227     var roomsForFloor = GetRoomsByFloorNum(floornum);
228     for(var b=0; b<roomsForFloor.length; b++) {
229       var room = roomsForFloor[b];
230       currentDropTargets.push(addRoomToList(floorUL, room));
231     }
232     if (currentExpanded != null && currentExpanded == name) {
233       expandFloor(floorSPAN);
234     }
235   }
236 }
237
238 function addRoomToList(floorUL,room) {
239   var roomName = room[RN_ROOM_NAME];
240   var flag = room[RN_ROOM_FLAG];
241   var curView = room[RN_CUR_VIEW];
242   var view = room[RN_DEF_VIEW];
243   var isMailBox = ((flag & QR_MAILBOX) == QR_MAILBOX);
244   var hasNewMsgs = ((curView & UA_HASNEWMSGS) == UA_HASNEWMSGS);
245   var roomLI = document.createElement("li");
246   var roomA = document.createElement("a");
247   roomA.setAttribute("href","dotgoto?room="+roomName);
248   roomA.appendChild(document.createTextNode(roomName));
249   roomLI.appendChild(roomA);
250   floorUL.appendChild(roomLI);
251   var className = "room ";
252   if (view == VIEW_MAILBOX) {
253     className += "room-private"
254   } else if (view == VIEW_ADDRESSBOOK) {
255     className += "room-addr";
256   } else if (view == VIEW_CALENDAR || view == VIEW_CALBRIEF) {
257     className += "room-cal";
258   } else if (view == VIEW_TASKS) {
259     className += "room-tasks";
260   } else if (view == VIEW_NOTES) {
261     className += "room-notes";
262   } else {
263     className += "room-chat";
264   }
265   if (hasNewMsgs) {
266     className += " room-newmsgs";
267   }
268   roomLI.setAttribute("class", className);
269   roomA.dropTarget = true;
270   roomA.dropHandler = roomListDropHandler;
271   return roomLI;
272 }
273
274 function roomListDropHandler(target, dropped) {
275   if (dropped.ctdlMsgId) {
276     var room = getTextContent(target);
277     var msgIds = "";
278     for(msgId in currentlyMarkedRows) { //defined in summaryview.js
279       msgIds += ","+msgId;
280     }
281     var mvCommand = "g_cmd=MOVE " + msgIds + "|"+room+"|0";
282     new Ajax.Request('ajax_servcmd', {
283       method: 'post',
284           parameters: mvCommand,
285           onComplete: deleteAllMarkedRows()});
286     } 
287 }
288 function expandFloorEvent(event) {
289   expandFloor(event.target);
290 }
291 function expandFloor(target) {
292   if (target.nodeName.toLowerCase() != "span") {
293     return; // ignore clicks on child UL
294   }
295   ctdlLocalPrefs.setPref("rooms_expanded", target.firstChild.nodeValue);
296   var parentUL = target.parentNode;
297   if (currentlyExpandedFloor != null) {
298     currentlyExpandedFloor.className = currentlyExpandedFloor.className.replace("floor-expanded","");
299   }
300   parentUL.className = parentUL.className + " floor-expanded";
301   currentlyExpandedFloor = parentUL;
302 }
303
304 // These functions handle moving sticky notes around the screen by dragging them
305
306 var uid_of_note_being_dragged = 0;
307 var saved_cursor_style = 'default';
308 var note_was_dragged = 0;
309
310 function NotesDragMouseUp(evt) {
311         document.onmouseup = null;
312         document.onmousemove = null;
313         if (document.layers) {
314                 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
315         }
316
317         d = $('note-' + uid_of_note_being_dragged);
318         d.style.cursor = saved_cursor_style;
319
320         // If any motion actually occurred, submit an ajax http call to record it to the server
321         if (note_was_dragged > 0) {
322                 p = 'note_uid=' + uid_of_note_being_dragged
323                         + '&left=' + d.style.left
324                         + '&top=' + d.style.top
325                         + '&r=' + CtdlRandomString();
326                 new Ajax.Request(
327                         'ajax_update_note',
328                         {
329                                 method: 'post',
330                                 parameters: p
331                         }
332                 );
333         }
334
335         uid_of_note_being_dragged = '';
336         return true;
337 }
338
339 function NotesDragMouseMove(evt) {
340         x = (ns6 ? evt.clientX : event.clientX);
341         x_increment = x - saved_x;
342         y = (ns6 ? evt.clientY : event.clientY);
343         y_increment = y - saved_y;
344
345         // Move the div
346         d = $('note-' + uid_of_note_being_dragged);
347
348         divTop = parseInt(d.style.top);
349         divLeft = parseInt(d.style.left);
350
351         d.style.top = (divTop + y_increment) + 'px';
352         d.style.left = (divLeft + x_increment) + 'px';
353
354         saved_x = x;
355         saved_y = y;
356         note_was_dragged = 1;
357         return true;
358 }
359
360
361 function NotesDragMouseDown(evt, uid) {
362         saved_x = (ns6 ? evt.clientX : event.clientX);
363         saved_y = (ns6 ? evt.clientY : event.clientY);
364         document.onmouseup = NotesDragMouseUp;
365         document.onmousemove = NotesDragMouseMove;
366         if (document.layers) {
367                 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
368         }
369         uid_of_note_being_dragged = uid;
370         d = $('note-' + uid_of_note_being_dragged);
371         saved_cursor_style = d.style.cursor;
372         d.style.cursor = 'move';
373         return false;           // disable the default action
374 }
375
376
377 // Called when the user clicks on the palette icon of a sticky note to change its color.
378 // It toggles the color selector visible or invisible.
379
380 function NotesClickPalette(evt, uid) {
381         uid_of_note_being_colored = uid;
382         d = $('palette-' + uid_of_note_being_colored);
383
384         if (d.style.display) {
385                 if (d.style.display == 'none') {
386                         d.style.display = 'block';
387                 }
388                 else {
389                         d.style.display = 'none';
390                 }
391         }
392         else {
393                 d.style.display = 'block';
394         }
395
396         return true;
397 }
398
399
400 // Called when the user clicks on one of the colors in an open color selector.
401 // Sets the desired color and then closes the color selector.
402
403 function NotesClickColor(evt, uid, red, green, blue, notecolor, titlecolor) {
404         uid_of_note_being_colored = uid;
405         palette_button = $('palette-' + uid_of_note_being_colored);
406         note_div = $('note-' + uid_of_note_being_colored);
407         titlebar_div = $('titlebar-' + uid_of_note_being_colored);
408
409         // alert('FIXME red=' + red + ' green=' + green + ' blue=' + blue);
410
411         note_div.style.backgroundColor = notecolor;
412         titlebar_div.style.backgroundColor = titlecolor;
413         palette_button.style.display = 'none';
414
415         // submit an ajax http call to record it to the server
416         p = 'note_uid=' + uid_of_note_being_colored
417                 + '&red=' + red
418                 + '&green=' + green
419                 + '&blue=' + blue
420                 + '&r=' + CtdlRandomString();
421         new Ajax.Request(
422                 'ajax_update_note',
423                 {
424                         method: 'post',
425                         parameters: p
426                 }
427         );
428 }
429
430
431
432
433 // These functions handle resizing sticky notes by dragging the resize handle
434
435 var uid_of_note_being_resized = 0;
436 var saved_cursor_style = 'default';
437 var note_was_resized = 0;
438
439 function NotesResizeMouseUp(evt) {
440         document.onmouseup = null;
441         document.onmousemove = null;
442         if (document.layers) {
443                 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
444         }
445
446         d = $('note-' + uid_of_note_being_resized);
447         d.style.cursor = saved_cursor_style;
448
449         // If any motion actually occurred, submit an ajax http call to record it to the server
450         if (note_was_resized > 0) {
451                 p = 'note_uid=' + uid_of_note_being_resized
452                         + '&width=' + d.style.width
453                         + '&height=' + d.style.height
454                         + '&r=' + CtdlRandomString();
455                 new Ajax.Request(
456                         'ajax_update_note',
457                         {
458                                 method: 'post',
459                                 parameters: p
460                         }
461                 );
462         }
463
464         uid_of_note_being_resized = '';
465         return false;           // disable the default action
466 }
467
468 function NotesResizeMouseMove(evt) {
469         x = (ns6 ? evt.clientX : event.clientX);
470         x_increment = x - saved_x;
471         y = (ns6 ? evt.clientY : event.clientY);
472         y_increment = y - saved_y;
473
474         // Move the div
475         d = $('note-' + uid_of_note_being_resized);
476
477         divTop = parseInt(d.style.height);
478         divLeft = parseInt(d.style.width);
479
480         d.style.height = (divTop + y_increment) + 'px';
481         d.style.width = (divLeft + x_increment) + 'px';
482
483         saved_x = x;
484         saved_y = y;
485         note_was_resized = 1;
486         return false;           // disable the default action
487 }
488
489
490 function NotesResizeMouseDown(evt, uid) {
491         saved_x = (ns6 ? evt.clientX : event.clientX);
492         saved_y = (ns6 ? evt.clientY : event.clientY);
493         document.onmouseup = NotesResizeMouseUp;
494         document.onmousemove = NotesResizeMouseMove;
495         if (document.layers) {
496                 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
497         }
498         uid_of_note_being_resized = uid;
499         d = $('note-' + uid_of_note_being_resized);
500         saved_cursor_style = d.style.cursor;
501         d.style.cursor = 'move';
502         return false;           // disable the default action
503 }
504
505
506 function DeleteStickyNote(evt, uid, confirmation_prompt) {
507         uid_of_note_being_deleted = uid;
508         d = $('note-' + uid_of_note_being_deleted);
509
510         if (confirm(confirmation_prompt)) {
511                 new Effect.Puff(d);
512
513                 // submit an ajax http call to delete it on the server
514                 p = 'note_uid=' + uid_of_note_being_deleted
515                         + '&deletenote=yes'
516                         + '&r=' + CtdlRandomString();
517                 new Ajax.Request(
518                         'ajax_update_note',
519                         {
520                                 method: 'post',
521                                 parameters: p
522                         }
523                 );
524         }
525 }
526
527 function ctdl_ts_getInnerText(el) {
528         if (typeof el == "string") return el;
529         if (typeof el == "undefined") { return el };
530         if (el.innerText) return el.innerText;  //Not needed but it is faster
531         var str = "";
532         
533         var cs = el.childNodes;
534         var l = cs.length;
535         for (var i = 0; i < l; i++) {
536                 switch (cs[i].nodeType) {
537                         case 1: //ELEMENT_NODE
538                                 str += ts_getInnerText(cs[i]);
539                                 break;
540                         case 3: //TEXT_NODE
541                                 str += cs[i].nodeValue;
542                                 break;
543                 }
544         }
545         return str;
546 }
547
548
549 // Place a gradient loadscreen on an element, e.g to use before Ajax.updater
550 function CtdlLoadScreen(elementid) {
551 var elem = document.getElementById(elementid);
552 elem.innerHTML = "<div align=center><br><table border=0 cellpadding=10 bgcolor=\"#ffffff\"><tr><td><img src=\"static/throbber.gif\" /><font color=\"#AAAAAA\">&nbsp;&nbsp;Loading....</font></td></tr></table><br /></div>";
553 }
554
555
556
557 // Pop open the address book (target_input is the INPUT field to populate)
558
559 function PopOpenAddressBook(target_input) {
560         $('address_book_popup').style.display = 'block';
561         p = 'target_input=' + target_input + '&r=' + CtdlRandomString();
562         new Ajax.Updater(
563                 'address_book_popup_middle_div',
564                 'display_address_book_middle_div',
565                 {
566                         method: 'get',
567                         parameters: p,
568                         evalScripts: true
569                 }
570         );
571 }
572
573 function PopulateAddressBookInnerDiv(which_addr_book, target_input) {
574         $('address_book_inner_div').innerHTML = "<div align=center><br><table border=0 cellpadding=10 bgcolor=\"#ffffff\"><tr><td><img src=\"static/throbber.gif\" /><font color=\"#AAAAAA\">&nbsp;&nbsp;Loading....</font></td></tr></table><br /></div>";
575         p = 'which_addr_book=' + which_addr_book
576           + '&target_input=' + target_input
577           + '&r=' + CtdlRandomString();
578         new Ajax.Updater(
579                 'address_book_inner_div',
580                 'display_address_book_inner_div',
581                 {
582                         method: 'get',
583                         parameters: p
584                 }
585         );
586 }
587
588 // What happens when a contact is selected from the address book popup
589 // (populate the specified target)
590
591 function AddContactsToTarget(target, whichaddr) {
592         while (whichaddr.selectedIndex != -1) {
593                 if (target.value.length > 0) {
594                         target.value = target.value + ', ';
595                 }
596                 target.value = target.value + whichaddr.value;
597                 whichaddr.options[whichaddr.selectedIndex].selected = false;
598         }
599 }
600
601 // Respond to a meeting invitation
602 function RespondToInvitation(question_divname, title_divname, msgnum, cal_partnum, sc) {
603         p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
604         new Ajax.Updater(title_divname, 'respond_to_request', { method: 'post', parameters: p } );
605         Effect.Fade(question_divname, { duration: 0.5 });
606 }
607
608 // Handle a received RSVP
609 function HandleRSVP(question_divname, title_divname, msgnum, cal_partnum, sc) {
610         p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
611         new Ajax.Updater(title_divname, 'handle_rsvp', { method: 'post', parameters: p } );
612         Effect.Fade(question_divname, { duration: 0.5 });
613 }
614 /* var fakeMouse = document.createEvent("MouseEvents");
615  fakeMouse.initMouseEvent("click", true, true, window, 
616    0,0,0,0,0, false, false, false, false, 0, null); */
617 // TODO: Collapse into one function
618 function toggleTaskDtStart(event) {
619         var checkBox = $('nodtstart');
620         dtStart = document.getElementById("dtstart");
621         if (checkBox.checked) {
622                 dtStart.disabled = true;
623                 dtStart.style.textDecoration = "line-through";
624         } else {
625                 dtStart.disabled = false;
626                 dtStart.style.textDecoration = "";
627                 if (dtStart.value.length == 0)
628                         dtStart.dpck._initCurrentDate();
629         }
630 }
631 function toggleTaskDue(event) {
632         var checkBox = $('nodue');
633         dueField = document.getElementById("due");
634         if (checkBox.checked) {
635                 dueField.disabled = true;
636                 dueField.style.textDecoration = "line-through";
637         } else {
638                 dueField.disabled = false;
639                 dueField.style.textDecoration = "";
640                 if (dueField.value.length == 0)
641                         dueField.dpck._initCurrentDate();
642         }
643 }
644 function ToggleTaskDateOrNoDateActivate(event) {
645         var dtstart = document.getElementById("nodtstart");
646         if (dtstart != null) {
647                 toggleTaskDtStart(null);
648                 toggleTaskDue(null);
649                 $('nodtstart').observe('click', toggleTaskDtStart);
650                 $('nodue').observe('click', toggleTaskDue);
651         } 
652 }
653 function TaskViewGatherCategoriesFromTable() {
654         var table = $('taskview');
655         
656 }
657 function attachDatePicker(relative) {
658         var dpck = new DatePicker({
659         relative: relative,
660         language: 'en', // fix please
661         disableFutureDate: false
662         });
663         document.getElementById(relative).dpck = dpck; // attach a ref to it
664 }
665 function eventEditAllDay() {
666         var allDayCheck = document.getElementById("alldayevent");
667         var dtend= document.getElementById("dtendcell");
668         if(allDayCheck.checked) {
669                 //dtend.disabled = true;
670                 dtend.style.textDecoration = "line-through";
671         } else {
672                 //dtend_day.disabled = false;
673                 dtend.style.textDecoration = "";
674         }
675 }
676
677
678
679
680 // Functions which handle show/hide of various elements in the recurrence editor
681
682 function RecurrenceShowHide() {
683
684         if ($('is_recur').checked) {
685                 $('rrule_div').style.display = 'block';
686         }
687         else {
688                 $('rrule_div').style.display = 'none';
689         }
690
691         if ($('freq_selector').selectedIndex == 4) {
692                 $('weekday_selector').style.display = 'block';
693         }
694         else {
695                 $('weekday_selector').style.display = 'none';
696         }
697
698         if ($('freq_selector').selectedIndex == 5) {
699                 $('monthday_selector').style.display = 'block';
700         }
701         else {
702                 $('monthday_selector').style.display = 'none';
703         }
704
705         if ($('rrend_count').checked) {
706                 $('rrcount').disabled = false;
707         }
708         else {
709                 $('rrcount').disabled = true;
710         }
711
712         if ($('rrend_until').checked) {
713                 $('rruntil').disabled = false;
714         }
715         else {
716                 $('rruntil').disabled = true;
717         }
718
719         if ($('rrmonthtype_mday').checked) {
720                 $('rrmday').disabled = false;
721         }
722         else {
723                 $('rrmday').disabled = true;
724         }
725
726         if ($('rrmonthtype_wday').checked) {
727                 $('rrmweek').disabled = false;
728                 $('rrmweekday').disabled = false;
729         }
730         else {
731                 $('rrmweek').disabled = true;
732                 $('rrmweekday').disabled = true;
733         }
734
735         if ($('freq_selector').selectedIndex == 6) {
736                 $('yearday_selector').style.display = 'block';
737         }
738         else {
739                 $('yearday_selector').style.display = 'none';
740         }
741
742         $('ymday').innerHTML = 'XXXX-' + $('dtstart').value.substr(5);
743         $('rrmday').innerHTML = $('dtstart').value.substr(8);
744
745         if ($('rryeartype_ywday').checked) {
746                 $('rrymweek').disabled = false;
747                 $('rrymweekday').disabled = false;
748                 $('rrymonth').disabled = false;
749         }
750         else {
751                 $('rrymweek').disabled = true;
752                 $('rrymweekday').disabled = true;
753                 $('rrymonth').disabled = true;
754         }
755
756 }