4 // JavaScript function library for WebCit.
10 var room_is_trash = 0;
12 var currentlyExpandedFloor = null;
15 var _switchToRoomList = "switch to room list";
16 var _switchToMenu = "switch to menu";
18 var currentDropTarget = null;
20 var supportsAddEventListener = (!!document.addEventListener);
21 var today = new Date();
25 if (document.all) {browserType = "ie"}
26 if (window.navigator.userAgent.toLowerCase().match("gecko")) {
29 var ns6=document.getElementById&&!document.all;
30 Event.observe(window, 'load', ToggleTaskDateOrNoDateActivate);
31 Event.observe(window, 'load', taskViewActivate);
32 Event.observe(window, 'load', fixbanner);
33 Event.observe(window, 'load', resizeViewport);
34 Event.observe(window, 'resize', resizeViewport);
35 //document.observe("dom:loaded", setupPrefEngine);
36 document.observe("dom:loaded", setupIconBar);
37 document.observe('dom:loaded', function() { if (!!document.getElementById("ib_chat_launch")) { $('ib_chat_launch').observe('click', launchChat); } });
38 function CtdlRandomString() {
39 return((Math.random()+'').substr(3));
41 function strcmp ( str1, str2 ) {
42 // http://kevin.vanzonneveld.net
43 // + original by: Waldo Malqui Silva
44 // + input by: Steve Hilder
45 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
46 // + revised by: gorthaur
47 // * example 1: strcmp( 'waldo', 'owald' );
49 // * example 2: strcmp( 'owald', 'waldo' );
52 return ( ( str1 == str2 ) ? 0 : ( ( str1 > str2 ) ? 1 : -1 ) );
55 function emptyElement(element) {
56 childNodes = element.childNodes;
57 for(var i=0; i<childNodes.length; i++) {
59 element.removeChild(childNodes[i]);
61 WCLog(e+"|"+e.description);
65 /** Implements superior internet explorer 'extract all child text from element' feature'. Falls back on buggy, patent violating standardized method */
66 function getTextContent(element) {
67 if (element.textContent == undefined) {
68 return element.innerText;
70 return element.textContent;
72 /** Same reasons as above */
73 function setTextContent(element, textContent) {
74 if(element.textContent == undefined) {
75 element.innerText = textContent;
77 element.textContent = textContent;
81 // We love string tokenizers.
82 function extract_token(source_string, token_num, delimiter) {
84 var extracted_string = source_string;
87 for (i=0; i<token_num; ++i) {
88 var j = extracted_string.indexOf(delimiter);
90 extracted_string = extracted_string.substr(j+1);
95 j = extracted_string.indexOf(delimiter);
97 extracted_string = extracted_string.substr(0, j);
100 return extracted_string;
103 function CtdlSpawnContextMenu(event, source) {
104 // remove any existing menus
105 disintergrateContextMenus(null);
106 var x = event.clientX-10; // cut a few pixels out so our mouseout works right
107 var y = event.clientY-10;
108 var contextDIV = document.createElement("div");
109 contextDIV.setAttribute("id", "ctdlContextMenu");
110 document.body.appendChild(contextDIV);
111 var sourceChildren = source.childNodes;
112 for(var j=0; j<sourceChildren.length; j++) {
113 contextDIV.appendChild(sourceChildren[j].cloneNode(true));
115 var leftRule = "left: "+x+"px;";
116 contextDIV.setAttribute("style", leftRule);
117 contextDIV.setAttribute("actual", leftRule);
118 contextDIV.style.top = y+"px";
119 contextDIV.style.display = "block";
120 $(contextDIV).observe('mouseout',disintergrateContextMenus);
122 function disintergrateContextMenus(event) {
123 var contextMenu = document.getElementById("ctdlContextMenu");
125 contextMenu.parentNode.removeChild(contextMenu);
127 Event.stopObserving(document,'click',disintergrateContextMenus);
129 // This code handles the popups for important-messages.
130 function hide_imsg_popup() {
131 if (browserType == "gecko") {
132 document.poppedLayer = eval('document.getElementById(\'important_message\')');
134 else if (browserType == "ie") {
135 document.poppedLayer = eval('document.all[\'important_message\']');
138 document.poppedLayer = eval('document.layers[\'`important_message\']');
141 document.poppedLayer.style.visibility = "hidden";
145 // This function activates the ajax-powered recipient autocompleters on the message entry screen.
146 function activate_entmsg_autocompleters() {
147 new Ajax.Autocompleter('cc_id', 'cc_name_choices', 'cc_autocomplete', {} );
148 new Ajax.Autocompleter('bcc_id', 'bcc_name_choices', 'bcc_autocomplete', {} );
149 new Ajax.Autocompleter('recp_id', 'recp_name_choices', 'recp_autocomplete', {} );
152 function setupIconBar() {
153 if (!document.getElementById("switch")) {
156 _switchToRoomList = getTextContent(document.getElementById("rmlist_template"));
157 _switchToMenu = getTextContent(document.getElementById("mnlist_template"));
158 var switchSpan = document.getElementById("switch").firstChild;
159 if (switchSpan != null) {
160 setTextContent(switchSpan, _switchToRoomList);
161 $(switchSpan).observe('click', changeIconBarEvent);
162 var currentView = ctdlLocalPrefs.readPref("iconbar_view");
163 if (currentView != null) {
164 switchSpan.ctdlSwitchIconBarTo = currentView;
165 changeIconBar(switchSpan);
167 switchSpan.ctdlSwitchIconBarTo = "rooms";
170 var online_users = document.getElementById("online_users");
171 if (online_users.offsetParent != null && online_users.offsetTop > 0) {
172 new Ajax.PeriodicalUpdater('online_users', 'do_template?template=wholist_section', {method: 'get', frequency: 30});
175 function changeIconBarEvent(event) {
176 changeIconBar(event.target);
178 function changeIconBar(target) {
179 var switchTo = target.ctdlSwitchIconBarTo;
180 WCLog("Changing to: " + switchTo);
181 ctdlLocalPrefs.setPref("iconbar_view", target.ctdlSwitchIconBarTo);
182 if (switchTo == "rooms") {
183 switch_to_room_list();
184 setTextContent(target, _switchToMenu);
185 target.ctdlSwitchIconBarTo = "menu";
187 switch_to_menu_buttons();
188 setTextContent(target, _switchToRoomList);
189 target.ctdlSwitchIconBarTo = "rooms";
192 function switch_to_room_list() {
193 var roomlist = document.getElementById("roomlist");
194 var summary = document.getElementById("iconbar_menu");
195 if (!rooms || !floors || !roomlist) {
196 FillRooms(IconBarRoomList);
198 roomlist.className = roomlist.className.replace("hidden","");
199 summary.className += " hidden";
202 function switch_to_menu_buttons() {
203 if (roomlist != null) {
204 roomlist.className += "hidden";
206 var iconbar = document.getElementById("iconbar_menu");
207 iconbar.className = iconbar.className.replace("hidden","");
208 var roomlist = document.getElementById("roomlist");
209 roomlist.className += " hidden";
211 function IconBarRoomList() {
212 var currentExpanded = ctdlLocalPrefs.readPref("rooms_expanded");
213 var curRoomName = "";
214 if (document.getElementById("rmname")) {
215 curRoomName = getTextContent(document.getElementById("rmname"));
217 currentDropTargets = new Array();
218 var iconbar = document.getElementById("iconbar");
219 roomlist = document.getElementById("roomlist");
220 var ul = document.createElement("ul");
221 roomlist.appendChild(ul);
222 // Add mailbox, because they are special
223 var mailboxLI = document.createElement("li");
224 ul.appendChild(mailboxLI);
225 var mailboxSPAN = document.createElement("span");
226 var _mailbox = getTextContent(document.getElementById("mbox_template"));
227 mailboxSPAN.appendChild(document.createTextNode(_mailbox));
228 $(mailboxSPAN).observe('click', expandFloorEvent);
229 mailboxLI.appendChild(mailboxSPAN);
230 mailboxLI.className = "floor";
231 var mailboxUL = document.createElement("ul");
232 mailboxLI.appendChild(mailboxUL);
233 var mailboxRooms = GetMailboxRooms();
234 for(var i=0; i<mailboxRooms.length; i++) {
235 var room = mailboxRooms[i];
236 currentDropTargets.push(addRoomToList(mailboxUL, room, curRoomName));
238 if (currentExpanded != null && currentExpanded == _mailbox ) {
239 expandFloor(mailboxSPAN);
241 for(var a=0; a<floors.length; a++) {
242 var floor = floors[a];
243 var floornum = floor[0];
245 var floorLI = document.createElement("li");
246 ul.appendChild(floorLI);
247 var floorSPAN = document.createElement("span");
248 floorSPAN.appendChild(document.createTextNode(name));
249 $(floorSPAN).observe('click', expandFloorEvent);
250 floorLI.appendChild(floorSPAN);
251 floorLI.className = "floor";
252 var floorUL = document.createElement("ul");
253 floorLI.appendChild(floorUL);
254 var roomsForFloor = GetRoomsByFloorNum(floornum);
255 for(var b=0; b<roomsForFloor.length; b++) {
256 var room = roomsForFloor[b];
257 currentDropTargets.push(addRoomToList(floorUL, room, curRoomName));
259 if (currentExpanded != null && currentExpanded == name) {
260 expandFloor(floorSPAN);
265 function addRoomToList(floorUL,room, roomToEmphasize) {
266 var roomName = room[RN_ROOM_NAME];
267 var flag = room[RN_ROOM_FLAG];
268 var curView = room[RN_CUR_VIEW];
269 var view = room[RN_DEF_VIEW];
270 var isMailBox = ((flag & QR_MAILBOX) == QR_MAILBOX);
271 var hasNewMsgs = ((curView & UA_HASNEWMSGS) == UA_HASNEWMSGS);
272 var roomLI = document.createElement("li");
273 var roomA = document.createElement("a");
274 roomA.setAttribute("href","dotgoto?room="+roomName);
275 roomA.appendChild(document.createTextNode(roomName));
276 roomLI.appendChild(roomA);
277 floorUL.appendChild(roomLI);
278 var className = "room ";
279 if (view == VIEW_MAILBOX) {
280 className += "room-private"
281 } else if (view == VIEW_ADDRESSBOOK) {
282 className += "room-addr";
283 } else if (view == VIEW_CALENDAR || view == VIEW_CALBRIEF) {
284 className += "room-cal";
285 } else if (view == VIEW_TASKS) {
286 className += "room-tasks";
287 } else if (view == VIEW_NOTES) {
288 className += "room-notes";
290 className += "room-chat";
293 className += " room-newmsgs";
295 if (roomName == roomToEmphasize) {
296 className += " room-emphasized";
298 roomLI.setAttribute("class", className);
299 roomA.dropTarget = true;
300 roomA.dropHandler = roomListDropHandler;
304 function roomListDropHandler(target, dropped) {
305 if (dropped.ctdlMsgId) {
306 var room = getTextContent(target);
308 for(msgId in currentlyMarkedRows) { //defined in summaryview.js
311 var mvCommand = "g_cmd=MOVE " + msgIds + "|"+room+"|0";
312 new Ajax.Request('ajax_servcmd', {
314 parameters: mvCommand,
315 onComplete: deleteAllMarkedRows()});
318 function expandFloorEvent(event) {
319 expandFloor(event.target);
321 function expandFloor(target) {
322 if (target.nodeName.toLowerCase() != "span") {
323 return; // ignore clicks on child UL
325 ctdlLocalPrefs.setPref("rooms_expanded", target.firstChild.nodeValue);
326 var parentUL = target.parentNode;
327 if (currentlyExpandedFloor != null) {
328 currentlyExpandedFloor.className = currentlyExpandedFloor.className.replace("floor-expanded","");
330 parentUL.className = parentUL.className + " floor-expanded";
331 currentlyExpandedFloor = parentUL;
334 // These functions handle moving sticky notes around the screen by dragging them
336 var uid_of_note_being_dragged = 0;
337 var saved_cursor_style = 'default';
338 var note_was_dragged = 0;
340 function NotesDragMouseUp(evt) {
341 document.onmouseup = null;
342 document.onmousemove = null;
343 if (document.layers) {
344 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
347 d = $('note-' + uid_of_note_being_dragged);
348 d.style.cursor = saved_cursor_style;
350 // If any motion actually occurred, submit an ajax http call to record it to the server
351 if (note_was_dragged > 0) {
352 p = 'note_uid=' + uid_of_note_being_dragged
353 + '&left=' + d.style.left
354 + '&top=' + d.style.top
355 + '&r=' + CtdlRandomString();
365 uid_of_note_being_dragged = '';
369 function NotesDragMouseMove(evt) {
370 x = (ns6 ? evt.clientX : event.clientX);
371 x_increment = x - saved_x;
372 y = (ns6 ? evt.clientY : event.clientY);
373 y_increment = y - saved_y;
376 d = $('note-' + uid_of_note_being_dragged);
378 divTop = parseInt(d.style.top);
379 divLeft = parseInt(d.style.left);
381 d.style.top = (divTop + y_increment) + 'px';
382 d.style.left = (divLeft + x_increment) + 'px';
386 note_was_dragged = 1;
391 function NotesDragMouseDown(evt, uid) {
392 saved_x = (ns6 ? evt.clientX : event.clientX);
393 saved_y = (ns6 ? evt.clientY : event.clientY);
394 document.onmouseup = NotesDragMouseUp;
395 document.onmousemove = NotesDragMouseMove;
396 if (document.layers) {
397 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
399 uid_of_note_being_dragged = uid;
400 d = $('note-' + uid_of_note_being_dragged);
401 saved_cursor_style = d.style.cursor;
402 d.style.cursor = 'move';
403 return false; // disable the default action
407 // Called when the user clicks on the palette icon of a sticky note to change its color.
408 // It toggles the color selector visible or invisible.
410 function NotesClickPalette(evt, uid) {
411 uid_of_note_being_colored = uid;
412 d = $('palette-' + uid_of_note_being_colored);
414 if (d.style.display) {
415 if (d.style.display == 'none') {
416 d.style.display = 'block';
419 d.style.display = 'none';
423 d.style.display = 'block';
430 // Called when the user clicks on one of the colors in an open color selector.
431 // Sets the desired color and then closes the color selector.
433 function NotesClickColor(evt, uid, red, green, blue, notecolor, titlecolor) {
434 uid_of_note_being_colored = uid;
435 palette_button = $('palette-' + uid_of_note_being_colored);
436 note_div = $('note-' + uid_of_note_being_colored);
437 titlebar_div = $('titlebar-' + uid_of_note_being_colored);
439 // alert('FIXME red=' + red + ' green=' + green + ' blue=' + blue);
441 note_div.style.backgroundColor = notecolor;
442 titlebar_div.style.backgroundColor = titlecolor;
443 palette_button.style.display = 'none';
445 // submit an ajax http call to record it to the server
446 p = 'note_uid=' + uid_of_note_being_colored
450 + '&r=' + CtdlRandomString();
463 // These functions handle resizing sticky notes by dragging the resize handle
465 var uid_of_note_being_resized = 0;
466 var saved_cursor_style = 'default';
467 var note_was_resized = 0;
469 function NotesResizeMouseUp(evt) {
470 document.onmouseup = null;
471 document.onmousemove = null;
472 if (document.layers) {
473 document.releaseEvents(Event.MOUSEUP | Event.MOUSEMOVE);
476 d = $('note-' + uid_of_note_being_resized);
477 d.style.cursor = saved_cursor_style;
479 // If any motion actually occurred, submit an ajax http call to record it to the server
480 if (note_was_resized > 0) {
481 p = 'note_uid=' + uid_of_note_being_resized
482 + '&width=' + d.style.width
483 + '&height=' + d.style.height
484 + '&r=' + CtdlRandomString();
494 uid_of_note_being_resized = '';
495 return false; // disable the default action
498 function NotesResizeMouseMove(evt) {
499 x = (ns6 ? evt.clientX : event.clientX);
500 x_increment = x - saved_x;
501 y = (ns6 ? evt.clientY : event.clientY);
502 y_increment = y - saved_y;
505 d = $('note-' + uid_of_note_being_resized);
507 divTop = parseInt(d.style.height);
508 divLeft = parseInt(d.style.width);
510 d.style.height = (divTop + y_increment) + 'px';
511 d.style.width = (divLeft + x_increment) + 'px';
515 note_was_resized = 1;
516 return false; // disable the default action
520 function NotesResizeMouseDown(evt, uid) {
521 saved_x = (ns6 ? evt.clientX : event.clientX);
522 saved_y = (ns6 ? evt.clientY : event.clientY);
523 document.onmouseup = NotesResizeMouseUp;
524 document.onmousemove = NotesResizeMouseMove;
525 if (document.layers) {
526 document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);
528 uid_of_note_being_resized = uid;
529 d = $('note-' + uid_of_note_being_resized);
530 saved_cursor_style = d.style.cursor;
531 d.style.cursor = 'move';
532 return false; // disable the default action
536 function DeleteStickyNote(evt, uid, confirmation_prompt) {
537 uid_of_note_being_deleted = uid;
538 d = $('note-' + uid_of_note_being_deleted);
540 if (confirm(confirmation_prompt)) {
543 // submit an ajax http call to delete it on the server
544 p = 'note_uid=' + uid_of_note_being_deleted
546 + '&r=' + CtdlRandomString();
557 function ctdl_ts_getInnerText(el) {
558 if (typeof el == "string") return el;
559 if (typeof el == "undefined") { return el };
560 if (el.innerText) return el.innerText; //Not needed but it is faster
563 var cs = el.childNodes;
565 for (var i = 0; i < l; i++) {
566 switch (cs[i].nodeType) {
567 case 1: //ELEMENT_NODE
568 str += ts_getInnerText(cs[i]);
571 str += cs[i].nodeValue;
579 // Place a gradient loadscreen on an element, e.g to use before Ajax.updater
580 function CtdlLoadScreen(elementid) {
581 var elem = document.getElementById(elementid);
582 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>";
587 // Pop open the address book (target_input is the INPUT field to populate)
589 function PopOpenAddressBook(target_input) {
590 $('address_book_popup').style.display = 'block';
591 p = 'target_input=' + target_input + '&r=' + CtdlRandomString();
593 'address_book_popup_middle_div',
594 'display_address_book_middle_div',
603 function PopulateAddressBookInnerDiv(which_addr_book, target_input) {
604 $('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>";
605 p = 'which_addr_book=' + which_addr_book
606 + '&target_input=' + target_input
607 + '&r=' + CtdlRandomString();
609 'address_book_inner_div',
610 'display_address_book_inner_div',
618 // What happens when a contact is selected from the address book popup
619 // (populate the specified target)
621 function AddContactsToTarget(target, whichaddr) {
622 while (whichaddr.selectedIndex != -1) {
623 if (target.value.length > 0) {
624 target.value = target.value + ', ';
626 target.value = target.value + whichaddr.value;
627 whichaddr.options[whichaddr.selectedIndex].selected = false;
631 // Respond to a meeting invitation
632 function RespondToInvitation(question_divname, title_divname, msgnum, cal_partnum, sc) {
633 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
634 new Ajax.Updater(title_divname, 'respond_to_request', { method: 'post', parameters: p } );
635 Effect.Fade(question_divname, { duration: 0.5 });
638 // Handle a received RSVP
639 function HandleRSVP(question_divname, title_divname, msgnum, cal_partnum, sc) {
640 p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ;
641 new Ajax.Updater(title_divname, 'handle_rsvp', { method: 'post', parameters: p } );
642 Effect.Fade(question_divname, { duration: 0.5 });
644 /* var fakeMouse = document.createEvent("MouseEvents");
645 fakeMouse.initMouseEvent("click", true, true, window,
646 0,0,0,0,0, false, false, false, false, 0, null); */
647 // TODO: Collapse into one function
648 function toggleTaskDtStart(event) {
649 var checkBox = $('nodtstart');
650 var checkBoxTime = $('dtstart_time');
651 dtStart = document.getElementById("dtstart");
652 dtStartHour = document.getElementById("dtstart_hour");
653 dtStartMinute = document.getElementById("dtstart_minute");
654 if (checkBox.checked) {
655 dtStart.disabled = true;
656 dtStartHour.disabled = true;
657 dtStartMinute.disabled = true;
658 dtStart.style.textDecoration = "line-through";
660 dtStart.disabled = false;
661 if (checkBoxTime.checked) {
662 dtStartHour.disabled = false;
663 dtStartMinute.disabled = false;
665 dtStartHour.disabled = true;
666 dtStartMinute.disabled = true;
668 dtStart.style.textDecoration = "";
669 if (dtStart.value.length == 0)
670 dtStart.dpck._initCurrentDate();
673 function toggleTaskDue(event) {
674 var checkBox = $('nodue');
675 var checkBoxTime = $('due_time');
676 dueField = document.getElementById("due");
677 dueFieldHour = document.getElementById("due_hour");
678 dueFieldMinute = document.getElementById("due_minute");
679 if (checkBox.checked) {
680 dueField.disabled = true;
681 dueFieldHour.disabled = true;
682 dueFieldMinute.disabled = true;
683 dueField.style.textDecoration = "line-through";
685 dueField.disabled = false;
686 if (checkBoxTime.checked) {
687 dueFieldHour.disabled = false;
688 dueFieldMinute.disabled = false;
690 dueFieldHour.disabled = true;
691 dueFieldMinute.disabled = true;
693 dueField.style.textDecoration = "";
694 if (dueField.value.length == 0)
695 dueField.dpck._initCurrentDate();
698 function ToggleTaskDateOrNoDateActivate(event) {
699 var dtstart = document.getElementById("nodtstart");
700 if (dtstart != null) {
701 toggleTaskDtStart(null);
703 $('nodtstart').observe('click', toggleTaskDtStart);
704 $('dtstart_time').observe('click', toggleTaskDtStart);
705 $('nodue').observe('click', toggleTaskDue);
706 $('due_time').observe('click', toggleTaskDue);
709 function TaskViewGatherCategoriesFromTable() {
710 var table = $('taskview');
713 function attachDatePicker(relative) {
714 var dpck = new DatePicker({
716 language: 'en', //wclang.substr(0,2),
717 disableFutureDate: false,
718 dateFormat: [ ["yyyy", "mm", "dd"], "-"],
721 document.getElementById(relative).dpck = dpck; // attach a ref to it
723 function eventEditAllDay() {
724 var allDayCheck = document.getElementById("alldayevent");
725 var dtend= document.getElementById("dtendcell");
726 if(allDayCheck.checked) {
727 //dtend.disabled = true;
728 dtend.style.textDecoration = "line-through";
730 //dtend_day.disabled = false;
731 dtend.style.textDecoration = "";
735 // Functions which handle show/hide of various elements in the recurrence editor
737 function RecurrenceShowHide() {
739 if ($('is_recur').checked) {
740 $('rrule_div').style.display = 'block';
743 $('rrule_div').style.display = 'none';
746 if ($('freq_selector').selectedIndex == 4) {
747 $('weekday_selector').style.display = 'block';
750 $('weekday_selector').style.display = 'none';
753 if ($('freq_selector').selectedIndex == 5) {
754 $('monthday_selector').style.display = 'block';
757 $('monthday_selector').style.display = 'none';
760 if ($('rrend_count').checked) {
761 $('rrcount').disabled = false;
764 $('rrcount').disabled = true;
767 if ($('rrend_until').checked) {
768 $('rruntil').disabled = false;
771 $('rruntil').disabled = true;
774 if ($('rrmonthtype_mday').checked) {
775 $('rrmday').disabled = false;
778 $('rrmday').disabled = true;
781 if ($('rrmonthtype_wday').checked) {
782 $('rrmweek').disabled = false;
783 $('rrmweekday').disabled = false;
786 $('rrmweek').disabled = true;
787 $('rrmweekday').disabled = true;
790 if ($('freq_selector').selectedIndex == 6) {
791 $('yearday_selector').style.display = 'block';
794 $('yearday_selector').style.display = 'none';
797 $('ymday').innerHTML = 'XXXX-' + $('dtstart').value.substr(5);
798 $('rrmday').innerHTML = $('dtstart').value.substr(8);
800 if ($('rryeartype_ywday').checked) {
801 $('rrymweek').disabled = false;
802 $('rrymweekday').disabled = false;
803 $('rrymonth').disabled = false;
806 $('rrymweek').disabled = true;
807 $('rrymweekday').disabled = true;
808 $('rrymonth').disabled = true;
814 // Enable or disable the 'check attendee availability' button depending on whether
815 // the attendees list is empty
816 function EnableOrDisableCheckButton()
818 if ($('attendees_box').value.length == 0) {
819 $('check_button').disabled = true;
822 $('check_button').disabled = false;
829 function launchChat(event) {
830 window.open('chat', 'ctdl_chat_window', 'toolbar=no,location=no,directories=no,copyhistory=no,status=no,scrollbars=yes,resizable=yes');
833 function WCLog(msg) {
834 if (!!window.console && !!console.log) {
836 } else if (!!window.opera && !!opera.postError) {
837 opera.postError(msg);
839 wc_log += msg + "\r\n";
843 function fixMissingCSSTable(elems) {
844 if (elems[0] == null || elems[1] == null) {
847 if (elems[0].getStyle("display") != "table-cell") {
848 var parentNode = elems[0].parentNode;
849 var table = document.createElement("table");
850 table.style.width = "100%";
851 var tbody = document.createElement("tbody");
852 table.appendChild(tbody);
853 var tr = document.createElement("tr");
854 tbody.appendChild(tr);
855 parentNode.appendChild(table);
856 for(var i=0; i<elems.length; i++) {
857 parentNode.removeChild(elems[i]);
858 var td = document.createElement("td");
859 td.appendChild(elems[i]);
864 function fixbanner() {
865 // Use prototype api methods here
866 var elems = [$('room_banner'),$('actiondiv')];
867 fixMissingCSSTable(elems);
869 Event.observe(window, 'resize', makeContentScrollable);
870 makeContentScrollable();
873 function makeContentScrollable() {
874 if (document.getElementById("banner")
875 && document.getElementById("content")
876 && !document.getElementById("summary_view")) {
877 WCLog("makeContentScrollable");
878 document.body.style.overflowY="hidden";
879 var global = $("global");
880 global.className += "scrollable";
881 var content = document.getElementById("content");
882 var banner = document.getElementById("banner");
883 var bannerHeight = banner.offsetHeight;
884 banner.style.width="100%";
885 var bannerPercent = (bannerHeight/document.viewport.getHeight())*100;
886 //banner.style.height=bannerPercent+"%";
887 content.style.overflowY="scroll";
888 //content.style.top=bannerPercent+"%";
889 content.style.height=(100-bannerPercent)+"%";
890 content.style.right="0px";
893 function fixOffsetBanner() {
894 var banner = document.getElementById("banner");
895 if (banner.offsetLeft > 0) {
896 var viewportWidth = document.viewport.getWidth();
897 var iconbarWidth = document.getElementById("iconbar").offsetWidth;
898 var contentDiv = document.getElementById("content");
899 var newContentWidth = viewportWidth-iconbarWidth;
900 contentDiv.style.width = newContentWidth+"px";
903 /** Attempt to stop overflowing in x-axis in IE6 */
904 function resizeViewport() {
905 var documentWidth = 0;
906 var viewportWidth = document.viewport.getWidth();
907 var iconbar = $('iconbar');
908 var global = $('global');
909 if (iconbar == null || global == null || document.documentElement == null) {
912 if (typeof window.offsetWidth != 'undefined') {
913 documentWidth = window.offsetWidth;
915 documentWidth = document.documentElement.offsetWidth;
917 if (documentWidth > viewportWidth) {
918 WCLog("resizeViewport");
919 document.documentElement.style.width = viewportWidth+"px";
920 document.documentElement.style.overflowX = "hidden";
921 //viewportWidth = 0.98 * viewportWidth;
922 var newIconBarSize = 0.16 * viewportWidth;
923 var newContentSize = viewportWidth - newIconBarSize;
924 iconbar.style.width = newIconBarSize+"px";
925 global.style.width = newContentSize+"px";