3 * Copyright 2005 - 2009 The Citadel Team
4 * Licensed under the GPL V3
6 * JavaScript function library for WebCit.
12 var room_is_trash = 0;
14 var currentlyExpandedFloor = null;
17 var _switchToRoomList = "switch to room list";
18 var _switchToMenu = "switch to menu";
20 var currentDropTarget = null;
22 var supportsAddEventListener = (!!document.addEventListener);
23 var today = new Date();
27 if (document.all) {browserType = "ie"}
28 if (window.navigator.userAgent.toLowerCase().match("gecko")) {
31 var ns6=document.getElementById&&!document.all;
32 Event.observe(window, 'load', ToggleTaskDateOrNoDateActivate);
33 Event.observe(window, 'load', taskViewActivate);
34 Event.observe(window, 'load', fixbanner);
35 Event.observe(window, 'load', resizeViewport);
36 Event.observe(window, 'resize', resizeViewport);
37 //document.observe("dom:loaded", setupPrefEngine);
38 document.observe("dom:loaded", setupIconBar);
39 document.observe('dom:loaded', function() { if (!!document.getElementById("ib_chat_launch")) { $('ib_chat_launch').observe('click', launchChat); } });
40 function CtdlRandomString() {
41 return((Math.random()+'').substr(3));
43 function strcmp ( str1, str2 ) {
44 // http://kevin.vanzonneveld.net
45 // + original by: Waldo Malqui Silva
46 // + input by: Steve Hilder
47 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
48 // + revised by: gorthaur
49 // * example 1: strcmp( 'waldo', 'owald' );
51 // * example 2: strcmp( 'owald', 'waldo' );
54 return ( ( str1 == str2 ) ? 0 : ( ( str1 > str2 ) ? 1 : -1 ) );
57 function emptyElement(element) {
58 childNodes = element.childNodes;
59 for(var i=0; i<childNodes.length; i++) {
61 element.removeChild(childNodes[i]);
63 WCLog(e+"|"+e.description);
67 /** Implements superior internet explorer 'extract all child text from element' feature'. Falls back on buggy, patent violating standardized method */
68 function getTextContent(element) {
69 if (element.textContent == undefined) {
70 return element.innerText;
72 return element.textContent;
74 /** Same reasons as above */
75 function setTextContent(element, textContent) {
76 if(element.textContent == undefined) {
77 element.innerText = textContent;
79 element.textContent = textContent;
83 // We love string tokenizers.
84 function extract_token(source_string, token_num, delimiter) {
86 var extracted_string = source_string;
89 for (i=0; i<token_num; ++i) {
90 var j = extracted_string.indexOf(delimiter);
92 extracted_string = extracted_string.substr(j+1);
97 j = extracted_string.indexOf(delimiter);
99 extracted_string = extracted_string.substr(0, j);
102 return extracted_string;
105 function CtdlSpawnContextMenu(event, source) {
106 // remove any existing menus
107 disintergrateContextMenus(null);
108 var x = event.clientX-10; // cut a few pixels out so our mouseout works right
109 var y = event.clientY-10;
110 var contextDIV = document.createElement("div");
111 contextDIV.setAttribute("id", "ctdlContextMenu");
112 document.body.appendChild(contextDIV);
113 var sourceChildren = source.childNodes;
114 for(var j=0; j<sourceChildren.length; j++) {
115 contextDIV.appendChild(sourceChildren[j].cloneNode(true));
117 var leftRule = "left: "+x+"px;";
118 contextDIV.setAttribute("style", leftRule);
119 contextDIV.setAttribute("actual", leftRule);
120 contextDIV.style.top = y+"px";
121 contextDIV.style.display = "block";
122 $(contextDIV).observe('mouseout',disintergrateContextMenus);
124 function disintergrateContextMenus(event) {
125 var contextMenu = document.getElementById("ctdlContextMenu");
127 contextMenu.parentNode.removeChild(contextMenu);
129 Event.stopObserving(document,'click',disintergrateContextMenus);
131 // This code handles the popups for important-messages.
132 function hide_imsg_popup() {
133 if (browserType == "gecko") {
134 document.poppedLayer = eval('document.getElementById(\'important_message\')');
136 else if (browserType == "ie") {
137 document.poppedLayer = eval('document.all[\'important_message\']');
140 document.poppedLayer = eval('document.layers[\'`important_message\']');
143 document.poppedLayer.style.visibility = "hidden";
147 // This function activates the ajax-powered recipient autocompleters on the message entry screen.
148 function activate_entmsg_autocompleters() {
149 new Ajax.Autocompleter('cc_id', 'cc_name_choices', 'cc_autocomplete', {} );
150 new Ajax.Autocompleter('bcc_id', 'bcc_name_choices', 'bcc_autocomplete', {} );
151 new Ajax.Autocompleter('recp_id', 'recp_name_choices', 'recp_autocomplete', {} );
154 function setupIconBar() {
155 if (!document.getElementById("switch")) {
158 _switchToRoomList = getTextContent(document.getElementById("rmlist_template"));
159 _switchToMenu = getTextContent(document.getElementById("mnlist_template"));
160 var switchSpan = document.getElementById("switch").firstChild;
161 if (switchSpan != null) {
162 setTextContent(switchSpan, _switchToRoomList);
163 $(switchSpan).observe('click', changeIconBarEvent);
164 var currentView = ctdlLocalPrefs.readPref("iconbar_view");
165 if (currentView != null) {
166 switchSpan.ctdlSwitchIconBarTo = currentView;
167 changeIconBar(switchSpan);
169 switchSpan.ctdlSwitchIconBarTo = "rooms";
172 var online_users = document.getElementById("online_users");
173 if (online_users.offsetParent != null && online_users.offsetTop > 0) {
174 new Ajax.PeriodicalUpdater('online_users', 'do_template?template=wholist_section', {method: 'get', frequency: 30});
177 function changeIconBarEvent(event) {
178 changeIconBar(event.target);
180 function changeIconBar(target) {
181 var switchTo = target.ctdlSwitchIconBarTo;
182 WCLog("Changing to: " + switchTo);
183 ctdlLocalPrefs.setPref("iconbar_view", target.ctdlSwitchIconBarTo);
184 if (switchTo == "rooms") {
185 switch_to_room_list();
186 setTextContent(target, _switchToMenu);
187 target.ctdlSwitchIconBarTo = "menu";
189 switch_to_menu_buttons();
190 setTextContent(target, _switchToRoomList);
191 target.ctdlSwitchIconBarTo = "rooms";
194 function switch_to_room_list() {
195 var roomlist = document.getElementById("roomlist");
196 var summary = document.getElementById("iconbar_menu");
197 if (!rooms || !floors || !roomlist) {
198 FillRooms(IconBarRoomList);
200 roomlist.className = roomlist.className.replace("hidden","");
201 summary.className += " hidden";
204 function switch_to_menu_buttons() {
205 if (roomlist != null) {
206 roomlist.className += "hidden";
208 var iconbar = document.getElementById("iconbar_menu");
209 iconbar.className = iconbar.className.replace("hidden","");
210 var roomlist = document.getElementById("roomlist");
211 roomlist.className += " hidden";
213 function IconBarRoomList() {
214 var currentExpanded = ctdlLocalPrefs.readPref("rooms_expanded");
215 var curRoomName = "";
216 if (document.getElementById("rmname")) {
217 curRoomName = getTextContent(document.getElementById("rmname"));
219 currentDropTargets = new Array();
220 var iconbar = document.getElementById("iconbar");
221 roomlist = document.getElementById("roomlist");
222 var ul = document.createElement("ul");
223 roomlist.appendChild(ul);
224 // Add mailbox, because they are special
225 var mailboxLI = document.createElement("li");
226 ul.appendChild(mailboxLI);
227 var mailboxSPAN = document.createElement("span");
228 var _mailbox = getTextContent(document.getElementById("mbox_template"));
229 mailboxSPAN.appendChild(document.createTextNode(_mailbox));
230 $(mailboxSPAN).observe('click', expandFloorEvent);
231 mailboxLI.appendChild(mailboxSPAN);
232 mailboxLI.className = "floor";
233 var mailboxUL = document.createElement("ul");
234 mailboxLI.appendChild(mailboxUL);
235 var mailboxRooms = GetMailboxRooms();
236 for(var i=0; i<mailboxRooms.length; i++) {
237 var room = mailboxRooms[i];
238 currentDropTargets.push(addRoomToList(mailboxUL, room, curRoomName));
240 if (currentExpanded != null && currentExpanded == _mailbox ) {
241 expandFloor(mailboxSPAN);
243 for(var a=0; a<floors.length; a++) {
244 var floor = floors[a];
245 var floornum = floor[0];
251 var floorLI = document.createElement("li");
252 ul.appendChild(floorLI);
253 var floorSPAN = document.createElement("span");
254 floorSPAN.appendChild(document.createTextNode(name));
255 $(floorSPAN).observe('click', expandFloorEvent);
256 floorLI.appendChild(floorSPAN);
257 floorLI.className = "floor";
258 var floorUL = document.createElement("ul");
259 floorLI.appendChild(floorUL);
260 var roomsForFloor = GetRoomsByFloorNum(floornum);
261 for(var b=0; b<roomsForFloor.length; b++) {
262 var room = roomsForFloor[b];
263 currentDropTargets.push(addRoomToList(floorUL, room, curRoomName));
265 if (currentExpanded != null && currentExpanded == name) {
266 expandFloor(floorSPAN);
272 function addRoomToList(floorUL,room, roomToEmphasize) {
273 var roomName = room[RN_ROOM_NAME];
274 var flag = room[RN_ROOM_FLAG];
275 var curView = room[RN_CUR_VIEW];
276 var view = room[RN_DEF_VIEW];
277 var isMailBox = ((flag & QR_MAILBOX) == QR_MAILBOX);
278 var hasNewMsgs = ((curView & UA_HASNEWMSGS) == UA_HASNEWMSGS);
279 var roomLI = document.createElement("li");
280 var roomA = document.createElement("a");
281 roomA.setAttribute("href","dotgoto?room="+roomName);
282 roomA.appendChild(document.createTextNode(roomName));
283 roomLI.appendChild(roomA);
284 floorUL.appendChild(roomLI);
285 var className = "room ";
286 if (view == VIEW_MAILBOX) {
287 className += "room-private"
288 } else if (view == VIEW_ADDRESSBOOK) {
289 className += "room-addr";
290 } else if (view == VIEW_CALENDAR || view == VIEW_CALBRIEF) {
291 className += "room-cal";
292 } else if (view == VIEW_TASKS) {
293 className += "room-tasks";
294 } else if (view == VIEW_NOTES) {
295 className += "room-notes";
297 className += "room-chat";
300 className += " room-newmsgs";
302 if (roomName == roomToEmphasize) {
303 className += " room-emphasized";
305 roomLI.setAttribute("class", className);
306 roomA.dropTarget = true;
307 roomA.dropHandler = roomListDropHandler;
311 function roomListDropHandler(target, dropped) {
312 if (dropped.getAttribute("citadel:msgid")) {
313 var room = getTextContent(target);
315 for(msgId in currentlyMarkedRows) { //defined in summaryview.js
318 var mvCommand = "g_cmd=MOVE " + msgIds + "|"+room+"|0";
319 new Ajax.Request('ajax_servcmd', {
321 parameters: mvCommand,
322 onComplete: deleteAllMarkedRows()});
325 function expandFloorEvent(event) {
326 expandFloor(event.target);
328 function expandFloor(target) {
329 if (target.nodeName.toLowerCase() != "span") {
330 return; // ignore clicks on child UL
332 ctdlLocalPrefs.setPref("rooms_expanded", target.firstChild.nodeValue);
333 var parentUL = target.parentNode;
334 if (currentlyExpandedFloor != null) {
335 currentlyExpandedFloor.className = currentlyExpandedFloor.className.replace("floor-expanded","");
337 parentUL.className = parentUL.className + " floor-expanded";
338 currentlyExpandedFloor = parentUL;
341 // These functions handle moving sticky notes around the screen by dragging them
343 var uid_of_note_being_dragged = 0;
344 var saved_cursor_style = 'default';
345 var note_was_dragged = 0;
347 function NotesDragMouseUp(evt) {
348 document.onmouseup = null;
349 document.onmousemove = null;
350 if (document.layers) {
351 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
354 d = $('note-' + uid_of_note_being_dragged);
355 d.style.cursor = saved_cursor_style;
357 // If any motion actually occurred, submit an ajax http call to record it to the server
358 if (note_was_dragged > 0) {
359 p = 'note_uid=' + uid_of_note_being_dragged
360 + '&left=' + d.style.left
361 + '&top=' + d.style.top
362 + '&r=' + CtdlRandomString();
372 uid_of_note_being_dragged = '';
376 function NotesDragMouseMove(evt) {
377 x = (ns6 ? evt.clientX : event.clientX);
378 x_increment = x - saved_x;
379 y = (ns6 ? evt.clientY : event.clientY);
380 y_increment = y - saved_y;
383 d = $('note-' + uid_of_note_being_dragged);
385 divTop = parseInt(d.style.top);
386 divLeft = parseInt(d.style.left);
388 d.style.top = (divTop + y_increment) + 'px';
389 d.style.left = (divLeft + x_increment) + 'px';
393 note_was_dragged = 1;
398 function NotesDragMouseDown(evt, uid) {
399 saved_x = (ns6 ? evt.clientX : event.clientX);
400 saved_y = (ns6 ? evt.clientY : event.clientY);
401 document.onmouseup = NotesDragMouseUp;
402 document.onmousemove = NotesDragMouseMove;
403 if (document.layers) {
404 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
406 uid_of_note_being_dragged = uid;
407 d = $('note-' + uid_of_note_being_dragged);
408 saved_cursor_style = d.style.cursor;
409 d.style.cursor = 'move';
410 return false; // disable the default action
414 // Called when the user clicks on the palette icon of a sticky note to change its color.
415 // It toggles the color selector visible or invisible.
417 function NotesClickPalette(evt, uid) {
418 uid_of_note_being_colored = uid;
419 d = $('palette-' + uid_of_note_being_colored);
421 if (d.style.display) {
422 if (d.style.display == 'none') {
423 d.style.display = 'block';
426 d.style.display = 'none';
430 d.style.display = 'block';
437 // Called when the user clicks on one of the colors in an open color selector.
438 // Sets the desired color and then closes the color selector.
440 function NotesClickColor(evt, uid, red, green, blue, notecolor, titlecolor) {
441 uid_of_note_being_colored = uid;
442 palette_button = $('palette-' + uid_of_note_being_colored);
443 note_div = $('note-' + uid_of_note_being_colored);
444 titlebar_div = $('titlebar-' + uid_of_note_being_colored);
446 // alert('FIXME red=' + red + ' green=' + green + ' blue=' + blue);
448 note_div.style.backgroundColor = notecolor;
449 titlebar_div.style.backgroundColor = titlecolor;
450 palette_button.style.display = 'none';
452 // submit an ajax http call to record it to the server
453 p = 'note_uid=' + uid_of_note_being_colored
457 + '&r=' + CtdlRandomString();
470 // These functions handle resizing sticky notes by dragging the resize handle
472 var uid_of_note_being_resized = 0;
473 var saved_cursor_style = 'default';
474 var note_was_resized = 0;
476 function NotesResizeMouseUp(evt) {
477 document.onmouseup = null;
478 document.onmousemove = null;
479 if (document.layers) {
480 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
483 d = $('note-' + uid_of_note_being_resized);
484 d.style.cursor = saved_cursor_style;
486 // If any motion actually occurred, submit an ajax http call to record it to the server
487 if (note_was_resized > 0) {
488 p = 'note_uid=' + uid_of_note_being_resized
489 + '&width=' + d.style.width
490 + '&height=' + d.style.height
491 + '&r=' + CtdlRandomString();
501 uid_of_note_being_resized = '';
502 return false; // disable the default action
505 function NotesResizeMouseMove(evt) {
506 x = (ns6 ? evt.clientX : event.clientX);
507 x_increment = x - saved_x;
508 y = (ns6 ? evt.clientY : event.clientY);
509 y_increment = y - saved_y;
512 d = $('note-' + uid_of_note_being_resized);
514 divTop = parseInt(d.style.height);
515 divLeft = parseInt(d.style.width);
517 newHeight = divTop + y_increment;
518 if (newHeight < 50) newHeight = 50;
520 newWidth = divLeft + x_increment;
521 if (newWidth < 50) newWidth = 50;
523 d.style.height = newHeight + 'px';
524 d.style.width = newWidth + 'px';
528 note_was_resized = 1;
529 return false; // disable the default action
533 function NotesResizeMouseDown(evt, uid) {
534 saved_x = (ns6 ? evt.clientX : event.clientX);
535 saved_y = (ns6 ? evt.clientY : event.clientY);
536 document.onmouseup = NotesResizeMouseUp;
537 document.onmousemove = NotesResizeMouseMove;
538 if (document.layers) {
539 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
541 uid_of_note_being_resized = uid;
542 d = $('note-' + uid_of_note_being_resized);
543 saved_cursor_style = d.style.cursor;
544 d.style.cursor = 'move';
545 return false; // disable the default action
549 function DeleteStickyNote(evt, uid, confirmation_prompt) {
550 uid_of_note_being_deleted = uid;
551 d = $('note-' + uid_of_note_being_deleted);
553 if (confirm(confirmation_prompt)) {
556 // submit an ajax http call to delete it on the server
557 p = 'note_uid=' + uid_of_note_being_deleted
559 + '&r=' + CtdlRandomString();
570 function ctdl_ts_getInnerText(el) {
571 if (typeof el == "string") return el;
572 if (typeof el == "undefined") { return el };
573 if (el.innerText) return el.innerText; //Not needed but it is faster
576 var cs = el.childNodes;
578 for (var i = 0; i < l; i++) {
579 switch (cs[i].nodeType) {
580 case 1: //ELEMENT_NODE
581 str += ts_getInnerText(cs[i]);
584 str += cs[i].nodeValue;
592 // Place a gradient loadscreen on an element, e.g to use before Ajax.updater
593 function CtdlLoadScreen(elementid) {
594 var elem = document.getElementById(elementid);
595 elem.innerHTML = "<div align=center><br><table border=0 cellpadding=10 bgcolor=\"#ffffff\"><tr><td><img src=\"static/throbber.gif\" /><font color=\"#AAAAAA\"> Loading....</font></td></tr></table><br /></div>";
600 // Pop open the address book (target_input is the INPUT field to populate)
602 function PopOpenAddressBook(target_input) {
603 $('address_book_popup').style.display = 'block';
604 p = 'target_input=' + target_input + '&r=' + CtdlRandomString();
606 'address_book_popup_middle_div',
607 'display_address_book_middle_div',
616 function PopulateAddressBookInnerDiv(which_addr_book, target_input) {
617 $('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\"> Loading....</font></td></tr></table><br /></div>";
618 p = 'which_addr_book=' + which_addr_book
619 + '&target_input=' + target_input
620 + '&r=' + CtdlRandomString();
622 'address_book_inner_div',
623 'display_address_book_inner_div',
631 // What happens when a contact is selected from the address book popup
632 // (populate the specified target)
634 function AddContactsToTarget(target, whichaddr) {
635 while (whichaddr.selectedIndex != -1) {
636 if (target.value.length > 0) {
637 target.value = target.value + ', ';
639 target.value = target.value + whichaddr.value;
640 whichaddr.options[whichaddr.selectedIndex].selected = false;
644 // Respond to a meeting invitation
645 function RespondToInvitation(question_divname, title_divname, msgnum, cal_partnum, sc) {
646 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
647 new Ajax.Updater(title_divname, 'respond_to_request', { method: 'post', parameters: p } );
648 Effect.Fade(question_divname, { duration: 0.5 });
651 // Handle a received RSVP
652 function HandleRSVP(question_divname, title_divname, msgnum, cal_partnum, sc) {
653 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
654 new Ajax.Updater(title_divname, 'handle_rsvp', { method: 'post', parameters: p } );
655 Effect.Fade(question_divname, { duration: 0.5 });
657 /* var fakeMouse = document.createEvent("MouseEvents");
658 fakeMouse.initMouseEvent("click", true, true, window,
659 0,0,0,0,0, false, false, false, false, 0, null); */
660 // TODO: Collapse into one function
661 function toggleTaskDtStart(event) {
662 var checkBox = $('nodtstart');
663 var checkBoxTime = $('dtstart_time_assoc');
664 var dtstart = document.getElementById("dtstart");
665 var dtstart_date = document.getElementById("dtstart_date");
666 var dtstart_time = document.getElementById("dtstart_time");
667 if (checkBox.checked) {
668 dtstart_date.style.visibility = "hidden";
669 dtstart_time.style.visibility = "hidden";
671 if (checkBoxTime.checked) {
672 dtstart_time.style.visibility = "visible";
674 dtstart_time.style.visibility = "hidden";
676 dtstart_date.style.visibility = "visible";
677 if (dtstart.value.length == 0)
678 dtstart.dpck._initCurrentDate();
681 function toggleTaskDue(event) {
682 var checkBox = $('nodue');
683 var checkBoxTime = $('due_time_assoc');
684 var due = document.getElementById("due");
685 var due_date = document.getElementById("due_date");
686 var due_time = document.getElementById("due_time");
687 if (checkBox.checked) {
688 due_date.style.visibility = "hidden";
689 due_time.style.visibility = "hidden";
691 if (checkBoxTime.checked) {
692 due_time.style.visibility = "visible";
694 due_time.style.visibility = "hidden";
696 due_date.style.visibility = "visible";
697 if (due.value.length == 0)
698 due.dpck._initCurrentDate();
701 function ToggleTaskDateOrNoDateActivate(event) {
702 var dtstart = document.getElementById("nodtstart");
703 if (dtstart != null) {
704 toggleTaskDtStart(null);
706 $('nodtstart').observe('click', toggleTaskDtStart);
707 $('dtstart_time_assoc').observe('click', toggleTaskDtStart);
708 $('nodue').observe('click', toggleTaskDue);
709 $('due_time_assoc').observe('click', toggleTaskDue);
712 function TaskViewGatherCategoriesFromTable() {
713 var table = $('taskview');
716 function attachDatePicker(relative) {
717 var dpck = new DatePicker({
719 language: 'en', //wclang.substr(0,2),
720 disableFutureDate: false,
721 dateFormat: [ ["yyyy", "mm", "dd"], "-"],
724 document.getElementById(relative).dpck = dpck; // attach a ref to it
726 function eventEditAllDay() {
727 var allDayCheck = document.getElementById("alldayevent");
728 var dtend_time = document.getElementById("dtend_time");
729 var dtstart_time = document.getElementById("dtstart_time");
730 if(allDayCheck.checked) {
731 dtstart_time.style.visibility = "hidden";
732 dtend_time.style.visibility = "hidden";
734 dtstart_time.style.visibility = "visible";
735 dtend_time.style.visibility = "visible";
739 // Functions which handle show/hide of various elements in the recurrence editor
741 function RecurrenceShowHide() {
743 if ($('is_recur').checked) {
744 $('rrule_div').style.display = 'block';
747 $('rrule_div').style.display = 'none';
750 if ($('freq_selector').selectedIndex == 4) {
751 $('weekday_selector').style.display = 'block';
754 $('weekday_selector').style.display = 'none';
757 if ($('freq_selector').selectedIndex == 5) {
758 $('monthday_selector').style.display = 'block';
761 $('monthday_selector').style.display = 'none';
764 if ($('rrend_count').checked) {
765 $('rrcount').disabled = false;
768 $('rrcount').disabled = true;
771 if ($('rrend_until').checked) {
772 $('rruntil').disabled = false;
775 $('rruntil').disabled = true;
778 if ($('rrmonthtype_mday').checked) {
779 $('rrmday').disabled = false;
782 $('rrmday').disabled = true;
785 if ($('rrmonthtype_wday').checked) {
786 $('rrmweek').disabled = false;
787 $('rrmweekday').disabled = false;
790 $('rrmweek').disabled = true;
791 $('rrmweekday').disabled = true;
794 if ($('freq_selector').selectedIndex == 6) {
795 $('yearday_selector').style.display = 'block';
798 $('yearday_selector').style.display = 'none';
801 $('ymday').innerHTML = 'XXXX-' + $('dtstart').value.substr(5);
802 $('rrmday').innerHTML = $('dtstart').value.substr(8);
804 if ($('rryeartype_ywday').checked) {
805 $('rrymweek').disabled = false;
806 $('rrymweekday').disabled = false;
807 $('rrymonth').disabled = false;
810 $('rrymweek').disabled = true;
811 $('rrymweekday').disabled = true;
812 $('rrymonth').disabled = true;
818 // Enable or disable the 'check attendee availability' button depending on whether
819 // the attendees list is empty
820 function EnableOrDisableCheckButton()
822 if ($('attendees_box').value.length == 0) {
823 $('check_button').disabled = true;
826 $('check_button').disabled = false;
833 function launchChat(event) {
834 window.open('chat', 'ctdl_chat_window', 'toolbar=no,location=no,directories=no,copyhistory=no,status=no,scrollbars=yes,resizable=yes');
837 function WCLog(msg) {
838 if (!!window.console && !!console.log) {
840 } else if (!!window.opera && !!opera.postError) {
841 opera.postError(msg);
843 wc_log += msg + "\r\n";
847 function fixMissingCSSTable(elems) {
848 if (elems[0] == null || elems[1] == null) {
851 if (elems[0].getStyle("display") != "table-cell") {
852 var parentNode = elems[0].parentNode;
853 var table = document.createElement("table");
854 table.style.width = "100%";
855 var tbody = document.createElement("tbody");
856 table.appendChild(tbody);
857 var tr = document.createElement("tr");
858 tbody.appendChild(tr);
859 parentNode.appendChild(table);
860 for(var i=0; i<elems.length; i++) {
861 parentNode.removeChild(elems[i]);
862 var td = document.createElement("td");
863 td.appendChild(elems[i]);
868 function fixbanner() {
869 // Use prototype api methods here
870 var elems = [$('room_banner'),$('actiondiv')];
871 fixMissingCSSTable(elems);
873 Event.observe(window, 'resize', makeContentScrollable);
874 makeContentScrollable();
877 function makeContentScrollable() {
878 if (document.getElementById("banner")
879 && document.getElementById("content")
880 && !document.getElementById("summary_view")) {
881 WCLog("makeContentScrollable");
882 document.body.style.overflowY="hidden";
883 var global = $("global");
884 global.className += "scrollable";
885 var content = document.getElementById("content");
886 var banner = document.getElementById("banner");
887 var bannerHeight = banner.offsetHeight;
888 banner.style.width="100%";
889 var bannerPercent = (bannerHeight/document.viewport.getHeight())*100;
890 //banner.style.height=bannerPercent+"%";
891 content.style.overflowY="scroll";
892 //content.style.top=bannerPercent+"%";
893 content.style.height=(100-bannerPercent)+"%";
894 content.style.right="0px";
897 function fixOffsetBanner() {
898 var banner = document.getElementById("banner");
899 if (banner.offsetLeft > 0) {
900 var viewportWidth = document.viewport.getWidth();
901 var iconbarWidth = document.getElementById("iconbar").offsetWidth;
902 var contentDiv = document.getElementById("content");
903 var newContentWidth = viewportWidth-iconbarWidth;
904 contentDiv.style.width = newContentWidth+"px";
907 /** Attempt to stop overflowing in x-axis in IE6 */
908 function resizeViewport() {
909 var documentWidth = 0;
910 var viewportWidth = document.viewport.getWidth();
911 var iconbar = $('iconbar');
912 var global = $('global');
913 if (iconbar == null || global == null || document.documentElement == null) {
916 if (typeof window.offsetWidth != 'undefined') {
917 documentWidth = window.offsetWidth;
919 documentWidth = document.documentElement.offsetWidth;
921 if (documentWidth > viewportWidth) {
922 WCLog("resizeViewport");
923 document.documentElement.style.width = viewportWidth+"px";
924 document.documentElement.style.overflowX = "hidden";
925 //viewportWidth = 0.98 * viewportWidth;
926 var newIconBarSize = 0.16 * viewportWidth;
927 var newContentSize = viewportWidth - newIconBarSize;
928 iconbar.style.width = newIconBarSize+"px";
929 global.style.width = newContentSize+"px";
933 function RefreshSMTPqueueDisplay() {
934 new Ajax.Updater('smtpqueue_inner_div',
935 'display_smtpqueue_inner_div', { method: 'get',
936 parameters: Math.random() } );
939 function DeleteSMTPqueueMsg(msgnum1, msgnum2) {
943 parameters: 'g_cmd=DELE ' + msgnum1 + ',' + msgnum2,
944 onComplete: RefreshSMTPqueueDisplay()